Created
September 23, 2016 02:30
-
-
Save orodio/37dc7feb7619294624890d6699a22bcc to your computer and use it in GitHub Desktop.
Lambda Calc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
λf.(λx.f(xx))(λx.f(xx)) | |
ZERO = λfx.x | f -> x -> x | |
ONE = λfx.fx | f -> x -> f(x) | |
TWO = λfx.f(fx) | f -> x -> f(f(x)) | |
THREE = λfx.f(f(fx)) | f -> x -> f(f(f(x))) | |
SUCC = λnfx.nfx | n -> f -> x -> n(f)(x) | |
ADD = λmnfx.mf(nfx) || λmn.n succ m | m -> n -> f -> x -> m(n(f))(x) | |
MULt = λmnfx.m(nf)x || λmnf.m(nf) | m -> n -> f -> m(n(f)) | |
PRED = λnfx.n(λgh.h(gf))(λu.x)(λu.u) | n -> f -> x -> (g -> h -> h(g(f)))(u -> x)(u -> u) | |
TRUE = λab.a | a -> b -> a | |
FALSE = λab.b | a -> b -> b | |
IF = λpab.pab | p -> a -> b -> p(a)(b) | |
AND = λpq.pqp | p -> q -> p(q)(p) | |
OR = λpq.ppq | p -> q -> p(p)(q) | |
NOT = λpab.pba | p -> a -> b -> p(b)(a) | |
XOR = λab.a(NOT b)b | a -> b -> a(NOT(b))(b) | |
ISZERO = λn.(n (λx.FALSE) TRUE) | n -> n(x -> FALSE)(TRUE) | |
LEQ = <= = λmn.(ISZERO (MINUS m n)) | |
EQ = == = λmn.(AND (LEQ m n) (LEQ n m)) | |
IF QUIBIT DEAD ALIVE | |
λpab.pab QUIBIT DEAD ALIVE | |
λab.(QUIBIT a b) DEAD ALIVE | |
λb.(QUIBIT DEAD b) ALIVE | |
QUIBIT DEAD ALIVE | |
QUIBIT = TRUE = λab.a | QUBIT = FALSE = λab.b | |
QUIBIT DEAD ALIVE | QUIBIT DEAD ALIVE | |
λab.a DEAD ALIVE | λab.b DEAD ALIVE | |
λb.DEAD ALIVE | λb.b ALIVE | |
DEAD | ALIVE | |
DEAD = FALSE | |
ALIVE = TRUE | |
QUBIT DEAD ALIVE | QUBIT DEAD ALIVE | |
TRUE FALSE TRUE | FALSE FALSE TRUE | |
λab.a FALSE TRUE | λab.b FALSE TRUE | |
λb.FALSE TRUE | λb.b TRUE | |
FALSE | TRUE | |
Y = λf.(λx.f(xx))(λx.f(xx)) | f -> (x -> f(x(x)))(x -> f(x(x))) | |
var rawr = (n) -> | |
n == 0 | |
? 0 | |
: n * rawr(n-1) | |
FACT = λfn.(IF (ISZERO n) ONE (MULTI n (f f (PRED n)))) | |
FACT FACT ZERO | |
λn.(IF (ISZERO n) ONE (MULTI n (FACT FACT (PRED n)))) ZERO | |
IF (ISZERO ZERO) ONE (MULTI n (FACT FACT (PRED n))) | |
ISZERO ZERO | |
ZERO λx.FALSE TRUE | |
λfx.x λx.FALSE TRUE | |
λx.x TRUE | |
TRUE | |
IF TRUE ONE (MULTI ZERO (FACT FACT (PRED ZERO))) | |
λpab.pab TRUE ONE (MULTI ZERO FACT (FACT (PRED ZERO))) | |
λab.(TRUE a b) ONE (MULTI ZERO FACT (PRED ZERO))) | |
λb.(TRUE ONE b) (MULTI ZERO FACT (FACT (PRED ZERO))) | |
TRUE ONE (MULTI ZERO (FACT FACT (PRED ZERO))) | |
λab.a ONE (MULTI ZERO (FACT FACT (PRED ZERO))) | |
λb.ONE (MULTI ZERO (FACT FACT (PRED ZERO))) | |
ONE | |
FACT FACT ONE | |
λn.(IF (ISZERO n) ZERO (MULTI n (FACT FACT (PRED n)))) ONE | |
IF (ISZERO ONE) ZERO (MULTI ONE (FACT FACT (PRED ONE))) | |
IF FALSE ZERO (MULTI ONE (FACT FACT (PRED ONE))) | |
MULTI ONE (FACT FACT (PRED ONE)) | |
MULTI ONE (FACT FACT ZERO) | |
MULTI ONE ONE | |
ONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment