Theoremuseful_spec_of
An inhabitant whose root is constructor k with argument types as, decomposed.
Statement
theorem useful_spec_of {tbl : ConTable} {mode : Mode} {τ : Ty} {τr : List Ty} {P : List (List PatN)}
{qs : List PatN} {h : Inh} {hr : List Inh} {k : String} {as : List Ty}
(hP : ∀ r ∈ P, PTypedList tbl (τ :: τr) r) (has : argTys tbl τ k = some as) (hh : IsInh tbl mode τ h)
(hroot : h.f [] = some (.con k as.length)) (hwr : WT tbl mode τr hr)
(hn : ∀ r ∈ P, ¬ RowCovers r (h :: hr)) (qa : List PatN) (hqa : RowCovers qa (h.children as.length))
(hcr : RowCovers qs hr) :
Useful tbl mode (as ++ τr) (specializeCon k as.length P) (qa ++ qs)Proof
by
obtain ⟨nd, hnd, _, hbeyond⟩ := hh.root
rw [hroot] at hnd
cases hnd
have hdec := decompose hroot (fun i p hi => hbeyond i p hi)
refine ⟨h.children as.length ++ hr, WT.append (WT.ofGet (by rw [children_length]) (fun i hi => ?_)) hwr, ?_, ?_⟩
· rw [children_getElem]; exact hh.child hroot has i hi
· rw [RowCovers.append (by rw [RowCovers.length hqa])]
exact ⟨hqa, hcr⟩
· intro r' hr' hcov
have hP' := con_rows_length has hP
rw [← children_length h as.length] at hr' hP'
obtain ⟨r, hr0, hc0⟩ := specializeCon_bwd k (h.children as.length) hr P (by
intro r hr0 args rest he; rw [children_length]; rw [children_length] at hP'; exact hP' r hr0 args rest he) ⟨r', hr', hcov⟩
rw [← hdec] at hc0
exact hn r hr0 hc0Proved 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.