]> matita.cs.unibo.it Git - helm.git/blobdiff - components/acic_procedural/proceduralTypes.ml
CicInspect: a function for counting the nodes of a term has been activated
[helm.git] / components / acic_procedural / proceduralTypes.ml
index bc725d118f1124d3d2d3adf22492677a20a797cc..2d3c915f7234e7ed8b7437086277ec4d77740d85 100644 (file)
  * http://cs.unibo.it/helm/.
  *)
 
-module H = HExtlib
-module C = Cic
-module G = GrafiteAst
-module N = CicNotationPt
+module HEL = HExtlib
+module C   = Cic
+module I   = CicInspect
+module G   = GrafiteAst
+module N   = CicNotationPt
+
+module H   = ProceduralHelpers
 
 (* functions to be moved ****************************************************)
 
@@ -83,7 +86,7 @@ let mk_arel i b = Cic.ARel ("", "", i, b)
 
 (* grafite ast constructors *************************************************)
 
-let floc = H.dummy_floc
+let floc = HEL.dummy_floc
 
 let mk_note str = G.Comment (floc, G.Note (floc, str))
 
@@ -219,3 +222,23 @@ let rec count_step a = function
    | _               -> succ a   
 
 and count_steps a = List.fold_left count_step a
+
+let rec count_node a = function
+   | Note _
+   | Theorem _   
+   | Qed _
+   | Id _
+   | Intros _
+   | Clear _
+   | ClearBody _             -> a
+   | Cut (_, t, _)
+   | LetIn (_, t, _)
+   | Apply (t, _)            -> I.count_nodes a (H.cic t)
+   | Rewrite (_, t, _, p, _)
+   | Elim (t, _, p, _)
+   | Change (t, _, _, p, _)  -> 
+      let a = I.count_nodes a (H.cic t) in
+      I.count_nodes a (H.cic p) 
+   | Branch (ss, _)          -> List.fold_left count_nodes a ss
+
+and count_nodes a = List.fold_left count_node a