Theoremuseful_of_spec
A constructor that applies at τ: a vector useful after specialising by it gives one for the wildcard.
Statement
theorem useful_of_spec {tbl : ConTable} {mode : Mode} {τ : Ty} {τr : List Ty} {P : List (List PatN)}
{qs : List PatN} {k : String} {as : List Ty} (hlit : (litKind τ).isNone = true) (hc : (k, as) ∈ ctorsAt tbl τ) :
Useful tbl mode (as ++ τr) (specializeCon k as.length P) (List.replicate as.length .wild ++ qs) →
Useful tbl mode (τ :: τr) P (.wild :: qs)Proof
by
rintro ⟨hs', hw', hc', hn'⟩
have has := ctorsAt_argTys hc
obtain ⟨cs, hr, rfl, hwc, hwr⟩ := WT.split hw'
have hcl : cs.length = as.length := (WT.length hwc).symm
refine ⟨Inh.mkCon k cs :: hr, ⟨isInh_mkCon hlit has hcl (fun i hi => WT.get hwc i hi _), hwr⟩, ?_, ?_⟩
· rw [RowCovers.append (by simp [hcl])] at hc'
exact ⟨trivial, hc'.2⟩
· intro r hr0 hcov
obtain ⟨r', hr', hc''⟩ := specializeCon_fwd k cs hr P ⟨r, hr0, hcov⟩
rw [hcl] at hr'
exact hn' r' hr' hc''Proved 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.