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 X = Xml in
358 let module K = Content in
359 let module U = UriManager in
360 let module C2A = Cic2acic in
363 C.ARel (id,idref,n,b) as t ->
364 let sort = Hashtbl.find ids_to_inner_sorts id in
365 if sort = "Prop" then
366 generate_exact seed t id name ~ids_to_inner_types
367 else raise Not_a_proof
368 | C.AVar (id,uri,exp_named_subst) as t ->
369 let sort = Hashtbl.find ids_to_inner_sorts id in
370 if sort = "Prop" then
371 generate_exact seed t id name ~ids_to_inner_types
372 else raise Not_a_proof
373 | C.AMeta (id,n,l) as t ->
374 let sort = Hashtbl.find ids_to_inner_sorts id in
375 if sort = "Prop" then
376 generate_exact seed t id name ~ids_to_inner_types
377 else raise Not_a_proof
378 | C.ASort (id,s) -> raise Not_a_proof
379 | C.AImplicit _ -> raise NotImplemented
380 | C.AProd (_,_,_,_) -> raise Not_a_proof
381 | C.ACast (id,v,t) -> aux v
382 | C.ALambda (id,n,s,t) ->
383 let sort = Hashtbl.find ids_to_inner_sorts id in
384 if sort = "Prop" then
385 let proof = aux t ~name:None in
387 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
388 match proof.K.proof_conclude.K.conclude_args with
396 (build_decl_item seed id n s ids_to_inner_sorts)::
397 proof'.K.proof_context
400 generate_intros_let_tac seed id n s true proof'' name ~ids_to_inner_types
401 else raise Not_a_proof
402 | C.ALetIn (id,n,s,t) ->
403 let sort = Hashtbl.find ids_to_inner_sorts id in
404 if sort = "Prop" then
407 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
408 match proof.K.proof_conclude.K.conclude_args with
416 ((build_def_item seed id n s ids_to_inner_sorts
417 ids_to_inner_types):> Cic.annterm K.in_proof_context_element)
418 ::proof'.K.proof_context;
421 generate_intros_let_tac seed id n s false proof'' name ~ids_to_inner_types
422 else raise Not_a_proof
425 seed name id li ids_to_inner_types ids_to_inner_sorts
426 with NotApplicable ->
428 seed name id li ids_to_inner_types ids_to_inner_sorts
429 with NotApplicable ->
431 List.filter (test_for_lifting ~ids_to_inner_types) li in
433 match args_to_lift with
434 [_] -> List.map aux args_to_lift
435 | _ -> List.map (aux ~name:(Some "H")) args_to_lift in
436 let args = build_args seed li subproofs
437 ~ids_to_inner_types ~ids_to_inner_sorts in
438 { K.proof_name = name;
439 K.proof_id = gen_id seed;
440 K.proof_context = [];
441 K.proof_apply_context = serialize seed subproofs;
443 { K.conclude_id = gen_id seed;
444 K.conclude_aref = id;
445 K.conclude_method = "Apply";
446 K.conclude_args = args;
447 K.conclude_conclusion =
449 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
450 with notfound -> None
453 | C.AConst (id,uri,exp_named_subst) as t ->
454 let sort = Hashtbl.find ids_to_inner_sorts id in
455 if sort = "Prop" then
456 generate_exact seed t id name ~ids_to_inner_types
457 else raise Not_a_proof
458 | C.AMutInd (id,uri,i,exp_named_subst) -> raise Not_a_proof
459 | C.AMutConstruct (id,uri,i,j,exp_named_subst) as t ->
460 let sort = Hashtbl.find ids_to_inner_sorts id in
461 if sort = "Prop" then
462 generate_exact seed t id name ~ids_to_inner_types
463 else raise Not_a_proof
464 | C.AMutCase (id,uri,typeno,ty,te,patterns) ->
465 let teid = get_id te in
466 let pp = List.map (function p -> (K.ArgProof (aux p))) patterns in
468 (try Some (Hashtbl.find ids_to_inner_types teid).C2A.annsynthesized
469 with notfound -> None)
471 Some tety -> (* we must lift up the argument *)
473 { K.proof_name = Some "name";
474 K.proof_id = gen_id seed;
475 K.proof_context = [];
476 K.proof_apply_context = flat seed p;
478 { K.conclude_id = gen_id seed;
479 K.conclude_aref = id;
480 K.conclude_method = "Case";
481 K.conclude_args = (K.Term ty)::(K.Term te)::pp;
482 K.conclude_conclusion =
484 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
485 with notfound -> None
489 { K.proof_name = name;
490 K.proof_id = gen_id seed;
491 K.proof_context = [];
492 K.proof_apply_context = [];
494 { K.conclude_id = gen_id seed;
495 K.conclude_aref = id;
496 K.conclude_method = "Case";
497 K.conclude_args = (K.Term ty)::(K.Term te)::pp;
498 K.conclude_conclusion =
500 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
501 with notfound -> None
505 | C.AFix (id, no, [(id1,n,_,ty,bo)]) ->
506 let proof = (aux bo) in (* must be recursive !! *)
507 { K.proof_name = name;
508 K.proof_id = gen_id seed;
509 K.proof_context = [`Proof proof];
510 K.proof_apply_context = [];
512 { K.conclude_id = gen_id seed;
513 K.conclude_aref = id;
514 K.conclude_method = "Exact";
517 { K.premise_id = gen_id seed;
518 K.premise_xref = proof.K.proof_id;
519 K.premise_binder = proof.K.proof_name;
520 K.premise_n = Some 1;
523 K.conclude_conclusion =
525 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
526 with notfound -> None
529 | C.AFix (id, no, funs) ->
531 List.map (function (id1,n,_,ty,bo) -> (`Proof (aux bo))) funs in
533 { K.joint_id = gen_id seed;
534 K.joint_kind = `Recursive;
535 K.joint_defs = proofs
538 { K.proof_name = name;
539 K.proof_id = gen_id seed;
540 K.proof_context = [`Joint jo];
541 K.proof_apply_context = [];
543 { K.conclude_id = gen_id seed;
544 K.conclude_aref = id;
545 K.conclude_method = "Exact";
548 { K.premise_id = gen_id seed;
549 K.premise_xref = jo.K.joint_id;
550 K.premise_binder = Some "tiralo fuori";
551 K.premise_n = Some no;
554 K.conclude_conclusion =
556 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
557 with notfound -> None
560 | C.ACoFix (id,no,[(id1,n,ty,bo)]) ->
561 let proof = (aux bo) in (* must be recursive !! *)
562 { K.proof_name = name;
563 K.proof_id = gen_id seed;
564 K.proof_context = [`Proof proof];
565 K.proof_apply_context = [];
567 { K.conclude_id = gen_id seed;
568 K.conclude_aref = id;
569 K.conclude_method = "Exact";
572 { K.premise_id = gen_id seed;
573 K.premise_xref = proof.K.proof_id;
574 K.premise_binder = proof.K.proof_name;
575 K.premise_n = Some 1;
578 K.conclude_conclusion =
580 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
581 with notfound -> None
584 | C.ACoFix (id,no,funs) ->
586 List.map (function (id1,n,ty,bo) -> (`Proof (aux bo))) funs in
588 { K.joint_id = gen_id seed;
589 K.joint_kind = `Recursive;
590 K.joint_defs = proofs
593 { K.proof_name = name;
594 K.proof_id = gen_id seed;
595 K.proof_context = [`Joint jo];
596 K.proof_apply_context = [];
598 { K.conclude_id = gen_id seed;
599 K.conclude_aref = id;
600 K.conclude_method = "Exact";
603 { K.premise_id = gen_id seed;
604 K.premise_xref = jo.K.joint_id;
605 K.premise_binder = Some "tiralo fuori";
606 K.premise_n = Some no;
609 K.conclude_conclusion =
611 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
612 with notfound -> None
617 generate_conversion seed false id t1 ~ids_to_inner_types
620 and inductive seed name id li ids_to_inner_types ids_to_inner_sorts =
621 let aux ?(name = None) = acic2content seed ~name:None ~ids_to_inner_types ~ids_to_inner_sorts in
622 let module C2A = Cic2acic in
623 let module K = Content in
624 let module C = Cic in
626 C.AConst (idc,uri,exp_named_subst)::args ->
627 let uri_str = UriManager.string_of_uri uri in
628 let suffix = Str.regexp_string "_ind.con" in
629 let len = String.length uri_str in
630 let n = (try (Str.search_backward suffix uri_str len)
631 with Not_found -> -1) in
632 if n<0 then raise NotApplicable
634 let prefix = String.sub uri_str 0 n in
635 let ind_str = (prefix ^ ".ind") in
636 let ind_uri = UriManager.uri_of_string ind_str in
637 let inductive_types,noparams =
638 (match CicEnvironment.get_obj ind_uri with
639 Cic.Constant _ -> assert false
640 | Cic.Variable _ -> assert false
641 | Cic.CurrentProof _ -> assert false
642 | Cic.InductiveDefinition (l,_,n) -> (l,n)
645 if n = 0 then ([],l) else
646 let p,a = split (n-1) (List.tl l) in
647 ((List.hd l::p),a) in
648 let params_and_IP,tail_args = split (noparams+1) args in
650 (match inductive_types with
652 | _ -> raise NotApplicable) (* don't care for mutual ind *) in
654 let rec clean_up n t =
657 (label,Cic.Prod (_,_,t)) -> clean_up (n-1) (label,t)
658 | _ -> assert false) in
659 List.map (clean_up noparams) constructors in
660 let no_constructors= List.length constructors in
661 let args_for_cases, other_args =
662 split no_constructors tail_args in
664 List.filter (test_for_lifting ~ids_to_inner_types) other_args in
666 match args_to_lift with
667 [_] -> List.map aux args_to_lift
668 | _ -> List.map (aux ~name:(Some "H")) args_to_lift in
669 prerr_endline "****** end subproofs *******"; flush stderr;
670 let other_method_args =
671 build_args seed other_args subproofs
672 ~ids_to_inner_types ~ids_to_inner_sorts in
674 let rparams,inductive_arg =
679 | a::tl -> let (p,ia) = aux tl in (a::p,ia) in
680 aux other_method_args in
682 prerr_endline "****** end other *******"; flush stderr;
684 let rec build_method_args =
686 [],_-> [] (* extra args are ignored ???? *)
687 | (name,ty)::tlc,arg::tla ->
688 let idarg = get_id arg in
690 (try (Hashtbl.find ids_to_inner_sorts idarg)
691 with Not_found -> "Type") in
693 if sortarg = "Prop" then
697 Cic.Prod (_,s,t),Cic.ALambda(idl,n,s1,t1) ->
700 seed idl n s1 ~ids_to_inner_sorts in
701 if (occur ind_uri s) then
702 ( prerr_endline ("inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
704 Cic.ALambda(id2,n2,s2,t2) ->
707 { K.dec_name = name_of n2;
708 K.dec_id = gen_id seed;
709 K.dec_inductive = true;
713 let (context,body) = bc (t,t2) in
714 (ce::inductive_hyp::context,body)
717 ( prerr_endline ("no inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
718 let (context,body) = bc (t,t1) in
720 | _ , t -> ([],aux t ~name:None) in
724 K.proof_name = Some name;
725 K.proof_context = co;
728 hdarg::(build_method_args (tlc,tla))
729 | _ -> assert false in
730 build_method_args (constructors1,args_for_cases) in
731 { K.proof_name = None;
732 K.proof_id = gen_id seed;
733 K.proof_context = [];
734 K.proof_apply_context = subproofs;
736 { K.conclude_id = gen_id seed;
737 K.conclude_aref = id;
738 K.conclude_method = "ByInduction";
740 K.Aux no_constructors
741 ::K.Term (C.AAppl id ((C.AConst(idc,uri,exp_named_subst))::params_and_IP))
742 ::method_args@other_method_args;
743 K.conclude_conclusion =
745 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
746 with notfound -> None
749 | _ -> raise NotApplicable
751 and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts =
752 let aux ?(name = None) = acic2content seed ~name:None ~ids_to_inner_types ~ids_to_inner_sorts in
753 let module C2A = Cic2acic in
754 let module K = Content in
755 let module C = Cic in
757 C.AConst (sid,uri,exp_named_subst)::args ->
758 let uri_str = UriManager.string_of_uri uri in
759 if uri_str = "cic:/Coq/Init/Logic/eq_ind.con" or
760 uri_str = "cic:/Coq/Init/Logic/eq_ind_r.con" then
761 let subproof = aux (List.nth args 3) in
763 let rec ma_aux n = function
769 { K.premise_id = gen_id seed;
770 K.premise_xref = subproof.K.proof_id;
771 K.premise_binder = None;
775 let aid = get_id a in
776 let asort = (try (Hashtbl.find ids_to_inner_sorts aid)
777 with Not_found -> "Type") in
778 if asort = "Prop" then
781 hd::(ma_aux (n-1) tl) in
783 { K.proof_name = None;
784 K.proof_id = gen_id seed;
785 K.proof_context = [];
786 K.proof_apply_context = [subproof];
788 { K.conclude_id = gen_id seed;
789 K.conclude_aref = id;
790 K.conclude_method = "Rewrite";
792 K.Term (C.AConst (sid,uri,exp_named_subst))::method_args;
793 K.conclude_conclusion =
795 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
796 with notfound -> None
799 else raise NotApplicable
800 | _ -> raise NotApplicable
804 seed ~ids_to_inner_sorts ~ids_to_inner_types (id,n,context,ty)
809 (id,None) as item -> item
810 | (id,Some (name,Cic.ADecl t)) ->
813 (build_decl_item seed (get_id t) name t
815 | (id,Some (name,Cic.ADef t)) ->
818 (build_def_item seed (get_id t) name t
819 ~ids_to_inner_sorts ~ids_to_inner_types)
825 let rec annobj2content ~ids_to_inner_sorts ~ids_to_inner_types =
826 let module C = Cic in
827 let module K = Content in
828 let module C2A = Cic2acic in
831 C.ACurrentProof (_,_,n,conjectures,bo,ty,params) ->
832 (gen_id seed, params,
835 (map_conjectures seed ~ids_to_inner_sorts ~ids_to_inner_types)
838 build_def_item seed (get_id bo) (C.Name n) bo
839 ~ids_to_inner_sorts ~ids_to_inner_types))
840 | C.AConstant (_,_,n,Some bo,ty,params) ->
841 (gen_id seed, params, None,
843 build_def_item seed (get_id bo) (C.Name n) bo
844 ~ids_to_inner_sorts ~ids_to_inner_types))
845 | C.AConstant (id,_,n,None,ty,params) ->
846 (gen_id seed, params, None,
848 build_decl_item seed id (C.Name n) ty
849 ~ids_to_inner_sorts))
850 | C.AVariable (_,n,Some bo,ty,params) ->
851 (gen_id seed, params, None,
853 build_def_item seed (get_id bo) (C.Name n) bo
854 ~ids_to_inner_sorts ~ids_to_inner_types))
855 | C.AVariable (id,n,None,ty,params) ->
856 (gen_id seed, params, None,
858 build_decl_item seed id (C.Name n) ty
859 ~ids_to_inner_sorts))
860 | C.AInductiveDefinition (id,l,params,nparams) ->
861 (gen_id seed, params, None,
863 { K.joint_id = gen_id seed;
864 K.joint_kind = `Inductive nparams;
865 K.joint_defs = List.map (build_inductive seed) l
869 build_inductive seed =
870 let module K = Content in
873 { K.inductive_id = gen_id seed;
874 K.inductive_kind = b;
875 K.inductive_type = ty;
876 K.inductive_constructors = build_constructors seed l
880 build_constructors seed l =
881 let module K = Content in
884 { K.dec_name = Some n;
885 K.dec_id = gen_id seed;
886 K.dec_inductive = false;
893 and 'term cinductiveType =
894 id * string * bool * 'term * (* typename, inductive, arity *)
895 'term cconstructor list (* constructors *)
897 and 'term cconstructor =