The Acme predicate language includes primitive operators for comparison, logic, arithmetic, and set operations, along with a small collection of miscellaneous operations. Details for each category of operator are given in the following tables.
The predicate language includes the following operators for comparing two values:
Operator |
Example |
Meaning |
== |
x == y |
true if x equals y, else false |
!= |
x != y |
true if x does not equal y, else false |
> |
x > y |
true if x is greater than y else false |
>= |
x >= y |
true if x is greater than or equal to y, else false |
< |
x < y |
true if x is less than y, else false |
<= |
x <= y |
true if x is less or equal to y, else false |
Comparison operator notes:
n Operands must be numeric for the operators >, <, >=, and <=.
n
The equality and inequality operators (== and !=) perform object (or
reference) equality tests for design elements and references to design
elements. That is, the statement element e == element e’ is true
iff element e is element e’. The equality operators
perform value equality tests on properties and literal values. That is,
if
property x == 4 and property y == 4 then x =
y.
The predicate language includes the following operators for building logical expressions:
Operator |
Example |
Meaning |
and |
x and y |
true if both x and y are true, else false |
or |
x or y |
true if either x or y are true, else false |
xor |
x xor y |
true if (x = true and y = false) or (x = false and y = true), else false |
-> |
x -> y |
Implication (if). If x is true then y must be true. If x is false, the value is true. |
<-> |
x <-> y |
two-way implication (iff). true if x and y are either both true or both false. false if they have different values. |
! |
!x |
not x. True if x is false, else false |
For all logical operators, both the left-hand-side (lhs) and the right-hand-side (rhs) operands must evaluate to boolean typed values. Likewise, all logical operators return a boolean typed value.
The predicate language includes the following operators for doing simple arithmetic operations:
Operator |
Example |
Meaning |
+ |
x + y |
Addition. Sum of the values of x and y |
- |
x – y |
Subtraction. Difference of x – y |
* |
x * y |
Multiplication. Product of x and y |
/ |
x / y |
Integer division if both x and y are integers, else floating point division. |
mod |
x mod y |
Modular division. |
For all of the arithmetic operators, the operands need to be numeric. Modular division requires that both operands be integers.
The following miscellaneous operators are also be primitive operations in the Acme predicate language:
Operator |
Example |
Meaning |
() |
(z or (x < y)) |
Precedence operator. all expressions in the innermost parentheses are evaluated before moving to the outer level of parentheses. Standard C interpretation used. |
. |
object.property comp.portName |
Qualifier and dereferencer. The period is used to qualify names and dereference substructure within an object. The value of the referenced entity is returned by the operation. |
The following table give the list of builtin operators of the Acme predicate language, sorted by category. For example, if I have a component “c”, its set of ports can be accessed by c.ports.
Category |
Operator |
Meaning |
System |
Components |
Gives the set of components in the system. |
|
Connectors |
Gives the set of connectors in the system. |
|
Properties |
Gives the set of properties associated with the system |
Component |
Ports |
Gives the set of ports in the component |
|
Properties |
Gives the set of properties associated with the component |
|
Representations |
Gives the set of representations of the component |
Connector |
Roles |
Gives the set of ports of the connector. |
|
Properties |
Gives the set of properties associated with the connector |
|
Representations |
Gives the set of representations of the connector |
Port |
AttachedRoles |
Gives the set of roles that are attached to the port. |
|
Properties |
Gives the set of properties associated with the port. |
Role |
AttachedPorts |
Gives the set of ports that are attached to the role |
|
Properties |
Gives the set of properties associated with the role. |
It is, of course, possible to build up expressions using the primitive predicates and the supplied operators. The grammar for doing so looks is:
Expression
::= Primitive-Function(ActualParams)
| Literal-Constant
| Identifier
| DesignAnalysisIdentifier(ActualParams)
| QuantifedPredicate
| Unary-Operator Expression
| Expression Binary-Operator Expression;
Unary-Operator ::= Acme primitive unary-operator ;
Binary-Operator ::= Acme primitive binary-operator ;
Primitive-Function ::= Primitive Acme Predicate Language function ;
Identifier ::= Valid reference to a variable or property
DesignAnalysisIdentifier ::= Valid reference to a user-defined Design Analysis
ActualParams ::= List of values for parameters to pass to function
The production for QuantifedPredicate is defined in this chapter’s Quantification section. A PredicateExpression is an Expression that evaluates to a boolean value.