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