key(a, {attrs})
A macro for use in constraints i.e. the rule. Expands to:
not assigned(a) or count(a) = count(a{attrs})
The not assigned check ensures that the constraint doesn't fail if the relvar does not exist, e.g. the constraint is added before the relvar is created or the relvar has been dropped (and may well be re-created).
A simpler rule can be used, count(a) = count(a{attrs}), if relvar a will be created/dropped in the same (atomic) assigment statement as the constraint.
Examples
$S key
print("key example rule is:", key($S,{SNO}))
key example rule is: not assigned($S) or count($S) = count($S{SNO})