diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-02-13 20:00:02 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-02-13 20:00:02 -0700 |
commit | 0c476e92e1807928ffb30864126076ef4c6a0821 (patch) | |
tree | a4992161ce4b6203edffb5d78533e9c73e61e6f1 /src/utils/lambdas.ts | |
parent | 512c245466fad78106a046c1ea6233acdcc3e4de (diff) | |
download | compiling-the-lambda-calculus-0c476e92e1807928ffb30864126076ef4c6a0821.tar.gz compiling-the-lambda-calculus-0c476e92e1807928ffb30864126076ef4c6a0821.zip |
Diffstat (limited to 'src/utils/lambdas.ts')
-rw-r--r-- | src/utils/lambdas.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/utils/lambdas.ts b/src/utils/lambdas.ts new file mode 100644 index 0000000..ef6b399 --- /dev/null +++ b/src/utils/lambdas.ts @@ -0,0 +1,35 @@ +const succ = "(λ n.(λ f.(λ x.(f ((n f) x)))))"; +const zero = "(λ g.(λ y.y))"; +const one = "(λ g.(λ y.(g y)))"; +const two = "(λ g.(λ y.(g (g y))))"; +const three = "(λ g.(λ y.(g (g (g y)))))"; +const four = "(λ g.(λ y.(g (g (g (g y))))))"; +const five = "(λ g.(λ y.(g (g (g (g (g y)))))))"; +const mult = "(λ m.(λ n.(λ f.(m (n f)))))"; +const trueL = "(λ a.(λ b.a))"; +const falseL = "(λ a.(λ b.b))"; +const ifL = "(λ b.(λ n.(λ m.((b n) m))))"; +const iszero = "(λ num.((num (λ x.false)) true))"; +const not = "(λ b.((b false) true))"; +const and = "(λ b.(λ c.((b c) false)))"; +const or = "(λ b.(λ c.((b true) c)))"; +const Y = "(λ h.((λ z.(h (z z))) (λ z.(h (z z)))))"; + +export const baseDefinitions = { + iszero, + succ, + zero, + one, + two, + three, + four, + five, + mult, + true: trueL, + false: falseL, + if: ifL, + not, + and, + or, + Y, +}; |