1) For performance purposes, I want to discard a group of rules from being 
   pattern matched. Each module has its agenda and although rules belonging to
   a module which is not on the stack will not fire, they are however tested 
   for pattern matching at each cycle. How can I prevent the pattern matching?   

   For the purposes of pattern matching, modules are separate. That is, if two 
   modules do not share common patterns (by sharing the same deftemplates), 
   then facts asserted in one module are not compared to the patterns of the 
   other module. Thus, if two modules share a common deftemplate, they both 
   perform pattern matching whenever a fact of the shared deftemplate is 
   asserted or retracted. The alternative would be to delay the pattern  
   matching of assertion and retraction of facts for a specific module until 
   the module is focused upon. Instead of attaching the data structures for 
   pattern matching to a specific deftemplate, they would be attached to a 
   specific module. Unless the pattern matching algorithm was extremely 
   sophisticated, this could potentially have the exact opposite effect of 
   improving performance--Performance could be degraded because common
   patterns used in separate modules wouldn't be shared.

   To achieve the behavior of delayed pattern matching, place control patterns 
   in your rules. For example:

   (defrule A::example
     (module A active)
     (fact 1 ?x)
     (fact 2 ?x)
     =>
     (assert (fact 3 ?x)))

   In this example, the expensive part of pattern matching (comparing variables 
   across patterns) will not occur unless the control fact (module A active)  
   has been asserted. Just assert the control facts when you focus on a module 
   and retract them when the module is done. This will force the expensive part 
   of pattern matching to occur only when the module is the current focus.

2) I want rules from two different modules be be shared on one agenda at the 
   same time. For instance, I would like to mix rules of the MAIN module (rules 
   which are common for all modules but have to fire in between more specific 
   rules) with rules of a particular module. It seems to me that it is not 
   possible because of the separate agendas for each module. How can this
   behavior be achieved?

   Under certain circumstances, the auto-focus feature can be used to achieve
   this behavior. The dilemma1.clp example program shows how this feature is 
   used to interrupt the search for a problem solution when constraint 
   violations are detected or a solution is found.

