Last active
September 5, 2024 22:57
-
-
Save VictorTaelin/40edfb3c30ac43bf4a7560dfcd8b4a97 to your computer and use it in GitHub Desktop.
Induction on Cedille (executable JS type checker on comments):
This file contains hidden or 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
-- Natural numbers | |
def Nat | |
{-Nat : Type} | |
{succ : {x : Nat} Nat} | |
{zero : Nat} | |
Nat | |
def succ | |
[n : Nat] | |
[-Nat : Type] | |
[succ : {x : Nat} Nat] | |
[zero : Nat] | |
(succ (n -Nat succ zero)) | |
def zero | |
[-Nat : Type] | |
[succ : {x : Nat} Nat] | |
[zero : Nat] | |
zero | |
-- Inductive hypothesis on natural numbers | |
def Ind <self : Nat> | |
{-Ind : {n : Nat} Type} | |
{step : {-n : Nat} {i : (Ind n)} (Ind (succ n))} | |
{base : (Ind zero)} | |
(Ind self) | |
def step [n : Ind] : Ind = (succ .n) & | |
[-Ind : {n : Nat} Type] | |
[step : {-n : Nat} {i : (Ind n)} (Ind (succ n))] | |
[base : (Ind zero)] | |
(step -.n (+n -Ind step base)) | |
def base : Ind = zero & | |
[-Ind : {n : Nat} Type] | |
[step : {-n : Nat} {i : (Ind n)} (Ind (succ n))] | |
[base : (Ind zero)] | |
base | |
def to_ind [n : Nat] | |
(n -Ind step base) | |
def ind_reflection [i : Ind] | |
let motive [n : Nat] | |
|.(to_ind n) = n| | |
let case_s [-n : Nat] [i : |.(to_ind n) = n|] | |
def cong [-A : Type] [-B : Type] [-x : A] [-y : A] [-e : |x = y|] [-f : {x : A} B] | |
(%k |(f x) = (f k)| e ($(f x) [x] x)) | |
(cong -Nat -Nat -.(to_ind n) -n -i -succ) | |
let case_z | |
($zero [x] x) | |
(+i -motive case_s case_z) | |
def ind_induction | |
[i : Ind] | |
[-P : {i : Ind} Type] | |
[S : {-i : Ind} {ih : (P i)} (P (step i))] | |
[Z : (P base)] | |
let motive [n : Nat] | |
(P (to_ind n)) | |
let case_s [-n : Nat] [ih : (P (to_ind n))] | |
(S -(to_ind n) ih) | |
let case_z | |
Z | |
(%i (P i) (ind_reflection i) (+i -motive case_s case_z)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Executable JS type checker: