Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PROLOG does SO have NOT() !!

6 views
Skip to first unread message

Graham Cooper

unread,
Nov 20, 2012, 3:39:12 AM11/20/12
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
Exactly the same way we use not().

Failure to return a result can be programmed for ANY PREDICATE

*WITH A FINITE DOMAIN*

e.g. Boolean Predicates


if(X,Y) :- true(X) , true(Y)
if(X,Y) :- not(X) , true(Y)
if(X,Y) :- not(X) , not(Y)
not(if(X,Y)) :- true(X) , not(Y)

---------------

A predicate with more than 2 values!

gender(m). 1
gender(f). 2
not(gender(X)). 3

Prolog searches for a match from top to bottom,
it will return
--> gender(m)

or
--> not(gender(t)).

for any value other than m or f!

You can PROGRAM the predicate NOT(...)

for any predicate with a FINITE SET OF ARGUMENT VALUES!


Herc
--
www.microPROLOG.com

if( if(t(S),f(R)) , if(t(R),f(S)) ).
if it's sunny then it's not raining
ergo
if it's raining then it's not sunny

Graham Cooper

unread,
Nov 20, 2012, 4:21:06 AM11/20/12
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
> A predicate with more than 2 values!
>
> gender(m).            1
> gender(f).                2
> not(gender(X)).         3
>
> Prolog searches for a match from top to bottom,
> it will return
> --> gender(m)
>
> or
> --> not(gender(t)).
>
> for any value other than m or f!
>


Correction... it will match X to 'm' or 'f' if you search for
not(gender(m))

You have to specify the final option(s).

gender(m).
gender(f).
not(gender(t)).
not(gender(o)).

Herc

Frederick Williams

unread,
Nov 20, 2012, 8:52:43 AM11/20/12
to
Graham Cooper wrote:
>
> Exactly the same way we use not().
>
> Failure to return a result can be programmed for ANY PREDICATE
>
> *WITH A FINITE DOMAIN*
>
> [...]
>
> You can PROGRAM the predicate NOT(...)
>
> for any predicate with a FINITE SET OF ARGUMENT VALUES!

Is this "negation as failure"?

--
When a true genius appears in the world, you may know him by
this sign, that the dunces are all in confederacy against him.
Jonathan Swift: Thoughts on Various Subjects, Moral and Diverting

Graham Cooper

unread,
Nov 20, 2012, 3:33:47 PM11/20/12
to
On Nov 20, 11:52 pm, Frederick Williams
<freddywilli...@btinternet.com> wrote:
> Graham Cooper wrote:
>
> > Exactly the same way we use not().
>
> > Failure to return a result can be programmed for ANY PREDICATE
>
> > *WITH A FINITE DOMAIN*
>
> > [...]
>
> > You can PROGRAM the predicate NOT(...)
>
> > for any predicate with a FINITE SET OF ARGUMENT VALUES!
>
> Is this "negation as failure"?
>


It's Negation as OTHER.

You can hand program Negation in prolog code for any predicate with a
finite domain.

refundable(CUST) :- taxtype( CUST, personal )
refundable(CUST) :- taxtype( CUST, business )
refundable(CUST) :- taxtype( CUST, company )
not(refundable(CUST)) :- taxtype(CUST, other)


if( refundable(C) , processreturn(C) ).

This works for BOOLEAN ARG predicates like if, or, and, iff, xor,
nand, nor, ..

nand(X) :- not(X).

even if you nest them.

?- or( if(1,0) , if(1,X) )
X = 1

Herc
0 new messages