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: closure.mli 11897 2009-02-09 19:28:02Z barras $ i*)
19
(* Flags for profiling reductions. *)
23
val with_stats: 'a Lazy.t -> 'a
25
(*s Delta implies all consts (both global (= by
26
[kernel_name]) and local (= by [Rel] or [Var])), all evars, and letin's.
27
Rem: reduction of a Rel/Var bound to a term is Delta, but reduction of
28
a LetIn expression is Letin reduction *)
32
val all_opaque : transparent_state
33
val all_transparent : transparent_state
35
(* Sets of reduction kinds. *)
36
module type RedFlagsSig = sig
40
(* The different kinds of reduction *)
45
val fCONST : constant -> red_kind
46
val fVAR : identifier -> red_kind
48
(* No reduction at all *)
51
(* Adds a reduction kind to a set *)
52
val red_add : reds -> red_kind -> reds
54
(* Removes a reduction kind to a set *)
55
val red_sub : reds -> red_kind -> reds
57
(* Adds a reduction kind to a set *)
58
val red_add_transparent : reds -> transparent_state -> reds
60
(* Build a reduction set from scratch = iter [red_add] on [no_red] *)
61
val mkflags : red_kind list -> reds
63
(* Tests if a reduction kind is set *)
64
val red_set : reds -> red_kind -> bool
66
(* Gives the constant list *)
67
val red_get_const : reds -> bool * evaluable_global_reference list
70
module RedFlags : RedFlagsSig
75
val betadeltaiota : reds
76
val betaiotazeta : reds
77
val betadeltaiotanolet : reds
79
val unfold_side_red : reds
80
val unfold_red : evaluable_global_reference -> reds
82
(***********************************************************************)
83
type table_key = id_key
86
val ref_value_cache: 'a infos -> table_key -> 'a option
87
val info_flags: 'a infos -> reds
88
val create: ('a infos -> constr -> 'a) -> reds -> env ->
89
(existential -> constr option) -> 'a infos
90
val evar_value : 'a infos -> existential -> constr option
92
(************************************************************************)
93
(*s Lazy reduction. *)
95
(* [fconstr] is the type of frozen constr *)
99
(* [fconstr] can be accessed by using the function [fterm_of] and by
100
matching on type [fterm] *)
104
| FAtom of constr (* Metas and Sorts *)
105
| FCast of fconstr * cast_kind * fconstr
108
| FConstruct of constructor
109
| FApp of fconstr * fconstr array
110
| FFix of fixpoint * fconstr subs
111
| FCoFix of cofixpoint * fconstr subs
112
| FCases of case_info * fconstr * fconstr * fconstr array
113
| FLambda of int * (name * constr) list * constr * fconstr subs
114
| FProd of name * fconstr * fconstr
115
| FLetIn of name * fconstr * fconstr * constr * fconstr subs
116
| FEvar of existential * fconstr subs
117
| FLIFT of int * fconstr
118
| FCLOS of constr * fconstr subs
121
(************************************************************************)
122
(*s A [stack] is a context of arguments, arguments are pushed by
123
[append_stack] one array at a time but popped with [decomp_stack]
127
| Zapp of fconstr array
128
| Zcase of case_info * fconstr * fconstr array
129
| Zfix of fconstr * stack
133
and stack = stack_member list
135
val empty_stack : stack
136
val append_stack : fconstr array -> stack -> stack
138
val decomp_stack : stack -> (fconstr * stack) option
139
val array_of_stack : stack -> fconstr array
140
val stack_assign : stack -> int -> fconstr -> stack
141
val stack_args_size : stack -> int
142
val stack_tail : int -> stack -> stack
143
val stack_nth : stack -> int -> fconstr
144
val zip_term : (fconstr -> constr) -> constr -> stack -> constr
146
(* To lazy reduce a constr, create a [clos_infos] with
147
[create_clos_infos], inject the term to reduce with [inject]; then use
148
a reduction function *)
150
val inject : constr -> fconstr
151
(* mk_atom: prevents a term from being evaluated *)
152
val mk_atom : constr -> fconstr
154
val fterm_of : fconstr -> fterm
155
val term_of_fconstr : fconstr -> constr
157
(fconstr subs -> constr -> fconstr) -> fconstr -> name * fconstr * fconstr
159
(* Global and local constant cache *)
161
val create_clos_infos :
162
?evars:(existential->constr option) -> reds -> env -> clos_infos
164
(* Reduction function *)
166
(* [norm_val] is for strong normalization *)
167
val norm_val : clos_infos -> fconstr -> constr
169
(* [whd_val] is for weak head normalization *)
170
val whd_val : clos_infos -> fconstr -> constr
172
(* [whd_stack] performs weak head normalization in a given stack. It
173
stops whenever a reduction is blocked. *)
175
clos_infos -> fconstr -> stack -> fconstr * stack
177
(* Conversion auxiliary functions to do step by step normalisation *)
179
(* [unfold_reference] unfolds references in a [fconstr] *)
180
val unfold_reference : clos_infos -> table_key -> fconstr option
182
(* [mind_equiv] checks whether two inductive types are intentionally equal *)
183
val mind_equiv : env -> inductive -> inductive -> bool
184
val mind_equiv_infos : clos_infos -> inductive -> inductive -> bool
186
(************************************************************************)
187
(*i This is for lazy debug *)
189
val lift_fconstr : int -> fconstr -> fconstr
190
val lift_fconstr_vect : int -> fconstr array -> fconstr array
192
val mk_clos : fconstr subs -> constr -> fconstr
193
val mk_clos_vect : fconstr subs -> constr array -> fconstr array
195
(fconstr subs -> constr -> fconstr) ->
196
fconstr subs -> constr -> fconstr
198
val kni: clos_infos -> fconstr -> stack -> fconstr * stack
199
val knr: clos_infos -> fconstr -> stack -> fconstr * stack
200
val kl : clos_infos -> fconstr -> constr
202
val to_constr : (lift -> fconstr -> constr) -> lift -> fconstr -> constr
203
val optimise_closure : fconstr subs -> constr -> fconstr subs * constr
205
(* End of cbn debug section i*)