Question: PROLOG Question : Implement PROLOG program for plus, times, and greater than using the successor representation of natural numbers and write a PROLOG program for
PROLOG
Question :
Implement PROLOG program for plus, times, and greater than using the successor representation of natural numbers and write a PROLOG program for computing the quotient and remainder of two numbers (use the successor representation of numbers).
Fill the code:
num(0).
num(s(X)) :- num(X).
% Helper func, converts decimal repr of peano num and back.
peano_to_decimal_rec(0, 0).
peano_to_decimal_rec(s(X), Y) :- peano_to_decimal_rec(X, N), Y is N + 1.
peano_to_decimal(X, Y) :- once(peano_to_decimal_rec(X, Y)).
% Comparison
% equal
equal(X, X).
% less than (add base cases when needed)
less_than(X, Y) :-
write("Error: Not Implemented"), false.
% greater than (add base cases when needed)
greater_than(X, Y) :-
write("Error: Not Implemented"), false.
% addition (add base cases when needed)
add(Addend, Augend, Sum) :-
write("Error: Not Implemented"), false.
% multiplication (add base cases when needed)
multiply(Multiplicand, Multiplier, Product) :-
write("Error: Not Implemented"), false.
Quotient And Remainder
divide(Dividend, Divisor, Quo, Rem) :-
write("Error: Not Implemented"), false.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
