问题描述
让我们假设有带 dif/2 的 pure_2 Prolog 和不带 dif/2 的 pure_1 Prolog.我们能不能意识到值的 Peano 分离度,即 Peano 数字,不使用 dif/2?因此,让我们假设我们在 pure_2 Prolog 中有这样的 Peano 分离:
Lets assume there is pure_2 Prolog with dif/2 and pure_1 Prolog without dif/2. Can we realizePeano 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).
我们能否用更纯的定义替换 neq(X,Y),即来自不使用 dif/2 的 pure_1 Prolog?所以我们有一个终止的 neq/2 谓词可以决定皮亚诺数的不等式?那么它的定义是什么?
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 definition?
/* pure_1 Prolog */
neq(X, Y) :- ??
推荐答案
Using less
from 此评论:
Using less
from this comment:
less(0, s(_)).
less(s(X), s(Y)) :- less(X, Y).
neq(X, Y) :- less(X, Y); less(Y, X).
这篇关于Pure Prolog Peano Number 公寓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!