Elm Exactly

TheoremcheckAtExp_sound

StandardElmMech/Stat/CheckSound.lean:146, Expressions · term proof

Statement

theorem checkAtExp_sound (C : Ctx) : (a : AAtExp) → checkAtExp C a = true → ElAtExp C a.erase a.ty
  | .scon sc τ, h => by
    simp only [checkAtExp] at h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_scon (gen_of_genAt h)
  | .var lv inst τ, h => by
    simp only [checkAtExp] at h
    obtain ⟨σ, is, hl, hg⟩

Proof

lookup_gen h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_longvar hl hg
  | .con lc inst τ, h => by
    simp only [checkAtExp] at h
    obtain ⟨σ, is, hl, hg⟩ := lookup_gen h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_longcon hl hg
  | .op o inst τ, h => by
    simp only [checkAtExp] at h
    split at h
    · rename_i σ is hl
      simp only [AAtExp.erase, AAtExp.ty]
      exact .r_s_atexp_op hl (gen_of_genAt h)
    · cases h
  | .unit, _ => by simp only [AAtExp.erase, AAtExp.ty]; exact .r_s_atexp_unit
  | .tuple e1 e2 e3, h => by
    simp only [checkAtExp, Bool.and_eq_true] at h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_tuple (checkExpS_sound C e1 h.1.1) (checkExpS_sound C e2 h.1.2) (checkExpOpt_sound C e3 h.2)
  | .nil τ, h => by
    simp only [checkAtExp] at h
    obtain ⟨τ0, rfl⟩ := isListTy_spec h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_nil
  | .record row, h => by
    simp only [checkAtExp] at h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_record (checkExpRowOpt_sound C row h)
  | .update x inst τ row, h => by
    simp only [checkAtExp, Bool.and_eq_true] at h
    obtain ⟨⟨⟨h1, h2⟩, h3⟩, h4⟩ := h
    obtain ⟨σ, is, hl, hg⟩ := lookup_gen h1
    obtain ⟨ρτ, tl, rfl⟩ := isRecordTy_spec h2
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_update (.r_s_atexp_longvar hl hg) rfl (checkExpRow_sound C row h3)
      ((Row.subB_iff _ _).mp h4)
  | .letE d e, h => by
    simp only [checkAtExp, Bool.and_eq_true] at h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_let (checkDec_sound C d h.1) (checkExpS_sound _ e h.2)
  | .paren e, h => by
    simp only [checkAtExp] at h
    simp only [AAtExp.erase, AAtExp.ty]
    exact .r_s_atexp_paren (checkExpS_sound C e 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.