
tabs(N,X) :-
    N1 is N,
    forall(between(1,N1,_),print(X)).

showts1(X,L) :-
    tabs(L,'|  '),print(X),nl.

showts(X) :- 
    print(X),nl,nl,
    forall(runiv(X,Y,0,L), showts1(Y,L)).

runiv(X,X,L,L) :- atomic(X).
runiv(In, X,L0,L) :-
    nonvar(In),
    In =.. [A,B|C],
    (runiv(A,X,L0,L)
    ; member(Y,[B|C]),
      runiv(Y,X,L0+1,L)).

about(X) :- 
    nl, forall(current_op(P,A,X),(print(op(P,A,(X))),nl)).


:- op(920,xfx,if).
:- op(910,xfx,then).
:- op(900,xfy,or).
:- op(890,xfy,and).
:- op(880,fy,not).
:- op(1,fx,rule).

demo(1) :- showts(1+2+3+4), about(+).
demo(2) :- showts((1,2,3,4)), about((,)).
demo(3) :- showts(s(np(det(the),noun(man)),vp(v(sees)))).
demo(4) :- showts(s(np(det(the),noun(man)),vp(v(sees),pp(in_the_house)))).
demo(5) :- showts(s(np(det(the),noun(man)),vp(v(sees),pp(p(in),np(the_house))))).
demo(6) :- showts(s(np(det(the),noun(man)),vp(v(sees),pp(p(in),np(det(the),noun(house)))))).
demo(7) :- showts(if(rule(1),then(or(not(x),and(a,and(b,c))),and(d,e)))).
demo(8) :- showts(rule 1 if not x or a and b and c then d and e).


demos :- 
	clause(demo(N),X), 
	nl,print('%-----| '),print(N),
        print(' |--------------------------------'), 
        nl,nl,call(X),fail.
demos.
