This PR changes how match splitters are generated: Rather than rewriting the match statement, the match compilation pipeline is used again. The benefits are: * Re-doing the match compilation means we can do more intelligent book keeping, e.g. prove overlap assumptions only once and re-use the proof, or prune the context of the MVar to speed up `contradiction`. This may have allowed a different solution than #11200. * It would unblock #11105, as the existing splitter implementation would have trouble dealing with the matchers produced that way. * It provides the necessary machinery also for source-exposed “none of the above” bindings, a feature that we probably want at some point (and we mostly need to find good syntax for, see #3136, although maybe I should open a dedicated RFC). * It allows us to skip costly things during matcher creation that would only be useful for the splitter, and thus allows performance improvements like #11508. * We can drop the existing implementation. It’s not entirely free: * We have to run `simpH` twice, once for the match equations and once for the splitter.
20 lines
699 B
Text
20 lines
699 B
Text
set_option linter.unusedVariables false
|
|
|
|
noncomputable def myTest (x : List Bool) : Bool :=
|
|
match hx : x with
|
|
| x'@hx':(x::xs) => false
|
|
| x'@([]) => true
|
|
|
|
-- #check myTest.match_1
|
|
/--
|
|
info: private def myTest.match_1.splitter.{u_1} : (motive : List Bool → Sort u_1) →
|
|
(x : List Bool) →
|
|
((x_1 : Bool) → (xs : List Bool) → x = x_1 :: xs → motive (x_1 :: xs)) → (x = [] → motive []) → motive x :=
|
|
fun motive x h_1 h_2 =>
|
|
(fun x_1 => List.casesOn (motive := fun x_2 => x = x_2 → motive x_2) x_1 h_2 fun head tail => h_1 head tail) x ⋯
|
|
-/
|
|
#guard_msgs in
|
|
#print myTest.match_1.splitter
|
|
|
|
#guard_msgs in
|
|
example : myTest [] := by unfold myTest; split; contradiction; rfl
|