In this particular case you can do<br><br> $p1:person (name==&quot;Alice&quot;)<br>
  $p3:person (name==&quot;David&quot;, this after[0,1] $p1)<br> not person (name != &quot;Bob&quot;, this after[0,1] $p1 &amp;&amp; before[0,1] $p3 ) <br><br>A more general approach should be possible by monitoring states rather than event sequences, especially if you process events in real time. <br>
<br>1) Alice =&gt; state := A<br>2a) David =&gt; OK<br>2b) Bob  =&gt; state := AB<br>2c) Edward =&gt; state := _<br><br>And so on.<br>-W<br><br><br><br><div class="gmail_quote">On 20 July 2011 22:21, Edward Johnson <span dir="ltr">&lt;<a href="mailto:ejohnson@coderyte.com">ejohnson@coderyte.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">How do you do rules that are a sequence of events where some of them are optional?<br>
<br>
Example:<br>
<br>
Alert if DAVID enters a room after ALICE or after ALICE and BOB<br>
If it were a string, this is roughly equivalant to the regex /ALICE( BOB)? DAVID/<br>
<br>
So:<br>
Alice then David =&gt; alert<br>
Alice then Bob then David =&gt; alert<br>
Alice then Charles then David =&gt; no alert<br>
<br>
I could write this as two rules but as the rules get more complex it could by hard to manage the resulting combatorial explosion.  Here it is as two rules:<br>
<br>
Rule 1:<br>
  $p1:person (name==&quot;Alice&quot;)<br>
  $p2:person (name==&quot;David&quot;, this after[0,1] $p1)<br>
<br>
Rule 2:<br>
  $p1:person (name==&quot;Alice&quot;)<br>
  $p2:person (name==&quot;Bob&quot;, this after[0,1] $p1)<br>
  $p3:person (name==&quot;David&quot;, this after[0,1] $p2)<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>