]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_paramodulation/pp.ml
First compiling version
[helm.git] / helm / software / components / ng_paramodulation / pp.ml
index b90c08d385db330b97e903dae90a432041522aea..061dae2b1f86296bf899df8e98caebfb3eb58ae3 100644 (file)
@@ -47,12 +47,14 @@ let string_of_direction = function
 ;;
 
 let pp_substitution ~formatter:f subst =
-     (List.iter
-       (fun (i, t) ->
-          (Format.fprintf f "?%d -> " i;
-          pp_foterm f t)
-       )
-       subst)
+  Format.fprintf f "@[<v 2>";
+  List.iter
+    (fun (i, t) ->
+       (Format.fprintf f "?%d -> " i;
+       pp_foterm f t;
+       Format.fprintf f "@;"))
+    subst;
+  Format.fprintf f "@]";
 ;;
 
 let pp_proof bag ~formatter:f p =
@@ -66,8 +68,8 @@ let pp_proof bag ~formatter:f p =
           eq (string_of_rule rule);
        Format.fprintf f "|%d with %d dir %s))" eq1 eq2
          (string_of_direction dir);
-       let (_, _, _, proof1) = Terms.M.find eq1 bag in
-       let (_, _, _, proof2) = Terms.M.find eq2 bag in
+       let (_, _, _, _, proof1),_,_ = Terms.get_from_bag eq1 bag in
+       let (_, _, _, _, proof2),_,_ = Terms.get_from_bag eq2 bag in
          Format.fprintf f "@[<v 2>";
           aux eq1 proof1;          
           aux eq2 proof2;
@@ -83,42 +85,92 @@ let string_of_comparison = function
   | Terms.Gt -> "=>="
   | Terms.Eq -> "==="
   | Terms.Incomparable -> "=?="
+  | Terms.Invertible -> "=<->="
+
+(*let pp_literal ~formatter:f l =
+    match l with
+      | Terms.Predicate t ->
+         Format.fprintf f "@[<hv>{";
+         pp_foterm f t;
+          Format.fprintf f "@;[%s] by "
+            (String.concat ", " (List.map string_of_int vars));
+          (match proof with
+           | Terms.Exact t -> pp_foterm f t
+           | Terms.Step (rule, id1, id2, _, p, _) -> 
+               Format.fprintf f "%s %d with %d at %s" 
+                 (string_of_rule rule) id1 id2 (String.concat
+                  "," (List.map string_of_int p)));
+          Format.fprintf f "@]"
+      | Terms.Equation (lhs, rhs, ty, comp) ->
+         Format.fprintf f "@[<hv>{";
+         pp_foterm f ty;
+          Format.fprintf f "}:@;@[<hv>";
+         pp_foterm f lhs;
+          Format.fprintf f "@;%s@;" (string_of_comparison comp);
+         pp_foterm f rhs;
+          Format.fprintf f "@]@;[%s] by "
+            (String.concat ", " (List.map string_of_int vars));
+          (match proof with
+           | Terms.Exact t -> pp_foterm f t
+           | Terms.Step (rule, id1, id2, _, p, _) -> 
+               Format.fprintf f "%s %d with %d at %s" 
+                 (string_of_rule rule) id1 id2 (String.concat
+                  "," (List.map string_of_int p)));
+          Format.fprintf f "@]"
+*)
 
 let pp_unit_clause ~formatter:f c =
   let (id, l, vars, proof) = c in
-    Format.fprintf f "Id : %d, " id ;
+    Format.fprintf f "Id : %3d, " id ;
     match l with
       | Terms.Predicate t ->
-         pp_foterm f t
+         Format.fprintf f "@[<hv>{";
+         pp_foterm f t;
+          Format.fprintf f "@;[%s] by "
+            (String.concat ", " (List.map string_of_int vars));
+          (match proof with
+           | Terms.Exact t -> pp_foterm f t
+           | Terms.Step (rule, id1, id2, _, p, _) -> 
+               Format.fprintf f "%s %d with %d at %s" 
+                 (string_of_rule rule) id1 id2 (String.concat
+                  "," (List.map string_of_int p)));
+          Format.fprintf f "@]"
       | Terms.Equation (lhs, rhs, ty, comp) ->
-         Format.fprintf f "{";
+         Format.fprintf f "@[<hv>{";
          pp_foterm f ty;
-         Format.fprintf f "}: ";
+          Format.fprintf f "}:@;@[<hv>";
          pp_foterm f lhs;
-         Format.fprintf f " %s " (string_of_comparison comp);
+          Format.fprintf f "@;%s@;" (string_of_comparison comp);
          pp_foterm f rhs;
-         Format.fprintf f " [%s] by %s"
-            (String.concat ", " (List.map string_of_int vars))
-            (match proof with
-            | Terms.Exact _ -> "axiom"
-            | Terms.Step (rule, id1, id2, _, p, _) -> 
-                 Printf.sprintf "%s %d with %d at %s" 
-                  (string_of_rule rule)
-                  id1 id2 (String.concat
-                 "," (List.map string_of_int p)))
+          Format.fprintf f "@]@;[%s] by "
+            (String.concat ", " (List.map string_of_int vars));
+          (match proof with
+           | Terms.Exact t -> pp_foterm f t
+           | Terms.Step (rule, id1, id2, _, p, _) -> 
+               Format.fprintf f "%s %d with %d at %s" 
+                 (string_of_rule rule) id1 id2 (String.concat
+                  "," (List.map string_of_int p)));
+          Format.fprintf f "@]"
+;;
+
+let pp_clause ~formatter:f c =
+       assert false
 ;;
 
-let pp_bag ~formatter:f bag = 
+let pp_bag ~formatter:f (_,bag) = 
   Format.fprintf f "@[<v>";
   Terms.M.iter 
-  (fun _ c -> pp_unit_clause ~formatter:f c;Format.fprintf f "@;") bag;
+  (fun _ (c,d,_) -> pp_clause ~formatter:f c;
+     if d then Format.fprintf f " (discarded)@;"
+     else Format.fprintf f "@;") bag;
   Format.fprintf f "@]"
 ;;
 
 (* String buffer implementation *)
-let on_buffer f t = 
+let on_buffer ?(margin=80) f t = 
   let buff = Buffer.create 100 in
   let formatter = Format.formatter_of_buffer buff in
+  Format.pp_set_margin formatter margin;
   f ~formatter:formatter t;
   Format.fprintf formatter "@?";
   Buffer.contents buff
@@ -140,8 +192,12 @@ let pp_proof bag =
   on_buffer (pp_proof bag)
 ;;
 
-let pp_unit_clause =
-  on_buffer pp_unit_clause
+let pp_unit_clause ?margin x=
+  on_buffer ?margin pp_unit_clause x
+;;
+
+let pp_clause ?margin x =
+  on_buffer ?margin pp_clause x
 ;;
 
 end