Loops
- A loop repeats something over and over again
- A rule or set of a rules can implement a loop
- For one rule you need to keep the LHS true but change one
of the data items it depends on.
- For example
- if (value ?a) (test (< ?a 5) then (assert (value (+ ?a 1))
- You get ?a, see if it is less than 5, and if so assert
a new fact. The next cycle this exact rule will be rerun again
until (value 5).
- This is the basic idea for any loop.
- They can also benefit from an initialisation and conclusion rule.