Question

Prolog: Given the following facts and predicates mystery(X,[X|R],R).             mystery(X,[F|R],[F|S]) :- mystery(X,R,S). What is the result...

Prolog:

Given the following facts and predicates

mystery(X,[X|R],R).
            mystery(X,[F|R],[F|S]) :- mystery(X,R,S).

What is the result L of the following query?
?- mystery(1,[1,2,3], L).

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

What is the arity of the following compound term?

            love(2,loves(richard, sarah), X).

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Prolog: Given the following facts and predicates mystery(X,[X|R],R).             mystery(X,[F|R],[F|S]) :- mystery(X,R,S). What is the result...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 13. What is the result of the following Prolog statements? ?- assert(test(N,R) :- R is N*N)....

    13. What is the result of the following Prolog statements? ?- assert(test(N,R) :- R is N*N). ?- maplist(test,[1,2,3,4],Rss). 14. Explain the behavior or goal of the following program xyz/3. xyz(X,[X|R],R). xyz(X,[F|R],[F|S]) :- xyz(X,R,S). ?- xyz(X,[1,2,3],L). 15. What is the arity of the following compound term? love(2,loves(richard, sarah), X).

  • 4. [201 Use Prolog (e.g., SWI-Prolog) to create a knowledge base for the family tree of...

    4. [201 Use Prolog (e.g., SWI-Prolog) to create a knowledge base for the family tree of Figure 1 and then ask queries about the family tree. Assume the intended interpretation of all predicates of the form p(x.y) is that "x is the p of y" George eMum r-Kydd Elizabeth Philip Margaret Diana-Charles Anne-Mark Andrew Sarah E William Harry Peter Zara Beatrice Eugenie Figure 1. A typical family tree. The symbol-connects spouses and arrows point to children. Enter the information from...

  • CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This...

    CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This Assignment Is About: Facts, Rules, Goals Prolog execution model Arithmetic operations . Recursive Rules B. Use the following Guidelines Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of...

  • Based on the prolog facts given below: 1.Given two medications, if they interact, tell what the...

    Based on the prolog facts given below: 1.Given two medications, if they interact, tell what the effect of the interaction may be. Note there may be more than one result of the interaction. 2. Given a medical condition, list the drug interactions that may have caused it. interacts(gatifloxacin,mometasone,asthma). interacts(gatifloxacin,cisplatin,hyperglycaemia). interacts(gatifloxacin,cisplatin,bone_marrow_failure). interacts(gatifloxacin,montelukast,difficulty_breathing). interacts(temazepam,thalidomide,neutropenia). interacts(temazepam,thalidomide,thrombocytopenia). interacts(temazepam,timolol,drowsiness). interacts(temazepam,tizanidine,acid_reflux). interacts(temazepam,tizanidine,heart_attack).

  • 1. Given the following predicates and premises: C(x): “ x is in this class” R(x): “...

    1. Given the following predicates and premises: C(x): “ x is in this class” R(x): “ x owns a yellow truck” T(x): “ x has gotten a parking ticket.” Premises C(Linda), R(Linda) , ∀x(R(x) → T(x)) Conclude that ∃x(C(x) ∧ T(x)) 2.Find the error/s in this argument that shows that if ∃xP(x) ∧ ∃xQ(x) is true then ∃x(P(x) ∧ Q(x)) is true. 1. ∃xP(x) ∧ ∃xQ(x) Premise 2. ∃xP(x) Simplification from (1) 3. P(c) Existential instantiation from (2) 4. ∃xQ(x)...

  • ///Program needs to write in prolog/// 6. A binary tree is either empty or it is...

    ///Program needs to write in prolog/// 6. A binary tree is either empty or it is composed of a root element and two successors, which are binary trees themselves. In Prolog we represent the empty tree by the atom 'nil' and the non-empty tree by the term t(X,L,R), where X denotes the root node and L and R denote the left and right subtree, respectively. The following Prolog term represents the given binary tree below. T1 = t(a,t(b,t(d,nil,nil),t(e,nil,nil)),t(c,nil,t(f,t(g,nil, nil),nil))) d...

  • Based on the prolog facts given below: 1.Given two medications, if they interact, tell what the...

    Based on the prolog facts given below: 1.Given two medications, if they interact, tell what the effect of the interaction may be. Note there may be more than one result of the interaction. 2. Given a medical condition, list the drug interactions that may have caused it. 3. Given a drug, list the drugs, which have no interactions with it. 4. Given a drug, list the drugs, which do interact with it. interacts(gatifloxacin,mometasone,asthma). interacts(gatifloxacin,cisplatin,hyperglycaemia). interacts(gatifloxacin,cisplatin,bone_marrow_failure). interacts(gatifloxacin,montelukast,difficulty_breathing). interacts(temazepam,thalidomide,neutropenia). interacts(temazepam,thalidomide,thrombocytopenia). interacts(temazepam,timolol,drowsiness). interacts(temazepam,tizanidine,acid_reflux)....

  • #s 1-5 in prolog Give an example of "or" relationship. Give an example of "and" relationship. Assume the following facts: parent(a,b). man(a). woman(c) 1. 2. 3. State a clause for...

    #s 1-5 in prolog Give an example of "or" relationship. Give an example of "and" relationship. Assume the following facts: parent(a,b). man(a). woman(c) 1. 2. 3. State a clause for father(a,b) 4. What would be the English meaning for this o prolog clause. o owner(jack, cat(X)) :- fur(X),spots(X) 5. Do the following terms unify? Why? likes(jax, X), and likes(X, jin). Give an example of "or" relationship. Give an example of "and" relationship. Assume the following facts: parent(a,b). man(a). woman(c) 1....

  • C++ Given the following recursive function: string mystery(strings) { == == if ($ "") return "";...

    C++ Given the following recursive function: string mystery(strings) { == == if ($ "") return ""; if (toupper(s[ 0 ]) 'A' || toupper(s[ 0 ]) || toupper(s[ 0 ]) 'I' || toupper(s [ 0 ]) || toupper(s [ 0 ]) 'U') 'E' 'O' == == == { return s.substr(0, 1) + mystery(s.substr(1, s.size() 1)); } return + mystery(s.substr(1, s.size() - 1)); } Show all the calls to the function and what each one returns to its predecessor. string result =...

  • Problem 4 Let S :R R be such that f (x + y) = f(x) +...

    Problem 4 Let S :R R be such that f (x + y) = f(x) + f(y) for all sy ER Also assume that limf () = LER. 1. Show that f (2x) = 2 (s). 2. Use the result from part 1 to determine the value of L.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT