JML

org.jmlspecs.models
Class JMLInfiniteIntegerClass

java.lang.Object
  extended byorg.jmlspecs.models.JMLInfiniteIntegerClass
All Implemented Interfaces:
Cloneable, Comparable, JMLComparable, JMLInfiniteInteger, JMLType, Serializable
Direct Known Subclasses:
JMLFiniteInteger, JMLNegativeInfinity, JMLPositiveInfinity

public abstract class JMLInfiniteIntegerClass
extends Object
implements JMLInfiniteInteger

Class with common code to implement JMLInfiniteInteger.

Version:
$Revision: 1.11 $
Author:
Gary T. Leavens
See Also:
BigInteger

Class Specifications
public invariant this.owner == null;

Specifications inherited from class Object
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this);

Specifications inherited from interface JMLInfiniteInteger
public invariant this.sign == -1||this.sign == 0||this.sign == 1;
instance public invariant this.sign == -1||this.sign == 0||this.sign == 1;
instance public invariant !this.is_infinite ==> this.finite_value != null&&this.sign == this.finite_value.signum();
instance public invariant_redundantly this.sign == 0 <==> !this.is_infinite&&this.finite_value.equals(java.math.BigInteger.ZERO);
instance public constraint this.nonnegative == \old(this.nonnegative);
instance public constraint this.sign == \old(this.sign);
instance public constraint this.is_infinite == \old(this.is_infinite);
instance public constraint this.finite_value == \old(this.finite_value);
instance public represents nonnegative <- this.sign >= 0;

Specifications inherited from interface Comparable
instance public invariant ( \forall java.lang.Comparable x; x != null; x.compareTo(x) == 0);
instance public invariant ( \forall java.lang.Comparable x, y; x != null&&y != null&&this.definedComparison(x,y)&&this.definedComparison(y,x); this.sgn(x.compareTo(y)) == -this.sgn(y.compareTo(x)));
instance public invariant ( \forall int n; n == -1||n == 1; ( \forall java.lang.Comparable x, y, z; x != null&&y != null&&z != null&&this.definedComparison(x,y)&&this.definedComparison(y,z)&&this.definedComparison(x,z); this.sgn(x.compareTo(y)) == n&&this.sgn(y.compareTo(z)) == n ==> this.sgn(x.compareTo(z)) == n));
instance public invariant ( \forall int n; n == -1||n == 1; ( \forall java.lang.Comparable x, y, z; x != null&&y != null&&z != null&&this.definedComparison(x,y)&&this.definedComparison(y,z)&&this.definedComparison(x,z); (this.sgn(x.compareTo(y)) == 0&&this.sgn(y.compareTo(z)) == n||this.sgn(x.compareTo(y)) == n&&this.sgn(y.compareTo(z)) == 0) ==> this.sgn(x.compareTo(z)) == n));
instance public invariant ( \forall java.lang.Comparable x, y, z; x != null&&y != null&&z != null&&this.definedComparison(x,y)&&this.definedComparison(x,z)&&this.definedComparison(y,z); this.sgn(x.compareTo(y)) == 0 ==> this.sgn(x.compareTo(z)) == this.sgn(y.compareTo(z)));

Model Field Summary
 
Model fields inherited from class java.lang.Object
_getClass, objectState, theString
 
Model fields inherited from interface org.jmlspecs.models.JMLInfiniteInteger
finite_value, is_infinite, nonnegative, sign
 
Ghost Field Summary
 
Ghost fields inherited from class java.lang.Object
objectTimesFinalized, owner
 
Constructor Summary
JMLInfiniteIntegerClass()
           
 
Model Method Summary
 
Model methods inherited from class java.lang.Object
hashValue
 
Model methods inherited from interface java.lang.Comparable
definedComparison, sgn
 
Method Summary
 JMLInfiniteInteger abs()
          Return the absolute value of this integer.
 Object clone()
          Return a clone of this integer.
abstract  int compareTo(non_null JMLInfiniteInteger n)
          Compare this to n, returning a comparison code.
 boolean equals(nullable Object o)
          Tell whether this integer is equal to the argument.
 boolean greaterThan(JMLInfiniteInteger n)
          Tell if this integer is strictly greater than the argument.
 boolean greaterThanOrEqualTo(JMLInfiniteInteger n)
          Tell if this integer is greater than or equal to the argument.
 boolean lessThan(JMLInfiniteInteger n)
          Tell if this integer is strictly less than the argument.
 boolean lessThanOrEqualTo(JMLInfiniteInteger n)
          Tell if this integer is less than or equal to the argument.
 JMLInfiniteInteger max(JMLInfiniteInteger n)
          Return the maximum of this integer and the argument.
 JMLInfiniteInteger min(JMLInfiniteInteger n)
          Return the minimum of this integer and the argument.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jmlspecs.models.JMLInfiniteInteger
