dk.brics.bisimulationGame.equiv
Class StateSpace

java.lang.Object
  extended by dk.brics.bisimulationGame.equiv.StateSpace

public class StateSpace
extends java.lang.Object

A representation of all nodes of two LTSs (S,T) partitioned into one or more blocks. Initially a state space contains one block, which contains all nodes. A state space is created when one player plays against the computer, and is used to calculate winning strategies. A successor map is used for partitioning the state space. This map is created in the GrappaModel, based on the chosen bisimulation type. After partitioning the state space, two processes are bisimilar iff the initial nodes of S and T lie in the same block. From a partitioned state space, a computer defender or attacker may create a winning strategy.

This class contains a method 'partition' for partitioning the state space, which is inspired by the partition function in the source code of the Edinburgh Concurrency Workbench.

Author:
Martin Mosegaard martinm@daimi.au.dk

Field Summary
private  java.util.Vector<Block> blocks
          Blocks making up the partition.
private  java.util.HashMap<att.grappa.Node,java.util.Vector<Capability>> capabilityMap
          A map from nodes to their capabilities.
private  att.grappa.Node initialNodeLeft
          The initial nodes of the left and right LTSs.
private  att.grappa.Node initialNodeRight
          The initial nodes of the left and right LTSs.
private  java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> leftSuccessorMap
           
private  java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> rightSuccessorMap
           
 
Constructor Summary
StateSpace(att.grappa.Node initialNodeLeft, att.grappa.Node initialNodeRight, java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> leftSuccessorMap, java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> rightSuccessorMap)
          Constructs a state space based on a successor map, but does not partition it.
 
Method Summary
private  boolean checkBlock(Block block)
          Checks if all nodes in a block have equal capabilities.
private  java.util.Vector<Capability> computeNodeCapability(att.grappa.Node node)
          Lookup if the capability has already been computed.
private  void createBlock(java.util.Set<att.grappa.Node> nodes)
          Creates a block with running block number and a set of nodes, adds the block to the block vector, and increments running block number.
private  Block getBlockByNumber(int blockNumber)
           
 int getBlockNumber(att.grappa.Node node)
          Returns the block number of a node.
 java.util.Vector<att.grappa.Node> getChoices(int side, att.grappa.Node from, java.lang.String action)
          Find all nodes that are head of an edge with label=action and which has tail=from.
 att.grappa.Node getInitialNodeLeft()
          Returns the initial node of the left LTS
 att.grappa.Node getInitialNodeRight()
          Returns the initial node of the right LTS
 java.util.Vector<Capability> getNodeCapability(att.grappa.Node node)
          Retrieve the capability of a node.
 att.grappa.Node getNodeInBlock(int side, att.grappa.Node from, java.lang.String action, int blockNumber)
          Find a node that is head of an edge with label=action and which has tail=from, such that the node is in the block with number=blockNumber.
 boolean partition()
          Partitions the state space according to strong bisimulation and returns true if the two initial nodes are in the same block (partition).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

blocks

private java.util.Vector<Block> blocks
Blocks making up the partition.


capabilityMap

private java.util.HashMap<att.grappa.Node,java.util.Vector<Capability>> capabilityMap
A map from nodes to their capabilities.


initialNodeLeft

private att.grappa.Node initialNodeLeft
The initial nodes of the left and right LTSs.


initialNodeRight

private att.grappa.Node initialNodeRight
The initial nodes of the left and right LTSs.


leftSuccessorMap

private java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> leftSuccessorMap

rightSuccessorMap

private java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> rightSuccessorMap
Constructor Detail

StateSpace

public StateSpace(att.grappa.Node initialNodeLeft,
                  att.grappa.Node initialNodeRight,
                  java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> leftSuccessorMap,
                  java.util.HashMap<att.grappa.Node,java.util.Vector<Successor>> rightSuccessorMap)
Constructs a state space based on a successor map, but does not partition it.

Parameters:
initialNodeLeft - The initial node of the left LTS
initialNodeRight - The initial node of the right LTS
leftSuccessorMap - The successor map of the left LTS
rightSuccessorMap - The successor map of the right LTS
Method Detail

createBlock

private void createBlock(java.util.Set<att.grappa.Node> nodes)
Creates a block with running block number and a set of nodes, adds the block to the block vector, and increments running block number.

Parameters:
nodes - Nodes in the new block

getNodeCapability

public java.util.Vector<Capability> getNodeCapability(att.grappa.Node node)
Retrieve the capability of a node. Assumes that the state space has been partitioned.

Parameters:
node - A node
Returns:
The nodes capability

computeNodeCapability

private java.util.Vector<Capability> computeNodeCapability(att.grappa.Node node)
Lookup if the capability has already been computed. If not, compute it and tabulate it for later lookup. A capability records all outgoing actions as well as the block number the target nodes.

Parameters:
node - A node
Returns:
The nodes capability

getBlockNumber

public int getBlockNumber(att.grappa.Node node)
Returns the block number of a node.

Parameters:
node - A node
Returns:
The block number of the node, or -1 if it is not found

checkBlock

private boolean checkBlock(Block block)
Checks if all nodes in a block have equal capabilities. This is done by comparing the capability of one node (the first) with the capabilities of the other nodes, and marking nodes that differ. If the set of marked nodes is non-empty, it forms a new block, and the marked nodes are removed from the current block. Capabilities are equal when, for all actions a and block numbers m; this.contains(a,m) ==> other.contains(a,m) and other.contains(a,m) ==> this.contains(a,m) The containsAll call on the vectors compares using the equals method of a Capability.

Parameters:
block - The block (partition) to consider
Returns:
True if we should split

partition

public boolean partition()
Partitions the state space according to strong bisimulation and returns true if the two initial nodes are in the same block (partition).

Returns:
True if the initial nodes lie in the same partition

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getBlockByNumber

private Block getBlockByNumber(int blockNumber)

getNodeInBlock

public att.grappa.Node getNodeInBlock(int side,
                                      att.grappa.Node from,
                                      java.lang.String action,
                                      int blockNumber)
Find a node that is head of an edge with label=action and which has tail=from, such that the node is in the block with number=blockNumber.

Parameters:
side - The side (left/right)
from - The from-node
action - The action name
blockNumber - The block number of the to-node
Returns:
A node

getChoices

public java.util.Vector<att.grappa.Node> getChoices(int side,
                                                    att.grappa.Node from,
                                                    java.lang.String action)
Find all nodes that are head of an edge with label=action and which has tail=from.

Parameters:
side - The side (left/right)
from - The from-node
action - The action name
Returns:
A set of choices

getInitialNodeLeft

public att.grappa.Node getInitialNodeLeft()
Returns the initial node of the left LTS

Returns:
The initial node of the left LTS

getInitialNodeRight

public att.grappa.Node getInitialNodeRight()
Returns the initial node of the right LTS

Returns:
The initial node of the right LTS