Theoremapply_map
Statement
theorem apply_map (f : TyName → TyName) (S : Subst) :
∀ τ : Ty, (mapSubst f S).apply (mapTy f τ) = (S.apply τ).map (mapTy f)
| .var a => by
simp only [mapTy, Subst.apply, mapSubst, Option.map_some]
rw [find?_map_snd (mapTy f)]
cases FMap.find? S.ty a <;> simp [mapTy]
| .record ρ none => by
simp only [mapTy, Subst.apply]
rw [applyRow_map f S ρ]
cases S.applyRow ρ <;> simp [mapTy]
| .record ρ (some e) => by
simp only [mapTy, Subst.apply]
rw [applyRow_map f S ρ]
cases S.applyRow ρ with
| none => simp
| some ρ' =>
simp only [Option.map_some]
have hf : FMap.find? (mapSubst f S).row e = (FMap.find? S.row e).map (fun p => (mapRow f p.1, p.2))Proof
by
simp only [mapSubst]
exact find?_map_snd (fun p => (mapRow f p.1, p.2)) e S.row
rw [hf]
cases FMap.find? S.row e with
| none => simp [mapTy]
| some p =>
obtain ⟨ρ2, tl⟩ := p
simp only [Option.map_some, mapRow_rowMap]
rw [merge_map]
cases Row.merge ρ' ρ2 <;> simp [mapTy, mapRow_rowMap]
| .fn a b => by
simp only [mapTy, Subst.apply]
rw [apply_map f S a, apply_map f S b]
cases S.apply a <;> cases S.apply b <;> simp [mapTy]
| .con as t => by
simp only [mapTy, Subst.apply]
rw [applyList_map f S as]
cases S.applyList as <;> simp [mapTy]Proved with tactics, which Lean expands into a proof term that its kernel checks.
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.