add, compareTo, divide, doubleValue, finiteValue, floatValue, hashCode, isFinite, mod, multiply, negate, pow, remainder, signum, subtract, toString, toString
 

Constructor Detail

JMLInfiniteIntegerClass

public JMLInfiniteIntegerClass()
Method Detail

clone

public Object clone()
Return a clone of this integer.

Specified by:
clone in interface JMLType
Overrides:
clone in class Object
Specifications: (class)pure
Specifications inherited from overridden method in class Object:
       non_null
protected normal_behavior
requires this instanceof java.lang.Cloneable;
assignable \nothing;
ensures \result != null;
ensures \typeof(\result ) == \typeof(this);
ensures (* \result is a clone of this *);
     also
protected normal_behavior
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
     also
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures java.lang.reflect.Array.getLength(\result ) == java.lang.reflect.Array.getLength(this);
ensures ( \forall int i; 0 <= i&&i < java.lang.reflect.Array.getLength(this); ( \exists java.lang.Object result_i; result_i == java.lang.reflect.Array.get(\result ,i); (result_i == null&&java.lang.reflect.Array.get(this,i) == null)||(result_i != null&&result_i.equals(java.lang.reflect.Array.get(this,i)))));
     also
protected exceptional_behavior
requires !(this instanceof java.lang.Cloneable);
assignable \nothing;
signals_only java.lang.CloneNotSupportedException;
     also
