English 中文(简体)
ECLiPSe Prolog - Unexpected conduct of nonvar/1
原标题:ECLiPSe Prolog - Unexpected behaviour of nonvar/1
  • 时间:2012-04-14 15:12:53
  •  标签:
  • prolog

我正在通过一些ECLiPSe文件,发现:

`nonvar/1` : Fails if Term is not instantiated

我试图这样做:

1. Query: nonvar(X). Result: No (AS EXPECTED)
2. Query: X=5, nonvar(X). Result: Yes (AS EXPECTED)
3. Query: X=5, nonvar(f(X)). Result: Yes, X=5. (AS EXPECTED)

现在,这一令人怀疑的结果使我感到不解:

4. Query: nonvar(f(X)). Result: Yes, X=X.

查询1 233份。 对我来说,4项成果是令人不快的。 根据非第1/1号文件,如果论点是经口头修正的,则该论点可以是:ANY PROLOG TERM (so, f(X)是罚款),如果是没有。

在4起案件中,该事件不是立即发生的,而是应当为NO而不是YES(X=X)。 如果我的理解不正确,或者它是否是欧洲自由与民主运动赞成文件的问题,请予以纠正? 我正在使用最新版本。

感谢!

最佳回答

在您的询问中,f(X)>>>>>。 The non-instantiated variability X but it is not se an uninstantiated/2007/5.

SWI-Prolog 帮助或许比照nonvar的含义更为明确:

nonvar(Term): True if Term currently is not a free variable.

您可核实某一术语是否包含有<代码>ground/1的自由变量:

?- X = 5, ground(f(X)).
X = 5.

?- ground(f(X)).
false.
问题回答

暂无回答




相关问题
Prolog : Learning by example

I am trying to learn a little bit about swi-prolog (beyond the basic, useless programs). Can anyone explain (perhaps in pseudocode) what this sudoku solver and the related functions are doing? If ...

Working with lists in Prolog

First off let me state that this is part of a class exercise given as homework. But, the entire assignment is much more involved than the subject of this question. So.. I am searching through two ...

SWI-Prolog conditional statements

I m trying to write a function that will test to see if the word hello is contained in a list. If it is contained, i don t want it to say "true", i want it to say : "yes, the word hello is contained ...

prolog cut off in method

I have a question I would like to ask you something about a code snippet: insert_pq(State, [], [State]) :- !. insert_pq(State, [H|Tail], [State, H|Tail]) :- precedes(State, H). insert_pq(State, [...

Max out of values defined by prolog clauses

I know how to iterate over lists in Prolog to find the maximum, but what if each thing is a separate clause? For example if I had a bunch of felines and their ages, how would I find the oldest kitty? ...

热门标签