]> matita.cs.unibo.it Git - helm.git/blob - matita/matitaprover.ml
added
[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 theorem eq_f: \\forall  A,B:Type.\\forall f:A\\to B.
45   \\forall x,y:A. eq A x y \\to eq B (f x) (f y).
46 intros.elim H.reflexivity.
47 qed.
48
49 theorem eq_f1: \\forall  A,B:Type.\\forall f:A\\to B.
50   \\forall x,y:A. eq A x y \\to eq B (f y) (f x).
51 intros.elim H.reflexivity.
52 qed.
53
54 default \"equality\"
55  " ^ buri ^ "/eq.ind
56  " ^ buri ^ "/sym_eq.con
57  " ^ buri ^ "/trans_eq.con
58  " ^ buri ^ "/eq_ind.con
59  " ^ buri ^ "/eq_elim_r.con
60  " ^ buri ^ "/eq_f.con
61  " ^ buri ^ "/eq_f1.con.
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 main () =
78   MatitaInit.fill_registry ();
79   let tptppath = ref "./" in
80   MatitaInit.add_cmdline_spec
81     ["-tptppath",Arg.String (fun s -> tptppath:= s),
82       "Where to find the Axioms/ and Problems/ directory"];
83   MatitaInit.parse_cmdline ();
84   MatitaInit.load_configuration_file ();
85   Helm_registry.set_bool "db.nodb" true;
86   Helm_registry.set_bool "matita.nodisk" true;
87   HLog.set_log_callback (fun _ _ -> ()); 
88   let args = Helm_registry.get_list Helm_registry.string "matita.args" in
89   let inputfile = 
90     match args with
91     | [file] -> file
92     | _ -> prerr_endline "You must specify exactly one .p file."; exit 1
93   in
94   let data = 
95      Tptp2grafite.tptp2grafite ~filename:inputfile ~tptppath:!tptppath
96      ~raw_preamble ()
97   in
98 (*   prerr_endline data; *)
99   let is = Ulexing.from_utf8_string data in
100   let gs = GrafiteSync.init () in
101   let ls = 
102     CicNotation2.load_notation ~include_paths:[] 
103       BuildTimeConf.core_notation_script 
104   in
105   Sys.catch_break true;
106   try
107     let _ = 
108       MatitaEngine.eval_from_stream 
109         ~first_statement_only:false 
110         ~include_paths:[]
111         ~clean_baseuri:true
112         ~do_heavy_checks:false
113         ~prompt:false
114         ls gs is
115          (fun _ _ -> ()) 
116 (*
117         (fun _ s -> 
118           let pp_ast_statement =
119             GrafiteAstPp.pp_statement ~term_pp:CicNotationPp.pp_term
120             ~lazy_term_pp:CicNotationPp.pp_term ~obj_pp:CicNotationPp.pp_obj
121           in
122           prerr_endline (pp_ast_statement s)) 
123 *)
124     in
125     exit 0
126   with exn ->
127     prerr_endline (snd (MatitaExcPp.to_string exn));
128     exit 1
129 ;;