Elm Exactly

TheoremwCheck_of_ctx

StandardElmMech/Stat/Complete/Discharge.lean:280, Legality, the specialisation of the program, its meaning · tactic proof

A check with the context given is the check.

Statement

theorem wCheck_of_ctx {B : SBasis} {imps : List Src.BImport} {C : Ctx} {s : SProgram} {q : Option Mod.Reduced}
    (hC : importCtx B imps = some C) (h : wCheckIn B imps C s q = true) : wCheck B s q = true

Proof

by
  unfold wCheckIn at h
  simp only [Bool.and_eq_true] at h
  obtain ⟨hsyn, h⟩ := h
  unfold wCheck
  rw [hsyn, Bool.true_and]
  split at h
  · rename_i m hm
    simp only [Bool.and_eq_true, decide_eq_true_eq] at h
    obtain ⟨rfl, h⟩ := h
    rw [hm]
    have hw := inferModuleW_eq_In (fuel := MW.wFuel) hC
    split at h
    · rename_i a ha
      rw [← hw] at ha
      obtain ⟨-, -, -, -, -, haim, -⟩ := MW.inferModuleW_ok_inv ha
      have hCa : importCtx B a.imports = some C := haim ▸ hC
      have hres := AModule.result_of_ctx hCa
      split at h
      · rename_i B' E hr
        simp only [Bool.and_eq_true] at h
        obtain ⟨⟨hc, hfu⟩, hq⟩ := h
        have hp : MW.inferProgramW MW.wFuel B [m] = .ok [a] := by
          simp only [MW.inferProgramW, ha, hres, hr]
        have hpr : progResults B [a] = some [(B, B', E)] := by
          simp only [progResults, hres, hr, Option.map_some]
        rw [hp]
        simp only [hpr, hc, furtherAllB, hres, hr, hfu, Bool.true_and, Bool.and_true]
        exact hq
      · cases h
    · cases h
  · cases h

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

Theorems it uses

In StandardElmMech/Stat/Complete/Discharge.lean: Step 11, milestone (g): Stat.wCheck, legal_of_W, ident_of_wCheck, programSem_of_wCheck (D11 discharged test by test), not_legal_of_wMainVar (A96's flags refusal), principalExistsCore_of_covers, principalExistsMod_of_covers, d11For_of_agree; Lean's pipeline with W, endToEndW (step 10's endToEnd with W in place of step 9's inference), with endToEndW_of_wCheck (the per-test spec_ from wcheck_, without a second run of the inference), specOf_of_endToEndW, ident_of_endToEndW, programSem_of_endToEndW (step 10's statements, without D11); wCheckIn, wCheck_of_ctx (the W check of a one-module program with the context of its imports given by a lemma ctx_<name>_eq, so the kernel does not compute it per test: an end-to-end shard of 20 tests takes 32 s instead of 98 s).

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.