I have this graph structure representing data flow in Prolog.
The function definition_clear_path
should compute the definition-clear path of any variable.
When I run this I get the following error:
definition_clear_path/3: Undefined procedure: definition_clear_path1/4
However, there are definitions for:
definition_clear_path/3
When I enter the rule for definition_clear_path1
from the terminal I get Syntax error: Operator expected
. Why?
edge(1, 2).
edge(1,3).
edge(3,7).
edge(3,4).
edge(4,6).
edge(4,5).
edge(7,x).
def(p,1).
def(e,1).
def(d,1).
def(x,1).
def(c,1).
def(d,4).
def(t,4).
def(c,5).
def(x, 6).
def(c,6).
use(d,3).
use(e,3).
use(d,4).
use(c,4).
use(x,4).
use(t,4).
use(c,5).
use(x,6).
use(c,6).
use(d,6).
use(x,7).
pos_path(X,Y, [X,Y]):- edge(X,Y).
pos_path(Start, End, [Start|T]) :- edge(Start,Mid), pos_path(Mid, End, T).
definition_clear_path( Node , J , Var ):- definition_clear_path1( Node , J , Var , [ Node ] ) .
definition_clear_path1(B , J, K , F):- edge (B , J ).
definition_clear_path1( Node , J , Var , L):-
edge ( Node , N1 ) ,
not(def( Var , N1 )) ,
not(use( Var , N1 )) ,
definition_clear_path1( N1 , J , Var , [ Node | L ] ) .
Remove the space between edge and the opening parenthesis. Spaces delimit terms, so Prolog will think that edge is an operator rather than the functor of a compound term.
Because of the problems of negation-as-failure, negation in Prolog is represented in modern Prolog interpreters using the symbol \+ , which is supposed to be a mnemonic for not provable with the \ standing for not and the + for provable.
Remove the space between edge
and the opening parenthesis.
Spaces delimit terms, so Prolog will think that edge
is an operator rather than the functor of a compound term.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With