Guards †Rules with a Guard †Guards specify applicability conditions of rewrite rules. The syntax of a rule with a guard is:
where Guard is a multiset of type constraints of the form c($p1, ..., $pn). Type constraints constrains the shapes of processes (or the names of unary atoms) received by the process contexts $p1, ..., $pn. The type constraint name c is drawn from a builtin set and specifies which kind of constraints is imposed. A constraint of the form uniq($p1, ..., $pn) is also allowed. This is a control structure rather than a type constraint and used to avoid infinite rule application (see below). Examples †Here is an example rule with guard: waitint(X), $p[X] : int($p)  ok. This can be abbreviated to waitint($p) : int($p)  ok. and can be thought of representing the following infinite number of rules: waitint(0) : ok. waitint(1) : ok. waitint(1) : ok. waitint(2) : ok. waitint(2) : ok. ... The following are examples of some type constraints that can be written in Guard:
Notes †Each type constraint name (such as int or <) has its own mode of usage that specifies which of its arguments are input arguments. The effect of the constraint specified by a type constraint is enabled only after the shapes (or values) of its input arguments are all determined. For example, $r = $p + $q proceeds only when $p and $q are determined. The same abbreviation scheme as defined for atoms applies to type constraints when a process context name $pk occurs exactly twice in the rule. For example, p($n) : $n>$z, 0($z)  ok can be abbreviated to p($n) : $n>0  ok. Typed Process Contexts †A process context constrained in Guard is said to be a typed process context. Avoiding Infinite Rule Application †A constraint of the form uniq($p1, ..., $pn) succeeds if each $pk is a ground structure (connected graph with exactly one free link; see below) and the rule has not been applied to the tuple $p1, ..., $pn before. As a special case of n=0, uniq succeeds if the rule in question has not been used before. The uniq() test is a general tool for avoiding infinite application of rules whose righthand side is a super(multi)set of the lefthand side. Guard Library †The following type constraints can be used in guards. The + (input) sign preceding a process context name means that the name should appear in the head, while the  (output) sign means that the name should not appear in the head. Type checking †
Comparison †
Assignment †
Others †
