]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic/unshare.ml
ocaml 3.09 transition
[helm.git] / helm / ocaml / cic / unshare.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 rec unshare =
27  let module C = Cic in
28   function
29      C.Rel m -> C.Rel m
30    | C.Var (uri,exp_named_subst) ->
31       let exp_named_subst' = 
32        List.map (function (uri,t) -> (uri,unshare t)) exp_named_subst
33       in
34        C.Var (uri,exp_named_subst')
35    | C.Meta (i,l) ->
36       let l' =
37        List.map
38         (function
39             None -> None
40           | Some t -> Some (unshare t)
41         ) l
42       in
43        C.Meta(i,l')
44    | C.Sort s -> C.Sort s
45    | C.Implicit info -> C.Implicit info
46    | C.Cast (te,ty) -> C.Cast (unshare te, unshare ty)
47    | C.Prod (n,s,t) -> C.Prod (n, unshare s, unshare t)
48    | C.Lambda (n,s,t) -> C.Lambda (n, unshare s, unshare t)
49    | C.LetIn (n,s,t) -> C.LetIn (n, unshare s, unshare t)
50    | C.Appl l -> C.Appl (List.map unshare l)
51    | C.Const (uri,exp_named_subst) ->
52       let exp_named_subst' = 
53        List.map (function (uri,t) -> (uri,unshare t)) exp_named_subst
54       in
55        C.Const (uri,exp_named_subst')
56    | C.MutInd (uri,tyno,exp_named_subst) ->
57       let exp_named_subst' = 
58        List.map (function (uri,t) -> (uri,unshare t)) exp_named_subst
59       in
60        C.MutInd (uri,tyno,exp_named_subst')
61    | C.MutConstruct (uri,tyno,consno,exp_named_subst) ->
62       let exp_named_subst' = 
63        List.map (function (uri,t) -> (uri,unshare t)) exp_named_subst
64       in
65        C.MutConstruct (uri,tyno,consno,exp_named_subst')
66    | C.MutCase (sp,i,outty,t,pl) ->
67       C.MutCase (sp, i, unshare outty, unshare t,
68        List.map unshare pl)
69    | C.Fix (i, fl) ->
70       let len = List.length fl in
71       let liftedfl =
72        List.map
73         (fun (name, i, ty, bo) -> (name, i, unshare ty, unshare bo))
74          fl
75       in
76        C.Fix (i, liftedfl)
77    | C.CoFix (i, fl) ->
78       let len = List.length fl in
79       let liftedfl =
80        List.map
81         (fun (name, ty, bo) -> (name, unshare ty, unshare bo))
82          fl
83       in
84        C.CoFix (i, liftedfl)