Skip to content

Commit 133f1b3

Browse files
author
Virgil Marionneau
committed
Minor comments
1 parent 5485d01 commit 133f1b3

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

theories/LambdaCube/Term.v

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Inductive sort : Type :=
66
| Star : sort
77
| Box : sort.
88

9+
(* Terms of the Lambda Cube with n free variables.
10+
Variables are represented as De Bruijn levels.
11+
The free variable most recently introduced in
12+
a term with (n + 1) free variables has value n
13+
*)
914
Inductive term (n : nat) : Type :=
1015
| Var : {k | k < n} → term n
1116
| Pi : term n → term (S n) → term n
@@ -19,6 +24,7 @@ Arguments Abs {n}.
1924
Arguments App {n}.
2025
Arguments Srt {n}.
2126

27+
(* Execution contexts of the Lambda Cube with n free variables. *)
2228
Inductive ctx (n : nat) : Type :=
2329
| Hole : ctx n
2430
| PiL : ctx n → term (S n) → ctx n
@@ -46,9 +52,11 @@ Proof.
4652
apply le_unique.
4753
Qed.
4854

55+
(* Basic weakening renaming *)
4956
Definition weaken {k : nat} (i : {i | i < k}) : {i | i < S k} :=
5057
exist _ (proj1_sig i) (Nat.lt_lt_succ_r _ _ (proj2_sig i)).
5158

59+
(* Lifting of variable renamings *)
5260
Definition lift
5361
{k n : nat} (σ : {i | i < k} → {i | i < n})
5462
(i : {i | i < S k}) : {i | i < S n}
@@ -147,6 +155,7 @@ Fixpoint renK {k n : nat} (σ : {i | i < k} → {i | i < n}) (K : ctx k) : ctx n
147155
| AppR tm1 K => AppR (ren σ tm1) (renK σ K)
148156
end.
149157

158+
(* Plug a term in place of the hole in a context *)
150159
Fixpoint fill {n : nat} (K : ctx n) (t : term n) : term n :=
151160
match K with
152161
| Hole => t
@@ -212,7 +221,8 @@ Proof.
212221
intros i;
213222
apply lift_weaken.
214223
Qed.
215-
224+
225+
(* Lifting of variable substitutions *)
216226
Definition lift_bind {k n : nat} (σ : {i | i < k} → term n) (i : {i | i < S k}) : term (S n) :=
217227
match lt_dec (proj1_sig i) k with
218228
| left Hi => ren weaken (σ (exist _ (proj1_sig i) Hi))
@@ -248,6 +258,7 @@ Proof.
248258
- reflexivity.
249259
Qed.
250260

261+
(* Substitution of free variables inside a term *)
251262
Fixpoint bind {k n : nat} (σ : {i | i < k} → term n) (t : term k) : term n
252263
:=
253264
match t with
@@ -258,6 +269,7 @@ Fixpoint bind {k n : nat} (σ : {i | i < k} → term n) (t : term k) : term n
258269
| Srt s => Srt s
259270
end.
260271

272+
(* Substitution of free variables inside a context *)
261273
Fixpoint bindK {k n : nat} (σ : {i | i < k} → term n) (K : ctx k) : ctx n :=
262274
match K with
263275
| Hole => Hole
@@ -278,8 +290,6 @@ Lemma lift_bind_comp :
278290
Proof.
279291
Abort.
280292

281-
282-
283293
Lemma bind_ext :
284294
∀ {k n : nat}
285295
(σ1 σ2: {i | i < k} → term n)
@@ -321,7 +331,8 @@ Lemma bind_fill :
321331
bind σ (fill K t) = fill (bindK σ K) (bind σ t).
322332
Proof.
323333
Abort.
324-
334+
335+
(* Basic substitution capturing the free variable introduced last *)
325336
Definition bind_first {k : nat} (t : term k) (i : {i | i < S k}) : term k
326337
:=
327338
match lt_dec (proj1_sig i) k with

0 commit comments

Comments
 (0)