1 (* Copyright (C) 2003-2005, 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 module P = Mpresentation
41 let p_mtr a b = Mpresentation.Mtr(a,b)
42 let p_mtd a b = Mpresentation.Mtd(a,b)
43 let p_mtable a b = Mpresentation.Mtable(a,b)
44 let p_mtext a b = Mpresentation.Mtext(a,b)
45 let p_mi a b = Mpresentation.Mi(a,b)
46 let p_mo a b = Mpresentation.Mo(a,b)
47 let p_mrow a b = Mpresentation.Mrow(a,b)
48 let p_mphantom a b = Mpresentation.Mphantom(a,b)
53 split (n-1) (List.tl l) in
56 let get_xref = function
58 | `Hypothesis d -> d.Con.dec_id
59 | `Proof p -> p.Con.proof_id
60 | `Definition d -> d.Con.def_id
61 | `Joint jo -> jo.Con.joint_id
64 RenderingAttrs.spacing_attributes `BoxML
65 @ RenderingAttrs.indent_attributes `BoxML
67 let make_row items concl =
68 B.b_hv hv_attrs (items @ [ concl ])
71 B.b_v attrs [B.b_h [] items; B.b_indent concl]
73 B.b_h attrs (items@[B.b_space; concl]) *)
75 let make_concl ?(attrs=[]) verb concl =
76 B.b_hv (hv_attrs @ attrs) [ B.b_kw verb; concl ]
79 B.b_v attrs [ B.b_kw verb; B.b_indent concl]
81 B.b_h attrs [ B.b_kw verb; B.b_space; concl ] *)
83 let make_args_for_apply term2pres args =
84 let make_arg_for_apply is_first arg row =
87 Con.Aux n -> assert false
90 (match prem.Con.premise_binder with
93 (B.b_object (P.Mi ([], name)))::row
96 Some "helm", "xref", lemma.Con.lemma_id;
97 Some "xlink", "href", lemma.Con.lemma_uri ]
99 (B.b_object (P.Mi(lemma_attrs,lemma.Con.lemma_name)))::row
101 if is_first || (not b) then
103 else (B.b_object (P.Mi([],"?")))::row
106 (B.b_object (P.Mi([],"?")))::row
108 if is_first then res else B.skip::res
112 make_arg_for_apply true hd
113 (List.fold_right (make_arg_for_apply false) tl [])
116 let get_name ?(default="_") = function
120 let add_xref id = function
121 | B.Text (attrs, t) -> B.Text (((Some "helm", "xref", id) :: attrs), t)
122 | _ -> assert false (* TODO, add_xref is meaningful for all boxes *)
124 let rec justification ~ignore_atoms term2pres p =
125 if p.Con.proof_conclude.Con.conclude_method = "Exact" &&
130 (p.Con.proof_conclude.Con.conclude_method = "Exact" && not ignore_atoms) ||
131 (p.Con.proof_context = [] &&
132 p.Con.proof_apply_context = [] &&
133 p.Con.proof_conclude.Con.conclude_method = "Apply")
136 make_args_for_apply term2pres p.Con.proof_conclude.Con.conclude_args
139 (B.b_kw "by")::B.b_space::
140 B.Text([],"(")::pres_args@[B.Text([],")")])], None
142 [B.H([],[B.b_kw "by"; B.b_space; B.b_kw "proof"])],
143 Some (B.b_toggle [B.b_kw "proof";B.indent (proof2pres true term2pres p)])
145 and proof2pres ?skip_initial_lambdas is_top_down term2pres p =
146 let rec proof2pres ?skip_initial_lambdas_internal is_top_down p in_bu_conversion =
151 | `Hypothesis _ -> true
153 ((List.filter is_decl p.Con.proof_context) != []) in
154 let omit_conclusion = (not indent) && (p.Con.proof_context != []) in
156 (match p.Con.proof_conclude.Con.conclude_conclusion with
158 | Some t -> Some (term2pres t)) in
162 ?skip_initial_lambdas_internal:
163 (match skip_initial_lambdas_internal with
164 Some (`Later s) -> Some (`Now s)
166 is_top_down p.Con.proof_name p.Con.proof_conclude indent
167 omit_conclusion in_bu_conversion in
170 (if p.Con.proof_conclude.Con.conclude_method = "BU_Conversion" then
174 p.Con.proof_apply_context
176 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
179 (match skip_initial_lambdas_internal with
180 Some (`Now n) -> snd (HExtlib.split_nth n p.Con.proof_context)
181 | _ -> p.Con.proof_context)
184 let body = B.V([],[B.b_kw ("(*<<" ^ p.Con.proof_conclude.Con.conclude_method ^ (if is_top_down then "(TD)" else "(NTD)") ^ "*)"); body; B.b_kw "(*>>*)"]) in
185 match p.Con.proof_name with
193 make_concl ~attrs:[ Some "helm", "xref", p.Con.proof_id ]
195 B.b_toggle [ B.H ([], [concl; B.skip ; B.Text([],"(");
196 B.Object ([], P.Mi ([],name));
197 B.Text([],")") ]) ; body ]
201 and context2pres c continuation =
202 (* we generate a subtable for each context element, for selection
204 The table generated by the head-element does not have an xref;
205 the whole context-proof is already selectable *)
211 (fun ce continuation ->
212 let xref = get_xref ce in
213 B.V([Some "helm", "xref", xref ],
214 [B.H([Some "helm", "xref", "ce_"^xref],
215 [ce2pres_in_proof_context_element ce]);
216 continuation])) tl continuation in
217 let hd_xref= get_xref hd in
219 [B.H([Some "helm", "xref", "ce_"^hd_xref],
220 [ce2pres_in_proof_context_element hd]);
223 and ce2pres_in_joint_context_element = function
224 | `Inductive _ -> assert false (* TODO *)
225 | (`Declaration _) as x -> ce2pres x
226 | (`Hypothesis _) as x -> ce2pres x
227 | (`Proof _) as x -> ce2pres x
228 | (`Definition _) as x -> ce2pres x
230 and ce2pres_in_proof_context_element = function
232 B.H ([],(List.map ce2pres_in_joint_context_element ho.Content.joint_defs))
233 | (`Declaration _) as x -> ce2pres x
234 | (`Hypothesis _) as x -> ce2pres x
235 | (`Proof _) as x -> ce2pres x
236 | (`Definition _) as x -> ce2pres x
241 let ty = term2pres d.Con.dec_type in
245 B.Object ([], P.Mi([],get_name d.Con.dec_name));
250 let ty = term2pres h.Con.dec_type in
257 B.Object ([], P.Mi ([],get_name h.Con.dec_name));
261 proof2pres false p false
263 let term = term2pres d.Con.def_term in
265 [ B.b_kw "let"; B.b_space;
266 B.Object ([], P.Mi([],get_name d.Con.def_name));
267 B.Text([],Utf8Macro.unicode_of_tex "\\def");
270 and acontext2pres is_top_down ac continuation indent in_bu_conversion =
275 let continuation = aux tl in
276 (* Applicative context get flattened and the "body" of a BU_Conversion
277 is put in the applicative context. Thus two different situations
279 {method = "BU_Conversion"; applicative_context=[p1; ...; pn]}
280 {method = xxx; applicative_context =
281 [ p1; ...; pn; {method="BU_Conversion"} ; p_{n+1}; ... ; pm ]}
282 In both situations only pn must be processed in in_bu_conversion
285 let in_bu_conversion =
287 [] -> in_bu_conversion
288 | p::_ -> p.Con.proof_conclude.Con.conclude_method = "BU_Conversion"
290 let hd = proof2pres is_top_down p in_bu_conversion in
291 let hd = if indent then B.indent hd else hd in
292 B.V([Some "helm","xref",p.Con.proof_id],
293 [B.H([Some "helm","xref","ace_"^p.Con.proof_id],[hd]);
297 and conclude2pres ?skip_initial_lambdas_internal is_top_down name conclude indent omit_conclusion in_bu_conversion =
299 match conclude.Con.conclude_conclusion with
300 Some t (*when not omit_conclusion or
301 (* CSC: I ignore the omit_conclusion flag in this case. *)
302 (* CSC: Is this the correct behaviour? In the stylesheets *)
303 (* CSC: we simply generated nothing (i.e. the output type *)
304 (* CSC: of the function should become an option. *)
305 conclude.Con.conclude_method = "BU_Conversion" *) ->
306 let concl = term2pres t in
307 if conclude.Con.conclude_method = "BU_Conversion" then
309 (make_concl "that is equivalent to" concl ::
310 if is_top_down then [B.b_space ; B.b_kw "done";
311 B.Text([],".")] else [B.Text([],".")])
312 else if conclude.Con.conclude_method = "FalseInd" then
313 (* false ind is in charge to add the conclusion *)
319 conclude.Con.conclude_method = "Intros+LetTac"
321 let name = get_name name in
325 (match conclude.Con.conclude_conclusion with
326 None -> B.Text([],"NO EXPECTED!!!")
327 | Some c -> term2pres c)
329 [make_concl "we need to prove" expected;
332 B.Object ([], P.Mi ([],name));
339 conclude_aux ?skip_initial_lambdas_internal is_top_down conclude in
341 if conclude.Con.conclude_method = "Intros+LetTac"
342 || conclude.Con.conclude_method = "ByInduction"
343 || conclude.Con.conclude_method = "TD_Conversion"
344 || conclude.Con.conclude_method = "Eq_chain"
347 else if omit_conclusion then
348 B.H([], [B.b_kw "done" ; B.Text([],".") ])
351 ((if not is_top_down || in_bu_conversion then
352 (make_concl "we proved" concl) ::
353 if not is_top_down then
354 let name = get_name ~default:"previous" name in
355 [B.b_space; B.Text([],"(" ^ name ^ ")")]
358 ) @ if not in_bu_conversion then [B.Text([],".")] else [])
360 B.V ([], prequel @ [conclude_body; ann_concl])
361 | _ -> conclude_aux ?skip_initial_lambdas_internal is_top_down conclude
364 B.indent (B.H ([Some "helm", "xref", conclude.Con.conclude_id],
367 B.H ([Some "helm", "xref", conclude.Con.conclude_id],[tconclude_body])
369 and conclude_aux ?skip_initial_lambdas_internal is_top_down conclude =
370 if conclude.Con.conclude_method = "TD_Conversion" then
372 (match conclude.Con.conclude_conclusion with
373 None -> B.Text([],"NO EXPECTED!!!")
374 | Some c -> term2pres c) in
376 (match conclude.Con.conclude_args with
377 [Con.ArgProof p] -> p
378 | _ -> assert false) in
380 (match subproof.Con.proof_conclude.Con.conclude_conclusion with
381 None -> B.Text([],"NO SYNTH!!!")
382 | Some c -> (term2pres c)) in
385 [make_concl "we need to prove" expected;
386 B.H ([],[make_concl "or equivalently" synth; B.Text([],".")]);
387 proof2pres true subproof false])
388 else if conclude.Con.conclude_method = "BU_Conversion" then
390 else if conclude.Con.conclude_method = "Exact" then
392 (match conclude.Con.conclude_args with
393 [Con.Term (b,t)] -> assert (not b);term2pres t
395 (match p.Con.premise_binder with
396 | None -> assert false; (* unnamed hypothesis ??? *)
397 | Some s -> B.Text([],s))
398 | err -> assert false) in
399 (match conclude.Con.conclude_conclusion with
401 B.b_h [] [B.b_kw "by"; B.b_space; arg]
403 B.b_h [] [B.b_kw "by"; B.b_space; arg]
405 else if conclude.Con.conclude_method = "Intros+LetTac" then
406 (match conclude.Con.conclude_args with
408 (match conclude.Con.conclude_args with
410 proof2pres ?skip_initial_lambdas_internal true p false
415 (match conclude.Con.conclude_conclusion with
416 None -> B.Text([],"NO Conclusion!!!")
417 | Some c -> term2pres c) in
418 (match conclude.Con.conclude_args with
421 ([None,"align","baseline 1"; None,"equalrows","false";
422 None,"columnalign","left"],
423 [B.H([],[B.Object([],proof2pres p false)]);
425 (make_concl "we proved 1" conclusion))])]);
428 else if (conclude.Con.conclude_method = "Case") then
430 else if (conclude.Con.conclude_method = "ByInduction") then
432 else if (conclude.Con.conclude_method = "Exists") then
434 else if (conclude.Con.conclude_method = "AndInd") then
436 else if (conclude.Con.conclude_method = "FalseInd") then
438 else if conclude.Con.conclude_method = "RewriteLR"
439 || conclude.Con.conclude_method = "RewriteRL" then
440 let justif1,justif2 =
441 (match (List.nth conclude.Con.conclude_args 6) with
442 Con.ArgProof p -> justification ~ignore_atoms:true term2pres p
443 | _ -> assert false) in
449 let index_term1, index_term2 =
450 if (conclude.Con.conclude_method = "RewriteLR" && is_top_down)
451 || (conclude.Con.conclude_method = "RewriteRL" && not is_top_down)
455 (match List.nth conclude.Con.conclude_args index_term1 with
456 Con.Term (_,t) -> term2pres t
457 | _ -> assert false) in
459 (match List.nth conclude.Con.conclude_args index_term2 with
460 Con.Term (_,t) -> term2pres t
461 | _ -> assert false) in
468 [B.b_kw "we proved (" ;
471 term2; B.b_kw ") (equality)."])]
478 B.b_space; (B.b_kw "with");
480 B.b_space; justif1])::
481 match justif2 with None -> [] | Some j -> [B.indent j])
483 B.V([], justif @ [B.b_kw "by _"])
484 else if conclude.Con.conclude_method = "Eq_chain" then
485 let justification p =
486 let j1,j2 = justification ~ignore_atoms:false term2pres p in
487 j1, match j2 with Some j -> [j] | None -> []
492 | (Con.ArgProof p)::(Con.Term (_,t))::tl ->
493 let justif1,justif2 = justification p in
494 B.HOV(RenderingAttrs.indent_attributes `BoxML,([B.b_kw
495 "=";B.b_space;term2pres t;B.b_space]@justif1@
496 (if tl <> [] then [B.Text ([],".")] else [B.b_space; B.b_kw "done" ; B.Text([],".")])@
501 match List.hd conclude.Con.conclude_args with
502 | Con.Term (_,t) -> t
507 [B.b_kw "conclude";B.b_space;term2pres hd;
508 B.V ([],aux (List.tl conclude.Con.conclude_args))])
511 [B.b_kw "obtain";B.b_space;B.b_kw "FIXMEXX"; B.b_space;term2pres hd;
512 B.V ([],aux (List.tl conclude.Con.conclude_args))])
513 else if conclude.Con.conclude_method = "Apply" then
515 make_args_for_apply term2pres conclude.Con.conclude_args in
519 B.Text([],"(")::pres_args@[B.Text([],")")])
522 B.b_kw ("Apply method" ^ conclude.Con.conclude_method ^ " to");
523 (B.indent (B.V ([], args2pres conclude.Con.conclude_args)))])
525 and args2pres l = List.map arg2pres l
529 Con.Aux n -> B.b_kw ("aux " ^ n)
530 | Con.Premise prem -> B.b_kw "premise"
531 | Con.Lemma lemma -> B.b_kw "lemma"
532 | Con.Term (_,t) -> term2pres t
533 | Con.ArgProof p -> proof2pres true p false
534 | Con.ArgMethod s -> B.b_kw "method"
537 let proof_conclusion =
538 (match conclude.Con.conclude_conclusion with
539 None -> B.b_kw "No conclusion???"
540 | Some t -> term2pres t) in
541 let arg,args_for_cases =
542 (match conclude.Con.conclude_args with
543 Con.Aux(_)::Con.Aux(_)::Con.Term(_)::arg::tl ->
545 | _ -> assert false) in
549 Con.Aux n -> B.b_kw "an aux???"
550 | Con.Premise prem ->
551 (match prem.Con.premise_binder with
552 None -> B.b_kw "previous"
553 | Some n -> B.Object ([], P.Mi([],n)))
554 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
557 | Con.ArgProof p -> B.b_kw "a proof???"
558 | Con.ArgMethod s -> B.b_kw "a method???")
560 (make_concl "we proceed by cases on" case_arg) in
562 (make_concl "to prove" proof_conclusion) in
563 B.V ([], case_on::to_prove::(make_cases args_for_cases))
565 and byinduction conclude =
566 let proof_conclusion =
567 (match conclude.Con.conclude_conclusion with
568 None -> B.b_kw "No conclusion???"
569 | Some t -> term2pres t) in
570 let inductive_arg,args_for_cases =
571 (match conclude.Con.conclude_args with
573 let l1,l2 = split (int_of_string n) tl in
574 let last_pos = (List.length l2)-1 in
575 List.nth l2 last_pos,l1
576 | _ -> assert false) in
579 (match inductive_arg with
580 Con.Aux n -> B.b_kw "an aux???"
581 | Con.Premise prem ->
582 (match prem.Con.premise_binder with
583 None -> B.b_kw "previous"
584 | Some n -> B.Object ([], P.Mi([],n)))
585 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
588 | Con.ArgProof p -> B.b_kw "a proof???"
589 | Con.ArgMethod s -> B.b_kw "a method???") in
590 (make_concl "we proceed by induction on" arg) in
592 B.H ([], [make_concl "to prove" proof_conclusion ; B.Text([],".")]) in
593 B.V ([], induction_on::to_prove::(make_cases args_for_cases))
595 and make_cases l = List.map make_case l
601 (match p.Con.proof_name with
602 None -> B.b_kw "no name for case!!"
603 | Some n -> B.Object ([], P.Mi([],n))) in
607 `Hypothesis h -> h.Con.dec_inductive
608 | _ -> false) p.Con.proof_context in
616 let name = get_name h.Con.dec_name in
619 B.Object ([], P.Mi ([],name));
621 (term2pres h.Con.dec_type);
623 | _ -> assert false (*[B.Text ([],"???")]*)) in
627 (B.b_kw "case"::B.b_space::name::pattern_aux)@
631 (match p.Con.proof_conclude.Con.conclude_conclusion with
632 None -> B.b_kw "No conclusion!!!"
633 | Some t -> term2pres t) in
634 let asubconcl = B.indent (make_concl "the thesis becomes" subconcl) in
635 let induction_hypothesis =
639 let text = B.indent (B.b_kw "by induction hypothesis we know") in
644 (match h.Con.dec_name with
648 [term2pres h.Con.dec_type;
651 B.Object ([], P.Mi ([],name));
654 | _ -> assert false in
655 let hyps = List.map make_hyp indhyps in
658 conclude2pres true p.Con.proof_name p.Con.proof_conclude true true false in
661 match p.Con.proof_apply_context with
662 [] -> p.Con.proof_conclude.Con.conclude_id
663 | {Con.proof_id = id}::_ -> id
665 B.Action([None,"type","toggle"],
666 [ B.indent (add_xref acontext_id (B.b_kw "Proof"));
668 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
669 p.Con.proof_apply_context body true
670 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
672 B.V ([], pattern::induction_hypothesis@[B.H ([],[asubconcl;B.Text([],".")]);presacontext])
675 and falseind conclude =
676 let proof_conclusion =
677 (match conclude.Con.conclude_conclusion with
678 None -> B.b_kw "No conclusion???"
679 | Some t -> term2pres t) in
681 (match conclude.Con.conclude_args with
682 [Con.Aux(n);_;case_arg] -> case_arg
685 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
689 Con.Aux n -> assert false
690 | Con.Premise prem ->
691 (match prem.Con.premise_binder with
692 None -> [B.b_kw "Contradiction, hence"]
694 [ B.Object ([],P.Mi([],n)); B.skip;
695 B.b_kw "is contradictory, hence"])
697 [ B.Object ([], P.Mi([],lemma.Con.lemma_name)); B.skip;
698 B.b_kw "is contradictory, hence" ]
699 | _ -> assert false) in
700 make_row arg proof_conclusion
702 and andind conclude =
704 (match conclude.Con.conclude_args with
705 [Con.Aux(n);_;Con.ArgProof proof;case_arg] -> proof,case_arg
708 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
712 Con.Aux n -> assert false
713 | Con.Premise prem ->
714 (match prem.Con.premise_binder with
716 | Some n -> [(B.b_kw "by"); B.b_space; B.Object([], P.Mi([],n))])
718 [(B.b_kw "by");B.skip;
719 B.Object([], P.Mi([],lemma.Con.lemma_name))]
720 | _ -> assert false) in
721 match proof.Con.proof_context with
722 `Hypothesis hyp1::`Hypothesis hyp2::tl ->
726 B.Object ([], P.Mi([],get_name hyp1.Con.dec_name));
729 term2pres hyp1.Con.dec_type]) in
733 B.Object ([], P.Mi([],get_name hyp2.Con.dec_name));
736 term2pres hyp2.Con.dec_type]) in
738 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
741 acontext2pres false proof.Con.proof_apply_context body false false
745 [B.H ([],arg@[B.skip; B.b_kw "we have"]);
752 and exists conclude =
754 (match conclude.Con.conclude_args with
755 [Con.Aux(n);_;Con.ArgProof proof;_] -> proof
758 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
760 match proof.Con.proof_context with
761 `Declaration decl::`Hypothesis hyp::tl
762 | `Hypothesis decl::`Hypothesis hyp::tl ->
767 B.Object ([], P.Mi([],get_name decl.Con.dec_name));
768 B.Text([],":"); term2pres decl.Con.dec_type]) in
771 [(B.b_kw "such that");
774 B.Object ([], P.Mi([],get_name hyp.Con.dec_name));
777 term2pres hyp.Con.dec_type]) in
779 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
782 acontext2pres false proof.Con.proof_apply_context body false false
793 ?skip_initial_lambdas_internal:
794 (match skip_initial_lambdas with
795 None -> Some (`Later 0) (* we already printed theorem: *)
796 | Some n -> Some (`Later n))
803 let conjecture2pres term2pres (id, n, context, ty) =
805 (B.b_hv [Some "helm", "xref", id]
807 B.b_h [] [B.b_text [] "{...}"; B.b_space];
812 [ B.b_object (p_mi [] "_") ;
813 B.b_object (p_mo [] ":?") ;
814 B.b_object (p_mi [] "_")]
815 | Some (`Declaration d)
816 | Some (`Hypothesis d) ->
817 let { Content.dec_name =
818 dec_name ; Content.dec_type = ty } = d
828 | Some (`Definition d) ->
830 { Content.def_name = def_name ;
831 Content.def_term = bo } = d
834 [ B.b_object (p_mi []
838 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
841 let proof_name = p.Content.proof_name in
843 [ B.b_object (p_mi []
844 (match proof_name with
847 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
848 proof2pres true term2pres p])
849 (List.rev context)) ] ::
851 [ B.b_text [] (Utf8Macro.unicode_of_tex "\\vdash");
852 B.b_object (p_mi [] (string_of_int n)) ;
856 let metasenv2pres term2pres = function
859 (* Conjectures are in their own table to make *)
860 (* diffing the DOM trees easier. *)
862 ((B.b_kw ("Conjectures:" ^
863 (let _ = incr counter; in (string_of_int !counter)))) ::
864 (List.map (conjecture2pres term2pres) metasenv'))]
866 let params2pres params =
868 B.b_text [Some "xlink", "href", UriManager.string_of_uri uri]
869 (UriManager.name_of_uri uri)
871 let rec spatiate = function
874 | hd :: tl -> hd :: B.b_text [] ", " :: spatiate tl
879 let params = spatiate (List.map param2pres p) in
881 B.b_h [] (B.b_text [] "[" :: params @ [ B.b_text [] "]" ])]
883 let recursion_kind2pres params kind =
886 | `Recursive _ -> "Recursive definition"
887 | `CoRecursive -> "CoRecursive definition"
888 | `Inductive _ -> "Inductive definition"
889 | `CoInductive _ -> "CoInductive definition"
891 B.b_h [] (B.b_kw kind :: params2pres params)
893 let inductive2pres term2pres ind =
894 let constructor2pres decl =
896 B.b_text [] ("| " ^ get_name decl.Content.dec_name ^ ":");
898 term2pres decl.Content.dec_type
903 B.b_kw (ind.Content.inductive_name ^ " of arity");
905 term2pres ind.Content.inductive_type ]
906 :: List.map constructor2pres ind.Content.inductive_constructors)
908 let joint_def2pres term2pres def =
910 | `Inductive ind -> inductive2pres term2pres ind
911 | _ -> assert false (* ZACK or raise ToDo? *)
914 ?skip_initial_lambdas ?(skip_thm_and_qed=false) term2pres
915 (id,params,metasenv,obj)
918 | `Def (Content.Const, thesis, `Proof p) ->
919 let name = get_name p.Content.proof_name in
920 let proof = proof2pres true term2pres ?skip_initial_lambdas p in
921 if skip_thm_and_qed then
925 [Some "helm","xref","id"]
926 ([ B.b_h [] (B.b_kw ("theorem " ^ name) ::
927 params2pres params @ [B.b_kw ":"]);
928 B.H ([],[B.indent (term2pres thesis) ; B.b_kw "." ])] @
929 metasenv2pres term2pres metasenv @
930 [proof ; B.b_kw "qed."])
931 | `Def (_, ty, `Definition body) ->
932 let name = get_name body.Content.def_name in
934 [Some "helm","xref","id"]
936 (B.b_kw ("definition " ^ name) :: params2pres params @ [B.b_kw ":"]);
937 B.indent (term2pres ty)] @
938 metasenv2pres term2pres metasenv @
940 B.indent (term2pres body.Content.def_term);
942 | `Decl (_, `Declaration decl)
943 | `Decl (_, `Hypothesis decl) ->
944 let name = get_name decl.Content.dec_name in
946 [Some "helm","xref","id"]
947 ([B.b_h [] (B.b_kw ("Axiom " ^ name) :: params2pres params);
949 B.indent (term2pres decl.Content.dec_type)] @
950 metasenv2pres term2pres metasenv)
953 (recursion_kind2pres params joint.Content.joint_kind
954 :: List.map (joint_def2pres term2pres) joint.Content.joint_defs)
958 ?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_inner_sorts
960 content2pres ?skip_initial_lambdas ?skip_thm_and_qed
961 (fun ?(prec=90) annterm ->
962 let ast, ids_to_uris =
963 TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
965 CicNotationPres.box_of_mpres
966 (CicNotationPres.render ids_to_uris ~prec
967 (TermContentPres.pp_ast ast)))