Existential quantifier
- Last Updated: March 24, 2022
- 2 minute read
- Corticon
- Version 6.3
- Documentation
The other special operator available is the existential quantifier. The meaning
of the existential quantifier is that there exists at least one
element of a collection for which a given condition evaluates to true. This logic is
implemented in the Rulesheet using the ->exists operator
in the Operator Vocabulary.
You can construct a Rulesheet to determine the rating value for a Security entity by
evaluating a collection of associated SecInfo elements
with the existential quantifier. In this example, volume
rather than rank is used to determine the rating value for the security. The Rulesheet for this example
is shown in the following figure:
In this Rulesheet, you see the following condition
secinfo ->exists(secinfo.volume >1000)Notice again the required use of an alias to represent
the collection being examined. The exact meaning of the condition in this example is that
for the collection of SecInfo elements associated with a
Security (again represented by the secinfo alias), determine if the expression in parentheses (
secinfo.volume > 1000) holds true for at least one
Secinfo element. Depending on the outcome of the exists evaluation, a value of either High Volume or Normal Volume will be assigned
to the rating attribute of the Security object, and the corresponding Rule Statement will be posted as a
message to the user.
The following figure shows a Ruletest constructed to test the exists condition rules.
SecInfo elements
associated with a single Security entity will be
evaluated. Because the volume attribute value assigned in
at least one of the SecInfo objects ( secInfo[2]) is greater than 1000, you should expect that the
exists Condition will evaluate to true and a rating value of High Volume will be assigned to our Security
object when the Ruletest is run through the rules engine. This outcome is confirmed in the
Ruletest shown in the following figure: