Skip to content

System F erasure and closing environments

21 fully proved

System F

DefinitionShift of untyped bound indices above a cutoff#✓fully proved

Shift free bound indices in CSLib syntax, preserving indices below c.

def shiftAt (c : Nat) : Term Nat → Term Nat
  | .bvar i => .bvar (if i < c then i else i + 1)
  | .fvar x => .fvar x
  | .app f a => .app (shiftAt c f) (shiftAt c a)
  | .abs b => .abs (shiftAt (c + 1) b)
Used by 6

DefinitionLifting a raw erasure environment under a binder#✓fully proved

Lift a raw erasure environment beneath one scoped term binder.

def liftRaw {m : Nat} (σ : Fin m → Term Nat) :
    Fin (m + 1) → Term Nat :=
  Fin.cases (.bvar 0) (fun i => shiftAt 0 (σ i))
Uses 1 · Used by 9

TheoremShifting leaves locally closed terms unchanged#✓fully proved

Introducing a binder does not shift an already locally closed term.

theorem shiftAt_closed (c : Nat) (t : Term Nat) (h : t.LcAt 0) :
    shiftAt c t = t
Uses 1 · Used by 2

Type erasure and closing

DefinitionType erasure under an untyped environment#✓fully proved

Erase a scoped term under an arbitrary simultaneous untyped environment.

@[simp] def eraseWith {n m : Nat} (σ : Fin m → Term Nat) :
    Tm n m → Term Nat
  | .var i => σ i
  | .lam _ b => .abs (eraseWith (liftRaw σ) b)
  | .app f a => .app (eraseWith σ f) (eraseWith σ a)
  | .tabs b => eraseWith σ b
  | .tapp f _ => eraseWith σ f
Uses 3 · Used by 10

DefinitionType erasure of System F terms to untyped terms#✓fully proved

Type erasure into the existing untyped de Bruijn syntax.

def erase {n m : Nat} (t : Tm n m) : Term Nat :=
  eraseWith (fun i => .bvar i.val) t
Uses 2

TheoremErasure with locally closed images is locally closed#✓fully proved

Erasure preserves the closure invariant of its environment images.

theorem eraseWith_lcAt {n m k : Nat} (σ : Fin m → Term Nat) (t : Tm n m)
    (hσ : ∀ i, (σ i).LcAt k) : (eraseWith σ t).LcAt k
Uses 5 · Used by 1

DefinitionClosing System F terms in the term model#✓fully proved

Close every scoped term variable with a locally closed model term.

def close {n m : Nat} (σ : Fin m → Model) (t : Tm n m) : Model :=
  ⟨eraseWith (fun i => (σ i).val) t,
    eraseWith_lcAt _ t (fun i => (σ i).property)⟩
Uses 4 · Used by 18

DefinitionErasure of closed System F terms to the term model#✓fully proved

Erase a term with no free term variables into the existing term model.

def eraseModel {n : Nat} (t : Tm n 0) : Model := close Fin.elim0 t
Uses 3 · Used by 4

TheoremOpening commutes with erasure under an environment#✓fully proved

Opening an erased instance opens exactly its raw environment images.

theorem eraseWith_openRec {n m : Nat} (u : Term Nat) (hu : u.LcAt 0)
    (k : Nat) (σ : Fin m → Term Nat) (t : Tm n m) :
    Term.openRec k u (eraseWith σ t) =
      eraseWith (fun i => Term.openRec k u (σ i)) t
Uses 6 · Used by 1

TheoremUntyped erasure is invariant under type substitution#✓fully proved

Type substitution changes no part of the erased untyped term.

theorem eraseWith_tySubst {n k m : Nat} (σ : Fin n → Ty k)
    (η : Fin m → Term Nat) (t : Tm n m) :
    eraseWith η (tySubst σ t) = eraseWith η t
Uses 7 · Used by 2

TheoremClosing a System F variable#✓fully proved

Closing a variable returns exactly its environment image.

@[simp] theorem close_var {n m : Nat} (σ : Fin m → Model) (i : Fin m) :
    close σ (.var i : Tm n m) = σ i
Uses 3

TheoremClosing a System F application#✓fully proved

Closing commutes with the upstream model's application.

@[simp] theorem close_app {n m : Nat} (σ : Fin m → Model) (f a : Tm n m) :
    close σ (.app f a) = Model.app (close σ f) (close σ a)
Uses 4 · Used by 1

TheoremClosing erases System F type abstraction#✓fully proved

A type lambda contributes no untyped binder.

@[simp] theorem close_tabs {n m : Nat} (σ : Fin m → Model)
    (b : Tm (n + 1) m) : close σ (.tabs b) = close σ b
Uses 3 · Used by 1

TheoremClosing erases System F type application#✓fully proved

A type argument contributes no untyped application.

@[simp] theorem close_tapp {n m : Nat} (σ : Fin m → Model)
    (f : Tm n m) (A : Ty n) : close σ (.tapp f A) = close σ f
Uses 4 · Used by 1

TheoremSystem F closing is invariant under type substitution#✓fully proved

Closing is independent of every type substitution.

@[simp] theorem close_tySubst {n k m : Nat} (σ : Fin n → Ty k)
    (η : Fin m → Model) (t : Tm n m) :
    close η (tySubst σ t) = close η t
Uses 6 · Used by 1

TheoremBeta conversion of a closed System F lambda application#✓fully proved

An erased lambda application beta-converts to its extended body instance.

theorem close_beta {n m : Nat} (σ : Fin m → Model) (A : Ty n)
    (b : Tm n (m + 1)) (a : Model) :
    BetaEq (Model.app (close σ (.lam A b)) a) (close (Fin.cases a σ) b)
Uses 11 · Used by 3

TheoremShifting commutes with erasure under an environment#✓fully proved

Shifting an erased instance shifts exactly its raw environment images.

theorem eraseWith_shift {n m : Nat} (c : Nat) (σ : Fin m → Term Nat)
    (t : Tm n m) : shiftAt c (eraseWith σ t) =
      eraseWith (fun i => shiftAt c (σ i)) t
Uses 5 · Used by 1

TheoremErasure of a term-variable renaming#✓fully proved

Erasing a term-variable renaming precomposes the raw environment.

theorem eraseWith_rename {n m k : Nat} (η : Fin m → Fin k)
    (σ : Fin k → Term Nat) (t : Tm n m) :
    eraseWith σ (rename η t) = eraseWith (σ ∘ η) t
Uses 6 · Used by 1

TheoremErasure of a term substitution#✓fully proved

Actual term substitution erases by composing raw environments.

theorem eraseWith_subst {n m k : Nat} (σ : Fin m → Tm n k)
    (η : Fin k → Term Nat) (t : Tm n m) :
    eraseWith η (subst σ t) =
      eraseWith (fun i => eraseWith η (σ i)) t
Uses 12 · Used by 1

TheoremClosing commutes with System F term substitution#✓fully proved

Closing an actual substitution composes its model-valued environments.

theorem close_subst {n m k : Nat} (σ : Fin m → Tm n k)
    (η : Fin k → Model) (t : Tm n m) :
    close η (subst σ t) = close (fun i => close η (σ i)) t
Uses 5 · Used by 2

TheoremClosing an instantiated System F term binder#✓fully proved

Actual binder discharge agrees with extending the closing environment.

theorem close_instantiate {n m : Nat} (η : Fin m → Model)
    (b : Tm n (m + 1)) (a : Tm n m) :
    close η (instantiate b a) = close (Fin.cases (close η a) η) b
Uses 6 · Used by 2

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.