Elm Exactly

Theorempres

StandardElmMech/Stat/RefuseTypes.lean:1279, The module's declarations · term proof

Statement

theorem pres : ∀ (a : ATopDec) (C : Ctx) (E : Env) (PE : PortEnv), Inv B f A C →
    preserves A a.erase = true → checkTopDec C a = some (E, PE) → Inv B f A (C.oplusE E)
  | .value VE vb, C, E, PE, hI, _, h => by
    simp only [checkTopDec] at h
    split at h
    · simp only [Option.some.injEq, Prod.mk.injEq] at h
      obtain ⟨rfl, rfl⟩

Proof

h
      exact hI.ofVE _
    · cases h
  | .types TE VE db tbs, C, E, PE, hI, hp, h => by
    simp only [ATopDec.erase, preserves, Bool.and_eq_true] at hp
    exact (types_top hcol hAU rfl hI hp.1 (.inr hp.2) h).2.1
  | .port x ty U, C, E, PE, hI, _, h => by
    obtain ⟨_, _, s, PE', hr⟩ := elabPort_shape h
    simp only [checkTopDec, hr] at h
    cases hr
    exact hI.ofVE _
  | .seq a1 a2, C, E, PE, hI, hp, h => by
    simp only [ATopDec.erase, preserves, Bool.and_eq_true] at hp
    simp only [checkTopDec] at h
    cases h1 : checkTopDec C a1 with
    | none => rw [h1] at h; simp at h
    | some r1 =>
      obtain ⟨E1, PE1⟩ := r1
      rw [h1] at h
      simp only at h
      cases h2 : checkTopDec (C.oplusE E1) a2 with
      | none => rw [h2] at h; simp at h
      | some r2 =>
        obtain ⟨E2, PE2⟩ := r2
        rw [h2] at h
        simp only [Option.some.injEq, Prod.mk.injEq] at h
        obtain ⟨rfl, rfl⟩ := h
        have ih1 := pres a1 C E1 PE1 hI hp.1 h1
        have ih2 := pres a2 (C.oplusE E1) E2 PE2 ih1 hp.2 h2
        exact ⟨fun lc => lookSim_of_same (sameTy_oplusE_plus C E1 E2) (ih2.look lc), hI.U,
          fun t ht => T_oplusE C _ t (hI.T t ht)⟩

Proved by a term, which Lean's kernel checks directly.

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.