Package apron

Class Environment

java.lang.Object
apron.Environment
All Implemented Interfaces:
Serializable, Cloneable

public class Environment extends Object implements Cloneable, Serializable

Class of environments for level 1 objects.

An Environment is a set of integer-valued variables and a set of real-valued variable names. Level 1 objects (Abstract1, etc.) refer to variables by name, and are defined relative to an environment. In an environment, no two variables can have the same name (even an integer-valued and a real-valued).

An environment maps level 1 variable names to level 0 dimensions. First, it sorts variables into integer-valued variables first, and real-valued variables next. Each set of variables is further sorted in lexicographic order. Methods to add, remove, or permute variables in environments take care to maintain this order. Changes of environments on level 1 objects automatically apply any needed permutation required to retain consistency with the environment.

Environment objects are immutable.

An Environment object encapsulates an ap_environment_t Apron object allocated in the C heap.

See Also:
  • Constructor Details

    • Environment

      public Environment()
      Constructs an empty environment.
    • Environment

      public Environment(String[] intVars, String[] realVars)
    • Environment

      public Environment(Var[] intVars, Var[] realVars)
      Constructs an environment containing some integer-valued and some real-valued variables.

      All variable names must be distinct.

  • Method Details

    • finalize

      protected void finalize()
      Deallocates the underlying Apron object.
      Overrides:
      finalize in class Object
    • add

      public Environment add(String[] intVars, String[] realVars)
    • add

      public Environment add(Var[] intVars, Var[] realVars)
      Returns a new environment with some integer-valued and/or real-valued variables added.

      this is not modified.

      One or both array(s) can be null.

      Added variables must not already exist.

    • addPerm

      public Environment addPerm(String[] intVars, String[] realVars, Dimperm[] p)
    • addPerm

      public Environment addPerm(Var[] intVars, Var[] realVars, Dimperm[] p)
      Returns a new environment with some integer-valued and/or real-valued variables added.

      Similar to add(Var[], Var[]), but also returns in p[0] the level 0 dimension permutation induced by the variable addition in order to keep them sorted.

    • remove

      public Environment remove(String[] vars)
    • remove

      public Environment remove(Var[] vars)
      Returns a new environment with some variables removed.

      this is not modified.

      Removed variables must exist in this.

    • lce

      public Environment lce(Environment op)
      Returns the least environment extending this and op.

      this and op are not modified.

    • lce

      public static Environment lce(Environment[] ar)
      Returns the least environment extending all environments in ar.

      Environments in ar are not modified.

    • rename

      public Environment rename(String[] org, String[] dst)
    • rename

      public Environment rename(Var[] org, Var[] dst)
      Returns the environment obtained by mapping each variable named org[i] to dst[i].

      org[] and dst[] must have the same size.

    • rename

      public Environment rename(String[] org, String[] dst, Dimperm[] p)
    • rename

      public Environment rename(Var[] org, Var[] dst, Dimperm[] p)
      Returns the environment obtained by mapping each variable named org[i] to dst[i].

      Similar to rename(Var[], Var[]), but also returns in p[0] the level 0 dimension permutation to switch from the original to the renamed environment.

    • getDimension

      public Dimension getDimension()
      Returns the number of integer-valued and real-valued variables in the environment.
    • getSize

      public int getSize()
      Returns the total number of variables in the environment.
    • hasVar

      public boolean hasVar(String var)
    • hasVar

      public boolean hasVar(Var var)
      Whether a variable named var exists in the environment.
    • dimOfVar

      public int dimOfVar(String var)
    • dimOfVar

      public int dimOfVar(Var var)
      Returns the index associated to the variable in the environment.

      Throws an IllegalArgumentException if no such variable exists.

    • isInt

      public boolean isInt(String var)
    • isInt

      public boolean isInt(Var var)
      Whether the given variable is integer-valued.
    • isInt

      public boolean isInt(int dim)
      Whether the given dimension is integer-valued.
    • varOfDim

      public Var varOfDim(int dim)
      Returns the name of the variable at dimension dim.
    • getIntVars

      public Var[] getIntVars()
      Returns the set of integer-valued variable names, ordered in lexical order.
    • getRealVars

      public Var[] getRealVars()
      Returns the set of real-valued variable names, ordered in lexical order.
    • getVars

      public Var[] getVars()
      Returns the set of all variables, ordered by dimension.

      Integer-valued variables appear first, in lexicographic order, then real-valued variables, also in lexicographic order.

    • toString

      public String toString()
      Returns the list of variable names in the environment, ordered by dimension.
      Overrides:
      toString in class Object
    • dimchange

      public Dimchange dimchange(Environment e)
      Returns the dimension specification to add to convert a level 0 object on the environment this to a level 0 object on the super-environment e.

      e must be a super-environment of this.

    • dimchange2

      public Dimchange[] dimchange2(Environment e)
      Returns the dimension specification to add and to remove to convert a level 0 object on environment this to a level 0 object on environment e.

      To convert from a to b, assuming r=a.dimchange2(b), you should first add r[0] dimensions and then remove r[1] dimensions.

      The two environments must not have variables with the same name and different type.

    • isEqual

      public boolean isEqual(Environment e)
      Whether this and e are equal.
    • isIncluded

      public boolean isIncluded(Environment e)
      Whether this is a subset of e.
    • cmp

      public int cmp(Environment e)
      Returns -2 if the environments are incompatible, -1 if this is a subset of e, 0 if this and e are equal, 1 if this is a superset of e, and 2 otherwise, if this and e have a least common element.

      Note: -2 is returned when there exists a variable that is integer in one environment, and real in the other one.

    • hashCode

      public int hashCode()
      Returns a hash of the environment.
      Overrides:
      hashCode in class Object
    • clone

      public Environment clone()
      Returns this (as Environment are immutable).
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object x)
      Whether x is a Generator1 and structurally equal to this.
      Overrides:
      equals in class Object