exception Fail of string;;
+(*CSC: generatore di nomi? Chiedere il nome? *)
+let fresh_name =
+ let next_fresh_index = ref 0
+in
+ function () ->
+ incr next_fresh_index ;
+ "fresh_name" ^ string_of_int !next_fresh_index
+;;
+
(* lambda_abstract newmeta ty *)
(* returns a triple [bo],[context],[ty'] where *)
(* [ty] = Pi/LetIn [context].[ty'] ([context] is a vector!) *)
match n with
C.Name _ -> n
(*CSC: generatore di nomi? Chiedere il nome? *)
- | C.Anonimous -> C.Name "fresh_name"
+ | C.Anonimous -> C.Name (fresh_name ())
in
((Declaration (n',s))::ctx,ty,C.Lambda(n',s,bo))
| C.LetIn (n,s,t) ->
metano,context,ty
in
let context = cic_context_of_named_context context in
- if R.are_convertible (T.type_of_aux' metasenv context bo) ty then
+ if R.are_convertible context (T.type_of_aux' metasenv context bo) ty then
begin
refine_meta metano bo [] ;
goal := None
None -> assert false
| Some (metano,(context,ty)) -> metano,context,ty
in
- let term' = reduction_function term in
+ let ciccontext = cic_context_of_named_context context in
+ let term' = reduction_function ciccontext term in
(* We don't know if [term] is a subterm of [ty] or a subterm of *)
(* the type of one metavariable. So we replace it everywhere. *)
(*CSC: ma si potrebbe ovviare al problema. Ma non credo *)
None -> []
| Some (_,(context,_)) -> context
in
- let term' = reduction_function term in
+ let ciccontext = cic_context_of_named_context context in
+ let term' = reduction_function ciccontext term in
ProofEngineReduction.replace ~what:term ~with_what:term' ~where:ty
;;
None -> assert false
| Some (metano,(context,ty)) -> metano,context,ty
in
- let term' = CicReduction.whd term in
+ let ciccontext = cic_context_of_named_context context in
+ let term' = CicReduction.whd ciccontext term in
(* We don't know if [term] is a subterm of [ty] or a subterm of *)
(* the type of one metavariable. So we replace it everywhere. *)
(*CSC: ma si potrebbe ovviare al problema. Ma non credo *)
let ciccontext = cic_context_of_named_context context in
(* are_convertible works only on well-typed terms *)
ignore (CicTypeChecker.type_of_aux' metasenv ciccontext input) ;
- if CicReduction.are_convertible goal_input input then
+ if CicReduction.are_convertible ciccontext goal_input input then
begin
let ty' = ProofEngineReduction.replace goal_input input ty in
let metasenv' =
(* Takes a well-typed term and fully reduces it. *)
(*CSC: It does not perform reduction in a Case *)
-let reduce =
+let reduce context =
let rec reduceaux l =
let module C = Cic in
let module S = CicSubstitution in
(* change in every iteration, i.e. to the actual arguments for the *)
(* lambda-abstractions that precede the Fix. *)
(*CSC: It does not perform simplification in a Case *)
-let simpl =
+let simpl context =
(* reduceaux is equal to the reduceaux locally defined inside *)
(*reduce, but for the const case. *)
(**** Step 1 ****)
with
_ -> raise AlreadySimplified
in
- (match CicReduction.whd recparam with
+ (match CicReduction.whd context recparam with
C.MutConstruct _
| C.Appl ((C.MutConstruct _)::_) ->
let body' =
[] -> C.Const (uri,cookingsno)
| _ -> C.Appl ((C.Const (uri,cookingsno))::constant_args)
in
- let reduced_term_to_fold = reduce term_to_fold in
+ let reduced_term_to_fold = reduce context term_to_fold in
prerr_endline ("TERM TO FOLD: " ^ CicPp.ppterm term_to_fold) ; flush stderr ;
prerr_endline ("REDUCED TERM TO FOLD: " ^ CicPp.ppterm reduced_term_to_fold) ; flush stderr ;
replace reduced_term_to_fold term_to_fold res