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 (***************************************************************************)
37 exception ContentPpInternalError;;
38 exception NotEnoughElements;;
41 (* Utility functions *)
50 (* get_nth l n returns the nth element of the list l if it exists or *)
51 (* raises NotEnoughElements if l has less than n elements *)
55 | (n, he::tail) when n > 1 -> get_nth tail (n-1)
56 | (_,_) -> raise NotEnoughElements
61 else (" " ^ (blanks (n-1)));;
63 let rec pproof (p: Cic.annterm Content.proof) indent =
64 let module Con = Content in
66 (match p.Con.proof_name with
69 ((blanks indent) ^ "(" ^ s ^ ")"); flush stderr ;(indent + 1)
72 if (p.Con.proof_context = []) then new_indent
74 (pcontext p.Con.proof_context new_indent; (new_indent + 1)) in
75 papply_context p.Con.proof_apply_context new_indent1;
76 pconclude p.Con.proof_conclude new_indent1;
78 and pcontext c indent =
79 List.iter (pcontext_element indent) c
81 and pcontext_element indent =
82 let module Con = Content in
85 (match d.Con.dec_name with
89 ^ "Assume " ^ s ^ " : "
90 ^ (CicPp.ppterm (Deannotate.deannotate_term d.Con.dec_type)));
93 prerr_endline ((blanks indent) ^ "NO NAME!!"))
95 (match h.Con.dec_name with
99 ^ "Suppose " ^ s ^ " : "
100 ^ (CicPp.ppterm (Deannotate.deannotate_term h.Con.dec_type)));
103 prerr_endline ((blanks indent) ^ "NO NAME!!"))
104 | `Proof p -> pproof p indent
106 (match d.Con.def_name with
109 ((blanks indent) ^ "Let " ^ s ^ " = "
110 ^ (CicPp.ppterm (Deannotate.deannotate_term d.Con.def_term)));
113 prerr_endline ((blanks indent) ^ "NO NAME!!"))
115 prerr_endline ((blanks indent) ^ "Joint Def");
118 and papply_context ac indent =
119 List.iter(function p -> (pproof p indent)) ac
121 and pconclude concl indent =
122 let module Con = Content in
123 prerr_endline ((blanks indent) ^ "Apply method " ^ concl.Con.conclude_method ^ " to");flush stderr;
124 pargs concl.Con.conclude_args indent;
125 match concl.Con.conclude_conclusion with
126 None -> prerr_endline ((blanks indent) ^"No conclude conclusion");flush stderr
127 | Some t -> prerr_endline ((blanks indent) ^ "conclude" ^ concl.Con.conclude_method ^ (CicPp.ppterm (Deannotate.deannotate_term t)));flush stderr
129 and pargs args indent =
130 List.iter (parg indent) args
133 let module Con = Content in
135 Con.Aux n -> prerr_endline ((blanks (indent+1)) ^ n)
136 | Con.Premise prem -> prerr_endline ((blanks (indent+1)) ^ "Premise")
137 | Con.Lemma lemma -> prerr_endline ((blanks (indent+1)) ^ "Lemma")
139 prerr_endline ((blanks (indent+1)) ^ (CicPp.ppterm (Deannotate.deannotate_term t)))
140 | Con.ArgProof p -> pproof p (indent+1)
141 | Con.ArgMethod s -> prerr_endline ((blanks (indent+1)) ^ "A Method !!!")
144 let print_proof p = pproof p 0;;
146 let print_obj (_,_,_,obj) =
149 pcontext_element 0 (decl:> Cic.annterm Content.in_proof_context_element)
151 pcontext_element 0 (def:> Cic.annterm Content.in_proof_context_element)
152 | `Joint _ as jo -> pcontext_element 0 jo