]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_transformations/content2pres.ml
- better handling of proof expansion/contraction
[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.Lemma lemma -> 
109              current_size + (String.length lemma.Con.lemma_name)
110          | Con.Term t -> countterm current_size t
111          | Con.ArgProof p -> countp current_size p
112          | Con.ArgMethod s -> (maxsize + 1)) in
113   let size = (countp 0 p) in
114   (size > maxsize)
115 ;;
116
117 let is_big = is_big_general (Cexpr2pres.countterm)
118 ;;
119
120 let get_xref =
121     let module Con = Content in
122       function
123         `Declaration d  
124       | `Hypothesis d -> d.Con.dec_id
125       | `Proof p -> p.Con.proof_id
126       | `Definition d -> d.Con.def_id
127       | `Joint jo -> jo.Con.joint_id
128 ;;
129
130 let make_row ?(attrs=[]) items concl =
131   let module P = Mpresentation in
132     (match concl with 
133        P.Mtable _ -> (* big! *)
134          P.Mtable (attrs@[None,"align","baseline 1"; None,"equalrows","false";
135           None,"columnalign","left"],
136            [P.Mtr([],[P.Mtd ([],P.Mrow([],items))]);
137             P.Mtr ([],[P.Mtd ([],P.indented concl)])])
138      | _ ->  (* small *)
139        P.Mrow(attrs,items@[P.Mspace([None,"width","0.1cm"]);concl]))
140 ;;
141
142 let make_concl ?(attrs=[]) verb concl =
143   let module P = Mpresentation in
144     (match concl with 
145        P.Mtable _ -> (* big! *)
146          P.Mtable (attrs@[None,"align","baseline 1"; None,"equalrows","false";
147           None,"columnalign","left"],
148            [P.Mtr([],[P.Mtd ([],P.Mtext([None,"mathcolor","Red"],verb))]);
149             P.Mtr ([],[P.Mtd ([],P.indented concl)])])
150      | _ ->  (* small *)
151        P.Mrow(attrs,
152         [P.Mtext([None,"mathcolor","Red"],verb); 
153          P.Mspace([None,"width","0.1cm"]);
154          concl]))
155 ;;
156
157 let make_args_for_apply term2pres args =
158  let module Con = Content in
159  let module P = Mpresentation in
160  let rec make_arg_for_apply is_first arg row = 
161    (match arg with 
162       Con.Aux n -> assert false
163     | Con.Premise prem -> 
164         let name = 
165           (match prem.Con.premise_binder with
166              None -> "previous"
167            | Some s -> s) in
168         P.smallskip::P.Mi([],name)::row
169     | Con.Lemma lemma -> 
170          P.smallskip::P.Mi([],lemma.Con.lemma_name)::row 
171     | Con.Term t -> 
172         if is_first then
173           (term2pres t)::row
174         else P.smallskip::P.Mi([],"_")::row
175     | Con.ArgProof _ 
176     | Con.ArgMethod _ -> 
177        P.smallskip::P.Mi([],"_")::row) in
178  match args with 
179    hd::tl -> 
180      make_arg_for_apply true hd 
181        (List.fold_right (make_arg_for_apply false) tl [])
182  | _ -> assert false;;
183
184 let rec justification term2pres p = 
185   let module Con = Content in
186   let module P = Mpresentation in
187   if ((p.Con.proof_conclude.Con.conclude_method = "Exact") or
188      ((p.Con.proof_context = []) &
189       (p.Con.proof_apply_context = []) &
190       (p.Con.proof_conclude.Con.conclude_method = "Apply"))) then
191     let pres_args = 
192       make_args_for_apply term2pres p.Con.proof_conclude.Con.conclude_args in
193     P.Mrow([],
194       P.Mtext([None,"mathcolor","Red"],"by")::P.Mspace([None,"width","0.1cm"])::
195       P.Mo([],"(")::pres_args@[P.Mo([],")")]) 
196   else proof2pres term2pres p 
197      
198 and proof2pres term2pres p =
199   let rec proof2pres p =
200     let module Con = Content in
201     let module P = Mpresentation in
202       let indent = 
203         let is_decl e = 
204           (match e with 
205              `Declaration _
206            | `Hypothesis _ -> true
207            | _ -> false) in
208         ((List.filter is_decl p.Con.proof_context) != []) in 
209       let concl = 
210         (match p.Con.proof_conclude.Con.conclude_conclusion with
211            None -> None
212          | Some t -> Some (term2pres t)) in
213       let body =
214           let presconclude = conclude2pres p.Con.proof_conclude indent in
215           let presacontext = 
216             acontext2pres p.Con.proof_apply_context presconclude indent in
217           context2pres p.Con.proof_context presacontext in
218       match p.Con.proof_name with
219         None -> body
220       | Some name ->
221           let ac = 
222         (match concl with
223                None -> P.Mtext([],"NO PROOF!!!")
224              | Some c -> c) in 
225           let action = 
226             P.Maction([None,"actiontype","toggle" ;
227                        None,"selection","1"],
228               [(make_concl "proof of" ac);
229                 body]) in
230           P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
231               None,"columnalign","left";Some "helm", "xref", p.Con.proof_id],
232             [P.Mtr ([],[P.Mtd ([],P.Mfenced([],[P.Mtext ([],name)]))]);
233              P.Mtr ([],[P.Mtd ([], P.indented action)])])
234
235   and context2pres c continuation =
236     (* we generate a subtable for each context element, for selection
237        purposes *)
238     let module P = Mpresentation in
239     List.fold_right
240       (fun ce continuation ->
241          let xref = get_xref ce in
242          P.Mtable([None,"align","baseline 1"; None,"equalrows","false";
243           None,"columnalign","left"; Some "helm", "xref", xref ],
244            [P.Mtr([Some "helm", "xref", "ce_"^xref],[P.Mtd ([],ce2pres ce)]);
245             P.Mtr([],[P.Mtd ([], continuation)])])) c continuation
246
247   and ce2pres =
248     let module P = Mpresentation in
249     let module Con = Content in
250       function
251         `Declaration d -> 
252           (match d.Con.dec_name with
253               Some s ->
254                 let ty = term2pres d.Con.dec_type in
255                 P.Mrow ([],
256                   [P.Mtext([None,"mathcolor","Red"],"Assume");
257                    P.Mspace([None,"width","0.1cm"]);
258                    P.Mi([],s);
259                    P.Mtext([],":");
260                    ty])
261             | None -> 
262                 prerr_endline "NO NAME!!"; assert false)
263       | `Hypothesis h ->
264           (match h.Con.dec_name with
265               Some s ->
266                 let ty = term2pres h.Con.dec_type in
267                 P.Mrow ([],
268                   [P.Mtext([None,"mathcolor","Red"],"Suppose");
269                    P.Mspace([None,"width","0.1cm"]);
270                    P.Mtext([],"(");
271                    P.Mi ([],s);
272                    P.Mtext([],")");
273                    P.Mspace([None,"width","0.1cm"]);
274                    ty])
275             | None -> 
276                 prerr_endline "NO NAME!!"; assert false) 
277       | `Proof p -> proof2pres p
278       | `Definition d -> 
279            (match d.Con.def_name with
280               Some s ->
281                 let term = term2pres d.Con.def_term in
282                 P.Mrow ([],
283                   [P.Mtext([],"Let ");
284                    P.Mi([],s);
285                    P.Mtext([]," = ");
286                    term])
287             | None -> 
288                 prerr_endline "NO NAME!!"; assert false) 
289       | `Joint ho -> 
290             P.Mtext ([],"jointdef")
291
292   and acontext2pres ac continuation indent =
293     let module Con = Content in
294     let module P = Mpresentation in
295     List.fold_right
296       (fun p continuation ->
297          let hd = 
298            if indent then
299              P.indented (proof2pres p)
300            else 
301              proof2pres p in
302          P.Mtable([None,"align","baseline 1"; None,"equalrows","false";
303           None,"columnalign","left"; Some "helm","xref",p.Con.proof_id],
304            [P.Mtr([Some "helm","xref","ace_"^p.Con.proof_id],[P.Mtd ([],hd)]);
305             P.Mtr([],[P.Mtd ([], continuation)])])) ac continuation 
306
307   and conclude2pres conclude indent =
308     let module P = Mpresentation in
309     if indent then
310       P.indented (conclude_aux conclude)
311     else 
312       conclude_aux conclude
313
314   and conclude_aux conclude =
315     let module Con = Content in
316     let module P = Mpresentation in
317     if conclude.Con.conclude_method = "TD_Conversion" then
318       let expected = 
319         (match conclude.Con.conclude_conclusion with 
320            None -> P.Mtext([],"NO EXPECTED!!!")
321          | Some c -> term2pres c) in
322       let subproof = 
323         (match conclude.Con.conclude_args with
324           [Con.ArgProof p] -> p
325          | _ -> assert false) in
326       let synth = 
327         (match subproof.Con.proof_conclude.Con.conclude_conclusion with
328            None -> P.Mtext([],"NO SYNTH!!!")
329          | Some c -> (term2pres c)) in
330       P.Mtable 
331         ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"; Some "helm", "xref", conclude.Con.conclude_id],
332         [P.Mtr([],[P.Mtd([],make_concl "we must prove" expected)]);
333          P.Mtr([],[P.Mtd([],make_concl "or equivalently" synth)]);
334          P.Mtr([],[P.Mtd([],proof2pres subproof)])])
335     else if conclude.Con.conclude_method = "BU_Conversion" then
336       let conclusion = 
337       (match conclude.Con.conclude_conclusion with 
338          None -> P.Mtext([],"NO Conclusion!!!")
339        | Some c -> term2pres c) in
340       make_concl 
341         ~attrs:[Some "helm", "xref", conclude.Con.conclude_id]
342           "that is equivalent to" conclusion
343     else if conclude.Con.conclude_method = "Exact" then
344       let conclusion = 
345         (match conclude.Con.conclude_conclusion with 
346            None -> P.Mtext([],"NO Conclusion!!!")
347          | Some c -> term2pres c) in
348       let arg = 
349         (match conclude.Con.conclude_args with 
350            [Con.Term t] -> term2pres t
351          | _ -> assert false) in
352       make_row ~attrs:[Some "helm", "xref", conclude.Con.conclude_id]
353         [arg;P.Mspace([None,"width","0.1cm"]);P.Mtext([],"proves")] conclusion
354     else if conclude.Con.conclude_method = "Intros+LetTac" then
355       let conclusion = 
356       (match conclude.Con.conclude_conclusion with 
357          None -> P.Mtext([],"NO Conclusion!!!")
358        | Some c -> term2pres c) in
359       (match conclude.Con.conclude_args with
360          [Con.ArgProof p] -> 
361            P.Mtable 
362             ([None,"align","baseline 1"; None,"equalrows","false";
363               None,"columnalign","left"; 
364               Some "helm", "xref", conclude.Con.conclude_id],
365               [P.Mtr([],[P.Mtd([],proof2pres p)]);
366                P.Mtr([],[P.Mtd([],
367                 (make_concl "we proved *" conclusion))])]);
368        | _ -> assert false)
369     else if (conclude.Con.conclude_method = "ByInduction") then
370       byinduction conclude
371     else if (conclude.Con.conclude_method = "Rewrite") then
372       let justif = 
373         (match (List.nth conclude.Con.conclude_args 6) with
374            Con.ArgProof p -> justification term2pres p
375          | _ -> assert false) in
376       let term1 = 
377         (match List.nth conclude.Con.conclude_args 2 with
378            Con.Term t -> term2pres t
379          | _ -> assert false) in 
380       let term2 = 
381         (match List.nth conclude.Con.conclude_args 5 with
382            Con.Term t -> term2pres t
383          | _ -> assert false) in  
384       let conclusion = 
385         (match conclude.Con.conclude_conclusion with 
386            None -> P.Mtext([],"NO Conclusion!!!")
387          | Some c -> term2pres c) in
388       P.Mtable ([None,"align","baseline 1";None,"equalrows","false";
389             None,"columnalign","left"; 
390             Some "helm", "xref", conclude.Con.conclude_id],
391              [P.Mtr ([],[P.Mtd ([],P.Mrow([],[
392                P.Mtext([None,"mathcolor","Red"],"rewrite");
393                P.Mspace([None,"width","0.1cm"]);term1;
394                P.Mspace([None,"width","0.1cm"]);
395                P.Mtext([None,"mathcolor","Red"],"with");
396                P.Mspace([None,"width","0.1cm"]);term2]))]);
397               P.Mtr ([],[P.Mtd ([],P.indented justif)]);
398               P.Mtr ([],[P.Mtd ([],make_concl "we proved" conclusion)])])
399     else if conclude.Con.conclude_method = "Apply" then
400       let pres_args = 
401         make_args_for_apply term2pres conclude.Con.conclude_args in 
402       let by = 
403          P.Mrow([],
404            P.Mtext([None,"mathcolor","Red"],"by")::P.Mspace([None,"width","0.1cm"])::
405            P.Mo([],"(")::pres_args@[P.Mo([],")")]) in 
406       match conclude.Con.conclude_conclusion with
407         None -> P.Mrow([],[P.Mtext([],"QUA");by])
408       | Some t ->
409          let concl = (term2pres t) in
410          let ann_concl = make_concl "we proved" concl in
411          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
412             None,"columnalign","left"; 
413             Some "helm", "xref", conclude.Con.conclude_id],
414              [P.Mtr ([],[P.Mtd ([],by)]);
415               P.Mtr ([],[P.Mtd ([],ann_concl)])])
416     else let body =
417       P.Mtable 
418         ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"; Some "helm", "xref", conclude.Con.conclude_id],
419          [P.Mtr ([],[P.Mtd ([],P.Mtext([],"Apply method" ^ conclude.Con.conclude_method ^ " to"))]);
420           P.Mtr ([],
421            [P.Mtd ([], 
422              (P.indented 
423                (P.Mtable 
424                  ([None,"align","baseline 1"; None,"equalrows","false";
425                    None,"columnalign","left"],
426                   args2pres conclude.Con.conclude_args))))])]) in
427      match conclude.Con.conclude_conclusion with
428        None -> body
429      | Some t ->
430          let concl = (term2pres t) in
431          let ann_concl = make_concl "we proved" concl in
432          P.Mtable ([None,"align","baseline 1"; None,"equalrows","false";
433             None,"columnalign","left"],
434              [P.Mtr ([],[P.Mtd ([],body)]);
435               P.Mtr ([],[P.Mtd ([],ann_concl)])])
436
437   and args2pres l =
438     let module P = Mpresentation in
439     List.map 
440      (function a -> P.Mtr ([], [P.Mtd ([], arg2pres a)])) l
441
442   and arg2pres =
443     let module P = Mpresentation in
444     let module Con = Content in
445     function
446         Con.Aux n -> 
447           P.Mtext ([],"aux " ^ n)
448       | Con.Premise prem -> 
449           P.Mtext ([],"premise")
450       | Con.Lemma lemma ->
451           P.Mtext ([],"lemma")
452       | Con.Term t -> 
453           term2pres t
454       | Con.ArgProof p ->
455         proof2pres p 
456       | Con.ArgMethod s -> 
457          P.Mtext ([],"method") 
458  
459    and byinduction conclude =
460      let module P = Mpresentation in
461      let module Con = Content in
462      let proof_conclusion = 
463        (match conclude.Con.conclude_conclusion with
464           None -> P.Mtext([],"No conclusion???")
465         | Some t -> term2pres t) in
466      let inductive_arg,args_for_cases = 
467        (match conclude.Con.conclude_args with
468            Con.Aux(n)::_::tl ->
469              let l1,l2 = split (int_of_string n) tl in
470              let last_pos = (List.length l2)-1 in
471              List.nth l2 last_pos,l1
472          | _ -> assert false) in
473      let induction_on =
474        let arg = 
475          (match inductive_arg with
476             Con.Aux n -> 
477               P.Mtext ([],"an aux???")
478            | Con.Premise prem ->
479               (match prem.Con.premise_binder with
480                  None -> P.Mtext ([],"the previous result")
481                | Some n -> P.Mi([],n))
482            | Con.Lemma lemma -> P.Mi([],lemma.Con.lemma_name)
483            | Con.Term t -> 
484                term2pres t
485            | Con.ArgProof p ->
486                P.Mtext ([],"a proof???")
487            | Con.ArgMethod s -> 
488                P.Mtext ([],"a method???")) in
489         (make_concl "we proceede by induction on" arg) in
490      let to_prove =
491         (make_concl "to prove" proof_conclusion) in
492      let we_proved = 
493         (make_concl "we proved" proof_conclusion) in
494      P.Mtable 
495        ([None,"align","baseline 1"; None,"equalrows","false"; None,"columnalign","left"],
496           P.Mtr ([],[P.Mtd ([],induction_on)])::
497           P.Mtr ([],[P.Mtd ([],to_prove)])::
498           (make_cases args_for_cases) @
499           [P.Mtr ([],[P.Mtd ([],we_proved)])]) 
500     
501     and make_cases args_for_cases =
502     let module P = Mpresentation in
503     List.map 
504       (fun p -> P.Mtr ([],[P.Mtd ([],make_case p)])) args_for_cases
505
506     and make_case =  
507       let module P = Mpresentation in
508       let module Con = Content in
509       function 
510         Con.ArgProof p ->
511           let name =
512             (match p.Con.proof_name with
513                None -> P.Mtext([],"no name for case!!")
514              | Some n -> P.Mi([],n)) in
515           let indhyps,args =
516              List.partition 
517                (function
518                    `Hypothesis h -> h.Con.dec_inductive
519                  | _ -> false) p.Con.proof_context in
520           let pattern_aux =
521              List.fold_right
522                (fun e p -> 
523                   let dec  = 
524                     (match e with 
525                        `Declaration h 
526                      | `Hypothesis h -> 
527                          let name = 
528                            (match h.Con.dec_name with
529                               None -> "NO NAME???"
530                            | Some n ->n) in
531                          [P.Mspace([None,"width","0.1cm"]);
532                           P.Mi ([],name);
533                           P.Mtext([],":");
534                           (term2pres h.Con.dec_type)]
535                      | _ -> [P.Mtext ([],"???")]) in
536                   dec@p) args [] in
537           let pattern = 
538             P.Mtr ([],[P.Mtd ([],P.Mrow([],
539                P.Mtext([],"Case")::P.Mspace([None,"width","0.1cm"])::name::pattern_aux@
540                 [P.Mspace([None,"width","0.1cm"]);
541                  P.Mtext([],"->")]))]) in
542           let subconcl = 
543             (match p.Con.proof_conclude.Con.conclude_conclusion with
544                None -> P.Mtext([],"No conclusion!!!") 
545              | Some t -> term2pres t) in
546           let asubconcl =
547              P.Mtr([],[P.Mtd([],
548               P.indented (make_concl "the thesis becomes" subconcl))]) in
549           let induction_hypothesis = 
550             (match indhyps with
551               [] -> []
552             | _ -> 
553                let text =
554                  P.Mtr([],[P.Mtd([], P.indented 
555                  (P.Mtext([],"by induction hypothesis we know:")))]) in
556                let make_hyp =
557                  function 
558                    `Hypothesis h ->
559                      let name = 
560                        (match h.Con.dec_name with
561                           None -> "no name"
562                         | Some s -> s) in
563                      P.indented (P.Mrow ([],
564                        [P.Mtext([],"(");
565                         P.Mi ([],name);
566                         P.Mtext([],")");
567                         P.Mspace([None,"width","0.1cm"]);
568                         term2pres h.Con.dec_type]))
569                    | _ -> assert false in
570                let hyps = 
571                  List.map 
572                    (function ce -> P.Mtr ([], [P.Mtd ([], make_hyp ce)])) 
573                     indhyps in
574                text::hyps) in          
575           (* let acontext = 
576                acontext2pres_old p.Con.proof_apply_context true in *)
577           let body = conclude2pres p.Con.proof_conclude true in
578           let presacontext = 
579             P.Maction([None,"actiontype","toggle" ; None,"selection","1"],
580               [P.indented (P.Mtext([None,"mathcolor","Red"],"Proof"));
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                   (* Conjectures are in their own table to make *)
626                   (* diffing the DOM trees easier.              *)
627                   (P.Mtable
628                     [None,"align","baseline 1";
629                      None,"equalrows","false";
630                      None,"columnalign","left"]
631                    ((P.Mtr []
632                       [P.Mtd []
633                        (P.Mrow []
634                          [P.Mtext [] "CONJECTURES:"])])::
635                     List.map
636                      (function
637                        (id,n,context,ty) ->
638                          P.Mtr []
639                           [P.Mtd []
640                            (P.Mrow []
641                              (List.map
642                                (function
643                                    (_,None) ->
644                                      P.Mrow []
645                                       [ P.Mi [] "_" ;
646                                         P.Mo [] ":?" ;
647                                         P.Mi [] "_"]
648                                  | (_,Some (`Declaration d))
649                                  | (_,Some (`Hypothesis d)) ->
650                                     let
651                                      { K.dec_name = dec_name ;
652                                        K.dec_type = ty } = d
653                                      in
654                                       P.Mrow []
655                                        [ P.Mi []
656                                           (match dec_name with
657                                               None -> "_"
658                                             | Some n -> n) ;
659                                          P.Mo [] ":" ;
660                                          term2pres ty]
661                                  | (_,Some (`Definition d)) ->
662                                     let
663                                      { K.def_name = def_name ;
664                                        K.def_term = bo } = d
665                                      in
666                                       P.Mrow []
667                                        [ P.Mi []
668                                           (match def_name with
669                                               None -> "_"
670                                             | Some n -> n) ;
671                                          P.Mo [] ":=" ;
672                                          term2pres bo]
673                                  | (_,Some (`Proof p)) ->
674                                     let proof_name = p.K.proof_name in
675                                      P.Mrow []
676                                       [ P.Mi []
677                                          (match proof_name with
678                                              None -> "_"
679                                            | Some n -> n) ;
680                                         P.Mo [] ":=" ;
681                                         proof2pres term2pres p]
682                                ) context @
683                              [ P.Mo [] "|-" ] @
684                              [ P.Mi [] (string_of_int n) ;
685                                P.Mo [] ":" ;
686                                term2pres ty ]
687                            ))
688                           ]
689                      ) metasenv'
690                   ))]]
691          )  @
692         [P.Mtr []
693           [P.Mtd []
694             (P.Mrow []
695               [proof2pres term2pres p])]])
696    | _ -> raise ToDo
697 ;;
698
699 let content2pres ~ids_to_inner_sorts =
700  content2pres 
701   (function p -> 
702    (Cexpr2pres.cexpr2pres_charcount 
703     (Content_expressions.acic2cexpr ids_to_inner_sorts p)))
704 ;;