2

我得到了这种形式的经典爱因斯坦/斑马谜题:

让我们假设在同一条路上有五个不同颜色的房子相邻。每个房子里住着一个不同国籍的人。每个男人都有他最喜欢的饮料,他最喜欢的香烟品牌,并养着一种特定的宠物。

The Englishman lives in the red house. 
The Swede keeps dogs. 
The Dane drinks tea. 
The green house is just to the left of the white one. 
The owner of the green house drinks coffee. 
The Pall Mall smoker keeps birds. 
The owner of the yellow house smokes Dunhills. 
The man in the center house drinks milk. 
The Norwegian lives in the first house. 
The Blend smoker has a neighbor who keeps cats. 
The man who smokes Blue Masters drinks bier. 
The man who keeps horses lives next to the Dunhill smoker. 
The German smokes Prince. 
The Norwegian lives next to the blue house. 
The Blend smoker has a neighbor who drinks water. 
The question to be answered is: Who keeps fish?

任务是将这些陈述表达为一阶逻辑中的一组封闭公式,每个陈述一个,假设拼图中的五个人由英国人、瑞典人、丹麦人、挪威人、德国人和保持(X,Y) 表示人 X 养宠物 Y。这些稍后将转换为序言。

我的问题是我是否要以正确的方式转换语句。现在,我有类似的东西:

color(X, red) → lives(englishman, X)
keep(swede, dog)
drinks(dane, tea)
color(X, red) ∧ color(Y, green) → leftof(X, Y)
color(X, green) ∧ lives(Y, X) → drinks(Y, coffee)
smokes(X, pallmall) → keep(X, birds)
color(X, yellow) ∧ lives(Y, X) → smokes(Y, dunhills)

这是正确的,还是应该更像我尝试的另一种方式:

house(X) ∧ color(X, red) → lives(englishman, X)
dog(X) → keep(swede, X)
tea(X) → drinks(dane, X)
house(X) ∧ house(Y) ∧ color(X, green) ∧ color(Y, white) → leftof(X, Y)
house(X) ∧ color(X, green) ∧ lives(Y, X) ∧ coffee(Z) → drinks(Y, Z)
pallmalls(X) ∧ smokes(Y, X) ∧ birds(Z) → keep(Y, Z)
house(X) ∧ color(X, yellow) ∧ lives(Y, X) ∧ dunhills(Z) → smokes(Y, Z)

我也尝试过类似的事情:

lives(englishman, redhouse)
keep(swede, dogs)
drinks(dane, tea)
leftof(greenhouse, whitehouse)
lives(X, greenhouse) → drinks(X, coffee)
smokes(X, pallmall) → keep(X, birds)
lives(X, yellowhouse) → smokes(X, dunhills)

我认为第一个是最正确的,但我不确定。我也不确定如何在一阶逻辑中表示中心或邻居之类的东西。这些是否接近正确?

编辑:我想出了一个我认为可能是正确的解决方案。我注意到它说的是 CLOSED 公式,所以我这样做了:

lives(englishman, red)
keep(swede, dogs)
drinks(dane, tea)
leftof(green, white)
∃X lives(X, green) ∧ drinks(X, coffee)
∃X smokes(X, pallmalls) ∧ keep(X, birds)
∃X lives(X, yellow) ∧ smokes(X, dunhills)
∃X position(X, 3) ∧ drinks(X, milk)
position(norwegian, 1)
∃X,Y smokes(X, blend) ∧ neighbor(X, Y) ∧ smokes(Y, dunhill)
∃X smokes(X, bluemasters) ∧ drinks(X, bier)
∃X,Y keep(X, horses) ∧ neighbor(X, Y) ∧ smoke(Y, dunhill)
smokes(german, prince)
∃X neighbor(norwegian, X) ∧ lives(X, blue)
∃X,Y smokes(X, blends) ∧ neighbor(X,Y) ∧ drinks(Y, water)

这是正确的方法吗?任何帮助,将不胜感激。

4

0 回答 0