Hi Antonio,<br />Documentation states that the complement to &quot;not&quot; is &quot;exists&quot;, 
whereas &quot;not&quot; keyword is used to match the absence of a fact (in Working
 Memory), and &quot;exists&quot; keyword is used to test the existence of one or 
more facts (in Working memory).<br /> <br />
So if you want to test that a fact is not in working memory, then you 
should&nbsp; use the <br />
not(MyClass()) pattern.<br /> <br />
Hope this helps,<br />
Francois.<br /> <br />
Antonio Neto &lt;antoniosouzaneto@gmail.com&gt; a écrit&nbsp;:<br /> <br />
&gt; Any idea? Please...<br />
&gt;<br />
&gt; 2010/5/4 Antonio Neto &lt;antoniosouzaneto@gmail.com&gt;<br />
&gt;<br />
&gt;&gt; Hi all,<br />
&gt;&gt;<br />
&gt;&gt; I don't know exactly why I have a problem in my &quot;exists&quot; function. I've<br />
&gt;&gt; tried many different ways, but it does not work. Anybody could help me,<br />
&gt;&gt; please?<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt; I have the following rules:<br />
&gt;&gt;<br />
&gt;&gt; *rule &quot;diff&quot;<br />
&gt;&gt; when<br />
&gt;&gt;&nbsp; &nbsp; &nbsp;$var1: EReference(name == &quot;employee&quot;)<br />
&gt;&gt;&nbsp; &nbsp; &nbsp;$var2: EClass(name == &quot;Company&quot;, EAllReferences contains $var1)<br />
&gt;&gt;&nbsp; &nbsp; &nbsp;not (exists( EPackage(EClassifiers contains $var2 ) ))<br />
&gt;&gt; then<br />
&gt;&gt;&nbsp; &nbsp; &nbsp;insertLogical(new IntConstraintOccurrence(&quot;diff&quot;, 10));<br />
&gt;&gt; end<br />
&gt;&gt;<br />
&gt;&gt; rule &quot;ClassesNotReferenced&quot;<br />
&gt;&gt;&nbsp; &nbsp; &nbsp;when<br />
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$q1 : EClass();<br />
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$q2 : EPackage(EClassifiers contains $q1);<br />
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;not( exists ( EReference(EType == $q1) ));<br />
&gt;&gt;&nbsp; &nbsp; &nbsp;then<br />
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insertLogical(new IntConstraintOccurrence(&quot;ClassesNotReferenced&quot;,<br />
&gt;&gt; 1, $q1));<br />
&gt;&gt; end*<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt; and in my facts (and my EPackage) I have 4 instances of EClass &quot;Company&quot;<br />
&gt;&gt; with a EReference &quot;employee&quot;, and another EClass &quot;Person&quot;.&nbsp; I still have a<br />
&gt;&gt; &quot;move&quot; that removes EClasses in my Drools Solver.<br />
&gt;&gt;<br />
&gt;&gt; I need to have only one classe &quot;Company&quot; after processing. But it removes<br />
&gt;&gt; only the EClass &quot;Person&quot;, when it was supposed to remove one EClass &quot;Person&quot;<br />
&gt;&gt; and 3 ECLasses &quot;Company&quot;. Leaving one EClass &quot;Company&quot; in the end.<br />
&gt;&gt;<br />
&gt;&gt; The problem is:&nbsp; when Drools tries to remove a EClass &quot;Person&quot; it thinks<br />
&gt;&gt; that&nbsp; the EClass &quot;Company&quot; does not exists. But in fact there are 3 others.<br />
&gt;&gt;<br />
&gt;&gt; Any clue about it, please ?<br />
&gt;&gt;<br />
&gt;&gt; Thanks<br />
&gt;&gt;<br />
&gt;&gt; Bests regards<br />
&gt;&gt;<br />
&gt;&gt; Antonio<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt;<br />