Skip to content

Instantly share code, notes, and snippets.

Created April 19, 2020 19:55
What would you like to do?
Peano's Axioms in Prolog
% Peano's Axioms
:- module(peano, [
/** Peano's Axioms
* 1. 0 is a natural number
* 2. For every number x, x = x (reflexive property)
* 3. For all numbers x and y, if x = y, then y = x (symmetric property)
* 4. For all numbers x, y and z, if x = y and y = z, then x = z (transitive property)
* 5. For all a and b, if b is a natural number and a = b, then a is also a natural number (closed under equality)
* 6. For every number n, Successor(n) is a number (closed under a successor function)
* 7. For all numbers m and n, m = n if and only if Successor(m) = Successor(n) (Successor is an injection)
* 8. For every number n, Successor(n) = 0 is false (0 is the starting point of the numbers)
is_natural(succ(X)) :- is_natural(X).
pred(succ(X), X) :- is_natural(X).
equal(X, succ(_)) :- is_natural(X), \+ is_zero(X).
equal(X, X) :- is_natural(X).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment