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
135 B.H([],[B.b_kw "by"; B.b_space; B.b_kw "proof"]),
136 Some (B.b_toggle [B.b_kw "proof";B.indent (proof2pres true term2pres p)])
138 and proof2pres ?skip_initial_lambdas is_top_down term2pres p =
139 let rec proof2pres ?skip_initial_lambdas_internal is_top_down p omit_dot =
144 | `Hypothesis _ -> true
146 ((List.filter is_decl p.Con.proof_context) != []) in
147 let omit_conclusion = (not indent) && (p.Con.proof_context != []) in
149 (match p.Con.proof_conclude.Con.conclude_conclusion with
151 | Some t -> Some (term2pres t)) in
155 ?skip_initial_lambdas_internal:
156 (match skip_initial_lambdas_internal with
157 Some (`Later s) -> Some (`Now s)
160 p.Con.proof_name p.Con.proof_conclude indent omit_conclusion
164 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
165 p.Con.proof_apply_context
167 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
170 (match skip_initial_lambdas_internal with
171 Some (`Now n) -> snd (HExtlib.split_nth n p.Con.proof_context)
172 | _ -> p.Con.proof_context)
175 match p.Con.proof_name with
183 make_concl ~attrs:[ Some "helm", "xref", p.Con.proof_id ]
185 B.b_toggle [ B.H ([], [concl; B.skip ; B.Text([],"(");
186 B.Object ([], P.Mi ([],name));
187 B.Text([],")") ]) ; body ]
191 and context2pres c continuation =
192 (* we generate a subtable for each context element, for selection
194 The table generated by the head-element does not have an xref;
195 the whole context-proof is already selectable *)
201 (fun ce continuation ->
202 let xref = get_xref ce in
203 B.V([Some "helm", "xref", xref ],
204 [B.H([Some "helm", "xref", "ce_"^xref],
205 [ce2pres_in_proof_context_element ce]);
206 continuation])) tl continuation in
207 let hd_xref= get_xref hd in
209 [B.H([Some "helm", "xref", "ce_"^hd_xref],
210 [ce2pres_in_proof_context_element hd]);
213 and ce2pres_in_joint_context_element = function
214 | `Inductive _ -> assert false (* TODO *)
215 | (`Declaration _) as x -> ce2pres x
216 | (`Hypothesis _) as x -> ce2pres x
217 | (`Proof _) as x -> ce2pres x
218 | (`Definition _) as x -> ce2pres x
220 and ce2pres_in_proof_context_element = function
222 B.H ([],(List.map ce2pres_in_joint_context_element ho.Content.joint_defs))
223 | (`Declaration _) as x -> ce2pres x
224 | (`Hypothesis _) as x -> ce2pres x
225 | (`Proof _) as x -> ce2pres x
226 | (`Definition _) as x -> ce2pres x
231 let ty = term2pres d.Con.dec_type in
235 B.Object ([], P.Mi([],get_name d.Con.dec_name));
240 let ty = term2pres h.Con.dec_type in
247 B.Object ([], P.Mi ([],get_name h.Con.dec_name));
251 proof2pres false p false
253 let term = term2pres d.Con.def_term in
255 [ B.b_kw "let"; B.b_space;
256 B.Object ([], P.Mi([],get_name d.Con.def_name));
257 B.Text([],Utf8Macro.unicode_of_tex "\\def");
260 and acontext2pres is_top_down ac continuation indent in_bu_conversion =
265 let continuation = aux tl in
266 (* Applicative context get flattened and the "body" of a BU_Conversion
267 is put in the applicative context. Thus two different situations
269 {method = "BU_Conversion"; applicative_context=[p1; ...; pn]}
270 {method = xxx; applicative_context =
271 [ p1; ...; pn; {method="BU_Conversion"} ; p_{n+1}; ... ; pm ]}
272 In both situations only pn must be processed in in_bu_conversion
275 let in_bu_conversion =
277 [] -> in_bu_conversion
278 | p::_ -> p.Con.proof_conclude.Con.conclude_method = "BU_Conversion"
282 B.indent (proof2pres is_top_down p in_bu_conversion)
284 proof2pres is_top_down p in_bu_conversion
286 B.V([Some "helm","xref",p.Con.proof_id],
287 [B.H([Some "helm","xref","ace_"^p.Con.proof_id],[hd]);
291 and conclude2pres ?skip_initial_lambdas_internal is_top_down name conclude indent omit_conclusion omit_dot =
293 match conclude.Con.conclude_conclusion with
294 Some t (*when not omit_conclusion or
295 (* CSC: I ignore the omit_conclusion flag in this case. *)
296 (* CSC: Is this the correct behaviour? In the stylesheets *)
297 (* CSC: we simply generated nothing (i.e. the output type *)
298 (* CSC: of the function should become an option. *)
299 conclude.Con.conclude_method = "BU_Conversion" *) ->
300 let concl = term2pres t in
301 if conclude.Con.conclude_method = "BU_Conversion" then
303 (make_concl "that is equivalent to" concl ::
304 if is_top_down then [B.b_space ; B.b_kw "done";
305 B.Text([],".")] else [B.Text([],".")])
306 else if conclude.Con.conclude_method = "FalseInd" then
307 (* false ind is in charge to add the conclusion *)
313 conclude.Con.conclude_method = "Intros+LetTac"
315 let name = get_name name in
319 (match conclude.Con.conclude_conclusion with
320 None -> B.Text([],"NO EXPECTED!!!")
321 | Some c -> term2pres c)
323 [make_concl "we need to prove" expected;
326 B.Object ([], P.Mi ([],name));
333 conclude_aux ?skip_initial_lambdas_internal is_top_down conclude in
335 if conclude.Con.conclude_method = "Intros+LetTac"
336 || conclude.Con.conclude_method = "ByInduction"
337 || conclude.Con.conclude_method = "TD_Conversion"
338 || conclude.Con.conclude_method = "Eq_chain"
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
444 (match List.nth conclude.Con.conclude_args 2 with
445 Con.Term (_,t) -> term2pres t
446 | _ -> assert false) in
448 (match List.nth conclude.Con.conclude_args 5 with
449 Con.Term (_,t) -> term2pres t
450 | _ -> assert false) in
456 B.b_space; (B.b_kw "with");
458 B.b_space; justif1])::
459 match justif2 with None -> [] | Some j -> [B.indent j])
461 if (conclude.Con.conclude_method = "RewriteLR" && is_top_down)
462 || (conclude.Con.conclude_method = "RewriteRL" && not is_top_down) then
463 B.V([], [justif ; B.H([],[B.b_kw "we proved (" ; term1 ; B.b_kw "=" ; term2; B.b_kw ") (equality)."]); B.b_kw "by _"])
465 B.V([], [justif ; B.H([],[B.b_kw "we proved (" ; term2 ; B.b_kw "=" ; term1; B.b_kw ") (equality)."]); B.b_kw "by _"])
467 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])]) *)
468 else if conclude.Con.conclude_method = "Eq_chain" then
469 let justification p =
470 let j1,j2 = justification term2pres p in
471 [j1], match j2 with Some j -> [j] | None -> []
476 | (Con.ArgProof p)::(Con.Term (_,t))::tl ->
477 let justif1,justif2 = justification p in
478 B.HOV(RenderingAttrs.indent_attributes `BoxML,([B.b_kw
479 "=";B.b_space;term2pres t;B.b_space]@justif1@
480 (if tl <> [] then [B.Text ([],".")] else [B.b_space; B.b_kw "done" ; B.Text([],".")])@
485 match List.hd conclude.Con.conclude_args with
486 | Con.Term (_,t) -> t
489 B.HOV([],[B.b_kw "conclude";B.b_space;term2pres hd; (* B.b_space; *)
490 B.V ([],aux (List.tl conclude.Con.conclude_args))])
491 else if conclude.Con.conclude_method = "Apply" then
493 make_args_for_apply term2pres conclude.Con.conclude_args in
497 B.Text([],"(")::pres_args@[B.Text([],")")])
500 B.b_kw ("Apply method" ^ conclude.Con.conclude_method ^ " to");
501 (B.indent (B.V ([], args2pres conclude.Con.conclude_args)))])
503 and args2pres l = List.map arg2pres l
507 Con.Aux n -> B.b_kw ("aux " ^ n)
508 | Con.Premise prem -> B.b_kw "premise"
509 | Con.Lemma lemma -> B.b_kw "lemma"
510 | Con.Term (_,t) -> term2pres t
511 | Con.ArgProof p -> proof2pres true p false
512 | Con.ArgMethod s -> B.b_kw "method"
515 let proof_conclusion =
516 (match conclude.Con.conclude_conclusion with
517 None -> B.b_kw "No conclusion???"
518 | Some t -> term2pres t) in
519 let arg,args_for_cases =
520 (match conclude.Con.conclude_args with
521 Con.Aux(_)::Con.Aux(_)::Con.Term(_)::arg::tl ->
523 | _ -> assert false) in
527 Con.Aux n -> B.b_kw "an aux???"
528 | Con.Premise prem ->
529 (match prem.Con.premise_binder with
530 None -> B.b_kw "previous"
531 | Some n -> B.Object ([], P.Mi([],n)))
532 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
535 | Con.ArgProof p -> B.b_kw "a proof???"
536 | Con.ArgMethod s -> B.b_kw "a method???")
538 (make_concl "we proceed by cases on" case_arg) in
540 (make_concl "to prove" proof_conclusion) in
541 B.V ([], case_on::to_prove::(make_cases args_for_cases))
543 and byinduction conclude =
544 let proof_conclusion =
545 (match conclude.Con.conclude_conclusion with
546 None -> B.b_kw "No conclusion???"
547 | Some t -> term2pres t) in
548 let inductive_arg,args_for_cases =
549 (match conclude.Con.conclude_args with
551 let l1,l2 = split (int_of_string n) tl in
552 let last_pos = (List.length l2)-1 in
553 List.nth l2 last_pos,l1
554 | _ -> assert false) in
557 (match inductive_arg with
558 Con.Aux n -> B.b_kw "an aux???"
559 | Con.Premise prem ->
560 (match prem.Con.premise_binder with
561 None -> B.b_kw "previous"
562 | Some n -> B.Object ([], P.Mi([],n)))
563 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
566 | Con.ArgProof p -> B.b_kw "a proof???"
567 | Con.ArgMethod s -> B.b_kw "a method???") in
568 (make_concl "we proceed by induction on" arg) in
570 B.H ([], [make_concl "to prove" proof_conclusion ; B.Text([],".")]) in
571 B.V ([], induction_on::to_prove::(make_cases args_for_cases))
573 and make_cases l = List.map make_case l
579 (match p.Con.proof_name with
580 None -> B.b_kw "no name for case!!"
581 | Some n -> B.Object ([], P.Mi([],n))) in
585 `Hypothesis h -> h.Con.dec_inductive
586 | _ -> false) p.Con.proof_context in
594 let name = get_name h.Con.dec_name in
597 B.Object ([], P.Mi ([],name));
599 (term2pres h.Con.dec_type);
601 | _ -> assert false (*[B.Text ([],"???")]*)) in
605 (B.b_kw "case"::B.b_space::name::pattern_aux)@
609 (match p.Con.proof_conclude.Con.conclude_conclusion with
610 None -> B.b_kw "No conclusion!!!"
611 | Some t -> term2pres t) in
612 let asubconcl = B.indent (make_concl "the thesis becomes" subconcl) in
613 let induction_hypothesis =
617 let text = B.indent (B.b_kw "by induction hypothesis we know") in
622 (match h.Con.dec_name with
626 [term2pres h.Con.dec_type;
629 B.Object ([], P.Mi ([],name));
632 | _ -> assert false in
633 let hyps = List.map make_hyp indhyps in
636 conclude2pres true p.Con.proof_name p.Con.proof_conclude true true false in
639 match p.Con.proof_apply_context with
640 [] -> p.Con.proof_conclude.Con.conclude_id
641 | {Con.proof_id = id}::_ -> id
643 B.Action([None,"type","toggle"],
644 [ B.indent (add_xref acontext_id (B.b_kw "Proof"));
646 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
647 p.Con.proof_apply_context body true
648 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
650 B.V ([], pattern::induction_hypothesis@[B.H ([],[asubconcl;B.Text([],".")]);presacontext])
653 and falseind conclude =
654 let proof_conclusion =
655 (match conclude.Con.conclude_conclusion with
656 None -> B.b_kw "No conclusion???"
657 | Some t -> term2pres t) in
659 (match conclude.Con.conclude_args with
660 [Con.Aux(n);_;case_arg] -> case_arg
663 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
667 Con.Aux n -> assert false
668 | Con.Premise prem ->
669 (match prem.Con.premise_binder with
670 None -> [B.b_kw "Contradiction, hence"]
672 [ B.Object ([],P.Mi([],n)); B.skip;
673 B.b_kw "is contradictory, hence"])
675 [ B.Object ([], P.Mi([],lemma.Con.lemma_name)); B.skip;
676 B.b_kw "is contradictory, hence" ]
677 | _ -> assert false) in
678 make_row arg proof_conclusion
680 and andind conclude =
682 (match conclude.Con.conclude_args with
683 [Con.Aux(n);_;Con.ArgProof proof;case_arg] -> proof,case_arg
686 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
690 Con.Aux n -> assert false
691 | Con.Premise prem ->
692 (match prem.Con.premise_binder with
694 | Some n -> [(B.b_kw "by"); B.b_space; B.Object([], P.Mi([],n))])
696 [(B.b_kw "by");B.skip;
697 B.Object([], P.Mi([],lemma.Con.lemma_name))]
698 | _ -> assert false) in
699 match proof.Con.proof_context with
700 `Hypothesis hyp1::`Hypothesis hyp2::tl ->
704 B.Object ([], P.Mi([],get_name hyp1.Con.dec_name));
707 term2pres hyp1.Con.dec_type]) in
711 B.Object ([], P.Mi([],get_name hyp2.Con.dec_name));
714 term2pres hyp2.Con.dec_type]) in
716 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
719 acontext2pres false proof.Con.proof_apply_context body false false
723 [B.H ([],arg@[B.skip; B.b_kw "we have"]);
730 and exists conclude =
732 (match conclude.Con.conclude_args with
733 [Con.Aux(n);_;Con.ArgProof proof;_] -> proof
736 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
738 match proof.Con.proof_context with
739 `Declaration decl::`Hypothesis hyp::tl
740 | `Hypothesis decl::`Hypothesis hyp::tl ->
745 B.Object ([], P.Mi([],get_name decl.Con.dec_name));
746 B.Text([],":"); term2pres decl.Con.dec_type]) in
749 [(B.b_kw "such that");
752 B.Object ([], P.Mi([],get_name hyp.Con.dec_name));
755 term2pres hyp.Con.dec_type]) in
757 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
760 acontext2pres false proof.Con.proof_apply_context body false false
771 ?skip_initial_lambdas_internal:
772 (match skip_initial_lambdas with
773 None -> Some (`Later 0) (* we already printed theorem: *)
774 | Some n -> Some (`Later n))
781 let conjecture2pres term2pres (id, n, context, ty) =
783 (B.b_hv [Some "helm", "xref", id]
785 B.b_h [] [B.b_text [] "{...}"; B.b_space];
790 [ B.b_object (p_mi [] "_") ;
791 B.b_object (p_mo [] ":?") ;
792 B.b_object (p_mi [] "_")]
793 | Some (`Declaration d)
794 | Some (`Hypothesis d) ->
795 let { Content.dec_name =
796 dec_name ; Content.dec_type = ty } = d
806 | Some (`Definition d) ->
808 { Content.def_name = def_name ;
809 Content.def_term = bo } = d
812 [ B.b_object (p_mi []
816 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
819 let proof_name = p.Content.proof_name in
821 [ B.b_object (p_mi []
822 (match proof_name with
825 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
826 proof2pres true term2pres p])
827 (List.rev context)) ] ::
829 [ B.b_text [] (Utf8Macro.unicode_of_tex "\\vdash");
830 B.b_object (p_mi [] (string_of_int n)) ;
834 let metasenv2pres term2pres = function
837 (* Conjectures are in their own table to make *)
838 (* diffing the DOM trees easier. *)
840 ((B.b_kw ("Conjectures:" ^
841 (let _ = incr counter; in (string_of_int !counter)))) ::
842 (List.map (conjecture2pres term2pres) metasenv'))]
844 let params2pres params =
846 B.b_text [Some "xlink", "href", UriManager.string_of_uri uri]
847 (UriManager.name_of_uri uri)
849 let rec spatiate = function
852 | hd :: tl -> hd :: B.b_text [] ", " :: spatiate tl
857 let params = spatiate (List.map param2pres p) in
859 B.b_h [] (B.b_text [] "[" :: params @ [ B.b_text [] "]" ])]
861 let recursion_kind2pres params kind =
864 | `Recursive _ -> "Recursive definition"
865 | `CoRecursive -> "CoRecursive definition"
866 | `Inductive _ -> "Inductive definition"
867 | `CoInductive _ -> "CoInductive definition"
869 B.b_h [] (B.b_kw kind :: params2pres params)
871 let inductive2pres term2pres ind =
872 let constructor2pres decl =
874 B.b_text [] ("| " ^ get_name decl.Content.dec_name ^ ":");
876 term2pres decl.Content.dec_type
881 B.b_kw (ind.Content.inductive_name ^ " of arity");
883 term2pres ind.Content.inductive_type ]
884 :: List.map constructor2pres ind.Content.inductive_constructors)
886 let joint_def2pres term2pres def =
888 | `Inductive ind -> inductive2pres term2pres ind
889 | _ -> assert false (* ZACK or raise ToDo? *)
892 ?skip_initial_lambdas ?(skip_thm_and_qed=false) term2pres
893 (id,params,metasenv,obj)
896 | `Def (Content.Const, thesis, `Proof p) ->
897 let name = get_name p.Content.proof_name in
898 let proof = proof2pres true term2pres ?skip_initial_lambdas p in
899 if skip_thm_and_qed then
903 [Some "helm","xref","id"]
904 ([ B.b_h [] (B.b_kw ("theorem " ^ name) ::
905 params2pres params @ [B.b_kw ":"]);
906 B.H ([],[B.indent (term2pres thesis) ; B.b_kw "." ])] @
907 metasenv2pres term2pres metasenv @
908 [proof ; B.b_kw "qed."])
909 | `Def (_, ty, `Definition body) ->
910 let name = get_name body.Content.def_name in
912 [Some "helm","xref","id"]
914 (B.b_kw ("definition " ^ name) :: params2pres params @ [B.b_kw ":"]);
915 B.indent (term2pres ty)] @
916 metasenv2pres term2pres metasenv @
918 B.indent (term2pres body.Content.def_term);
920 | `Decl (_, `Declaration decl)
921 | `Decl (_, `Hypothesis decl) ->
922 let name = get_name decl.Content.dec_name in
924 [Some "helm","xref","id"]
925 ([B.b_h [] (B.b_kw ("Axiom " ^ name) :: params2pres params);
927 B.indent (term2pres decl.Content.dec_type)] @
928 metasenv2pres term2pres metasenv)
931 (recursion_kind2pres params joint.Content.joint_kind
932 :: List.map (joint_def2pres term2pres) joint.Content.joint_defs)
936 ?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_inner_sorts
938 content2pres ?skip_initial_lambdas ?skip_thm_and_qed
939 (fun ?(prec=90) annterm ->
940 let ast, ids_to_uris =
941 TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
943 CicNotationPres.box_of_mpres
944 (CicNotationPres.render ids_to_uris ~prec
945 (TermContentPres.pp_ast ast)))