harpoon.Util.Constraints
Class InclusionConstraints

java.lang.Object
  |
  +--harpoon.Util.Constraints.InclusionConstraints

public class InclusionConstraints
extends Object

InclusionConstraints is a simple solver for inclusion constraints. A system of inclusion constraints is a set of constraints of the form "T1 included in T2" where each term Ti is either a variable or a set of atoms.

Here is a simple example:

  1. V0 included in V1
  2. {1, 2} included in V0
  3. {3} included in V1

Solving a system of inclusion constraints means finding a mapping variable -> set of atoms such that when we replace each variable with the corresponding set of atoms, all constraints are satisfied. A possible solution for the previous constraint system is V0 = {1, 2}, V1 = {1, 2, 3}. Here's another one V0 = {1, 2, 100}, V1 = {1, 2, 3, 100, 1000}.

We'll always study the least possible solution. Note that a system of inclusion constraints can be unfeasible: just add the constraint V1 included in {} to the previous example.

Version:
$Id: InclusionConstraints.java,v 1.1 2002/04/02 23:54:15 salcianu Exp $
Author:
Alexandru SALCIANU <salcianu@MIT.edu>

Nested Class Summary
static class InclusionConstraints.AtomSet
          Set of atoms term for the inclusion constraints.
static class InclusionConstraints.Term
          Root of the term class hierarchy.
static class InclusionConstraints.TermVisitor
          Visitor for Term.
static class InclusionConstraints.Var
          Variable for the inclusion constraints.
 
Constructor Summary
InclusionConstraints()
           
 
Method Summary
 void addConstraint(InclusionConstraints.Term t1, InclusionConstraints.Term t2)
          Adds the inclusion constraint t1 included in t2.
 Map solve()
          Solves this system of inclusion constraints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InclusionConstraints

public InclusionConstraints()
Method Detail

addConstraint

public void addConstraint(InclusionConstraints.Term t1,
                          InclusionConstraints.Term t2)
Adds the inclusion constraint t1 included in t2. Each ti can be either a variable or a set of atoms.

See Also:
InclusionConstraints.Var, InclusionConstraints.AtomSet

solve

public Map solve()
          throws Unfeasible
Solves this system of inclusion constraints.

Returns:
If the system is feasible, returns a map that assigns to each variable from the constraint system a set of atoms; this assignment is the least possible solution of the system.
Throws:
Unfeasible - if the system is unfeasible.
Unfeasible