chars int64 40 24k | content_type stringclasses 9
values | id stringlengths 13 64 | source stringclasses 5
values | subset stringclasses 31
values | text stringlengths 40 24k |
|---|---|---|---|---|---|
613 | leanexplore_declaration | leanexplore:388063 | leanexplore_sqlite | leanexplore_declarations | /-- Locally closed terms. -/
inductive LC : Term Var → Prop
| var : LC (fvar x)
| abs (L : Finset Var) : σ.LC → (∀ x ∉ L, LC (t₁ ^ᵗᵗ fvar x)) → LC (abs σ t₁)
| app : LC t₁ → LC t₂ → LC (app t₁ t₂)
| tabs (L : Finset Var) : σ.LC → (∀ X ∉ L, LC (t₁ ^ᵗᵞ .fvar X)) → LC (tabs σ t₁)
| tapp : LC t₁ → σ.LC → LC (tapp... |
77 | leanexplore_declaration | leanexplore:388065 | leanexplore_sqlite | leanexplore_declarations | | abs (L : Finset Var) : σ.LC → (∀ x ∉ L, LC (t₁ ^ᵗᵗ fvar x)) → LC (abs σ t₁) |
80 | leanexplore_declaration | leanexplore:388067 | leanexplore_sqlite | leanexplore_declarations | | tabs (L : Finset Var) : σ.LC → (∀ X ∉ L, LC (t₁ ^ᵗᵞ .fvar X)) → LC (tabs σ t₁) |
81 | leanexplore_declaration | leanexplore:388069 | leanexplore_sqlite | leanexplore_declarations | | let' (L : Finset Var) : LC t₁ → (∀ x ∉ L, LC (t₂ ^ᵗᵗ fvar x)) → LC (let' t₁ t₂) |
140 | leanexplore_declaration | leanexplore:388072 | leanexplore_sqlite | leanexplore_declarations | | case (L : Finset Var) :
LC t₁ →
(∀ x ∉ L, LC (t₂ ^ᵗᵗ fvar x)) →
(∀ x ∉ L, LC (t₃ ^ᵗᵗ fvar x)) →
LC (case t₁ t₂ t₃) |
262 | leanexplore_declaration | leanexplore:388073 | leanexplore_sqlite | leanexplore_declarations | /-- An opening (term to type) appearing in both sides of an equality of terms can be removed. -/
lemma openRec_ty_neq_eq (neq : X ≠ Y) (eq : t⟦Y ↝ σ⟧ᵗᵞ = t⟦Y ↝ σ⟧ᵗᵞ⟦X ↝ τ⟧ᵗᵞ) :
t = t⟦X ↝ τ⟧ᵗᵞ := by
induction t generalizing X Y <;> grind [Ty.openRec_neq_eq] |
195 | leanexplore_declaration | leanexplore:388074 | leanexplore_sqlite | leanexplore_declarations | /-- Elimination of mixed term and type opening. -/
@[scoped grind .]
lemma openRec_tm_ty_eq (eq : t⟦x ↝ s⟧ᵗᵗ = t⟦x ↝ s⟧ᵗᵗ⟦y ↝ δ⟧ᵗᵞ) : t = t⟦y ↝ δ⟧ᵗᵞ
:= by induction t generalizing x y <;> grind |
322 | leanexplore_declaration | leanexplore:388075 | leanexplore_sqlite | leanexplore_declarations | /-- A locally closed term is unchanged by type opening. -/
@[scoped grind =_]
lemma openRec_ty_lc {t : Term Var} (lc : t.LC) : t = t⟦X ↝ σ⟧ᵗᵞ := by
induction lc generalizing X with
| let' | case | tabs | abs =>
grind [fresh_exists <| free_union Var, Ty.openRec_lc, openRec_ty_neq_eq]
| _ => grind [Ty.openRec_l... |
566 | leanexplore_declaration | leanexplore:388076 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a type within a term. -/
@[scoped grind =]
def subst_ty (X : Var) (δ : Ty Var) : Term Var → Term Var
| bvar x => bvar x
| fvar x => fvar x
| abs σ t₁ => abs (σ [X := δ]) (subst_ty X δ t₁)
| app t₁ t₂ => app (subst_ty X δ t₁) (subst_ty X δ t₂)
| tabs σ t₁ => tabs (σ [X := δ]) (subst_ty X δ t₁)
| tapp... |
93 | leanexplore_declaration | leanexplore:388077 | leanexplore_sqlite | leanexplore_declarations | instance : HasSubstitution (Term Var) Var (Ty Var) where
subst t X δ := Term.subst_ty X δ t |
109 | leanexplore_declaration | leanexplore:388078 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind _=_]
lemma subst_ty_def : subst_ty (X : Var) (δ : Ty Var) (t : Term Var) = t[X := δ] := by rfl |
205 | leanexplore_declaration | leanexplore:388079 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a free type variable not present in a term leaves it unchanged. -/
lemma subst_ty_fresh (nmem : X ∉ t.fv_ty) (δ : Ty Var) : t = t [X := δ] :=
by induction t <;> grind [Ty.subst_fresh] |
293 | leanexplore_declaration | leanexplore:388080 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a locally closed type distributes with term opening to a type . -/
lemma openRec_ty_subst_ty (Y : ℕ) (t : Term Var) (σ : Ty Var) (lc : δ.LC) (X : Var) :
(t⟦Y ↝ σ⟧ᵗᵞ)[X := δ] = (t[X := δ])⟦Y ↝ σ[X := δ]⟧ᵗᵞ := by
induction t generalizing Y <;> grind [Ty.openRec_subst] |
221 | leanexplore_declaration | leanexplore:388081 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.openRec_ty_subst` to the first opening. -/
lemma open_ty_subst_ty (t : Term Var) (σ : Ty Var) (lc : δ.LC) (X : Var) :
(t ^ᵗᵞ σ)[X := δ] = t[X := δ] ^ᵗᵞ σ[X := δ] := openRec_ty_subst_ty 0 t σ lc X |
215 | leanexplore_declaration | leanexplore:388082 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.open_ty_subst` to free type variables. -/
lemma open_ty_subst_ty_var (t : Term Var) (neq : Y ≠ X) (lc : δ.LC) :
(t ^ᵗᵞ .fvar Y)[X := δ] = t[X := δ] ^ᵗᵞ .fvar Y := by grind [open_ty_subst_ty] |
289 | leanexplore_declaration | leanexplore:388083 | leanexplore_sqlite | leanexplore_declarations | /-- Opening a term to a type is equivalent to opening to a free variable and substituting. -/
lemma openRec_ty_subst_ty_intro (Y : ℕ) (t : Term Var) (nmem : X ∉ t.fv_ty) :
t⟦Y ↝ δ⟧ᵗᵞ = (t⟦Y ↝ Ty.fvar X⟧ᵗᵞ)[X := δ] := by
induction t generalizing X δ Y <;> grind [Ty.openRec_subst_intro] |
230 | leanexplore_declaration | leanexplore:388084 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.openRec_ty_subst_ty_intro` to the first opening. -/
lemma open_ty_subst_ty_intro (t : Term Var) (δ : Ty Var) (nmem : X ∉ t.fv_ty) :
t ^ᵗᵞ δ = (t ^ᵗᵞ Ty.fvar X)[X := δ] := openRec_ty_subst_ty_intro _ _ nmem |
557 | leanexplore_declaration | leanexplore:388085 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a term within a term. -/
@[scoped grind =]
def subst_tm (x : Var) (s : Term Var) : Term Var → Term Var
| bvar x => bvar x
| fvar y => if y = x then s else fvar y
| abs σ t₁ => abs σ (subst_tm x s t₁)
| app t₁ t₂ => app (subst_tm x s t₁) (subst_tm x s t₂)
| tabs σ t₁ => tabs σ (subst_tm x s t₁)
| tap... |
95 | leanexplore_declaration | leanexplore:388086 | leanexplore_sqlite | leanexplore_declarations | instance : HasSubstitution (Term Var) Var (Term Var) where
subst t x s := Term.subst_tm x s t |
111 | leanexplore_declaration | leanexplore:388087 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind _=_]
lemma subst_tm_def : subst_tm (x : Var) (s : Term Var) (t : Term Var) = t[x := s] := by rfl |
246 | leanexplore_declaration | leanexplore:388088 | leanexplore_sqlite | leanexplore_declarations | /-- An opening (term to term) appearing in both sides of an equality of terms can be removed. -/
lemma openRec_tm_neq_eq (neq : x ≠ y) (eq : t⟦y ↝ s₁⟧ᵗᵗ = t⟦y ↝ s₁⟧ᵗᵗ⟦x ↝ s₂⟧ᵗᵗ) :
t = t⟦x ↝ s₂⟧ᵗᵗ := by
induction t generalizing x y <;> grind |
177 | leanexplore_declaration | leanexplore:388089 | leanexplore_sqlite | leanexplore_declarations | /-- Elimination of mixed term and type opening. -/
lemma openRec_ty_tm_eq (eq : t⟦Y ↝ σ⟧ᵗᵞ = t⟦Y ↝ σ⟧ᵗᵞ⟦x ↝ s⟧ᵗᵗ) : t = t⟦x ↝ s⟧ᵗᵗ := by
induction t generalizing x Y <;> grind |
294 | leanexplore_declaration | leanexplore:388090 | leanexplore_sqlite | leanexplore_declarations | /-- A locally closed term is unchanged by term opening. -/
@[scoped grind =_]
lemma openRec_tm_lc (lc : t.LC) : t = t⟦x ↝ s⟧ᵗᵗ := by
induction lc generalizing x with
| let' | case | tabs | abs =>
grind [fresh_exists <| free_union Var, openRec_tm_neq_eq, openRec_ty_tm_eq]
| _ => grind |
189 | leanexplore_declaration | leanexplore:388091 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a free term variable not present in a term leaves it unchanged. -/
lemma subst_tm_fresh (nmem : x ∉ t.fv_tm) (s : Term Var) : t = t[x := s] := by
induction t <;> grind |
269 | leanexplore_declaration | leanexplore:388092 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a locally closed term distributes with term opening to a term. -/
lemma openRec_tm_subst_tm (y : ℕ) (t₁ t₂ : Term Var) (lc : s.LC) (x : Var) :
(t₁⟦y ↝ t₂⟧ᵗᵗ)[x := s] = (t₁[x := s])⟦y ↝ t₂[x := s]⟧ᵗᵗ := by
induction t₁ generalizing y <;> grind |
222 | leanexplore_declaration | leanexplore:388093 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.openRec_tm_subst_tm` to the first opening. -/
lemma open_tm_subst_tm (t₁ t₂ : Term Var) (lc : s.LC) (x : Var) :
(t₁ ^ᵗᵗ t₂)[x := s] = (t₁[x := s]) ^ᵗᵗ t₂[x := s] := openRec_tm_subst_tm 0 t₁ t₂ lc x |
222 | leanexplore_declaration | leanexplore:388094 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.openRec_tm_subst_tm` to free term variables. -/
lemma open_tm_subst_tm_var (t : Term Var) (neq : y ≠ x) (lc : s.LC) :
(t ^ᵗᵗ fvar y)[x := s] = (t[x := s]) ^ᵗᵗ fvar y := by grind [open_tm_subst_tm] |
270 | leanexplore_declaration | leanexplore:388095 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a locally closed type distributes with term opening to a term. -/
lemma openRec_tm_subst_ty (y : ℕ) (t₁ t₂ : Term Var) (δ : Ty Var) (X : Var) :
(t₁⟦y ↝ t₂⟧ᵗᵗ)[X := δ] = (t₁[X := δ])⟦y ↝ t₂[X := δ]⟧ᵗᵗ := by
induction t₁ generalizing y <;> grind |
221 | leanexplore_declaration | leanexplore:388096 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.openRec_tm_subst_ty` to the first opening -/
lemma open_tm_subst_ty (t₁ t₂ : Term Var) (δ : Ty Var) (X : Var) :
(t₁ ^ᵗᵗ t₂)[X := δ] = (t₁[X := δ]) ^ᵗᵗ t₂[X := δ] := openRec_tm_subst_ty 0 t₁ t₂ δ X |
219 | leanexplore_declaration | leanexplore:388097 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.open_tm_subst_ty` to free term variables -/
lemma open_tm_subst_ty_var (t₁ : Term Var) (δ : Ty Var) (X y : Var) :
(t₁ ^ᵗᵗ fvar y)[X := δ] = (t₁[X := δ]) ^ᵗᵗ fvar y := by grind [open_tm_subst_ty] |
262 | leanexplore_declaration | leanexplore:388098 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a locally closed term distributes with term opening to a type. -/
lemma openRec_ty_subst_tm (Y : ℕ) (t : Term Var) (δ : Ty Var) (lc : s.LC) (x : Var) :
(t⟦Y ↝ δ⟧ᵗᵞ)[x := s] = t[x := s]⟦Y ↝ δ⟧ᵗᵞ := by
induction t generalizing Y <;> grind |
215 | leanexplore_declaration | leanexplore:388099 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.openRec_ty_subst_tm` to the first opening. -/
lemma open_ty_subst_tm (t : Term Var) (δ : Ty Var) (lc : s.LC) (x : Var) :
(t ^ᵗᵞ δ)[x := s] = t[x := s] ^ᵗᵞ δ := openRec_ty_subst_tm 0 t δ lc x |
214 | leanexplore_declaration | leanexplore:388100 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.open_ty_subst_tm` to free type variables. -/
lemma open_ty_subst_tm_var (t : Term Var) (lc : s.LC) (x Y : Var) :
(t ^ᵗᵞ .fvar Y)[x := s] = t[x := s] ^ᵗᵞ .fvar Y := open_ty_subst_tm _ _ lc _ |
261 | leanexplore_declaration | leanexplore:388101 | leanexplore_sqlite | leanexplore_declarations | /-- Opening a term to a term is equivalent to opening to a free variable and substituting. -/
lemma openRec_tm_subst_tm_intro (y : ℕ) (t s : Term Var) (nmem : x ∉ t.fv_tm) :
t⟦y ↝ s⟧ᵗᵗ = (t⟦y ↝ fvar x⟧ᵗᵗ)[x := s] := by
induction t generalizing y <;> grind |
217 | leanexplore_declaration | leanexplore:388102 | leanexplore_sqlite | leanexplore_declarations | /-- Specialize `Term.openRec_tm_subst_tm_intro` to the first opening. -/
lemma open_tm_subst_tm_intro (t s : Term Var) (nmem : x ∉ t.fv_tm) :
t ^ᵗᵗs = (t ^ᵗᵗ fvar x)[x := s] := openRec_tm_subst_tm_intro _ _ _ nmem |
355 | leanexplore_declaration | leanexplore:388103 | leanexplore_sqlite | leanexplore_declarations | lemma subst_ty_lc (t_lc : t.LC) (δ_lc : δ.LC) (X : Var) : t[X := δ].LC := by
induction t_lc
case' abs => apply LC.abs (free_union Var)
case' tabs => apply LC.tabs (free_union Var)
case' let' => apply LC.let' (free_union Var)
case' case => apply LC.case (free_union Var)
all_goals grind [Ty.subst_lc, open_tm... |
343 | leanexplore_declaration | leanexplore:388104 | leanexplore_sqlite | leanexplore_declarations | lemma subst_tm_lc (t_lc : t.LC) (s_lc : s.LC) (x : Var) : t[x := s].LC := by
induction t_lc
case' abs => apply LC.abs (free_union Var)
case' let' => apply LC.let' (free_union Var)
case' case => apply LC.case (free_union Var)
case' tabs => apply LC.tabs (free_union Var)
all_goals grind [open_tm_subst_tm_var... |
172 | leanexplore_declaration | leanexplore:388105 | leanexplore_sqlite | leanexplore_declarations | /-- Binding substitution of types. -/
@[scoped grind =]
def subst (X : Var) (δ : Ty Var) : Binding Var → Binding Var
| sub γ => sub <| γ[X := δ]
| ty γ => ty <| γ[X := δ] |
96 | leanexplore_declaration | leanexplore:388106 | leanexplore_sqlite | leanexplore_declarations | instance : HasSubstitution (Binding Var) Var (Ty Var) where
subst γ X δ := Binding.subst X δ γ |
81 | leanexplore_declaration | leanexplore:388107 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind _=_]
lemma subst_sub : (sub γ)[X := δ] = sub (γ[X := δ]) := by rfl |
78 | leanexplore_declaration | leanexplore:388108 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind _=_]
lemma subst_ty : (ty γ)[X := δ] = ty (γ[X := δ]) := by rfl |
214 | leanexplore_declaration | leanexplore:388109 | leanexplore_sqlite | leanexplore_declarations | /-- Substitution of a free variable not present in a binding leaves it unchanged. -/
lemma subst_fresh {γ : Binding Var} (nmem : X ∉ γ.fv) (δ : Ty Var) : γ = γ[X := δ] := by
induction γ <;> grind [Ty.subst_fresh] |
169 | leanexplore_declaration | leanexplore:388110 | leanexplore_sqlite | leanexplore_declarations | /-- Existential predicate for being a locally closed body of an abstraction. -/
@[scoped grind =]
def body (t : Term Var) := ∃ L : Finset Var, ∀ x ∉ L, LC (t ^ᵗᵗ fvar x) |
314 | leanexplore_declaration | leanexplore:388111 | leanexplore_sqlite | leanexplore_declarations | /-- Locally closed let bindings have a locally closed body. -/
@[scoped grind _=_]
lemma body_let : (let' t₁ t₂).LC ↔ t₁.LC ∧ t₂.body := by
constructor <;> intro h <;> cases h
case mp.let' L t₁_lc h => exact ⟨t₁_lc, L, h⟩
case mpr.intro body =>
obtain ⟨_, _⟩ := body
grind [LC.let' <| free_union Var] |
352 | leanexplore_declaration | leanexplore:388112 | leanexplore_sqlite | leanexplore_declarations | /-- Locally closed case bindings have a locally closed bodies. -/
@[scoped grind _=_]
lemma body_case : (case t₁ t₂ t₃).LC ↔ t₁.LC ∧ t₂.body ∧ t₃.body := by
constructor <;> intro h
case mp => cases h with | case L t₁_lc h₂ h₃ => exact ⟨t₁_lc, ⟨L, h₂⟩, ⟨L, h₃⟩⟩
case mpr =>
obtain ⟨_, ⟨_, _⟩, ⟨_, _⟩⟩ := h
g... |
236 | leanexplore_declaration | leanexplore:388113 | leanexplore_sqlite | leanexplore_declarations | /-- Opening a body preserves local closure. -/
@[scoped grind <=]
lemma open_tm_body (body : t₁.body) (lc : t₂.LC) : (t₁ ^ᵗᵗ t₂).LC := by
cases body
grind [fresh_exists <| free_union [fv_tm] Var, subst_tm_lc, open_tm_subst_tm_intro] |
240 | leanexplore_declaration | leanexplore:388114 | leanexplore_sqlite | leanexplore_declarations | /-- Values are irreducible terms. -/
@[grind]
inductive Value : Term Var → Prop
| abs : LC (abs σ t₁) → Value (abs σ t₁)
| tabs : LC (tabs σ t₁) → Value (tabs σ t₁)
| inl : Value t₁ → Value (inl t₁)
| inr : Value t₁ → Value (inr t₁) |
40 | leanexplore_declaration | leanexplore:388115 | leanexplore_sqlite | leanexplore_declarations | | abs : LC (abs σ t₁) → Value (abs σ t₁) |
43 | leanexplore_declaration | leanexplore:388116 | leanexplore_sqlite | leanexplore_declarations | | tabs : LC (tabs σ t₁) → Value (tabs σ t₁) |
95 | leanexplore_declaration | leanexplore:388119 | leanexplore_sqlite | leanexplore_declarations | @[grind →]
lemma Value.lc {t : Term Var} (val : t.Value) : t.LC := by
induction val <;> grind |
920 | leanexplore_declaration | leanexplore:388120 | leanexplore_sqlite | leanexplore_declarations | /-- The call-by-value reduction relation. -/
@[grind, reduction_sys "βᵛ"]
inductive Red : Term Var → Term Var → Prop
| appₗ : LC t₂ → Red t₁ t₁' → Red (app t₁ t₂) (app t₁' t₂)
| appᵣ : Value t₁ → Red t₂ t₂' → Red (app t₁ t₂) (app t₁ t₂')
| tapp : σ.LC → Red t₁ t₁' → Red (tapp t₁ σ) (tapp t₁' σ)
| abs : LC (abs ... |
58 | leanexplore_declaration | leanexplore:388121 | leanexplore_sqlite | leanexplore_declarations | | appₗ : LC t₂ → Red t₁ t₁' → Red (app t₁ t₂) (app t₁' t₂) |
61 | leanexplore_declaration | leanexplore:388122 | leanexplore_sqlite | leanexplore_declarations | | appᵣ : Value t₁ → Red t₂ t₂' → Red (app t₁ t₂) (app t₁ t₂') |
57 | leanexplore_declaration | leanexplore:388123 | leanexplore_sqlite | leanexplore_declarations | | tapp : σ.LC → Red t₁ t₁' → Red (tapp t₁ σ) (tapp t₁' σ) |
70 | leanexplore_declaration | leanexplore:388124 | leanexplore_sqlite | leanexplore_declarations | | abs : LC (abs σ t₁) → Value t₂ → Red (app (abs σ t₁) t₂) (t₁ ^ᵗᵗ t₂) |
68 | leanexplore_declaration | leanexplore:388125 | leanexplore_sqlite | leanexplore_declarations | | tabs : LC (tabs σ t₁) → τ.LC → Red (tapp (tabs σ t₁) τ) (t₁ ^ᵗᵞ τ) |
66 | leanexplore_declaration | leanexplore:388126 | leanexplore_sqlite | leanexplore_declarations | | let_bind : Red t₁ t₁' → t₂.body → Red (let' t₁ t₂) (let' t₁' t₂) |
62 | leanexplore_declaration | leanexplore:388127 | leanexplore_sqlite | leanexplore_declarations | | let_body : Value t₁ → t₂.body → Red (let' t₁ t₂) (t₂ ^ᵗᵗ t₁) |
43 | leanexplore_declaration | leanexplore:388128 | leanexplore_sqlite | leanexplore_declarations | | inl : Red t₁ t₁' → Red (inl t₁) (inl t₁') |
43 | leanexplore_declaration | leanexplore:388129 | leanexplore_sqlite | leanexplore_declarations | | inr : Red t₁ t₁' → Red (inr t₁) (inr t₁') |
78 | leanexplore_declaration | leanexplore:388130 | leanexplore_sqlite | leanexplore_declarations | | case : Red t₁ t₁' → t₂.body → t₃.body → Red (case t₁ t₂ t₃) (case t₁' t₂ t₃) |
81 | leanexplore_declaration | leanexplore:388131 | leanexplore_sqlite | leanexplore_declarations | | case_inl : Value t₁ → t₂.body → t₃.body → Red (case (inl t₁) t₂ t₃) (t₂ ^ᵗᵗ t₁) |
81 | leanexplore_declaration | leanexplore:388132 | leanexplore_sqlite | leanexplore_declarations | | case_inr : Value t₁ → t₂.body → t₃.body → Red (case (inr t₁) t₂ t₃) (t₃ ^ᵗᵗ t₁) |
1,038 | leanexplore_declaration | leanexplore:388133 | leanexplore_sqlite | leanexplore_declarations | @[grind, reduction_sys "βᵛ"]
inductive Red : Term Var → Term Var → Prop
| appₗ : LC t₂ → Red t₁ t₁' → Red (app t₁ t₂) (app t₁' t₂)
| appᵣ : Value t₁ → Red t₂ t₂' → Red (app t₁ t₂) (app t₁ t₂')
| tapp : σ.LC → Red t₁ t₁' → Red (tapp t₁ σ) (tapp t₁' σ)
| abs : LC (abs σ t₁) → Value t₂ → Red (app (abs σ t₁) t₂) (t... |
374 | leanexplore_declaration | leanexplore:388135 | leanexplore_sqlite | leanexplore_declarations | /-- Terms of a reduction are locally closed. -/
lemma Red.lc {t t' : Term Var} (red : t ⭢βᵛ t') : t.LC ∧ t'.LC := by
induction red
case abs lc _ | tabs lc _ =>
split_ands
· grind
· cases lc
grind [
fresh_exists <| free_union [fv_tm, fv_ty] Var, subst_tm_lc,
subst_ty_lc, open_tm_sub... |
1,728 | leanexplore_declaration | leanexplore:388136 | leanexplore_sqlite | leanexplore_declarations | /-- Any reduction step preserves typing. -/
lemma Typing.preservation (der : Typing Γ t τ) (step : t ⭢βᵛ t') : Typing Γ t' τ := by
induction der generalizing t'
case app Γ _ σ τ _ _ _ _ _ =>
cases step
case appₗ | appᵣ => grind
case abs der _ _ =>
have sub : Sub Γ (σ.arrow τ) (σ.arrow τ) := by gri... |
2,117 | leanexplore_declaration | leanexplore:388137 | leanexplore_sqlite | leanexplore_declarations | /-- Any typable term either has a reduction step or is a value. -/
lemma Typing.progress (der : Typing [] t τ) : t.Value ∨ ∃ t', t ⭢βᵛ t' := by
generalize eq : [] = Γ at der
have der' : Typing Γ t τ := by assumption
induction der <;> subst eq <;> simp only [forall_const] at *
case var mem => grind
case app t₁... |
550 | leanexplore_declaration | leanexplore:388138 | leanexplore_sqlite | leanexplore_declarations | /-- The subtyping relation. -/
inductive Sub : Env Var → Ty Var → Ty Var → Prop
| top : Γ.Wf → σ.Wf Γ → Sub Γ σ top
| refl_tvar : Γ.Wf → (fvar X).Wf Γ → Sub Γ (fvar X) (fvar X)
| trans_tvar : Binding.sub σ ∈ Γ.dlookup X → Sub Γ σ σ' → Sub Γ (fvar X) σ'
| arrow : Sub Γ σ σ' → Sub Γ τ' τ → Sub Γ (arrow σ' τ') (ar... |
60 | leanexplore_declaration | leanexplore:388140 | leanexplore_sqlite | leanexplore_declarations | | refl_tvar : Γ.Wf → (fvar X).Wf Γ → Sub Γ (fvar X) (fvar X) |
75 | leanexplore_declaration | leanexplore:388141 | leanexplore_sqlite | leanexplore_declarations | | trans_tvar : Binding.sub σ ∈ Γ.dlookup X → Sub Γ σ σ' → Sub Γ (fvar X) σ' |
67 | leanexplore_declaration | leanexplore:388142 | leanexplore_sqlite | leanexplore_declarations | | arrow : Sub Γ σ σ' → Sub Γ τ' τ → Sub Γ (arrow σ' τ') (arrow σ τ) |
155 | leanexplore_declaration | leanexplore:388143 | leanexplore_sqlite | leanexplore_declarations | | all (L : Finset Var) :
Sub Γ σ σ' →
(∀ X ∉ L, Sub (⟨X, Binding.sub σ⟩ :: Γ) (τ' ^ᵞ fvar X) (τ ^ᵞ fvar X)) →
Sub Γ (all σ' τ') (all σ τ) |
61 | leanexplore_declaration | leanexplore:388144 | leanexplore_sqlite | leanexplore_declarations | | sum : Sub Γ σ' σ → Sub Γ τ' τ → Sub Γ (sum σ' τ') (sum σ τ) |
272 | leanexplore_declaration | leanexplore:388145 | leanexplore_sqlite | leanexplore_declarations | /-- Subtypes have well-formed contexts and types. -/
@[grind →]
lemma wf (Γ : Env Var) (σ σ' : Ty Var) (sub : Sub Γ σ σ') : Γ.Wf ∧ σ.Wf Γ ∧ σ'.Wf Γ := by
induction sub with
| all => grind [Wf.all (free_union Var), Wf.narrow_cons, cases Env.Wf, cases LC]
| _ => grind |
197 | leanexplore_declaration | leanexplore:388146 | leanexplore_sqlite | leanexplore_declarations | /-- Subtypes are reflexive when well-formed. -/
lemma refl (wf_Γ : Γ.Wf) (wf_σ : σ.Wf Γ) : Sub Γ σ σ := by
induction wf_σ with
| all => grind [all (free_union [Context.dom] Var)]
| _ => grind |
326 | leanexplore_declaration | leanexplore:388147 | leanexplore_sqlite | leanexplore_declarations | /-- Weakening of subtypes. -/
lemma weaken (sub : Sub (Γ ++ Θ) σ σ') (wf : (Γ ++ Δ ++ Θ).Wf) : Sub (Γ ++ Δ ++ Θ) σ σ' := by
generalize eq : Γ ++ Θ = ΓΘ at sub
induction sub generalizing Γ
case all =>
subst eq
apply all (free_union [Context.dom] Var) <;> grind
all_goals grind [Ty.Wf.weaken, <= sublist_dl... |
144 | leanexplore_declaration | leanexplore:388148 | leanexplore_sqlite | leanexplore_declarations | lemma weaken_head (sub : Sub Δ σ σ') (wf : (Γ ++ Δ).Wf) : Sub (Γ ++ Δ) σ σ' := by
have eq : Γ ++ Δ = [] ++ Γ ++ Δ := by grind
grind [weaken] |
1,130 | leanexplore_declaration | leanexplore:388149 | leanexplore_sqlite | leanexplore_declarations | lemma narrow_aux
(trans : ∀ Γ σ τ, Sub Γ σ δ → Sub Γ δ τ → Sub Γ σ τ)
(sub₁ : Sub (Γ ++ ⟨X, Binding.sub δ⟩ :: Δ) σ τ) (sub₂ : Sub Δ δ' δ) :
Sub (Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ) σ τ := by
generalize eq : Γ ++ ⟨X, Binding.sub δ⟩ :: Δ = Θ at sub₁
induction sub₁ generalizing Γ δ
case trans_tvar σ _ σ' X'... |
1,073 | leanexplore_declaration | leanexplore:388150 | leanexplore_sqlite | leanexplore_declarations | @[grind →]
lemma trans : Sub Γ σ δ → Sub Γ δ τ → Sub Γ σ τ := by
intro sub₁ sub₂
have δ_lc : δ.LC := by grind
induction δ_lc generalizing Γ σ τ
case top => cases sub₁ <;> cases sub₂ <;> grind
case var X =>
generalize eq : fvar X = γ at sub₁
induction sub₁ <;> grind [cases Sub]
case arrow σ' τ' _ _ _... |
71 | leanexplore_declaration | leanexplore:388151 | leanexplore_sqlite | leanexplore_declarations | instance (Γ : Env Var) : Trans (Sub Γ) (Sub Γ) (Sub Γ) :=
⟨Sub.trans⟩ |
200 | leanexplore_declaration | leanexplore:388152 | leanexplore_sqlite | leanexplore_declarations | /-- Narrowing of subtypes. -/
lemma narrow (sub_δ : Sub Δ δ δ') (sub_narrow : Sub (Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ) σ τ) :
Sub (Γ ++ ⟨X, Binding.sub δ⟩ :: Δ) σ τ := by
grind [narrow_aux (δ := δ')] |
851 | leanexplore_declaration | leanexplore:388153 | leanexplore_sqlite | leanexplore_declarations | /-- Subtyping of substitutions. -/
lemma map_subst (sub₁ : Sub (Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ) σ τ) (sub₂ : Sub Δ δ δ') :
Sub (Γ.map_val (·[X:=δ]) ++ Δ) (σ[X:=δ]) (τ[X:=δ]) := by
generalize eq : Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ = Θ at sub₁
induction sub₁ generalizing Γ
case all => apply Sub.all (free_union Var) ... |
316 | leanexplore_declaration | leanexplore:388154 | leanexplore_sqlite | leanexplore_declarations | /-- Strengthening of subtypes. -/
lemma strengthen (sub : Sub (Γ ++ ⟨X, Binding.ty δ⟩ :: Δ) σ τ) : Sub (Γ ++ Δ) σ τ := by
generalize eq : Γ ++ ⟨X, Binding.ty δ⟩ :: Δ = Θ at sub
induction sub generalizing Γ with
| all => grind [Sub.all (free_union Var)]
| _ => grind [to_ok, Wf.strengthen, Env.Wf.strengthen] |
1,139 | leanexplore_declaration | leanexplore:388155 | leanexplore_sqlite | leanexplore_declarations | /-- The typing relation. -/
inductive Typing : Env Var → Term Var → Ty Var → Prop
| var : Γ.Wf → Binding.ty σ ∈ Γ.dlookup x → Typing Γ (fvar x) σ
| abs (L : Finset Var) :
(∀ x ∉ L, Typing (⟨x, Binding.ty σ⟩ :: Γ) (t₁ ^ᵗᵗ fvar x) τ) →
Typing Γ (abs σ t₁) (arrow σ τ)
| app : Typing Γ t₁ (arrow σ τ) → Ty... |
63 | leanexplore_declaration | leanexplore:388156 | leanexplore_sqlite | leanexplore_declarations | | var : Γ.Wf → Binding.ty σ ∈ Γ.dlookup x → Typing Γ (fvar x) σ |
131 | leanexplore_declaration | leanexplore:388157 | leanexplore_sqlite | leanexplore_declarations | | abs (L : Finset Var) :
(∀ x ∉ L, Typing (⟨x, Binding.ty σ⟩ :: Γ) (t₁ ^ᵗᵗ fvar x) τ) →
Typing Γ (abs σ t₁) (arrow σ τ) |
72 | leanexplore_declaration | leanexplore:388158 | leanexplore_sqlite | leanexplore_declarations | | app : Typing Γ t₁ (arrow σ τ) → Typing Γ t₂ σ → Typing Γ (app t₁ t₂) τ |
144 | leanexplore_declaration | leanexplore:388159 | leanexplore_sqlite | leanexplore_declarations | | tabs (L : Finset Var) :
(∀ X ∉ L, Typing (⟨X, Binding.sub σ⟩ :: Γ) (t₁ ^ᵗᵞ fvar X) (τ ^ᵞ fvar X)) →
Typing Γ (tabs σ t₁) (all σ τ) |
77 | leanexplore_declaration | leanexplore:388160 | leanexplore_sqlite | leanexplore_declarations | | tapp : Typing Γ t₁ (all σ τ) → Sub Γ σ' σ → Typing Γ (tapp t₁ σ') (τ ^ᵞ σ') |
49 | leanexplore_declaration | leanexplore:388161 | leanexplore_sqlite | leanexplore_declarations | | sub : Typing Γ t τ → Sub Γ τ τ' → Typing Γ t τ' |
146 | leanexplore_declaration | leanexplore:388162 | leanexplore_sqlite | leanexplore_declarations | | let' (L : Finset Var) :
Typing Γ t₁ σ →
(∀ x ∉ L, Typing (⟨x, Binding.ty σ⟩ :: Γ) (t₂ ^ᵗᵗ fvar x) τ) →
Typing Γ (let' t₁ t₂) τ |
60 | leanexplore_declaration | leanexplore:388163 | leanexplore_sqlite | leanexplore_declarations | | inl : Typing Γ t₁ σ → τ.Wf Γ → Typing Γ (inl t₁) (sum σ τ) |
60 | leanexplore_declaration | leanexplore:388164 | leanexplore_sqlite | leanexplore_declarations | | inr : Typing Γ t₁ τ → σ.Wf Γ → Typing Γ (inr t₁) (sum σ τ) |
226 | leanexplore_declaration | leanexplore:388165 | leanexplore_sqlite | leanexplore_declarations | | case (L : Finset Var) :
Typing Γ t₁ (sum σ τ) →
(∀ x ∉ L, Typing (⟨x, Binding.ty σ⟩ :: Γ) (t₂ ^ᵗᵗ fvar x) δ) →
(∀ x ∉ L, Typing (⟨x, Binding.ty τ⟩ :: Γ) (t₃ ^ᵗᵗ fvar x) δ) →
Typing Γ (case t₁ t₂ t₃) δ |
600 | leanexplore_declaration | leanexplore:388166 | leanexplore_sqlite | leanexplore_declarations | /-- Typings have well-formed contexts and types. -/
@[grind →]
lemma wf {Γ : Env Var} {t : Term Var} {τ : Ty Var} (der : Typing Γ t τ) : Γ.Wf ∧ t.LC ∧ τ.Wf Γ := by
induction der <;> let L := free_union Var <;> have ⟨x, nmem⟩ := fresh_exists L
case tabs ih =>
cases (ih x (by grind)).left
grind [LC.tabs L, Ty... |
595 | leanexplore_declaration | leanexplore:388167 | leanexplore_sqlite | leanexplore_declarations | /-- Weakening of typings. -/
lemma weaken (der : Typing (Γ ++ Δ) t τ) (wf : (Γ ++ Θ ++ Δ).Wf) :
Typing (Γ ++ Θ ++ Δ) t τ := by
generalize eq : Γ ++ Δ = ΓΔ at der
induction der generalizing Γ
case' abs => apply abs ((Γ ++ Θ ++ Δ).dom ∪ free_union Var)
case' tabs => apply tabs ((Γ ++ Θ ++ Δ).dom ∪ free_union ... |
215 | leanexplore_declaration | leanexplore:388168 | leanexplore_sqlite | leanexplore_declarations | /-- Weakening of typings (at the front). -/
lemma weaken_head (der : Typing Δ t τ) (wf : (Γ ++ Δ).Wf) :
Typing (Γ ++ Δ) t τ := by
have eq : Δ = [] ++ Δ := by rfl
rw [eq] at der
grind [Typing.weaken der wf] |
612 | leanexplore_declaration | leanexplore:388169 | leanexplore_sqlite | leanexplore_declarations | /-- Narrowing of typings. -/
lemma narrow (sub : Sub Δ δ δ') (der : Typing (Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ) t τ) :
Typing (Γ ++ ⟨X, Binding.sub δ⟩ :: Δ) t τ := by
generalize eq : Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ = Θ at der
induction der generalizing Γ
case var X' _ _ =>
grind [Env.Wf.narrow, List.perm_nodupKe... |
1,134 | leanexplore_declaration | leanexplore:388170 | leanexplore_sqlite | leanexplore_declarations | /-- Term substitution within a typing. -/
lemma subst_tm (der : Typing (Γ ++ ⟨X, .ty σ⟩ :: Δ) t τ) (der_sub : Typing Δ s σ) :
Typing (Γ ++ Δ) (t[X := s]) τ := by
generalize eq : Γ ++ ⟨X, .ty σ⟩ :: Δ = Θ at der
induction der generalizing Γ X
case var σ' _ X' _ _ =>
have : Γ ++ ⟨X, .ty σ⟩ :: Δ ~ ⟨X, .ty σ⟩ ... |
1,008 | leanexplore_declaration | leanexplore:388171 | leanexplore_sqlite | leanexplore_declarations | /-- Type substitution within a typing. -/
lemma subst_ty (der : Typing (Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ) t τ) (sub : Sub Δ δ δ') :
Typing (Γ.map_val (·[X := δ]) ++ Δ) (t[X := δ]) (τ[X := δ]) := by
generalize eq : Γ ++ ⟨X, Binding.sub δ'⟩ :: Δ = Θ at der
induction der generalizing Γ X
case var σ _ X' _ mem =>
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.