Prolog and Logical definitions of plus/subtract



Hello,

I know that the logical definition of and plus and subtract in Prolog
is:
plus(0,N,N).
plus(s(M),N,s(Z)) :- plus(M,N,Z).

where s(X) is the successor of number X.

However, what would you do if you wanted to represent negative numbers?


Thanks,
John

.



Relevant Pages

  • Re: Prolog and Logical definitions of plus/subtract
    ... John Todd a écrit: ... I know that the logical definition of and plus and subtract in Prolog ...
    (comp.lang.prolog)
  • Using the CAS to teach algebra
    ... I wonder if someone can help me understand what appears to me in my ignorance to be some odd behaviour in the CAS. ... In both cases the behaviour with the subtract has not been as I expected so the CAS is clearly not interpreting the expressions in the way I am. ... why is it not subtracting 225 from both sides and instead adding in eqn 2 and doing something I don't follow in eqn 1? ... However I really would prefer to avoid this because doing it this way means that the subtract is not being done simultaneously and, for a moment at least, the equation and its successor are not equivalent. ...
    (comp.sys.hp48)
  • Re: GNU prolog is not so reliable as SWI-prolog
    ... You should then consider the PDC Prolog, which is the successor of Turbo Prolog. ... the local stack under a Unix shell use: ...
    (comp.lang.prolog)