Pattern matching#
Pattern matching over terms#
Matches the term term-scrutinee, of type constr, against any of the term-case in order.
In a branch, a pattern variable ?x is bound to an OCaml variable named x of type constr. When a match is found, x contains the value of the matched variable ?x.
If a branch fails, matching may continue with later branches depending on match-key.
As in Ltac, matching is non-linear, i.e., pattern variables that occur more than once must be syntactically equal or be α-convertible.
Non-backtracking match: if a branch fails, the match is exited. In other words, match%lazy commits to the first matching branch.
Backtracking match: if a branch fails, the next branch is tried.
Multi-success match: behaves like match%rocq, except that a failure after the match also backtracks to the next branch.
Matches a subterm instead of the whole term (equivalent to Ltac’s context ident [ pattern ]). If ident is specified, the context is bound to an OCaml variable of the same name in the branch.
Pattern matching over goals#
Matches the current goal against any of the goal-pattern.
If reverse is specified, hypotheses are matched in the reverse order.
Specifies how to match the goal’s hypotheses and conclusion.
Matches a single hypothesis.
Matches the body of the hypothesis against term-pattern. If term-pattern is _, matching succeeds regardless of whether the hypothesis has a body or not.
Warning
Do not confuse _ with {|_|}: the former matches any hypothesis, while the latter matches only if the hypothesis has a body (regardless of the body).
Matches the body and type of the hypothesis against term-pattern.