1) Use the constant z for the number zero and the unary functor s for the successor function to denote the non-negative integers(e.g. S(s(z)) denotes 2), and define in PROLOG the predicate numeral (X,N), which is true iff X is the term corresponding to the number N, and also the predicates representing the unary function predessor, the binary functions addition, subtraction, multiplication and factorial, and the finary relations equal, less than, and greater than. Hint: Assuming that the predicate add(X,Y,Z) is true iff X+Y=Z, where X, Y, and Z are the decimals, addition could be defined in PROLOG as follows: addition(0,X,X). addition(Y,X,Z) :- V is Y-1, addition(V,X,W), Z is w+1.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *