]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_paramodulation/nCicParamod.ml
379aca1dcf906d8d96624a24f7d3e115cffa19bb
[helm.git] / helm / software / components / ng_paramodulation / nCicParamod.ml
1 (*
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.                     
5     ||I||                                                                
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_______________________________________________________________ *)
11
12 (* $Id: orderings.ml 9869 2009-06-11 22:52:38Z denes $ *)
13
14 let nparamod rdb metasenv subst context t table =
15   let module C = 
16     struct
17       let metasenv = metasenv
18       let subst = subst
19       let context = context
20     end
21   in
22   let module B : Terms.Blob 
23       with type t = NCic.term and type input = NCic.term 
24     = NCicBlob.NCicBlob(C) 
25   in
26   let module P = Paramod.Paramod(B) in
27   let module Pp = Pp.Pp(B) in
28   let bag, maxvar = Terms.empty_bag, 0 in
29   let (bag,maxvar), passives = 
30     HExtlib.list_mapi_acc (fun x _ a -> P.mk_passive a x) (bag,maxvar) table
31   in
32   let (bag,maxvar), goals = 
33     HExtlib.list_mapi_acc (fun x _ a -> P.mk_goal a x) (bag,maxvar) [t]
34   in
35   let solutions = 
36     P.paramod ~max_steps:max_int ~timeout:(Unix.gettimeofday () +. 300.0) 
37       ~g_passives:goals ~passives (bag,maxvar) 
38   in
39   List.map 
40     (fun (bag,i,l) ->
41       (* List.iter (fun x ->
42         print_endline (Pp.pp_unit_clause ~margin:max_int
43           (fst(Terms.M.find x bag)))) l; *)
44       let stamp = Unix.gettimeofday () in
45       let proofterm = NCicProof.mk_proof bag i l in
46       prerr_endline (Printf.sprintf "Got proof term in %fs"
47         (Unix.gettimeofday() -. stamp));
48       let metasenv, proofterm = 
49         let rec aux k metasenv = function
50           | NCic.Meta _ as t -> metasenv, t
51           | NCic.Implicit _ -> 
52               let metasenv,i,_,_=NCicMetaSubst.mk_meta metasenv context `Term in
53               metasenv, NCic.Meta (i,(k,NCic.Irl (List.length context)))
54           | t -> NCicUntrusted.map_term_fold_a 
55                   (fun _ k -> k+1) k aux metasenv t
56         in
57          aux 0 metasenv proofterm
58       in
59       let metasenv, subst, proofterm, _prooftype = 
60         NCicRefiner.typeof 
61           (rdb#set_coerc_db NCicCoercion.empty_db) 
62           metasenv subst context proofterm None
63       in
64       proofterm, metasenv, subst)
65     solutions
66 ;;
67   
68   
69
70