]> matita.cs.unibo.it Git - helm.git/blob - matita/matitaprover.ml
79ab7683b04acbd045d140cfcf3e65eef04e6ce1
[helm.git] / matita / matitaprover.ml
1 (* Copyright (C) 2006, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 let raw_preamble buri = "
27 inductive eq (A:Type) (x:A) : A \\to Prop \\def refl_eq : eq A x x.
28
29 theorem sym_eq : \\forall A:Type.\\forall x,y:A. eq A x y \\to eq A y x.
30 intros.elim H. apply refl_eq.
31 qed.
32
33 theorem eq_elim_r:
34  \\forall A:Type.\\forall x:A. \\forall P: A \\to Prop.
35    P x \\to \\forall y:A. eq A y x \\to P y.
36 intros. elim (sym_eq ? ? ? H1).assumption.
37 qed.
38
39 theorem trans_eq : 
40     \\forall A:Type.\\forall x,y,z:A. eq A x y \\to eq A y z \\to eq A x z.
41 intros.elim H1.assumption.
42 qed.
43
44 default \"equality\"
45  " ^ buri ^ "/eq.ind
46  " ^ buri ^ "/sym_eq.con
47  " ^ buri ^ "/trans_eq.con
48  " ^ buri ^ "/eq_ind.con
49  " ^ buri ^ "/eq_elim_r.con
50  " ^ buri ^ "/eq_f.con
51  " ^ buri ^ "/eq_f1.con.
52
53 theorem eq_f: \\forall  A,B:Type.\\forall f:A\\to B.
54   \\forall x,y:A. eq A x y \\to eq B (f x) (f y).
55 intros.elim H.reflexivity.
56 qed.
57
58 theorem eq_f1: \\forall  A,B:Type.\\forall f:A\\to B.
59   \\forall x,y:A. eq A x y \\to eq B (f y) (f x).
60 intros.elim H.reflexivity.
61 qed.
62
63 inductive ex (A:Type) (P:A \\to Prop) : Prop \\def
64     ex_intro: \\forall x:A. P x \\to ex A P.
65 interpretation \"exists\" 'exists \\eta.x =
66   (" ^ buri ^ "/ex.ind#xpointer(1/1) _ x).
67
68 notation < \"hvbox(\\exists ident i opt (: ty) break . p)\"
69   right associative with precedence 20
70 for @{ 'exists ${default
71   @{\\lambda ${ident i} : $ty. $p)}
72   @{\\lambda ${ident i} . $p}}}.
73
74 "
75 ;;
76
77 let p_to_ma ?timeout ~tptppath ~filename () = 
78   let data = 
79      Tptp2grafite.tptp2grafite ?timeout ~filename ~tptppath:tptppath
80      ~raw_preamble ()
81   in
82   data
83 ;;
84
85 let main () =
86   let tptppath = ref "./" in
87   let timeout = ref 600 in
88   MatitaInit.add_cmdline_spec
89     ["-tptppath",Arg.String (fun s -> tptppath:= s),
90        "Where to find the Axioms/ and Problems/ directory";
91      "-timeout", Arg.Int (fun x -> timeout := x),
92        "Timeout in seconds"];
93   MatitaInit.parse_cmdline_and_configuration_file ();
94   Helm_registry.set_bool "matita.nodisk" true;
95   HLog.set_log_callback (fun _ _ -> ()); 
96   let args = Helm_registry.get_list Helm_registry.string "matita.args" in
97   let inputfile = 
98     match args with
99     | [file] -> file
100     | _ -> prerr_endline "You must specify exactly one .p file."; exit 1
101   in
102   let data = 
103     p_to_ma ~timeout:!timeout ~filename:inputfile ~tptppath:!tptppath ()
104   in
105 (*   prerr_endline data; *)
106   let is = Ulexing.from_utf8_string data in
107   let gs = GrafiteSync.init "cic:/TPTP/" in
108   let ls = 
109     CicNotation2.load_notation ~include_paths:[] 
110       BuildTimeConf.core_notation_script 
111   in
112   Sys.catch_break true;
113   try
114     let _ = 
115       MatitaEngine.eval_from_stream 
116         ~first_statement_only:false 
117         ~include_paths:[]
118         ~do_heavy_checks:false
119         ~prompt:false
120         ls gs is
121          (fun _ _ -> ()) 
122 (*
123         (fun _ s -> 
124           let pp_ast_statement =
125             GrafiteAstPp.pp_statement ~term_pp:CicNotationPp.pp_term
126             ~lazy_term_pp:CicNotationPp.pp_term ~obj_pp:CicNotationPp.pp_obj
127           in
128           prerr_endline (pp_ast_statement s)) 
129 *)
130     in
131     exit 0
132   with exn ->
133     prerr_endline (snd (MatitaExcPp.to_string exn));
134     exit 1
135 ;;