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)
185 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
187 match p.Con.proof_name with
195 make_concl ~attrs:[ Some "helm", "xref", p.Con.proof_id ]
197 B.b_toggle [ B.H ([], [concl; B.skip ; B.Text([],"(");
198 B.Object ([], P.Mi ([],name));
199 B.Text([],")") ]) ; body ]
203 and context2pres c continuation =
204 (* we generate a subtable for each context element, for selection
206 The table generated by the head-element does not have an xref;
207 the whole context-proof is already selectable *)
213 (fun ce continuation ->
214 let xref = get_xref ce in
215 B.V([Some "helm", "xref", xref ],
216 [B.H([Some "helm", "xref", "ce_"^xref],
217 [ce2pres_in_proof_context_element ce]);
218 continuation])) tl continuation in
219 let hd_xref= get_xref hd in
221 [B.H([Some "helm", "xref", "ce_"^hd_xref],
222 [ce2pres_in_proof_context_element hd]);
225 and ce2pres_in_joint_context_element = function
226 | `Inductive _ -> assert false (* TODO *)
227 | (`Declaration _) as x -> ce2pres x
228 | (`Hypothesis _) as x -> ce2pres x
229 | (`Proof _) as x -> ce2pres x
230 | (`Definition _) as x -> ce2pres x
232 and ce2pres_in_proof_context_element = function
234 B.H ([],(List.map ce2pres_in_joint_context_element ho.Content.joint_defs))
235 | (`Declaration _) as x -> ce2pres x
236 | (`Hypothesis _) as x -> ce2pres x
237 | (`Proof _) as x -> ce2pres x
238 | (`Definition _) as x -> ce2pres x
243 let ty = term2pres d.Con.dec_type in
247 B.Object ([], P.Mi([],get_name d.Con.dec_name));
252 let ty = term2pres h.Con.dec_type in
259 B.Object ([], P.Mi ([],get_name h.Con.dec_name));
263 proof2pres false p false
265 let term = term2pres d.Con.def_term in
267 [ B.b_kw "let"; B.b_space;
268 B.Object ([], P.Mi([],get_name d.Con.def_name));
269 B.Text([],Utf8Macro.unicode_of_tex "\\def");
272 and acontext2pres is_top_down ac continuation indent in_bu_conversion =
277 let continuation = aux tl in
278 (* Applicative context get flattened and the "body" of a BU_Conversion
279 is put in the applicative context. Thus two different situations
281 {method = "BU_Conversion"; applicative_context=[p1; ...; pn]}
282 {method = xxx; applicative_context =
283 [ p1; ...; pn; {method="BU_Conversion"} ; p_{n+1}; ... ; pm ]}
284 In both situations only pn must be processed in in_bu_conversion
287 let in_bu_conversion =
289 [] -> in_bu_conversion
290 | p::_ -> p.Con.proof_conclude.Con.conclude_method = "BU_Conversion"
292 let hd = proof2pres is_top_down p in_bu_conversion in
293 let hd = if indent then B.indent hd else hd in
294 B.V([Some "helm","xref",p.Con.proof_id],
295 [B.H([Some "helm","xref","ace_"^p.Con.proof_id],[hd]);
299 and conclude2pres ?skip_initial_lambdas_internal is_top_down name conclude indent omit_conclusion in_bu_conversion =
301 match conclude.Con.conclude_conclusion with
302 Some t (*when not omit_conclusion or
303 (* CSC: I ignore the omit_conclusion flag in this case. *)
304 (* CSC: Is this the correct behaviour? In the stylesheets *)
305 (* CSC: we simply generated nothing (i.e. the output type *)
306 (* CSC: of the function should become an option. *)
307 conclude.Con.conclude_method = "BU_Conversion" *) ->
308 let concl = term2pres t in
309 if conclude.Con.conclude_method = "BU_Conversion" then
311 (make_concl "that is equivalent to" concl ::
312 if is_top_down then [B.b_space ; B.b_kw "done";
313 B.Text([],".")] else [B.Text([],".")])
314 else if conclude.Con.conclude_method = "FalseInd" then
315 (* false ind is in charge to add the conclusion *)
321 conclude.Con.conclude_method = "Intros+LetTac"
323 let name = get_name name in
327 (match conclude.Con.conclude_conclusion with
328 None -> B.Text([],"NO EXPECTED!!!")
329 | Some c -> term2pres c)
331 [make_concl "we need to prove" expected;
334 B.Object ([], P.Mi ([],name));
341 conclude_aux ?skip_initial_lambdas_internal is_top_down conclude in
343 if conclude.Con.conclude_method = "Intros+LetTac"
344 || conclude.Con.conclude_method = "ByInduction"
345 || conclude.Con.conclude_method = "TD_Conversion"
346 || conclude.Con.conclude_method = "Eq_chain"
349 else if omit_conclusion then
350 B.H([], [B.b_kw "done" ; B.Text([],".") ])
353 ((if not is_top_down || in_bu_conversion then
354 (make_concl "we proved" concl) ::
355 if not is_top_down then
356 let name = get_name ~default:"previous" name in
357 [B.b_space; B.Text([],"(" ^ name ^ ")")]
360 ) @ if not in_bu_conversion then [B.Text([],".")] else [])
362 B.V ([], prequel @ [conclude_body; ann_concl])
363 | _ -> conclude_aux ?skip_initial_lambdas_internal is_top_down conclude
366 B.indent (B.H ([Some "helm", "xref", conclude.Con.conclude_id],
369 B.H ([Some "helm", "xref", conclude.Con.conclude_id],[tconclude_body])
371 and conclude_aux ?skip_initial_lambdas_internal is_top_down conclude =
372 if conclude.Con.conclude_method = "TD_Conversion" then
374 (match conclude.Con.conclude_conclusion with
375 None -> B.Text([],"NO EXPECTED!!!")
376 | Some c -> term2pres c) in
378 (match conclude.Con.conclude_args with
379 [Con.ArgProof p] -> p
380 | _ -> assert false) in
382 (match subproof.Con.proof_conclude.Con.conclude_conclusion with
383 None -> B.Text([],"NO SYNTH!!!")
384 | Some c -> (term2pres c)) in
387 [make_concl "we need to prove" expected;
388 B.H ([],[make_concl "or equivalently" synth; B.Text([],".")]);
389 proof2pres true subproof false])
390 else if conclude.Con.conclude_method = "BU_Conversion" then
392 else if conclude.Con.conclude_method = "Exact" then
394 (match conclude.Con.conclude_args with
395 [Con.Term (b,t)] -> assert (not b);term2pres t
397 (match p.Con.premise_binder with
398 | None -> assert false; (* unnamed hypothesis ??? *)
399 | Some s -> B.Text([],s))
400 | err -> assert false) in
401 (match conclude.Con.conclude_conclusion with
403 B.b_h [] [B.b_kw "by"; B.b_space; arg]
405 B.b_h [] [B.b_kw "by"; B.b_space; arg]
407 else if conclude.Con.conclude_method = "Intros+LetTac" then
408 (match conclude.Con.conclude_args with
410 (match conclude.Con.conclude_args with
412 proof2pres ?skip_initial_lambdas_internal true p false
417 (match conclude.Con.conclude_conclusion with
418 None -> B.Text([],"NO Conclusion!!!")
419 | Some c -> term2pres c) in
420 (match conclude.Con.conclude_args with
423 ([None,"align","baseline 1"; None,"equalrows","false";
424 None,"columnalign","left"],
425 [B.H([],[B.Object([],proof2pres p false)]);
427 (make_concl "we proved 1" conclusion))])]);
430 else if (conclude.Con.conclude_method = "Case") then
432 else if (conclude.Con.conclude_method = "ByInduction") then
434 else if (conclude.Con.conclude_method = "Exists") then
436 else if (conclude.Con.conclude_method = "AndInd") then
438 else if (conclude.Con.conclude_method = "FalseInd") then
440 else if conclude.Con.conclude_method = "RewriteLR"
441 || conclude.Con.conclude_method = "RewriteRL" then
442 let justif1,justif2 =
443 (match (List.nth conclude.Con.conclude_args 6) with
444 Con.ArgProof p -> justification ~ignore_atoms:true term2pres p
445 | _ -> assert false) in
451 let index_term1, index_term2 =
452 if conclude.Con.conclude_method = "RewriteLR" then 2,5 else 5,2
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 ~output_type:`Term ids_to_inner_sorts annterm
965 CicNotationPres.box_of_mpres
966 (CicNotationPres.render ids_to_uris ~prec
967 (TermContentPres.pp_ast ast)))