(clear)
(defrule r1 =>))
(defrule r2 (a) => (assert (b)))
(defrule r3 ?f <- (y) ?g <- (a2) => (retract ?f) (if (> 3 4) then (retract ?g)))
(defrule r4 ?f <- (x) => (retract ?f) (assert (x)))
(defrule r5 (or (x) (y) (and (a) (b))) => (assert (a3)))
(defrule r6 (and (a) (b)) (c) => (assert (a2)))
(defrule * (not (x)) (not (y)) => (assert (x)) (assert (y)))
(list-defrules d6)
(rules)
(ppdefrule r1)
(ppdefrule r2)
(ppdefrule r3)
(ppdefrule r4)
(ppdefrule r5)
(ppdefrule r6)
(ppdefrule *)
(undefrule)
(undefrule 10)
(undefrule bad-name)
(undefrule r6 10)
(list-defrules)
(undefrule r1)
(undefrule r2)
(undefrule r3)
(list-defrules)
(undefrule *)
(list-defrules)
(undefrule *)
(list-defrules)
(clear) ; Test deleting a rule by itself
(defrule foo => (undefrule foo))
(rules)
(reset)
(run)
(rules)
(clear) ; Test loading another KB
(defrule foo1 (a) => (assert (f)))
(defrule foo2 (b) (f) => (assert (g)))
(defrule foo3 (c) (g) =>)
(save "Temp//foo.tmp")
(clear)
(defrule bar1 => (assert (a)))
(defrule bar2 (a) => (assert (b)))
(defrule bar3 (b) 
   => 
   (assert (c)) 
   (rules)
   (printout t "-------" crlf)
   (undefrule *)
   (rules)
   (printout t "-------" crlf)
   (load "Temp//foo.tmp")
   (rules)
   (printout t "-------" crlf))
