λ-calculus #
The λ-calculus with polymorphism and subtyping, with a locally nameless representation of syntax. This file defines the well-formedness condition for types and contexts.
References #
- A. Chargueraud, The Locally Nameless Representation
- See also https://www.cis.upenn.edu/~plclub/popl08-tutorial/code/, from which this is adapted
A type is well-formed when it is locally closed and all free variables appear in a context.
- top {Var : Type u_1} [DecidableEq Var] {Γ : Env Var} : Wf Γ Ty.top
- var {Var : Type u_1} [DecidableEq Var] {σ : Ty Var} {Γ : Env Var} {X : Var} : Binding.sub σ ∈ List.dlookup X Γ → Wf Γ (fvar X)
- arrow {Var : Type u_1} [DecidableEq Var] {Γ : Env Var} {σ τ : Ty Var} : Wf Γ σ → Wf Γ τ → Wf Γ (σ.arrow τ)
- all {Var : Type u_1} [DecidableEq Var] {Γ : Env Var} {σ τ : Ty Var} (L : Finset Var) : Wf Γ σ → (∀ X ∉ L, Wf (⟨X, Binding.sub σ⟩ :: Γ) (τ.open' (fvar X))) → Wf Γ (σ.all τ)
- sum {Var : Type u_1} [DecidableEq Var] {Γ : Env Var} {σ τ : Ty Var} : Wf Γ σ → Wf Γ τ → Wf Γ (σ.sum τ)
Instances For
An environment is well-formed if it binds each variable exactly once to a well-formed type.
- empty {Var : Type u_1} [DecidableEq Var] : Wf []
- sub {Var : Type u_1} [DecidableEq Var] {Γ : Env Var} {X : Var} {τ : Ty Var} : Γ.Wf → Ty.Wf Γ τ → X ∉ Context.dom Γ → Wf (⟨X, Binding.sub τ⟩ :: Γ)
- ty {Var : Type u_1} [DecidableEq Var] {Γ : Env Var} {x : Var} {τ : Ty Var} : Γ.Wf → Ty.Wf Γ τ → x ∉ Context.dom Γ → Wf (⟨x, Binding.ty τ⟩ :: Γ)
Instances For
A well-formed context contains no duplicate keys.
A well-formed type is locally closed.
A type remains well-formed under context narrowing.
A type remains well-formed under context strengthening.
A type remains well-formed under context substitution (of a well-formed type).
A type bound in a context is well formed.
A type at the head of a well-formed context is well-formed.
A subtype at the head of a well-formed context is well-formed.
A variable not appearing in a context does not appear in its well-formed types.
A context remains well-formed under narrowing (of a well-formed subtype).
A context remains well-formed under strengthening.
A context remains well-formed under substitution (of a well-formed type).
A well-formed context is unchaged by substituting for a free key.