]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/acic_procedural/proceduralTypes.ml
librarian: retrieval of buildable files speeded up a lot
[helm.git] / helm / software / components / acic_procedural / proceduralTypes.ml
index bc725d118f1124d3d2d3adf22492677a20a797cc..6534b872538b0912e4e1d8ce75fa72a2a434a604 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))
 
@@ -131,8 +134,9 @@ let mk_letin name what punctation =
 let mk_rewrite direction what where pattern punctation =
    let direction = if direction then `RightToLeft else `LeftToRight in 
    let pattern, rename = match where with
-      | None                 -> (None, [], Some pattern), []
-      | Some (premise, name) -> (None, [premise, pattern], None), [name] 
+      | None                      -> (None, [], Some pattern), []
+      | Some (premise, Some name) -> (None, [premise, pattern], None), [Some name]
+      | Some (premise, None)      -> (None, [premise, pattern], None), [] 
    in
    let tactic = G.Rewrite (floc, direction, what, pattern, rename) in
    mk_tactic tactic punctation
@@ -143,7 +147,7 @@ let mk_elim what using pattern punctation =
    mk_tactic tactic punctation
 
 let mk_apply t punctation =
-   let tactic = G.Apply (floc, t) in
+   let tactic = G.ApplyP (floc, t) in
    mk_tactic tactic punctation
 
 let mk_change t where pattern punctation =
@@ -205,7 +209,7 @@ and render_steps sep a = function
    | p :: ((Branch (_ :: _ :: _, _) :: _) as ps) ->
       render_steps sep (render_step mk_sc a p) ps
    | p :: ps                                     ->
-      render_steps sep (render_step mk_dot a p) ps
+      render_steps sep (render_step mk_sc a p) ps
 
 let render_steps a = render_steps mk_dot a
 
@@ -219,3 +223,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