尝试解决合金中的女士或老虎

发布于 2025-01-20 04:28:15 字数 776 浏览 1 评论 0原文

我一直在尝试解决合金中的女士或老虎的逻辑难题,但陷入困境。现在我正在尝试解决第二天的第四个难题。 事情是这样的:有几个房间,每个房间上都有一个标牌,上面写着什么。根据所给出的规则,标志上的陈述可能是正确的,也可能是错误的。有可能两个房间都有女士,也有可能两个房间都有老虎,也有可能一个房间有老虎,另一个房间有女士,但永远不可能一个房间里有多个生物(女士或老虎)。

标牌上写着:

标牌 1:“两个房间里都有女士”,并且只有当 1 号房间里有女士时,此声明才成立。

标志 2:“两个房间里都有女士”,只有当房间 2 里有老虎时,这个陈述才成立。

我已经尝试过几件事,这就是我所得到的。问题是我不知道如何表述,例如 Sign1 仅当 Room1 中有一位女士时才为 true。

abstract sig Creature {}
sig Lady, Tiger extends Creature {}
one sig Room1, Room2 in Creature {}

abstract sig Sign {}
one sig Sign1, Sign2 extends Sign {}
sig Truthful in Sign {}

fact {
    Sign1 in Truthful => Lady in Room1 <=> Lady in Room1 && Lady in Room2
    Sign2 in Truthful => Tiger in Room2 <=> Lady in Room1 && Lady in Room2
}

run {}

I've been trying to solve the logic puzzle Lady or the Tiger in Alloy but got stuck. Right now I'm trying to solve the 4th puzzle which is on the 2nd day.
It goes as following: There are a few rooms and on each room is a sign that says something. Depending on the rules that have been given, the statements on the signs can either be true or false. It is possible that there are Ladies in both rooms, it is also possible that there are Tigers in both rooms, it is also possible for there to be a tiger in one room and a lady in the other room but it is never possible to have multiple creatures(Lady or Tiger) in one room.

The signs say:

Sign1: "There are Ladies in both rooms" and this statement can only be true if there is a Lady in Room1.

Sign2: "There are Ladies in both rooms" and this statement can only be true if there is a Tiger in Room2.

I've tried several things already and this is as far as I got. The problem is that I don't know how to formulate that for example Sign1 can only be true if there is a Lady in Room1.

abstract sig Creature {}
sig Lady, Tiger extends Creature {}
one sig Room1, Room2 in Creature {}

abstract sig Sign {}
one sig Sign1, Sign2 extends Sign {}
sig Truthful in Sign {}

fact {
    Sign1 in Truthful => Lady in Room1 <=> Lady in Room1 && Lady in Room2
    Sign2 in Truthful => Tiger in Room2 <=> Lady in Room1 && Lady in Room2
}

run {}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱本泡沫多脆弱 2025-01-27 04:28:15
enum Creature { Lady, Tiger }
enum boolean { false, true}

let bool[x] = x => true else false

pred rules[ s1, s2: boolean, disj room1, room2 : Creature ] {
    s1 = bool[room1 = lady]
    s2 = bool[room2 = tiger]
}
run rules

enum Creature { Lady, Tiger }
enum boolean { false, true}

let bool[x] = x => true else false

pred rules[ s1, s2: boolean, disj room1, room2 : Creature ] {
    s1 = bool[room1 = lady]
    s2 = bool[room2 = tiger]
}
run rules

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文