1 (* Copyright (C) 2000, 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 (**************************************************************************)
35 (* e se mettessi la conversione di BY nell'apply_context ? *)
36 (* sarebbe carino avere l'invariante che la proof2pres
37 generasse sempre prove con contesto vuoto *)
40 let res = "p" ^ string_of_int !seed in
45 let name_of = function
47 | Cic.Name b -> Some b;;
49 exception Not_a_proof;;
50 exception NotImplemented;;
51 exception NotApplicable;;
53 (* we do not care for positivity, here, that in any case is enforced by
54 well typing. Just a brutal search *)
63 | C.Implicit -> raise NotImplemented
64 | C.Prod (_,s,t) -> (occur uri s) or (occur uri t)
65 | C.Cast (te,ty) -> (occur uri te)
66 | C.Lambda (_,s,t) -> (occur uri s) or (occur uri t) (* or false ?? *)
67 | C.LetIn (_,s,t) -> (occur uri s) or (occur uri t)
72 else (occur uri a)) false l
73 | C.Const (_,_) -> false
74 | C.MutInd (uri1,_,_) -> if uri = uri1 then true else false
75 | C.MutConstruct (_,_,_,_) -> false
76 | C.MutCase _ -> false (* presuming too much?? *)
77 | C.Fix _ -> false (* presuming too much?? *)
78 | C.CoFix (_,_) -> false (* presuming too much?? *)
84 C.ARel (id,_,_,_) -> id
85 | C.AVar (id,_,_) -> id
86 | C.AMeta (id,_,_) -> id
87 | C.ASort (id,_) -> id
88 | C.AImplicit _ -> raise NotImplemented
89 | C.AProd (id,_,_,_) -> id
90 | C.ACast (id,_,_) -> id
91 | C.ALambda (id,_,_,_) -> id
92 | C.ALetIn (id,_,_,_) -> id
93 | C.AAppl (id,_) -> id
94 | C.AConst (id,_,_) -> id
95 | C.AMutInd (id,_,_,_) -> id
96 | C.AMutConstruct (id,_,_,_,_) -> id
97 | C.AMutCase (id,_,_,_,_,_) -> id
98 | C.AFix (id,_,_) -> id
99 | C.ACoFix (id,_,_) -> id
102 let test_for_lifting ~ids_to_inner_types =
103 let module C = Cic in
104 let module C2A = Cic2acic in
105 (* atomic terms are never lifted, according to my policy *)
107 C.ARel (id,_,_,_) -> false
108 | C.AVar (id,_,_) -> false
109 | C.AMeta (id,_,_) -> false
110 | C.ASort (id,_) -> false
111 | C.AImplicit _ -> raise NotImplemented
112 | C.AProd (id,_,_,_) -> false
113 | C.ACast (id,_,_) ->
115 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
117 with notfound -> false)
118 | C.ALambda (id,_,_,_) ->
120 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
122 with notfound -> false)
123 | C.ALetIn (id,_,_,_) ->
125 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
127 with notfound -> false)
130 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
132 with notfound -> false)
133 | C.AConst (id,_,_) ->
135 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
137 with notfound -> false)
138 | C.AMutInd (id,_,_,_) -> false
139 | C.AMutConstruct (id,_,_,_,_) ->
141 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
143 with notfound -> false)
145 | C.AMutCase (id,_,_,_,_,_) ->
147 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
149 with notfound -> false)
152 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
154 with notfound -> false)
155 | C.ACoFix (id,_,_) ->
157 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
159 with notfound -> false)
162 let build_args seed l subproofs ~ids_to_inner_types ~ids_to_inner_sorts =
163 let module C = Cic in
164 let module K = Content in
165 let rec aux l subrpoofs =
169 if (test_for_lifting t ~ids_to_inner_types) then
170 (match subproofs with
175 { K.premise_id = gen_id seed;
176 K.premise_xref = p.K.proof_id;
177 K.premise_binder = p.K.proof_name;
180 in new_arg::(aux l1 tl))
184 C.ARel (idr,idref,n,b) ->
186 (try Hashtbl.find ids_to_inner_sorts idr
187 with notfound -> "Type") in
190 { K.premise_id = gen_id seed;
191 K.premise_xref = idr;
192 K.premise_binder = Some b;
196 | _ -> (K.Term t)) in
197 hd::(aux l1 subproofs)
201 (* transform a proof p into a proof list, concatenating the last
202 conclude element to the apply_context list, in case context is
203 empty. Otherwise, it just returns [p] *)
206 let module K = Content in
207 if (p.K.proof_context = []) then
208 if p.K.proof_apply_context = [] then [p]
212 K.proof_id = gen_id seed;
213 K.proof_context = [];
214 K.proof_apply_context = []
216 p.K.proof_apply_context@[p1]
221 let rec serialize seed =
224 | p::tl -> (flat seed p)@(serialize seed tl);;
226 (* top_down = true if the term is a LAMBDA or a decl *)
227 let generate_conversion seed top_down id inner_proof ~ids_to_inner_types =
228 let module C2A = Cic2acic in
229 let module K = Content in
230 let exp = (try ((Hashtbl.find ids_to_inner_types id).C2A.annexpected)
231 with Not_found -> None)
236 if inner_proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
237 { K.proof_name = None ;
238 K.proof_id = gen_id seed;
239 K.proof_context = [] ;
240 K.proof_apply_context = [];
242 { K.conclude_id = gen_id seed;
243 K.conclude_aref = id;
244 K.conclude_method = "TD_Conversion";
245 K.conclude_args = [K.ArgProof inner_proof];
246 K.conclude_conclusion = Some expty
250 { K.proof_name = None ;
251 K.proof_id = gen_id seed;
252 K.proof_context = [] ;
253 K.proof_apply_context = [inner_proof];
255 { K.conclude_id = gen_id seed;
256 K.conclude_aref = id;
257 K.conclude_method = "BU_Conversion";
260 { K.premise_id = gen_id seed;
261 K.premise_xref = inner_proof.K.proof_id;
262 K.premise_binder = None;
266 K.conclude_conclusion = Some expty
271 let generate_exact seed t id name ~ids_to_inner_types =
272 let module C2A = Cic2acic in
273 let module K = Content in
274 { K.proof_name = name;
276 K.proof_context = [] ;
277 K.proof_apply_context = [];
279 { K.conclude_id = gen_id seed;
280 K.conclude_aref = id;
281 K.conclude_method = "Exact";
282 K.conclude_args = [K.Term t];
283 K.conclude_conclusion =
284 try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
285 with notfound -> None
290 let generate_intros_let_tac seed id n s is_intro inner_proof name ~ids_to_inner_types =
291 let module C2A = Cic2acic in
292 let module C = Cic in
293 let module K = Content in
294 { K.proof_name = name;
296 K.proof_context = [] ;
297 K.proof_apply_context = [];
299 { K.conclude_id = gen_id seed;
300 K.conclude_aref = id;
301 K.conclude_method = "Intros+LetTac";
302 K.conclude_args = [K.ArgProof inner_proof];
303 K.conclude_conclusion =
305 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
307 (match inner_proof.K.proof_conclude.K.conclude_conclusion with
310 if is_intro then Some (C.AProd ("gen"^id,n,s,t))
311 else Some (C.ALetIn ("gen"^id,n,s,t)))
316 let build_decl_item seed id n s ~ids_to_inner_sorts =
317 let module K = Content in
318 let sort = Hashtbl.find ids_to_inner_sorts (Cic2acic.source_id_of_id id) in
319 if sort = "Prop" then
321 { K.dec_name = name_of n;
322 K.dec_id = gen_id seed;
323 K.dec_inductive = false;
329 { K.dec_name = name_of n;
330 K.dec_id = gen_id seed;
331 K.dec_inductive = false;
337 let rec build_def_item seed id n t ~ids_to_inner_sorts ~ids_to_inner_types =
338 let module K = Content in
339 let sort = Hashtbl.find ids_to_inner_sorts id in
340 if sort = "Prop" then
341 `Proof (acic2content seed ~name:(name_of n) ~ids_to_inner_sorts ~ids_to_inner_types t)
344 { K.def_name = name_of n;
345 K.def_id = gen_id seed;
350 (* the following function must be called with an object of sort
351 Prop. For debugging purposes this is tested again, possibly raising an
352 Not_a_proof exception *)
354 and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t =
355 let rec aux ?(name = None) t =
356 let module C = Cic in
357 let module K = Content in
358 let module C2A = Cic2acic in
361 C.ARel (id,idref,n,b) as t ->
362 let sort = Hashtbl.find ids_to_inner_sorts id in
363 if sort = "Prop" then
364 generate_exact seed t id name ~ids_to_inner_types
365 else raise Not_a_proof
366 | C.AVar (id,uri,exp_named_subst) as t ->
367 let sort = Hashtbl.find ids_to_inner_sorts id in
368 if sort = "Prop" then
369 generate_exact seed t id name ~ids_to_inner_types
370 else raise Not_a_proof
371 | C.AMeta (id,n,l) as t ->
372 let sort = Hashtbl.find ids_to_inner_sorts id in
373 if sort = "Prop" then
374 generate_exact seed t id name ~ids_to_inner_types
375 else raise Not_a_proof
376 | C.ASort (id,s) -> raise Not_a_proof
377 | C.AImplicit _ -> raise NotImplemented
378 | C.AProd (_,_,_,_) -> raise Not_a_proof
379 | C.ACast (id,v,t) -> aux v
380 | C.ALambda (id,n,s,t) ->
381 let sort = Hashtbl.find ids_to_inner_sorts id in
382 if sort = "Prop" then
383 let proof = aux t ~name:None in
385 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
386 match proof.K.proof_conclude.K.conclude_args with
394 (build_decl_item seed id n s ids_to_inner_sorts)::
395 proof'.K.proof_context
398 generate_intros_let_tac seed id n s true proof'' name ~ids_to_inner_types
399 else raise Not_a_proof
400 | C.ALetIn (id,n,s,t) ->
401 let sort = Hashtbl.find ids_to_inner_sorts id in
402 if sort = "Prop" then
405 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
406 match proof.K.proof_conclude.K.conclude_args with
414 ((build_def_item seed id n s ids_to_inner_sorts
415 ids_to_inner_types):> Cic.annterm K.in_proof_context_element)
416 ::proof'.K.proof_context;
419 generate_intros_let_tac seed id n s false proof'' name ~ids_to_inner_types
420 else raise Not_a_proof
423 seed name id li ids_to_inner_types ids_to_inner_sorts
424 with NotApplicable ->
426 seed name id li ids_to_inner_types ids_to_inner_sorts
427 with NotApplicable ->
429 List.filter (test_for_lifting ~ids_to_inner_types) li in
431 match args_to_lift with
432 [_] -> List.map aux args_to_lift
433 | _ -> List.map (aux ~name:(Some "H")) args_to_lift in
434 let args = build_args seed li subproofs
435 ~ids_to_inner_types ~ids_to_inner_sorts in
436 { K.proof_name = name;
437 K.proof_id = gen_id seed;
438 K.proof_context = [];
439 K.proof_apply_context = serialize seed subproofs;
441 { K.conclude_id = gen_id seed;
442 K.conclude_aref = id;
443 K.conclude_method = "Apply";
444 K.conclude_args = args;
445 K.conclude_conclusion =
447 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
448 with notfound -> None
451 | C.AConst (id,uri,exp_named_subst) as t ->
452 let sort = Hashtbl.find ids_to_inner_sorts id in
453 if sort = "Prop" then
454 generate_exact seed t id name ~ids_to_inner_types
455 else raise Not_a_proof
456 | C.AMutInd (id,uri,i,exp_named_subst) -> raise Not_a_proof
457 | C.AMutConstruct (id,uri,i,j,exp_named_subst) as t ->
458 let sort = Hashtbl.find ids_to_inner_sorts id in
459 if sort = "Prop" then
460 generate_exact seed t id name ~ids_to_inner_types
461 else raise Not_a_proof
462 | C.AMutCase (id,uri,typeno,ty,te,patterns) ->
463 let teid = get_id te in
464 let pp = List.map (function p -> (K.ArgProof (aux p))) patterns in
466 (try Some (Hashtbl.find ids_to_inner_types teid).C2A.annsynthesized
467 with notfound -> None)
469 Some tety -> (* we must lift up the argument *)
471 { K.proof_name = Some "name";
472 K.proof_id = gen_id seed;
473 K.proof_context = [];
474 K.proof_apply_context = flat seed p;
476 { K.conclude_id = gen_id seed;
477 K.conclude_aref = id;
478 K.conclude_method = "Case";
479 K.conclude_args = (K.Term ty)::(K.Term te)::pp;
480 K.conclude_conclusion =
482 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
483 with notfound -> None
487 { K.proof_name = name;
488 K.proof_id = gen_id seed;
489 K.proof_context = [];
490 K.proof_apply_context = [];
492 { K.conclude_id = gen_id seed;
493 K.conclude_aref = id;
494 K.conclude_method = "Case";
495 K.conclude_args = (K.Term ty)::(K.Term te)::pp;
496 K.conclude_conclusion =
498 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
499 with notfound -> None
503 | C.AFix (id, no, [(id1,n,_,ty,bo)]) ->
504 let proof = (aux bo) in (* must be recursive !! *)
505 { K.proof_name = name;
506 K.proof_id = gen_id seed;
507 K.proof_context = [`Proof proof];
508 K.proof_apply_context = [];
510 { K.conclude_id = gen_id seed;
511 K.conclude_aref = id;
512 K.conclude_method = "Exact";
515 { K.premise_id = gen_id seed;
516 K.premise_xref = proof.K.proof_id;
517 K.premise_binder = proof.K.proof_name;
518 K.premise_n = Some 1;
521 K.conclude_conclusion =
523 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
524 with notfound -> None
527 | C.AFix (id, no, funs) ->
529 List.map (function (id1,n,_,ty,bo) -> (`Proof (aux bo))) funs in
531 { K.joint_id = gen_id seed;
532 K.joint_kind = `Recursive;
533 K.joint_defs = proofs
536 { K.proof_name = name;
537 K.proof_id = gen_id seed;
538 K.proof_context = [`Joint jo];
539 K.proof_apply_context = [];
541 { K.conclude_id = gen_id seed;
542 K.conclude_aref = id;
543 K.conclude_method = "Exact";
546 { K.premise_id = gen_id seed;
547 K.premise_xref = jo.K.joint_id;
548 K.premise_binder = Some "tiralo fuori";
549 K.premise_n = Some no;
552 K.conclude_conclusion =
554 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
555 with notfound -> None
558 | C.ACoFix (id,no,[(id1,n,ty,bo)]) ->
559 let proof = (aux bo) in (* must be recursive !! *)
560 { K.proof_name = name;
561 K.proof_id = gen_id seed;
562 K.proof_context = [`Proof proof];
563 K.proof_apply_context = [];
565 { K.conclude_id = gen_id seed;
566 K.conclude_aref = id;
567 K.conclude_method = "Exact";
570 { K.premise_id = gen_id seed;
571 K.premise_xref = proof.K.proof_id;
572 K.premise_binder = proof.K.proof_name;
573 K.premise_n = Some 1;
576 K.conclude_conclusion =
578 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
579 with notfound -> None
582 | C.ACoFix (id,no,funs) ->
584 List.map (function (id1,n,ty,bo) -> (`Proof (aux bo))) funs in
586 { K.joint_id = gen_id seed;
587 K.joint_kind = `Recursive;
588 K.joint_defs = proofs
591 { K.proof_name = name;
592 K.proof_id = gen_id seed;
593 K.proof_context = [`Joint jo];
594 K.proof_apply_context = [];
596 { K.conclude_id = gen_id seed;
597 K.conclude_aref = id;
598 K.conclude_method = "Exact";
601 { K.premise_id = gen_id seed;
602 K.premise_xref = jo.K.joint_id;
603 K.premise_binder = Some "tiralo fuori";
604 K.premise_n = Some no;
607 K.conclude_conclusion =
609 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
610 with notfound -> None
615 generate_conversion seed false id t1 ~ids_to_inner_types
618 and inductive seed name id li ids_to_inner_types ids_to_inner_sorts =
619 let aux ?(name = None) = acic2content seed ~name:None ~ids_to_inner_types ~ids_to_inner_sorts in
620 let module C2A = Cic2acic in
621 let module K = Content in
622 let module C = Cic in
624 C.AConst (idc,uri,exp_named_subst)::args ->
625 let uri_str = UriManager.string_of_uri uri in
626 let suffix = Str.regexp_string "_ind.con" in
627 let len = String.length uri_str in
628 let n = (try (Str.search_backward suffix uri_str len)
629 with Not_found -> -1) in
630 if n<0 then raise NotApplicable
632 let prefix = String.sub uri_str 0 n in
633 let ind_str = (prefix ^ ".ind") in
634 let ind_uri = UriManager.uri_of_string ind_str in
635 let inductive_types,noparams =
636 (match CicEnvironment.get_obj ind_uri with
637 Cic.Constant _ -> assert false
638 | Cic.Variable _ -> assert false
639 | Cic.CurrentProof _ -> assert false
640 | Cic.InductiveDefinition (l,_,n) -> (l,n)
643 if n = 0 then ([],l) else
644 let p,a = split (n-1) (List.tl l) in
645 ((List.hd l::p),a) in
646 let params_and_IP,tail_args = split (noparams+1) args in
648 (match inductive_types with
650 | _ -> raise NotApplicable) (* don't care for mutual ind *) in
652 let rec clean_up n t =
655 (label,Cic.Prod (_,_,t)) -> clean_up (n-1) (label,t)
656 | _ -> assert false) in
657 List.map (clean_up noparams) constructors in
658 let no_constructors= List.length constructors in
659 let args_for_cases, other_args =
660 split no_constructors tail_args in
662 List.filter (test_for_lifting ~ids_to_inner_types) other_args in
664 match args_to_lift with
665 [_] -> List.map aux args_to_lift
666 | _ -> List.map (aux ~name:(Some "H")) args_to_lift in
667 prerr_endline "****** end subproofs *******"; flush stderr;
668 let other_method_args =
669 build_args seed other_args subproofs
670 ~ids_to_inner_types ~ids_to_inner_sorts in
672 let rparams,inductive_arg =
677 | a::tl -> let (p,ia) = aux tl in (a::p,ia) in
678 aux other_method_args in
680 prerr_endline "****** end other *******"; flush stderr;
682 let rec build_method_args =
684 [],_-> [] (* extra args are ignored ???? *)
685 | (name,ty)::tlc,arg::tla ->
686 let idarg = get_id arg in
688 (try (Hashtbl.find ids_to_inner_sorts idarg)
689 with Not_found -> "Type") in
691 if sortarg = "Prop" then
695 Cic.Prod (_,s,t),Cic.ALambda(idl,n,s1,t1) ->
698 seed idl n s1 ~ids_to_inner_sorts in
699 if (occur ind_uri s) then
700 ( prerr_endline ("inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
702 Cic.ALambda(id2,n2,s2,t2) ->
705 { K.dec_name = name_of n2;
706 K.dec_id = gen_id seed;
707 K.dec_inductive = true;
711 let (context,body) = bc (t,t2) in
712 (ce::inductive_hyp::context,body)
715 ( prerr_endline ("no inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
716 let (context,body) = bc (t,t1) in
718 | _ , t -> ([],aux t ~name:None) in
722 K.proof_name = Some name;
723 K.proof_context = co;
726 hdarg::(build_method_args (tlc,tla))
727 | _ -> assert false in
728 build_method_args (constructors1,args_for_cases) in
729 { K.proof_name = None;
730 K.proof_id = gen_id seed;
731 K.proof_context = [];
732 K.proof_apply_context = subproofs;
734 { K.conclude_id = gen_id seed;
735 K.conclude_aref = id;
736 K.conclude_method = "ByInduction";
738 K.Aux no_constructors
739 ::K.Term (C.AAppl id ((C.AConst(idc,uri,exp_named_subst))::params_and_IP))
740 ::method_args@other_method_args;
741 K.conclude_conclusion =
743 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
744 with notfound -> None
747 | _ -> raise NotApplicable
749 and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts =
750 let aux ?(name = None) = acic2content seed ~name:None ~ids_to_inner_types ~ids_to_inner_sorts in
751 let module C2A = Cic2acic in
752 let module K = Content in
753 let module C = Cic in
755 C.AConst (sid,uri,exp_named_subst)::args ->
756 let uri_str = UriManager.string_of_uri uri in
757 if uri_str = "cic:/Coq/Init/Logic/eq_ind.con" or
758 uri_str = "cic:/Coq/Init/Logic/eq_ind_r.con" then
759 let subproof = aux (List.nth args 3) in
761 let rec ma_aux n = function
767 { K.premise_id = gen_id seed;
768 K.premise_xref = subproof.K.proof_id;
769 K.premise_binder = None;
773 let aid = get_id a in
774 let asort = (try (Hashtbl.find ids_to_inner_sorts aid)
775 with Not_found -> "Type") in
776 if asort = "Prop" then
779 hd::(ma_aux (n-1) tl) in
781 { K.proof_name = None;
782 K.proof_id = gen_id seed;
783 K.proof_context = [];
784 K.proof_apply_context = [subproof];
786 { K.conclude_id = gen_id seed;
787 K.conclude_aref = id;
788 K.conclude_method = "Rewrite";
790 K.Term (C.AConst (sid,uri,exp_named_subst))::method_args;
791 K.conclude_conclusion =
793 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
794 with notfound -> None
797 else raise NotApplicable
798 | _ -> raise NotApplicable
802 seed ~ids_to_inner_sorts ~ids_to_inner_types (id,n,context,ty)
807 (id,None) as item -> item
808 | (id,Some (name,Cic.ADecl t)) ->
811 (build_decl_item seed (get_id t) name t
813 | (id,Some (name,Cic.ADef t)) ->
816 (build_def_item seed (get_id t) name t
817 ~ids_to_inner_sorts ~ids_to_inner_types)
823 let rec annobj2content ~ids_to_inner_sorts ~ids_to_inner_types =
824 let module C = Cic in
825 let module K = Content in
826 let module C2A = Cic2acic in
829 C.ACurrentProof (_,_,n,conjectures,bo,ty,params) ->
830 (gen_id seed, params,
833 (map_conjectures seed ~ids_to_inner_sorts ~ids_to_inner_types)
836 build_def_item seed (get_id bo) (C.Name n) bo
837 ~ids_to_inner_sorts ~ids_to_inner_types))
838 | C.AConstant (_,_,n,Some bo,ty,params) ->
839 (gen_id seed, params, None,
841 build_def_item seed (get_id bo) (C.Name n) bo
842 ~ids_to_inner_sorts ~ids_to_inner_types))
843 | C.AConstant (id,_,n,None,ty,params) ->
844 (gen_id seed, params, None,
846 build_decl_item seed id (C.Name n) ty
847 ~ids_to_inner_sorts))
848 | C.AVariable (_,n,Some bo,ty,params) ->
849 (gen_id seed, params, None,
851 build_def_item seed (get_id bo) (C.Name n) bo
852 ~ids_to_inner_sorts ~ids_to_inner_types))
853 | C.AVariable (id,n,None,ty,params) ->
854 (gen_id seed, params, None,
856 build_decl_item seed id (C.Name n) ty
857 ~ids_to_inner_sorts))
858 | C.AInductiveDefinition (id,l,params,nparams) ->
859 (gen_id seed, params, None,
861 { K.joint_id = gen_id seed;
862 K.joint_kind = `Inductive nparams;
863 K.joint_defs = List.map (build_inductive seed) l
867 build_inductive seed =
868 let module K = Content in
871 { K.inductive_id = gen_id seed;
872 K.inductive_kind = b;
873 K.inductive_type = ty;
874 K.inductive_constructors = build_constructors seed l
878 build_constructors seed l =
879 let module K = Content in
882 { K.dec_name = Some n;
883 K.dec_id = gen_id seed;
884 K.dec_inductive = false;
891 and 'term cinductiveType =
892 id * string * bool * 'term * (* typename, inductive, arity *)
893 'term cconstructor list (* constructors *)
895 and 'term cconstructor =