TheoremspecializeCon_bwd
Statement
theorem specializeCon_bwd (k : String) (cs : List Inh) (hr : List Inh) : ∀ (P : List (List PatN)),
(∀ r ∈ P, ∀ args rest, r = .con k args :: rest → args.length = cs.length) →
(∃ r' ∈ specializeCon k cs.length P, RowCovers r' (cs ++ hr)) → ∃ r ∈ P, RowCovers r (Inh.mkCon k cs :: hr)
| [], _, ⟨_, hm, _⟩ => by simp [specializeCon] at hm
| r :: P, hP, ⟨r', hm, hc⟩ => by
have ih0 : ∀ {r1 : List PatN}, r' ∈ specializeCon k cs.length P → ∃ r0 ∈ r1 :: P, RowCovers r0 (Inh.mkCon k cs :: hr)Proof
fun h' =>
let ⟨r0, h0, h1⟩ := specializeCon_bwd k cs hr P (fun r hr' => hP r (List.mem_cons_of_mem _ hr')) ⟨r', h', hc⟩
⟨r0, List.mem_cons_of_mem _ h0, h1⟩
match r, hm with
| .wild :: rest, hm =>
simp only [specializeCon, List.mem_cons] at hm
rcases hm with rfl | hm
· rw [RowCovers.append (by simp)] at hc
exact ⟨.wild :: rest, List.mem_cons_self, trivial, hc.2⟩
· exact ih0 hm
| .con k' args :: rest, hm =>
simp only [specializeCon] at hm
split at hm
· rename_i hk
subst hk
rcases List.mem_cons.mp hm with rfl | hm
· have hl := hP _ List.mem_cons_self args rest rfl
rw [RowCovers.append hl] at hc
exact ⟨_, List.mem_cons_self, (covers_mkCon_iff _ _ _ _).mpr ⟨rfl, hl, hc.1⟩, hc.2⟩
· exact ih0 hm
· exact ih0 hm
| .den _ :: _, hm => exact ih0 (by simpa [specializeCon] using hm)
| [], hm => exact ih0 (by simpa [specializeCon] using hm)Proved by a term, which Lean's kernel checks directly.
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.