FO[Agg]¶
Goal
The goal of FO[Agg] is to allow expressing knowledge about the size (aka cardinality) of a set,
as well as aggregates (sum, min, and max).
This extension extends FO[Int] and/or FO[Real].
Lexicon
Token |
Pattern |
Example |
|---|---|---|
CARD |
|
|
MIN |
|
|
SUM |
|
Syntax
FO[Agg] adds these production rules:
Base ← CARD '{' Quantee {',' Quantee} [ ':' Expression ] '}';
Base ← MIN '{' Expression '|' Quantee {',' Quantee} [ ':' Expression ] '}';
Base ← SUM '{{' Expression '|' Quantee {',' Quantee} [ ':' Expression ] '}}';
Well-formedness
in
CARD{ x∈T : φ },φmust be a boolean expression.in
MIN{ t | x∈T: φ },tmust be a numeric term, andφa boolean expression.in
SUM{{ t | x∈T: φ }},tmust be a numeric term, andφa boolean expression.the variables in
tandφmust bexor declared in a outer quantification or aggregation.
Semantics
#{ x∈T: φ }is the cardinality of the set of elementsxinTthat makeφtrue.min{ t | x∈T: φ }is the minimum oftfor eachxinTsuch thatφis true.sum{{ t | x∈T: φ }}is the sum oftfor eachxinTsuch thatφis true.
Example
c() = #{x∈T: p(x)}.
[The perimeter is the sum of the lengths of the sides]
perimeter() = sum{{ length(n) | n ∈ Side_Nr }}.
FO(Agg) abstract language
The formal semantics of FO(Agg) is described in [DPB01].