title: Calculating Time Difference in Prolog
body: <p>I'm having some trouble writing a relatively simple predicate in Prolog. This predicate is supposed to receive two arguments in the format Hours:Minutes, calculate the difference between the two and check if that value is greater or equal to 40 minutes.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>time(Time1, Time2):- 
      X:Y =:= Time1, A:B =:= Time2, calculate_time(X, Y, A, B).
  
  calculate_time(X, Y, A, B):-
      Y - X =:= 0,
      B - A &gt;= 40, !.
  calculate_time(X, Y, A, B):-
      Y - X &gt; 0.
  </code></pre>
  
  <p>This, as you can imagine, is giving an error, namely:</p>
  
  <pre><code>?- time(10:00, 10:55).
   ERROR at  clause 1 of user:time/2 !!
   INSTANTIATION ERROR- in arithmetic: expected bound value
  </code></pre>
  
  <p>So, as far as I can understand, he thinks that he's been given four arguments. Why is he reacting this way? Also, at the beginning of the file, I have the following commands:</p>
  
  <pre><code>:-op(500,xfy,:).
  :-op(600,xfy,/).
  </code></pre>
  
  <p>This predicate is supposed to be a part of a larger program, so these two lines need to stay in the file. I'm not using any module and I'm using YAP.</p>
  
  <p>Any help would be appreciated!</p>