Theoremdecompose
Statement
theorem decompose {h : Inh} {k : String} {m : Nat} (hroot : h.f [] = some (.con k m))
(hnone : ∀ i p, m ≤ i → h.f (i :: p) = none) : h = Inh.mkCon k (h.children m)Proof
by
apply Inh.ext; intro p
match p with
| [] => simp [Inh.mkCon, hroot, children_length]
| i :: p =>
simp only [Inh.mkCon]
by_cases hi : i < m
· have : i < (h.children m).length := by rw [children_length]; exact hi
rw [List.getElem?_eq_getElem this, children_getElem]
rfl
· rw [hnone i p (by omega)]
have : (h.children m)[i]? = none := by
rw [List.getElem?_eq_none_iff, children_length]; omega
rw [this]; rflProved with tactics, which Lean expands into a proof term that its kernel checks.
Theorems it uses
Used by
In StandardElmMech/Stat/PatternsProof.lean: The pattern decider is correct: every type is inhabited (inhabited), useful_spec, exhDec_sound, irrDec_sound.
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.