-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathstlc_small.lean
76 lines (58 loc) · 1.9 KB
/
stlc_small.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def Ty : Type 1
:= ∀ (Ty : Type)
(ι : Ty)
(arr : Ty → Ty → Ty)
, Ty
def ι : Ty := λ _ ι _ => ι
def arr : Ty → Ty → Ty
:= λ A B Ty ι arr =>
arr (A Ty ι arr) (B Ty ι arr)
def Con : Type 1
:= ∀ (Con : Type)
(nil : Con)
(snoc : Con → Ty → Con)
, Con
def nil : Con
:= λ Con nil snoc => nil
def snoc : Con → Ty → Con
:= λ Γ A Con nil snoc => snoc (Γ Con nil snoc) A
def Var : Con → Ty → Type 1
:= λ Γ A =>
∀ (Var : Con → Ty → Type)
(vz : ∀ Γ A, Var (snoc Γ A) A)
(vs : ∀ Γ B A, Var Γ A → Var (snoc Γ B) A)
, Var Γ A
def vz {Γ A} : Var (snoc Γ A) A
:= λ Var vz vs => vz _ _
def vs {Γ B A} : Var Γ A → Var (snoc Γ B) A
:= λ x Var vz vs => vs _ _ _ (x Var vz vs)
def Tm : Con → Ty → Type 1
:= λ Γ A =>
∀ (Tm : Con → Ty → Type)
(var : ∀ Γ A , Var Γ A → Tm Γ A)
(lam : ∀ Γ A B , Tm (snoc Γ A) B → Tm Γ (arr A B))
(app : ∀ Γ A B , Tm Γ (arr A B) → Tm Γ A → Tm Γ B)
, Tm Γ A
def var {Γ A} : Var Γ A → Tm Γ A
:= λ x Tm var lam app =>
var _ _ x
def lam {Γ A B} : Tm (snoc Γ A) B → Tm Γ (arr A B)
:= λ t Tm var lam app =>
lam _ _ _ (t Tm var lam app)
def app {Γ A B} : Tm Γ (arr A B) → Tm Γ A → Tm Γ B
:= λ t u Tm var lam app =>
app _ _ _
(t Tm var lam app)
(u Tm var lam app)
def v0 {Γ A} : Tm (snoc Γ A) A
:= var vz
def v1 {Γ A B} : Tm (snoc (snoc Γ A) B) A
:= var (vs vz)
def v2 {Γ A B C} : Tm (snoc (snoc (snoc Γ A) B) C) A
:= var (vs (vs vz))
def v3 {Γ A B C D} : Tm (snoc (snoc (snoc (snoc Γ A) B) C) D) A
:= var (vs (vs (vs vz)))
def v4 {Γ A B C D E} : Tm (snoc (snoc (snoc (snoc (snoc Γ A) B) C) D) E) A
:= var (vs (vs (vs (vs vz))))
def test {Γ A} : Tm Γ (arr (arr A A) (arr A A))
:= lam (lam (app v1 (app v1 (app v1 (app v1 (app v1 (app v1 v0)))))))