]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/cic/cicUtil.ml
Procedural : cic object preprocessor added
[helm.git] / helm / software / components / cic / cicUtil.ml
index de796910a5c7432a410470a3579a094234d6e782..496452a87bf75f02efaa3344a3742f4592d29406 100644 (file)
@@ -61,7 +61,8 @@ let clean_up_local_context subst metasenv n l =
              None , _ -> None
            | _ , t -> t) cc l
    with 
-       Invalid_argument _ -> assert false)
+       Invalid_argument _ -> 
+        assert false)
 
 let is_closed =
  let module C = Cic in
@@ -165,12 +166,12 @@ let term_of_uri uri =
   | Not_found -> raise (UriManager.IllFormedUri s)
 
 let uri_of_term = function
-  | Cic.Const (uri, [])
-  | Cic.Var (uri, []) -> uri
-  | Cic.MutInd (baseuri, tyno, []) ->
+  | Cic.Const (uri, _)
+  | Cic.Var (uri, _) -> uri
+  | Cic.MutInd (baseuri, tyno, _) ->
      UriManager.uri_of_string
       (sprintf "%s#xpointer(1/%d)" (UriManager.string_of_uri baseuri) (tyno+1))
-  | Cic.MutConstruct (baseuri, tyno, consno, []) ->
+  | Cic.MutConstruct (baseuri, tyno, consno, _) ->
      UriManager.uri_of_string
       (sprintf "%s#xpointer(1/%d/%d)" (UriManager.string_of_uri baseuri)
         (tyno + 1) consno)
@@ -207,6 +208,33 @@ let attributes_of_obj = function
   | Cic.CurrentProof (_, _, _, _, _, attributes)
   | Cic.InductiveDefinition (_, _, _, attributes) ->
       attributes
+
+let is_generated obj = List.exists ((=) `Generated) (attributes_of_obj obj)
+
+let arity_of_composed_coercion obj =
+  let attrs = attributes_of_obj obj in
+  try
+    let tag=List.find (function `Class (`Coercion _) -> true|_->false) attrs in
+    match tag with
+    |  `Class (`Coercion n) -> n
+    | _-> assert false 
+  with Not_found -> 0
+;;
+
+let projections_of_record obj uri =
+  let attrs = attributes_of_obj obj in
+  try
+    let tag=List.find (function `Class (`Record _) -> true|_->false) attrs in
+    match tag with
+    |  `Class (`Record l) -> 
+         List.map (fun (name,_,_) ->
+           let buri = UriManager.buri_of_uri uri in
+           let puri = UriManager.uri_of_string (buri ^ "/" ^ name ^ ".con") in
+           puri) l
+    | _-> assert false 
+  with Not_found -> []
+;;
+      
 let rec mk_rels howmany from =
   match howmany with 
   | 0 -> []