]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/cic/cicInspect.ml
cicInspect: now we can choose not to count the Cic.Implicit constructors
[helm.git] / helm / software / components / cic / cicInspect.ml
index cc911df84ac902fe9ae43b2284d1eca430a499ad..25efa4cab4108969e83b5025dc7d3fbc322c8514 100644 (file)
@@ -111,34 +111,35 @@ let get_mutinds_of_uri u t =
    let g a = a in
    aux g t S.empty
 
-let rec aux n = function
-   | C.Sort _
-   | C.Implicit _
-   | C.Rel _                      -> succ n
-   | C.Appl ts                    -> List.fold_left aux (succ n) ts
-   | C.Const (_, ss)
-   | C.MutConstruct (_, _, _, ss)
-   | C.MutInd (_, _, ss)
-   | C.Var (_, ss)                -> 
-      let map n (_, t) = aux n t in 
-      List.fold_left map (succ n) ss
-   | C.Meta (_, ss)               ->
-      let map n = function 
-        | None   -> n
-        | Some t -> aux n t
-      in
-      List.fold_left map (succ n) ss
-   | C.Cast (t1, t2)
-   | C.Lambda (_, t1, t2)
-   | C.Prod (_, t1, t2) -> aux (aux (succ n) t2) t1
-   | C.LetIn (_, t1, ty, t2) -> aux (aux (aux (succ n) t2) ty) t1
-   | C.MutCase (_, _, t1, t2, ss) ->
-      aux (aux (List.fold_left aux (succ n) ss) t2) t1
-   | C.Fix (_, ss)                ->
-      let map n (_, _, t1, t2) = aux (aux n t2) t1 in
-      List.fold_left map (succ n) ss
-   | C.CoFix (_, ss)              ->
-      let map n (_, t1, t2) = aux (aux n t2) t1 in
-      List.fold_left map (succ n) ss
-
-let count_nodes = aux
+let count_nodes ~implicit n t =
+   let rec aux n = function
+      | C.Implicit _                 -> if implicit then succ n else n
+      | C.Sort _
+      | C.Rel _                      -> succ n
+      | C.Appl ts                    -> List.fold_left aux (succ n) ts
+      | C.Const (_, ss)
+      | C.MutConstruct (_, _, _, ss)
+      | C.MutInd (_, _, ss)
+      | C.Var (_, ss)                -> 
+         let map n (_, t) = aux n t in 
+         List.fold_left map (succ n) ss
+      | C.Meta (_, ss)               ->
+         let map n = function 
+           | None   -> n
+           | Some t -> aux n t
+         in
+         List.fold_left map (succ n) ss
+      | C.Cast (t1, t2)
+      | C.Lambda (_, t1, t2)
+      | C.Prod (_, t1, t2) -> aux (aux (succ n) t2) t1
+      | C.LetIn (_, t1, ty, t2) -> aux (aux (aux (succ n) t2) ty) t1
+      | C.MutCase (_, _, t1, t2, ss) ->
+         aux (aux (List.fold_left aux (succ n) ss) t2) t1
+      | C.Fix (_, ss)                ->
+         let map n (_, _, t1, t2) = aux (aux n t2) t1 in
+         List.fold_left map (succ n) ss
+      | C.CoFix (_, ss)              ->
+         let map n (_, t1, t2) = aux (aux n t2) t1 in
+         List.fold_left map (succ n) ss
+in
+aux n t