{"id":15409719,"url":"https://github.com/whiteblackgoose/lambdacalculusfsharp","last_synced_at":"2025-04-19T06:39:41.607Z","repository":{"id":140733494,"uuid":"395776918","full_name":"WhiteBlackGoose/LambdaCalculusFSharp","owner":"WhiteBlackGoose","description":"λ calculus library made purely in and for F#","archived":false,"fork":false,"pushed_at":"2023-06-07T14:32:39.000Z","size":33041,"stargazers_count":33,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T19:16:12.748Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://lambda.wbg.gg","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WhiteBlackGoose.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-13T19:49:43.000Z","updated_at":"2025-02-23T03:46:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"03049be0-2b52-4778-b94a-e2df0bb610b4","html_url":"https://github.com/WhiteBlackGoose/LambdaCalculusFSharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteBlackGoose%2FLambdaCalculusFSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteBlackGoose%2FLambdaCalculusFSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteBlackGoose%2FLambdaCalculusFSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteBlackGoose%2FLambdaCalculusFSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WhiteBlackGoose","download_url":"https://codeload.github.com/WhiteBlackGoose/LambdaCalculusFSharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249191341,"owners_count":21227547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T16:41:07.498Z","updated_at":"2025-04-19T06:39:41.573Z","avatar_url":"https://github.com/WhiteBlackGoose.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"./.github/logo_transparent.png\" width=\"200\" /\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e  \n\u003ch1 align=\"center\"\u003eλ calculus in F#\u003c/h1\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ci\u003e\n        Library for lambda calculus made purely in and for F#\n    \u003c/i\u003e\n\u003c/p\u003e\n\n\u003e The λ-calculus is, at heart, a simple notation for functions and application. The main ideas are applying a function to an argument and forming functions by abstraction. Despite its sparse syntax, the expressiveness and flexibility of the λ-calculus make it a cornucopia of logic and mathematics. [**(c)**](https://plato.stanford.edu/entries/lambda-calculus/)\n\nThe library serves no production purpose and made exclusively out of academic interest. It has a [web app](https://whiteblackgoose.github.io/LambdaCalculusFSharp/) made for demonstration.\n\n## Syntax of λ-calculus\n\nRules:\n- Variables are single-character lower-case Latin letters.\n- Lambda starts with `\\`, then is followed by 1 or more variable, then a dot (`.`), then expression.\n- Associativity is left-sided: `xyz` is `(xy)z`.\n- A nested lambda can be shortcuted: `\\x.\\y.\\z.xyz` is the same as `\\xyz.xyz`.\n- Symbol `λ` can be used instead of `\\`, but is not essential.\n\nExamples:\n- `x` - an expression of one free variable x\n- `xy` - `y` applied to `x`\n- `\\x.x` - an identity\n- `\\x.xx` - a lambda which returns its only parameter applied to itself\n- `(\\x.x)y` - `y` applied to identity (will return `y` after beta reduction)\n- `(\\x.xx)(\\x.xx)` - simple example of beta-irreducible expression\n\n## Library API\n\nExpression is defined as following:\n```fs\ntype Expression =\n    | Variable of char\n    | Lambda of Head : Variable * Body : Expression\n    | Applied of Lambda : Expression * Argument : Expression\n```\nin `LambdaCalculus.Atoms`.\n\nIn the same module `LambdaCalculus.Atoms` there are \n- `alphaEqual` or `αEqual`: `Expression -\u003e Expression -\u003e bool` compares two expressions up to lambdas parameter names\n- `betaReduce` or `βReduce`: `Expression -\u003e Expression` performs beta-reduction, that is, simplification of an expression\n(starting from bottom, replaces parameters of lambdas in their bodies with the applied expressions)\n- `etaReduce` or `ηReduce`: `Expression -\u003e expression` performs eta-reduction, that is, removing redundant abstractions (`\\x.ex` -\u003e `e`)\n- `substitute`: `Variable -\u003e Expression -\u003e Expression -\u003e Expression` replaces the given variable with a given expression. In case\nof conflicts between it and a local variable in a lambda, it will alpha-convert the lambda's parameter to a new name.\n\nIn the module `LambdaCalculus.Parsing` there is `parse` which takes a string as an argument, and returns a `Result` of\n`Expression` and `string`.\n\n## Basic functions\n\nTaken from [Wikipedia](https://en.wikipedia.org/wiki/Church_encoding#Church_numerals).\n\n#### Numbers\n\n| Number | Lambda  |\n|--------|---------|\n| 0      | `\\fx.x` |\n| 1      | `\\fx.fx` |\n| 2      | `\\fx.f(fx)` |\n| 3      | `\\fx.f(f(fx))` |\n| 4      | `\\fx.f(f(f(fx)))` |\n| 5      | `\\fx.f(f(f(f(fx))))` |\n| 6      | `\\fx.f(f(f(f(f(fx)))))` |\n| 7      | `\\fx.f(f(f(f(f(f(fx))))))` |\n| 8      | `\\fx.f(f(f(f(f(f(f(fx)))))))` |\n| 9      | `\\fx.f(f(f(f(f(f(f(f(fx))))))))` |\n\n#### Arithmetic operations\n\n| Operation | Lambda |\n|-----------|--------|\n| Succ      | `\\nfx.f(nfx)` |\n| Plus      | `\\mnfx.mf(nfx)` |\n| Mult      | `\\mnfx.m(nf)x` |\n| Exp       | `\\mn.nm` |\n| Pred      | `\\nfx.n(\\gh.h(gf))(\\u.x)(\\u.u)` |\n\n\n## Fun facts\n\nThe library is made in pure functional programming. Even the parser has no exceptions, early returns, for-loops.\nThe logic is implemented with recursion, pattern matching, and computation expressions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhiteblackgoose%2Flambdacalculusfsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhiteblackgoose%2Flambdacalculusfsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhiteblackgoose%2Flambdacalculusfsharp/lists"}