]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_transformations/content2pres.ml
9356c288540066c7b207c4d02d75ba539866954e
[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                        None,"selection","1"],
220               [(make_concl "proof of" ac);
221                 body]) in
222           P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
223               None,"columnalign","left"],
224             [P.Mtr ([],[P.Mtd ([],P.Mfenced([],[P.Mtext ([],name)]))]);
225              P.Mtr ([],[P.Mtd ([], P.indented action)])])
226
227   and context2pres c continuation =
228     let module P = Mpresentation in
229     List.fold_right
230       (fun ce continuation ->
231          P.Mtable([None,"align","baseline 1"; None,"equalrows","false";
232           None,"columnalign","left"],
233            [P.Mtr([],[P.Mtd ([],ce2pres ce)]);
234             P.Mtr([],[P.Mtd ([], continuation)])])) c continuation
235
236   and context2pres_old c =
237     let module P = Mpresentation in
238     List.map 
239       (function ce -> P.Mtr ([], [P.Mtd ([], ce2pres ce)])) c
240
241   and ce2pres =
242     let module P = Mpresentation in
243     let module Con = Content in
244       function
245         `Declaration d -> 
246           (match d.Con.dec_name with
247               Some s ->
248                 let ty = term2pres d.Con.dec_type in
249                 P.Mrow ([],
250                   [P.Mtext([None,"mathcolor","Red"],"Assume");
251                    P.Mspace([None,"width","0.1cm"]);
252                    P.Mi([],s);
253                    P.Mtext([],":");
254                    ty])
255             | None -> 
256                 prerr_endline "NO NAME!!"; assert false)
257       | `Hypothesis h ->
258           (match h.Con.dec_name with
259               Some s ->
260                 let ty = term2pres h.Con.dec_type in
261                 P.Mrow ([],
262                   [P.Mtext([None,"mathcolor","Red"],"Suppose");
263                    P.Mspace([None,"width","0.1cm"]);
264                    P.Mtext([],"(");
265                    P.Mi ([],s);
266                    P.Mtext([],")");
267                    P.Mspace([None,"width","0.1cm"]);
268                    ty])
269             | None -> 
270                 prerr_endline "NO NAME!!"; assert false) 
271       | `Proof p -> proof2pres p
272       | `Definition d -> 
273            (match d.Con.def_name with
274               Some s ->
275                 let term = term2pres d.Con.def_term in
276                 P.Mrow ([],
277                   [P.Mtext([],"Let ");
278                    P.Mi([],s);
279                    P.Mtext([]," = ");
280                    term])
281             | None -> 
282                 prerr_endline "NO NAME!!"; assert false) 
283       | `Joint ho -> 
284             P.Mtext ([],"jointdef")
285
286   and acontext2pres ac continuation indent =
287     let module P = Mpresentation in
288     List.fold_right
289       (fun p continuation ->
290          let hd = 
291            if indent then
292              P.indented (proof2pres p)
293            else 
294              proof2pres p in
295          P.Mtable([None,"align","baseline 1"; None,"equalrows","false";
296           None,"columnalign","left"],
297            [P.Mtr([],[P.Mtd ([],hd)]);
298             P.Mtr([],[P.Mtd ([], continuation)])])) ac continuation 
299
300   and acontext2pres_old ac indent =
301     let module P = Mpresentation in
302     List.map 
303       (function p -> 
304          if indent then
305            P.Mtr ([], [P.Mtd ([], P.indented (proof2pres p))])
306          else 
307            P.Mtr ([], 
308              [P.Mtd ([], proof2pres p)])) ac
309
310   and conclude2pres conclude indent =
311     let module P = Mpresentation in
312     if indent then
313       P.indented (conclude_aux conclude)
314     else 
315       conclude_aux conclude
316
317   and conclude2pres_old conclude indent =
318     let module P = Mpresentation in
319     if indent then
320       P.Mtr ([], [P.Mtd ([], P.indented (conclude_aux conclude))])
321     else 
322       P.Mtr ([], 
323         [P.Mtd ([], conclude_aux conclude)])
324
325   and conclude_aux conclude =
326     let module Con = Content in
327     let module P = Mpresentation in
328     if conclude.Con.conclude_method = "TD_Conversion" then
329       let expected = 
330         (match conclude.Con.conclude_conclusion with 
331            None -> P.Mtext([],"NO EXPECTED!!!")
332          | Some c -> term2pres c) in
333       let subproof = 
334         (match conclude.Con.conclude_args with
335           [Con.ArgProof p] -> p
336          | _ -> assert false) in
337       let synth = 
338         (match subproof.Con.proof_conclude.Con.conclude_conclusion with
339            None -> P.Mtext([],"NO SYNTH!!!")
340          | Some c -> (term2pres c)) in
341       P.Mtable 
342         ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"],
343         [P.Mtr([],[P.Mtd([],make_concl "we must prove" expected)]);
344          P.Mtr([],[P.Mtd([],make_concl "or equivalently" synth)]);
345          P.Mtr([],[P.Mtd([],proof2pres subproof)])])
346     else if conclude.Con.conclude_method = "BU_Conversion" then
347       let conclusion = 
348       (match conclude.Con.conclude_conclusion with 
349          None -> P.Mtext([],"NO Conclusion!!!")
350        | Some c -> term2pres c) in
351       make_concl "that is equivalent to" conclusion
352     else if conclude.Con.conclude_method = "Exact" then
353       let conclusion = 
354         (match conclude.Con.conclude_conclusion with 
355            None -> P.Mtext([],"NO Conclusion!!!")
356          | Some c -> term2pres c) in
357       let arg = 
358         (match conclude.Con.conclude_args with 
359            [Con.Term t] -> term2pres t
360          | _ -> assert false) in
361       make_row 
362         [arg;P.Mspace([None,"width","0.1cm"]);P.Mtext([],"proves")] conclusion
363     else if conclude.Con.conclude_method = "Intros+LetTac" then
364       let conclusion = 
365       (match conclude.Con.conclude_conclusion with 
366          None -> P.Mtext([],"NO Conclusion!!!")
367        | Some c -> term2pres c) in
368       (match conclude.Con.conclude_args with
369          [Con.ArgProof p] -> 
370            P.Mtable 
371             ([None,"align","baseline 1"; None,"equalrows","false";
372               None,"columnalign","left"],
373               [P.Mtr([],[P.Mtd([],proof2pres p)]);
374                P.Mtr([],[P.Mtd([],
375                 (make_concl "we proved *" conclusion))])]);
376        | _ -> assert false)
377     else if (conclude.Con.conclude_method = "ByInduction") then
378       byinduction conclude
379     else if (conclude.Con.conclude_method = "Rewrite") then
380       let justif = 
381         (match (List.nth conclude.Con.conclude_args 6) with
382            Con.ArgProof p -> justification term2pres p
383          | _ -> assert false) in
384       let term1 = 
385         (match List.nth conclude.Con.conclude_args 2 with
386            Con.Term t -> term2pres t
387          | _ -> assert false) in 
388       let term2 = 
389         (match List.nth conclude.Con.conclude_args 5 with
390            Con.Term t -> term2pres t
391          | _ -> assert false) in  
392       let conclusion = 
393         (match conclude.Con.conclude_conclusion with 
394            None -> P.Mtext([],"NO Conclusion!!!")
395          | Some c -> term2pres c) in
396       P.Mtable ([None,"align","baseline 1";None,"equalrows","false";
397             None,"columnalign","left"],
398              [P.Mtr ([],[P.Mtd ([],P.Mrow([],[
399                P.Mtext([None,"mathcolor","Red"],"rewrite");
400                P.Mspace([None,"width","0.1cm"]);term1;
401                P.Mspace([None,"width","0.1cm"]);
402                P.Mtext([None,"mathcolor","Red"],"with");
403                P.Mspace([None,"width","0.1cm"]);term2]))]);
404               P.Mtr ([],[P.Mtd ([],P.indented justif)]);
405               P.Mtr ([],[P.Mtd ([],make_concl "we proved" conclusion)])])
406     else if conclude.Con.conclude_method = "Apply" then
407       let pres_args = 
408         make_args_for_apply term2pres conclude.Con.conclude_args in 
409       let by = 
410          P.Mrow([],
411            P.Mtext([None,"mathcolor","Red"],"by")::P.Mspace([None,"width","0.1cm"])::
412            P.Mo([],"(")::pres_args@[P.Mo([],")")]) in 
413       match conclude.Con.conclude_conclusion with
414         None -> P.Mrow([],[P.Mtext([],"QUA");by])
415       | Some t ->
416          let concl = (term2pres t) in
417          let ann_concl = make_concl "we proved" concl in
418          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
419             None,"columnalign","left"],
420              [P.Mtr ([],[P.Mtd ([],by)]);
421               P.Mtr ([],[P.Mtd ([],ann_concl)])])
422     else let body =
423       P.Mtable 
424         ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"],
425          [P.Mtr ([],[P.Mtd ([],P.Mtext([],"Apply method" ^ conclude.Con.conclude_method ^ " to"))]);
426           P.Mtr ([],
427            [P.Mtd ([], 
428              (P.indented 
429                (P.Mtable 
430                  ([None,"align","baseline 1"; None,"equalrows","false";
431                    None,"columnalign","left"],
432                   args2pres conclude.Con.conclude_args))))])]) in
433      match conclude.Con.conclude_conclusion with
434        None -> body
435      | Some t ->
436          let concl = (term2pres t) in
437          let ann_concl = make_concl "we proved" concl in
438          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
439             None,"columnalign","left"],
440              [P.Mtr ([],[P.Mtd ([],body)]);
441               P.Mtr ([],[P.Mtd ([],ann_concl)])])
442
443   and args2pres l =
444     let module P = Mpresentation in
445     List.map 
446      (function a -> P.Mtr ([], [P.Mtd ([], arg2pres a)])) l
447
448   and arg2pres =
449     let module P = Mpresentation in
450     let module Con = Content in
451     function
452         Con.Aux n -> 
453           P.Mtext ([],"aux " ^ n)
454       | Con.Premise prem -> 
455           P.Mtext ([],"premise")
456       | Con.Term t -> 
457           term2pres t
458       | Con.ArgProof p ->
459         proof2pres p 
460       | Con.ArgMethod s -> 
461          P.Mtext ([],"method") 
462  
463    and byinduction conclude =
464      let module P = Mpresentation in
465      let module Con = Content in
466      let proof_conclusion = 
467        (match conclude.Con.conclude_conclusion with
468           None -> P.Mtext([],"No conclusion???")
469         | Some t -> term2pres t) in
470      let inductive_arg,args_for_cases = 
471        (match conclude.Con.conclude_args with
472            Con.Aux(n)::_::tl ->
473              let l1,l2 = split (int_of_string n) tl in
474              let last_pos = (List.length l2)-1 in
475              List.nth l2 last_pos,l1
476          | _ -> assert false) in
477      let induction_on =
478        let arg = 
479          (match inductive_arg with
480             Con.Aux n -> 
481               P.Mtext ([],"an aux???")
482            | Con.Premise prem ->
483               (match prem.Con.premise_binder with
484                  None -> P.Mtext ([],"the previous result")
485                | Some n -> P.Mi([],n))
486            | Con.Term t -> 
487                term2pres t
488            | Con.ArgProof p ->
489                P.Mtext ([],"a proof???")
490            | Con.ArgMethod s -> 
491                P.Mtext ([],"a method???")) in
492         (make_concl "we proceede by induction on" arg) in
493      let to_prove =
494         (make_concl "to prove" proof_conclusion) in
495      let we_proved = 
496         (make_concl "we proved" proof_conclusion) in
497      P.Mtable 
498        ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"],
499           P.Mtr ([],[P.Mtd ([],induction_on)])::
500           P.Mtr ([],[P.Mtd ([],to_prove)])::
501           (make_cases args_for_cases) @
502           [P.Mtr ([],[P.Mtd ([],we_proved)])]) 
503     
504     and make_cases args_for_cases =
505     let module P = Mpresentation in
506     List.map 
507       (fun p -> P.Mtr ([],[P.Mtd ([],make_case p)])) args_for_cases
508
509     and make_case =  
510       let module P = Mpresentation in
511       let module Con = Content in
512       function 
513         Con.ArgProof p ->
514           let name =
515             (match p.Con.proof_name with
516                None -> P.Mtext([],"no name for case!!")
517              | Some n -> P.Mi([],n)) in
518           let indhyps,args =
519              List.partition 
520                (function
521                    `Hypothesis h -> h.Con.dec_inductive
522                  | _ -> false) p.Con.proof_context in
523           let pattern_aux =
524              List.fold_right
525                (fun e p -> 
526                   let dec  = 
527                     (match e with 
528                        `Declaration h 
529                      | `Hypothesis h -> 
530                          let name = 
531                            (match h.Con.dec_name with
532                               None -> "NO NAME???"
533                            | Some n ->n) in
534                          [P.Mspace([None,"width","0.1cm"]);
535                           P.Mi ([],name);
536                           P.Mtext([],":");
537                           (term2pres h.Con.dec_type)]
538                      | _ -> [P.Mtext ([],"???")]) in
539                   dec@p) args [] in
540           let pattern = 
541             P.Mtr ([],[P.Mtd ([],P.Mrow([],
542                P.Mtext([],"Case")::P.Mspace([None,"width","0.1cm"])::name::pattern_aux@
543                 [P.Mspace([None,"width","0.1cm"]);
544                  P.Mtext([],"->")]))]) in
545           let subconcl = 
546             (match p.Con.proof_conclude.Con.conclude_conclusion with
547                None -> P.Mtext([],"No conclusion!!!") 
548              | Some t -> term2pres t) in
549           let asubconcl =
550              P.Mtr([],[P.Mtd([],
551               make_concl "the thesis becomes" subconcl)]) in
552           let induction_hypothesis = 
553             (match indhyps with
554               [] -> []
555             | _ -> 
556                let text =
557                  P.Mtr([],[P.Mtd([], P.indented 
558                  (P.Mtext([],"by induction hypothesis we know:")))]) in
559                let make_hyp =
560                  function 
561                    `Hypothesis h ->
562                      let name = 
563                        (match h.Con.dec_name with
564                           None -> "no name"
565                         | Some s -> s) in
566                      P.indented (P.Mrow ([],
567                        [P.Mtext([],"(");
568                         P.Mi ([],name);
569                         P.Mtext([],")");
570                         P.Mspace([None,"width","0.1cm"]);
571                         term2pres h.Con.dec_type]))
572                    | _ -> assert false in
573                let hyps = 
574                  List.map 
575                    (function ce -> P.Mtr ([], [P.Mtd ([], make_hyp ce)])) 
576                     indhyps in
577                text::hyps) in          
578           (* let acontext = 
579                acontext2pres_old p.Con.proof_apply_context true in *)
580           let body = conclude2pres p.Con.proof_conclude true in
581           let presacontext = 
582             acontext2pres p.Con.proof_apply_context body true in
583           P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
584              None,"columnalign","left"],
585              pattern::asubconcl::induction_hypothesis@
586               [P.Mtr([],[P.Mtd([],presacontext)])])
587       | _ -> assert false in
588
589 proof2pres p
590 ;;
591
592 exception ToDo;;
593
594 let content2pres term2pres (id,params,metasenv,obj) =
595  let module K = Content in
596  let module P = Mpresentation in
597   match obj with
598      `Def (K.Const,thesis,`Proof p) ->
599        P.Mtable
600         [None,"align","baseline 1";
601          None,"equalrows","false";
602          None,"columnalign","left";
603          None,"helm:xref","id"]
604         ([P.Mtr []
605            [P.Mtd []
606             (P.Mrow []
607              [P.Mtext []
608                ("UNFINISHED PROOF" ^ id ^"(" ^
609                  String.concat " ; " (List.map UriManager.string_of_uri params)^
610                 ")")])] ;
611          P.Mtr []
612           [P.Mtd []
613             (P.Mrow []
614               [P.Mtext [] "THESIS:"])] ;
615          P.Mtr []
616           [P.Mtd []
617             (P.Mrow []
618               [P.Mphantom []
619                 (P.Mtext [] "__") ;
620               term2pres thesis])]] @
621          (match metasenv with
622              None -> []
623            | Some metasenv' ->
624               [P.Mtr []
625                 [P.Mtd []
626                   (* Conjectures are in their own table to make *)
627                   (* diffing the DOM trees easier.              *)
628                   (P.Mtable
629                     [None,"align","baseline 1";
630                      None,"equalrows","false";
631                      None,"columnalign","left"]
632                    ((P.Mtr []
633                       [P.Mtd []
634                        (P.Mrow []
635                          [P.Mtext [] "CONJECTURES:"])])::
636                     List.map
637                      (function
638                        (id,n,context,ty) ->
639                          P.Mtr []
640                           [P.Mtd []
641                            (P.Mrow []
642                              (List.map
643                                (function
644                                    (_,None) ->
645                                      P.Mrow []
646                                       [ P.Mi [] "_" ;
647                                         P.Mo [] ":?" ;
648                                         P.Mi [] "_"]
649                                  | (_,Some (`Declaration d))
650                                  | (_,Some (`Hypothesis d)) ->
651                                     let
652                                      { K.dec_name = dec_name ;
653                                        K.dec_type = ty } = d
654                                      in
655                                       P.Mrow []
656                                        [ P.Mi []
657                                           (match dec_name with
658                                               None -> "_"
659                                             | Some n -> n) ;
660                                          P.Mo [] ":" ;
661                                          term2pres ty]
662                                  | (_,Some (`Definition d)) ->
663                                     let
664                                      { K.def_name = def_name ;
665                                        K.def_term = bo } = d
666                                      in
667                                       P.Mrow []
668                                        [ P.Mi []
669                                           (match def_name with
670                                               None -> "_"
671                                             | Some n -> n) ;
672                                          P.Mo [] ":=" ;
673                                          term2pres bo]
674                                  | (_,Some (`Proof p)) ->
675                                     let proof_name = p.K.proof_name in
676                                      P.Mrow []
677                                       [ P.Mi []
678                                          (match proof_name with
679                                              None -> "_"
680                                            | Some n -> n) ;
681                                         P.Mo [] ":=" ;
682                                         proof2pres term2pres p]
683                                ) context @
684                              [ P.Mo [] "|-" ] @
685                              [ P.Mi [] (string_of_int n) ;
686                                P.Mo [] ":" ;
687                                term2pres ty ]
688                            ))
689                           ]
690                      ) metasenv'
691                   ))]]
692          )  @
693         [P.Mtr []
694           [P.Mtd []
695             (P.Mrow []
696               [proof2pres term2pres p])]])
697    | _ -> raise ToDo
698 ;;
699
700 let content2pres ~ids_to_inner_sorts =
701  content2pres 
702   (function p -> 
703    (Cexpr2pres.cexpr2pres_charcount 
704     (Content_expressions.acic2cexpr ids_to_inner_sorts p)))
705 ;;