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
505 B.HOV([],[B.b_kw "conclude";B.b_space;term2pres hd; (* B.b_space; *)
506 B.V ([],aux (List.tl conclude.Con.conclude_args))])
507 else if conclude.Con.conclude_method = "Apply" then
509 make_args_for_apply term2pres conclude.Con.conclude_args in
513 B.Text([],"(")::pres_args@[B.Text([],")")])
516 B.b_kw ("Apply method" ^ conclude.Con.conclude_method ^ " to");
517 (B.indent (B.V ([], args2pres conclude.Con.conclude_args)))])
519 and args2pres l = List.map arg2pres l
523 Con.Aux n -> B.b_kw ("aux " ^ n)
524 | Con.Premise prem -> B.b_kw "premise"
525 | Con.Lemma lemma -> B.b_kw "lemma"
526 | Con.Term (_,t) -> term2pres t
527 | Con.ArgProof p -> proof2pres true p false
528 | Con.ArgMethod s -> B.b_kw "method"
531 let proof_conclusion =
532 (match conclude.Con.conclude_conclusion with
533 None -> B.b_kw "No conclusion???"
534 | Some t -> term2pres t) in
535 let arg,args_for_cases =
536 (match conclude.Con.conclude_args with
537 Con.Aux(_)::Con.Aux(_)::Con.Term(_)::arg::tl ->
539 | _ -> assert false) in
543 Con.Aux n -> B.b_kw "an aux???"
544 | Con.Premise prem ->
545 (match prem.Con.premise_binder with
546 None -> B.b_kw "previous"
547 | Some n -> B.Object ([], P.Mi([],n)))
548 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
551 | Con.ArgProof p -> B.b_kw "a proof???"
552 | Con.ArgMethod s -> B.b_kw "a method???")
554 (make_concl "we proceed by cases on" case_arg) in
556 (make_concl "to prove" proof_conclusion) in
557 B.V ([], case_on::to_prove::(make_cases args_for_cases))
559 and byinduction conclude =
560 let proof_conclusion =
561 (match conclude.Con.conclude_conclusion with
562 None -> B.b_kw "No conclusion???"
563 | Some t -> term2pres t) in
564 let inductive_arg,args_for_cases =
565 (match conclude.Con.conclude_args with
567 let l1,l2 = split (int_of_string n) tl in
568 let last_pos = (List.length l2)-1 in
569 List.nth l2 last_pos,l1
570 | _ -> assert false) in
573 (match inductive_arg with
574 Con.Aux n -> B.b_kw "an aux???"
575 | Con.Premise prem ->
576 (match prem.Con.premise_binder with
577 None -> B.b_kw "previous"
578 | Some n -> B.Object ([], P.Mi([],n)))
579 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
582 | Con.ArgProof p -> B.b_kw "a proof???"
583 | Con.ArgMethod s -> B.b_kw "a method???") in
584 (make_concl "we proceed by induction on" arg) in
586 B.H ([], [make_concl "to prove" proof_conclusion ; B.Text([],".")]) in
587 B.V ([], induction_on::to_prove::(make_cases args_for_cases))
589 and make_cases l = List.map make_case l
595 (match p.Con.proof_name with
596 None -> B.b_kw "no name for case!!"
597 | Some n -> B.Object ([], P.Mi([],n))) in
601 `Hypothesis h -> h.Con.dec_inductive
602 | _ -> false) p.Con.proof_context in
610 let name = get_name h.Con.dec_name in
613 B.Object ([], P.Mi ([],name));
615 (term2pres h.Con.dec_type);
617 | _ -> assert false (*[B.Text ([],"???")]*)) in
621 (B.b_kw "case"::B.b_space::name::pattern_aux)@
625 (match p.Con.proof_conclude.Con.conclude_conclusion with
626 None -> B.b_kw "No conclusion!!!"
627 | Some t -> term2pres t) in
628 let asubconcl = B.indent (make_concl "the thesis becomes" subconcl) in
629 let induction_hypothesis =
633 let text = B.indent (B.b_kw "by induction hypothesis we know") in
638 (match h.Con.dec_name with
642 [term2pres h.Con.dec_type;
645 B.Object ([], P.Mi ([],name));
648 | _ -> assert false in
649 let hyps = List.map make_hyp indhyps in
652 conclude2pres true p.Con.proof_name p.Con.proof_conclude true true false in
655 match p.Con.proof_apply_context with
656 [] -> p.Con.proof_conclude.Con.conclude_id
657 | {Con.proof_id = id}::_ -> id
659 B.Action([None,"type","toggle"],
660 [ B.indent (add_xref acontext_id (B.b_kw "Proof"));
662 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
663 p.Con.proof_apply_context body true
664 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
666 B.V ([], pattern::induction_hypothesis@[B.H ([],[asubconcl;B.Text([],".")]);presacontext])
669 and falseind conclude =
670 let proof_conclusion =
671 (match conclude.Con.conclude_conclusion with
672 None -> B.b_kw "No conclusion???"
673 | Some t -> term2pres t) in
675 (match conclude.Con.conclude_args with
676 [Con.Aux(n);_;case_arg] -> case_arg
679 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
683 Con.Aux n -> assert false
684 | Con.Premise prem ->
685 (match prem.Con.premise_binder with
686 None -> [B.b_kw "Contradiction, hence"]
688 [ B.Object ([],P.Mi([],n)); B.skip;
689 B.b_kw "is contradictory, hence"])
691 [ B.Object ([], P.Mi([],lemma.Con.lemma_name)); B.skip;
692 B.b_kw "is contradictory, hence" ]
693 | _ -> assert false) in
694 make_row arg proof_conclusion
696 and andind conclude =
698 (match conclude.Con.conclude_args with
699 [Con.Aux(n);_;Con.ArgProof proof;case_arg] -> proof,case_arg
702 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
706 Con.Aux n -> assert false
707 | Con.Premise prem ->
708 (match prem.Con.premise_binder with
710 | Some n -> [(B.b_kw "by"); B.b_space; B.Object([], P.Mi([],n))])
712 [(B.b_kw "by");B.skip;
713 B.Object([], P.Mi([],lemma.Con.lemma_name))]
714 | _ -> assert false) in
715 match proof.Con.proof_context with
716 `Hypothesis hyp1::`Hypothesis hyp2::tl ->
720 B.Object ([], P.Mi([],get_name hyp1.Con.dec_name));
723 term2pres hyp1.Con.dec_type]) in
727 B.Object ([], P.Mi([],get_name hyp2.Con.dec_name));
730 term2pres hyp2.Con.dec_type]) in
732 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
735 acontext2pres false proof.Con.proof_apply_context body false false
739 [B.H ([],arg@[B.skip; B.b_kw "we have"]);
746 and exists conclude =
748 (match conclude.Con.conclude_args with
749 [Con.Aux(n);_;Con.ArgProof proof;_] -> proof
752 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
754 match proof.Con.proof_context with
755 `Declaration decl::`Hypothesis hyp::tl
756 | `Hypothesis decl::`Hypothesis hyp::tl ->
761 B.Object ([], P.Mi([],get_name decl.Con.dec_name));
762 B.Text([],":"); term2pres decl.Con.dec_type]) in
765 [(B.b_kw "such that");
768 B.Object ([], P.Mi([],get_name hyp.Con.dec_name));
771 term2pres hyp.Con.dec_type]) in
773 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
776 acontext2pres false proof.Con.proof_apply_context body false false
787 ?skip_initial_lambdas_internal:
788 (match skip_initial_lambdas with
789 None -> Some (`Later 0) (* we already printed theorem: *)
790 | Some n -> Some (`Later n))
797 let conjecture2pres term2pres (id, n, context, ty) =
799 (B.b_hv [Some "helm", "xref", id]
801 B.b_h [] [B.b_text [] "{...}"; B.b_space];
806 [ B.b_object (p_mi [] "_") ;
807 B.b_object (p_mo [] ":?") ;
808 B.b_object (p_mi [] "_")]
809 | Some (`Declaration d)
810 | Some (`Hypothesis d) ->
811 let { Content.dec_name =
812 dec_name ; Content.dec_type = ty } = d
822 | Some (`Definition d) ->
824 { Content.def_name = def_name ;
825 Content.def_term = bo } = d
828 [ B.b_object (p_mi []
832 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
835 let proof_name = p.Content.proof_name in
837 [ B.b_object (p_mi []
838 (match proof_name with
841 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
842 proof2pres true term2pres p])
843 (List.rev context)) ] ::
845 [ B.b_text [] (Utf8Macro.unicode_of_tex "\\vdash");
846 B.b_object (p_mi [] (string_of_int n)) ;
850 let metasenv2pres term2pres = function
853 (* Conjectures are in their own table to make *)
854 (* diffing the DOM trees easier. *)
856 ((B.b_kw ("Conjectures:" ^
857 (let _ = incr counter; in (string_of_int !counter)))) ::
858 (List.map (conjecture2pres term2pres) metasenv'))]
860 let params2pres params =
862 B.b_text [Some "xlink", "href", UriManager.string_of_uri uri]
863 (UriManager.name_of_uri uri)
865 let rec spatiate = function
868 | hd :: tl -> hd :: B.b_text [] ", " :: spatiate tl
873 let params = spatiate (List.map param2pres p) in
875 B.b_h [] (B.b_text [] "[" :: params @ [ B.b_text [] "]" ])]
877 let recursion_kind2pres params kind =
880 | `Recursive _ -> "Recursive definition"
881 | `CoRecursive -> "CoRecursive definition"
882 | `Inductive _ -> "Inductive definition"
883 | `CoInductive _ -> "CoInductive definition"
885 B.b_h [] (B.b_kw kind :: params2pres params)
887 let inductive2pres term2pres ind =
888 let constructor2pres decl =
890 B.b_text [] ("| " ^ get_name decl.Content.dec_name ^ ":");
892 term2pres decl.Content.dec_type
897 B.b_kw (ind.Content.inductive_name ^ " of arity");
899 term2pres ind.Content.inductive_type ]
900 :: List.map constructor2pres ind.Content.inductive_constructors)
902 let joint_def2pres term2pres def =
904 | `Inductive ind -> inductive2pres term2pres ind
905 | _ -> assert false (* ZACK or raise ToDo? *)
908 ?skip_initial_lambdas ?(skip_thm_and_qed=false) term2pres
909 (id,params,metasenv,obj)
912 | `Def (Content.Const, thesis, `Proof p) ->
913 let name = get_name p.Content.proof_name in
914 let proof = proof2pres true term2pres ?skip_initial_lambdas p in
915 if skip_thm_and_qed then
919 [Some "helm","xref","id"]
920 ([ B.b_h [] (B.b_kw ("theorem " ^ name) ::
921 params2pres params @ [B.b_kw ":"]);
922 B.H ([],[B.indent (term2pres thesis) ; B.b_kw "." ])] @
923 metasenv2pres term2pres metasenv @
924 [proof ; B.b_kw "qed."])
925 | `Def (_, ty, `Definition body) ->
926 let name = get_name body.Content.def_name in
928 [Some "helm","xref","id"]
930 (B.b_kw ("definition " ^ name) :: params2pres params @ [B.b_kw ":"]);
931 B.indent (term2pres ty)] @
932 metasenv2pres term2pres metasenv @
934 B.indent (term2pres body.Content.def_term);
936 | `Decl (_, `Declaration decl)
937 | `Decl (_, `Hypothesis decl) ->
938 let name = get_name decl.Content.dec_name in
940 [Some "helm","xref","id"]
941 ([B.b_h [] (B.b_kw ("Axiom " ^ name) :: params2pres params);
943 B.indent (term2pres decl.Content.dec_type)] @
944 metasenv2pres term2pres metasenv)
947 (recursion_kind2pres params joint.Content.joint_kind
948 :: List.map (joint_def2pres term2pres) joint.Content.joint_defs)
952 ?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_inner_sorts
954 content2pres ?skip_initial_lambdas ?skip_thm_and_qed
955 (fun ?(prec=90) annterm ->
956 let ast, ids_to_uris =
957 TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
959 CicNotationPres.box_of_mpres
960 (CicNotationPres.render ids_to_uris ~prec
961 (TermContentPres.pp_ast ast)))