Browse Source
symbolic: add ModelTransformation, ModelExpressionTransformation (similar to functionality in explicit engine)
symbolic: add ModelTransformation, ModelExpressionTransformation (similar to functionality in explicit engine)
git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11948 bbc10eb1-c90d-0410-af57-cb519fbb1720master
4 changed files with 325 additions and 0 deletions
-
54prism/src/prism/ModelExpressionTransformation.java
-
108prism/src/prism/ModelExpressionTransformationNested.java
-
68prism/src/prism/ModelTransformation.java
-
95prism/src/prism/ModelTransformationNested.java
@ -0,0 +1,54 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2015- |
|||
// Authors: |
|||
// * Joachim Klein <klein@tcs.inf.tu-dresden.de> (TU Dresden) |
|||
// |
|||
//------------------------------------------------------------------------------ |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of 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. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
|
|||
package prism; |
|||
|
|||
import parser.ast.Expression; |
|||
|
|||
/** |
|||
* Interface for a model and expression transformation.<br> |
|||
* |
|||
* Implementing classes provide a combined model and expression transformation, allowing the calculation |
|||
* of a (potentially simpler) expression in the transformed model to calculate the result of the |
|||
* original expression in the original model.<br> |
|||
* |
|||
* The general idea is the following sequence of calls:<br> |
|||
* |
|||
* {@code ModelExpressionTransformation t = ...;}<br> |
|||
* {@code StateValues resultTransformed = check t.getTransformedExpression() in t.getTransformedModel()}<br> |
|||
* {@code StateValues result = t.projectToOriginalModel(resultTransformed);} |
|||
*/ |
|||
public interface ModelExpressionTransformation<OriginalModel extends Model, TransformedModel extends Model> |
|||
extends ModelTransformation<OriginalModel, TransformedModel> { |
|||
|
|||
/** Get the transformed expression. */ |
|||
public Expression getTransformedExpression(); |
|||
|
|||
/** Get the original expression. */ |
|||
public Expression getOriginalExpression(); |
|||
|
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2015- |
|||
// Authors: |
|||
// * Joachim Klein <klein@tcs.inf.tu-dresden.de> (TU Dresden) |
|||
// |
|||
//------------------------------------------------------------------------------ |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of 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. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
package prism; |
|||
|
|||
import jdd.JDDNode; |
|||
import parser.ast.Expression; |
|||
import prism.PrismException; |
|||
|
|||
/** |
|||
* Nesting of two model/expression transformations. |
|||
* <br> |
|||
* original -(innerTransformation)-> intermediate -(outerTransformation)-> transformed |
|||
*/ |
|||
|
|||
public class ModelExpressionTransformationNested<OriginalModel extends Model, IntermediateModel extends Model, TransformedModel extends Model> implements |
|||
ModelExpressionTransformation<OriginalModel, TransformedModel> { |
|||
|
|||
/** The inner transformation */ |
|||
protected ModelExpressionTransformation<OriginalModel, IntermediateModel> innerTransformation; |
|||
/** The outer transformation */ |
|||
protected ModelExpressionTransformation<IntermediateModel,TransformedModel> outerTransformation; |
|||
|
|||
/** |
|||
* Constructor, chain the two transformations. |
|||
* <br> |
|||
* The transformations will be cleared on a call to {@code clear()}. |
|||
* <br> |
|||
* [STORE: innerTransformation, outerTransformation ] |
|||
*/ |
|||
public ModelExpressionTransformationNested(ModelExpressionTransformation<OriginalModel, IntermediateModel> innerTransformation, |
|||
ModelExpressionTransformation<IntermediateModel, TransformedModel> outerTransformation) |
|||
{ |
|||
this.innerTransformation = innerTransformation; |
|||
this.outerTransformation = outerTransformation; |
|||
|
|||
if (innerTransformation.getTransformedModel() != outerTransformation.getOriginalModel()) { |
|||
throw new IllegalArgumentException("Trying to nest unrelated ModelExpressionTransformations."); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public TransformedModel getTransformedModel() |
|||
{ |
|||
return outerTransformation.getTransformedModel(); |
|||
} |
|||
|
|||
@Override |
|||
public StateValues projectToOriginalModel(StateValues svTransformedModel) throws PrismException |
|||
{ |
|||
StateValues svIntermediate = outerTransformation.projectToOriginalModel(svTransformedModel); |
|||
StateValues svOriginal = innerTransformation.projectToOriginalModel(svIntermediate); |
|||
return svOriginal; |
|||
} |
|||
|
|||
@Override |
|||
public Expression getTransformedExpression() |
|||
{ |
|||
return outerTransformation.getTransformedExpression(); |
|||
} |
|||
|
|||
@Override |
|||
public OriginalModel getOriginalModel() { |
|||
return innerTransformation.getOriginalModel(); |
|||
} |
|||
|
|||
@Override |
|||
public Expression getOriginalExpression() |
|||
{ |
|||
return innerTransformation.getOriginalExpression(); |
|||
} |
|||
|
|||
@Override |
|||
public JDDNode getTransformedStatesOfInterest() |
|||
{ |
|||
return outerTransformation.getTransformedStatesOfInterest(); |
|||
} |
|||
|
|||
@Override |
|||
public void clear() |
|||
{ |
|||
outerTransformation.clear(); |
|||
innerTransformation.clear(); |
|||
} |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2015- |
|||
// Authors: |
|||
// * Joachim Klein <klein@tcs.inf.tu-dresden.de> (TU Dresden) |
|||
// |
|||
//------------------------------------------------------------------------------ |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of 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. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
package prism; |
|||
|
|||
import jdd.JDDNode; |
|||
import prism.PrismException; |
|||
|
|||
/** |
|||
* Interface for a model transformation. |
|||
*/ |
|||
public interface ModelTransformation<OriginalModel extends Model, TransformedModel extends Model> { |
|||
|
|||
/** Get the original model. */ |
|||
public OriginalModel getOriginalModel(); |
|||
|
|||
/** Get the transformed model. */ |
|||
public TransformedModel getTransformedModel(); |
|||
|
|||
/** Clear the transformed model and all other intermediate BDD information. |
|||
* Should be called when the transformation is not needed anymore. Does not clear the |
|||
* original model. |
|||
*/ |
|||
public void clear(); |
|||
|
|||
/** |
|||
* Take a {@code StateValues} object for the transformed model and |
|||
* project the values to the original model. |
|||
* <br> |
|||
* The {@code svTransformedModel} argument is consumed/cleared and should not be |
|||
* used afterwards. |
|||
* @param svTransformedModel a {@code StateValues} object for the transformed model |
|||
* @return a corresponding {@code StateValues} object for the original model. |
|||
*/ |
|||
public StateValues projectToOriginalModel(StateValues svTransformedModel) throws PrismException; |
|||
|
|||
/** |
|||
* Get the transformed state set of the states of interest, |
|||
* i.e., the set of states that should be calculated to allow a successful |
|||
* application of the projectToOriginalModel method. |
|||
* |
|||
* <br>[REF: <i>result</i>] |
|||
*/ |
|||
public JDDNode getTransformedStatesOfInterest(); |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2015- |
|||
// Authors: |
|||
// * Joachim Klein <klein@tcs.inf.tu-dresden.de> (TU Dresden) |
|||
// |
|||
//------------------------------------------------------------------------------ |
|||
// |
|||
// This file is part of PRISM. |
|||
// |
|||
// PRISM is free software; you can redistribute it and/or modify |
|||
// it under the terms of 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. |
|||
// |
|||
// PRISM is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with PRISM; if not, write to the Free Software Foundation, |
|||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
//============================================================================== |
|||
|
|||
package prism; |
|||
|
|||
import jdd.JDDNode; |
|||
import prism.PrismException; |
|||
|
|||
/** |
|||
* Nesting of two model transformations. |
|||
* <br> |
|||
* originalModel -(innerTransformation)-> intermediateModel -(outerTransformation)-> transformedModel |
|||
*/ |
|||
public class ModelTransformationNested<OriginalModel extends Model, IntermediateModel extends Model, TransformedModel extends Model> implements |
|||
ModelTransformation<OriginalModel, TransformedModel> { |
|||
|
|||
/** The inner transformation */ |
|||
protected ModelTransformation<OriginalModel, IntermediateModel> innerTransformation; |
|||
/** The outer transformation */ |
|||
protected ModelTransformation<IntermediateModel,TransformedModel> outerTransformation; |
|||
|
|||
/** |
|||
* Constructor, chain the two transformations. |
|||
* <br> |
|||
* The transformations will be cleared on a call to {@code clear()}. |
|||
* <br> |
|||
* [STORE: innerTransformation, outerTransformation ] |
|||
*/ |
|||
public ModelTransformationNested(ModelTransformation<OriginalModel, IntermediateModel> innerTransformation, |
|||
ModelTransformation<IntermediateModel, TransformedModel> outerTransformation) throws PrismException |
|||
{ |
|||
this.innerTransformation = innerTransformation; |
|||
this.outerTransformation = outerTransformation; |
|||
|
|||
if (innerTransformation.getTransformedModel() != outerTransformation.getOriginalModel()) { |
|||
throw new PrismException("Trying to nest unrelated ModelExpressionTransformations."); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public TransformedModel getTransformedModel() |
|||
{ |
|||
return outerTransformation.getTransformedModel(); |
|||
} |
|||
|
|||
@Override |
|||
public StateValues projectToOriginalModel(StateValues svTransformedModel) throws PrismException |
|||
{ |
|||
StateValues svIntermediate = outerTransformation.projectToOriginalModel(svTransformedModel); |
|||
StateValues svOriginal = innerTransformation.projectToOriginalModel(svIntermediate); |
|||
return svOriginal; |
|||
} |
|||
|
|||
@Override |
|||
public OriginalModel getOriginalModel() |
|||
{ |
|||
return innerTransformation.getOriginalModel(); |
|||
} |
|||
|
|||
@Override |
|||
public void clear() |
|||
{ |
|||
outerTransformation.clear(); |
|||
innerTransformation.clear(); |
|||
} |
|||
|
|||
@Override |
|||
public JDDNode getTransformedStatesOfInterest() |
|||
{ |
|||
return outerTransformation.getTransformedStatesOfInterest(); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue