将以下规则添加到我的代码会导致错误消息 ( info: operation undefined (Max-Min)
):
rank_difference(Room, Deck, Diff) :-
played(Room, Deck),
Min = #min {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Max = #max {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Diff = Max - Min.
played(Room, Deck)
意味着每个玩家都存在至少一个seat(Player, Room, Deck)
谓词(实际上恰好存在 3 或 4 个),rank(Player, Rank)
因此这不应该是一个空集问题。
更新 - 可运行示例(没有任何约束):
#const nRounds = 4.
#const nPlayers = 13.
#const nRooms = 4.
#const nDecks = 10.
player(1..nPlayers).
room(1..nRooms).
deck(1..nDecks).
writer(1,1;2,2;3,3;4,4).
rank(Player, Player) :- player(Player).
nRounds { round(Player, 1..nDecks) } nRounds :- player(Player).
{ played(Room, Deck) } :- room(Room), deck(Deck).
3 { seat(Player, Room, Deck) : round(Player, Deck) } 4 :- played(Room, Deck).
rank_difference(Room, Deck, Diff) :-
played(Room, Deck),
Min = #min {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Max = #max {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Diff = Max - Min.