%% binary numbers

% first version, only works correctly in one direction
% inc_(+std, -std)

inc_(e,    b1(e)).
inc_(b0(M),b1(M)).
inc_(b1(M),b0(N)) :- inc_(M,N).

% inc(+std, -std), inc(-std,+std).

inc(e,        b1(e)).
% no case for inc(b0(e),_)
inc(b0(b0(M)),b1(b0(M))).
inc(b0(b1(M)),b1(b1(M))).
inc(b1(M),    b0(N)) :- inc(M,N).

std(e).
% no case for std(b0(e))
std(b0(b0(N))) :- std(b0(N)).
std(b0(b1(N))) :- std(b1(N)).
std(b1(N)) :- std(N).
