INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

prolog program predicate

prolog program predicate

(OP)
Hi everybody,

I just start to learn Prolog.
I have to write a Prolog program where the Horn clauses and the goal will only consist of a predicate symbol, which thus will not be followed by a sequence of terms enclosed in parentheses.

What exactly means?
Something like this:

A :- B, C, D.
B.
C.
D :- E.
E.


and the goal A or another character.
Is it right? Someone can give me another example?

RE: prolog program predicate

That's correct but you must use lowercase letters :

CODE --> Prolog

a :- b, c, d.
b.
c.
d :- e.
e. 

RE: prolog program predicate

Notice that b, c and e are called "facts"

RE: prolog program predicate

(OP)
Thanks a lot!!!
and what exactly means that code?

that 'a' is true only if 'b' , 'c' and 'd' are true? right?

and the goal could be every letter that i use in the code?

RE: prolog program predicate

You should say "a succeeds only if b, c and d (so e) succeed".
Since b, c and e are facts, a succeeds.
Yes, every letter in this example can be a goal.

RE: prolog program predicate

(OP)
Thanks a lot!!! :)

I have a last question.. I have to write in C the and/or tree for this prolog file..
How can I do it? how I know when is an 'or' and when is an 'and'.

For example.. if the goal is 'a':

a
|
--------------------------
| | |
b c d
| | |
succeed succeed e
|
succeed

is it ok? but how i can make an 'or'? and to have a 'failure'?

RE: prolog program predicate

'or' is achieved with a semicolon ';'.
If I understand your question 'to have a failure' you can use \+ wich is the negation
\+a. gives 'false'

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close