title: Prolog: Check if list of tuples is a function
body: <p>I want to check, if a list L of tuples (x1,y1) has the function property:</p>
  <pre><code>∀(x1,y1),(x2,y2) ∈ L (x1=x2  y1 = y2)
  </code></pre>
  <p>I tried to solve it with the following predicate:</p>
  <pre><code>m_Function(L) :-
      ((member(M1, L), member(M2, L), 
      M1 = (X1, Y1), M2 = (X2, Y2), X1 = X2) 
      -&gt; Y1 = Y2).
  </code></pre>
  <p>the problem of that is, that e.g. the input</p>
  <pre><code>L = [(p, q),  (p, r)]
  </code></pre>
  <p>results in true.</p>
  <p>The trace of my debug shows me I more exactly realised the statement:</p>
  <pre><code>∃(x1,y1),(x2,y2) ∈ L (x1=x2  y1 = y2)
  </code></pre>
  <p>trace:</p>
  <pre><code> T Call: (8) m_Function([(p, q),  (p, r)])
     Call: (8) m_Function([(p, q),  (p, r)]) ? creep
     Call: (9) lists:member(_5074, [(p, q),  (p, r)]) ? creep
     Exit: (9) lists:member((p, q), [(p, q),  (p, r)]) ? creep
     Call: (9) lists:member(_5074, [(p, q),  (p, r)]) ? creep
     Exit: (9) lists:member((p, q), [(p, q),  (p, r)]) ? creep
     Call: (9) (p, q)=(_5060, _5062) ? creep
     Exit: (9) (p, q)=(p, q) ? creep
     Call: (9) (p, q)=(_5066, _5068) ? creep
     Exit: (9) (p, q)=(p, q) ? creep
     Call: (9) p=p ? creep
     Exit: (9) p=p ? creep
     Call: (9) q=q ? creep
     Exit: (9) q=q ? creep
   T Exit: (8) m_Function([(p, q),  (p, r)])
     Exit: (8) m_Function([(p, q),  (p, r)]) ? creep
  </code></pre>
  <p>Is their in prolog some elegant way e.g. with some &quot;for all&quot;-quantifier which I can use to solve this kind of problem?</p>