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" && is_top_down)
453 || (conclude.Con.conclude_method = "RewriteRL" && not is_top_down)
457 (match List.nth conclude.Con.conclude_args index_term1 with
458 Con.Term (_,t) -> term2pres t
459 | _ -> assert false) in
461 (match List.nth conclude.Con.conclude_args index_term2 with
462 Con.Term (_,t) -> term2pres t
463 | _ -> assert false) in
470 [B.b_kw "we proved (" ;
473 term2; B.b_kw ") (equality)."])]
480 B.b_space; (B.b_kw "with");
482 B.b_space; justif1])::
483 match justif2 with None -> [] | Some j -> [B.indent j])
485 B.V([], justif @ [B.b_kw "by _"])
486 else if conclude.Con.conclude_method = "Eq_chain" then
487 let justification p =
488 let j1,j2 = justification ~ignore_atoms:false term2pres p in
489 j1, match j2 with Some j -> [j] | None -> []
494 | (Con.ArgProof p)::(Con.Term (_,t))::tl ->
495 let justif1,justif2 = justification p in
496 B.HOV(RenderingAttrs.indent_attributes `BoxML,([B.b_kw
497 "=";B.b_space;term2pres t;B.b_space]@justif1@
498 (if tl <> [] then [B.Text ([],".")] else [B.b_space; B.b_kw "done" ; B.Text([],".")])@
503 match List.hd conclude.Con.conclude_args with
504 | Con.Term (_,t) -> t
509 [B.b_kw "conclude";B.b_space;term2pres hd;
510 B.V ([],aux (List.tl conclude.Con.conclude_args))])
513 [B.b_kw "obtain";B.b_space;B.b_kw "FIXMEXX"; B.b_space;term2pres hd;
514 B.V ([],aux (List.tl conclude.Con.conclude_args))])
515 else if conclude.Con.conclude_method = "Apply" then
517 make_args_for_apply term2pres conclude.Con.conclude_args in
521 B.Text([],"(")::pres_args@[B.Text([],")")])
524 B.b_kw ("Apply method" ^ conclude.Con.conclude_method ^ " to");
525 (B.indent (B.V ([], args2pres conclude.Con.conclude_args)))])
527 and args2pres l = List.map arg2pres l
531 Con.Aux n -> B.b_kw ("aux " ^ n)
532 | Con.Premise prem -> B.b_kw "premise"
533 | Con.Lemma lemma -> B.b_kw "lemma"
534 | Con.Term (_,t) -> term2pres t
535 | Con.ArgProof p -> proof2pres true p false
536 | Con.ArgMethod s -> B.b_kw "method"
539 let proof_conclusion =
540 (match conclude.Con.conclude_conclusion with
541 None -> B.b_kw "No conclusion???"
542 | Some t -> term2pres t) in
543 let arg,args_for_cases =
544 (match conclude.Con.conclude_args with
545 Con.Aux(_)::Con.Aux(_)::Con.Term(_)::arg::tl ->
547 | _ -> assert false) in
551 Con.Aux n -> B.b_kw "an aux???"
552 | Con.Premise prem ->
553 (match prem.Con.premise_binder with
554 None -> B.b_kw "previous"
555 | Some n -> B.Object ([], P.Mi([],n)))
556 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
559 | Con.ArgProof p -> B.b_kw "a proof???"
560 | Con.ArgMethod s -> B.b_kw "a method???")
562 (make_concl "we proceed by cases on" case_arg) in
564 (make_concl "to prove" proof_conclusion) in
565 B.V ([], case_on::to_prove::(make_cases args_for_cases))
567 and byinduction conclude =
568 let proof_conclusion =
569 (match conclude.Con.conclude_conclusion with
570 None -> B.b_kw "No conclusion???"
571 | Some t -> term2pres t) in
572 let inductive_arg,args_for_cases =
573 (match conclude.Con.conclude_args with
575 let l1,l2 = split (int_of_string n) tl in
576 let last_pos = (List.length l2)-1 in
577 List.nth l2 last_pos,l1
578 | _ -> assert false) in
581 (match inductive_arg with
582 Con.Aux n -> B.b_kw "an aux???"
583 | Con.Premise prem ->
584 (match prem.Con.premise_binder with
585 None -> B.b_kw "previous"
586 | Some n -> B.Object ([], P.Mi([],n)))
587 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
590 | Con.ArgProof p -> B.b_kw "a proof???"
591 | Con.ArgMethod s -> B.b_kw "a method???") in
592 (make_concl "we proceed by induction on" arg) in
594 B.H ([], [make_concl "to prove" proof_conclusion ; B.Text([],".")]) in
595 B.V ([], induction_on::to_prove::(make_cases args_for_cases))
597 and make_cases l = List.map make_case l
603 (match p.Con.proof_name with
604 None -> B.b_kw "no name for case!!"
605 | Some n -> B.Object ([], P.Mi([],n))) in
609 `Hypothesis h -> h.Con.dec_inductive
610 | _ -> false) p.Con.proof_context in
618 let name = get_name h.Con.dec_name in
621 B.Object ([], P.Mi ([],name));
623 (term2pres h.Con.dec_type);
625 | _ -> assert false (*[B.Text ([],"???")]*)) in
629 (B.b_kw "case"::B.b_space::name::pattern_aux)@
633 (match p.Con.proof_conclude.Con.conclude_conclusion with
634 None -> B.b_kw "No conclusion!!!"
635 | Some t -> term2pres t) in
636 let asubconcl = B.indent (make_concl "the thesis becomes" subconcl) in
637 let induction_hypothesis =
641 let text = B.indent (B.b_kw "by induction hypothesis we know") in
646 (match h.Con.dec_name with
650 [term2pres h.Con.dec_type;
653 B.Object ([], P.Mi ([],name));
656 | _ -> assert false in
657 let hyps = List.map make_hyp indhyps in
660 conclude2pres true p.Con.proof_name p.Con.proof_conclude true true false in
663 match p.Con.proof_apply_context with
664 [] -> p.Con.proof_conclude.Con.conclude_id
665 | {Con.proof_id = id}::_ -> id
667 B.Action([None,"type","toggle"],
668 [ B.indent (add_xref acontext_id (B.b_kw "Proof"));
670 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
671 p.Con.proof_apply_context body true
672 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
674 B.V ([], pattern::induction_hypothesis@[B.H ([],[asubconcl;B.Text([],".")]);presacontext])
677 and falseind conclude =
678 let proof_conclusion =
679 (match conclude.Con.conclude_conclusion with
680 None -> B.b_kw "No conclusion???"
681 | Some t -> term2pres t) in
683 (match conclude.Con.conclude_args with
684 [Con.Aux(n);_;case_arg] -> case_arg
687 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
691 Con.Aux n -> assert false
692 | Con.Premise prem ->
693 (match prem.Con.premise_binder with
694 None -> [B.b_kw "Contradiction, hence"]
696 [ B.Object ([],P.Mi([],n)); B.skip;
697 B.b_kw "is contradictory, hence"])
699 [ B.Object ([], P.Mi([],lemma.Con.lemma_name)); B.skip;
700 B.b_kw "is contradictory, hence" ]
701 | _ -> assert false) in
702 make_row arg proof_conclusion
704 and andind conclude =
706 (match conclude.Con.conclude_args with
707 [Con.Aux(n);_;Con.ArgProof proof;case_arg] -> proof,case_arg
710 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
714 Con.Aux n -> assert false
715 | Con.Premise prem ->
716 (match prem.Con.premise_binder with
718 | Some n -> [(B.b_kw "by"); B.b_space; B.Object([], P.Mi([],n))])
720 [(B.b_kw "by");B.skip;
721 B.Object([], P.Mi([],lemma.Con.lemma_name))]
722 | _ -> assert false) in
723 match proof.Con.proof_context with
724 `Hypothesis hyp1::`Hypothesis hyp2::tl ->
728 B.Object ([], P.Mi([],get_name hyp1.Con.dec_name));
731 term2pres hyp1.Con.dec_type]) in
735 B.Object ([], P.Mi([],get_name hyp2.Con.dec_name));
738 term2pres hyp2.Con.dec_type]) in
740 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
743 acontext2pres false proof.Con.proof_apply_context body false false
747 [B.H ([],arg@[B.skip; B.b_kw "we have"]);
754 and exists conclude =
756 (match conclude.Con.conclude_args with
757 [Con.Aux(n);_;Con.ArgProof proof;_] -> proof
760 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
762 match proof.Con.proof_context with
763 `Declaration decl::`Hypothesis hyp::tl
764 | `Hypothesis decl::`Hypothesis hyp::tl ->
769 B.Object ([], P.Mi([],get_name decl.Con.dec_name));
770 B.Text([],":"); term2pres decl.Con.dec_type]) in
773 [(B.b_kw "such that");
776 B.Object ([], P.Mi([],get_name hyp.Con.dec_name));
779 term2pres hyp.Con.dec_type]) in
781 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
784 acontext2pres false proof.Con.proof_apply_context body false false
795 ?skip_initial_lambdas_internal:
796 (match skip_initial_lambdas with
797 None -> Some (`Later 0) (* we already printed theorem: *)
798 | Some n -> Some (`Later n))
805 let conjecture2pres term2pres (id, n, context, ty) =
807 (B.b_hv [Some "helm", "xref", id]
809 B.b_h [] [B.b_text [] "{...}"; B.b_space];
814 [ B.b_object (p_mi [] "_") ;
815 B.b_object (p_mo [] ":?") ;
816 B.b_object (p_mi [] "_")]
817 | Some (`Declaration d)
818 | Some (`Hypothesis d) ->
819 let { Content.dec_name =
820 dec_name ; Content.dec_type = ty } = d
830 | Some (`Definition d) ->
832 { Content.def_name = def_name ;
833 Content.def_term = bo } = d
836 [ B.b_object (p_mi []
840 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
843 let proof_name = p.Content.proof_name in
845 [ B.b_object (p_mi []
846 (match proof_name with
849 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
850 proof2pres true term2pres p])
851 (List.rev context)) ] ::
853 [ B.b_text [] (Utf8Macro.unicode_of_tex "\\vdash");
854 B.b_object (p_mi [] (string_of_int n)) ;
858 let metasenv2pres term2pres = function
861 (* Conjectures are in their own table to make *)
862 (* diffing the DOM trees easier. *)
864 ((B.b_kw ("Conjectures:" ^
865 (let _ = incr counter; in (string_of_int !counter)))) ::
866 (List.map (conjecture2pres term2pres) metasenv'))]
868 let params2pres params =
870 B.b_text [Some "xlink", "href", UriManager.string_of_uri uri]
871 (UriManager.name_of_uri uri)
873 let rec spatiate = function
876 | hd :: tl -> hd :: B.b_text [] ", " :: spatiate tl
881 let params = spatiate (List.map param2pres p) in
883 B.b_h [] (B.b_text [] "[" :: params @ [ B.b_text [] "]" ])]
885 let recursion_kind2pres params kind =
888 | `Recursive _ -> "Recursive definition"
889 | `CoRecursive -> "CoRecursive definition"
890 | `Inductive _ -> "Inductive definition"
891 | `CoInductive _ -> "CoInductive definition"
893 B.b_h [] (B.b_kw kind :: params2pres params)
895 let inductive2pres term2pres ind =
896 let constructor2pres decl =
898 B.b_text [] ("| " ^ get_name decl.Content.dec_name ^ ":");
900 term2pres decl.Content.dec_type
905 B.b_kw (ind.Content.inductive_name ^ " of arity");
907 term2pres ind.Content.inductive_type ]
908 :: List.map constructor2pres ind.Content.inductive_constructors)
910 let joint_def2pres term2pres def =
912 | `Inductive ind -> inductive2pres term2pres ind
913 | _ -> assert false (* ZACK or raise ToDo? *)
916 ?skip_initial_lambdas ?(skip_thm_and_qed=false) term2pres
917 (id,params,metasenv,obj)
920 | `Def (Content.Const, thesis, `Proof p) ->
921 let name = get_name p.Content.proof_name in
922 let proof = proof2pres true term2pres ?skip_initial_lambdas p in
923 if skip_thm_and_qed then
927 [Some "helm","xref","id"]
928 ([ B.b_h [] (B.b_kw ("theorem " ^ name) ::
929 params2pres params @ [B.b_kw ":"]);
930 B.H ([],[B.indent (term2pres thesis) ; B.b_kw "." ])] @
931 metasenv2pres term2pres metasenv @
932 [proof ; B.b_kw "qed."])
933 | `Def (_, ty, `Definition body) ->
934 let name = get_name body.Content.def_name in
936 [Some "helm","xref","id"]
938 (B.b_kw ("definition " ^ name) :: params2pres params @ [B.b_kw ":"]);
939 B.indent (term2pres ty)] @
940 metasenv2pres term2pres metasenv @
942 B.indent (term2pres body.Content.def_term);
944 | `Decl (_, `Declaration decl)
945 | `Decl (_, `Hypothesis decl) ->
946 let name = get_name decl.Content.dec_name in
948 [Some "helm","xref","id"]
949 ([B.b_h [] (B.b_kw ("Axiom " ^ name) :: params2pres params);
951 B.indent (term2pres decl.Content.dec_type)] @
952 metasenv2pres term2pres metasenv)
955 (recursion_kind2pres params joint.Content.joint_kind
956 :: List.map (joint_def2pres term2pres) joint.Content.joint_defs)
960 ?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_inner_sorts
962 content2pres ?skip_initial_lambdas ?skip_thm_and_qed
963 (fun ?(prec=90) annterm ->
964 let ast, ids_to_uris =
965 TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
967 CicNotationPres.box_of_mpres
968 (CicNotationPres.render ids_to_uris ~prec
969 (TermContentPres.pp_ast ast)))