/** * Compare clause entries, taking into account variable indices. * The equality function ignores differences between variables. */ @Override public boolean sameAs(Object o) { return equals(o); }
/** * Compare clause entries, taking into account variable indices. * The equality function ignores differences between variables. */ @Override public boolean sameAs(Object o) { return equals(o); }
/** * Compare two derivations. This is a shallow comparison, two derivations * are the same if they contain the same conclusion, rule and match list. * They do not need to be derived from the same (or any) infGraph. */ @Override public boolean equals(Object other) { if (other instanceof RuleDerivation) { RuleDerivation otherD = (RuleDerivation)other; return conclusion.equals(otherD.getConclusion()) && matches.equals(otherD.getMatches()) && rule.equals(otherD.getRule()); } else { return false; } } }
/** * Compare two derivations. This is a shallow comparison, two derivations * are the same if they contain the same conclusion, rule and match list. * They do not need to be derived from the same (or any) infGraph. */ @Override public boolean equals(Object other) { if (other instanceof RuleDerivation) { RuleDerivation otherD = (RuleDerivation)other; return conclusion.equals(otherD.getConclusion()) && matches.equals(otherD.getMatches()) && rule.equals(otherD.getRule()); } else { return false; } } }
/** * Test rule equality operations. */ public void testRuleEquality() { Rule r1 = Rule.parseRule("(?a p ?b) -> (?a q ?b)."); Rule r2 = Rule.parseRule("(?a p ?b) -> (?b q ?a)."); Rule r1b = Rule.parseRule("(?x p ?y) -> (?x q ?y)."); Rule r3 = Rule.parseRule("(?a p ?b), addOne(?a) -> (?a q ?b)."); Rule r3b = Rule.parseRule("(?c p ?d), addOne(?c) -> (?c q ?d)."); Rule r4 = Rule.parseRule("(?a p ?b), makeTemp(?a) -> (?a q ?b)."); Rule r5 = Rule.parseRule("(?a p ?b), addOne(?b) -> (?a q ?b)."); Rule r6 = Rule.parseRule("(?a p ?b), addOne(p) -> (?a q ?b)."); assertTrue(! r1.equals(r2)); assertTrue( r1.equals(r1b)); assertTrue(! r1.equals(r3)); assertTrue( r3.equals(r3b)); assertTrue(! r3.equals(r4)); assertTrue(! r3.equals(r5)); assertTrue(! r3.equals(r6)); }
/** * Test rule equality operations. */ public void testRuleEquality() { Rule r1 = Rule.parseRule("(?a p ?b) -> (?a q ?b)."); Rule r2 = Rule.parseRule("(?a p ?b) -> (?b q ?a)."); Rule r1b = Rule.parseRule("(?x p ?y) -> (?x q ?y)."); Rule r3 = Rule.parseRule("(?a p ?b), addOne(?a) -> (?a q ?b)."); Rule r3b = Rule.parseRule("(?c p ?d), addOne(?c) -> (?c q ?d)."); Rule r4 = Rule.parseRule("(?a p ?b), makeTemp(?a) -> (?a q ?b)."); Rule r5 = Rule.parseRule("(?a p ?b), addOne(?b) -> (?a q ?b)."); Rule r6 = Rule.parseRule("(?a p ?b), addOne(p) -> (?a q ?b)."); assertTrue(! r1.equals(r2)); assertTrue( r1.equals(r1b)); assertTrue(! r1.equals(r3)); assertTrue( r3.equals(r3b)); assertTrue(! r3.equals(r4)); assertTrue(! r3.equals(r5)); assertTrue(! r3.equals(r6)); }