Menu

#90 inverse slots can cause infinite loop

open
5
2007-05-08
2007-05-08
No

Attached is my MentionUtil .java

Note that:

(1) it was originally version 1.3.6.1 as I have not yet updated to 1.4
(2) there are other changes in the code besides the ones relevant for
this current fix. These are the changes I made for a previous fix, as
discussed on the list
(3) Changes for this new fix are to these methods:

equals(SimpleInstance, SimpleInstance, boolean)

equals(SimpleInstance, List<Object>,
SimpleInstance, List<Object>,
boolean)

compareSlotValues( ... )
compareSlotMentions( ... )

I was beginning to wonder if it was worth continuing with the inverse
slots, and unsure if its implementation would cause other problems.
Interested to hear that you want to use them too, though.

thanks again

Discussion

  • Philip Ogren

    Philip Ogren - 2007-05-08

    MentionUtil.java

     
  • Philip Ogren

    Philip Ogren - 2007-05-08

    Logged In: YES
    user_id=1052182
    Originator: YES

    The following is the original problem pointed out by Angus on the forum:

    I've noticed another problem with creating inverse slots. It can cause an infinite recursion in MentionUtil.equals(SimpleInstance, SimpleInstance, boolean).

    I've seen this occur when creating consensus sets, but perhaps it could occur elsewhere?

    The problem arises because MentionUtil.equals recursively checks slot values for equality. If there is any cycle in slot values back to the original mention, then the infinite recursion starts. This would be a problem in any cyclic definition, but using inverses makes these much more likely.

    The solution that came to my mind was to pass sets of visited mentions through the recursive calls to equals, and break out when we find that we are in a cycle. I've written some code to do this, but it makes the equals method and its friends a bit messy. Also, I am not sure if there are other repercussions to altering equals...

    Note that for most people, there should be no problem - only for those of us who set off on the mad adventure of using inverse slots! (or some other cycle)

    Let me know if you want the code

     

Log in to post a comment.