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