Theoremderive_derivesTo
Under the restrictions of the module, the function's choices are among those the appendix allows.
Statement
theorem derive_derivesTo (m : SModule) (h : ModuleOK m) : DerivesTo m (deriveModule m)Proof
by
obtain ⟨-, -, -, -, -, -, -, -, -, -, -, -, -, -, htd, -, -, -, -, -, hanr, -⟩ := h
have hnames : ((aliasesOf m.decls).map (·.1)).Nodup := by
rw [aliases_names]
exact (List.nodup_append.mp htd).2.1
have hdecls : m.aliasDecls = (aliasesOf m.decls).map (fun a => (a.1, a.2.2)) := aliasDecls_eq m.decls
have hlen : m.aliasDecls.length = (aliasesOf m.decls).length := by rw [hdecls]; simp
have hrel : ∀ a b, a < (aliasesOf m.decls).length → b < (aliasesOf m.decls).length →
mentionsIdx (aliasesOf m.decls) a b = aliasRefers m a b := by
intro a b ha hb
simp only [mentionsIdx, aliasRefers, hdecls, List.getElem?_map, List.getElem?_eq_getElem ha,
List.getElem?_eq_getElem hb, Option.map_some, mentions]
have : (aliasesOf m.decls).any (fun x => x.1 == (aliasesOf m.decls)[b].1) = true :=
List.any_eq_true.mpr ⟨_, List.getElem_mem hb, by simp⟩
simp only [this, Bool.true_and]
congr 1
have hacyc : ∀ i < (aliasesOf m.decls).length, ¬ Plus (aliasesOf m.decls).length (mentionsIdx (aliasesOf m.decls)) i i := by
intro i hi hp
have := plus_congr (r' := aliasRefers m) hrel hp
rw [← hlen] at this
exact hanr i (by rw [hlen]; exact hi) this
refine ⟨rfl, rfl, _, _, _, components_valid _ _, aliasOrder_valid hnames hacyc, topBinds_rel _, rfl⟩Proved with tactics, which Lean expands into a proof term that its kernel checks.
Theorems it uses
In StandardElmMech/Src/DerivesTo.lean: The derived forms as the book states them, a relation (DerivesE, DerivesTo), and derive_derivesTo.
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.