2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
12 (* $Id: orderings.ml 9869 2009-06-11 22:52:38Z denes $ *)
14 let nparamod rdb metasenv subst context (g_t,g_ty) table =
17 let metasenv = metasenv
22 let module B : Orderings.Blob
23 with type t = NCic.term
24 = Orderings.NRKBO(NCicBlob.NCicBlob(C))
26 let module P = Paramod.Paramod(B) in
27 let module Pp = Pp.Pp(B) in
29 let rec embed = function
30 | NCic.Meta (i,_) -> Terms.Var i, [i]
32 let rec aux acc l = function
34 |hd::tl -> if List.mem hd l then aux acc l tl else aux (hd::acc) l tl
36 let res,vars = List.fold_left
37 (fun (r,v) t -> let r1,v1 = embed t in (r1::r),aux [] v v1) ([],[]) l
38 in (Terms.Node (List.rev res)), vars
39 | t -> Terms.Leaf t, []
42 let embed t = fst (embed t) in
44 let saturate ~is_goal t ty =
46 NCicMetaSubst.saturate ~delta:max_int C.metasenv C.subst C.context ty 0
49 if args = [] then Terms.Leaf t
50 else Terms.Node (Terms.Leaf t :: List.map embed args)
52 let sty = embed sty in
53 proof, if is_goal then [sty],[] else [],[sty]
55 let goal = saturate ~is_goal:true g_t g_ty in
56 let hypotheses = List.map (fun (t,ty) -> saturate ~is_goal:false t ty) table in
57 (*let (bag,maxvar), passives =
58 HExtlib.list_mapi_acc (fun x _ a -> P.mk_passive a x) (bag,maxvar) table
60 let (bag,maxvar), goals =
61 HExtlib.list_mapi_acc (fun x _ a -> P.mk_goal a x) (bag,maxvar) [t]
64 P.paramod ~useage:true ~max_steps:max_int ~print_problem:true
67 | P.Error _ | P.GaveUp | P.Timeout _ -> []
68 | P.Unsatisfiable solutions ->
71 (* List.iter (fun x ->
72 print_endline (Pp.pp_unit_clause ~margin:max_int
73 (fst(Terms.M.find x bag)))) l; *)
74 let stamp = Unix.gettimeofday () in
75 let proofterm = NCicProof.mk_proof bag i l in
76 prerr_endline (Printf.sprintf "Got proof term in %fs"
77 (Unix.gettimeofday() -. stamp));
78 let metasenv, proofterm =
79 let rec aux k metasenv = function
80 | NCic.Meta _ as t -> metasenv, t
82 let metasenv,i,_,_=NCicMetaSubst.mk_meta metasenv context `Term in
83 metasenv, NCic.Meta (i,(k,NCic.Irl (List.length context)))
84 | t -> NCicUntrusted.map_term_fold_a
85 (fun _ k -> k+1) k aux metasenv t
87 aux 0 metasenv proofterm
89 let metasenv, subst, proofterm, _prooftype =
91 (rdb#set_coerc_db NCicCoercion.empty_db)
92 metasenv subst context proofterm None
94 proofterm, metasenv, subst)