Question: Expand the logic programming language to include arithmetic comparisons, =, . Hint: as in Exercise 20, modify solve to detect these comparisons before calling infer.
Expand the logic programming language to include arithmetic comparisons, =, <, and >.
Hint: as in Exercise 20, modify solve to detect these comparisons before calling infer. If an expression is a comparison, replace any variables with their values and evaluate it. If it returns nil, solve should return the empty stream; if it returns non-nil, solve should return a stream containing the initial substitution set. Assume that the expressions do not contain unbound variables. For a more challenging exercise, define = so that it will function like the PROLOG is operator and assign a value to an unbound variable and simply do an equality test if all elements are bound.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
