]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_omdoc/cic2acic.ml
NameExpected exception removed. The "identifier" __n is now returned
[helm.git] / helm / ocaml / cic_omdoc / cic2acic.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 let hashtbl_add_time = ref 0.0;;
27
28 let xxx_add h k v =
29  let t1 = Sys.time () in
30   Hashtbl.add h k v ;
31   let t2 = Sys.time () in
32    hashtbl_add_time := !hashtbl_add_time +. t2 -. t1
33 ;;
34
35 let number_new_type_of_aux' = ref 0;;
36 let type_of_aux'_add_time = ref 0.0;;
37
38 let xxx_type_of_aux' m c t =
39  let t1 = Sys.time () in
40  let res = CicTypeChecker.type_of_aux' m c t in
41  let t2 = Sys.time () in
42  type_of_aux'_add_time := !type_of_aux'_add_time +. t2 -. t1 ;
43  res
44 ;;
45
46 type anntypes =
47  {annsynthesized : Cic.annterm ; annexpected : Cic.annterm option}
48 ;;
49
50 let gen_id seed =
51  let res = "i" ^ string_of_int !seed in
52   incr seed ;
53   res
54 ;;
55
56 let fresh_id seed ids_to_terms ids_to_father_ids =
57  fun father t ->
58   let res = gen_id seed in
59    xxx_add ids_to_father_ids res father ;
60    xxx_add ids_to_terms res t ;
61    res
62 ;;
63
64 let source_id_of_id id = "#source#" ^ id;;
65
66 exception NotEnoughElements;;
67
68 (*CSC: cut&paste da cicPp.ml *)
69 (* get_nth l n   returns the nth element of the list l if it exists or *)
70 (* raises NotEnoughElements if l has less than n elements             *)
71 let rec get_nth l n =
72  match (n,l) with
73     (1, he::_) -> he
74   | (n, he::tail) when n > 1 -> get_nth tail (n-1)
75   | (_,_) -> raise NotEnoughElements
76 ;;
77
78 let acic_of_cic_context' seed ids_to_terms ids_to_father_ids ids_to_inner_sorts
79      ids_to_inner_types metasenv context idrefs t expectedty
80 =
81  let module D = DoubleTypeInference in
82  let module C = Cic in
83   let fresh_id' = fresh_id seed ids_to_terms ids_to_father_ids in
84    let time1 = Sys.time () in
85    let terms_to_types =
86      let time0 = Sys.time () in
87      let prova = CicTypeChecker.type_of_aux' metasenv context t in
88      let time1 = Sys.time () in
89      prerr_endline ("*** Fine type_inference:" ^ (string_of_float (time1 -. time0)));
90      let res = D.double_type_of metasenv context t expectedty in
91      let time2 = Sys.time () in
92    prerr_endline ("*** Fine double_type_inference:" ^ (string_of_float (time2 -. time1)));
93      res 
94    in
95    let time2 = Sys.time () in
96    prerr_endline
97     ("++++++++++++ Tempi della double_type_of: "^ string_of_float (time2 -. time1)) ;
98     let rec aux computeinnertypes father context idrefs tt =
99      let fresh_id'' = fresh_id' father tt in
100      (*CSC: computeinnertypes era true, il che e' proprio sbagliato, no? *)
101      let aux' = aux computeinnertypes (Some fresh_id'') in
102       (* First of all we compute the inner type and the inner sort *)
103       (* of the term. They may be useful in what follows.          *)
104       (*CSC: This is a very inefficient way of computing inner types *)
105       (*CSC: and inner sorts: very deep terms have their types/sorts *)
106       (*CSC: computed again and again.                               *)
107       let string_of_sort t =
108        match CicReduction.whd context t with 
109           C.Sort C.Prop  -> "Prop"
110         | C.Sort C.Set   -> "Set"
111         | C.Sort C.Type  -> "Type"
112         | C.Sort C.CProp -> "CProp"
113         | _              -> assert false
114       in
115        let ainnertypes,innertype,innersort,expected_available =
116 (*CSC: Here we need the algorithm for Coscoy's double type-inference  *)
117 (*CSC: (expected type + inferred type). Just for now we use the usual *)
118 (*CSC: type-inference, but the result is very poor. As a very weak    *)
119 (*CSC: patch, I apply whd to the computed type. Full beta             *)
120 (*CSC: reduction would be a much better option.                       *)
121 (*CSC: solo per testare i tempi *)
122 (*XXXXXXX *)
123         try
124 (* *)
125         let {D.synthesized = synthesized; D.expected = expected} =
126          if computeinnertypes then
127           D.CicHash.find terms_to_types tt
128          else
129           (* We are already in an inner-type and Coscoy's double *)
130           (* type inference algorithm has not been applied.      *)
131           {D.synthesized =
132 (***CSC: patch per provare i tempi
133             CicReduction.whd context (xxx_type_of_aux' metasenv context tt) ; *)
134 Cic.Sort Cic.Type ;
135           D.expected = None}
136         in
137          incr number_new_type_of_aux' ;
138          let innersort = (*XXXXX *) xxx_type_of_aux' metasenv context synthesized (* Cic.Sort Cic.Prop *) in
139           let ainnertypes,expected_available =
140            if computeinnertypes then
141             let annexpected,expected_available =
142                match expected with
143                   None -> None,false
144                 | Some expectedty' ->
145                    Some
146                     (aux false (Some fresh_id'') context idrefs expectedty'),
147                     true
148             in
149              Some
150               {annsynthesized =
151                 aux false (Some fresh_id'') context idrefs synthesized ;
152                annexpected = annexpected
153               }, expected_available
154            else
155             None,false
156           in
157            ainnertypes,synthesized, string_of_sort innersort, expected_available
158 (*XXXXXXXX *)
159         with
160          Not_found ->  (* l'inner-type non e' nella tabella ==> sort <> Prop *)
161           (* CSC: Type or Set? I can not tell *)
162           None,Cic.Sort Cic.Type,"Type",false
163 (* *)
164        in
165         let add_inner_type id =
166          match ainnertypes with
167             None -> ()
168           | Some ainnertypes -> xxx_add ids_to_inner_types id ainnertypes
169         in
170          match tt with
171             C.Rel n ->
172              let id =
173               match get_nth context n with
174                  (Some (C.Name s,_)) -> s
175                | _ -> "__" ^ string_of_int n
176              in
177               xxx_add ids_to_inner_sorts fresh_id'' innersort ;
178               if innersort = "Prop"  && expected_available then
179                add_inner_type fresh_id'' ;
180               C.ARel (fresh_id'', List.nth idrefs (n-1), n, id)
181           | C.Var (uri,exp_named_subst) ->
182              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
183              if innersort = "Prop"  && expected_available then
184               add_inner_type fresh_id'' ;
185              let exp_named_subst' =
186               List.map
187                (function i,t -> i, (aux' context idrefs t)) exp_named_subst
188              in
189               C.AVar (fresh_id'', uri,exp_named_subst')
190           | C.Meta (n,l) ->
191              let (_,canonical_context,_) =
192               List.find (function (m,_,_) -> n = m) metasenv
193              in
194              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
195              if innersort = "Prop"  && expected_available then
196               add_inner_type fresh_id'' ;
197              C.AMeta (fresh_id'', n,
198               (List.map2
199                 (fun ct t ->
200                   match (ct, t) with
201                   | None, _ -> None
202                   | _, Some t -> Some (aux' context idrefs t)
203                   | Some _, None -> assert false (* due to typing rules *))
204                 canonical_context l))
205           | C.Sort s -> C.ASort (fresh_id'', s)
206           | C.Implicit -> C.AImplicit (fresh_id'')
207           | C.Cast (v,t) ->
208              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
209              if innersort = "Prop" then
210               add_inner_type fresh_id'' ;
211              C.ACast (fresh_id'', aux' context idrefs v, aux' context idrefs t)
212           | C.Prod (n,s,t) ->
213               xxx_add ids_to_inner_sorts fresh_id''
214                (string_of_sort innertype) ;
215                     let sourcetype = xxx_type_of_aux' metasenv context s in
216                      xxx_add ids_to_inner_sorts (source_id_of_id fresh_id'')
217                       (string_of_sort sourcetype) ;
218               let n' =
219                match n with
220                   C.Anonymous -> n
221                 | C.Name n' ->
222                    if DoubleTypeInference.does_not_occur 1 t then
223                     C.Anonymous
224                    else
225                     C.Name n'
226               in
227                C.AProd
228                 (fresh_id'', n', aux' context idrefs s,
229                  aux' ((Some (n, C.Decl s))::context) (fresh_id''::idrefs) t)
230           | C.Lambda (n,s,t) ->
231              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
232                    let sourcetype = xxx_type_of_aux' metasenv context s in
233                     xxx_add ids_to_inner_sorts (source_id_of_id fresh_id'')
234                      (string_of_sort sourcetype) ;
235               if innersort = "Prop" then
236                begin
237                 let father_is_lambda =
238                  match father with
239                     None -> false
240                   | Some father' ->
241                      match Hashtbl.find ids_to_terms father' with
242                         C.Lambda _ -> true
243                       | _ -> false
244                 in
245                  if (not father_is_lambda) || expected_available then
246                   add_inner_type fresh_id''
247                end ;
248               C.ALambda
249                (fresh_id'',n, aux' context idrefs s,
250                 aux' ((Some (n, C.Decl s)::context)) (fresh_id''::idrefs) t)
251           | C.LetIn (n,s,t) ->
252              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
253              if innersort = "Prop" then
254               add_inner_type fresh_id'' ;
255              C.ALetIn
256               (fresh_id'', n, aux' context idrefs s,
257                aux' ((Some (n, C.Def(s,None)))::context) (fresh_id''::idrefs) t)
258           | C.Appl l ->
259              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
260              if innersort = "Prop" then
261               add_inner_type fresh_id'' ;
262              C.AAppl (fresh_id'', List.map (aux' context idrefs) l)
263           | C.Const (uri,exp_named_subst) ->
264              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
265              if innersort = "Prop"  && expected_available then
266               add_inner_type fresh_id'' ;
267              let exp_named_subst' =
268               List.map
269                (function i,t -> i, (aux' context idrefs t)) exp_named_subst
270              in
271               C.AConst (fresh_id'', uri, exp_named_subst')
272           | C.MutInd (uri,tyno,exp_named_subst) ->
273              let exp_named_subst' =
274               List.map
275                (function i,t -> i, (aux' context idrefs t)) exp_named_subst
276              in
277               C.AMutInd (fresh_id'', uri, tyno, exp_named_subst')
278           | C.MutConstruct (uri,tyno,consno,exp_named_subst) ->
279              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
280              if innersort = "Prop"  && expected_available then
281               add_inner_type fresh_id'' ;
282              let exp_named_subst' =
283               List.map
284                (function i,t -> i, (aux' context idrefs t)) exp_named_subst
285              in
286               C.AMutConstruct (fresh_id'', uri, tyno, consno, exp_named_subst')
287           | C.MutCase (uri, tyno, outty, term, patterns) ->
288              xxx_add ids_to_inner_sorts fresh_id'' innersort ;
289              if innersort = "Prop" then
290               add_inner_type fresh_id'' ;
291              C.AMutCase (fresh_id'', uri, tyno, aux' context idrefs outty,
292               aux' context idrefs term, List.map (aux' context idrefs) patterns)
293           | C.Fix (funno, funs) ->
294              let fresh_idrefs =
295               List.map (function _ -> gen_id seed) funs in
296              let new_idrefs = List.rev fresh_idrefs @ idrefs in
297              let tys =
298               List.map (fun (name,_,ty,_) -> Some (C.Name name, C.Decl ty)) funs
299              in
300               xxx_add ids_to_inner_sorts fresh_id'' innersort ;
301               if innersort = "Prop" then
302                add_inner_type fresh_id'' ;
303               C.AFix (fresh_id'', funno,
304                List.map2
305                 (fun id (name, indidx, ty, bo) ->
306                   (id, name, indidx, aux' context idrefs ty,
307                     aux' (tys@context) new_idrefs bo)
308                 ) fresh_idrefs funs
309              )
310           | C.CoFix (funno, funs) ->
311              let fresh_idrefs =
312               List.map (function _ -> gen_id seed) funs in
313              let new_idrefs = List.rev fresh_idrefs @ idrefs in
314              let tys =
315               List.map (fun (name,ty,_) -> Some (C.Name name, C.Decl ty)) funs
316              in
317               xxx_add ids_to_inner_sorts fresh_id'' innersort ;
318               if innersort = "Prop" then
319                add_inner_type fresh_id'' ;
320               C.ACoFix (fresh_id'', funno,
321                List.map2
322                 (fun id (name, ty, bo) ->
323                   (id, name, aux' context idrefs ty,
324                     aux' (tys@context) new_idrefs bo)
325                 ) fresh_idrefs funs
326               )
327         in
328          let timea = Sys.time () in
329          let res = aux true None context idrefs t in
330          let timeb = Sys.time () in
331           prerr_endline
332            ("+++++++++++++ Tempi della aux dentro alla acic_of_cic: "^ string_of_float (timeb -. timea)) ;
333           res
334 ;;
335
336 let acic_of_cic_context metasenv context idrefs t =
337  let ids_to_terms = Hashtbl.create 503 in
338  let ids_to_father_ids = Hashtbl.create 503 in
339  let ids_to_inner_sorts = Hashtbl.create 503 in
340  let ids_to_inner_types = Hashtbl.create 503 in
341  let seed = ref 0 in
342    acic_of_cic_context' seed ids_to_terms ids_to_father_ids ids_to_inner_sorts
343     ids_to_inner_types metasenv context idrefs t,
344    ids_to_terms, ids_to_father_ids, ids_to_inner_sorts, ids_to_inner_types
345 ;;
346
347 let aconjecture_of_conjecture seed ids_to_terms ids_to_father_ids 
348   ids_to_inner_sorts ids_to_inner_types ids_to_hypotheses hypotheses_seed
349   metasenv (metano,context,goal) = 
350   let acic_of_cic_context =
351     acic_of_cic_context' seed ids_to_terms ids_to_father_ids ids_to_inner_sorts
352       ids_to_inner_types  metasenv in
353   let _, acontext,final_idrefs =
354     (List.fold_right
355       (fun binding (context, acontext,idrefs) ->
356          let hid = "h" ^ string_of_int !hypotheses_seed in
357            Hashtbl.add ids_to_hypotheses hid binding ;
358            incr hypotheses_seed ;
359            match binding with
360                Some (n,Cic.Def (t,None)) ->
361                  let acic = acic_of_cic_context context idrefs t None in
362                  (binding::context),
363                    ((hid,Some (n,Cic.ADef acic))::acontext),(hid::idrefs)
364              | Some (n,Cic.Decl t) ->
365                  let acic = acic_of_cic_context context idrefs t None in
366                  (binding::context),
367                    ((hid,Some (n,Cic.ADecl acic))::acontext),(hid::idrefs)
368              | None ->
369                  (* Invariant: "" is never looked up *)
370                   (None::context),((hid,None)::acontext),""::idrefs
371              | Some (_,Cic.Def (_,Some _)) -> assert false
372          ) context ([],[],[])
373        )
374   in 
375   let agoal = acic_of_cic_context context final_idrefs goal None in
376   (metano,acontext,agoal)
377 ;;
378
379 let asequent_of_sequent (metasenv:Cic.metasenv) (sequent:Cic.conjecture) = 
380     let ids_to_terms = Hashtbl.create 503 in
381     let ids_to_father_ids = Hashtbl.create 503 in
382     let ids_to_inner_sorts = Hashtbl.create 503 in
383     let ids_to_inner_types = Hashtbl.create 503 in
384     let ids_to_hypotheses = Hashtbl.create 23 in
385     let hypotheses_seed = ref 0 in
386     let seed = ref 1 in (* 'i0' is used for the whole sequent *)
387     let (metano,acontext,agoal) = 
388       aconjecture_of_conjecture seed ids_to_terms ids_to_father_ids 
389       ids_to_inner_sorts ids_to_inner_types ids_to_hypotheses hypotheses_seed
390       metasenv sequent in
391     ("i0",metano,acontext,agoal), 
392      ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,ids_to_hypotheses
393 ;;
394
395 let acic_object_of_cic_object obj =
396  let module C = Cic in
397  let module E = Eta_fixing in
398   let ids_to_terms = Hashtbl.create 503 in
399   let ids_to_father_ids = Hashtbl.create 503 in
400   let ids_to_inner_sorts = Hashtbl.create 503 in
401   let ids_to_inner_types = Hashtbl.create 503 in
402   let ids_to_conjectures = Hashtbl.create 11 in
403   let ids_to_hypotheses = Hashtbl.create 127 in
404   let hypotheses_seed = ref 0 in
405   let conjectures_seed = ref 0 in
406   let seed = ref 0 in
407   let acic_term_of_cic_term_context' =
408    acic_of_cic_context' seed ids_to_terms ids_to_father_ids ids_to_inner_sorts
409     ids_to_inner_types in
410   let acic_term_of_cic_term' = acic_term_of_cic_term_context' [] [] [] in
411   let aconjecture_of_conjecture' = aconjecture_of_conjecture seed 
412     ids_to_terms ids_to_father_ids ids_to_inner_sorts ids_to_inner_types 
413     ids_to_hypotheses hypotheses_seed in 
414    let aobj =
415     match obj with
416       C.Constant (id,Some bo,ty,params) ->
417        let bo' = E.eta_fix [] bo in
418        let ty' = E.eta_fix [] ty in
419        let abo = acic_term_of_cic_term' bo' (Some ty') in
420        let aty = acic_term_of_cic_term' ty' None in
421         C.AConstant
422          ("mettereaposto",Some "mettereaposto2",id,Some abo,aty,params)
423     | C.Constant (id,None,ty,params) ->
424        let ty' = E.eta_fix [] ty in
425        let aty = acic_term_of_cic_term' ty' None in
426         C.AConstant
427          ("mettereaposto",None,id,None,aty,params)
428     | C.Variable (id,bo,ty,params) ->
429        let ty' = E.eta_fix [] ty in
430        let abo =
431         match bo with
432            None -> None
433          | Some bo ->
434             let bo' = E.eta_fix [] bo in
435              Some (acic_term_of_cic_term' bo' (Some ty'))
436        in
437        let aty = acic_term_of_cic_term' ty' None in
438         C.AVariable
439          ("mettereaposto",id,abo,aty, params)
440     | C.CurrentProof (id,conjectures,bo,ty,params) ->
441        let conjectures' =
442         List.map
443          (function (i,canonical_context,term) ->
444            let canonical_context' =
445             List.map
446              (function
447                  None -> None
448                | Some (n, C.Decl t)-> Some (n, C.Decl (E.eta_fix conjectures t))
449                | Some (n, C.Def (t,None)) ->
450                   Some (n, C.Def ((E.eta_fix conjectures t),None))
451                | Some (_,C.Def (_,Some _)) -> assert false
452              ) canonical_context
453            in
454            let term' = E.eta_fix conjectures term in
455             (i,canonical_context',term')
456          ) conjectures
457        in
458        let aconjectures = 
459         List.map
460          (function (i,canonical_context,term) as conjecture ->
461            let cid = "c" ^ string_of_int !conjectures_seed in
462             xxx_add ids_to_conjectures cid conjecture ;
463             incr conjectures_seed ;
464            let (i,acanonical_context,aterm) 
465              = aconjecture_of_conjecture' conjectures conjecture in
466            (cid,i,acanonical_context,aterm))
467           conjectures' in 
468 (*           let idrefs',revacanonical_context =
469              let rec aux context idrefs =
470               function
471                  [] -> idrefs,[]
472                | hyp::tl ->
473                   let hid = "h" ^ string_of_int !hypotheses_seed in
474                   let new_idrefs = hid::idrefs in
475                    xxx_add ids_to_hypotheses hid hyp ;
476                    incr hypotheses_seed ;
477                    match hyp with
478                       (Some (n,C.Decl t)) ->
479                         let final_idrefs,atl =
480                          aux (hyp::context) new_idrefs tl in
481                         let at =
482                          acic_term_of_cic_term_context'
483                           conjectures context idrefs t None
484                         in
485                          final_idrefs,(hid,Some (n,C.ADecl at))::atl
486                     | (Some (n,C.Def (t,_))) ->
487                         let final_idrefs,atl =
488                          aux (hyp::context) new_idrefs tl in
489                         let at =
490                          acic_term_of_cic_term_context'
491                           conjectures context idrefs t None
492                         in
493                          final_idrefs,(hid,Some (n,C.ADef at))::atl
494                     | None ->
495                        let final_idrefs,atl =
496                         aux (hyp::context) new_idrefs tl
497                        in
498                         final_idrefs,(hid,None)::atl
499              in
500               aux [] [] (List.rev canonical_context) 
501             in
502              let aterm =
503               acic_term_of_cic_term_context' conjectures
504                canonical_context idrefs' term None 
505              in
506               (cid,i,(List.rev revacanonical_context),aterm) 
507          ) conjectures' in *)
508        let time1 = Sys.time () in
509        let bo' = E.eta_fix conjectures' bo in
510        let ty' = E.eta_fix conjectures' ty in
511        let time2 = Sys.time () in
512        prerr_endline
513         ("++++++++++ Tempi della eta_fix: "^ string_of_float (time2 -. time1)) ;
514        hashtbl_add_time := 0.0 ;
515        type_of_aux'_add_time := 0.0 ;
516        DoubleTypeInference.syntactic_equality_add_time := 0.0 ;
517        let abo =
518         acic_term_of_cic_term_context' conjectures' [] [] bo' (Some ty') in
519        let aty = acic_term_of_cic_term_context' conjectures' [] [] ty' None in
520        let time3 = Sys.time () in
521        prerr_endline
522         ("++++++++++++ Tempi della hashtbl_add_time: " ^ string_of_float !hashtbl_add_time) ;
523        prerr_endline
524         ("++++++++++++ Tempi della type_of_aux'_add_time(" ^ string_of_int !number_new_type_of_aux' ^ "): " ^ string_of_float !type_of_aux'_add_time) ;
525        prerr_endline
526         ("++++++++++++ Tempi della type_of_aux'_add_time nella double_type_inference(" ^ string_of_int !DoubleTypeInference.number_new_type_of_aux'_double_work ^ ";" ^ string_of_int !DoubleTypeInference.number_new_type_of_aux'_prop ^ "/" ^ string_of_int !DoubleTypeInference.number_new_type_of_aux' ^ "): " ^ string_of_float !DoubleTypeInference.type_of_aux'_add_time) ;
527        prerr_endline
528         ("++++++++++++ Tempi della syntactic_equality_add_time: " ^ string_of_float !DoubleTypeInference.syntactic_equality_add_time) ;
529        prerr_endline
530         ("++++++++++ Tempi della acic_of_cic: " ^ string_of_float (time3 -. time2)) ;
531        prerr_endline
532         ("++++++++++ Numero di iterazioni della acic_of_cic: " ^ string_of_int !seed) ;
533         C.ACurrentProof
534          ("mettereaposto","mettereaposto2",id,aconjectures,abo,aty,params)
535     | C.InductiveDefinition (tys,params,paramsno) ->
536        let context =
537         List.map
538          (fun (name,_,arity,_) -> Some (C.Name name, C.Decl arity)) tys in
539        let idrefs = List.map (function _ -> gen_id seed) tys in
540        let atys =
541         List.map2
542          (fun id (name,inductive,ty,cons) ->
543            let acons =
544             List.map
545              (function (name,ty) ->
546                (name,
547                  acic_term_of_cic_term_context' [] context idrefs ty None)
548              ) cons
549            in
550             (id,name,inductive,acic_term_of_cic_term' ty None,acons)
551          ) (List.rev idrefs) tys
552        in
553         C.AInductiveDefinition ("mettereaposto",atys,params,paramsno)
554    in
555     aobj,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,ids_to_inner_types,
556      ids_to_conjectures,ids_to_hypotheses
557 ;;
558
559