<br>
Given classes Switch and Track, and the &quot;natural&quot; class hierarchy representing state changes for these two elements:<br>
   ElementState<br>
   TrackState extends ElementState (&quot;free/occupied&quot;)<br>
   SwitchState extends TrackState (adds &quot;left/right/moving&quot;)<br>Now we have rules for updating Switch and Track elements, like this one:<br>
   rule &quot;Xyz state update&quot;  <br>
   when<br>
       $s: XyzState( $id: id, ... )<br>
       $e: Xyz( id == $id )<br>
   then<br>
     //...update $e, retract $s<br>
   end<br>
and, since we want to catch bad ids, also<br>
   rule &quot;Xyz state for unknown element&quot;<br>
   when<br>
      $s: XyzState( $id: id )<br>
      not Xyz( id == $id )<br>
  then<br>
      //... diagnostic, retract $s<br>
  end<br>
<br>
Best practice, wouldn&#39;t you say?<br><br>Testing by inserting a few of SwitchState objects works fine:<br>   updated: Switch 5 RIGHT occupied<br>   updated: Switch 2 RIGHT<br>   updated: Switch 1 RIGHT occupied<br> so everything is allright, wouldn&#39;t you say? <br>

<br>Add another SwitchState for Switch &quot;4&quot; to the test, and suddenly:<br>  updated: Switch 4 RIGHT<br>  track state for unknown element 5<br>  updated: Switch 2 RIGHT<br>  updated: Switch 1 RIGHT occupied<br>What&#39;s this?!<br>
<br>After some headscratching I realized that the negative rule for the SwitchState&#39;s superclass TrackState produces another activation, since, for any Switch element with an id x there clearly isn&#39;t a Track element with id x! This activation <i>occasionally </i>precedes the activation for the match in the &quot;update&quot; rule.<br>
<br>This is annoying. Of course, negative salience for the &quot;not&quot; rules fixes this, but who would have thought that you need it with conditions (seemingly!) describing disjoint situations. And the negative salience is counter-intuitive, since normally you&#39;d perform the check &quot;no such element&quot; <i>before </i>permitting any update action.<br>
<br>Remarkable.<br>Wolfgang<br><br><br><br> <br> <br><br><br>