peano-numbers

Pure Prolog Peano Number Apartness

▼魔方 西西 提交于 2021-01-15 22:47:17
问题 Lets assume there is pure_2 Prolog with dif/2 and pure_1 Prolog without dif/2. Can we realize Peano apartness for values, i.e. Peano numbers, without using dif/2? Thus lets assume we have Peano apartness like this in pure_2 Prolog: /* pure_2 Prolog */ neq(X, Y) :- dif(X, Y). Can we replace neq(X,Y) by a more pure definition, namely from pure_1 Prolog that doesn't use dif/2? So that we have a terminating neq/2 predicate that can decide inequality for Peano numbers? So what would be its

Times, Quotient and Remainder predicates in Prolog

会有一股神秘感。 提交于 2020-07-09 11:56:31
问题 how can I do the following. I needed to define the predicate shownumber (X,N) , which is true when the symbol X corresponds to the natural number N. For example, shownumber(s(zero),1) is true. Okay, now I've got a predicate: shownumber (zero, 0). shownumber (s (N), X): - shownumber (N, Y), X is Y + 1. Now I need to use the shownumber (X, Y) predicate to define: 1) times (X, Y, Z) which is true if X * Y = Z. 2) quotient (X, Y, Q) which is true if X / Y = Q (in natural number arithmetic) 3)