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 term2pres p =
125 if ((p.Con.proof_conclude.Con.conclude_method = "Exact") or
126 ((p.Con.proof_context = []) &
127 (p.Con.proof_apply_context = []) &
128 (p.Con.proof_conclude.Con.conclude_method = "Apply"))) then
130 make_args_for_apply term2pres p.Con.proof_conclude.Con.conclude_args in
132 (B.b_kw "by")::B.b_space::
133 B.Text([],"(")::pres_args@[B.Text([],")")]), None
136 Some (B.b_toggle [B.b_kw "proof";proof2pres true term2pres p])*)
137 proof2pres true term2pres p, None
139 and proof2pres ?skip_initial_lambdas is_top_down term2pres p =
140 let rec proof2pres ?skip_initial_lambdas_internal is_top_down p omit_dot =
145 | `Hypothesis _ -> true
147 ((List.filter is_decl p.Con.proof_context) != []) in
148 let omit_conclusion = (not indent) && (p.Con.proof_context != []) in
150 (match p.Con.proof_conclude.Con.conclude_conclusion with
152 | Some t -> Some (term2pres t)) in
156 ?skip_initial_lambdas_internal:
157 (match skip_initial_lambdas_internal with
158 Some (`Later s) -> Some (`Now s)
161 p.Con.proof_name p.Con.proof_conclude indent omit_conclusion
165 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
166 p.Con.proof_apply_context
168 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
171 (match skip_initial_lambdas_internal with
172 Some (`Now n) -> snd (HExtlib.split_nth n p.Con.proof_context)
173 | _ -> p.Con.proof_context)
176 match p.Con.proof_name with
184 make_concl ~attrs:[ Some "helm", "xref", p.Con.proof_id ]
186 B.b_toggle [ B.H ([], [concl; B.skip ; B.Text([],"(");
187 B.Object ([], P.Mi ([],name));
188 B.Text([],")") ]) ; body ]
192 and context2pres c continuation =
193 (* we generate a subtable for each context element, for selection
195 The table generated by the head-element does not have an xref;
196 the whole context-proof is already selectable *)
202 (fun ce continuation ->
203 let xref = get_xref ce in
204 B.V([Some "helm", "xref", xref ],
205 [B.H([Some "helm", "xref", "ce_"^xref],
206 [ce2pres_in_proof_context_element ce]);
207 continuation])) tl continuation in
208 let hd_xref= get_xref hd in
210 [B.H([Some "helm", "xref", "ce_"^hd_xref],
211 [ce2pres_in_proof_context_element hd]);
214 and ce2pres_in_joint_context_element = function
215 | `Inductive _ -> assert false (* TODO *)
216 | (`Declaration _) as x -> ce2pres x
217 | (`Hypothesis _) as x -> ce2pres x
218 | (`Proof _) as x -> ce2pres x
219 | (`Definition _) as x -> ce2pres x
221 and ce2pres_in_proof_context_element = function
223 B.H ([],(List.map ce2pres_in_joint_context_element ho.Content.joint_defs))
224 | (`Declaration _) as x -> ce2pres x
225 | (`Hypothesis _) as x -> ce2pres x
226 | (`Proof _) as x -> ce2pres x
227 | (`Definition _) as x -> ce2pres x
232 let ty = term2pres d.Con.dec_type in
236 B.Object ([], P.Mi([],get_name d.Con.dec_name));
241 let ty = term2pres h.Con.dec_type in
248 B.Object ([], P.Mi ([],get_name h.Con.dec_name));
252 proof2pres false p false
254 let term = term2pres d.Con.def_term in
256 [ B.b_kw "let"; B.b_space;
257 B.Object ([], P.Mi([],get_name d.Con.def_name));
258 B.Text([],Utf8Macro.unicode_of_tex "\\def");
261 and acontext2pres is_top_down ac continuation indent in_bu_conversion =
266 let continuation = aux tl in
267 (* Applicative context get flattened and the "body" of a BU_Conversion
268 is put in the applicative context. Thus two different situations
270 {method = "BU_Conversion"; applicative_context=[p1; ...; pn]}
271 {method = xxx; applicative_context =
272 [ p1; ...; pn; {method="BU_Conversion"} ; p_{n+1}; ... ; pm ]}
273 In both situations only pn must be processed in in_bu_conversion
276 let in_bu_conversion =
278 [] -> in_bu_conversion
279 | p::_ -> p.Con.proof_conclude.Con.conclude_method = "BU_Conversion"
283 B.indent (proof2pres is_top_down p in_bu_conversion)
285 proof2pres is_top_down p in_bu_conversion
287 B.V([Some "helm","xref",p.Con.proof_id],
288 [B.H([Some "helm","xref","ace_"^p.Con.proof_id],[hd]);
292 and conclude2pres ?skip_initial_lambdas_internal is_top_down name conclude indent omit_conclusion omit_dot =
294 match conclude.Con.conclude_conclusion with
295 Some t (*when not omit_conclusion or
296 (* CSC: I ignore the omit_conclusion flag in this case. *)
297 (* CSC: Is this the correct behaviour? In the stylesheets *)
298 (* CSC: we simply generated nothing (i.e. the output type *)
299 (* CSC: of the function should become an option. *)
300 conclude.Con.conclude_method = "BU_Conversion" *) ->
301 let concl = term2pres t in
302 if conclude.Con.conclude_method = "BU_Conversion" then
304 (make_concl "that is equivalent to" concl ::
305 if is_top_down then [B.b_space ; B.b_kw "done";
306 B.Text([],".")] else [B.Text([],".")])
307 else if conclude.Con.conclude_method = "FalseInd" then
308 (* false ind is in charge to add the conclusion *)
314 conclude.Con.conclude_method = "Intros+LetTac"
316 let name = get_name name in
320 (match conclude.Con.conclude_conclusion with
321 None -> B.Text([],"NO EXPECTED!!!")
322 | Some c -> term2pres c)
324 [make_concl "we need to prove" expected;
327 B.Object ([], P.Mi ([],name));
334 conclude_aux ?skip_initial_lambdas_internal is_top_down conclude in
336 if conclude.Con.conclude_method = "Intros+LetTac"
337 || conclude.Con.conclude_method = "ByInduction"
338 || conclude.Con.conclude_method = "TD_Conversion"
341 else if omit_conclusion then
342 B.H([], [B.b_kw "done" ; B.Text([],".") ])
345 ((if not is_top_down || omit_dot then
346 (make_concl "we proved" concl) ::
347 if not is_top_down then
348 let name = get_name ~default:"previous" name in
349 [B.b_space; B.Text([],"(" ^ name ^ ")")]
352 ) @ if not omit_dot then [B.Text([],".")] else [])
354 B.V ([], prequel @ [conclude_body; ann_concl])
355 | _ -> conclude_aux ?skip_initial_lambdas_internal is_top_down conclude
358 B.indent (B.H ([Some "helm", "xref", conclude.Con.conclude_id],
361 B.H ([Some "helm", "xref", conclude.Con.conclude_id],[tconclude_body])
363 and conclude_aux ?skip_initial_lambdas_internal is_top_down conclude =
364 if conclude.Con.conclude_method = "TD_Conversion" then
366 (match conclude.Con.conclude_conclusion with
367 None -> B.Text([],"NO EXPECTED!!!")
368 | Some c -> term2pres c) in
370 (match conclude.Con.conclude_args with
371 [Con.ArgProof p] -> p
372 | _ -> assert false) in
374 (match subproof.Con.proof_conclude.Con.conclude_conclusion with
375 None -> B.Text([],"NO SYNTH!!!")
376 | Some c -> (term2pres c)) in
379 [make_concl "we need to prove" expected;
380 B.H ([],[make_concl "or equivalently" synth; B.Text([],".")]);
381 proof2pres true subproof false])
382 else if conclude.Con.conclude_method = "BU_Conversion" then
384 else if conclude.Con.conclude_method = "Exact" then
386 (match conclude.Con.conclude_args with
387 [Con.Term (b,t)] -> assert (not b);term2pres t
389 (match p.Con.premise_binder with
390 | None -> assert false; (* unnamed hypothesis ??? *)
391 | Some s -> B.Text([],s))
392 | err -> assert false) in
393 (match conclude.Con.conclude_conclusion with
395 B.b_h [] [B.b_kw "by"; B.b_space; arg]
397 B.b_h [] [B.b_kw "by"; B.b_space; arg]
399 else if conclude.Con.conclude_method = "Intros+LetTac" then
400 (match conclude.Con.conclude_args with
402 (match conclude.Con.conclude_args with
404 proof2pres ?skip_initial_lambdas_internal true p false
409 (match conclude.Con.conclude_conclusion with
410 None -> B.Text([],"NO Conclusion!!!")
411 | Some c -> term2pres c) in
412 (match conclude.Con.conclude_args with
415 ([None,"align","baseline 1"; None,"equalrows","false";
416 None,"columnalign","left"],
417 [B.H([],[B.Object([],proof2pres p false)]);
419 (make_concl "we proved 1" conclusion))])]);
422 else if (conclude.Con.conclude_method = "Case") then
424 else if (conclude.Con.conclude_method = "ByInduction") then
426 else if (conclude.Con.conclude_method = "Exists") then
428 else if (conclude.Con.conclude_method = "AndInd") then
430 else if (conclude.Con.conclude_method = "FalseInd") then
432 else if conclude.Con.conclude_method = "RewriteLR"
433 || conclude.Con.conclude_method = "RewriteRL" then
434 let justif1,justif2 =
435 (match (List.nth conclude.Con.conclude_args 6) with
436 Con.ArgProof p -> justification term2pres p
437 | _ -> assert false) in
439 (match List.nth conclude.Con.conclude_args 2 with
440 Con.Term (_,t) -> term2pres t
441 | _ -> assert false) in
443 (match List.nth conclude.Con.conclude_args 5 with
444 Con.Term (_,t) -> term2pres t
445 | _ -> assert false) in
451 B.b_space; (B.b_kw "with");
453 B.b_space; justif1])::
454 match justif2 with None -> [] | Some j -> [B.indent j])
456 if (conclude.Con.conclude_method = "RewriteLR" && is_top_down)
457 || (conclude.Con.conclude_method = "RewriteRL" && not is_top_down) then
458 B.V([], [justif1 ; B.H([],[B.b_kw "we proved (" ; term1 ; B.b_kw "=" ; term2; B.b_kw ") (equality)."]); B.b_kw "by _"])
460 B.V([], [justif1 ; B.H([],[B.b_kw "we proved (" ; term2 ; B.b_kw "=" ; term1; B.b_kw ") (equality)."]); B.b_kw "by _"])
462 B.V([], [B.H([],[B.b_kw "obtain fooo " ; term2 ; B.b_kw "=" ; term1; B.b_kw "by" ; B.b_kw "proof" ; B.Text([],"."); justif1])]) *)
463 else if conclude.Con.conclude_method = "Eq_chain" then
464 let justification p =
466 if skip_initial_lambdas <> None (* cheating *) then
470 let j1,j2 = justification term2pres p in
471 j1 :: B.b_space :: (match j2 with Some j -> [j] | None -> [])
476 | (Con.ArgProof p)::(Con.Term (_,t))::tl ->
477 B.HOV(RenderingAttrs.indent_attributes `BoxML,([B.b_kw
478 "=";B.b_space;term2pres t;B.b_space]@justification p@
479 (if tl <> [] then [B.Text ([],".")] else [])))::(aux tl)
483 match List.hd conclude.Con.conclude_args with
484 | Con.Term (_,t) -> t
487 B.HOV([],[B.b_kw "conclude";B.b_space;term2pres hd; (* B.b_space; *)
488 B.V ([],aux (List.tl conclude.Con.conclude_args))])
489 else if conclude.Con.conclude_method = "Apply" then
491 make_args_for_apply term2pres conclude.Con.conclude_args in
495 B.Text([],"(")::pres_args@[B.Text([],")")])
498 B.b_kw ("Apply method" ^ conclude.Con.conclude_method ^ " to");
499 (B.indent (B.V ([], args2pres conclude.Con.conclude_args)))])
501 and args2pres l = List.map arg2pres l
505 Con.Aux n -> B.b_kw ("aux " ^ n)
506 | Con.Premise prem -> B.b_kw "premise"
507 | Con.Lemma lemma -> B.b_kw "lemma"
508 | Con.Term (_,t) -> term2pres t
509 | Con.ArgProof p -> proof2pres true p false
510 | Con.ArgMethod s -> B.b_kw "method"
513 let proof_conclusion =
514 (match conclude.Con.conclude_conclusion with
515 None -> B.b_kw "No conclusion???"
516 | Some t -> term2pres t) in
517 let arg,args_for_cases =
518 (match conclude.Con.conclude_args with
519 Con.Aux(_)::Con.Aux(_)::Con.Term(_)::arg::tl ->
521 | _ -> assert false) in
525 Con.Aux n -> B.b_kw "an aux???"
526 | Con.Premise prem ->
527 (match prem.Con.premise_binder with
528 None -> B.b_kw "previous"
529 | Some n -> B.Object ([], P.Mi([],n)))
530 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
533 | Con.ArgProof p -> B.b_kw "a proof???"
534 | Con.ArgMethod s -> B.b_kw "a method???")
536 (make_concl "we proceed by cases on" case_arg) in
538 (make_concl "to prove" proof_conclusion) in
539 B.V ([], case_on::to_prove::(make_cases args_for_cases))
541 and byinduction conclude =
542 let proof_conclusion =
543 (match conclude.Con.conclude_conclusion with
544 None -> B.b_kw "No conclusion???"
545 | Some t -> term2pres t) in
546 let inductive_arg,args_for_cases =
547 (match conclude.Con.conclude_args with
549 let l1,l2 = split (int_of_string n) tl in
550 let last_pos = (List.length l2)-1 in
551 List.nth l2 last_pos,l1
552 | _ -> assert false) in
555 (match inductive_arg with
556 Con.Aux n -> B.b_kw "an aux???"
557 | Con.Premise prem ->
558 (match prem.Con.premise_binder with
559 None -> B.b_kw "previous"
560 | Some n -> B.Object ([], P.Mi([],n)))
561 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
564 | Con.ArgProof p -> B.b_kw "a proof???"
565 | Con.ArgMethod s -> B.b_kw "a method???") in
566 (make_concl "we proceed by induction on" arg) in
568 B.H ([], [make_concl "to prove" proof_conclusion ; B.Text([],".")]) in
569 B.V ([], induction_on::to_prove::(make_cases args_for_cases))
571 and make_cases l = List.map make_case l
577 (match p.Con.proof_name with
578 None -> B.b_kw "no name for case!!"
579 | Some n -> B.Object ([], P.Mi([],n))) in
583 `Hypothesis h -> h.Con.dec_inductive
584 | _ -> false) p.Con.proof_context in
592 let name = get_name h.Con.dec_name in
595 B.Object ([], P.Mi ([],name));
597 (term2pres h.Con.dec_type);
599 | _ -> assert false (*[B.Text ([],"???")]*)) in
603 (B.b_kw "case"::B.b_space::name::pattern_aux)@
607 (match p.Con.proof_conclude.Con.conclude_conclusion with
608 None -> B.b_kw "No conclusion!!!"
609 | Some t -> term2pres t) in
610 let asubconcl = B.indent (make_concl "the thesis becomes" subconcl) in
611 let induction_hypothesis =
615 let text = B.indent (B.b_kw "by induction hypothesis we know") in
620 (match h.Con.dec_name with
624 [term2pres h.Con.dec_type;
627 B.Object ([], P.Mi ([],name));
630 | _ -> assert false in
631 let hyps = List.map make_hyp indhyps in
634 conclude2pres true p.Con.proof_name p.Con.proof_conclude true true false in
637 match p.Con.proof_apply_context with
638 [] -> p.Con.proof_conclude.Con.conclude_id
639 | {Con.proof_id = id}::_ -> id
641 B.Action([None,"type","toggle"],
642 [ B.indent (add_xref acontext_id (B.b_kw "Proof"));
644 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
645 p.Con.proof_apply_context body true
646 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
648 B.V ([], pattern::induction_hypothesis@[B.H ([],[asubconcl;B.Text([],".")]);presacontext])
651 and falseind conclude =
652 let proof_conclusion =
653 (match conclude.Con.conclude_conclusion with
654 None -> B.b_kw "No conclusion???"
655 | Some t -> term2pres t) in
657 (match conclude.Con.conclude_args with
658 [Con.Aux(n);_;case_arg] -> case_arg
661 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
665 Con.Aux n -> assert false
666 | Con.Premise prem ->
667 (match prem.Con.premise_binder with
668 None -> [B.b_kw "Contradiction, hence"]
670 [ B.Object ([],P.Mi([],n)); B.skip;
671 B.b_kw "is contradictory, hence"])
673 [ B.Object ([], P.Mi([],lemma.Con.lemma_name)); B.skip;
674 B.b_kw "is contradictory, hence" ]
675 | _ -> assert false) in
676 make_row arg proof_conclusion
678 and andind conclude =
680 (match conclude.Con.conclude_args with
681 [Con.Aux(n);_;Con.ArgProof proof;case_arg] -> proof,case_arg
684 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
688 Con.Aux n -> assert false
689 | Con.Premise prem ->
690 (match prem.Con.premise_binder with
692 | Some n -> [(B.b_kw "by"); B.b_space; B.Object([], P.Mi([],n))])
694 [(B.b_kw "by");B.skip;
695 B.Object([], P.Mi([],lemma.Con.lemma_name))]
696 | _ -> assert false) in
697 match proof.Con.proof_context with
698 `Hypothesis hyp1::`Hypothesis hyp2::tl ->
702 B.Object ([], P.Mi([],get_name hyp1.Con.dec_name));
705 term2pres hyp1.Con.dec_type]) in
709 B.Object ([], P.Mi([],get_name hyp2.Con.dec_name));
712 term2pres hyp2.Con.dec_type]) in
714 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
717 acontext2pres false proof.Con.proof_apply_context body false false
721 [B.H ([],arg@[B.skip; B.b_kw "we have"]);
728 and exists conclude =
730 (match conclude.Con.conclude_args with
731 [Con.Aux(n);_;Con.ArgProof proof;_] -> proof
734 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
736 match proof.Con.proof_context with
737 `Declaration decl::`Hypothesis hyp::tl
738 | `Hypothesis decl::`Hypothesis hyp::tl ->
743 B.Object ([], P.Mi([],get_name decl.Con.dec_name));
744 B.Text([],":"); term2pres decl.Con.dec_type]) in
747 [(B.b_kw "such that");
750 B.Object ([], P.Mi([],get_name hyp.Con.dec_name));
753 term2pres hyp.Con.dec_type]) in
755 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
758 acontext2pres false proof.Con.proof_apply_context body false false
769 ?skip_initial_lambdas_internal:
770 (match skip_initial_lambdas with
771 None -> Some (`Later 0) (* we already printed theorem: *)
772 | Some n -> Some (`Later n))
779 let conjecture2pres term2pres (id, n, context, ty) =
781 (B.b_hv [Some "helm", "xref", id]
783 B.b_h [] [B.b_text [] "{...}"; B.b_space];
788 [ B.b_object (p_mi [] "_") ;
789 B.b_object (p_mo [] ":?") ;
790 B.b_object (p_mi [] "_")]
791 | Some (`Declaration d)
792 | Some (`Hypothesis d) ->
793 let { Content.dec_name =
794 dec_name ; Content.dec_type = ty } = d
804 | Some (`Definition d) ->
806 { Content.def_name = def_name ;
807 Content.def_term = bo } = d
810 [ B.b_object (p_mi []
814 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
817 let proof_name = p.Content.proof_name in
819 [ B.b_object (p_mi []
820 (match proof_name with
823 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
824 proof2pres true term2pres p])
825 (List.rev context)) ] ::
827 [ B.b_text [] (Utf8Macro.unicode_of_tex "\\vdash");
828 B.b_object (p_mi [] (string_of_int n)) ;
832 let metasenv2pres term2pres = function
835 (* Conjectures are in their own table to make *)
836 (* diffing the DOM trees easier. *)
838 ((B.b_kw ("Conjectures:" ^
839 (let _ = incr counter; in (string_of_int !counter)))) ::
840 (List.map (conjecture2pres term2pres) metasenv'))]
842 let params2pres params =
844 B.b_text [Some "xlink", "href", UriManager.string_of_uri uri]
845 (UriManager.name_of_uri uri)
847 let rec spatiate = function
850 | hd :: tl -> hd :: B.b_text [] ", " :: spatiate tl
855 let params = spatiate (List.map param2pres p) in
857 B.b_h [] (B.b_text [] "[" :: params @ [ B.b_text [] "]" ])]
859 let recursion_kind2pres params kind =
862 | `Recursive _ -> "Recursive definition"
863 | `CoRecursive -> "CoRecursive definition"
864 | `Inductive _ -> "Inductive definition"
865 | `CoInductive _ -> "CoInductive definition"
867 B.b_h [] (B.b_kw kind :: params2pres params)
869 let inductive2pres term2pres ind =
870 let constructor2pres decl =
872 B.b_text [] ("| " ^ get_name decl.Content.dec_name ^ ":");
874 term2pres decl.Content.dec_type
879 B.b_kw (ind.Content.inductive_name ^ " of arity");
881 term2pres ind.Content.inductive_type ]
882 :: List.map constructor2pres ind.Content.inductive_constructors)
884 let joint_def2pres term2pres def =
886 | `Inductive ind -> inductive2pres term2pres ind
887 | _ -> assert false (* ZACK or raise ToDo? *)
890 ?skip_initial_lambdas ?(skip_thm_and_qed=false) term2pres
891 (id,params,metasenv,obj)
894 | `Def (Content.Const, thesis, `Proof p) ->
895 let name = get_name p.Content.proof_name in
896 let proof = proof2pres true term2pres ?skip_initial_lambdas p in
897 if skip_thm_and_qed then
901 [Some "helm","xref","id"]
902 ([ B.b_h [] (B.b_kw ("theorem " ^ name) ::
903 params2pres params @ [B.b_kw ":"]);
904 B.H ([],[B.indent (term2pres thesis) ; B.b_kw "." ])] @
905 metasenv2pres term2pres metasenv @
906 [proof ; B.b_kw "qed."])
907 | `Def (_, ty, `Definition body) ->
908 let name = get_name body.Content.def_name in
910 [Some "helm","xref","id"]
912 (B.b_kw ("definition " ^ name) :: params2pres params @ [B.b_kw ":"]);
913 B.indent (term2pres ty)] @
914 metasenv2pres term2pres metasenv @
916 B.indent (term2pres body.Content.def_term);
918 | `Decl (_, `Declaration decl)
919 | `Decl (_, `Hypothesis decl) ->
920 let name = get_name decl.Content.dec_name in
922 [Some "helm","xref","id"]
923 ([B.b_h [] (B.b_kw ("Axiom " ^ name) :: params2pres params);
925 B.indent (term2pres decl.Content.dec_type)] @
926 metasenv2pres term2pres metasenv)
929 (recursion_kind2pres params joint.Content.joint_kind
930 :: List.map (joint_def2pres term2pres) joint.Content.joint_defs)
934 ?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_inner_sorts
936 content2pres ?skip_initial_lambdas ?skip_thm_and_qed
937 (fun ?(prec=90) annterm ->
938 let ast, ids_to_uris =
939 TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
941 CicNotationPres.box_of_mpres
942 (CicNotationPres.render ids_to_uris ~prec
943 (TermContentPres.pp_ast ast)))