13.5 Comparisons


 
Building Parsers with Java
By Steven  John  Metsker

Table of Contents
Chapter  13.   Logic Programming

    Content

A comparison compares the values of two terms, which can be variables , atoms , or arithmetic terms. The comparison operator is the functor of a comparison structure, and the comparison's terms are the terms of this structure. For example, a valid comparison can compare 9*11 to 100 :

 <(9*11, 100) 

You can issue a comparison as a query to the Logikus IDE. Regardless of the program that is present in the IDE, this comparison is true ”99 is less than 100. If you enter this query and press Next, the results area displays yes . If you press Next again, the results area displays no . There is only one proof of the comparison, and thus there is no other way to prove its truth.

Logikus recognizes the following operators in comparisons:

 <, >, =, <=, >=, != 

The terms in a comparison can be atoms. For example,

 >= (volleyball, golfball) 

is a valid comparison, and it is true because the Unicode value of v is greater than the Unicode value of g . (We might also say that "volleyball" comes alphabetically , or lexicographically, after "golfball" .)

Comparisons can also contain variables, a useful capability when a comparison appears in a rule.


   
Top


Building Parsers with Java
Building Parsers With Javaв„ў
ISBN: 0201719622
EAN: 2147483647
Year: 2000
Pages: 169

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net