Elm Exactly

TheoremtoPTy_isSome

StandardElmMech/Stat/Pipeline.lean:137, Payload types and `main` · term proof

Statement

theorem toPTy_isSome : (τ : Ty) → (toPTy τ).isSome = portB τ
  | .con [] t => by
    simp only [toPTy, portB]
    by_cases h1 : t = tInt; · subst h1; rfl
    by_cases h2 : t = tFloat; · subst h2; rfl
    by_cases h3 : t = tBool; · subst h3; rfl
    by_cases h4 : t = tString; · subst h4; rfl
    by_cases h5 : t = tBytes; · subst h5; rfl
    by_cases h6 : t = tUnit; · subst h6; rfl
    by_cases h7 : t = tValue; · subst h7; rfl
    simp [h1, h2, h3, h4, h5, h6, h7]
  | .con [τ] t => by
    have ih

Proof

toPTy_isSome τ
    simp only [toPTy, portB]
    by_cases h1 : t = tList; · subst h1; simp [ih]
    by_cases h2 : t = tMaybe; · subst h2; simp [ih, show tMaybe ≠ tList from by decide]
    by_cases h3 : t = tArray
    · subst h3; simp [ih, show tArray ≠ tList from by decide, show tArray ≠ tMaybe from by decide]
    simp [h1, h2, h3]
  | .con [τ1, τ2] t => by
    have ih1 := toPTy_isSome τ1
    have ih2 := toPTy_isSome τ2
    simp only [toPTy, portB]
    by_cases h : t = tTuple2
    · subst h
      simp only [ite_true, beq_self_eq_true, Bool.true_and]
      rw [← ih1, ← ih2]
      cases toPTy τ1 <;> cases toPTy τ2 <;> rfl
    · simp [h]
  | .con [τ1, τ2, τ3] t => by
    have ih1 := toPTy_isSome τ1
    have ih2 := toPTy_isSome τ2
    have ih3 := toPTy_isSome τ3
    simp only [toPTy, portB]
    by_cases h : t = tTuple3
    · subst h
      simp only [ite_true, beq_self_eq_true, Bool.true_and]
      rw [← ih1, ← ih2, ← ih3]
      cases toPTy τ1 <;> cases toPTy τ2 <;> cases toPTy τ3 <;> rfl
    · simp [h]
  | .con (_ :: _ :: _ :: _ :: _) _ => by simp [toPTy, portB]
  | .record ρ none => by
    simp only [toPTy, portB, Option.isSome_map]
    exact toPFields_isSome ρ
  | .record _ (some _) => by simp [toPTy, portB]
  | .var _ => by simp [toPTy, portB]
  | .fn _ _ => by simp [toPTy, portB]

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

Theorems it uses

Used by

In StandardElmMech/Stat/Pipeline.lean: SpecOf, DynOf (in Lib.Btest for a view, Mod.Btest [] for a worker: dynBasis), ProgramSem (r:p-program), D11For; copy names, payload types and main (copyName_inj, toPTy_isSome_iff, mainKind_worker_iff, mainKind_view_iff); the pipeline theorems (specOf_of_endToEnd, programSem_of_legal).

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.