title: Changing tedge/2 predicate from Lu & Mead's Prolog: A Tutorial Introduction
body: <p>the booklet "Prolog: A tutorial Introduction", by James Lu and Jerud Mead (available as a PDF in the Internet) features the predicate tedge/2 like this: </p>
  
  <pre><code>tedge(Node1,Node2) :-
     edge(Node1,SomeNode),
     edge(SomeNode,Node2).
  </code></pre>
  
  <p>I would like to change it to accept only nodes not directly connected by an edge. There's an easy way:</p>
  
  <pre><code>    tedge(Node1,Node2) :-
         edge(Node1,SomeNode),
         edge(SomeNode,Node2),
         \+ edge(Node1,Node2).
  </code></pre>
  
  <p>But when I imposed that <code>Node1</code>, <code>SomeNode</code>, and <code>Node2</code> should be different, like this: </p>
  
  <pre><code>tedge(Node1,Node2):-
     edge(Node1,SomeNode),
     edge(SomeNode,Node2),
     Node1 \= Node2, Node1 \= SomeNode, Node2 \= SomeNode.
  </code></pre>
  
  <p>It didn't work as expected. That is: for nodes a and b where with edge(a,b), the predicate tedge(a,b) would be true. </p>
  
  <p>Could you please tell me why ?</p>