CPS 721 Quiz 2
2021 Practice Version
(not shared) Switch account
Evaluating a Query in Prolog
Copyright By Assignmentchef assignmentchef
Refer to the knowledge base below for the following questions.
1. p(2,2,4).
2. p(4,2,6).
3. p(3,3,6).
4. q(2,2).
5. q(3,3).
6. q(X,Y):- p(Z,Y,X), q(Z,Y).
Questions are marked automatically; be sure to follow the specified format when responding to short- answer questions.
Record the order in which the numbered lines from the knowledge base are applied when the query ?- q(6,Y). is evaluated in Prolog. Use a comma to separate the numbers. Do not use spaces. Example: 1,2,3
Your answer
For the query ?- q(6,Y) what is the first value for Y that Prolog would produce? Enter an integer only.
Your answer
Evaluating an Arithmetic Query
What would Prolog answer for the following query?
?- X = 2 + 1, Y = 5, Y is X + 2
X = 2 + 1, Y = 2 + 1 + 2
Error: variables are not sufficiently instantiated X = 3, Y = 3 + 2
The query would fail
X = 3, Y = 5
X = 2 + 1, Y = 5
Constructing an Arithmetic Query
Choose the portion of a Prolog query which will correctly perform the specified computations. Assume that both X and Y already have integer values from earlier in the query.
Multiply X by 2, and multiply Y by 3. Ensure that the sum of the resulting values is less than 100.
X1 = X*2, Y1 = Y*2, Z is X1+Y1 < 100. Z = (X*2) + (Y*3), not Z == 100.X1 = 2*X, Y1 = 2*Y, X1+Y1 < 100.99 = 2*X+3*Y.X is 2*X, Y is 3*Y, 100 > X+Y.
X1 is X*2, Y1 is Y*3, Z is X1+Y1, Z < 100.Never submit passwords through Google Forms.This form was created inside of. Report AbuseClear form CS: assignmentchef QQ: 1823890830 Email: [email protected]
Reviews
There are no reviews yet.