0

I am trying a theorem proving program. But Rule 4 seems to be badly implemented.

% delete
del(X, [X | Tail], Tail).
del(X, [Y | Tail], [Y | Tail1]) :-
    del(X, Tail, Tail1).

% remove 
remove(X, Y, L1, L2) :-
    del(X, L1, L3),
    del(Y, L3, L2).

% prove
prove(true).
prove([L1 seq L2]) :-
    seq(L1, L2),
    !.

% Rule 1
seq(L1, L2) :-
    member(X, L1),
    member(X, L2),
    !.

% Rule 4
seq(L1, L2) :-
    Z = or(X, Y),
    del(Z, L2, L4),
    remove(X, Y, L3, L4),
    seq(L1, L3).

prove([[p] seq [q]]). -- Generates false, which is correct.
prove([[p] seq [q, r]]). -- Generates false, correct.
But prove([[p] seq [q or r]]). -- Out of global stack. Then I think there is something wrong with Rule 4.
Any idea how to fix this problem? Thanks a lot.

false
  • 10,264
  • 13
  • 101
  • 209
Yue Yu
  • 1
  • Your entire program, please? I just see that you need an operator declaration for `seq` – false Aug 30 '14 at 17:19

1 Answers1

0

In Rule 4, as best I can tell, you

  • Set Z to be a template for an or
  • Try to remove that template from L2, so that L4 is what gets left behind, and the components of that template (X and Y) get filled in,
  • Find an L3 from which the components of the or can be removed to also give L4,
  • And then you try to solve the problem with L3 instead of L2

But this means that L3 isn't necessarily making any progress toward termination.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101