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