let module M = CicMetaSubst in
let module HL = HelmLibraryObjects in
let cmp = !Utils.compare_terms in
+ ignore(CicTypeChecker.type_of_aux' metasenv context term);
let check = match termty with C.Implicit None -> false | _ -> true in
function
| [] -> None
let t2 = Unix.gettimeofday () in
match_unif_time_ok := !match_unif_time_ok +. (t2 -. t1);
r
- with Inference.MatchingFailure as e ->
+ with
+ | Inference.MatchingFailure as e ->
let t2 = Unix.gettimeofday () in
match_unif_time_no := !match_unif_time_no +. (t2 -. t1);
- raise e
+ raise e
+ | CicUtil.Meta_not_found _ as exn ->
+ prerr_endline "siam qua"; raise exn
in
Some (C.Rel (1 + lift_amount), subst', metasenv', ugraph',
(candidate, eq_URI))
let other' = U.guarded_simpl context (apply_subst s other) in *)
let other' = apply_subst s other in
let order = cmp c' other' in
- let names = U.names_of_context context in
if order = U.Gt then
res
else
let c' = apply_subst s c
and other' = apply_subst s other in
let order = cmp c' other' in
- let names = U.names_of_context context in
if order <> U.Lt && order <> U.Le then
res::(find_all_matches ~unif_fun metasenv context ugraph
lift_amount term termty tl)
let rec demodulation_aux ?(typecheck=false)
metasenv context ugraph table lift_amount term =
+ (* Printf.eprintf "term = %s\n" (CicPp.ppterm term); *)
+
let module C = Cic in
let module S = CicSubstitution in
let module M = CicMetaSubst in
let module HL = HelmLibraryObjects in
let module U = Utils in
let metasenv, context, ugraph = env in
- let _, proof, (eq_ty, left, right, order), metas, args = target in
+ let w, proof, (eq_ty, left, right, order), metas, args = target in
+ (* first, we simplify *)
+ let right = U.guarded_simpl context right in
+ let left = U.guarded_simpl context left in
+ let w = Utils.compute_equality_weight eq_ty left right in
+ let order = !Utils.compare_terms left right in
+ let target = w, proof, (eq_ty, left, right, order), metas, args in
+
let metasenv' = metasenv @ metas in
let maxmeta = ref newmeta in
in
let left, right = if is_left then newterm, right else left, newterm in
let m = (Inference.metas_of_term left) @ (Inference.metas_of_term right) in
- let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) (metas @ menv')
+ (* let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) (metas @ menv') *)
+ let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) (metasenv' @ menv')
and newargs = args
in
let ordering = !Utils.compare_terms left right in
match res with
| Some t ->
let newmeta, newtarget = build_newtarget true t in
- if (Inference.is_identity (metasenv', context, ugraph) newtarget) ||
+ if (Inference.is_weak_identity (metasenv', context, ugraph) newtarget) ||
(Inference.meta_convertibility_eq target newtarget) then
newmeta, newtarget
else
match res with
| Some t ->
let newmeta, newtarget = build_newtarget false t in
- if (Inference.is_identity (metasenv', context, ugraph) newtarget) ||
+ if (Inference.is_weak_identity (metasenv', context, ugraph) newtarget) ||
(Inference.meta_convertibility_eq target newtarget) then
newmeta, newtarget
else
newmeta, target
in
(* newmeta, newtarget *)
- (* tentiamo di normalizzare *)
- let w, p, (ty, left, right, o), m, a = newtarget in
- let left = U.guarded_simpl context left in
- let right = U.guarded_simpl context right in
- let w' = Utils.compute_equality_weight ty left right in
- let o' = !Utils.compare_terms left right in
- newmeta, (w', p, (ty, left, right, o'), m, a)
+ newmeta,newtarget
;;
let newgoal, newproof =
(* qua *)
let bo' = Utils.guarded_simpl context (apply_subst s (S.subst other bo)) in
- let t' =
- let name = C.Name ("x_SupR_" ^ (string_of_int !sup_r_counter)) in
- incr sup_r_counter;
- let l, r =
- if ordering = U.Gt then bo, S.lift 1 right else S.lift 1 left, bo in
- (name, ty, S.lift 1 eq_ty, l, r)
- in
let name = C.Name ("x_SupR_" ^ (string_of_int !sup_r_counter)) in
incr sup_r_counter;
let bo'' =
and newargs = args @ args' in
let eq' =
let w = Utils.compute_equality_weight eq_ty left right in
- (w, newproof, (eq_ty, left, right, neworder), newmenv, newargs)
- and env = (metasenv, context, ugraph) in
+ (w, newproof, (eq_ty, left, right, neworder), newmenv, newargs) in
let newm, eq' = Inference.fix_metas !maxmeta eq' in
newm, eq'
in
in
let new1 = List.map (build_new U.Gt) res1
and new2 = List.map (build_new U.Lt) res2 in
+(*
let ok e = not (Inference.is_identity (metasenv, context, ugraph) e) in
+*)
+ let ok e = not (Inference.is_identity (metasenv', context, ugraph) e) in
(!maxmeta,
(List.filter ok (new1 @ new2)))
;;
let metasenv, context, ugraph = env in
let maxmeta = ref newmeta in
let proof, metas, term = goal in
+ let term = Utils.guarded_simpl (~debug:true) context term in
+ let goal = proof, metas, term in
let metasenv' = metasenv @ metas in
let build_newgoal (t, subst, menv, ug, (eq_found, eq_URI)) =
| Inference.ProofGoalBlock (_, parent_proof) ->
(* debug_print (lazy "replacing another ProofGoalBlock"); *)
Inference.ProofGoalBlock (pb, parent_proof)
- | (Inference.SubProof (term, meta_index, p) as subproof) ->
-(* debug_print *)
-(* (lazy *)
-(* (Printf.sprintf "replacing %s" *)
-(* (Inference.string_of_proof subproof))); *)
+ | Inference.SubProof (term, meta_index, p) ->
Inference.SubProof (term, meta_index, repl p)
| _ -> assert false
in repl proof
bo, Inference.ProofGoalBlock (Inference.NoProof, goal_proof)
in
let m = Inference.metas_of_term newterm in
- let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) metas in
+ let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) (metas @ menv')in
!maxmeta, (newproof, newmetasenv, newterm)
in
let res =
let module HL = HelmLibraryObjects in
let metasenv, context, ugraph = env in
let maxmeta = ref newmeta in
- let proof, metas, term = theorem in
let term, termty, metas = theorem in
let metasenv' = metasenv @ metas in
-
+
let build_newtheorem (t, subst, menv, ug, (eq_found, eq_URI)) =
let pos, (_, proof', (ty, what, other, _), menv', args') = eq_found in
let what, other = if pos = Utils.Left then what, other else other, what in
Inference.BasicProof term)
in
(Inference.build_proof_term newproof, bo)
- in
+ in
+
let m = Inference.metas_of_term newterm in
- let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) metas in
+ let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) (metas @ menv') in
!maxmeta, (newterm, newty, newmetasenv)
in
let res =
newmeta, theorem
;;
-let demodulate_tac ~dbd ~pattern ((proof,goal) as initialstatus) =
- let module I = Inference in
- let curi,metasenv,pbo,pty = proof in
- let (metano,context,ty) as conjecture = CicUtil.lookup_meta goal metasenv in
- let eq_indexes, equalities, maxm = I.find_equalities context proof in
- let lib_eq_uris, library_equalities, maxm =
- I.find_library_equalities dbd context (proof, goal) (maxm+2) in
- let irl = CicMkImplicit.identity_relocation_list_for_metavariable context in
- let library_equalities = List.map snd library_equalities in
- let goalterm = Cic.Meta (metano,irl) in
- let initgoal = Inference.BasicProof goalterm, [], goalterm in
- let equalities = equalities @ library_equalities in
- let table =
- List.fold_left
- (fun tbl eq -> index tbl eq)
- empty equalities
- in
- let _,(newproof, newty, newmetasenv) = demodulation_goal
- maxm (metasenv,context,CicUniv.empty_ugraph) table initgoal
- in
- let proofterm = Inference.build_proof_term newproof in
- ProofEngineTypes.apply_tactic
- (PrimitiveTactics.apply_tac ~term:proofterm)
- initialstatus
-
-let demodulate_tac ~dbd ~pattern =
- ProofEngineTypes.mk_tactic (demodulate_tac ~dbd ~pattern)