关于序言的三个问题

问题描述 投票:-2回答:1

此程序将使用SWI Prolog进行测试。

Family.pl包含有关家庭成员,与谁结婚的事实,等等。

规则必须添加到底部并提交修改后的文件。

1.(5分)写一个motherInLaw(X,Y)谓词,表示X是Y的岳母。

2.(5分)写一个grandParent(X,Y)谓词,表示X是Y的祖父母。

3.(5分)写一个grandMother(X,Y)谓词,表示X是Y的祖母。

谢谢你们!

prolog swi-prolog
1个回答
0
投票

我是问这个问题的人,这是我自己的答案,请您看看并告诉我它们是否正确?谢谢

  1. motherInLaw(X,Y):mother(X,Z),couple(Z,Y)

  2. grandParent(X,Y):父母(X,Z),父母(Z,Y)

  3. grandMother(Z,Y):mother(X,Z),parent(Z,Y)

© www.soinside.com 2019 - 2024. All rights reserved.