Abella logo (small)

ackermann.thm

%% Proof that the Ackermann function is total %% %% This is a very small example that requires nested inductions. Kind nat type. Type z nat. Type s nat -> nat. Define nat : nat -> prop by nat z ; nat (s X) := nat X. Define ack : nat -> nat -> nat -> prop by ack z N (s N) ; ack (s M) z R := ack M (s z) R ; ack (s M) (s N) R := exists R', ack (s M) N R' /\ ack M R' R. Theorem ack_total : forall M N, nat M -> nat N -> exists R, nat R /\ ack M N R. IHM : induction on 1. IHN : induction on 2. intros HnatM HnatN. case HnatM (keep). - search. - HnatMpred => case HnatN. + apply IHM to HnatMpred _ with N = s z. search. + HnatNpred => HnatR : apply IHN to HnatM HnatNpred. apply IHM to HnatMpred HnatR. search.