protected normal_behavior
requires \elemtype(\typeof(this)) <: \type(java.lang.Object);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(int);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((int[])\result ).length == ((int[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((int[])this).length; ((int[])\result )[i] == ((int[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(byte);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((byte[])\result ).length == ((byte[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((byte[])this).length; ((byte[])\result )[i] == ((byte[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(char);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((char[])\result ).length == ((char[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((char[])this).length; ((char[])\result )[i] == ((char[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(long);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((long[])\result ).length == ((long[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((long[])this).length; ((long[])\result )[i] == ((long[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(short);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((short[])\result ).length == ((short[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((short[])this).length; ((short[])\result )[i] == ((short[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(boolean);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((boolean[])\result ).length == ((boolean[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((boolean[])this).length; ((boolean[])\result )[i] == ((boolean[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(float);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((float[])\result ).length == ((float[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((float[])this).length; (java.lang.Float.isNaN(((float[])\result )[i])&&java.lang.Float.isNaN(((float[])this)[i]))||((float[])\result )[i] == ((float[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(double);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((double[])\result ).length == ((double[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((double[])this).length; (java.lang.Double.isNaN(((double[])\result )[i])&&java.lang.Double.isNaN(((double[])this)[i]))||((double[])\result )[i] == ((double[])this)[i]);
Specifications inherited from overridden method in interface JMLType:
       pure
     also
public normal_behavior
ensures \result != null;
ensures \result instanceof org.jmlspecs.models.JMLType;
ensures ((org.jmlspecs.models.JMLType)\result ).equals(this);
    implies_that
ensures \result != null&&\typeof(\result ) <: \type(org.jmlspecs.models.JMLType);

equals

public boolean equals(nullable Object o)
Tell whether this integer is equal to the argument. Note that comparisons to BigIntegers are also handled.

Specified by:
equals in interface JMLInfiniteInteger
Overrides:
equals in class Object
See Also:
JMLInfiniteInteger.compareTo(Object), JMLInfiniteInteger.greaterThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.greaterThan(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThan(org.jmlspecs.models.JMLInfiniteInteger)
Specifications: (class)pure
Specifications inherited from overridden method equals(Object obj) in class Object:
       pure
public normal_behavior
requires obj != null;
ensures (* \result is true when obj is "equal to" this object *);
     also
public normal_behavior
requires this == obj;
ensures \result ;
     also
public code normal_behavior
requires obj != null;
ensures \result <==> this == obj;
     also
diverges false;
ensures obj == null ==> !\result ;
Specifications inherited from overridden method equals(Object o) in interface JMLInfiniteInteger:
       (class)pure
     also
public normal_behavior
requires o != null&&o instanceof org.jmlspecs.models.JMLInfiniteInteger;
{|
old org.jmlspecs.models.JMLInfiniteInteger n = (org.jmlspecs.models.JMLInfiniteInteger)o;
ensures \result <==> this.sign == n.sign&&this.is_infinite == n.is_infinite&&(!this.is_infinite&&!n.is_infinite ==> this.finite_value.compareTo(n.finite_value) == 0);
|}
     also
public normal_behavior
requires o != null&&o instanceof java.math.BigInteger;
{|
old java.math.BigInteger bi = (java.math.BigInteger)o;
ensures \result <==> !this.is_infinite&&this.finite_value.compareTo(bi) == 0;
|}
     also
public normal_behavior
requires o == null||!(o instanceof java.math.BigInteger||o instanceof org.jmlspecs.models.JMLInfiniteInteger);
ensures !\result ;
Specifications inherited from overridden method equals(Object ob2) in interface JMLType:
       pure
     also
public normal_behavior
ensures \result ==> ob2 != null&&(* ob2 is not distinguishable from this, except by using mutation or == *);
    implies_that
public normal_behavior
{|
requires ob2 != null&&ob2 instanceof org.jmlspecs.models.JMLType;
ensures ((org.jmlspecs.models.JMLType)ob2).equals(this) == \result ;
also
requires ob2 == this;
ensures \result <==> true;
|}

compareTo

public abstract int compareTo(non_null JMLInfiniteInteger n)
Compare this to n, returning a comparison code.

Parameters:
n - the object this is compared to.
Specifications: (class)pure
Specifications inherited from overridden method compareTo(Object o) in interface JMLInfiniteInteger:
       (class)pure
     also
public normal_behavior
requires o != null&&o instanceof org.jmlspecs.models.JMLInfiniteInteger;
{|
old org.jmlspecs.models.JMLInfiniteInteger n = (org.jmlspecs.models.JMLInfiniteInteger)o;
{|
requires this.lessThan(n);
ensures \result == -1;
also
requires this.equals(n);
ensures \result == 0;
also
requires this.greaterThan(n);
ensures \result == 1;
|}
|}
     also
public normal_behavior
requires o != null&&o instanceof java.math.BigInteger;
{|
requires this.is_infinite&&!this.nonnegative;
ensures \result == -1;
also
requires !this.is_infinite;
ensures \result == this.finite_value.compareTo((java.math.BigInteger)o);
also
requires this.is_infinite&&this.nonnegative;
ensures \result == 1;
|}
     also
public exceptional_behavior
requires o != null&&!(o instanceof org.jmlspecs.models.JMLInfiniteInteger)&&!(o instanceof java.math.BigInteger);
signals_only java.lang.ClassCastException;
Specifications inherited from overridden method compareTo(Object o) in interface JMLComparable:
       (class)pure
     also
public behavior
requires o != null;
ensures (* o is an instance of a comparable class *);
ensures (* if this is equal to o, then \result is 0 *)&&(* if this is less than o, then \result is negative *)&&(* if this is greater than o, then \result is positive *);
signals_only java.lang.ClassCastException;
signals (java.lang.ClassCastException) (* o is not an instance of a comparable class *);
Specifications inherited from overridden method compareTo(Object o) in interface Comparable:
       pure
public behavior
requires o != null;
ensures (* \result is negative if this is "less than" o *);
ensures (* \result is 0 if this is "equal to" o *);
ensures (* \result is positive if this is "greater than" o *);
signals_only java.lang.ClassCastException;
signals (java.lang.ClassCastException) (* the class of o prohibits it from being compared to this *);
     also
public behavior
requires o != null&&o instanceof java.lang.Comparable;
ensures this.definedComparison((java.lang.Comparable)o,this);
ensures o == this ==> \result == 0;
ensures this.sgn(\result ) == -this.sgn(((java.lang.Comparable)o).compareTo(this));
signals (java.lang.ClassCastException) !this.definedComparison((java.lang.Comparable)o,this);

greaterThanOrEqualTo

public boolean greaterThanOrEqualTo(JMLInfiniteInteger n)
Tell if this integer is greater than or equal to the argument.

Specified by:
greaterThanOrEqualTo in interface JMLInfiniteInteger
See Also:
JMLInfiniteInteger.equals(Object), JMLInfiniteInteger.compareTo(Object), JMLInfiniteInteger.greaterThan(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThan(org.jmlspecs.models.JMLInfiniteInteger)
Specifications: (class)pure
Specifications inherited from overridden method greaterThanOrEqualTo(JMLInfiniteInteger n) in interface JMLInfiniteInteger:
       (class)pure
public normal_behavior
requires n != null;
ensures \result <==> (this.is_infinite ==> (this.nonnegative||(!n.nonnegative&&n.is_infinite)))&&(!this.is_infinite ==> ((n.is_infinite&&!n.nonnegative)||this.finite_value.compareTo(n.finite_value) >= 0));
    implies_that
public normal_behavior
requires n != null;
{|
requires (this.nonnegative&&this.is_infinite)||(!n.nonnegative&&n.is_infinite);
ensures \result ;
also
requires (n.nonnegative&&n.is_infinite)||(!this.nonnegative&&this.is_infinite);
ensures !\result ;
also
requires !this.is_infinite&&!n.is_infinite;
ensures \result <==> this.finite_value.compareTo(n.finite_value) >= 0;
|}

lessThanOrEqualTo

public boolean lessThanOrEqualTo(JMLInfiniteInteger n)
Tell if this integer is less than or equal to the argument.

Specified by:
lessThanOrEqualTo in interface JMLInfiniteInteger
See Also:
JMLInfiniteInteger.equals(Object), JMLInfiniteInteger.compareTo(Object), JMLInfiniteInteger.greaterThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.greaterThan(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThan(org.jmlspecs.models.JMLInfiniteInteger)
Specifications: (class)pure
Specifications inherited from overridden method lessThanOrEqualTo(JMLInfiniteInteger n) in interface JMLInfiniteInteger:
       (class)pure
public normal_behavior
requires n != null;
ensures \result <==> n.greaterThanOrEqualTo(this);

greaterThan

public boolean greaterThan(JMLInfiniteInteger n)
Tell if this integer is strictly greater than the argument.

Specified by:
greaterThan in interface JMLInfiniteInteger
See Also:
JMLInfiniteInteger.equals(Object), JMLInfiniteInteger.compareTo(Object), JMLInfiniteInteger.greaterThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThan(org.jmlspecs.models.JMLInfiniteInteger)
Specifications: (class)pure
Specifications inherited from overridden method greaterThan(JMLInfiniteInteger n) in interface JMLInfiniteInteger:
       (class)pure
public normal_behavior
requires n != null;
ensures \result <==> !this.equals(n)&&this.greaterThanOrEqualTo(n);

lessThan

public boolean lessThan(JMLInfiniteInteger n)
Tell if this integer is strictly less than the argument.

Specified by:
lessThan in interface JMLInfiniteInteger
See Also:
JMLInfiniteInteger.equals(Object), JMLInfiniteInteger.compareTo(Object), JMLInfiniteInteger.greaterThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.greaterThan(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger)
Specifications: (class)pure
Specifications inherited from overridden method lessThan(JMLInfiniteInteger n) in interface JMLInfiniteInteger:
       (class)pure
public normal_behavior
requires n != null;
ensures \result <==> !this.equals(n)&&this.lessThanOrEqualTo(n);

abs

public JMLInfiniteInteger abs()
Return the absolute value of this integer.

Specified by:
abs in interface JMLInfiniteInteger
See Also:
JMLInfiniteInteger.negate()
Specifications: (class)pure
Specifications inherited from overridden method in interface JMLInfiniteInteger:
       non_null (class)pure
public normal_behavior
ensures \result != null&&\result .nonnegative&&\result .is_infinite == this.is_infinite&&(!\result .is_infinite ==> \result .finite_value.equals(this.finite_value.abs()));

max

public JMLInfiniteInteger max(JMLInfiniteInteger n)
Return the maximum of this integer and the argument.

Specified by:
max in interface JMLInfiniteInteger
See Also:
JMLInfiniteInteger.min(org.jmlspecs.models.JMLInfiniteInteger)
Specifications: (class)pure
Specifications inherited from overridden method max(JMLInfiniteInteger n) in interface JMLInfiniteInteger:
       non_null (class)pure
public normal_behavior
requires n != null;
{|
requires this.greaterThanOrEqualTo(n);
ensures \result .equals(this);
also
requires n.greaterThanOrEqualTo(this);
ensures \result .equals(n);
|}

min

public JMLInfiniteInteger min(JMLInfiniteInteger n)
Description copied from interface: JMLInfiniteInteger
Return the minimum of this integer and the argument.

Specified by:
min in interface JMLInfiniteInteger
See Also:
JMLInfiniteInteger.max(org.jmlspecs.models.JMLInfiniteInteger)
Specifications: (class)pure
Specifications inherited from overridden method min(JMLInfiniteInteger n) in interface JMLInfiniteInteger:
       non_null (class)pure
public normal_behavior
requires n != null;
{|
requires this.lessThanOrEqualTo(n);
ensures \result .equals(this);
also
requires n.lessThanOrEqualTo(this);
ensures \result .equals(n);
|}

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.