]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_transformations/content2pres.ml
Rendering of current proofs completed.
[helm.git] / helm / ocaml / cic_transformations / content2pres.ml
1 (* Copyright (C) 2000, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 (***************************************************************************)
27 (*                                                                         *)
28 (*                            PROJECT HELM                                 *)
29 (*                                                                         *)
30 (*                Andrea Asperti <asperti@cs.unibo.it>                     *)
31 (*                              17/06/2003                                 *)
32 (*                                                                         *)
33 (***************************************************************************)
34
35 let rec split n l =
36   if n = 0 then [],l
37   else let l1,l2 = 
38     split (n-1) (List.tl l) in
39     (List.hd l)::l1,l2
40 ;;
41   
42
43 let is_big_general countterm p =
44   let maxsize = Cexpr2pres.maxsize in
45   let module Con = Content in
46   let rec countp current_size p =
47     if current_size > maxsize then current_size
48     else 
49       let c1 = (countcontext current_size p.Con.proof_context) in
50       if c1 > maxsize then c1
51     else 
52       let c2 = (countapplycontext c1 p.Con.proof_apply_context) in
53       if c2 > maxsize then c2
54     else 
55       countconclude c2 p.Con.proof_conclude
56
57   and 
58     countcontext current_size c =
59       List.fold_left countcontextitem current_size c
60   and
61     countcontextitem current_size e =
62       if current_size > maxsize then maxsize
63       else 
64         (match e with
65           `Declaration d -> 
66             (match d.Con.dec_name with
67                Some s -> current_size + 4 + (String.length s)
68              | None -> prerr_endline "NO NAME!!"; assert false)
69         | `Hypothesis h ->
70             (match h.Con.dec_name with
71                 Some s -> current_size + 4 + (String.length s)
72               | None -> prerr_endline "NO NAME!!"; assert false) 
73         | `Proof p -> countp current_size p
74         | `Definition d -> 
75             (match d.Con.def_name with
76                 Some s -> 
77                   let c1 = (current_size + 4 + (String.length s)) in
78                   (countterm c1 d.Con.def_term)
79               | None -> 
80                   prerr_endline "NO NAME!!"; assert false) 
81         | `Joint ho -> maxsize + 1) (* we assume is big *)
82   and 
83     countapplycontext current_size ac =
84       List.fold_left countp current_size ac
85   and 
86     countconclude current_size co =
87       if current_size > maxsize then current_size
88       else
89         let c1 = countargs current_size co.Con.conclude_args in
90         if c1 > maxsize then c1 
91       else 
92         (match co.Con.conclude_conclusion with
93            Some concl ->  countterm c1 concl
94         | None -> c1)
95   and 
96     countargs current_size args =
97       List.fold_left countarg current_size args
98   and
99     countarg current_size arg =
100       if current_size > maxsize then current_size
101       else 
102         (match arg with 
103            Con.Aux _ -> current_size
104          | Con.Premise prem -> 
105              (match prem.Con.premise_binder with
106                 Some s -> current_size + (String.length s)
107               | None -> current_size + 7) 
108          | Con.Term t -> countterm current_size t
109          | Con.ArgProof p -> countp current_size p
110          | Con.ArgMethod s -> (maxsize + 1)) in
111   let size = (countp 0 p) in
112   (size > maxsize)
113 ;;
114
115 let is_big = is_big_general (Cexpr2pres.countterm)
116 ;;
117
118 let make_row items concl =
119   let module P = Mpresentation in
120     (match concl with 
121        P.Mtable _ -> (* big! *)
122          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
123           None,"columnalign","left"],
124            [P.Mtr([],[P.Mtd ([],P.Mrow([],items))]);
125             P.Mtr ([],[P.Mtd ([],P.indented concl)])])
126      | _ ->  (* small *)
127        P.Mrow([],items@[P.Mspace([None,"width","0.1cm"]);concl]))
128 ;;
129
130 let make_concl verb concl =
131   let module P = Mpresentation in
132     (match concl with 
133        P.Mtable _ -> (* big! *)
134          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
135           None,"columnalign","left"],
136            [P.Mtr([],[P.Mtd ([],P.Mtext([None,"mathcolor","Red"],verb))]);
137             P.Mtr ([],[P.Mtd ([],P.indented concl)])])
138      | _ ->  (* small *)
139        P.Mrow([],
140         [P.Mtext([None,"mathcolor","Red"],verb); 
141          P.Mspace([None,"width","0.1cm"]);
142          concl]))
143 ;;
144
145 let make_args_for_apply term2pres args =
146  let module Con = Content in
147  let module P = Mpresentation in
148  let rec make_arg_for_apply is_first arg row = 
149    (match arg with 
150       Con.Aux n -> assert false
151     | Con.Premise prem -> 
152         let name = 
153           (match prem.Con.premise_binder with
154              None -> "previous"
155            | Some s -> s) in
156         P.Mi([],name)::row
157     | Con.Term t -> 
158         if is_first then
159           (term2pres t)::row
160         else P.Mspace([None,"width","0.1cm"])::P.Mi([],"_")::row
161     | Con.ArgProof _ 
162     | Con.ArgMethod _ -> 
163        P.Mspace([None,"width","0.1cm"])::P.Mi([],"_")::row) in
164  match args with 
165    hd::tl -> 
166      make_arg_for_apply true hd 
167        (List.fold_right (make_arg_for_apply false) tl [])
168  | _ -> assert false;;
169
170 let rec justification term2pres p = 
171   let module Con = Content in
172   let module P = Mpresentation in
173   if ((p.Con.proof_conclude.Con.conclude_method = "Exact") or
174      ((p.Con.proof_context = []) &
175       (p.Con.proof_apply_context = []) &
176       (p.Con.proof_conclude.Con.conclude_method = "Apply"))) then
177     let pres_args = 
178       make_args_for_apply term2pres p.Con.proof_conclude.Con.conclude_args in
179     P.Mrow([],
180       P.Mtext([None,"mathcolor","Red"],"by")::P.Mspace([None,"width","0.1cm"])::
181       P.Mo([],"(")::pres_args@[P.Mo([],")")]) 
182   else proof2pres term2pres p 
183      
184 and proof2pres term2pres p =
185   let rec proof2pres p =
186     let module Con = Content in
187     let module P = Mpresentation in
188       let indent = 
189         let is_decl e = 
190           (match e with 
191              `Declaration _
192            | `Hypothesis _ -> true
193            | _ -> false) in
194         ((List.filter is_decl p.Con.proof_context) != []) in 
195       let concl = 
196         (match p.Con.proof_conclude.Con.conclude_conclusion with
197            None -> None
198          | Some t -> Some (term2pres t)) in
199       let body =
200           let presconclude = conclude2pres p.Con.proof_conclude indent in
201           let presacontext = 
202             acontext2pres p.Con.proof_apply_context presconclude indent in
203           context2pres p.Con.proof_context presacontext in
204 (*
205           P.Mtable ([("align","baseline 1");("equalrows","false");
206             ("columnalign","left")],
207             (context2pres_old p.Con.proof_context)@
208             (acontext2pres_old p.Con.proof_apply_context indent)@
209             [conclude2pres_old p.Con.proof_conclude indent]) in *)
210       match p.Con.proof_name with
211         None -> body
212       | Some name ->
213           let ac = 
214         (match concl with
215                None -> P.Mtext([],"NO PROOF!!!")
216              | Some c -> c) in 
217           let action = 
218             P.Maction([None,"actiontype","toggle"],
219               [(make_concl "proof of" ac);
220                 body]) in
221           P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
222               None,"columnalign","left"],
223             [P.Mtr ([],[P.Mtd ([],P.Mfenced([],[P.Mtext ([],name)]))]);
224              P.Mtr ([],[P.Mtd ([], P.indented action)])])
225
226   and context2pres c continuation =
227     let module P = Mpresentation in
228     List.fold_right
229       (fun ce continuation ->
230          P.Mtable([None,"align","baseline 1"; None,"equalrows","false";
231           None,"columnalign","left"],
232            [P.Mtr([],[P.Mtd ([],ce2pres ce)]);
233             P.Mtr([],[P.Mtd ([], continuation)])])) c continuation
234
235   and context2pres_old c =
236     let module P = Mpresentation in
237     List.map 
238       (function ce -> P.Mtr ([], [P.Mtd ([], ce2pres ce)])) c
239
240   and ce2pres =
241     let module P = Mpresentation in
242     let module Con = Content in
243       function
244         `Declaration d -> 
245           (match d.Con.dec_name with
246               Some s ->
247                 let ty = term2pres d.Con.dec_type in
248                 P.Mrow ([],
249                   [P.Mtext([None,"mathcolor","Red"],"Assume");
250                    P.Mspace([None,"width","0.1cm"]);
251                    P.Mi([],s);
252                    P.Mtext([],":");
253                    ty])
254             | None -> 
255                 prerr_endline "NO NAME!!"; assert false)
256       | `Hypothesis h ->
257           (match h.Con.dec_name with
258               Some s ->
259                 let ty = term2pres h.Con.dec_type in
260                 P.Mrow ([],
261                   [P.Mtext([None,"mathcolor","Red"],"Suppose");
262                    P.Mspace([None,"width","0.1cm"]);
263                    P.Mtext([],"(");
264                    P.Mi ([],s);
265                    P.Mtext([],")");
266                    P.Mspace([None,"width","0.1cm"]);
267                    ty])
268             | None -> 
269                 prerr_endline "NO NAME!!"; assert false) 
270       | `Proof p -> proof2pres p
271       | `Definition d -> 
272            (match d.Con.def_name with
273               Some s ->
274                 let term = term2pres d.Con.def_term in
275                 P.Mrow ([],
276                   [P.Mtext([],"Let ");
277                    P.Mi([],s);
278                    P.Mtext([]," = ");
279                    term])
280             | None -> 
281                 prerr_endline "NO NAME!!"; assert false) 
282       | `Joint ho -> 
283             P.Mtext ([],"jointdef")
284
285   and acontext2pres ac continuation indent =
286     let module P = Mpresentation in
287     List.fold_right
288       (fun p continuation ->
289          let hd = 
290            if indent then
291              P.indented (proof2pres p)
292            else 
293              proof2pres p in
294          P.Mtable([None,"align","baseline 1"; None,"equalrows","false";
295           None,"columnalign","left"],
296            [P.Mtr([],[P.Mtd ([],hd)]);
297             P.Mtr([],[P.Mtd ([], continuation)])])) ac continuation 
298
299   and acontext2pres_old ac indent =
300     let module P = Mpresentation in
301     List.map 
302       (function p -> 
303          if indent then
304            P.Mtr ([], [P.Mtd ([], P.indented (proof2pres p))])
305          else 
306            P.Mtr ([], 
307              [P.Mtd ([], proof2pres p)])) ac
308
309   and conclude2pres conclude indent =
310     let module P = Mpresentation in
311     if indent then
312       P.indented (conclude_aux conclude)
313     else 
314       conclude_aux conclude
315
316   and conclude2pres_old conclude indent =
317     let module P = Mpresentation in
318     if indent then
319       P.Mtr ([], [P.Mtd ([], P.indented (conclude_aux conclude))])
320     else 
321       P.Mtr ([], 
322         [P.Mtd ([], conclude_aux conclude)])
323
324   and conclude_aux conclude =
325     let module Con = Content in
326     let module P = Mpresentation in
327     if conclude.Con.conclude_method = "TD_Conversion" then
328       let expected = 
329         (match conclude.Con.conclude_conclusion with 
330            None -> P.Mtext([],"NO EXPECTED!!!")
331          | Some c -> term2pres c) in
332       let subproof = 
333         (match conclude.Con.conclude_args with
334           [Con.ArgProof p] -> p
335          | _ -> assert false) in
336       let synth = 
337         (match subproof.Con.proof_conclude.Con.conclude_conclusion with
338            None -> P.Mtext([],"NO SYNTH!!!")
339          | Some c -> (term2pres c)) in
340       P.Mtable 
341         ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"],
342         [P.Mtr([],[P.Mtd([],make_concl "we must prove" expected)]);
343          P.Mtr([],[P.Mtd([],make_concl "or equivalently" synth)]);
344          P.Mtr([],[P.Mtd([],proof2pres subproof)])])
345     else if conclude.Con.conclude_method = "BU_Conversion" then
346       let conclusion = 
347       (match conclude.Con.conclude_conclusion with 
348          None -> P.Mtext([],"NO Conclusion!!!")
349        | Some c -> term2pres c) in
350       make_concl "that is equivalent to" conclusion
351     else if conclude.Con.conclude_method = "Exact" then
352       let conclusion = 
353         (match conclude.Con.conclude_conclusion with 
354            None -> P.Mtext([],"NO Conclusion!!!")
355          | Some c -> term2pres c) in
356       let arg = 
357         (match conclude.Con.conclude_args with 
358            [Con.Term t] -> term2pres t
359          | _ -> assert false) in
360       make_row 
361         [arg;P.Mspace([None,"width","0.1cm"]);P.Mtext([],"proves")] conclusion
362     else if conclude.Con.conclude_method = "Intros+LetTac" then
363       let conclusion = 
364       (match conclude.Con.conclude_conclusion with 
365          None -> P.Mtext([],"NO Conclusion!!!")
366        | Some c -> term2pres c) in
367       (match conclude.Con.conclude_args with
368          [Con.ArgProof p] -> 
369            P.Mtable 
370             ([None,"align","baseline 1"; None,"equalrows","false";
371               None,"columnalign","left"],
372               [P.Mtr([],[P.Mtd([],proof2pres p)]);
373                P.Mtr([],[P.Mtd([],
374                 (make_concl "we proved *" conclusion))])]);
375        | _ -> assert false)
376     else if (conclude.Con.conclude_method = "ByInduction") then
377       byinduction conclude
378     else if (conclude.Con.conclude_method = "Rewrite") then
379       let justif = 
380         (match (List.nth conclude.Con.conclude_args 6) with
381            Con.ArgProof p -> justification term2pres p
382          | _ -> assert false) in
383       let term1 = 
384         (match List.nth conclude.Con.conclude_args 2 with
385            Con.Term t -> term2pres t
386          | _ -> assert false) in 
387       let term2 = 
388         (match List.nth conclude.Con.conclude_args 5 with
389            Con.Term t -> term2pres t
390          | _ -> assert false) in  
391       let conclusion = 
392         (match conclude.Con.conclude_conclusion with 
393            None -> P.Mtext([],"NO Conclusion!!!")
394          | Some c -> term2pres c) in
395       P.Mtable ([None,"align","baseline 1";None,"equalrows","false";
396             None,"columnalign","left"],
397              [P.Mtr ([],[P.Mtd ([],P.Mrow([],[
398                P.Mtext([None,"mathcolor","Red"],"rewrite");
399                P.Mspace([None,"width","0.1cm"]);term1;
400                P.Mspace([None,"width","0.1cm"]);
401                P.Mtext([None,"mathcolor","Red"],"with");
402                P.Mspace([None,"width","0.1cm"]);term2]))]);
403               P.Mtr ([],[P.Mtd ([],P.indented justif)]);
404               P.Mtr ([],[P.Mtd ([],make_concl "we proved" conclusion)])])
405     else if conclude.Con.conclude_method = "Apply" then
406       let pres_args = 
407         make_args_for_apply term2pres conclude.Con.conclude_args in 
408       let by = 
409          P.Mrow([],
410            P.Mtext([None,"mathcolor","Red"],"by")::P.Mspace([None,"width","0.1cm"])::
411            P.Mo([],"(")::pres_args@[P.Mo([],")")]) in 
412       match conclude.Con.conclude_conclusion with
413         None -> P.Mrow([],[P.Mtext([],"QUA");by])
414       | Some t ->
415          let concl = (term2pres t) in
416          let ann_concl = make_concl "we proved" concl in
417          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
418             None,"columnalign","left"],
419              [P.Mtr ([],[P.Mtd ([],by)]);
420               P.Mtr ([],[P.Mtd ([],ann_concl)])])
421     else let body =
422       P.Mtable 
423         ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"],
424          [P.Mtr ([],[P.Mtd ([],P.Mtext([],"Apply method" ^ conclude.Con.conclude_method ^ " to"))]);
425           P.Mtr ([],
426            [P.Mtd ([], 
427              (P.indented 
428                (P.Mtable 
429                  ([None,"align","baseline 1"; None,"equalrows","false";
430                    None,"columnalign","left"],
431                   args2pres conclude.Con.conclude_args))))])]) in
432      match conclude.Con.conclude_conclusion with
433        None -> body
434      | Some t ->
435          let concl = (term2pres t) in
436          let ann_concl = make_concl "we proved" concl in
437          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
438             None,"columnalign","left"],
439              [P.Mtr ([],[P.Mtd ([],body)]);
440               P.Mtr ([],[P.Mtd ([],ann_concl)])])
441
442   and args2pres l =
443     let module P = Mpresentation in
444     List.map 
445      (function a -> P.Mtr ([], [P.Mtd ([], arg2pres a)])) l
446
447   and arg2pres =
448     let module P = Mpresentation in
449     let module Con = Content in
450     function
451         Con.Aux n -> 
452           P.Mtext ([],"aux " ^ string_of_int n)
453       | Con.Premise prem -> 
454           P.Mtext ([],"premise")
455       | Con.Term t -> 
456           term2pres t
457       | Con.ArgProof p ->
458         proof2pres p 
459       | Con.ArgMethod s -> 
460          P.Mtext ([],"method") 
461  
462    and byinduction conclude =
463      let module P = Mpresentation in
464      let module Con = Content in
465      let proof_conclusion = 
466        (match conclude.Con.conclude_conclusion with
467           None -> P.Mtext([],"No conclusion???")
468         | Some t -> term2pres t) in
469      let inductive_arg,args_for_cases = 
470        (match conclude.Con.conclude_args with
471            Con.Aux(n)::_::tl ->
472              let l1,l2 = split n tl in
473              let last_pos = (List.length l2)-1 in
474              List.nth l2 last_pos,l1
475          | _ -> assert false) in
476      let induction_on =
477        let arg = 
478          (match inductive_arg with
479             Con.Aux n -> 
480               P.Mtext ([],"an aux???")
481            | Con.Premise prem ->
482               (match prem.Con.premise_binder with
483                  None -> P.Mtext ([],"the previous result")
484                | Some n -> P.Mi([],n))
485            | Con.Term t -> 
486                term2pres t
487            | Con.ArgProof p ->
488                P.Mtext ([],"a proof???")
489            | Con.ArgMethod s -> 
490                P.Mtext ([],"a method???")) in
491         (make_concl "we proceede by induction on" arg) in
492      let to_prove =
493         (make_concl "to prove" proof_conclusion) in
494      let we_proved = 
495         (make_concl "we proved" proof_conclusion) in
496      P.Mtable 
497        ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"],
498           P.Mtr ([],[P.Mtd ([],induction_on)])::
499           P.Mtr ([],[P.Mtd ([],to_prove)])::
500           (make_cases args_for_cases) @
501           [P.Mtr ([],[P.Mtd ([],we_proved)])]) 
502     
503     and make_cases args_for_cases =
504     let module P = Mpresentation in
505     List.map 
506       (fun p -> P.Mtr ([],[P.Mtd ([],make_case p)])) args_for_cases
507
508     and make_case =  
509       let module P = Mpresentation in
510       let module Con = Content in
511       function 
512         Con.ArgProof p ->
513           let name =
514             (match p.Con.proof_name with
515                None -> P.Mtext([],"no name for case!!")
516              | Some n -> P.Mi([],n)) in
517           let indhyps,args =
518              List.partition 
519                (function
520                    `Hypothesis h -> h.Con.dec_inductive
521                  | _ -> false) p.Con.proof_context in
522           let pattern_aux =
523              List.fold_right
524                (fun e p -> 
525                   let dec  = 
526                     (match e with 
527                        `Declaration h 
528                      | `Hypothesis h -> 
529                          let name = 
530                            (match h.Con.dec_name with
531                               None -> "NO NAME???"
532                            | Some n ->n) in
533                          [P.Mspace([None,"width","0.1cm"]);
534                           P.Mi ([],name);
535                           P.Mtext([],":");
536                           (term2pres h.Con.dec_type)]
537                      | _ -> [P.Mtext ([],"???")]) in
538                   dec@p) args [] in
539           let pattern = 
540             P.Mtr ([],[P.Mtd ([],P.Mrow([],
541                P.Mtext([],"Case")::P.Mspace([None,"width","0.1cm"])::name::pattern_aux@
542                 [P.Mspace([None,"width","0.1cm"]);
543                  P.Mtext([],"->")]))]) in
544           let subconcl = 
545             (match p.Con.proof_conclude.Con.conclude_conclusion with
546                None -> P.Mtext([],"No conclusion!!!") 
547              | Some t -> term2pres t) in
548           let asubconcl =
549              P.Mtr([],[P.Mtd([],
550               make_concl "the thesis becomes" subconcl)]) in
551           let induction_hypothesis = 
552             (match indhyps with
553               [] -> []
554             | _ -> 
555                let text =
556                  P.Mtr([],[P.Mtd([], P.indented 
557                  (P.Mtext([],"by induction hypothesis we know:")))]) in
558                let make_hyp =
559                  function 
560                    `Hypothesis h ->
561                      let name = 
562                        (match h.Con.dec_name with
563                           None -> "no name"
564                         | Some s -> s) in
565                      P.indented (P.Mrow ([],
566                        [P.Mtext([],"(");
567                         P.Mi ([],name);
568                         P.Mtext([],")");
569                         P.Mspace([None,"width","0.1cm"]);
570                         term2pres h.Con.dec_type]))
571                    | _ -> assert false in
572                let hyps = 
573                  List.map 
574                    (function ce -> P.Mtr ([], [P.Mtd ([], make_hyp ce)])) 
575                     indhyps in
576                text::hyps) in          
577           (* let acontext = 
578                acontext2pres_old p.Con.proof_apply_context true in *)
579           let body = conclude2pres p.Con.proof_conclude true in
580           let presacontext = 
581             acontext2pres p.Con.proof_apply_context body true in
582           P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
583              None,"columnalign","left"],
584              pattern::asubconcl::induction_hypothesis@
585               [P.Mtr([],[P.Mtd([],presacontext)])])
586       | _ -> assert false in
587
588 proof2pres p
589 ;;
590
591 exception ToDo;;
592
593 let content2pres term2pres (id,params,metasenv,obj) =
594  let module K = Content in
595  let module P = Mpresentation in
596   match obj with
597      `Def (K.Const,thesis,`Proof p) ->
598        P.Mtable
599         [None,"align","baseline 1";
600          None,"equalrows","false";
601          None,"columnalign","left";
602          None,"helm:xref","id"]
603         ([P.Mtr []
604            [P.Mtd []
605             (P.Mrow []
606              [P.Mtext []
607                ("UNFINISHED PROOF" ^ id ^"(" ^
608                  String.concat " ; " (List.map UriManager.string_of_uri params)^
609                 ")")])] ;
610          P.Mtr []
611           [P.Mtd []
612             (P.Mrow []
613               [P.Mtext [] "THESIS:"])] ;
614          P.Mtr []
615           [P.Mtd []
616             (P.Mrow []
617               [P.Mphantom []
618                 (P.Mtext [] "__") ;
619               term2pres thesis])]] @
620          (match metasenv with
621              None -> []
622            | Some metasenv' ->
623               (P.Mtr []
624                 [P.Mtd []
625                   (P.Mrow []
626                     [P.Mtext [] "CONJECTURES:"])]) ::
627                List.map
628                 (function
629                   (id,n,context,ty) ->
630                     P.Mtr []
631                      [P.Mtd []
632                       (P.Mrow []
633                         (List.map
634                           (function
635                               (_,None) ->
636                                 P.Mrow []
637                                  [ P.Mi [] "_" ;
638                                    P.Mo [] ":?" ;
639                                    P.Mi [] "_"]
640                             | (_,Some (`Declaration d))
641                             | (_,Some (`Hypothesis d)) ->
642                                let
643                                 { K.dec_name = dec_name ;
644                                   K.dec_type = ty } = d
645                                 in
646                                  P.Mrow []
647                                   [ P.Mi []
648                                      (match dec_name with
649                                          None -> "_"
650                                        | Some n -> n) ;
651                                     P.Mo [] ":" ;
652                                     term2pres ty]
653                             | (_,Some (`Definition d)) ->
654                                let
655                                 { K.def_name = def_name ;
656                                   K.def_term = bo } = d
657                                 in
658                                  P.Mrow []
659                                   [ P.Mi []
660                                      (match def_name with
661                                          None -> "_"
662                                        | Some n -> n) ;
663                                     P.Mo [] ":=" ;
664                                     term2pres bo]
665                             | (_,Some (`Proof p)) ->
666                                let proof_name = p.K.proof_name in
667                                 P.Mrow []
668                                  [ P.Mi []
669                                     (match proof_name with
670                                         None -> "_"
671                                       | Some n -> n) ;
672                                    P.Mo [] ":=" ;
673                                    proof2pres term2pres p]
674                           ) context @
675                         [ P.Mo [] "|-" ] @
676                         [ P.Mi [] (string_of_int n) ;
677                           P.Mo [] ":" ;
678                           term2pres ty ]
679                       ))
680                      ]
681                 ) metasenv'
682          ) @
683         [P.Mtr []
684           [P.Mtd []
685             (P.Mrow []
686               [proof2pres term2pres p])]])
687    | _ -> raise ToDo
688 ;;
689
690 let content2pres ~ids_to_inner_sorts =
691  content2pres 
692   (function p -> 
693    (Cexpr2pres.cexpr2pres_charcount 
694     (Content_expressions.acic2cexpr ids_to_inner_sorts p)))
695 ;;