Kind/book/_OBLITERATE.kind2
2024-03-01 12:21:43 -03:00

60 lines
2.7 KiB
Plaintext

// Bool : * = ∀(P: *) ∀(s: P) ∀(z: P) P
T_BOOL = Kind.set
T_Bool = (Kind.all "P" Kind.set λP(Kind.all "t" P λt(Kind.all "f" P λf(P))))
// True : Bool = λP λt λf t
T_TRUE = T_Bool
T_True = (Kind.lam "P" λP(Kind.lam "t" λt(Kind.lam "f" λf(t))))
// False : Bool = λP λt λf f
T_FALSE = T_Bool
T_False = (Kind.lam "P" λP(Kind.lam "t" λt(Kind.lam "f" λf(f))))
// AND : ∀(x: Bool) ∀(y: Bool) Bool = λx λy (x Bool y False)
T_AND = (Kind.all "x" T_Bool λx(Kind.all "y" T_Bool λy(T_Bool)))
T_and = (Kind.lam "x" λx(Kind.lam "y" λy(Kind.app (Kind.app (Kind.app x T_Bool) y) T_False)))
// Nat : * = ∀(P: *) ∀(s: ∀(x: P) P) ∀(z: P) P
T_NAT = Kind.set
T_Nat = (Kind.all "P" Kind.set λP(Kind.all "s" (Kind.all "x" P λx(P)) λs(Kind.all "z" P λz(P))))
// exp : ∀(n: Nat) Nat = λn λm λP λs λz (m ∀(x:P)P (n P))
T_EXP = (Kind.all "n" T_Nat λn(Kind.all "m" T_Nat λm(T_Nat)))
T_exp = (Kind.lam "n" λn(Kind.lam "m" λm(Kind.lam "P" λP(Kind.app (Kind.app m (Kind.all "x" P λx(P))) (Kind.app n P)))))
// C2 : Nat = λs λz (s (s z))
T_C2 = T_Nat
T_c2 = (Kind.lam "P" λP(Kind.lam "s" λs(Kind.lam "z" λz(Kind.app s (Kind.app s z)))))
// C4 : Nat = λs λz (s (s (s (s z))))
T_C4 = T_Nat
T_c4 = (Kind.lam "P" λP(Kind.lam "s" λs(Kind.lam "z" λz(Kind.app s (Kind.app s (Kind.app s (Kind.app s z)))))))
// Equal : ∀(A: *) ∀(a: A) ∀(b: A) * = λA λa λb ∀(P: ∀(x: A) *) ∀(p: (P a)) (P b)
T_EQUAL = (Kind.all "P" Kind.set λA(Kind.all "a" A λa(Kind.all "b" A λb(Kind.set))))
T_Equal = (Kind.lam "A" λA(Kind.lam "a" λa(Kind.lam "b" λb(Kind.all "P" (Kind.all "x" A λx(Kind.set)) λP(Kind.all "p" (Kind.app P a) λp(Kind.app P b))))))
// refl : ∀(A: *) ∀(a: A) (Equal A a a) = λA λa λP λp p
T_REFL = (Kind.all "A" Kind.set λA(Kind.all "a" A λa(Kind.app (Kind.app (Kind.app T_Equal A) a) a)))
T_refl = (Kind.lam "A" λA(Kind.lam "a" λa(Kind.lam "P" λP(Kind.lam "p" λp p))))
// WORK : ∀(n: Nat) Bool = λn (n ∀(x:Bool)Bool λpλb(Bool.and (p b) (p b)) λx(x) True)
T_WORK = (Kind.all "n" T_Nat λn(T_Bool))
T_work = (Kind.lam "n" λn(Kind.app (Kind.app (Kind.app (Kind.app n (Kind.all "x" T_Bool λx(T_Bool)))
(Kind.lam "p" λp(Kind.lam "b" λb(Kind.app (Kind.app (Kind.ann T_and T_AND) (Kind.app p b)) (Kind.app p b)))))
(Kind.lam "x" λx(x)))
T_True))
// RESULT : Bool = (work c3)
T_RESULT = T_Bool
T_result = (Kind.app (Kind.ann T_work T_WORK) (Kind.app (Kind.app T_exp T_c2) T_c4))
// MAIN : (Equal Bool result True) = λP λrefl refl
T_MAIN = (Kind.app (Kind.app (Kind.app T_Equal T_Bool) T_result) T_True)
T_main = (Kind.lam "P" λP(Kind.lam "refl" λrefl(refl)))
// Checks if `(work 2^4)` is propositionally equal to `true`
_OBLITERATE
: String
= (~(Kind.check T_main T_MAIN Nat.zero) λx(String) λt("check") "error")