FO[Int]¶
The goal of FO[Int] is to allow expressing knowledge about integer quantities using the 4 arithmetic operators and comparisons. It extends FO[PF].
It also allows creating and using types containing a range of elements, and the comparison of dates, e.g., to determine the applicability of a law..
Integer arithmetic¶
Lexicon
Token |
Pattern |
Example |
---|---|---|
COMPARISON |
|
|
INT |
|
|
INTEGER |
|
|
MULT_DIV |
|
|
POWER |
|
|
SUM_MINUS |
|
|
UNARY |
|
Note that this extension extends the pattern of UNARY in FO[Core].
Syntax
FO[Int] adds these production rules:
Type ← INT;
Conjunction ← Comparison {AND Comparison};
Comparison ← { ANNOT }
SumMinus {COMPARISON SumMinus};
SumMinus ← MultDiv {SUM_MINUS MultDiv};
MultDiv ← Power {MULT_DIV Power};
Power ← Unary {POWER Unary};
Identifier ← INTEGER;
Symbol ← 'abs';
Note that this extension replaces the syntax of a Conjunction in FO[Core].
Well-formedness
Division must be well-guarded to prevent division by 0 (e.g.,
if y ≠ 0 then x/y else 1
).Quantification over ℤ is not allowed (relaxed in FO[Infinite]).
Semantics
The arithmetic and comparison operators have their usual meaning.
Range¶
Syntax
FO[Int] adds these production rules:
TypeInterpretation ← '{' INTEGER '..' INTEGER '}';
Quantee ← VARIABLE {',' VARIABLE} IN '{' INTEGER '..' INTEGER '}';
Enum ← Base IN '{' INTEGER '..' INTEGER '}';
Identifier ← INTEGER;
Well-formedness
The first INTEGER
must be below the second INTEGER
.
If the interpretation of a range is not given in the vocabulary block
(but in the theory or structure block), it is required to state
that the declared type is a subtype of Int
.
Semantics
{1..8}
represents the set {1, 2, 3, 4, 5, 6, 7, 8}
.
The type that it interprets is automatically inferred to be a subtype of Int
.
Date¶
Lexicon
Token |
Pattern |
Example |
---|---|---|
DATE |
|
|
Syntax
FO[Int] adds these production rules:
Type ← 'Date';
Identifier ← DATE | '#TODAY' ['(' INTEGER, INTEGER, INTEGER ')'];
Well-formedness
Dates can occur wherever integers can occur.
DATE
must be a valid date.Quantification over
Date
is not allowed (except with the FO[Infinite] extension).
Semantics
Dates are converted to proleptic Gregorian ordinals, where January 1 of year 1 has ordinal 1.
#TODAY(y,m,d)
is today’s date shifted by y
years, m
month and d
days. #TODAY(-1, 0, 0)
is today last year.