[ equality of Rules modulo variable renaming
martin.hofmann@uni-bamberg.de**20090211141240] hunk ./src/Data/Rules.hs 6
-    RulePos(..), ruleSubtermAt, lhsSubtermAt, ruleVarPos, compareAtPos,
-    freeVars, hasFreeVars, openPositions, antiunifyRules,matchLhss, 
+    RulePos(..), ruleSubtermAt, lhsSubtermAt, ruleVarPos, sameSymAt,
+    freeVars, hasFreeVars, openPositions, antiunifyRules, matchLhss, 
+    hasVarAt, hasCtorAt,
hunk ./src/Data/Rules.hs 26
+import Data.Maybe
+import Data.Function
+ 
hunk ./src/Data/Rules.hs 30
-import Terms.Class
+import Terms.Class hiding (sameSymAt)
+import qualified Terms.Class as T (sameSymAt)
hunk ./src/Data/Rules.hs 43
- 
hunk ./src/Data/Rules.hs 44
+
hunk ./src/Data/Rules.hs 46
-data Rule = R {lhs :: LHS, rhs :: RHS} deriving( Eq, Ord)
+data Rule = R {lhs :: LHS, rhs :: RHS} deriving(Ord)
+
+instance Eq Rule where
+    (==) a b = (&&) ((equalLs `on` lhs) a b)((equal `on` rhs) a b)
hunk ./src/Data/Rules.hs 107
-compareAtPos :: RulePos -> Rule -> Rule -> Bool
-compareAtPos p@(Arg _ _ ) r1 r2 =
-    case (lhsSubtermAt p r1,lhsSubtermAt p r2) of
-        (Just t1,Just t2) -> sameAtPos t1 t2 Root
-        _otherwise        -> False
-compareAtPos p@(Body _ ) r1 r2 =
-    case (rhsSubtermAt p r1,rhsSubtermAt p r2) of
-        (Just t1,Just t2) -> sameAtPos t1 t2 Root
-        _otherwise        -> False
+hasVarAt :: Rule ->RulePos -> Bool
+hasVarAt (R l _)(Arg i p) = varAtPos (l !! i) p
+hasVarAt (R _ r)(Body p)  = varAtPos r p
+
+hasCtorAt :: Rule -> RulePos -> Bool
+hasCtorAt r p = not $ r `hasVarAt` p
+   
+-- | Returns 'true' if both 'Rule's have the same symbol at the specified position         
+sameSymAt :: RulePos -> Rule -> Rule -> Bool
+sameSymAt (Arg i p) = (T.sameSymAt p) `on`  ((!! i) . lhs)
+sameSymAt (Body p ) = (T.sameSymAt p) `on` rhs 
hunk ./src/Data/Rules.hs 126
-matchLhss :: Rule -> Rule -> LM Bool
-matchLhss r1 r2 
-    | length ls1 == length ls2 = 
-        (liftM and) $ mapM (uncurry matches) (zip ls1 ls2)
-    | otherwise                    = return False
-    where  
-    ls1 = lhs r1
-    ls2 = lhs r2
+matchLhss :: Rule -> Rule -> Bool
+matchLhss = matchesLs `on` lhs
+
+matchRhs :: Rule -> Rule -> Bool
+matchRhs = matches `on` rhs