在前面:这不是一个家庭作业.我正在努力学习Prolog,这只是一个需要解决的问题,而Prolog是一个完美的选择.
我有一堆家庭关系,包括我的事实:
male/1
female/1
husband/2
wife/2
father/2
mother/2
grandfather/2
grandmother/2
son/2
daughter/2
brother/2
sister/2
uncle/2
aunt/2
nephew/2
niece/2
cousin/2
Run Code Online (Sandbox Code Playgroud)
我拥有的数据不完整,缺少家庭网格的许多链接.我的事实来自外部来源,我只能提供规则.对于给定的人,我可能有male,brother和表姐,另一个mother和wife.在最糟糕的情况下,我几乎不知道cousin,但有足够的其他事实能够推断谁是,比如说,叔叔,因此这个人可能是其他地方提到的那个兄弟,因此是男性.等等.
我无法影响将会有哪些事实.这就是问题的全部要点:如果事实完整,我就不需要这样做了.我可以手工做猜测,但这就是计算机的用途,如果我能找到表达方式的话.因此,我们的目标是尽可能地填补缺失的环节,尤其是关于叔叔,阿姨,侄子,侄女和特别表兄的"间接"关系,这些关系众所周知是不完整的.
我可以像这样天真地写下我的规则:
male(Who) :-
brother(Who, _); father(Who, _); uncle(Who, _); …
brother(Who, Whose) :-
sibling(Who, Ofwhom), male(Who).
sibling(Who, Whose) :-
brother(Who, Whose) ; brother(Whose, Who).
motherly_cousin(Cousin, Whose) :-
cousin(Cousin, Whose),
sibling(Mother, Uncle_or_Aunt),
parent(Uncle_or_Aunt, Cousin).
Run Code Online (Sandbox Code Playgroud)
我很确定我试图以一种根本错误的方式解决问题,因为我认为无法打破循环推理.在不打破圈子的情况下,我为此设计的任何Prolog程序都将退化为无限的递归.
那么我该怎样做才能将这种纠结分解成可以解决的问题呢?
我有一个通过per-user settings.xml文件为Maven配置的代理服务器.剪切了默认的settings.xml模板的文档表明,可以通过命令行开关影响使用哪个已配置的代理:
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
Run Code Online (Sandbox Code Playgroud)
但是,我没有找到任何关于如何工作的文档.Maven文档有很多相同的模板,但没有提到任何命令行开关或其他.
因此,假设我已配置代理,但标记为<active>false</active>,如下例所示:
<proxies>
<proxy>
<id>firstProxy</id>
<active>false</active>
<protocol>http</protocol>
<host>proxy.example.invalid</host>
<port>3128</port>
</proxy>
</proxies>
Run Code Online (Sandbox Code Playgroud)
根据评论,有一些方法可以例如"激活"它,可能会给它的id或类似的东西.尝试"明显"使用mvn -Dproxies.proxy.firstProxy.active=true java:compile,但没有成功.
我对Maven很新,不能动摇我以某种方式咆哮错误树的感觉.我想要做什么甚至可能 - 如果是这样,任何人都可以指出我如何做到的描述 - 或者我是在浪费我的时间?
我很难理解如何discontiguous/1在(SWI)Prolog中正确使用谓词.
让buumi.pl这个伪事实的小文件:
discontiguous(buumi/1).
buumi(eins).
buri(zwei).
buumi(drei).
Run Code Online (Sandbox Code Playgroud)
swipl -s Buumi.pl然而,跑步仍会发出此警告:
% swipl -s Buumi.prolog
Warning: [...]/Buumi.prolog:5:
Clauses of buumi/1 are not together in the source-file
Run Code Online (Sandbox Code Playgroud)
文档非常含糊,只是陈述
discontiguous :PredicateIndicator, ...
但没有给出如何使用它的具体例子.我发现了一些例子表明我正确使用它; 至少,swipl并没有抱怨,但是再一次,它也不尊重我的要求.我在这做错了什么?