diff options
| author | Pierre-Marie Pédrot | 2017-07-26 21:27:36 +0200 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2017-07-27 01:39:24 +0200 |
| commit | f204058d329fa78b506f4c3b3c4f97ecce504d4b (patch) | |
| tree | 97ab8dee9941ddfaced5059456b6864d3beb3cac /theories/Pattern.v | |
| parent | c9e7d7f1ceb22667e77a4ee49a4afc2cce6f9a2c (diff) | |
Adding necessary primitives to do pattern-matching over constr.
Diffstat (limited to 'theories/Pattern.v')
| -rw-r--r-- | theories/Pattern.v | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/theories/Pattern.v b/theories/Pattern.v new file mode 100644 index 0000000000..c2ba4162e8 --- /dev/null +++ b/theories/Pattern.v @@ -0,0 +1,30 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +Require Import Ltac2.Init. + +Ltac2 Type t := pattern. + +Ltac2 Type context. + +Ltac2 @ external matches : t -> constr -> (ident * constr) list := + "ltac2" "pattern_matches". +(** If the term matches the pattern, returns the bound variables. If it doesn't, + fail with [Match_failure]. Panics if not focussed. *) + +Ltac2 @ external matches_subterm : t -> constr -> context * ((ident * constr) list) := + "ltac2" "pattern_matches_subterm". +(** Returns a stream of results corresponding to all of the subterms of the term + that matches the pattern as in [matches]. The stream is encoded as a + backtracking value whose last exception is [Match_failure]. The additional + value compared to [matches] is the context of the match, to be filled with + the instantiate function. *) + +Ltac2 @ external instantiate : context -> constr -> constr := + "ltac2" "pattern_instantiate". +(** Fill the hole of a context with the given term. *) |
