The ruleset macro

Programmers typically write girl code by defining signals in terms of other signals.  This supports a "backward-chaining" style of programming where defines propositions in terms of necessary and sufficient conditions.  In this case, the definitions of the propositions (their necessary and sufficient conditions) are explicit in the code, but their entailments (what you can infer from a proposition) are left implicit; to know the entailment of a proposition, you have to look at the code for all the other propositions to find where it's used.

It is often more convenient to specify a set of propositions in terms of their entailments rather than their definitions.  The ruleset macro allows you to define a set of propositions and their entailments using a set of if/then rules like you would find in a production system.  Girl then solves for their definitions at compile time.

Macro syntax

Rules are defined with the ruleset macro.

(ruleset (propositions ...)
   rules ...)
This creates a set of signals to represent propositions and rules.   It returns propositions ... as a list.

Rule syntax

The rules within a ruleset expression can be any of the following forms:

(if signal consequent alternative)
Signal is tested on every clock cycle.  When it is true, consequent is true.  When it is false, alternative is true.
(when signal consequents ...)
Signal is tested on every clock cycle.  When it is true, all the consequents are made true.  This rule has no effect when signal is false.
(unless signal consequents ...)
Signal is tested on every clock cycle.  When it is false, all the consequents are made true.  This rule has no effect when signal is true.