]> matita.cs.unibo.it Git - helm.git/blob - helm/interface/deannotate.ml
Initial revision
[helm.git] / helm / interface / deannotate.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 expect_possible_parameters = ref false;;
27
28 exception NotExpectingPossibleParameters;;
29
30 let rec deannotate_term =
31  let module C = Cic in
32   function
33      C.ARel (_,_,n,_) -> C.Rel n
34    | C.AVar (_,_,uri) -> C.Var uri
35    | C.AMeta (_,_,n) -> C.Meta n
36    | C.ASort (_,_,s) -> C.Sort s
37    | C.AImplicit _ -> C.Implicit
38    | C.ACast (_,_,va,ty) -> C.Cast (deannotate_term va, deannotate_term ty)
39    | C.AProd (_,_,name,so,ta) ->
40       C.Prod (name, deannotate_term so, deannotate_term ta)
41    | C.ALambda (_,_,name,so,ta) ->
42       C.Lambda (name, deannotate_term so, deannotate_term ta)
43    | C.ALetIn (_,_,name,so,ta) ->
44       C.LetIn (name, deannotate_term so, deannotate_term ta)
45    | C.AAppl (_,_,l) -> C.Appl (List.map deannotate_term l)
46    | C.AConst (_,_,uri, cookingsno) -> C.Const (uri, cookingsno)
47    | C.AAbst (_,_,uri) -> C.Abst uri
48    | C.AMutInd (_,_,uri,cookingsno,i) -> C.MutInd (uri,cookingsno,i)
49    | C.AMutConstruct (_,_,uri,cookingsno,i,j) ->
50       C.MutConstruct (uri,cookingsno,i,j)
51    | C.AMutCase (_,_,uri,cookingsno,i,outtype,te,pl) ->
52       C.MutCase (uri,cookingsno,i,deannotate_term outtype,
53        deannotate_term te, List.map deannotate_term pl)
54    | C.AFix (_,_,funno,ifl) ->
55       C.Fix (funno, List.map deannotate_inductiveFun ifl)
56    | C.ACoFix (_,_,funno,ifl) ->
57       C.CoFix (funno, List.map deannotate_coinductiveFun ifl)
58
59 and deannotate_inductiveFun (name,index,ty,bo) =
60  (name, index, deannotate_term ty, deannotate_term bo)
61
62 and deannotate_coinductiveFun (name,ty,bo) =
63  (name, deannotate_term ty, deannotate_term bo)
64 ;;
65
66 let deannotate_inductiveType (name, isinductive, arity, cons) =
67  (name, isinductive, deannotate_term arity,
68   List.map (fun (id,ty,recs) -> (id,deannotate_term ty, recs)) cons)
69 ;;
70
71 let deannotate_obj =
72  let module C = Cic in
73   function
74      C.ADefinition (_, _, id, bo, ty, params) ->
75       (match params with
76           C.Possible params ->
77            if !expect_possible_parameters then
78             C.Definition (id, deannotate_term bo, deannotate_term ty, params)
79            else
80             raise NotExpectingPossibleParameters
81         | C.Actual params ->
82            C.Definition (id, deannotate_term bo, deannotate_term ty, params)
83       )
84    | C.AAxiom (_, _, id, ty, params) ->
85       C.Axiom (id, deannotate_term ty, params)
86    | C.AVariable (_, _, name, bo, ty) ->
87       C.Variable (name,
88        (match bo with None -> None | Some bo -> Some (deannotate_term bo)),
89        deannotate_term ty)
90    | C.ACurrentProof (_, _, name, conjs, bo, ty) ->
91       C.CurrentProof (
92        name, List.map (fun (id,con) -> (id,deannotate_term con)) conjs,
93        deannotate_term bo, deannotate_term ty
94       )
95    | C.AInductiveDefinition (_, _, tys, params, parno) ->
96       C.InductiveDefinition ( List.map deannotate_inductiveType tys,
97        params, parno)
98 ;;