ASSIGNMENT OPERATORS

Assignment operators are domain-specific, such that the operator indicates the domain to be assigned into. Secondly, Pro/3 uses both deterministic and non-deterministic assignments. The assignment operator formats are:

  • deterministic assignment:     =dd     (dd is the domain short format).
  • non-deterministic assignment:     =dd*     (dd is the domain short format).

RESULT-DOMAIN IN ASSIGNMENTS

Value assignments are based on an explicit or implicit result domain. The result domain is determined by the assignment operator i.e. the operator is domain-qualified. This is implemented both in NL-format and internal format as a two- or three letter suffix to the operator (corresponding to the domain short format).

Example

CustomerPrice =NU (list price - (list price * customer discount))

The domain-qualifier is optional, and if absent, Pro/3 determines the result domain from the context. This can give un-intended results in some case, e.g. an expected integer-value becomes a number-value or vice versa. It is therefore highly recommended to use domain-qualified assignments, i.e. in function statements and in sentence rules (in variable condition-elements - assignments to data elements in the conclusion are automatically domain-qualified by the rule editor on the basis of the data element's domain).  

The different domains fall into four groups, integer, number, string, identifier, and the inference engine has four corresponding evaluation procedures. Note the following evaluation rules:

  1. An integer can be evaluated as an integer, number or string.
  2. A number can be evaluated as a number, integer or string.
  3. An identifier can be evaluated as an identifier or as a string.
  4. A string can only be evaluated as a string.
  5. An expression with both an integer and a number will be evaluated as a number.
  6. An expression involving a string and either of the integer, number or identifier domain groups, will be evaluated as a string.
  7. In absence of domain information, the following evaluation attempts will be made: first as integer, then as number, third as identifier and finally as string.

Example

offered price =IN (list price - (list price * customer discount))

Let's assume that the list price is the integer 120, while the customer discount is 10% (i.e. the number 0.1). The first expression to be evaluated (list price * customer discount) will be evaluated as a number (120 * 0.1=12.0). The second expression (120-12.0) will also be evaluated as a number (108.0), however the result assigned to offered price will be the integer 120 due to the domain qualifier.

ARITHMETICAL OPERATORS

Arithmetical operators are used to form arithmetical expressions.

NL IF DESCRIPTION CARDINALITY
+ + addition binary
- - unary minus unary
- - subtraction binary
* * multiplication binary
/ / division binary
divided by p_div integer division binary
^ ^ exponentiation (exponent can be any number) binary

COMPARISON OPERATORS

Comparison operators are not domain-qualified (with the exception of equality comparison, which generally are qualified i.e. there is no distinction between the assignment operator and the equality comparison operator). Pro/3 will thus decide on the result domain (integer, number, string or identifier) according to the actual operands and the rules 1-7 over.

 
NL RULE-TREE IF DESCRIPTION
= = = equality
=< =< =< less or equal than
>= >= >= greater or equal than
< < < less than
> > > greater than
<> <> <> not equal
unlike unlike unlike not like
like like like like

Wild-card characters in like/unlike-expressions are limited to:
"Nebr%" like "Nebraska"
"%bras%" like "Nebraska"
"%aska" like "Nebraska"

STRING OPERATORS

NL RULE-TREE IF DESCRIPTION
* * * concatenation

 

VALUES

Values and expressions occur on the right side of an assignment or comparison operator (or assumed assignment operator). Values include:

  • literal values (quoted strings, identifiers (unquoted strings), numbers, integers)
  • variable names
  • data element names
  • data element references expressions
  • solution set size expressions
  • function calls
  • inexact rule calls
  • procedure calls

Function calls

See
functions.

Data element references

A data element reference is a reference to one data element in a sentence, used as a value. Data element references are used in functions and inexact rules (data rules) only (data element references can not be used in rules).

Examples

Consider the projection period entity type with two data element types last period and start month, and the exists predicate type:

A data element reference to the last period could be written as:

the value of the existing projection period's last period
the value of the last period for the existing projection period
the value of last period where projection period exists


The following data element reference assigns or compares an assumed loan entity's disbursement time to/with the variable DisburseTime:

DisburseTime = the value of the disbursement time where the loan with project reference ProRef and name Ref is assumed


The data element references in above are non-deterministic, that is, the data element reference expressions refer multiple values, that is, as many values as there are sentences satisfying the sentence condition. In second example, this number is the number of assumed loans with project reference ProRef and name Ref (probably only one). However, if the data element reference had been written the value of the disbursement time where the loan with project reference ProRef is assumed, then the number of disbursement time values would have been equal to the number of assumed loans with the given project reference. The first indicator explicitly makes the expression deterministic. Only the first sentence encountered in the KB is considered.

Example

Assume that the following sentences are known:

the calendar month with name January, month no 1, ... exists!
the calendar month with name February, month no 2, ... exists!
:
the calendar month with name December, month no 12, ... exists!


The data element reference the value of the name of existing calendar month effectively refers to all twelve months.

The data element reference the value of name of existing calendar month with month no 2 refers to February.
The data element reference the value of the first name of existing calendar month refers to January.


Solution set size references

A solution set size reference is a reference to the number of sentences in solution set, that is satisfying a specified predicate condition. Solution set size references can be used both in rules and in functions. Consider the following sentence model entities:

Example

Assume the following sentences:

the cash flow with amount 1000, currency US$ and period 2 exists!
the cash flow with amount 2000, currency US$ and period 12 exists!
the cash flow with amount 3000, currency Pesos and period 21 exists!
the cash flow with amount 5000, currency Pesos and period 21 exists!
the cash flow with amount 1000, currency Pesos and period 22 exists!
the cash flow with amount 1000, currency US$ and period 1 exists!
the cash flow with amount 1000, currency US$ and period 2 exists!


The solution set reference the number of sentences of cash flows with amount equal to 1000 which exist has value 4. The solution set reference could also have been written:

  • the number of cash flows with amount equal to 1000 which exist
  • the number of existing cash flows with amount equal to 1000


Solution set size references can be used in expressions both in rules and in functions. References are always to predicate conditions (solution sets) involving one and only one sentence type. The predicate type can be unary as well as binary.

EXPRESSIONS

Compound values, i.e. combinations of simple values, operators and parenthesizes, are referred to as expressions. Expression operators include the arithmetical operators and the string operators. There are no limits with respect to the nesting of expressions and sub-expressions. However, expressions must be fully parenthesized (there is no operator hierarchy). Expressions can include all value types including data element references, solution set size references, functions calls and inexact rule calls. However, data element references and solution set references can not contain variables when used in expressions. (The first data element reference above is allowed in expressions, while the second is not). Note in this regard that simple values are regarded as expressions when they occur in the conclusion part of rules.

Examples

  • MonthlySalary is equal to (AnnualSalary/12.0)
  • HourlySalary is equal to (AnnualSalary/(252*8))
  • X=((the integer value of (Y*75%))^1.08)

VALID EXPRESSIONS:

  • ((-2+A)^1.5)
  • (2+the first value of the disbursement time of the assumed loan)

INVALID EXPRESSIONS:

  • A^2 no parenthesizes
  • (A*2+B) no parenthesizes for A*2 (or 2+B)
  • (A+B)*(C+D) no parenthesizes for the whole expression
  • (2+the value of the disbursement time of the assumed loan with project reference Pro