Type preservation of elaboration: source lookups erase to Core lookups under
elabTyp, the emitted composition terms are well-typed, and every elaborated
term is a well-typed Core term.
theorem
type_safe_index_lookup
{ST₁ ST₂ : SCE.Typ}
{n : Nat}
(h : SCE.SLookup ST₁ n ST₂)
:
Core.Lookup (elabTyp ST₁) n (elabTyp ST₂)
theorem
type_safe_record_lookup
{ST₁ ST₂ : SCE.Typ}
{l : String}
(h : SCE.SRLookup ST₁ l ST₂)
:
Core.RLookup (elabTyp ST₁) l (elabTyp ST₂)
theorem
elab_value
{Γ A : SCE.Typ}
{v : SCE.Exp}
{cv : Core.Exp}
(helab : elabExp Γ v A cv)
(hval : SCE.Value v)
:
Core.Value cv
The linearized wire is well-typed: under any context that reaches the
provider type ⟦Γ₁⟧ at index shift, wire_shift ⟦D⟧ has the interface type
⟦D⟧.
theorem
wire_typed_rcd
{A₁ A : Core.Typ}
{l : String}
(hrl : Core.RLookup A₁ l A)
{C : Core.Typ}
{shift : Nat}
:
Core.Lookup C shift A₁ → HasType C (wire shift (Core.Typ.rcd l A)) (Core.Typ.rcd l A)
The single-import wire, stated purely at the target: wire_shift {l:A} is
well-typed whenever the provider type reachable at shift has an l : A field.
theorem
linkedCore_typed
{Γc g1 D B : Core.Typ}
{ce₁ ce₂ : Core.Exp}
(h₁ : HasType Γc ce₁ g1)
(h₂ : HasType Γc ce₂ (D.arr B))
(hw : ∀ {C : Core.Typ} {shift : Nat}, Core.Lookup C shift g1 → HasType C (wire shift D) D)
:
HasType Γc (linkedCore g1 D B ce₁ ce₂) (g1.and B)
The linearized link composition is well-typed at g1 & B — the check the
OCaml linker replays on every link, discharged once and for all for the step
term it emits. The wire hypothesis is supplied by wire_typed (interface
LinkOk) or wire_typed_rcd (single import).