The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » sci.math.* » sci.math

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: PROLOG does SO have NOT() !!
Replies: 3   Last Post: Nov 20, 2012 3:33 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Graham Cooper

Posts: 4,495
Registered: 5/20/10
PROLOG does SO have NOT() !!
Posted: Nov 20, 2012 3:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Exactly the same way we use not().

Failure to return a result can be programmed for ANY PREDICATE


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)

--> 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!


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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.