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 ~ids_to_inner_sorts=
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
110 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
112 with Not_found -> false)
113 | C.AMeta (id,_,_) ->
115 Hashtbl.find ids_to_inner_sorts id = "Prop"
116 with Not_found -> assert false)
117 | C.ASort (id,_) -> false
118 | C.AImplicit _ -> raise NotImplemented
119 | C.AProd (id,_,_,_) -> false
120 | C.ACast (id,_,_) ->
122 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
124 with Not_found -> false)
125 | C.ALambda (id,_,_,_) ->
127 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
129 with Not_found -> false)
130 | C.ALetIn (id,_,_,_) ->
132 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
134 with Not_found -> false)
137 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
139 with Not_found -> false)
140 | C.AConst (id,_,_) ->
142 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
144 with Not_found -> false)
145 | C.AMutInd (id,_,_,_) -> false
146 | C.AMutConstruct (id,_,_,_,_) ->
148 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
150 with Not_found -> false)
152 | C.AMutCase (id,_,_,_,_,_) ->
154 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
156 with Not_found -> false)
159 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
161 with Not_found -> false)
162 | C.ACoFix (id,_,_) ->
164 ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized;
166 with Not_found -> false)
170 let build_args seed l subproofs ~ids_to_inner_types ~ids_to_inner_sorts =
171 let module C = Cic in
172 let module K = Content in
173 let rec aux l subproofs =
177 if (test_for_lifting t ~ids_to_inner_types) then
178 (match subproofs with
183 { K.premise_id = gen_id seed;
184 K.premise_xref = p.K.proof_id;
185 K.premise_binder = p.K.proof_name;
188 in new_arg::(aux l1 tl))
192 C.ARel (idr,idref,n,b) ->
194 (try Hashtbl.find ids_to_inner_sorts idr
195 with Not_found -> "Type") in
198 { K.premise_id = gen_id seed;
199 K.premise_xref = idr;
200 K.premise_binder = Some b;
204 | _ -> (K.Term t)) in
205 hd::(aux l1 subproofs)
210 (* transform a proof p into a proof list, concatenating the last
211 conclude element to the apply_context list, in case context is
212 empty. Otherwise, it just returns [p] *)
215 let module K = Content in
216 if (p.K.proof_context = []) then
217 if p.K.proof_apply_context = [] then [p]
221 K.proof_context = [];
222 K.proof_apply_context = []
224 p.K.proof_apply_context@[p1]
229 let rec serialize seed =
232 | a::l -> (flat seed a)@(serialize seed l)
235 (* top_down = true if the term is a LAMBDA or a decl *)
236 let generate_conversion seed top_down id inner_proof ~ids_to_inner_types =
237 let module C2A = Cic2acic in
238 let module K = Content in
239 let exp = (try ((Hashtbl.find ids_to_inner_types id).C2A.annexpected)
240 with Not_found -> None)
245 if inner_proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
246 { K.proof_name = None ;
247 K.proof_id = gen_id seed;
248 K.proof_context = [] ;
249 K.proof_apply_context = [];
251 { K.conclude_id = gen_id seed;
252 K.conclude_aref = id;
253 K.conclude_method = "TD_Conversion";
254 K.conclude_args = [K.ArgProof inner_proof];
255 K.conclude_conclusion = Some expty
259 { K.proof_name = None ;
260 K.proof_id = gen_id seed;
261 K.proof_context = [] ;
262 K.proof_apply_context = [inner_proof];
264 { K.conclude_id = gen_id seed;
265 K.conclude_aref = id;
266 K.conclude_method = "BU_Conversion";
269 { K.premise_id = gen_id seed;
270 K.premise_xref = inner_proof.K.proof_id;
271 K.premise_binder = None;
275 K.conclude_conclusion = Some expty
280 let generate_exact seed t id name ~ids_to_inner_types =
281 let module C2A = Cic2acic in
282 let module K = Content in
283 { K.proof_name = name;
285 K.proof_context = [] ;
286 K.proof_apply_context = [];
288 { K.conclude_id = gen_id seed;
289 K.conclude_aref = id;
290 K.conclude_method = "Exact";
291 K.conclude_args = [K.Term t];
292 K.conclude_conclusion =
293 try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
294 with Not_found -> None
299 let generate_intros_let_tac seed id n s is_intro inner_proof name ~ids_to_inner_types =
300 let module C2A = Cic2acic in
301 let module C = Cic in
302 let module K = Content in
303 { K.proof_name = name;
305 K.proof_context = [] ;
306 K.proof_apply_context = [];
308 { K.conclude_id = gen_id seed;
309 K.conclude_aref = id;
310 K.conclude_method = "Intros+LetTac";
311 K.conclude_args = [K.ArgProof inner_proof];
312 K.conclude_conclusion =
314 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
316 (match inner_proof.K.proof_conclude.K.conclude_conclusion with
319 if is_intro then Some (C.AProd ("gen"^id,n,s,t))
320 else Some (C.ALetIn ("gen"^id,n,s,t)))
325 let build_decl_item seed id n s ~ids_to_inner_sorts =
326 let module K = Content in
328 let sort = Hashtbl.find ids_to_inner_sorts (Cic2acic.source_id_of_id id) in
329 if sort = "Prop" then
331 { K.dec_name = name_of n;
332 K.dec_id = gen_id seed;
333 K.dec_inductive = false;
339 { K.dec_name = name_of n;
340 K.dec_id = gen_id seed;
341 K.dec_inductive = false;
346 Not_found -> assert false
349 let rec build_subproofs_and_args seed l ~ids_to_inner_types ~ids_to_inner_sorts =
350 let module C = Cic in
351 let module K = Content in
356 let subproofs,args = aux l1 in
357 if (test_for_lifting t ~ids_to_inner_types ~ids_to_inner_sorts) then
360 seed ~name:"H" ~ids_to_inner_types ~ids_to_inner_sorts t in
363 { K.premise_id = gen_id seed;
364 K.premise_xref = new_subproof.K.proof_id;
365 K.premise_binder = new_subproof.K.proof_name;
368 new_subproof::subproofs,new_arg::args
372 C.ARel (idr,idref,n,b) ->
374 (try Hashtbl.find ids_to_inner_sorts idr
375 with Not_found -> "Type") in
378 { K.premise_id = gen_id seed;
379 K.premise_xref = idr;
380 K.premise_binder = Some b;
384 | C.AConst(id,uri,[]) ->
386 (try Hashtbl.find ids_to_inner_sorts id
387 with Not_found -> "Type") in
390 { K.lemma_id = gen_id seed;
391 K.lemma_name = UriManager.name_of_uri uri;
392 K.lemma_uri = UriManager.string_of_uri uri
395 | C.AMutConstruct(id,uri,tyno,consno,[]) ->
397 (try Hashtbl.find ids_to_inner_sorts id
398 with Not_found -> "Type") in
400 let inductive_types =
401 (match CicEnvironment.get_obj uri with
402 Cic.Constant _ -> assert false
403 | Cic.Variable _ -> assert false
404 | Cic.CurrentProof _ -> assert false
405 | Cic.InductiveDefinition (l,_,_) -> l
407 let (_,_,_,constructors) =
408 List.nth inductive_types tyno in
409 let name,_ = List.nth constructors (consno - 1) in
411 { K.lemma_id = gen_id seed;
414 UriManager.string_of_uri uri ^ "#xpointer(1/" ^
415 string_of_int (tyno+1) ^ "/" ^ string_of_int consno ^
419 | _ -> (K.Term t)) in
424 [{p with K.proof_name = None}],
427 K.Premise prem when prem.K.premise_xref = p.K.proof_id ->
428 K.Premise {prem with K.premise_binder = None}
434 build_def_item seed id n t ~ids_to_inner_sorts ~ids_to_inner_types =
435 let module K = Content in
437 let sort = Hashtbl.find ids_to_inner_sorts id in
438 if sort = "Prop" then
439 `Proof (acic2content seed ?name:(name_of n) ~ids_to_inner_sorts ~ids_to_inner_types t)
442 { K.def_name = name_of n;
443 K.def_id = gen_id seed;
448 Not_found -> assert false
450 (* the following function must be called with an object of sort
451 Prop. For debugging purposes this is tested again, possibly raising an
452 Not_a_proof exception *)
454 and acic2content seed ?name ~ids_to_inner_sorts ~ids_to_inner_types t =
455 let rec aux ?name t =
456 let module C = Cic in
457 let module K = Content in
458 let module C2A = Cic2acic in
461 C.ARel (id,idref,n,b) as t ->
462 let sort = Hashtbl.find ids_to_inner_sorts id in
463 if sort = "Prop" then
464 generate_exact seed t id name ~ids_to_inner_types
465 else raise Not_a_proof
466 | C.AVar (id,uri,exp_named_subst) as t ->
467 let sort = Hashtbl.find ids_to_inner_sorts id in
468 if sort = "Prop" then
469 generate_exact seed t id name ~ids_to_inner_types
470 else raise Not_a_proof
471 | C.AMeta (id,n,l) as t ->
472 let sort = Hashtbl.find ids_to_inner_sorts id in
473 if sort = "Prop" then
474 generate_exact seed t id name ~ids_to_inner_types
475 else raise Not_a_proof
476 | C.ASort (id,s) -> raise Not_a_proof
477 | C.AImplicit _ -> raise NotImplemented
478 | C.AProd (_,_,_,_) -> raise Not_a_proof
479 | C.ACast (id,v,t) -> aux v
480 | C.ALambda (id,n,s,t) ->
481 let sort = Hashtbl.find ids_to_inner_sorts id in
482 if sort = "Prop" then
485 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
486 match proof.K.proof_conclude.K.conclude_args with
494 (build_decl_item seed id n s ids_to_inner_sorts)::
495 proof'.K.proof_context
498 generate_intros_let_tac seed id n s true proof'' name ~ids_to_inner_types
499 else raise Not_a_proof
500 | C.ALetIn (id,n,s,t) ->
501 let sort = Hashtbl.find ids_to_inner_sorts id in
502 if sort = "Prop" then
505 if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then
506 match proof.K.proof_conclude.K.conclude_args with
514 ((build_def_item seed id n s ids_to_inner_sorts
515 ids_to_inner_types):> Cic.annterm K.in_proof_context_element)
516 ::proof'.K.proof_context;
519 generate_intros_let_tac seed id n s false proof'' name ~ids_to_inner_types
520 else raise Not_a_proof
523 seed name id li ~ids_to_inner_types ~ids_to_inner_sorts
524 with NotApplicable ->
526 seed name id li ~ids_to_inner_types ~ids_to_inner_sorts
527 with NotApplicable ->
528 let subproofs, args =
529 build_subproofs_and_args
530 seed li ~ids_to_inner_types ~ids_to_inner_sorts in
533 List.filter (test_for_lifting ~ids_to_inner_types) li in
535 match args_to_lift with
536 [_] -> List.map aux args_to_lift
537 | _ -> List.map (aux ~name:"H") args_to_lift in
538 let args = build_args seed li subproofs
539 ~ids_to_inner_types ~ids_to_inner_sorts in *)
540 { K.proof_name = name;
541 K.proof_id = gen_id seed;
542 K.proof_context = [];
543 K.proof_apply_context = serialize seed subproofs;
545 { K.conclude_id = gen_id seed;
546 K.conclude_aref = id;
547 K.conclude_method = "Apply";
548 K.conclude_args = args;
549 K.conclude_conclusion =
551 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
552 with Not_found -> None
555 | C.AConst (id,uri,exp_named_subst) as t ->
556 let sort = Hashtbl.find ids_to_inner_sorts id in
557 if sort = "Prop" then
558 generate_exact seed t id name ~ids_to_inner_types
559 else raise Not_a_proof
560 | C.AMutInd (id,uri,i,exp_named_subst) -> raise Not_a_proof
561 | C.AMutConstruct (id,uri,i,j,exp_named_subst) as t ->
562 let sort = Hashtbl.find ids_to_inner_sorts id in
563 if sort = "Prop" then
564 generate_exact seed t id name ~ids_to_inner_types
565 else raise Not_a_proof
566 | C.AMutCase (id,uri,typeno,ty,te,patterns) ->
567 let inductive_types =
568 (match CicEnvironment.get_obj uri with
569 Cic.Constant _ -> assert false
570 | Cic.Variable _ -> assert false
571 | Cic.CurrentProof _ -> assert false
572 | Cic.InductiveDefinition (l,_,_) -> l
574 let (_,_,_,constructors) = List.nth inductive_types typeno in
575 let teid = get_id te in
577 (fun p (name,_) -> (K.ArgProof (aux ~name p)))
578 patterns constructors in
581 build_subproofs_and_args
582 seed ~ids_to_inner_types ~ids_to_inner_sorts [te]
585 | _ -> assert false) in
586 { K.proof_name = name;
587 K.proof_id = gen_id seed;
588 K.proof_context = [];
589 K.proof_apply_context = serialize seed context;
591 { K.conclude_id = gen_id seed;
592 K.conclude_aref = id;
593 K.conclude_method = "Case";
595 (K.Aux (UriManager.string_of_uri uri))::
596 (K.Aux (string_of_int typeno))::(K.Term ty)::term::pp;
597 K.conclude_conclusion =
599 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
600 with Not_found -> None
603 | C.AFix (id, no, funs) ->
606 (function (_,name,_,_,bo) -> `Proof (aux ~name bo)) funs in
607 let decreasing_args =
608 List.map (function (_,_,n,_,_) -> n) funs in
610 { K.joint_id = gen_id seed;
611 K.joint_kind = `Recursive decreasing_args;
612 K.joint_defs = proofs
615 { K.proof_name = name;
616 K.proof_id = gen_id seed;
617 K.proof_context = [`Joint jo];
618 K.proof_apply_context = [];
620 { K.conclude_id = gen_id seed;
621 K.conclude_aref = id;
622 K.conclude_method = "Exact";
625 { K.premise_id = gen_id seed;
626 K.premise_xref = jo.K.joint_id;
627 K.premise_binder = Some "tiralo fuori";
628 K.premise_n = Some no;
631 K.conclude_conclusion =
633 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
634 with Not_found -> None
637 | C.ACoFix (id,no,funs) ->
640 (function (_,name,_,bo) -> `Proof (aux ~name bo)) funs in
642 { K.joint_id = gen_id seed;
643 K.joint_kind = `CoRecursive;
644 K.joint_defs = proofs
647 { K.proof_name = name;
648 K.proof_id = gen_id seed;
649 K.proof_context = [`Joint jo];
650 K.proof_apply_context = [];
652 { K.conclude_id = gen_id seed;
653 K.conclude_aref = id;
654 K.conclude_method = "Exact";
657 { K.premise_id = gen_id seed;
658 K.premise_xref = jo.K.joint_id;
659 K.premise_binder = Some "tiralo fuori";
660 K.premise_n = Some no;
663 K.conclude_conclusion =
665 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
666 with Not_found -> None
671 generate_conversion seed false id t1 ~ids_to_inner_types
674 and inductive seed name id li ~ids_to_inner_types ~ids_to_inner_sorts =
675 let aux ?name = acic2content seed ~ids_to_inner_types ~ids_to_inner_sorts in
676 let module C2A = Cic2acic in
677 let module K = Content in
678 let module C = Cic in
680 C.AConst (idc,uri,exp_named_subst)::args ->
681 let uri_str = UriManager.string_of_uri uri in
682 let suffix = Str.regexp_string "_ind.con" in
683 let len = String.length uri_str in
684 let n = (try (Str.search_backward suffix uri_str len)
685 with Not_found -> -1) in
686 if n<0 then raise NotApplicable
688 let prefix = String.sub uri_str 0 n in
689 let ind_str = (prefix ^ ".ind") in
690 let ind_uri = UriManager.uri_of_string ind_str in
691 let inductive_types,noparams =
692 (match CicEnvironment.get_obj ind_uri with
693 Cic.Constant _ -> assert false
694 | Cic.Variable _ -> assert false
695 | Cic.CurrentProof _ -> assert false
696 | Cic.InductiveDefinition (l,_,n) -> (l,n)
699 if n = 0 then ([],l) else
700 let p,a = split (n-1) (List.tl l) in
701 ((List.hd l::p),a) in
702 let params_and_IP,tail_args = split (noparams+1) args in
704 (match inductive_types with
706 | _ -> raise NotApplicable) (* don't care for mutual ind *) in
708 let rec clean_up n t =
711 (label,Cic.Prod (_,_,t)) -> clean_up (n-1) (label,t)
712 | _ -> assert false) in
713 List.map (clean_up noparams) constructors in
714 let no_constructors= List.length constructors in
715 let args_for_cases, other_args =
716 split no_constructors tail_args in
717 let subproofs,other_method_args =
718 build_subproofs_and_args seed other_args
719 ~ids_to_inner_types ~ids_to_inner_sorts in
720 prerr_endline "****** end other *******"; flush stderr;
722 let rec build_method_args =
724 [],_-> [] (* extra args are ignored ???? *)
725 | (name,ty)::tlc,arg::tla ->
726 let idarg = get_id arg in
728 (try (Hashtbl.find ids_to_inner_sorts idarg)
729 with Not_found -> "Type") in
731 if sortarg = "Prop" then
735 Cic.Prod (_,s,t),Cic.ALambda(idl,n,s1,t1) ->
738 seed idl n s1 ~ids_to_inner_sorts in
739 if (occur ind_uri s) then
740 ( prerr_endline ("inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
742 Cic.ALambda(id2,n2,s2,t2) ->
745 { K.dec_name = name_of n2;
746 K.dec_id = gen_id seed;
747 K.dec_inductive = true;
751 let (context,body) = bc (t,t2) in
752 (ce::inductive_hyp::context,body)
755 ( prerr_endline ("no inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr;
756 let (context,body) = bc (t,t1) in
758 | _ , t -> ([],aux t) in
762 K.proof_name = Some name;
763 K.proof_context = co;
766 hdarg::(build_method_args (tlc,tla))
767 | _ -> assert false in
768 build_method_args (constructors1,args_for_cases) in
769 { K.proof_name = None;
770 K.proof_id = gen_id seed;
771 K.proof_context = [];
772 K.proof_apply_context = serialize seed subproofs;
774 { K.conclude_id = gen_id seed;
775 K.conclude_aref = id;
776 K.conclude_method = "ByInduction";
778 K.Aux (string_of_int no_constructors)
779 ::K.Term (C.AAppl id ((C.AConst(idc,uri,exp_named_subst))::params_and_IP))
780 ::method_args@other_method_args;
781 K.conclude_conclusion =
783 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
784 with Not_found -> None
787 | _ -> raise NotApplicable
789 and rewrite seed name id li ~ids_to_inner_types ~ids_to_inner_sorts =
790 let aux ?name = acic2content seed ~ids_to_inner_types ~ids_to_inner_sorts in
791 let module C2A = Cic2acic in
792 let module K = Content in
793 let module C = Cic in
795 C.AConst (sid,uri,exp_named_subst)::args ->
796 let uri_str = UriManager.string_of_uri uri in
797 if uri_str = "cic:/Coq/Init/Logic/eq_ind.con" or
798 uri_str = "cic:/Coq/Init/Logic/eq_ind_r.con" then
801 build_subproofs_and_args
802 seed ~ids_to_inner_types ~ids_to_inner_sorts [List.nth args 3]
805 | _,_ -> assert false) in
807 let rec ma_aux n = function
813 let aid = get_id a in
814 let asort = (try (Hashtbl.find ids_to_inner_sorts aid)
815 with Not_found -> "Type") in
816 if asort = "Prop" then
819 hd::(ma_aux (n-1) tl) in
821 { K.proof_name = None;
822 K.proof_id = gen_id seed;
823 K.proof_context = [];
824 K.proof_apply_context = serialize seed subproofs;
826 { K.conclude_id = gen_id seed;
827 K.conclude_aref = id;
828 K.conclude_method = "Rewrite";
830 K.Term (C.AConst (sid,uri,exp_named_subst))::method_args;
831 K.conclude_conclusion =
833 (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized
834 with Not_found -> None
837 else raise NotApplicable
838 | _ -> raise NotApplicable
842 seed ~ids_to_inner_sorts ~ids_to_inner_types (id,n,context,ty)
844 let module K = Content in
848 (id,None) as item -> item
849 | (id,Some (name,Cic.ADecl t)) ->
852 (* We should call build_decl_item, but we have not computed *)
853 (* the inner-types ==> we always produce a declaration *)
855 { K.dec_name = name_of name;
856 K.dec_id = gen_id seed;
857 K.dec_inductive = false;
858 K.dec_aref = get_id t;
861 | (id,Some (name,Cic.ADef t)) ->
864 (* We should call build_def_item, but we have not computed *)
865 (* the inner-types ==> we always produce a declaration *)
867 { K.def_name = name_of name;
868 K.def_id = gen_id seed;
869 K.def_aref = get_id t;
877 let rec annobj2content ~ids_to_inner_sorts ~ids_to_inner_types =
878 let module C = Cic in
879 let module K = Content in
880 let module C2A = Cic2acic in
883 C.ACurrentProof (_,_,n,conjectures,bo,ty,params) ->
884 (gen_id seed, params,
887 (map_conjectures seed ~ids_to_inner_sorts ~ids_to_inner_types)
890 build_def_item seed (get_id bo) (C.Name n) bo
891 ~ids_to_inner_sorts ~ids_to_inner_types))
892 | C.AConstant (_,_,n,Some bo,ty,params) ->
893 (gen_id seed, params, None,
895 build_def_item seed (get_id bo) (C.Name n) bo
896 ~ids_to_inner_sorts ~ids_to_inner_types))
897 | C.AConstant (id,_,n,None,ty,params) ->
898 (gen_id seed, params, None,
900 build_decl_item seed id (C.Name n) ty
901 ~ids_to_inner_sorts))
902 | C.AVariable (_,n,Some bo,ty,params) ->
903 (gen_id seed, params, None,
905 build_def_item seed (get_id bo) (C.Name n) bo
906 ~ids_to_inner_sorts ~ids_to_inner_types))
907 | C.AVariable (id,n,None,ty,params) ->
908 (gen_id seed, params, None,
910 build_decl_item seed id (C.Name n) ty
911 ~ids_to_inner_sorts))
912 | C.AInductiveDefinition (id,l,params,nparams) ->
913 (gen_id seed, params, None,
915 { K.joint_id = gen_id seed;
916 K.joint_kind = `Inductive nparams;
917 K.joint_defs = List.map (build_inductive seed) l
921 build_inductive seed =
922 let module K = Content in
925 { K.inductive_id = gen_id seed;
926 K.inductive_kind = b;
927 K.inductive_type = ty;
928 K.inductive_constructors = build_constructors seed l
932 build_constructors seed l =
933 let module K = Content in
936 { K.dec_name = Some n;
937 K.dec_id = gen_id seed;
938 K.dec_inductive = false;
945 and 'term cinductiveType =
946 id * string * bool * 'term * (* typename, inductive, arity *)
947 'term cconstructor list (* constructors *)
949 and 'term cconstructor =