Debian Codegraph @

tactics/hipattern.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Names
12 open Evd
13 open EConstr
14 open Rocqlib
15
16 (** High-order patterns *)
17
18 (** Given a term with second-order variables in it,
19 represented by Meta's, and possibly applied using SoApp
20 terms, this function will perform second-order, binding-preserving,
21 matching, in the case where the pattern is a pattern in the sense
22 of Dale Miller.
23
24 ALGORITHM:
25
26 Given a pattern, we decompose it, flattening casts and apply's,
27 recursing on all operators, and pushing the name of the binder each
28 time we descend a binder.
29
30 When we reach a first-order variable, we ask that the corresponding
31 term's free-rels all be higher than the depth of the current stack.
32
33 When we reach a second-order application, we ask that the
34 intersection of the free-rels of the term and the current stack be
35 contained in the arguments of the application *)
36
37 (** I implemented the following functions which test whether a term [t]
38 is an inductive but non-recursive type, a general conjunction, a
39 general disjunction, or a type with no constructors.
40
41 They are more general than matching with [or_term], [and_term], etc,
42 since they do not depend on the name of the type. Hence, they
43 also work on ad-hoc disjunctions introduced by the user.
44 (Eduardo, 6/8/97). *)
45
46 type 'a matching_function = Environ.env -> evar_map -> constr -> 'a option
47 type testing_function = Environ.env -> evar_map -> constr -> bool
48
49 val match_with_non_recursive_type : (constr * constr list) matching_function
50 val is_non_recursive_type : testing_function
51
52 (** Non recursive type with no indices and exactly one argument for each
53 constructor; canonical definition of n-ary disjunction if strict *)
54 val match_with_disjunction : ?strict:bool -> ?onlybinary:bool -> (constr * constr list) matching_function
55 val is_disjunction : ?strict:bool -> ?onlybinary:bool -> testing_function
56
57 (** Non recursive tuple (one constructor and no indices) with no inner
58 dependencies; canonical definition of n-ary conjunction if strict *)
59 val match_with_conjunction : ?strict:bool -> ?onlybinary:bool -> (constr * constr list) matching_function
60 val is_conjunction : ?strict:bool -> ?onlybinary:bool -> testing_function
61
62 (** Non recursive tuple, possibly with inner dependencies *)
63 val match_with_record : (constr * constr list) matching_function
64 val is_record : testing_function
65
66 (** Like record but supports and tells if recursive (e.g. Acc) *)
67 val match_with_tuple : (constr * constr list * bool) matching_function
68 val is_tuple : testing_function
69
70 (** No constructor, possibly with indices *)
71 val match_with_empty_type : constr matching_function
72 val is_empty_type : testing_function
73
74 (** type with only one constructor and no arguments, possibly with indices *)
75 val match_with_unit_or_eq_type : constr matching_function
76 val is_unit_or_eq_type : testing_function
77
78 (** type with only one constructor and no arguments, no indices *)
79 val is_unit_type : testing_function
80
81 (** type with only one constructor, no arguments and at least one dependency *)
82 val is_inductive_equality : Environ.env -> inductive -> bool
83 val match_with_equality_type : (constr * constr list) matching_function
84 val is_equality_type : testing_function
85
86 val match_with_nottype : (constr * constr) matching_function
87 val is_nottype : testing_function
88
89 val match_with_forall_term : (Name.t EConstr.binder_annot * constr * constr) matching_function
90 val is_forall_term : testing_function
91
92 val match_with_imp_term : (constr * constr) matching_function
93 val is_imp_term : testing_function
94
95 (** I added these functions to test whether a type contains dependent
96 products or not, and if an inductive has constructors with dependent types
97 (excluding parameters). this is useful to check whether a conjunction is a
98 real conjunction and not a dependent tuple. (Pierre Corbineau, 13/5/2002) *)
99
100 val has_nodep_prod_after : int -> testing_function
101 val has_nodep_prod : testing_function
102
103 val match_with_nodep_ind : (constr * constr list * int) matching_function
104 val is_nodep_ind : testing_function
105
106 val match_with_sigma_type : (constr * constr list) matching_function
107 val is_sigma_type : testing_function
108
109 (** Recongnize inductive relation defined by reflexivity *)
110
111 type equation_kind =
112 | MonomorphicLeibnizEq of constr * constr
113 | PolymorphicLeibnizEq of constr * constr * constr
114 | HeterogenousEq of constr * constr * constr * constr
115
116 exception NoEquationFound
117
118 val match_with_equation:
119 Environ.env -> evar_map -> constr -> rocq_eq_data option * constr * equation_kind
120
121 (***** Destructing patterns bound to some theory *)
122
123 (** Match terms [eq A t u], [identity A t u] or [JMeq A t A u]
124 Returns associated lemmas and [A,t,u] or fails PatternMatchingFailure *)
125 val find_eq_data_decompose : Environ.env -> evar_map -> constr ->
126 rocq_eq_data * EInstance.t * (types * constr * constr)
127
128 (** Idem but fails with an error message instead of PatternMatchingFailure *)
129 val find_this_eq_data_decompose : Environ.env -> evar_map -> constr ->
130 rocq_eq_data * EInstance.t * (types * constr * constr)
131
132 (** A variant that returns more informative structure on the equality found *)
133 val find_eq_data : Environ.env -> evar_map -> constr -> rocq_eq_data * EInstance.t * equation_kind
134
135 (** Match a term of the form [(existT A P t p)]
136 Returns associated lemmas and [A,P,t,p] *)
137 val find_sigma_data_decompose : Environ.env -> evar_map -> constr ->
138 rocq_sigma_data * (EInstance.t * constr * constr * constr * constr)
139
140 (** Match a term of the form [{x:A|P}], returns [A] and [P] *)
141 val match_sigma : Environ.env -> evar_map -> constr -> constr * constr
142
143 val is_matching_sigma : Environ.env -> evar_map -> constr -> bool
144
145 (** Match a decidable equality judgement (e.g [{t=u:>T}+{~t=u}]), returns
146 [t,u,T] and a boolean telling if equality is on the left side *)
147 val match_eqdec : Environ.env -> evar_map -> constr -> bool * GlobRef.t * constr * constr * constr
148
149 (** Match a negation *)
150 val is_matching_not : Environ.env -> evar_map -> constr -> bool
151 val is_matching_imp_False : Environ.env -> evar_map -> constr -> bool
152
153 (** Test if a homogeneous relation (in Prop) and, if so, returns the domain *)
154 val is_homogeneous_relation : ?loc:Loc.t -> Environ.env -> evar_map -> constr -> types