IIIM-IS / AERA

Other
12 stars 4 forks source link

In is_evidence, fix is evidence for anti fact target #277

Closed jefft0 closed 1 year ago

jefft0 commented 1 year ago

Background: is_evidence is used to check if a fact is evidence for a target. If two objects have the same object/property but different values, then this is called "counter-evidence" for example consider:

target:   (fact (mk.val h position 5))
evidence: (fact (mk.val h position 10))

If the target position is 5 but the evidence is that the position is 10, then this is counter-evidence. In this case, is_evidence returns MATCH_SUCCESS_NEGATIVE. (This is different than MATCH_FAILURE which means that the two facts are unrelated.)

But now consider if the target is an anti-fact:

target:   (|fact (mk.val h position 5))
evidence: (fact (mk.val h position 10))

The target was to not have position 5, and the evidence is that the position is 10, which is not 5. The target was achieved! The problem is that is_evidence doesn't take into account if the target is an anti-fact and still returns MATCH_SUCCESS_NEGATIVE in this case. This pull request changes it to return MATCH_SUCCESS_POSITIVE in this case.