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