Quiz Stuff

Quiz 9; March 20; Time: 4 minutes; 3+2+1 points

  1. Write a predicate three(?N) that if called with 3, it succeeds. If called with an uninstantiated variable, it instantiates the variable to 3. If called with a value other than 3, it fails.
    ?- three(3).
    true.
    ?- three(X).
    X = 3.
    ?- three(5).
    false.
    
  2. Write a predicate gt10(+X,+Y) that succeeds iff the sum of X and Y is greater than 10. X and Y are assumed to be instantiated.
    ?- gt10(8,5).
    true.
    
  3. Does the following query succeed, or does it fail? (No need to explain why.)
    ?- three(A), three(B), C is A*B, gt10(C,C).