Re: Negation In Prolog




Negation is a dodgy subject. I use the following hack:

not(Goal):-Goal,!, fail.
not(_):-true.

Which claims something is false if you can't prove it so, which is,
of course, an unsupportable contention. In fact, it is best to
avoid using truth by negation in programming for the reason that
constructive proofs do not suffer this infirmity.

Dhu


On 18 Oct 2005 19:44:45 -0700
samuel.kelly@xxxxxxxxx wrote:

> [Last post was titled wrong. Don't let the subject
> confuse you; it is not the question I am asking!]
>
> Hi,
>
> I have been looking at Prolog over the last week or so and have a
> question about negation.
>
> I have been trying to write a question and in the process have thought
> a little about negation in Prolog. Am I off the mark in my
> understanding?:
>
> ----------
>
> The logical statement
>
> not(p(X1, X2, ..., Xn))
>
> basically means "No X1, X2, ..., and Xn exist where p(X1, ... Xn)."
>
> However, in Prolog, this only works if all of Xi are first given a
> finite universe of possible values, before not(p(...)) is considered.
>
> Is this true?
>
> As a practical example, in a "family tree" Prolog program/database,
> you might try to include the rule
>
> single(X) :- not(married(X)).
>
> but this won't work with the query single(Q) because you have not
> established a finite universe for Q. You could instead say:
>
> single(X) :- person(X), not(married(X)).
>
> and make sure that person(X) is true for all the "people" you are
> concerned about.
>
> ----------
>
> Is that correct?
>
> I cannot think of a situation where you would need an infinite
> universe. I have thought about, for example, the natural numbers as an
> infinite universe for an argument to NOT(p(...)) but it seems the
> rule can always be rewritten to not us NOT.
>
> For example, in
>
> negative(X) :- X < 0.
> nonnegative(X) :- not(negative(X).
>
> nonnegative can just be written:
>
> nonnegative(X) :- X >= 0.
>
> Are they any examples you know of where an easy rewrite like this is
> not possible?
>
> Thanks,
> Sam
>
>
>
>
> Hi,
>
> I have been looking at Prolog over the last week or so and have a
> question about negation.
>
> I have been trying to write a question and in the process have thought
> a little about negation in Prolog. Am I off the mark in my
> understanding?:
>
> ----------
>
> The logical statement
>
> not(p(X1, X2, ..., Xn))
>
> basically means "No X1, X2, ..., and Xn exist where p(X1, ... Xn)."
>
> However, in Prolog, this only works if all of Xi are first given a
> finite universe of possible values, before not(p(...)) is considered.
>
> Is this true?
>
> As a practical example, in a "family tree" Prolog program/database,
> you might try to include the rule
>
> single(X) :- not(married(X)).
>
> but this won't work with the query single(Q) because you have not
> established a finite universe for Q. You could instead say:
>
> single(X) :- person(X), not(married(X)).
>
> and make sure that person(X) is true for all the "people" you are
> concerned about.
>
> ----------
>
> Is that correct?
>
> I cannot think of a situation where you would need an infinite
> universe. I have thought about, for example, the natural numbers as an
> infinite universe for an argument to NOT(p(...)) but it seems the
> rule can always be rewritten to not us NOT.
>
> For example, in
>
> negative(X) :- X < 0.
> nonnegative(X) :- not(negative(X).
>
> nonnegative can just be written:
>
> nonnegative(X) :- X >= 0.
>
> Are they any examples you know of where an easy rewrite like this is
> not possible?
>
> Thanks,
> Sam
>


--
???????????????????????????????????????

Can't get good help?

Contact Fubar the Hack: fubar AT neotext.ca

Area code seven eight zero, Exchange four six six, Local zero one zero nine

Highland terms, Canadian workmanship.

All persons named herein are purely fictional victims
of the Canidian Bagle Breeder's Association.

Save the Bagle!

Sun Ðhu

???????????????????????????????????????


.



Relevant Pages

  • Re: Negation In Prolog
    ... > a little about negation in Prolog. ... > finite universe of possible values, ... > Are they any examples you know of where an easy rewrite like this is ...
    (comp.lang.prolog)
  • Negation In Prolog
    ... a little about negation in Prolog. ... finite universe of possible values, ... infinite universe for an argument to NOT) but it seems the ... Are they any examples you know of where an easy rewrite like this is ...
    (comp.lang.prolog)
  • How to express (NOT A) AND (NOT B)
    ... a little about negation in Prolog. ... finite universe of possible values, ... Are they any examples you know of where an easy rewrite like this is ...
    (comp.lang.prolog)
  • Re: predicate in a predicate
    ... Prolog is somehow from Horn Clauses, they can have at most one ... how can I convert the FOL that have two positive ... With negation as failure you can go beyond horn clauses. ...
    (sci.logic)
  • Re: predicate in a predicate
    ... Prolog is somehow from Horn Clauses, they can have at most one ... how can I convert the FOL that have two positive ... With negation as failure you can go beyond horn clauses. ... positivity check is ok, so this amounts to prolog as: ...
    (sci.logic)