FO[Sugar]¶
Goal¶
The goal of FO[Sugar] is to add convenient notations: binary and direct quantifications, variable declaration, and the “in” operator.
It also supports reasoning with partial interpretation of symbols.
Binary Quantification and Variable Declaration¶
Syntax
FO[Sugar] adds these production rules:
Declaration ← VARIABLE IN ( Type | Symbol );
Quantee ← VARIABLE {',' VARIABLE} [ IN Symbol ];
Quantee ← VarTuple {',' VarTuple} IN Symbol;
VarTuple ← '(' VARIABLE { ',' VARIABLE } ')';
Well-formedness
Type
must be a declared type.Symbol
must be a declared predicate.Symbol
must be a unary predicate when quantifying aVARIABLE
, and an n-ary predicate when quantifying aVarTuple
.When
IN Symbol
is omitted, the type of the variable(s) is inferred from the variable’s declaration (if given), or from the quantified formula (to make it well-formed; an error is raised otherwise).When quantifying a
VarTuple
, the number ofVARIABLE
inVarTuple
must match the arity ofSymbol
.
Semantics
Let’s assume that the type signature of P
is T1 ⨯ ... ⨯ Tn → 𝔹
.
∃ x1 ∈ P: φ
reduces to ∃ x1 ∈ T1: P(x1) ∧ φ
(where P
is unary).
It can also be written ∃ x1: φ
.
∃ (x1, ..., xn) ∈ P: φ
reduces to ∃ x1 ∈ T1, .., xn ∈ Tn: P(x1, .., xn) ∧ φ
.
Similarly,∀ x1 ∈ P: φ
reduces to ∀ x1 ∈ T1: P(x1) ⇒ φ
(where P
is unary).
It can also be written ∀ x1: φ
.
∀ (x1, ..., xn) ∈ P: φ
reduces to ∀ x1 ∈ T1, .., xn ∈ Tn: P(x1, .., xn) ⇒ φ
.
Note
When inferring Symbol
is difficult for a human because of the complexity of the quantified formula,
it is recommended to declare the variable, or explicitly state the Symbol
in Quantee
.
Example
Assuming that the type signature of man
is Person → 𝔹
,
∀ x in man: mortal(x).
is equivalent to ∀ x in Person: man(x) ⇒ mortal(x).
Direct quantification¶
Syntax
FO[Sugar] adds these production rules:
Quantee ← VARIABLE {',' VARIABLE} IN '{' Value { ',' Value } '}';
Quantee ← VarTuple {',' VarTuple} IN '{' TupleValue { ',' TupleValue } '}';
Well-formedness
The
Value
s must have the same type; this type is the type of theVARIABLE
s.The
TupleValue
must be of the same type; they must not have aTO
Value
. TheVarTuple
type is the type of theTupleValue
s.
Semantics
∃ x ∈ {1,2,3}: φ(x)
reduces to φ(1) ∨ φ(2) ∨ φ(3)
.
∃ (x,y) ∈ {(a,1),(b,2)}: φ(x,y)
reduces to φ(a,1) ∨ φ(b,2)
.
∀ x ∈ {1,2,3}: φ(x)
reduces to φ(1) ∨ φ(2) ∨ φ(3)
.
∀ (x,y) ∈ {(a,1),(b,2)}: φ(x,y)
reduces to φ(a,1) ∧ φ(b,2)
.
“in” operator¶
Syntax
FO[Sugar] adds these production rules:
Unary ← { UNARY } Enum;
Enum ← Base IN '{' Value { ',' Value } '}';
Notice that this extension redefines the syntax of Unary
in FO[Core].
Well-formedness
The type of Base
must be the same as the type of Value
.
Semantics
Base IN { Value1, ..., Valuen }
is the same as Base=Value1 ∨ .. ∨ Base=Valuen
.
Partial interpretation of symbols¶
The goal is to support reasoning with partial interpretations of functions and predicates.
Lexicon
Token |
Pattern |
Example |
---|---|---|
INCLUDE |
|
Syntax
FO[Sugar] adds these production rules:
Enum ← NAME_S '(' Expression {',' Expression } ')' 'is' 'enumerated' ;
Interpretation ← NAME_S INCLUDE SymbolInterpretation '.';
Well-formedness
NAME_S
must be declared in the vocabulary and must be given anInterpretation
.The number and types of arguments of
NAME_S
inEnum
must match its type signature.The number and type of values
Interpretation
must match the type signature of theNAME_S
being interpreted.An
Interpretation
usingINCLUDE
must use aTO
element after every tuple of values in itsSymbolInterpretation
. TheSymbolInterpretation
does not have to be total over its domain.
Semantics
A symbol interpretation given using
INCLUDE
is a partial interpretation of the symbol: the interpretation of the symbol is left unspecified for the tuples that are not interpreted.NAME_S(e1, .. , en) is enumerated
istrue
when theInterpretation
ofNAME_S
is total or when the interpretation of the tuple(e1, .. , en)
is specified in theInterpretation
ofNAME_S
. It isfalse
otherwise.
Example
The following theory requires that material()
has a known maximum temperature.
Material := {A, B, C}.
maxTemp :⊇ {A→100}. // maxTemp: Material -> Int
maxTemp(material()) is enumerated. // material: () -> Material
material()
is thus A
in every model.