Comparing patterns in match statements is somewhat strange.
The first thing you should know is that inside Coq there is no such thing as match for several variables or with deep correspondence: everything is translated in terms of simpler match operators. So you actually wrote syntactic sugar on the following term:
match x with | 0 => 10 | S x' => match x' with | 0 => 5 | S x'' => 10 end end
what Coq points to when he prints your proof. The problem is that this syntax sugar does not work on Ltac templates: thus, when writing an Ltac template that mentions match , you should always try to match it as if it were a sibling match .
The second problem is that you cannot bind part of the template to match : something like
match goal with | H : match ?x => _ | ?y => _ end = 5 |- _ => (* ... *) end
doesn't really make sense in Ltac.
You have two options for solving your problem:
Write down the match you expect with an exact list of constructors of your type on part of the template, for example.
match goal with | H : match x with 0 => _ | S _ => _ end = 5 |- _ => (* ... *) end
Use the special match (* ... *) with _ => _ end syntax match (* ... *) with _ => _ end , which matches any match :
match goal with | H : match x with _ => _ end = 5 |- _ => (* ... *) end
Often, as in your case, you still need to consider all match branches, including deep ones. This idiom is often useful in this case:
repeat match goal with | H : match ?x with _ => _ end = _ |- _ => destruct x; try solve [inversion H] end.
source share