Elm Exactly

Theoreminv_base

StandardElmMech/Stat/RefuseTypes.lean:601, The abstract context · tactic proof

Statement

theorem inv_base (B : SBasis) (f : TyName → TyName) (C0 : Ctx) (L : TyEnv) (hU : C0.U = [])
    (hT : C0.T = B.T) (hL : unboundB C0 L = true) : Inv B f (absCtx f C0 L) C0

Proof

by
  refine ⟨?_, hU, fun t ht => hT ▸ ht⟩
  rintro ⟨q, c⟩ θ VE hl
  cases q with
  | none =>
    rw [lookupTy_none] at hl
    refine ⟨[], ?_⟩
    simp only [absCtx, Ctx.lookupTy, Env.lookupTy, FMap.find?_modify]
    have hn : FMap.find? L c = none := by
      cases hc : FMap.find? L c with
      | none => rfl
      | some v =>
        exfalso
        have hk : c ∈ L.keys := (FMap.find?_isSome_iff L c).mp (by rw [hc]; rfl)
        obtain ⟨p, hp, rfl⟩ := List.mem_map.mp hk
        have := List.all_eq_true.mp hL p hp
        rw [lookupTy_none, hl] at this
        cases this
    rw [hn]
    simp only [baseTE, Option.none_or]
    rw [find?_map_snd (mapStr f) c C0.E.TE, hl]
    rfl
  | some m =>
    rw [lookupTy_some] at hl
    refine ⟨[], ?_⟩
    simp only [absCtx, Ctx.lookupTy, Env.lookupTy, baseQE]
    rw [find?_map_snd (fun I : IEnv => (⟨I.TE.map (fun q => (q.1, mapStr f q.2)), []⟩ : IEnv)) m C0.E.QE]
    cases hm : FMap.find? C0.E.QE m with
    | none => rw [hm] at hl; cases hl
    | some I =>
      rw [hm] at hl
      simp only [Option.bind_some, Option.map_some] at hl ⊢
      rw [find?_map_snd (mapStr f) c I.TE, hl]
      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.