Theoremno_main
Statement
theorem no_main : ∀ (a : ATopDec) (C : Ctx) (E : Env) (PE : PortEnv), noMain a.erase = true →
checkTopDec C a = some (E, PE) → FMap.find? E.VE "main" = none
| .value VE vb, C, E, PE, hn, h => by
simp only [ATopDec.erase, noMain] at hn
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
simp only [Env.ofVE, closGroup, FMap.mapV]
rw [find?_map_key, ← hc.2, vb_noMain vb hn]
rfl
· cases h
| .types _ _ _ _, _, _, _, hn, _ => by simp [ATopDec.erase, noMain] at hn
| .port x ty U, C, E, PE, hn, h => by
simp only [ATopDec.erase, noMain, bne_iff_ne, ne_eq] at hn
replace h : elabPort C x ty U = some (E, PE) := h
obtain ⟨_, _, s, PE', hr⟩ := elabPort_shape h
simp only [Prod.mk.injEq] at hr
obtain ⟨rfl, rfl⟩ := hr
simp [Env.ofVE, FMap.find?, hn]
| .seq a1 a2, C, E, PE, hn, h => by
simp only [ATopDec.erase, noMain, Bool.and_eq_true] at hn
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]
rw [no_main a1 C E1 PE1 hn.1 h1, no_main a2 _ E2 PE2 hn.2 h2]
rflProved 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.