1 (* Copyright (C) 2000, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (***************************************************************************)
30 (* Andrea Asperti <asperti@cs.unibo.it> *)
33 (***************************************************************************)
35 exception ContentPpInternalError;;
36 exception NotEnoughElements;;
39 (* Utility functions *)
48 (* get_nth l n returns the nth element of the list l if it exists or *)
49 (* raises NotEnoughElements if l has less than n elements *)
53 | (n, he::tail) when n > 1 -> get_nth tail (n-1)
54 | (_,_) -> raise NotEnoughElements
59 else (" " ^ (blanks (n-1)));;
61 let rec pproof (p: Cic.annterm Content.proof) indent =
62 let module Con = Content in
64 (match p.Con.proof_name with
67 ((blanks indent) ^ "(" ^ s ^ ")"); flush stderr ;(indent + 1)
70 if (p.Con.proof_context = []) then new_indent
72 (pcontext p.Con.proof_context new_indent; (new_indent + 1)) in
73 papply_context p.Con.proof_apply_context new_indent1;
74 pconclude p.Con.proof_conclude new_indent1;
76 and pcontext c indent =
77 List.iter (pcontext_element indent) c
79 and pcontext_element indent =
80 let module Con = Content in
83 (match d.Con.dec_name with
87 ^ "Assume " ^ s ^ " : "
88 ^ (CicPp.ppterm (Deannotate.deannotate_term d.Con.dec_type)));
91 prerr_endline ((blanks indent) ^ "NO NAME!!"))
93 (match h.Con.dec_name with
97 ^ "Suppose " ^ s ^ " : "
98 ^ (CicPp.ppterm (Deannotate.deannotate_term h.Con.dec_type)));
101 prerr_endline ((blanks indent) ^ "NO NAME!!"))
102 | `Proof p -> pproof p indent
104 (match d.Con.def_name with
107 ((blanks indent) ^ "Let " ^ s ^ " = "
108 ^ (CicPp.ppterm (Deannotate.deannotate_term d.Con.def_term)));
111 prerr_endline ((blanks indent) ^ "NO NAME!!"))
113 prerr_endline ((blanks indent) ^ "Joint Def");
116 and papply_context ac indent =
117 List.iter(function p -> (pproof p indent)) ac
119 and pconclude concl indent =
120 let module Con = Content in
121 prerr_endline ((blanks indent) ^ "Apply method " ^ concl.Con.conclude_method ^ " to");flush stderr;
122 pargs concl.Con.conclude_args indent;
123 match concl.Con.conclude_conclusion with
124 None -> prerr_endline ((blanks indent) ^"No conclude conclusion");flush stderr
125 | Some t -> prerr_endline ((blanks indent) ^ "conclude" ^ concl.Con.conclude_method ^ (CicPp.ppterm (Deannotate.deannotate_term t)));flush stderr
127 and pargs args indent =
128 List.iter (parg indent) args
131 let module Con = Content in
133 Con.Aux n -> prerr_endline ((blanks (indent+1)) ^ n)
134 | Con.Premise prem -> prerr_endline ((blanks (indent+1)) ^ "Premise")
135 | Con.Lemma lemma -> prerr_endline ((blanks (indent+1)) ^ "Lemma")
137 prerr_endline ((blanks (indent+1)) ^ (CicPp.ppterm (Deannotate.deannotate_term t)))
138 | Con.ArgProof p -> pproof p (indent+1)
139 | Con.ArgMethod s -> prerr_endline ((blanks (indent+1)) ^ "A Method !!!")
142 let print_proof p = pproof p 0;;
144 let print_obj (_,_,_,obj) =
147 pcontext_element 0 (decl:> Cic.annterm Content.in_proof_context_element)
149 pcontext_element 0 (def:> Cic.annterm Content.in_proof_context_element)
150 | `Joint _ as jo -> pcontext_element 0 jo