0

I am trying to create a knowledge base. My problem has gate/1 and terminal/1 and I have defined the following rule:

gate(G) /\ terminal(T) :- (G \== T \== 1 \== 0).

What I am trying to say is that: "If there exists a gate G and a terminal T, then that implies that G is not equal to T is not equal to 1 is not equal to 0.

I get the following error: ERROR: c:/noob.pl:140:0: Syntax error: Operator priority clash

I don't even know if I am using the correct operators.

false
  • 10,264
  • 13
  • 101
  • 209
karancan
  • 2,152
  • 4
  • 23
  • 35

1 Answers1

1

The problem is in

G \== T \== 1 \== 0

which should be written

G \== T, G \== 1, G \== 0, T \== 1, T \== 0
Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • Thanks that works. For the sake of simplicity, I left out a few symbols that were not equal to each other. With all of them included, it becomes a very long statement :O – karancan Mar 10 '13 at 22:39
  • @karancan: with more than a couple of values that should be different, it may be worthwhile to use `setof`: `List = [G, T, 0, 1], setof(List, Set), length(List, N), length(Set, N).` – Fred Foo Mar 10 '13 at 22:42
  • I should look into that. I have just one more questions to ask- I hope you dont mind. I have a fact: `connected(A,B) :- connected(B,A)` . Then when I ask the question `connected(X,Y)` I get an infinite number of results (infinite recursion). I just want to a rule that is commutative. Could you guide me with this? – karancan Mar 10 '13 at 22:45
  • @karancan: open a new question for that (and be sure to search SO first, it's bound to have been asked before). – Fred Foo Mar 10 '13 at 23:02
  • Added a new question http://stackoverflow.com/questions/15328936/trying-to-implement-commutativity-in-prolog – karancan Mar 10 '13 at 23:27