Skip to content

Instantly share code, notes, and snippets.

@littlebenlittle
Last active May 16, 2020 16:51
Show Gist options
  • Save littlebenlittle/963186085def7b507e3917f7f5f8a640 to your computer and use it in GitHub Desktop.
Save littlebenlittle/963186085def7b507e3917f7f5f8a640 to your computer and use it in GitHub Desktop.
Peanos Axioms for the natural numbers in just a few lines of prolog
zero.
nat(zero).
nat(X) :-
nat(Y),
suc(Y,X).
one.
suc(zero,one).
two.
suc(one,two).
otherZero.
nat(otherZero).
eq(X,Y) :- X==Y.
eq(X,Y) :-
suc(X,A),
suc(Y,B),
eq(A,B).
otherOne.
suc(otherZero,otherOne).
suc(otherOne,two).
% try ?- eq(zero,otherZero)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment