Commits

cacol89  committed 6ff424a

added smart negation of inequalities

  • Participants
  • Parent commits 110d5ef

Comments (0)

Files changed (2)

         List.fold_left extract_rterm [] t
     | Query _    -> invalid_arg "function get_all_rule_rterms called with a query"
 
+(*Given an equation, returns the equivalent of a negation of it*)
+let negate_eq = function
+    | Equal (v,c) -> Ineq ("<>",v,c)
+    | Ineq ("<>",v,c) -> Equal (v,c)
+    | Ineq ("<",v,c) -> Ineq (">=",v,c)
+    | Ineq (">",v,c) -> Ineq ("<=",v,c)
+    | Ineq ("<=",v,c) -> Ineq (">",v,c)
+    | Ineq (">=",v,c) -> Ineq ("<",v,c)
+    | _ -> invalid_arg "function negate_eq called without an equation"
 
 (****************************************************
  *

File src/parser.mly

   | predicate							{ Rel $1 }
   | NOT predicate 						{ Not (Rel $2) }
   | equation							{ $1 }
-  | NOT equation					        { Not $2 }
+  | NOT equation					        { negate_eq $2 }
   ;
 
   predicate: