This problem uses the Logic starter file located here.

Write facts to define subtraction. You may use anything already included in the starter file linked above.

(fact (sub ; YOUR CODE HERE ))

Toggle Solution

(fact (sub ?x ?y ?z)
      (add ?z ?y ?x))

Here, we only need to define one fact because the base case is caught by in add. Subtraction is just addition with the arguments switched around so instead of x - y = z, we just manipulate it such that we have z + y = x.

I don't claim to be perfect so if you find an error on this page, please send me an email preferably with a link to this page so that I know what I need to fix!

comments powered by Disqus