TheoremprogCheck_el
Statement
theorem progCheck_el : ∀ (ms : List BModule) (B : SBasis) (as : AProgram) (Bs : List SBasis),
progCheckFrom B ms = true → inferProgramFrom B ms = .ok as → AProgram.bases B as = some Bs →
(∀ i (h : i < as.length) (h' : i < Bs.length), IsPrincipalMod Bs[i] as[i]) →
as.map AModule.erase = ms → ∃ τ PE, ElProgram B ms τ PE
| [], _, _, _, h, _, _, _, _ => by simp [progCheckFrom] at h
| [m], B, as, Bs, h, hi, hb, hp, he => by
simp only [progCheckFrom] at h
split at h
· rename_i a ha
split at h
· rename_i B' E hr
simp only [Bool.and_eq_true] at h
obtain ⟨⟨hfur, hports⟩, hmain⟩Proof
h
obtain ⟨τ, hτ⟩ := Option.isSome_iff_exists.mp hmain
simp only [inferProgramFrom, ha, hr, bind, Except.bind, pure, Except.pure, Except.ok.injEq] at hi
subst hi
simp only [AProgram.bases, hr, Option.map_some, Option.some.injEq] at hb
subst hb
have hprin : IsPrincipalMod B a := hp 0 (by simp) (by simp)
have hea : a.erase = m := by simpa using he
have hfm : FurtherMod B a := by unfold FurtherMod; rw [hr]; exact furtherModInB_sound hfur
exact ⟨τ, _, elProgram_main ⟨a, hea, hprin, hr, hfm⟩ (portsDisjointB_sound hports) hτ⟩
· cases h
· cases h
| m :: m2 :: ms, B, as, Bs, h, hi, hb, hp, he => by
simp only [progCheckFrom] at h
split at h
· rename_i a ha
split at h
· rename_i B' E hr
simp only [Bool.and_eq_true] at h
obtain ⟨⟨hfur, hports⟩, hrest⟩ := h
rw [inferProgramFrom_cons ha hr] at hi
cases hrest' : inferProgramFrom (B.plus B') (m2 :: ms) with
| error e => rw [hrest'] at hi; cases hi
| ok rest =>
rw [hrest'] at hi
simp only [Except.map, Except.ok.injEq] at hi
subst hi
simp only [AProgram.bases, hr] at hb
cases hbr : AProgram.bases (B.plus B') rest with
| none => rw [hbr] at hb; cases hb
| some Bs' =>
rw [hbr] at hb
simp only [Option.map_some, Option.some.injEq] at hb
subst hb
have hprin : IsPrincipalMod B a := hp 0 (by simp) (by simp)
simp only [List.map_cons, List.cons.injEq] at he
have hfm : FurtherMod B a := by unfold FurtherMod; rw [hr]; exact furtherModInB_sound hfur
obtain ⟨τ, PE, hel⟩ := progCheck_el (m2 :: ms) (B.plus B') rest Bs' hrest hrest' hbr
(fun i h1 h2 => hp (i + 1) (by simp; omega) (by simp; omega)) he.2
exact ⟨τ, PE, .r_p_stat_module ⟨a, he.1, hprin, hr, hfm⟩ (portsDisjointB_sound hports)
(by simp) hel⟩
· cases h
· cases hProved by a term, which Lean's kernel checks directly.
Rules of the book it uses
Theorems it uses
Used by
In StandardElmMech/Stat/Legal.lean: The master theorems: a program whose inferred derivation checks, meets the further restrictions and gives main a Chapter 9 type is legal, under D11 (legal_of_infer1, legal_of_infer).
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.