@@ -18,34 +18,33 @@ namespace Cslib
1818
1919universe u
2020
21- variable {Var : Type u}
22-
23-
2421namespace LambdaCalculus.LocallyNameless.Untyped.Term
2522
23+ variable {Var : Type u} {t t' : Term Var}
24+
2625open FullBeta
2726
2827attribute [grind =] Finset.union_singleton
2928
3029/-- A term is strongly normalizing if every reduction sequence terminates at some point.
3130 This is ensured by the following type as inductive data must always be finite. -/
3231inductive SN {α} : Term α → Prop
33- | sn t : (∀ (t' : Term α), ( t ⭢βᶠ t') → SN t') → SN t
32+ | sn t : (∀ t', t ⭢βᶠ t' → SN t') → SN t
3433
3534attribute [scoped grind .] SN.sn
3635
3736/-- A single β-reduction step preserves strong normalization. -/
3837@ [aesop safe]
39- lemma sn_step {t t' : Term Var} (t_st_t' : t ⭢βᶠ t') (sn_t : SN t) : SN t' := by
38+ lemma sn_step (t_st_t' : t ⭢βᶠ t') (sn_t : SN t) : SN t' := by
4039 cases sn_t; grind
4140
4241/-- Multiple β-reduction steps also preserve strong normalization. -/
4342@ [aesop safe]
44- lemma sn_steps {t t' : Term Var} (t_st_t' : t ↠βᶠ t') (sn_t : SN t) : SN t' := by
45- induction t_st_t' with grind[sn_step]
43+ lemma sn_steps (t_st_t' : t ↠βᶠ t') (sn_t : SN t) : SN t' := by
44+ induction t_st_t' with grind [sn_step]
4645
4746/-- Free variables are strongly normalizing. -/
48- lemma sn_fvar {x : Var} : SN (Term. fvar x) := by
47+ lemma sn_fvar {x : Var} : SN (fvar x) := by
4948 constructor
5049 intro t' hstep
5150 cases hstep
@@ -72,9 +71,7 @@ lemma sn_app (t s : Term Var)
7271
7372
7473/-- The left side of a strongly normalizing application is strongly normalizing. -/
75- lemma sn_app_left (M N : Term Var)
76- (lc_N : Term.LC N)
77- (sn_MN : SN (M.app N)) :
74+ lemma sn_app_left (M N : Term Var) (lc_N : Term.LC N) (sn_MN : SN (M.app N)) :
7875 SN M := by
7976 generalize Heq : M.app N = P
8077 rw[Heq] at sn_MN
@@ -91,12 +88,10 @@ lemma sn_app_left (M N : Term Var)
9188 · rfl
9289
9390/-- The right side of a strongly normalizing application is strongly normalizing. -/
94- lemma sn_app_right (M N : Term Var)
95- (lc_N : Term.LC M)
96- (sn_MN : SN (M.app N)) :
91+ lemma sn_app_right (M N : Term Var) (lc_N : Term.LC M) (sn_MN : SN (M.app N)) :
9792 SN N := by
9893 generalize Heq : M.app N = P
99- rw[Heq] at sn_MN
94+ rw [Heq] at sn_MN
10095 revert M N
10196 induction sn_MN
10297 · case sn P h_sn ih =>
@@ -112,29 +107,27 @@ lemma sn_app_right (M N : Term Var)
112107
113108/-- A neutral term is a term of the form v t₁ … t_n where
114109 v is a variable and t₁ … t_n are strongly normalizing terms. -/
115- inductive neutral : Term Var → Prop
110+ inductive Neutral : Term Var → Prop
116111/-- Just a bound variable is neutral. -/
117- | bvar : ∀ n, neutral (Term. bvar n)
112+ | bvar : ∀ n, Neutral ( bvar n)
118113/-- Just a free variable is neutral. -/
119- | fvar : ∀ x, neutral (Term. fvar x)
114+ | fvar : ∀ x, Neutral ( fvar x)
120115/-- Applying a strongly normalizing term to a neutral term yields a neutral term. -/
121- | app : ∀ t1 t2, neutral t1 → SN t2 → neutral (Term. app t1 t2)
116+ | app : ∀ t1 t2, Neutral t1 → SN t2 → Neutral ( app t1 t2)
122117
123- attribute [scoped grind .] neutral .bvar neutral .fvar neutral .app
118+ attribute [scoped grind .] Neutral .bvar Neutral .fvar Neutral .app
124119
125120/-- Neutral terms only reduce to other neutral terms in a single step -/
126- lemma neutral_step {t t' : Term Var}
127- (Hneut : neutral t) (Hstep : t ⭢βᶠ t') : neutral t' := by
121+ lemma neutral_step (Hneut : Neutral t) (Hstep : t ⭢βᶠ t') : Neutral t' := by
128122 induction Hneut generalizing t' <;> cases Hstep <;> try grind [sn_step]
129123 · contradiction
130124
131125/-- Neutral terms only reduce to other neutral terms in multiple steps -/
132- lemma neutral_steps {t t' : Term Var}
133- (Hneut : neutral t) (Hsteps : t ↠βᶠ t') : neutral t' := by
126+ lemma neutral_steps (Hneut : Neutral t) (Hsteps : t ↠βᶠ t') : Neutral t' := by
134127 induction Hsteps <;> grind [neutral_step]
135128
136129/-- Neutral terms are strongly normalizing. -/
137- lemma sn_neutral {t : Term Var} (Hneut : neutral t) : SN t := by
130+ lemma sn_neutral (Hneut : Neutral t) : SN t := by
138131 induction Hneut
139132 · case bvar n => constructor; intro t' hstep; cases hstep
140133 · case fvar x => constructor; intro t' hstep; cases hstep
@@ -145,36 +138,32 @@ lemma sn_neutral {t : Term Var} (Hneut : neutral t) : SN t := by
145138 contradiction
146139
147140/-- A lambda abstraction is strongly normalizing if its body is strongly normalizing. -/
148- lemma sn_abs [DecidableEq Var] [HasFresh Var] {M N : Term Var}
149- (sn_MN : SN (M ^ N)) (lc_N : LC N) : SN (Term. abs M) := by
141+ lemma sn_abs [DecidableEq Var] [HasFresh Var] {M N : Term Var} (sn_MN : SN (M ^ N)) (lc_N : LC N) :
142+ SN (abs M) := by
150143 generalize h : (M ^ N) = M_open at sn_MN
151144 revert N M
152145 induction sn_MN with
153146 | sn M_open h_sn ih =>
154- intro M N lc_N h
155- constructor
156- intro M' h_step
157- cases h_step with
158- | @abs h_M_red M' L H =>
159- specialize ih (M' ^ N)
160- rw[←h] at ih
161- apply ih
162- · apply FullBeta.step_open_cong_l <;> assumption
163- · assumption
164- · rfl
165-
166-
147+ intro M N lc_N h
148+ constructor
149+ intro M' h_step
150+ cases h_step with
151+ | @abs h_M_red M' L H =>
152+ specialize ih (M' ^ N)
153+ rw[←h] at ih
154+ apply ih
155+ · apply FullBeta.step_open_cong_l <;> assumption
156+ · assumption
157+ · rfl
167158
168159/-- A term of the form λ M N P_1 … P_n is strongly normalizing if
169160 1. N is strongly normalizing,
170161 1. M ^ N P₁ … Pₙ is strongly normalizing,
171162 1. N is locally closed,
172163 1. M ^ N P₁ … Pₙ is locally closed -/
173164lemma sn_abs_app_multiApp [DecidableEq Var] [HasFresh Var] {Ps} {M N : Term Var}
174- (sn_N : SN N)
175- (sn_MNPs : SN (multiApp (M ^ N) Ps))
176- (lc_N : LC N)
177- (lc_MNPs : LC (multiApp (M ^ N) Ps)) :
165+ (sn_N : SN N) (sn_MNPs : SN (multiApp (M ^ N) Ps))
166+ (lc_N : LC N) (lc_MNPs : LC (multiApp (M ^ N) Ps)) :
178167 SN (multiApp ((Term.abs M).app N) Ps) := by
179168 induction Ps
180169 · case nil =>
0 commit comments