Elm Exactly

Theoremvesound_modify

StandardElmMech/Stat/RefuseScope.lean:357, Sound value environments and the extension of shapes · tactic proof

Statement

theorem vesound_modify {f g : ValEnv} {bf bg : List (String × Option Nat)} (hf : VESound f bf)
    (hg : VESound g bg) : VESound (FMap.modify f g) (bg ++ bf)

Proof

by
  refine ⟨fun x b hx => ?_, fun x n hx => ?_⟩
  · rw [FMap.find?_modify] at hx
    rw [FMap.find?_append]
    cases hgx : FMap.find? g x with
    | some w =>
      rw [hgx] at hx; simp only [Option.some_or, Option.some.injEq] at hx; subst hx
      obtain ⟨a, ha, hv⟩ := hg.1 x w hgx
      exact ⟨a, by rw [ha]; rfl, hv⟩
    | none =>
      rw [hgx] at hx
      simp only [Option.none_or] at hx
      obtain ⟨a, ha, hv⟩ := hf.1 x b hx
      cases hbg : FMap.find? bg x with
      | none => exact ⟨a, by rw [ha]; rfl, hv⟩
      | some a' =>
        refine ⟨a', rfl, fun n hn _ => ?_⟩
        subst hn
        have := hg.2 x n hbg
        rw [hgx] at this; cases this
  · rw [FMap.find?_append] at hx
    rw [FMap.find?_modify]
    cases hbg : FMap.find? bg x with
    | some a' =>
      rw [hbg] at hx; cases hx
      have := hg.2 x n hbg
      cases hgx : FMap.find? g x with
      | none => rw [hgx] at this; cases this
      | some _ => rfl
    | none =>
      rw [hbg] at hx
      simp only [Option.none_or] at hx
      have := hf.2 x n hx
      cases hgx : FMap.find? g x with
      | none => simpa using this
      | some _ => rfl

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

Used by

In StandardElmMech/Stat/RefuseScope.lean: Refusals by scope, constructor arity and imports, for one module and for a module after a helper (scopeFailB).

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.