Term comparison

These predicates test the ordering of two terms as defined by the specification.

A goal executing any of these built-in predicates simply succeeds or fails; there is no side effect, unification, or error.

1. @=</2 (term less than or equal), ==/2 (term identical), \==/2 (term not identical), @</2 (term less than), @>/2 (term greater than), @>=/2 (term greater than or equal)

These predicates also test the identity and term-precedence of their arguments. As an example, '@=<'(X, Y) is true iff X preceds Y as defined by the specification, or X and Y are identical terms.

Templates and modes for the predicate are as follows:

'@=<'(@term, @term)
'=='(@term, @term)
'\\=='(@term, @term)
'@<'(@term, @term)
'@>'(@term, @term)
'@>='(@term, @term)

1.1 Example tests

Let's start with some simple tests verifying success of failure of single goals.

alice.tuprolog.SimpleGoalFixture
goalsuccess()
'@=<'(1.0, 1). true
'@<'(1.0, 1). true
'\\=='(1, 1). false
'@=<'(aardvark, zebra). true
'@=<'(short, short). true
'@=<'(short, shorter). true
'@>='(short, shorter). false
'@<'(foo(a, b), north(a)). false
'@>'(foo(b), foo(a)). true
'@<'(foo(a, X), foo(b, Y)). true
'@<'(foo(X, a), foo(Y, b)). true
'@=<'(X, X). true
'=='(X, X). true
'@=<'(X, Y). true
'=='(X, Y). false
\==(_, _). true
alice.tuprolog.MalformedGoalException
at alice.tuprolog.Prolog.solve(Prolog.java:407)
at alice.tuprolog.SimpleGoalFixture.success(SimpleGoalFixture.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fit.TypeAdapter.invoke(Unknown Source)
at fit.TypeAdapter.get(Unknown Source)
at fit.Fixture.check(Unknown Source)
at fit.ColumnFixture.check(Unknown Source)
at fit.ColumnFixture.doCell(Unknown Source)
at fit.Fixture.doCells(Unknown Source)
at fit.Fixture.doRow(Unknown Source)
at fit.ColumnFixture.doRow(Unknown Source)
at fit.Fixture.doRows(Unknown Source)
at fit.ColumnFixture.doRows(Unknown Source)
at fit.Fixture.doTable(Unknown Source)
at fit.Fixture.interpretTables(Unknown Source)
at fit.Fixture.doTables(Unknown Source)
at fit.FileRunner.process(Unknown Source)
at fit.FileRunner.run(Unknown Source)
at fit.FileRunner.main(Unknown Source)
'=='(_, _). false
'@=<'(_, _). true
'@=<'(foo(X, a), foo(Y, b)). true

Run the tests!


The results of the tests for Term comparison are as follows:

fit.Summary
counts 14 right, 0 wrong, 0 ignored, 1 exceptions
input file D:\Silvia\Merge_Tesi\Tesi\test\termComparison.html
input update Tue Dec 23 03:02:00 CET 2008
output file D:\Silvia\Merge_Tesi\Tesi\test\report_Montanari\termComparison.html
run date Wed Sep 28 12:47:51 CEST 2011
run elapsed time 0:00.73