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 Not_found -> false)
118 | C.ALambda (id,_,_,_) ->
120 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
122 with Not_found -> false)
123 | C.ALetIn (id,_,_,_) ->
125 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
127 with Not_found -> false)
130 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
132 with Not_found -> false)
133 | C.AConst (id,_,_) ->
135 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
137 with Not_found -> false)
138 | C.AMutInd (id,_,_,_) -> false
139 | C.AMutConstruct (id,_,_,_,_) ->
141 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
143 with Not_found -> false)
145 | C.AMutCase (id,_,_,_,_,_) ->
147 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
149 with Not_found -> false)
152 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
154 with Not_found -> false)
155 | C.ACoFix (id,_,_) ->
157 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
159 with Not_found -> 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 Not_found -> "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_context = [];
213 K.proof_apply_context = []
215 p.K.proof_apply_context@[p1]
220 let rec serialize seed =
223 | p::tl -> (flat seed p)@(serialize seed tl);;
225 (* top_down = true if the term is a LAMBDA or a decl *)
226 let generate_conversion seed top_down id inner_proof ~ids_to_inner_types =
227 let module C2A = Cic2acic in
228 let module K = Content in
229 let exp = (try ((Hashtbl.find ids_to_inner_types id).C2A.annexpected)
230 with Not_found -> None)
235 if inner_proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
236 { K.proof_name = None ;
237 K.proof_id = gen_id seed;
238 K.proof_context = [] ;
239 K.proof_apply_context = [];
241 { K.conclude_id = gen_id seed;
242 K.conclude_aref = id;
243 K.conclude_method = "TD_Conversion";
244 K.conclude_args = [K.ArgProof inner_proof];
245 K.conclude_conclusion = Some expty
249 { K.proof_name = None ;
250 K.proof_id = gen_id seed;
251 K.proof_context = [] ;
252 K.proof_apply_context = [inner_proof];
254 { K.conclude_id = gen_id seed;
255 K.conclude_aref = id;
256 K.conclude_method = "BU_Conversion";
259 { K.premise_id = gen_id seed;
260 K.premise_xref = inner_proof.K.proof_id;
261 K.premise_binder = None;
265 K.conclude_conclusion = Some expty
270 let generate_exact seed t id name ~ids_to_inner_types =
271 let module C2A = Cic2acic in
272 let module K = Content in
273 { K.proof_name = name;
275 K.proof_context = [] ;
276 K.proof_apply_context = [];
278 { K.conclude_id = gen_id seed;
279 K.conclude_aref = id;
280 K.conclude_method = "Exact";
281 K.conclude_args = [K.Term t];
282 K.conclude_conclusion =
283 try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
284 with Not_found -> None
289 let generate_intros_let_tac seed id n s is_intro inner_proof name ~ids_to_inner_types =
290 let module C2A = Cic2acic in
291 let module C = Cic in
292 let module K = Content in
293 { K.proof_name = name;
295 K.proof_context = [] ;
296 K.proof_apply_context = [];
298 { K.conclude_id = gen_id seed;
299 K.conclude_aref = id;
300 K.conclude_method = "Intros+LetTac";
301 K.conclude_args = [K.ArgProof inner_proof];
302 K.conclude_conclusion =
304 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
306 (match inner_proof.K.proof_conclude.K.conclude_conclusion with
309 if is_intro then Some (C.AProd ("gen"^id,n,s,t))
310 else Some (C.ALetIn ("gen"^id,n,s,t)))
315 let build_decl_item seed id n s ~ids_to_inner_sorts =
316 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;
336 Not_found -> assert false
339 let rec build_def_item seed id n t ~ids_to_inner_sorts ~ids_to_inner_types =
340 let module K = Content in
342 let sort = Hashtbl.find ids_to_inner_sorts id in
343 if sort = "Prop" then
344 `Proof (acic2content seed ?name:(name_of n) ~ids_to_inner_sorts ~ids_to_inner_types t)
347 { K.def_name = name_of n;
348 K.def_id = gen_id seed;
353 Not_found -> assert false
355 (* the following function must be called with an object of sort
356 Prop. For debugging purposes this is tested again, possibly raising an
357 Not_a_proof exception *)
359 and acic2content seed ?name ~ids_to_inner_sorts ~ids_to_inner_types t =
360 let rec aux ?name t =
361 let module C = Cic in
362 let module K = Content in
363 let module C2A = Cic2acic in
366 C.ARel (id,idref,n,b) 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.AVar (id,uri,exp_named_subst) 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.AMeta (id,n,l) as t ->
377 let sort = Hashtbl.find ids_to_inner_sorts id in
378 if sort = "Prop" then
379 generate_exact seed t id name ~ids_to_inner_types
380 else raise Not_a_proof
381 | C.ASort (id,s) -> raise Not_a_proof
382 | C.AImplicit _ -> raise NotImplemented
383 | C.AProd (_,_,_,_) -> raise Not_a_proof
384 | C.ACast (id,v,t) -> aux v
385 | C.ALambda (id,n,s,t) ->
386 let sort = Hashtbl.find ids_to_inner_sorts id in
387 if sort = "Prop" then
390 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
391 match proof.K.proof_conclude.K.conclude_args with
399 (build_decl_item seed id n s ids_to_inner_sorts)::
400 proof'.K.proof_context
403 generate_intros_let_tac seed id n s true proof'' name ~ids_to_inner_types
404 else raise Not_a_proof
405 | C.ALetIn (id,n,s,t) ->
406 let sort = Hashtbl.find ids_to_inner_sorts id in
407 if sort = "Prop" then
410 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
411 match proof.K.proof_conclude.K.conclude_args with
419 ((build_def_item seed id n s ids_to_inner_sorts
420 ids_to_inner_types):> Cic.annterm K.in_proof_context_element)
421 ::proof'.K.proof_context;
424 generate_intros_let_tac seed id n s false proof'' name ~ids_to_inner_types
425 else raise Not_a_proof
428 seed name id li ids_to_inner_types ids_to_inner_sorts
429 with NotApplicable ->
431 seed name id li ids_to_inner_types ids_to_inner_sorts
432 with NotApplicable ->
434 List.filter (test_for_lifting ~ids_to_inner_types) li in
436 match args_to_lift with
437 [_] -> List.map aux args_to_lift
438 | _ -> List.map (aux ~name:"H") args_to_lift in
439 let args = build_args seed li subproofs
440 ~ids_to_inner_types ~ids_to_inner_sorts in
441 { K.proof_name = name;
442 K.proof_id = gen_id seed;
443 K.proof_context = [];
444 K.proof_apply_context = serialize seed subproofs;
446 { K.conclude_id = gen_id seed;
447 K.conclude_aref = id;
448 K.conclude_method = "Apply";
449 K.conclude_args = args;
450 K.conclude_conclusion =
452 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
453 with Not_found -> None
456 | C.AConst (id,uri,exp_named_subst) as t ->
457 let sort = Hashtbl.find ids_to_inner_sorts id in
458 if sort = "Prop" then
459 generate_exact seed t id name ~ids_to_inner_types
460 else raise Not_a_proof
461 | C.AMutInd (id,uri,i,exp_named_subst) -> raise Not_a_proof
462 | C.AMutConstruct (id,uri,i,j,exp_named_subst) as t ->
463 let sort = Hashtbl.find ids_to_inner_sorts id in
464 if sort = "Prop" then
465 generate_exact seed t id name ~ids_to_inner_types
466 else raise Not_a_proof
467 | C.AMutCase (id,uri,typeno,ty,te,patterns) ->
468 let teid = get_id te in
469 let pp = List.map (function p -> (K.ArgProof (aux p))) patterns in
471 (try Some (Hashtbl.find ids_to_inner_types teid).C2A.annsynthesized
472 with Not_found -> None)
474 Some tety -> (* we must lift up the argument *)
476 { K.proof_name = Some "name";
477 K.proof_id = gen_id seed;
478 K.proof_context = [];
479 K.proof_apply_context = flat seed p;
481 { K.conclude_id = gen_id seed;
482 K.conclude_aref = id;
483 K.conclude_method = "Case";
484 K.conclude_args = (K.Term ty)::(K.Term te)::pp;
485 K.conclude_conclusion =
487 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
488 with Not_found -> None
492 { K.proof_name = name;
493 K.proof_id = gen_id seed;
494 K.proof_context = [];
495 K.proof_apply_context = [];
497 { K.conclude_id = gen_id seed;
498 K.conclude_aref = id;
499 K.conclude_method = "Case";
500 K.conclude_args = (K.Term ty)::(K.Term te)::pp;
501 K.conclude_conclusion =
503 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
504 with Not_found -> None
508 | C.AFix (id, no, funs) ->
511 (function (_,name,_,_,bo) -> `Proof (aux ~name bo)) funs in
512 let decreasing_args =
513 List.map (function (_,_,n,_,_) -> n) funs in
515 { K.joint_id = gen_id seed;
516 K.joint_kind = `Recursive decreasing_args;
517 K.joint_defs = proofs
520 { K.proof_name = name;
521 K.proof_id = gen_id seed;
522 K.proof_context = [`Joint jo];
523 K.proof_apply_context = [];
525 { K.conclude_id = gen_id seed;
526 K.conclude_aref = id;
527 K.conclude_method = "Exact";
530 { K.premise_id = gen_id seed;
531 K.premise_xref = jo.K.joint_id;
532 K.premise_binder = Some "tiralo fuori";
533 K.premise_n = Some no;
536 K.conclude_conclusion =
538 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
539 with Not_found -> None
542 | C.ACoFix (id,no,funs) ->
545 (function (_,name,_,bo) -> `Proof (aux ~name bo)) funs in
547 { K.joint_id = gen_id seed;
548 K.joint_kind = `CoRecursive;
549 K.joint_defs = proofs
552 { K.proof_name = name;
553 K.proof_id = gen_id seed;
554 K.proof_context = [`Joint jo];
555 K.proof_apply_context = [];
557 { K.conclude_id = gen_id seed;
558 K.conclude_aref = id;
559 K.conclude_method = "Exact";
562 { K.premise_id = gen_id seed;
563 K.premise_xref = jo.K.joint_id;
564 K.premise_binder = Some "tiralo fuori";
565 K.premise_n = Some no;
568 K.conclude_conclusion =
570 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
571 with Not_found -> None
576 generate_conversion seed false id t1 ~ids_to_inner_types
579 and inductive seed name id li ids_to_inner_types ids_to_inner_sorts =
580 let aux ?name = acic2content seed ~ids_to_inner_types ~ids_to_inner_sorts in
581 let module C2A = Cic2acic in
582 let module K = Content in
583 let module C = Cic in
585 C.AConst (idc,uri,exp_named_subst)::args ->
586 let uri_str = UriManager.string_of_uri uri in
587 let suffix = Str.regexp_string "_ind.con" in
588 let len = String.length uri_str in
589 let n = (try (Str.search_backward suffix uri_str len)
590 with Not_found -> -1) in
591 if n<0 then raise NotApplicable
593 let prefix = String.sub uri_str 0 n in
594 let ind_str = (prefix ^ ".ind") in
595 let ind_uri = UriManager.uri_of_string ind_str in
596 let inductive_types,noparams =
597 (match CicEnvironment.get_obj ind_uri with
598 Cic.Constant _ -> assert false
599 | Cic.Variable _ -> assert false
600 | Cic.CurrentProof _ -> assert false
601 | Cic.InductiveDefinition (l,_,n) -> (l,n)
604 if n = 0 then ([],l) else
605 let p,a = split (n-1) (List.tl l) in
606 ((List.hd l::p),a) in
607 let params_and_IP,tail_args = split (noparams+1) args in
609 (match inductive_types with
611 | _ -> raise NotApplicable) (* don't care for mutual ind *) in
613 let rec clean_up n t =
616 (label,Cic.Prod (_,_,t)) -> clean_up (n-1) (label,t)
617 | _ -> assert false) in
618 List.map (clean_up noparams) constructors in
619 let no_constructors= List.length constructors in
620 let args_for_cases, other_args =
621 split no_constructors tail_args in
623 List.filter (test_for_lifting ~ids_to_inner_types) other_args in
625 match args_to_lift with
626 [_] -> List.map aux args_to_lift
627 | _ -> List.map (aux ~name:"H") args_to_lift in
628 prerr_endline "****** end subproofs *******"; flush stderr;
629 let other_method_args =
630 build_args seed other_args subproofs
631 ~ids_to_inner_types ~ids_to_inner_sorts in
633 let rparams,inductive_arg =
638 | a::tl -> let (p,ia) = aux tl in (a::p,ia) in
639 aux other_method_args in
641 prerr_endline "****** end other *******"; flush stderr;
643 let rec build_method_args =
645 [],_-> [] (* extra args are ignored ???? *)
646 | (name,ty)::tlc,arg::tla ->
647 let idarg = get_id arg in
649 (try (Hashtbl.find ids_to_inner_sorts idarg)
650 with Not_found -> "Type") in
652 if sortarg = "Prop" then
656 Cic.Prod (_,s,t),Cic.ALambda(idl,n,s1,t1) ->
659 seed idl n s1 ~ids_to_inner_sorts in
660 if (occur ind_uri s) then
661 ( prerr_endline ("inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
663 Cic.ALambda(id2,n2,s2,t2) ->
666 { K.dec_name = name_of n2;
667 K.dec_id = gen_id seed;
668 K.dec_inductive = true;
672 let (context,body) = bc (t,t2) in
673 (ce::inductive_hyp::context,body)
676 ( prerr_endline ("no inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
677 let (context,body) = bc (t,t1) in
679 | _ , t -> ([],aux t) in
683 K.proof_name = Some name;
684 K.proof_context = co;
687 hdarg::(build_method_args (tlc,tla))
688 | _ -> assert false in
689 build_method_args (constructors1,args_for_cases) in
690 { K.proof_name = None;
691 K.proof_id = gen_id seed;
692 K.proof_context = [];
693 K.proof_apply_context = subproofs;
695 { K.conclude_id = gen_id seed;
696 K.conclude_aref = id;
697 K.conclude_method = "ByInduction";
699 K.Aux no_constructors
700 ::K.Term (C.AAppl id ((C.AConst(idc,uri,exp_named_subst))::params_and_IP))
701 ::method_args@other_method_args;
702 K.conclude_conclusion =
704 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
705 with Not_found -> None
708 | _ -> raise NotApplicable
710 and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts =
711 let aux ?name = acic2content seed ~ids_to_inner_types ~ids_to_inner_sorts in
712 let module C2A = Cic2acic in
713 let module K = Content in
714 let module C = Cic in
716 C.AConst (sid,uri,exp_named_subst)::args ->
717 let uri_str = UriManager.string_of_uri uri in
718 if uri_str = "cic:/Coq/Init/Logic/eq_ind.con" or
719 uri_str = "cic:/Coq/Init/Logic/eq_ind_r.con" then
720 let subproof = aux (List.nth args 3) in
722 let rec ma_aux n = function
728 { K.premise_id = gen_id seed;
729 K.premise_xref = subproof.K.proof_id;
730 K.premise_binder = None;
734 let aid = get_id a in
735 let asort = (try (Hashtbl.find ids_to_inner_sorts aid)
736 with Not_found -> "Type") in
737 if asort = "Prop" then
740 hd::(ma_aux (n-1) tl) in
742 { K.proof_name = None;
743 K.proof_id = gen_id seed;
744 K.proof_context = [];
745 K.proof_apply_context = [subproof];
747 { K.conclude_id = gen_id seed;
748 K.conclude_aref = id;
749 K.conclude_method = "Rewrite";
751 K.Term (C.AConst (sid,uri,exp_named_subst))::method_args;
752 K.conclude_conclusion =
754 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
755 with Not_found -> None
758 else raise NotApplicable
759 | _ -> raise NotApplicable
763 seed ~ids_to_inner_sorts ~ids_to_inner_types (id,n,context,ty)
765 let module K = Content in
769 (id,None) as item -> item
770 | (id,Some (name,Cic.ADecl t)) ->
773 (* We should call build_decl_item, but we have not computed *)
774 (* the inner-types ==> we always produce a declaration *)
776 { K.dec_name = name_of name;
777 K.dec_id = gen_id seed;
778 K.dec_inductive = false;
779 K.dec_aref = get_id t;
782 | (id,Some (name,Cic.ADef t)) ->
785 (* We should call build_def_item, but we have not computed *)
786 (* the inner-types ==> we always produce a declaration *)
788 { K.def_name = name_of name;
789 K.def_id = gen_id seed;
790 K.def_aref = get_id t;
798 let rec annobj2content ~ids_to_inner_sorts ~ids_to_inner_types =
799 let module C = Cic in
800 let module K = Content in
801 let module C2A = Cic2acic in
804 C.ACurrentProof (_,_,n,conjectures,bo,ty,params) ->
805 (gen_id seed, params,
808 (map_conjectures seed ~ids_to_inner_sorts ~ids_to_inner_types)
811 build_def_item seed (get_id bo) (C.Name n) bo
812 ~ids_to_inner_sorts ~ids_to_inner_types))
813 | C.AConstant (_,_,n,Some bo,ty,params) ->
814 (gen_id seed, params, None,
816 build_def_item seed (get_id bo) (C.Name n) bo
817 ~ids_to_inner_sorts ~ids_to_inner_types))
818 | C.AConstant (id,_,n,None,ty,params) ->
819 (gen_id seed, params, None,
821 build_decl_item seed id (C.Name n) ty
822 ~ids_to_inner_sorts))
823 | C.AVariable (_,n,Some bo,ty,params) ->
824 (gen_id seed, params, None,
826 build_def_item seed (get_id bo) (C.Name n) bo
827 ~ids_to_inner_sorts ~ids_to_inner_types))
828 | C.AVariable (id,n,None,ty,params) ->
829 (gen_id seed, params, None,
831 build_decl_item seed id (C.Name n) ty
832 ~ids_to_inner_sorts))
833 | C.AInductiveDefinition (id,l,params,nparams) ->
834 (gen_id seed, params, None,
836 { K.joint_id = gen_id seed;
837 K.joint_kind = `Inductive nparams;
838 K.joint_defs = List.map (build_inductive seed) l
842 build_inductive seed =
843 let module K = Content in
846 { K.inductive_id = gen_id seed;
847 K.inductive_kind = b;
848 K.inductive_type = ty;
849 K.inductive_constructors = build_constructors seed l
853 build_constructors seed l =
854 let module K = Content in
857 { K.dec_name = Some n;
858 K.dec_id = gen_id seed;
859 K.dec_inductive = false;
866 and 'term cinductiveType =
867 id * string * bool * 'term * (* typename, inductive, arity *)
868 'term cconstructor list (* constructors *)
870 and 'term cconstructor =