LambdaCalculus 1.0.0-lambda
dotnet add package LambdaCalculus --version 1.0.0-lambda
NuGet\Install-Package LambdaCalculus -Version 1.0.0-lambda
<PackageReference Include="LambdaCalculus" Version="1.0.0-lambda" />
<PackageVersion Include="LambdaCalculus" Version="1.0.0-lambda" />
<PackageReference Include="LambdaCalculus" />
paket add LambdaCalculus --version 1.0.0-lambda
#r "nuget: LambdaCalculus, 1.0.0-lambda"
#:package LambdaCalculus@1.0.0-lambda
#addin nuget:?package=LambdaCalculus&version=1.0.0-lambda&prerelease
#tool nuget:?package=LambdaCalculus&version=1.0.0-lambda&prerelease
λ calculus in F#
Fun library for lambda calculus made purely in F#. It has a web app made for demonstration.
Syntax of λ-calculus
Rules:
- Variables are single-character lower-case Latin letters.
- Lambda starts with
\, then is followed by 1 or more variable, then a dot (.), then expression. Until wrapped with parentheses, the body of a lambda has a lower priority than()(e. g.\x.(x)(y)is the same as(\x.x)(y)). - Associativity is left-sided:
xyzis(xy)z. - A nested lambda can be shortcuted:
\x.\y.\z.xyzis the same as\xyz.xyz. - Symbol
λcan be used instead of\, but is not essential.
Examples:
x- an expression of one free variable xxy-yapplied tox\x.x- an identity\x.xx- a lambda which returns its only parameter applied to itself(\x.x)y-yapplied to identity (will returnyafter beta reduction)(\x.xx)(\x.xx)- simple example of beta-irreducible expression
Library API
Expression is defined as following:
type Expression =
| Variable of char
| Lambda of Head : Variable * Body : Expression
| Applied of Lambda : Expression * Argument : Expression
in LambdaCalculus.Atoms.
In the same module LambdaCalculus.Atoms there are
betaReduceorβReduce:Expression -> Expressionperforms beta-reduction, that is, simplification of an expression (starting from bottom, replaces parameters of lambdas in their bodies with the applied expressions)alphaEqualorαEqual:Expression -> Expression -> Expressioncompares two expressions up to lambdas parameter namessubstitute:char -> Expression -> Expression -> Expressionreplaces the given variable with a given expression. In case of conflicts between it and a local variable in a lambda, it will alpha-convert the lambda's parameter to a new name.
In the module LambdaCalculus.Parsing there is parse which takes a string as an argument, and returns a Result of
Expression and string.
Fun facts
The library is made in pure functional programming. Even the parser has no exceptions, early returns, for-loops. The logic is implemented with recursion, pattern matching, and computation expressions.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net5.0
- FSharp.Core (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-lambda | 333 | 8/14/2021 |
First release