TheoremelProgram_of_results
Statement
theorem elProgram_of_results : ∀ (B : SBasis) (a : AProgram) (Bs : List SBasis)
(rs : List (SBasis × SBasis × Env)),
progResults B a = some rs → AProgram.bases B a = some Bs →
(∀ i (h : i < a.length) (h' : i < Bs.length), IsPrincipalMod Bs[i] a[i]) →
(∀ i (h : i < a.length) (h' : i < Bs.length), FurtherMod Bs[i] a[i]) →
checksAll rs = true → a ≠ [] → ∃ τ PE, ElProgram B (a.map AModule.erase) τ PE
| _, [], _, _, _, _, _, _, _, hne => absurd rfl hne
| B, m :: rest, Bs, rs, hr, hb, hp, hf, hc, _ => by
simp only [progResults] at hr
cases hm : m.result B with
| none => rw [hm] at hr; cases hr
| some pr =>
obtain ⟨B', E⟩Proof
pr
simp only [hm] at hr
cases hrr : progResults (B.plus B') rest with
| none => simp [hrr] at hr
| some rs' =>
simp only [hrr, Option.map_some, Option.some.injEq] at hr
subst hr
simp only [AProgram.bases, hm] at hb
cases hbr : AProgram.bases (B.plus B') rest with
| none => simp [hbr] at hb
| some Bs' =>
simp only [hbr, Option.map_some, Option.some.injEq] at hb
subst hb
simp only [checksAll, List.all_cons, Bool.and_eq_true] at hc
obtain ⟨⟨hpd, hall⟩, hmain⟩ := hc
have hprin : IsPrincipalMod B m := hp 0 (by simp) (by simp)
have hfm : FurtherMod B m := hf 0 (by simp) (by simp)
have hder : PrincipalModDer B m.erase B' E := ⟨m, rfl, hprin, hm, hfm⟩
cases rest with
| nil =>
simp only [progResults, Option.some.injEq] at hrr
subst hrr
simp only [mainScheme] at hmain
split at hmain
· rename_i σ hσ
obtain ⟨k, hk⟩ := Option.isSome_iff_exists.mp (by simpa using hmain)
obtain ⟨τ, hel⟩ := elProgram_main_of_kind hder (portsDisjointB_sound hpd) hσ hk
exact ⟨τ, _, hel⟩
· simp at hmain
| cons m2 rest2 =>
have hc' : checksAll rs' = true := by
simp only [checksAll, Bool.and_eq_true]
refine ⟨hall, ?_⟩
have : mainScheme ((B, B', E) :: rs') = mainScheme rs' := by
cases rs' with
| nil => have := progResults_length hrr; simp at this
| cons _ _ => rfl
rw [← this]; exact hmain
obtain ⟨τ, PE, hel⟩ := elProgram_of_results (B.plus B') (m2 :: rest2) Bs' rs' hrr hbr
(fun i h1 h2 => hp (i + 1) (by simp at h1 ⊢; omega) (by simp at h2 ⊢; omega))
(fun i h1 h2 => hf (i + 1) (by simp at h1 ⊢; omega) (by simp at h2 ⊢; omega))
hc' (by simp)
exact ⟨τ, PE, .r_p_stat_module hder (portsDisjointB_sound hpd) (by simp) hel⟩Proved by a term, which Lean's kernel checks directly.
Rules of the book it uses
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.