.type Integer <: symbol

.decl succ (a:Integer, b:Integer)
.decl count_second(a:Integer)
.output count_second()
.decl count_third(a:Integer)
.output count_third()
.decl count_all(a:Integer)
.output count_all()

count_second("3").
count_second(n) :- succ(pn, n), succ(ppn, pn), count_second(ppn).

count_third("3").
count_third(n) :- succ(pn, n), succ(ppn, pn), succ(pppn, ppn), count_third(pppn).

count_all(x) :- count_second(x), count_third(x).


succ("0", "1").
succ("1", "2").
succ("2", "3").
succ("3", "4").
succ("4", "5").
succ("5", "6").
succ("6", "7").
succ("7", "8").
succ("8", "9").
succ("9", "10").
succ("10", "11").
succ("11", "12").
succ("12", "13").
succ("13", "14").
succ("14", "15").
succ("15", "16").
succ("16", "17").
succ("17", "18").
succ("18", "19").
succ("19", "20").
succ("20", "21").

