Prolog System Predicates- Cut and Fail- a quiz

Hello friends. Today I was having my Prolog exams. There I had a very interesting question that I would like to share with you.

Ques: If there are N one argument facts for the predicate named 'test1' and M one argument facts for the predicate named 'test2'.
This would be like:
test1(1).      test2(1).
test1(2).      test2(2).
test1(3).      test2(3).
|                  |
test1(n).      test2(m).
Now find the maximum number of possible answers all the values of z for the query 'z' as:
?-z.
where the rule z in various cases is:
1. z:- test1(X), !, test2(X).

2. z:- test1(X), test2(X), !.

3. z:- !, test1(X), test2(X).

4. z:- test1(X), fail, test2(X).

5. z:- test1(X), !, test2(Y).

6. z:- test1(X), test2(Y), !.

7. z:- !, test1(X), test2(Y).

8. z:- test1(X), test2(Y), fail.
Feel free to ask any question on this topic.😀

Replies

  • Deepika Bansal
    Deepika Bansal
    No answer till now. Friends if you're having any doubt, please share with me, I'll help you to the best of my knowledge. We can start prolog from the very beginning if you want.

You are reading an archived discussion.

Related Posts

Recently Bharat won world cup. I had a comparison. We have also won it in 1983. The total prizes won by team were Rs.1.33 Million (13 lakh 30 Thousand) In...
European Robotics (Robot) League (ERL) On 23 April 2011 the first European Robotics Contest will take place in Michelsen Arena of LCC International University in KlaipÄ—da, Lithuania. Its objective is...
I got the news from a friend about his friend committing suicide out of frustration or guilt of not passing the 1st year examination. 😲 And I was shocked! We...
Hey there guys, i needed to design a vlan for part of my university coursework. I was hoping that some of you pros here can have a look at it...
Hey, is anyone familiar with the use of PEM fuel cell with regenerative braking system for a HEV? I'm trying to incorporate this system into a golf cart for my...