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 = 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 Some (B.b_toggle [B.b_kw "proof";proof2pres true term2pres p])
137 and proof2pres ?skip_initial_lambdas is_top_down term2pres p =
138 let rec proof2pres ?skip_initial_lambdas_internal is_top_down p omit_dot =
143 | `Hypothesis _ -> true
145 ((List.filter is_decl p.Con.proof_context) != []) in
146 let omit_conclusion = (not indent) && (p.Con.proof_context != []) in
148 (match p.Con.proof_conclude.Con.conclude_conclusion with
150 | Some t -> Some (term2pres t)) in
154 ?skip_initial_lambdas_internal:
155 (match skip_initial_lambdas_internal with
156 Some (`Later s) -> Some (`Now s)
159 p.Con.proof_name p.Con.proof_conclude indent omit_conclusion
163 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
164 p.Con.proof_apply_context
166 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
169 (match skip_initial_lambdas_internal with
170 Some (`Now n) -> snd (HExtlib.split_nth n p.Con.proof_context)
171 | _ -> p.Con.proof_context)
174 match p.Con.proof_name with
182 make_concl ~attrs:[ Some "helm", "xref", p.Con.proof_id ]
184 B.b_toggle [ B.H ([], [concl; B.skip ; B.Text([],"(");
185 B.Object ([], P.Mi ([],name));
186 B.Text([],")") ]) ; body ]
190 and context2pres c continuation =
191 (* we generate a subtable for each context element, for selection
193 The table generated by the head-element does not have an xref;
194 the whole context-proof is already selectable *)
200 (fun ce continuation ->
201 let xref = get_xref ce in
202 B.V([Some "helm", "xref", xref ],
203 [B.H([Some "helm", "xref", "ce_"^xref],
204 [ce2pres_in_proof_context_element ce]);
205 continuation])) tl continuation in
206 let hd_xref= get_xref hd in
208 [B.H([Some "helm", "xref", "ce_"^hd_xref],
209 [ce2pres_in_proof_context_element hd]);
212 and ce2pres_in_joint_context_element = function
213 | `Inductive _ -> assert false (* TODO *)
214 | (`Declaration _) as x -> ce2pres x
215 | (`Hypothesis _) as x -> ce2pres x
216 | (`Proof _) as x -> ce2pres x
217 | (`Definition _) as x -> ce2pres x
219 and ce2pres_in_proof_context_element = function
221 B.H ([],(List.map ce2pres_in_joint_context_element ho.Content.joint_defs))
222 | (`Declaration _) as x -> ce2pres x
223 | (`Hypothesis _) as x -> ce2pres x
224 | (`Proof _) as x -> ce2pres x
225 | (`Definition _) as x -> ce2pres x
230 let ty = term2pres d.Con.dec_type in
234 B.Object ([], P.Mi([],get_name d.Con.dec_name));
239 let ty = term2pres h.Con.dec_type in
246 B.Object ([], P.Mi ([],get_name h.Con.dec_name));
250 proof2pres false p false
252 let term = term2pres d.Con.def_term in
254 [ B.b_kw "let"; B.b_space;
255 B.Object ([], P.Mi([],get_name d.Con.def_name));
256 B.Text([],Utf8Macro.unicode_of_tex "\\def");
259 and acontext2pres is_top_down ac continuation indent in_bu_conversion =
264 let continuation = aux tl in
265 (* Applicative context get flattened and the "body" of a BU_Conversion
266 is put in the applicative context. Thus two different situations
268 {method = "BU_Conversion"; applicative_context=[p1; ...; pn]}
269 {method = xxx; applicative_context =
270 [ p1; ...; pn; {method="BU_Conversion"} ; p_{n+1}; ... ; pm ]}
271 In both situations only pn must be processed in in_bu_conversion
274 let in_bu_conversion =
276 [] -> in_bu_conversion
277 | p::_ -> p.Con.proof_conclude.Con.conclude_method = "BU_Conversion"
281 B.indent (proof2pres is_top_down p in_bu_conversion)
283 proof2pres is_top_down p in_bu_conversion
285 B.V([Some "helm","xref",p.Con.proof_id],
286 [B.H([Some "helm","xref","ace_"^p.Con.proof_id],[hd]);
290 and conclude2pres ?skip_initial_lambdas_internal is_top_down name conclude indent omit_conclusion omit_dot =
292 match conclude.Con.conclude_conclusion with
293 Some t (*when not omit_conclusion or
294 (* CSC: I ignore the omit_conclusion flag in this case. *)
295 (* CSC: Is this the correct behaviour? In the stylesheets *)
296 (* CSC: we simply generated nothing (i.e. the output type *)
297 (* CSC: of the function should become an option. *)
298 conclude.Con.conclude_method = "BU_Conversion" *) ->
299 let concl = term2pres t in
300 if conclude.Con.conclude_method = "BU_Conversion" then
302 (make_concl "that is equivalent to" concl ::
303 if is_top_down then [B.b_space ; B.b_kw "done";
304 B.Text([],".")] else [B.Text([],".")])
305 else if conclude.Con.conclude_method = "FalseInd" then
306 (* false ind is in charge to add the conclusion *)
312 conclude.Con.conclude_method = "Intros+LetTac"
314 let name = get_name name in
318 (match conclude.Con.conclude_conclusion with
319 None -> B.Text([],"NO EXPECTED!!!")
320 | Some c -> term2pres c)
322 [make_concl "we need to prove" expected;
325 B.Object ([], P.Mi ([],name));
332 conclude_aux ?skip_initial_lambdas_internal conclude in
334 if conclude.Con.conclude_method = "Intros+LetTac"
335 || conclude.Con.conclude_method = "ByInduction"
336 || conclude.Con.conclude_method = "TD_Conversion"
339 else if omit_conclusion then
340 B.H([], [B.b_kw "done" ; B.Text([],".") ])
343 ((if not is_top_down || omit_dot then
344 (make_concl "we proved" concl) ::
345 if not is_top_down then
346 [B.b_space; B.Text([],"(previous)")]
349 ) @ if not omit_dot then [B.Text([],".")] else [])
351 B.V ([], prequel @ [conclude_body; ann_concl])
352 | _ -> conclude_aux ?skip_initial_lambdas_internal conclude
355 B.indent (B.H ([Some "helm", "xref", conclude.Con.conclude_id],
358 B.H ([Some "helm", "xref", conclude.Con.conclude_id],[tconclude_body])
360 and conclude_aux ?skip_initial_lambdas_internal conclude =
361 if conclude.Con.conclude_method = "TD_Conversion" then
363 (match conclude.Con.conclude_conclusion with
364 None -> B.Text([],"NO EXPECTED!!!")
365 | Some c -> term2pres c) in
367 (match conclude.Con.conclude_args with
368 [Con.ArgProof p] -> p
369 | _ -> assert false) in
371 (match subproof.Con.proof_conclude.Con.conclude_conclusion with
372 None -> B.Text([],"NO SYNTH!!!")
373 | Some c -> (term2pres c)) in
376 [make_concl "we need to prove" expected;
377 B.H ([],[make_concl "or equivalently" synth; B.Text([],".")]);
378 proof2pres true subproof false])
379 else if conclude.Con.conclude_method = "BU_Conversion" then
381 else if conclude.Con.conclude_method = "Exact" then
383 (match conclude.Con.conclude_args with
384 [Con.Term (b,t)] -> assert (not b);term2pres t
386 (match p.Con.premise_binder with
387 | None -> assert false; (* unnamed hypothesis ??? *)
388 | Some s -> B.Text([],s))
389 | err -> assert false) in
390 (match conclude.Con.conclude_conclusion with
392 B.b_h [] [B.b_kw "by"; B.b_space; arg]
394 B.b_h [] [B.b_kw "by"; B.b_space; arg]
396 else if conclude.Con.conclude_method = "Intros+LetTac" then
397 (match conclude.Con.conclude_args with
399 (match conclude.Con.conclude_args with
401 proof2pres ?skip_initial_lambdas_internal true p false
406 (match conclude.Con.conclude_conclusion with
407 None -> B.Text([],"NO Conclusion!!!")
408 | Some c -> term2pres c) in
409 (match conclude.Con.conclude_args with
412 ([None,"align","baseline 1"; None,"equalrows","false";
413 None,"columnalign","left"],
414 [B.H([],[B.Object([],proof2pres p false)]);
416 (make_concl "we proved 1" conclusion))])]);
419 else if (conclude.Con.conclude_method = "Case") then
421 else if (conclude.Con.conclude_method = "ByInduction") then
423 else if (conclude.Con.conclude_method = "Exists") then
425 else if (conclude.Con.conclude_method = "AndInd") then
427 else if (conclude.Con.conclude_method = "FalseInd") then
429 else if (conclude.Con.conclude_method = "Rewrite") then
430 let justif1,justif2 =
431 (match (List.nth conclude.Con.conclude_args 6) with
432 Con.ArgProof p -> justification term2pres p
433 | _ -> assert false) in
435 (match List.nth conclude.Con.conclude_args 2 with
436 Con.Term (_,t) -> term2pres t
437 | _ -> assert false) in
439 (match List.nth conclude.Con.conclude_args 5 with
440 Con.Term (_,t) -> term2pres t
441 | _ -> assert false) in
447 B.b_space; (B.b_kw "with");
449 B.b_space; justif1])::
450 match justif2 with None -> [] | Some j -> [B.indent j])
451 *) B.V([], [justif1 ; B.H([],[B.b_kw "we proved (" ; term2 ; B.b_kw "=" ; term1; B.b_kw ") (previous)."]); B.b_kw "by _"])
452 else if conclude.Con.conclude_method = "Eq_chain" then
453 let justification p =
455 if skip_initial_lambdas <> None (* cheating *) then
459 let j1,j2 = justification term2pres p in
460 j1 :: B.b_space :: (match j2 with Some j -> [j] | None -> [])
465 | (Con.ArgProof p)::(Con.Term (_,t))::tl ->
466 B.HOV(RenderingAttrs.indent_attributes `BoxML,([B.b_kw
467 "=";B.b_space;term2pres t;B.b_space]@justification p@
468 (if tl <> [] then [B.Text ([],".")] else [])))::(aux tl)
472 match List.hd conclude.Con.conclude_args with
473 | Con.Term (_,t) -> t
476 B.HOV([],[B.b_kw "conclude";B.b_space;term2pres hd; (* B.b_space; *)
477 B.V ([],aux (List.tl conclude.Con.conclude_args))])
478 else if conclude.Con.conclude_method = "Apply" then
480 make_args_for_apply term2pres conclude.Con.conclude_args in
484 B.Text([],"(")::pres_args@[B.Text([],")")])
487 B.b_kw ("Apply method" ^ conclude.Con.conclude_method ^ " to");
488 (B.indent (B.V ([], args2pres conclude.Con.conclude_args)))])
490 and args2pres l = List.map arg2pres l
494 Con.Aux n -> B.b_kw ("aux " ^ n)
495 | Con.Premise prem -> B.b_kw "premise"
496 | Con.Lemma lemma -> B.b_kw "lemma"
497 | Con.Term (_,t) -> term2pres t
498 | Con.ArgProof p -> proof2pres true p false
499 | Con.ArgMethod s -> B.b_kw "method"
502 let proof_conclusion =
503 (match conclude.Con.conclude_conclusion with
504 None -> B.b_kw "No conclusion???"
505 | Some t -> term2pres t) in
506 let arg,args_for_cases =
507 (match conclude.Con.conclude_args with
508 Con.Aux(_)::Con.Aux(_)::Con.Term(_)::arg::tl ->
510 | _ -> assert false) in
514 Con.Aux n -> B.b_kw "an aux???"
515 | Con.Premise prem ->
516 (match prem.Con.premise_binder with
517 None -> B.b_kw "the previous result"
518 | Some n -> B.Object ([], P.Mi([],n)))
519 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
522 | Con.ArgProof p -> B.b_kw "a proof???"
523 | Con.ArgMethod s -> B.b_kw "a method???")
525 (make_concl "we proceed by cases on" case_arg) in
527 (make_concl "to prove" proof_conclusion) in
528 B.V ([], case_on::to_prove::(make_cases args_for_cases))
530 and byinduction conclude =
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 inductive_arg,args_for_cases =
536 (match conclude.Con.conclude_args with
538 let l1,l2 = split (int_of_string n) tl in
539 let last_pos = (List.length l2)-1 in
540 List.nth l2 last_pos,l1
541 | _ -> assert false) in
544 (match inductive_arg with
545 Con.Aux n -> B.b_kw "an aux???"
546 | Con.Premise prem ->
547 (match prem.Con.premise_binder with
548 None -> B.b_kw "the previous result"
549 | Some n -> B.Object ([], P.Mi([],n)))
550 | Con.Lemma lemma -> B.Object ([], P.Mi([],lemma.Con.lemma_name))
553 | Con.ArgProof p -> B.b_kw "a proof???"
554 | Con.ArgMethod s -> B.b_kw "a method???") in
555 (make_concl "we proceed by induction on" arg) in
557 B.H ([], [make_concl "to prove" proof_conclusion ; B.Text([],".")]) in
558 B.V ([], induction_on::to_prove::(make_cases args_for_cases))
560 and make_cases l = List.map make_case l
566 (match p.Con.proof_name with
567 None -> B.b_kw "no name for case!!"
568 | Some n -> B.Object ([], P.Mi([],n))) in
572 `Hypothesis h -> h.Con.dec_inductive
573 | _ -> false) p.Con.proof_context in
581 let name = get_name h.Con.dec_name in
584 B.Object ([], P.Mi ([],name));
586 (term2pres h.Con.dec_type);
588 | _ -> assert false (*[B.Text ([],"???")]*)) in
592 (B.b_kw "case"::B.b_space::name::pattern_aux)@
596 (match p.Con.proof_conclude.Con.conclude_conclusion with
597 None -> B.b_kw "No conclusion!!!"
598 | Some t -> term2pres t) in
599 let asubconcl = B.indent (make_concl "the thesis becomes" subconcl) in
600 let induction_hypothesis =
604 let text = B.indent (B.b_kw "by induction hypothesis we know") in
609 (match h.Con.dec_name with
613 [term2pres h.Con.dec_type;
616 B.Object ([], P.Mi ([],name));
619 | _ -> assert false in
620 let hyps = List.map make_hyp indhyps in
623 conclude2pres true p.Con.proof_name p.Con.proof_conclude true true false in
626 match p.Con.proof_apply_context with
627 [] -> p.Con.proof_conclude.Con.conclude_id
628 | {Con.proof_id = id}::_ -> id
630 B.Action([None,"type","toggle"],
631 [ B.indent (add_xref acontext_id (B.b_kw "Proof"));
633 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
634 p.Con.proof_apply_context body true
635 (p.Con.proof_conclude.Con.conclude_method = "BU_Conversion")
637 B.V ([], pattern::induction_hypothesis@[B.H ([],[asubconcl;B.Text([],".")]);presacontext])
640 and falseind conclude =
641 let proof_conclusion =
642 (match conclude.Con.conclude_conclusion with
643 None -> B.b_kw "No conclusion???"
644 | Some t -> term2pres t) in
646 (match conclude.Con.conclude_args with
647 [Con.Aux(n);_;case_arg] -> case_arg
650 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
654 Con.Aux n -> assert false
655 | Con.Premise prem ->
656 (match prem.Con.premise_binder with
657 None -> [B.b_kw "Contradiction, hence"]
659 [ B.Object ([],P.Mi([],n)); B.skip;
660 B.b_kw "is contradictory, hence"])
662 [ B.Object ([], P.Mi([],lemma.Con.lemma_name)); B.skip;
663 B.b_kw "is contradictory, hence" ]
664 | _ -> assert false) in
665 make_row arg proof_conclusion
667 and andind conclude =
669 (match conclude.Con.conclude_args with
670 [Con.Aux(n);_;Con.ArgProof proof;case_arg] -> proof,case_arg
673 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
677 Con.Aux n -> assert false
678 | Con.Premise prem ->
679 (match prem.Con.premise_binder with
681 | Some n -> [(B.b_kw "by"); B.b_space; B.Object([], P.Mi([],n))])
683 [(B.b_kw "by");B.skip;
684 B.Object([], P.Mi([],lemma.Con.lemma_name))]
685 | _ -> assert false) in
686 match proof.Con.proof_context with
687 `Hypothesis hyp1::`Hypothesis hyp2::tl ->
691 B.Object ([], P.Mi([],get_name hyp1.Con.dec_name));
694 term2pres hyp1.Con.dec_type]) in
698 B.Object ([], P.Mi([],get_name hyp2.Con.dec_name));
701 term2pres hyp2.Con.dec_type]) in
703 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
706 acontext2pres false proof.Con.proof_apply_context body false false
710 [B.H ([],arg@[B.skip; B.b_kw "we have"]);
717 and exists conclude =
719 (match conclude.Con.conclude_args with
720 [Con.Aux(n);_;Con.ArgProof proof;_] -> proof
723 List.map (ContentPp.parg 0) conclude.Con.conclude_args;
725 match proof.Con.proof_context with
726 `Declaration decl::`Hypothesis hyp::tl
727 | `Hypothesis decl::`Hypothesis hyp::tl ->
732 B.Object ([], P.Mi([],get_name decl.Con.dec_name));
733 B.Text([],":"); term2pres decl.Con.dec_type]) in
736 [(B.b_kw "such that");
739 B.Object ([], P.Mi([],get_name hyp.Con.dec_name));
742 term2pres hyp.Con.dec_type]) in
744 conclude2pres false proof.Con.proof_name proof.Con.proof_conclude
747 acontext2pres false proof.Con.proof_apply_context body false false
758 ?skip_initial_lambdas_internal:
759 (match skip_initial_lambdas with
760 None -> Some (`Later 0) (* we already printed theorem: *)
761 | Some n -> Some (`Later n))
768 let conjecture2pres term2pres (id, n, context, ty) =
770 (B.b_hv [Some "helm", "xref", id]
772 B.b_h [] [B.b_text [] "{...}"; B.b_space];
777 [ B.b_object (p_mi [] "_") ;
778 B.b_object (p_mo [] ":?") ;
779 B.b_object (p_mi [] "_")]
780 | Some (`Declaration d)
781 | Some (`Hypothesis d) ->
782 let { Content.dec_name =
783 dec_name ; Content.dec_type = ty } = d
793 | Some (`Definition d) ->
795 { Content.def_name = def_name ;
796 Content.def_term = bo } = d
799 [ B.b_object (p_mi []
803 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
806 let proof_name = p.Content.proof_name in
808 [ B.b_object (p_mi []
809 (match proof_name with
812 B.b_text [] (Utf8Macro.unicode_of_tex "\\Assign");
813 proof2pres true term2pres p])
814 (List.rev context)) ] ::
816 [ B.b_text [] (Utf8Macro.unicode_of_tex "\\vdash");
817 B.b_object (p_mi [] (string_of_int n)) ;
821 let metasenv2pres term2pres = function
824 (* Conjectures are in their own table to make *)
825 (* diffing the DOM trees easier. *)
827 ((B.b_kw ("Conjectures:" ^
828 (let _ = incr counter; in (string_of_int !counter)))) ::
829 (List.map (conjecture2pres term2pres) metasenv'))]
831 let params2pres params =
833 B.b_text [Some "xlink", "href", UriManager.string_of_uri uri]
834 (UriManager.name_of_uri uri)
836 let rec spatiate = function
839 | hd :: tl -> hd :: B.b_text [] ", " :: spatiate tl
844 let params = spatiate (List.map param2pres p) in
846 B.b_h [] (B.b_text [] "[" :: params @ [ B.b_text [] "]" ])]
848 let recursion_kind2pres params kind =
851 | `Recursive _ -> "Recursive definition"
852 | `CoRecursive -> "CoRecursive definition"
853 | `Inductive _ -> "Inductive definition"
854 | `CoInductive _ -> "CoInductive definition"
856 B.b_h [] (B.b_kw kind :: params2pres params)
858 let inductive2pres term2pres ind =
859 let constructor2pres decl =
861 B.b_text [] ("| " ^ get_name decl.Content.dec_name ^ ":");
863 term2pres decl.Content.dec_type
868 B.b_kw (ind.Content.inductive_name ^ " of arity");
870 term2pres ind.Content.inductive_type ]
871 :: List.map constructor2pres ind.Content.inductive_constructors)
873 let joint_def2pres term2pres def =
875 | `Inductive ind -> inductive2pres term2pres ind
876 | _ -> assert false (* ZACK or raise ToDo? *)
879 ?skip_initial_lambdas ?(skip_thm_and_qed=false) term2pres
880 (id,params,metasenv,obj)
883 | `Def (Content.Const, thesis, `Proof p) ->
884 let name = get_name p.Content.proof_name in
885 let proof = proof2pres true term2pres ?skip_initial_lambdas p in
886 if skip_thm_and_qed then
890 [Some "helm","xref","id"]
891 ([ B.b_h [] (B.b_kw ("theorem " ^ name) ::
892 params2pres params @ [B.b_kw ":"]);
893 B.H ([],[B.indent (term2pres thesis) ; B.b_kw "." ])] @
894 metasenv2pres term2pres metasenv @
895 [proof ; B.b_kw "qed."])
896 | `Def (_, ty, `Definition body) ->
897 let name = get_name body.Content.def_name in
899 [Some "helm","xref","id"]
901 (B.b_kw ("definition " ^ name) :: params2pres params @ [B.b_kw ":"]);
902 B.indent (term2pres ty)] @
903 metasenv2pres term2pres metasenv @
905 B.indent (term2pres body.Content.def_term);
907 | `Decl (_, `Declaration decl)
908 | `Decl (_, `Hypothesis decl) ->
909 let name = get_name decl.Content.dec_name in
911 [Some "helm","xref","id"]
912 ([B.b_h [] (B.b_kw ("Axiom " ^ name) :: params2pres params);
914 B.indent (term2pres decl.Content.dec_type)] @
915 metasenv2pres term2pres metasenv)
918 (recursion_kind2pres params joint.Content.joint_kind
919 :: List.map (joint_def2pres term2pres) joint.Content.joint_defs)
923 ?skip_initial_lambdas ?skip_thm_and_qed ~ids_to_inner_sorts
925 content2pres ?skip_initial_lambdas ?skip_thm_and_qed
926 (fun ?(prec=90) annterm ->
927 let ast, ids_to_uris =
928 TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
930 CicNotationPres.box_of_mpres
931 (CicNotationPres.render ids_to_uris ~prec
932 (TermContentPres.pp_ast ast)))