Elm Exactly

Theoremleaf_core

StandardElmMech/Stat/RefuseTypes.lean:929, Type declarations · tactic proof

Statement

theorem leaf_core {C : Ctx} (hI : Inv B f A C) {TE TE' : TyEnv} {seg post : List BTypBind}
    {VEs : List ValEnv} {TEs : List TyEnv}
    (hb : elabTypBinds (C.oplusTE TE) seg = some (VEs, TEs))
    (hfind : ∀ c, FMap.find? TE c = (FMap.find? (FMap.plusAll TEs) c).or (FMap.find? TE' c))
    (hTE' : ∀ c θ VEc, FMap.find? TE' c = some (θ, VEc) → ∃ VE'', A.lookupTy ⟨none, c⟩ = some (mapFcn f θ, VE''))
    (hnd : (seg.map (·.c)).Nodup) (hord : aliasOrderB (seg ++ post) = true)
    (hH : aliasesRefuted A (seg ++ post) = true ∨ aliasesAllOK A (seg ++ post) = true) :
    (aliasesRefuted A (seg ++ post) = true → aliasesRefuted A post = true) ∧
    (aliasesAllOK A (seg ++ post) = true → aliasesAllOK A post = true) ∧ ∀ lc, LookSim f (C.oplusTE TE) A lc

Proof

by
  have hfold := typBinds_fold (C.oplusTE TE) seg VEs TEs [] hb hnd
  refine aliases_inner hcol hAU (Cte := C.oplusTE TE) hI.U post seg ?_ ?_ hord hH
  · rintro ⟨q, c⟩ hlc
    cases q with
    | some m =>
      intro θ VE h
      rw [lookupTy_oplusTE_some] at h
      exact hI.look _ θ VE h
    | none =>
      have hn : c ∉ seg.map (·.c) := by
        rcases hlc with h | h
        · cases h
        · exact h
      intro θ VE h
      rw [lookupTy_oplusTE_none, hfind] at h
      have hp : FMap.find? (FMap.plusAll TEs) c = none := by
        unfold FMap.plusAll; rw [hfold.1 c hn]; rfl
      rw [hp, Option.none_or] at h
      cases h' : FMap.find? TE' c with
      | some s =>
        rw [h'] at h
        simp only [Option.some_or, Option.some.injEq] at h
        subst h
        exact hTE' c θ VE h'
      | none =>
        rw [h', Option.none_or] at h
        exact hI.look _ θ VE h
  · intro tb htb
    obtain ⟨τ, X, hτ, hf⟩ := hfold.2 tb htb
    refine ⟨τ, X, hτ, ?_⟩
    rw [lookupTy_oplusTE_none, hfind]
    unfold FMap.plusAll
    rw [hf]
    rfl

Proved with tactics, which Lean expands into a proof term that its kernel checks.

Theorems it uses

Used by

In StandardElmMech/Stat/RefuseTypes.lean: Refusals by type expressions (aliases, constructor arguments, annotations, ports) and by the type of main (typesFailB, mainFailB), for every choice of generated names and variable sorts.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.