Theoremmain_bad
Statement
theorem main_bad : ∀ (a : ATopDec) (C : Ctx) (E : Env) (PE : PortEnv), Inv B f A C →
mainRef A a.erase = true → checkTopDec C a = some (E, PE) →
∃ σ st, FMap.find? E.VE "main" = some (σ, st) ∧ badHeadB σ.body = true
| .value VE vb, C, E, PE, hI, hm, h => by
simp only [ATopDec.erase, mainRef] at hm
simp only [checkTopDec] at h
split at h
· rename_i hc
simp only [Bool.and_eq_true, decide_eq_true_eq] at hc
replace hcProof
hc.1
simp only [Option.some.injEq, Prod.mk.injEq] at h
obtain ⟨rfl, rfl⟩ := h
obtain ⟨sch, hs, hb⟩ := vb_mainBad hcol hAU (C' := C.plusVE VE) (fun lc => lookSim_plusVE VE (hI.look lc))
hI.U vb hc.1 hm
simp only [Env.ofVE, closGroup, FMap.mapV]
rw [find?_map_key, ← hc.2, hs]
exact ⟨_, _, rfl, badHead_canon _ hb⟩
· cases h
| .types _ _ _ _, _, _, _, _, hm, _ => by simp [ATopDec.erase, mainRef] at hm
| .port _ _ _, _, _, _, _, hm, _ => by simp [ATopDec.erase, mainRef] at hm
| .seq a1 a2, C, E, PE, hI, hm, h => by
simp only [ATopDec.erase, mainRef, Bool.or_eq_true, Bool.and_eq_true] at hm
simp only [checkTopDec] at h
cases h1 : checkTopDec C a1 with
| none => rw [h1] at h; simp at h
| some r1 =>
obtain ⟨E1, PE1⟩ := r1
rw [h1] at h
simp only at h
cases h2 : checkTopDec (C.oplusE E1) a2 with
| none => rw [h2] at h; simp at h
| some r2 =>
obtain ⟨E2, PE2⟩ := r2
rw [h2] at h
simp only [Option.some.injEq, Prod.mk.injEq] at h
obtain ⟨rfl, rfl⟩ := h
simp only [Env.plus, FMap.find?_modify]
rcases hm with ⟨hp, hm2⟩ | ⟨hm1, hn2⟩
· obtain ⟨σ, st, hs, hb⟩ := main_bad a2 (C.oplusE E1) E2 PE2 (pres hcol hAU a1 C E1 PE1 hI hp h1) hm2 h2
exact ⟨σ, st, by rw [hs]; rfl, hb⟩
· obtain ⟨σ, st, hs, hb⟩ := main_bad a1 C E1 PE1 hI hm1 h1
exact ⟨σ, st, by rw [no_main hcol hAU a2 _ E2 PE2 hn2 h2, hs]; rfl, hb⟩Proved by a term, which Lean's kernel checks directly.
Theorems it uses
Used by
In StandardElmMech/Stat/RefuseTypes.lean: Refusals by type expressions (aliases, constructor arguments, annotations, ports) and by the type of main (typesFailB, mainFailB), for every choice of generated names and variable sorts.
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.