Hi Jacob
First
let me correct an obvious omission from my previous rule, which should have
read as follows:
* Bid1
is highest for Advertisement if and only if
that Bid1 is for that Advertisement and offers some Price1
and no Bid2 <> Bid1 and is for that
Advertisement and offers some Price2 >= Price1.
This rule implies that the fact type is 1:1.
Alternatively, you could use the following simpler rule and then add an
asserted uniqueness constraint to the derived fact type to ensure there is only
one highest bid for each advertisement.
* Bid1
is highest for Advertisement if and only if
that Bid1 is for that Advertisement and offers some Price1
and no Bid2 is for that Advertisement and offers some
Price2 > Price1.
I now usually use “rule” to mean “derivation
rule” rather than a constraint. I now see that you are after a constraint. It
is usual to treat “It is forbidden that ” as a deontic modal operator, and “It is
impossible that” as an alethic modal operator. I assume by “This is forbidden”
you actually mean “This must be rejected” (an alethic constraint) rather than
accepting the update and marking it as forbidden (a deontic constraint).
There are many ways to specify the constraint
you are after. A dynamic rule approach is most efficient, but here is one simple
way to specify the constraint statically.
(1)
Add the derived fact type “Bid is highest for Advertisement” as indicated above.
(2)
Add the derived
fact type “Bid is latest for Advertisement” using the following derivation rule
(this enforces 1:1, but you also could use the alternative approach for the previous
rule):
* Bid1 is latest for
Advertisement if and only if
that Bid1 is for that Advertisement and is made on some
Datetime1
and no Bid2 <> Bid1 is for that
Advertisement and is made on some Datetime2 >= Datetime1.
(3)
Assert the following pair-equality
constraint between these two derived fact types:
Bid is latest for Advertisement if and only if that Bid
is highest for that Advertisement.
Cheers
Terry