Elm Exactly

TheoremcheckAtPat_sound

StandardElmMech/Stat/CheckSound.lean:35, Patterns · term proof

Statement

theorem checkAtPat_sound (C : Ctx) : (p : AAtPat) → checkAtPat C p = true → ElAtPat C p.erase p.ve p.ty
  | .wild τ, _ => by simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]; exact .r_s_atpat_wild
  | .scon sc τ, h => by
    simp only [checkAtPat, Bool.and_eq_true, decide_eq_true_eq] at h
    simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]
    exact .r_s_atpat_scon (gen_of_genAt h.1) h.2
  | .var x τ, _ => by simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]; exact .r_s_atpat_var
  | .con lc inst τ, h => by
    simp only [checkAtPat] at h
    split at h
    · rename_i σ hl
      simp only [Bool.and_eq_true] at h
      obtain ⟨τs, t, rfl⟩

Proof

isConTy_spec h.2
      simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]
      exact .r_s_atpat_con hl (gen_of_genAt h.1)
    · cases h
  | .unit, _ => by simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]; exact .r_s_atpat_unit
  | .tuple p1 p2 p3, h => by
    simp only [checkAtPat, Bool.and_eq_true] at h
    simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]
    exact .r_s_atpat_tuple (checkPat_sound C p1 h.1.1) (checkPat_sound C p2 h.1.2) (checkPatOpt_sound C p3 h.2)
  | .nil τ, h => by
    simp only [checkAtPat] at h
    obtain ⟨τ0, rfl⟩ := isListTy_spec h
    simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]
    exact .r_s_atpat_nil
  | .record row τ, h => by
    simp only [checkAtPat, Bool.and_eq_true] at h
    obtain ⟨⟨h1, h2⟩, h3⟩ := h
    obtain ⟨ρτ, tl, rfl⟩ := isRecordTy_spec h2
    simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]
    exact .r_s_atpat_record (checkPatRowOpt_sound C row h1) rfl ((Row.subB_iff _ _).mp h3)
  | .paren p, h => by
    simp only [checkAtPat] at h
    simp only [AAtPat.erase, AAtPat.ve, AAtPat.ty]
    exact .r_s_atpat_paren (checkPat_sound C p h)

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

Rules of the book it uses

Theorems it uses

Used by

In StandardElmMech/Stat/CheckSound.lean: The checker is sound: a phrase that checks has a derivation by the rules of Chapters 4 and 5 (checkExp_sound, checkModule_sound).

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.