title: Greater than operator in prolog
body: <p>I am working on SWI Prolog. I have some facts in my database. I am unable to figure out how to use 'greater than' operator(>) when constructing a new rule.</p>
  
  <p>I have some facts of the form</p>
  
  <pre><code>student(john,3.2,cs).
  student(mike,3.9,cs).
  </code></pre>
  
  <p>showing that john is a student, has a 3.2 cgpa, and belongs to CS department, similarly for mike. </p>
  
  <p>Now i want to add a rule to my database</p>
  
  <p>deanlist(X) which will return true if X's cgpa is greater than 3.8</p>
  
  <p>According to my knowledge, i can add this rule as follows</p>
  
  <pre><code>deanlist(X):-
     X's cgpa is greater than 3.8
  </code></pre>
  
  <p>if i go with brute force approach, i can enlist all possibilites of cgpa greater than 3.8 using OR operator. Like i can add rule like </p>
  
  <pre><code>deanlist(X):-
     student(X,3.81,cs)
   ; student(X,3.82,cs)
   ; student(X,3.82,cs)
   .......so on to
     student(X,4.0,cs).
  </code></pre>
  
  <p>But i don't want to go that way because it becomes hard coded and should be avoided. </p>
  
  <p>I have explore the following links </p>
  
  <p><a href="http://boklm.eu/prolog/page_10.html#101" rel="nofollow">http://boklm.eu/prolog/page_10.html#101</a></p>
  
  <p><a href="http://www.swi-prolog.org/pldoc/man?section=operators" rel="nofollow">http://www.swi-prolog.org/pldoc/man?section=operators</a></p>
  
  <p>But i could not figure out how to use greater than operator in my case.</p>
  
  <p>Please tell me how to use greater than operator in this case. 
  Thanks</p>