1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: clenv.mli 10856 2008-04-27 16:15:34Z herbelin $ i*)
24
(***************************************************************)
25
(* The Type of Constructions clausale environments. *)
27
(* [env] is the typing context
28
* [evd] is the mapping from metavar and evar numbers to their types
30
* [templval] is the template which we are trying to fill out.
31
* [templtyp] is its type.
36
templval : constr freelisted;
37
templtyp : constr freelisted }
39
(* Substitution is not applied on templenv (because [subst_clenv] is
40
applied only on hints which typing env is overwritten by the
42
val subst_clenv : substitution -> clausenv -> clausenv
44
(* subject of clenv (instantiated) *)
45
val clenv_value : clausenv -> constr
46
(* type of clenv (instantiated) *)
47
val clenv_type : clausenv -> types
48
(* substitute resolved metas *)
49
val clenv_nf_meta : clausenv -> constr -> constr
50
(* type of a meta in clenv context *)
51
val clenv_meta_type : clausenv -> metavariable -> types
53
val mk_clenv_from : evar_info sigma -> constr * types -> clausenv
55
evar_info sigma -> int option -> constr * types -> clausenv
56
val mk_clenv_type_of : evar_info sigma -> constr -> clausenv
57
val mk_clenv_from_env : env -> evar_map -> int option -> constr * types -> clausenv
59
(***************************************************************)
60
(* linking of clenvs *)
62
val connect_clenv : evar_info sigma -> clausenv -> clausenv
64
?allow_K:bool -> ?flags:unify_flags -> metavariable -> clausenv -> clausenv -> clausenv
66
(***************************************************************)
67
(* Unification with clenvs *)
69
(* Unifies two terms in a clenv. The boolean is [allow_K] (see [Unification]) *)
71
bool -> ?flags:unify_flags -> conv_pb -> constr -> constr -> clausenv -> clausenv
73
(* unifies the concl of the goal with the type of the clenv *)
74
val clenv_unique_resolver :
75
bool -> ?flags:unify_flags -> clausenv -> evar_info sigma -> clausenv
77
(* same as above ([allow_K=false]) but replaces remaining metas
78
with fresh evars if [evars_flag] is [true] *)
79
val evar_clenv_unique_resolver :
80
bool -> ?flags:unify_flags -> clausenv -> evar_info sigma -> clausenv
82
val clenv_dependent : bool -> clausenv -> metavariable list
84
val clenv_pose_metas_as_evars : clausenv -> metavariable list -> clausenv
86
(***************************************************************)
89
type arg_bindings = open_constr explicit_bindings
91
(* bindings where the key is the position in the template of the
92
clenv (dependent or not). Positions can be negative meaning to
93
start from the rightmost argument of the template. *)
94
val clenv_independent : clausenv -> metavariable list
95
val clenv_missing : clausenv -> metavariable list
97
val clenv_constrain_last_binding : constr -> clausenv -> clausenv
99
(* defines metas corresponding to the name of the bindings *)
100
val clenv_match_args : arg_bindings -> clausenv -> clausenv
102
val clenv_unify_meta_types : ?flags:unify_flags -> clausenv -> clausenv
104
(* start with a clenv to refine with a given term with bindings *)
106
(* the arity of the lemma is fixed *)
107
(* the optional int tells how many prods of the lemma have to be used *)
108
(* use all of them if None *)
109
val make_clenv_binding_apply :
110
evar_info sigma -> int option -> constr * constr -> open_constr bindings ->
112
val make_clenv_binding :
113
evar_info sigma -> constr * constr -> open_constr bindings -> clausenv
115
(* [clenv_environments sigma n t] returns [sigma',lmeta,ccl] where
116
[lmetas] is a list of metas to be applied to a proof of [t] so that
117
it produces the unification pattern [ccl]; [sigma'] is [sigma]
118
extended with [lmetas]; if [n] is defined, it limits the size of
119
the list even if [ccl] is still a product; otherwise, it stops when
120
[ccl] is not a product; example: if [t] is [forall x y, x=y -> y=x]
121
and [n] is [None], then [lmetas] is [Meta n1;Meta n2;Meta n3] and
122
[ccl] is [Meta n1=Meta n2]; if [n] is [Some 1], [lmetas] is [Meta n1]
123
and [ccl] is [forall y, Meta n1=y -> y=Meta n1] *)
124
val clenv_environments :
125
evar_defs -> int option -> types -> evar_defs * constr list * types
127
(* [clenv_environments_evars env sigma n t] does the same but returns
128
a list of Evar's defined in [env] and extends [sigma] accordingly *)
129
val clenv_environments_evars :
130
env -> evar_defs -> int option -> types -> evar_defs * constr list * types
132
(* [clenv_conv_leq env sigma t c n] looks for c1...cn s.t. [t <= c c1...cn] *)
134
env -> evar_map -> types -> constr -> int -> constr list
136
(* if the clause is a product, add an extra meta for this product *)
137
exception NotExtensibleClause
138
val clenv_push_prod : clausenv -> clausenv
140
(***************************************************************)
142
val pr_clenv : clausenv -> Pp.std_ppcmds