(defrule bar4 (a) (b) (c) =>)
(reset)
(watch rules)
(watch activations)
(watch facts)
(run)
(unwatch all)
(clear) ; Test agenda command
(agenda)
(agenda 20)
(defrule foo1 (declare (salience 2)) =>)
(defrule foo2 (declare (salience 1)) =>)
(defrule foo3 (declare (salience 0)) =>)
(reset)
(agenda)
(run 1)
(agenda)
(run 1)
(agenda)
(run 1)
(agenda)
(clear) ; Test matches command
(matches)
(matches 10)
(matches bad-rule)
(defrule foo (or (a ?x) (b ?x)) (c ?) =>)
(defrule bar (b ?x) (c ?x) (a ?) =>)
(defrule yaz (q) (r) =>)
(defrule flx (b ?x) (not (c ?x)) (a ?x) =>)
(assert (a 1) (a 2) (a 3) (b 1) (b 2) (c 1))
(matches foo)
(matches bar)
(matches yaz)
(matches flx)
(clear) ; Test breakpoint stuff
(set-break)
(set-break 10)
(set-break bad-rule)
(show-breaks)
(show-breaks 10)
(remove-break)
(remove-break 10)
(remove-break bad-rule)
(defrule foo1 (declare (salience 4)) =>)
(defrule foo2 (declare (salience 3)) =>)
(defrule foo3 (declare (salience 2)) =>)
(defrule foo4 (declare (salience 1)) => (assert (a)))
(defrule foo5 (declare (salience 0)) => (assert (b)))
(defrule foo6 (declare (salience 5)) (or (a) (b)) =>)
(set-break foo5 10)
(remove-break foo5 10)
(show-breaks)
(set-break foo2)
(set-break foo4)
(set-break foo6)
(show-breaks)
(watch rules)
(reset)
(run)
(run)
(run)
(run)
(remove-break foo4)
(show-breaks)
(remove-break foo6)
(reset)
(run)
(run)
(set-break foo3)
(remove-break)
(reset)
(run)
(unwatch all)
(clear) ; Test refresh command
(refresh)
(refresh 10)
(refresh bad-rule)
(defrule foo (a ?) (b ?) =>)
(assert (a 1) (a 2) (a 3) (b 1) (b 2))
(agenda)
(run 3)
(refresh foo)
(agenda)
(run)
(refresh foo)
(agenda)
(refresh foo)
(agenda)
(clear)
(defrule bar (or (a ?) (b ?)) =>)
(assert (a 1) (b 1) (a 2) (b 2) (a 3) (b 3))
(run 3)
(agenda)
(refresh bar)
(agenda)
(clear)
(defrule yak (a ?) (b ?) =>)
(defrule flx (declare (salience 1)) (a ?) (b ?) =>)
(assert (a 1) (b 1) (a 2) (b 2))
(agenda)
(run)
(refresh yak)
(agenda)
(clear) ; strategy commands
(set-strategy depth)
(get-strategy)
(set-strategy)
(set-strategy depth 20)
(get-strategy 10)
(set-strategy breadth)
(get-strategy)
(set-strategy lex)
(get-strategy)
(set-strategy mea)
(get-strategy)
(set-strategy simplicity)
(get-strategy)
(set-strategy complexity)
(get-strategy)
(set-strategy random)
(get-strategy)
(set-strategy bogus)
(get-strategy)
(set-strategy depth)
(clear) ; salience-evaluation commands
(set-salience-evaluation when-defined)
(get-salience-evaluation)
(set-salience-evaluation)
(set-salience-evaluation when-defined 20)
(get-salience-evaluation 10)
(set-salience-evaluation when-activated)
(get-salience-evaluation)
(set-salience-evaluation every-cycle)
(get-salience-evaluation)
(set-salience-evaluation bogus)
(get-salience-evaluation)
(set-salience-evaluation when-defined)
(clear) ; refresh-agenda command
(refresh-agenda 10)
(clear) ; incremental-reset command
(set-incremental-reset TRUE)
(get-incremental-reset)
(set-incremental-reset)
(get-incremental-reset)
(get-incremental-reset 20)
(set-incremental-reset 10)
(get-incremental-reset)
(set-incremental-reset FALSE)
(get-incremental-reset)
(set-incremental-reset TRUE)
(get-incremental-reset)
(clear) ; Some new 6.0 features
(defrule BOGUS::d5 =>)
(defmodule FOO)
(defrule FOO::d1 =>)
(defrule FOO::d2 =>)
(defmodule BAR)
(defrule BAR::d2 =>)
(defrule BAR::d3 =>)
(list-defrules BOGUS)
(list-defrules FOO 7)
(list-defrules FOO)
(list-defrules BAR)
(list-defrules)
(list-defrules *)
(get-defrule-list 7)
(get-defrule-list BOGUS 7)
(get-defrule-list)
(get-defrule-list BOGUS)
(get-defrule-list FOO)
(get-defrule-list BAR)
(get-defrule-list *)
(ppdefrule d1)
(ppdefrule d2)
(ppdefrule d3)
(ppdefrule BOGUS::d2)
(ppdefrule FOO::d1)
(ppdefrule FOO::d2)
(ppdefrule FOO::d3)
(ppdefrule BAR::d1)
(ppdefrule BAR::d2)
(ppdefrule BAR::d3)
(defrule-module)
(defrule-module bogus)
(defrule-module d3 7)
(defrule-module d2)
(defrule-module d3)
(defrule-module FOO::d1)
(defrule-module FOO::d2)
(defrule-module BAR::d2)
(defrule-module BAR::d3)
(undefrule BOGUS::d2)
(undefrule FOO::d2)
(list-defrules *)
(undefrule BAR::d2)
(list-defrules *)
(undefrule *)
(list-defrules *)
(clear)
(set-salience-evaluation when-activated)
(defglobal ?*x* = 0)
(defmodule MAIN (export ?ALL))
(defrule MAIN::d0 (declare (salience ?*x*)) => (focus FOO BAR))
(defmodule FOO (import MAIN ?ALL))
(defrule FOO::d1 (declare (salience ?*x*)) =>)
(defrule FOO::d2 (declare (salience ?*x*)) =>)
(defmodule BAR (import MAIN ?ALL))
(defrule BAR::d2 (declare (salience ?*x*)) =>)
(defrule BAR::d3 (declare (salience ?*x*)) =>)
(reset)
(agenda BOGUS)
(agenda 7)
(agenda FOO 7)
(agenda)
(agenda MAIN)
(agenda FOO)
(agenda BAR)
(agenda *)
(bind ?*x* 1)
(refresh-agenda BOGUS)
(refresh-agenda 7)
(refresh-agenda FOO 7)
(refresh-agenda)
(agenda *)
(refresh-agenda FOO)
(agenda *)
(refresh-agenda BAR)
(agenda *)
(bind ?*x* 2)
(agenda *)
(refresh-agenda *)
(agenda *)
(set-salience-evaluation when-defined)
(set-break FOO::d1)
(set-break BAR::d3)
(show-breaks BOGUS)
(show-breaks 7)
(show-breaks FOO 7)
(show-breaks)
(show-breaks MAIN)
(show-breaks FOO)
(show-breaks BAR)
(show-breaks *)
