skip to main content
Corticon Studio: Rule Modeling Guide : Collections : Special collection operators : Existential quantifier

Try Corticon Now
Existential quantifier
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 from our Operator Vocabulary.
As in our last example, we 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 new example, we will use volume rather than rank to determine the rating value for the security. The Rulesheet for this example is shown in the following figure:
Figure 116. Rulesheet with Existential Quantifier (exists) Condition
In this Rulesheet, we see the 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 our 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 our exists Condition rules.
Figure 117. Ruletest for Testing exists Condition Rules
Once again, we evaluate a collection of 3 SecInfo elements associated with a single Security entity. Since the volume attribute value assigned in at least one of the SecInfo objects ( secInfo[2]) is greater than 1000, we should expect that our 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 Corticon Server. This outcome is confirmed in the Ruletest shown in the following figure.
Figure 118. Ruletest for exists Condition Rules