- let term_equality = equality_of_term meta_proof goal in
- let meta_proof, (eq_ty, left, right), _, _ = term_equality in
- let active = [] in
-(* let passive = *)
-(* (EqualitySet.singleton term_equality, *)
-(* List.fold_left *)
-(* (fun res eq -> EqualitySet.add eq res) EqualitySet.empty equalities) *)
-(* in *)
- let passive = [term_equality], equalities in
- Printf.printf "\ncurrent goal: %s ={%s} %s\n"
- (PP.ppterm left) (PP.ppterm eq_ty) (PP.ppterm right);
- Printf.printf "\ncontext:\n%s\n" (PP.ppcontext context);
- Printf.printf "\nmetasenv:\n%s\n" (print_metasenv metasenv);
- Printf.printf "\nequalities:\n";
- List.iter
- (function (_, (ty, t1, t2), _, _) ->
- let w1 = weight_of_term t1 in
- let w2 = weight_of_term t2 in
- let res = nonrec_kbo t1 t2 in
- Printf.printf "{%s}: %s<%s> %s %s<%s>\n" (PP.ppterm ty)
- (PP.ppterm t1) (string_of_weight w1)
- (string_of_comparison res)
- (PP.ppterm t2) (string_of_weight w2))
- equalities;
- print_endline "--------------------------------------------------";
- let start = Sys.time () in
- print_endline "GO!";
- let res = given_clause env passive active in
- let finish = Sys.time () in
- match res with
- | Failure ->
- Printf.printf "NO proof found! :-(\n\n"
- | Success (Some proof, env) ->
- Printf.printf "OK, found a proof!:\n%s\n%.9f\n" (PP.ppterm proof)
- (finish -. start);
- | Success (None, env) ->
- Printf.printf "Success, but no proof?!?\n\n"
+ let term_equality = equality_of_term new_meta_goal goal in
+ let _, meta_proof, (eq_ty, left, right, ordering), _, _ = term_equality in
+ if is_identity env term_equality then
+ let proof =
+ Cic.Appl [Cic.MutConstruct (* reflexivity *)
+ (HelmLibraryObjects.Logic.eq_URI, 0, 1, []);
+ eq_ty; left]
+ in
+ let _ =
+ Printf.printf "OK, found a proof!\n";
+ let names = names_of_context context in
+ print_endline (PP.pp proof names)
+ in
+ ()
+ else
+ let equalities =
+ let equalities = equalities @ library_equalities in
+ debug_print (lazy (
+ Printf.sprintf "equalities:\n%s\n"
+ (String.concat "\n"
+ (List.map string_of_equality equalities))));
+ debug_print (lazy "SIMPLYFYING EQUALITIES...");
+ let rec simpl e others others_simpl =
+ let active = others @ others_simpl in
+ let tbl =
+ List.fold_left
+ (fun t (_, e) -> Indexing.index t e)
+ (Indexing.empty_table ()) active
+ in
+ let res = forward_simplify env e (active, tbl) in
+ match others with
+ | hd::tl -> (
+ match res with
+ | None -> simpl hd tl others_simpl
+ | Some e -> simpl hd tl (e::others_simpl)
+ )
+ | [] -> (
+ match res with
+ | None -> others_simpl
+ | Some e -> e::others_simpl
+ )
+ in
+ match equalities with
+ | [] -> []
+ | hd::tl ->
+ let others = List.map (fun e -> (Positive, e)) tl in
+ let res =
+ List.rev (List.map snd (simpl (Positive, hd) others []))
+ in
+ debug_print (lazy (
+ Printf.sprintf "equalities AFTER:\n%s\n"
+ (String.concat "\n"
+ (List.map string_of_equality res))));
+ res
+ in
+ let active = make_active () in
+ let passive = make_passive [term_equality] equalities in
+ Printf.printf "\ncurrent goal: %s\n"
+ (string_of_equality ~env term_equality);
+ Printf.printf "\ncontext:\n%s\n" (PP.ppcontext context);
+ Printf.printf "\nmetasenv:\n%s\n" (print_metasenv metasenv);
+ Printf.printf "\nequalities:\n%s\n"
+ (String.concat "\n"
+ (List.map
+ (string_of_equality ~env)
+ (equalities @ library_equalities)));
+ print_endline "--------------------------------------------------";
+ let start = Unix.gettimeofday () in
+ print_endline "GO!";
+ start_time := Unix.gettimeofday ();
+ let res =
+ (if !use_fullred then given_clause_fullred else given_clause)
+ env passive active
+ in
+ let finish = Unix.gettimeofday () in
+ let _ =
+ match res with
+ | ParamodulationFailure ->
+ Printf.printf "NO proof found! :-(\n\n"
+ | ParamodulationSuccess (Some goal, env) ->
+ let proof = Inference.build_proof_term goal in
+(* let proof = *)
+(* (\* let p = CicSubstitution.lift 1 proof in *\) *)
+(* let rec repl i = function *)
+(* | C.Meta _ -> C.Rel i *)
+(* | C.Appl l -> C.Appl (List.map (repl i) l) *)
+(* | C.Prod (n, s, t) -> C.Prod (n, s, repl (i+1) t) *)
+(* | C.Lambda (n, s, t) -> C.Lambda (n, s, repl (i+1) t) *)
+(* | t -> t *)
+(* in *)
+(* let p = repl 1 proof in *)
+(* p *)
+(* (\* C.Lambda (C.Anonymous, C.Rel 9, p) *\) *)
+(* in *)
+ let newmetasenv =
+ List.fold_left
+ (fun m (_, _, _, menv, _) -> m @ menv) metasenv equalities
+ in
+ let _ =
+ Printf.printf "OK, found a proof!\n";
+ (* REMEMBER: we have to instantiate meta_proof, we should use
+ apply the "apply" tactic to proof and status
+ *)
+ let names = names_of_context context in
+ print_endline (PP.pp proof names);
+ try
+ let ty, ug =
+ CicTypeChecker.type_of_aux' newmetasenv context proof ugraph
+ in
+(* Printf.printf "OK, found a proof!\n"; *)
+(* (\* REMEMBER: we have to instantiate meta_proof, we should use *)
+(* apply the "apply" tactic to proof and status *)
+(* *\) *)
+(* let names = names_of_context context in *)
+(* print_endline (PP.pp proof names); *)
+ (* print_endline (PP.ppterm proof); *)
+
+ print_endline (string_of_float (finish -. start));
+ Printf.printf
+ "\nGOAL was: %s\nPROOF has type: %s\nconvertible?: %s\n\n"
+ (CicPp.pp type_of_goal names) (CicPp.pp ty names)
+ (string_of_bool
+ (fst (CicReduction.are_convertible
+ context type_of_goal ty ug)));
+ with e ->
+ Printf.printf "\nEXCEPTION!!! %s\n" (Printexc.to_string e);
+ Printf.printf "MAXMETA USED: %d\n" !maxmeta;
+ print_endline (string_of_float (finish -. start));
+ in
+ ()
+
+ | ParamodulationSuccess (None, env) ->
+ Printf.printf "Success, but no proof?!?\n\n"
+ in
+ Printf.printf ("infer_time: %.9f\nforward_simpl_time: %.9f\n" ^^
+ "forward_simpl_new_time: %.9f\n" ^^
+ "backward_simpl_time: %.9f\n")
+ !infer_time !forward_simpl_time !forward_simpl_new_time
+ !backward_simpl_time;
+ Printf.printf "passive_maintainance_time: %.9f\n"
+ !passive_maintainance_time;
+ Printf.printf " successful unification/matching time: %.9f\n"
+ !Indexing.match_unif_time_ok;
+ Printf.printf " failed unification/matching time: %.9f\n"
+ !Indexing.match_unif_time_no;
+ Printf.printf " indexing retrieval time: %.9f\n"
+ !Indexing.indexing_retrieval_time;
+ Printf.printf " demodulate_term.build_newtarget_time: %.9f\n"
+ !Indexing.build_newtarget_time;
+ Printf.printf "derived %d clauses, kept %d clauses.\n"
+ !derived_clauses !kept_clauses;