Question: /* Problem 1a: Programming with matching. A line can be defined by 2 points. A point has an x and y coordinate. A line is
/* Problem 1a: Programming with matching. A line can be defined by 2 points. A point has an x and y coordinate. A line is vertical if both points have the same x value. A line is horizontal if both points have the same y values. The following is a knowledge base which specify what is meant for a line to be vertical or horizontal respectively. This example is due to Ivan Bratko. */
vertical(line(point(X,_),point(X,_))). horizontal(line(point(_,Y),point(_,Y))).
/* 1. Name the clauses, predicates, rules, and facts. 2. Name the atoms, variables, and data structure constructors. */
/* Problem 1b: A way of writing numerals, which is sometimes used in mathematical logic, makes use of just four symbols: 0, succ , and the left and right parentheses. The following is the knowledge base for this representation of a numeral. The predicate 'add' is the definition of adding this representation of numbers.
Use this base you should use to answer the question. (Reference 3.1 example 3 Learn Prolog Now! http://www.learnprolognow.org/lpnpage.php?pagetype=html&pageid=lpn-htmlse9) */
numeral(0). numeral(succ(X)) :- numeral(X).
add(0,Y,Y). add(succ(X),Y,succ(Z)) :- add(X,Y,Z).
/* 1. Name the clauses, predicates, rules, and facts. 2. Name the atoms, variables, and data structure constructors. */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
