From 9152a660dbfbf3294964233c76d6cf22111298ff Mon Sep 17 00:00:00 2001 From: Oszkar Semerath Date: Tue, 9 Jul 2019 20:49:10 +0200 Subject: aggregated partial substitution + builder --- .../model/logiclanguage/AggregateExpression.java | 15 ++ .../AggregatedParameterSubstitution.java | 46 ++++ .../model/logiclanguage/LogiclanguageFactory.java | 9 + .../model/logiclanguage/LogiclanguagePackage.java | 152 +++++++++++- .../impl/AggregateExpressionImpl.java | 56 +++++ .../impl/AggregatedParameterSubstitutionImpl.java | 159 +++++++++++++ .../impl/LogiclanguageFactoryImpl.java | 12 + .../impl/LogiclanguagePackageImpl.java | 46 ++++ .../util/LogiclanguageAdapterFactory.java | 18 ++ .../logiclanguage/util/LogiclanguageSwitch.java | 21 ++ .../model/logiclanguage.aird | 103 +++++++- .../model/logiclanguage.ecore | 5 + .../model/logiclanguage.genmodel | 4 + .../logic/model/builder/LogicProblemBuilder.xtend | 261 ++++++++++++--------- 14 files changed, 784 insertions(+), 123 deletions(-) create mode 100644 Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregatedParameterSubstitution.java create mode 100644 Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregatedParameterSubstitutionImpl.java diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregateExpression.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregateExpression.java index be146469..4b38becf 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregateExpression.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregateExpression.java @@ -2,6 +2,8 @@ */ package hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage; +import org.eclipse.emf.common.util.EList; + /** * @@ -13,6 +15,7 @@ package hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage; *

* * * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage#getAggregateExpression() @@ -46,4 +49,16 @@ public interface AggregateExpression extends Term { */ void setRelation(Relation value); + /** + * Returns the value of the 'Parameter Substitution' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution}. + * + * + * @return the value of the 'Parameter Substitution' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage#getAggregateExpression_ParameterSubstitution() + * @model containment="true" + * @generated + */ + EList getParameterSubstitution(); + } // AggregateExpression diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregatedParameterSubstitution.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregatedParameterSubstitution.java new file mode 100644 index 00000000..94b6365d --- /dev/null +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/AggregatedParameterSubstitution.java @@ -0,0 +1,46 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Aggregated Parameter Substitution'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage#getAggregatedParameterSubstitution() + * @model + * @generated + */ +public interface AggregatedParameterSubstitution extends EObject { + /** + * Returns the value of the 'Variable' reference. + * + * + * @return the value of the 'Variable' reference. + * @see #setVariable(Variable) + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage#getAggregatedParameterSubstitution_Variable() + * @model + * @generated + */ + Variable getVariable(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution#getVariable Variable}' reference. + * + * + * @param value the new value of the 'Variable' reference. + * @see #getVariable() + * @generated + */ + void setVariable(Variable value); + +} // AggregatedParameterSubstitution diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguageFactory.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguageFactory.java index a6b0a790..33d79329 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguageFactory.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguageFactory.java @@ -453,6 +453,15 @@ public interface LogiclanguageFactory extends EFactory { */ Max createMax(); + /** + * Returns a new object of class 'Aggregated Parameter Substitution'. + * + * + * @return a new object of class 'Aggregated Parameter Substitution'. + * @generated + */ + AggregatedParameterSubstitution createAggregatedParameterSubstitution(); + /** * Returns the package supported by this factory. * diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguagePackage.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguagePackage.java index ddfb75a2..f5347e31 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguagePackage.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/LogiclanguagePackage.java @@ -2750,6 +2750,15 @@ public interface LogiclanguagePackage extends EPackage { */ int AGGREGATE_EXPRESSION__RELATION = TERM_FEATURE_COUNT + 0; + /** + * The feature id for the 'Parameter Substitution' containment reference list. + * + * + * @generated + * @ordered + */ + int AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION = TERM_FEATURE_COUNT + 1; + /** * The number of structural features of the 'Aggregate Expression' class. * @@ -2757,7 +2766,7 @@ public interface LogiclanguagePackage extends EPackage { * @generated * @ordered */ - int AGGREGATE_EXPRESSION_FEATURE_COUNT = TERM_FEATURE_COUNT + 1; + int AGGREGATE_EXPRESSION_FEATURE_COUNT = TERM_FEATURE_COUNT + 2; /** * The number of operations of the 'Aggregate Expression' class. @@ -2787,6 +2796,15 @@ public interface LogiclanguagePackage extends EPackage { */ int PROJECTED_AGGREGATE_EXPRESSION__RELATION = AGGREGATE_EXPRESSION__RELATION; + /** + * The feature id for the 'Parameter Substitution' containment reference list. + * + * + * @generated + * @ordered + */ + int PROJECTED_AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION = AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION; + /** * The feature id for the 'Projection Index' attribute. * @@ -2833,6 +2851,15 @@ public interface LogiclanguagePackage extends EPackage { */ int SUM__RELATION = PROJECTED_AGGREGATE_EXPRESSION__RELATION; + /** + * The feature id for the 'Parameter Substitution' containment reference list. + * + * + * @generated + * @ordered + */ + int SUM__PARAMETER_SUBSTITUTION = PROJECTED_AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION; + /** * The feature id for the 'Projection Index' attribute. * @@ -2879,6 +2906,15 @@ public interface LogiclanguagePackage extends EPackage { */ int COUNT__RELATION = AGGREGATE_EXPRESSION__RELATION; + /** + * The feature id for the 'Parameter Substitution' containment reference list. + * + * + * @generated + * @ordered + */ + int COUNT__PARAMETER_SUBSTITUTION = AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION; + /** * The number of structural features of the 'Count' class. * @@ -2916,6 +2952,15 @@ public interface LogiclanguagePackage extends EPackage { */ int MIN__RELATION = PROJECTED_AGGREGATE_EXPRESSION__RELATION; + /** + * The feature id for the 'Parameter Substitution' containment reference list. + * + * + * @generated + * @ordered + */ + int MIN__PARAMETER_SUBSTITUTION = PROJECTED_AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION; + /** * The feature id for the 'Projection Index' attribute. * @@ -2962,6 +3007,15 @@ public interface LogiclanguagePackage extends EPackage { */ int MAX__RELATION = PROJECTED_AGGREGATE_EXPRESSION__RELATION; + /** + * The feature id for the 'Parameter Substitution' containment reference list. + * + * + * @generated + * @ordered + */ + int MAX__PARAMETER_SUBSTITUTION = PROJECTED_AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION; + /** * The feature id for the 'Projection Index' attribute. * @@ -2990,6 +3044,44 @@ public interface LogiclanguagePackage extends EPackage { int MAX_OPERATION_COUNT = PROJECTED_AGGREGATE_EXPRESSION_OPERATION_COUNT + 0; + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.AggregatedParameterSubstitutionImpl Aggregated Parameter Substitution}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.AggregatedParameterSubstitutionImpl + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.LogiclanguagePackageImpl#getAggregatedParameterSubstitution() + * @generated + */ + int AGGREGATED_PARAMETER_SUBSTITUTION = 65; + + /** + * The feature id for the 'Variable' reference. + * + * + * @generated + * @ordered + */ + int AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE = 0; + + /** + * The number of structural features of the 'Aggregated Parameter Substitution' class. + * + * + * @generated + * @ordered + */ + int AGGREGATED_PARAMETER_SUBSTITUTION_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'Aggregated Parameter Substitution' class. + * + * + * @generated + * @ordered + */ + int AGGREGATED_PARAMETER_SUBSTITUTION_OPERATION_COUNT = 0; + + /** * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type Type}'. * @@ -4305,6 +4397,17 @@ public interface LogiclanguagePackage extends EPackage { */ EReference getAggregateExpression_Relation(); + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregateExpression#getParameterSubstitution Parameter Substitution}'. + * + * + * @return the meta object for the containment reference list 'Parameter Substitution'. + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregateExpression#getParameterSubstitution() + * @see #getAggregateExpression() + * @generated + */ + EReference getAggregateExpression_ParameterSubstitution(); + /** * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Sum Sum}'. * @@ -4366,6 +4469,27 @@ public interface LogiclanguagePackage extends EPackage { */ EAttribute getProjectedAggregateExpression_ProjectionIndex(); + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution Aggregated Parameter Substitution}'. + * + * + * @return the meta object for class 'Aggregated Parameter Substitution'. + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution + * @generated + */ + EClass getAggregatedParameterSubstitution(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution#getVariable Variable}'. + * + * + * @return the meta object for the reference 'Variable'. + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution#getVariable() + * @see #getAggregatedParameterSubstitution() + * @generated + */ + EReference getAggregatedParameterSubstitution_Variable(); + /** * Returns the factory that creates the instances of the model. * @@ -5509,6 +5633,14 @@ public interface LogiclanguagePackage extends EPackage { */ EReference AGGREGATE_EXPRESSION__RELATION = eINSTANCE.getAggregateExpression_Relation(); + /** + * The meta object literal for the 'Parameter Substitution' containment reference list feature. + * + * + * @generated + */ + EReference AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION = eINSTANCE.getAggregateExpression_ParameterSubstitution(); + /** * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.SumImpl Sum}' class. * @@ -5567,6 +5699,24 @@ public interface LogiclanguagePackage extends EPackage { */ EAttribute PROJECTED_AGGREGATE_EXPRESSION__PROJECTION_INDEX = eINSTANCE.getProjectedAggregateExpression_ProjectionIndex(); + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.AggregatedParameterSubstitutionImpl Aggregated Parameter Substitution}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.AggregatedParameterSubstitutionImpl + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.LogiclanguagePackageImpl#getAggregatedParameterSubstitution() + * @generated + */ + EClass AGGREGATED_PARAMETER_SUBSTITUTION = eINSTANCE.getAggregatedParameterSubstitution(); + + /** + * The meta object literal for the 'Variable' reference feature. + * + * + * @generated + */ + EReference AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE = eINSTANCE.getAggregatedParameterSubstitution_Variable(); + } } //LogiclanguagePackage diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregateExpressionImpl.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregateExpressionImpl.java index fc1420b0..0459af42 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregateExpressionImpl.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregateExpressionImpl.java @@ -3,15 +3,21 @@ package hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl; import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregateExpression; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution; import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage; import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation; +import java.util.Collection; import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; /** * @@ -22,6 +28,7 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl; *

* * * @generated @@ -37,6 +44,16 @@ public abstract class AggregateExpressionImpl extends TermImpl implements Aggreg */ protected Relation relation; + /** + * The cached value of the '{@link #getParameterSubstitution() Parameter Substitution}' containment reference list. + * + * + * @see #getParameterSubstitution() + * @generated + * @ordered + */ + protected EList parameterSubstitution; + /** * * @@ -96,6 +113,33 @@ public abstract class AggregateExpressionImpl extends TermImpl implements Aggreg eNotify(new ENotificationImpl(this, Notification.SET, LogiclanguagePackage.AGGREGATE_EXPRESSION__RELATION, oldRelation, relation)); } + /** + * + * + * @generated + */ + @Override + public EList getParameterSubstitution() { + if (parameterSubstitution == null) { + parameterSubstitution = new EObjectContainmentEList(AggregatedParameterSubstitution.class, this, LogiclanguagePackage.AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION); + } + return parameterSubstitution; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case LogiclanguagePackage.AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION: + return ((InternalEList)getParameterSubstitution()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + /** * * @@ -107,6 +151,8 @@ public abstract class AggregateExpressionImpl extends TermImpl implements Aggreg case LogiclanguagePackage.AGGREGATE_EXPRESSION__RELATION: if (resolve) return getRelation(); return basicGetRelation(); + case LogiclanguagePackage.AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION: + return getParameterSubstitution(); } return super.eGet(featureID, resolve, coreType); } @@ -116,12 +162,17 @@ public abstract class AggregateExpressionImpl extends TermImpl implements Aggreg * * @generated */ + @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case LogiclanguagePackage.AGGREGATE_EXPRESSION__RELATION: setRelation((Relation)newValue); return; + case LogiclanguagePackage.AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION: + getParameterSubstitution().clear(); + getParameterSubstitution().addAll((Collection)newValue); + return; } super.eSet(featureID, newValue); } @@ -137,6 +188,9 @@ public abstract class AggregateExpressionImpl extends TermImpl implements Aggreg case LogiclanguagePackage.AGGREGATE_EXPRESSION__RELATION: setRelation((Relation)null); return; + case LogiclanguagePackage.AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION: + getParameterSubstitution().clear(); + return; } super.eUnset(featureID); } @@ -151,6 +205,8 @@ public abstract class AggregateExpressionImpl extends TermImpl implements Aggreg switch (featureID) { case LogiclanguagePackage.AGGREGATE_EXPRESSION__RELATION: return relation != null; + case LogiclanguagePackage.AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION: + return parameterSubstitution != null && !parameterSubstitution.isEmpty(); } return super.eIsSet(featureID); } diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregatedParameterSubstitutionImpl.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregatedParameterSubstitutionImpl.java new file mode 100644 index 00000000..15af0f21 --- /dev/null +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/AggregatedParameterSubstitutionImpl.java @@ -0,0 +1,159 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl; + +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'Aggregated Parameter Substitution'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.AggregatedParameterSubstitutionImpl#getVariable Variable}
  • + *
+ * + * @generated + */ +public class AggregatedParameterSubstitutionImpl extends MinimalEObjectImpl.Container implements AggregatedParameterSubstitution { + /** + * The cached value of the '{@link #getVariable() Variable}' reference. + * + * + * @see #getVariable() + * @generated + * @ordered + */ + protected Variable variable; + + /** + * + * + * @generated + */ + protected AggregatedParameterSubstitutionImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return LogiclanguagePackage.Literals.AGGREGATED_PARAMETER_SUBSTITUTION; + } + + /** + * + * + * @generated + */ + @Override + public Variable getVariable() { + if (variable != null && variable.eIsProxy()) { + InternalEObject oldVariable = (InternalEObject)variable; + variable = (Variable)eResolveProxy(oldVariable); + if (variable != oldVariable) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE, oldVariable, variable)); + } + } + return variable; + } + + /** + * + * + * @generated + */ + public Variable basicGetVariable() { + return variable; + } + + /** + * + * + * @generated + */ + @Override + public void setVariable(Variable newVariable) { + Variable oldVariable = variable; + variable = newVariable; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE, oldVariable, variable)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE: + if (resolve) return getVariable(); + return basicGetVariable(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE: + setVariable((Variable)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE: + setVariable((Variable)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE: + return variable != null; + } + return super.eIsSet(featureID); + } + +} //AggregatedParameterSubstitutionImpl diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguageFactoryImpl.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguageFactoryImpl.java index b890b6e0..b8d87d99 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguageFactoryImpl.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguageFactoryImpl.java @@ -104,6 +104,7 @@ public class LogiclanguageFactoryImpl extends EFactoryImpl implements Logiclangu case LogiclanguagePackage.COUNT: return createCount(); case LogiclanguagePackage.MIN: return createMin(); case LogiclanguagePackage.MAX: return createMax(); + case LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION: return createAggregatedParameterSubstitution(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); } @@ -637,6 +638,17 @@ public class LogiclanguageFactoryImpl extends EFactoryImpl implements Logiclangu return max; } + /** + * + * + * @generated + */ + @Override + public AggregatedParameterSubstitution createAggregatedParameterSubstitution() { + AggregatedParameterSubstitutionImpl aggregatedParameterSubstitution = new AggregatedParameterSubstitutionImpl(); + return aggregatedParameterSubstitution; + } + /** * * diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguagePackageImpl.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguagePackageImpl.java index 6d370c0f..64ebdde1 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguagePackageImpl.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/impl/LogiclanguagePackageImpl.java @@ -3,6 +3,7 @@ package hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl; import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregateExpression; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution; import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.And; import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion; import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AtomicTerm; @@ -547,6 +548,13 @@ public class LogiclanguagePackageImpl extends EPackageImpl implements Logiclangu */ private EClass projectedAggregateExpressionEClass = null; + /** + * + * + * @generated + */ + private EClass aggregatedParameterSubstitutionEClass = null; + /** * Creates an instance of the model Package, registered with * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package @@ -1868,6 +1876,16 @@ public class LogiclanguagePackageImpl extends EPackageImpl implements Logiclangu return (EReference)aggregateExpressionEClass.getEStructuralFeatures().get(0); } + /** + * + * + * @generated + */ + @Override + public EReference getAggregateExpression_ParameterSubstitution() { + return (EReference)aggregateExpressionEClass.getEStructuralFeatures().get(1); + } + /** * * @@ -1928,6 +1946,26 @@ public class LogiclanguagePackageImpl extends EPackageImpl implements Logiclangu return (EAttribute)projectedAggregateExpressionEClass.getEStructuralFeatures().get(0); } + /** + * + * + * @generated + */ + @Override + public EClass getAggregatedParameterSubstitution() { + return aggregatedParameterSubstitutionEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getAggregatedParameterSubstitution_Variable() { + return (EReference)aggregatedParameterSubstitutionEClass.getEStructuralFeatures().get(0); + } + /** * * @@ -2141,6 +2179,7 @@ public class LogiclanguagePackageImpl extends EPackageImpl implements Logiclangu aggregateExpressionEClass = createEClass(AGGREGATE_EXPRESSION); createEReference(aggregateExpressionEClass, AGGREGATE_EXPRESSION__RELATION); + createEReference(aggregateExpressionEClass, AGGREGATE_EXPRESSION__PARAMETER_SUBSTITUTION); sumEClass = createEClass(SUM); @@ -2152,6 +2191,9 @@ public class LogiclanguagePackageImpl extends EPackageImpl implements Logiclangu projectedAggregateExpressionEClass = createEClass(PROJECTED_AGGREGATE_EXPRESSION); createEAttribute(projectedAggregateExpressionEClass, PROJECTED_AGGREGATE_EXPRESSION__PROJECTION_INDEX); + + aggregatedParameterSubstitutionEClass = createEClass(AGGREGATED_PARAMETER_SUBSTITUTION); + createEReference(aggregatedParameterSubstitutionEClass, AGGREGATED_PARAMETER_SUBSTITUTION__VARIABLE); } /** @@ -2433,6 +2475,7 @@ public class LogiclanguagePackageImpl extends EPackageImpl implements Logiclangu initEClass(aggregateExpressionEClass, AggregateExpression.class, "AggregateExpression", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getAggregateExpression_Relation(), this.getRelation(), null, "relation", null, 0, 1, AggregateExpression.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getAggregateExpression_ParameterSubstitution(), this.getAggregatedParameterSubstitution(), null, "parameterSubstitution", null, 0, -1, AggregateExpression.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(sumEClass, Sum.class, "Sum", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -2445,6 +2488,9 @@ public class LogiclanguagePackageImpl extends EPackageImpl implements Logiclangu initEClass(projectedAggregateExpressionEClass, ProjectedAggregateExpression.class, "ProjectedAggregateExpression", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getProjectedAggregateExpression_ProjectionIndex(), ecorePackage.getEInt(), "projectionIndex", "-1", 1, 1, ProjectedAggregateExpression.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEClass(aggregatedParameterSubstitutionEClass, AggregatedParameterSubstitution.class, "AggregatedParameterSubstitution", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getAggregatedParameterSubstitution_Variable(), this.getVariable(), null, "variable", null, 0, 1, AggregatedParameterSubstitution.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + // Create resource createResource(eNS_URI); } diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageAdapterFactory.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageAdapterFactory.java index 25edee70..3fc7c298 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageAdapterFactory.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageAdapterFactory.java @@ -328,6 +328,10 @@ public class LogiclanguageAdapterFactory extends AdapterFactoryImpl { return createProjectedAggregateExpressionAdapter(); } @Override + public Adapter caseAggregatedParameterSubstitution(AggregatedParameterSubstitution object) { + return createAggregatedParameterSubstitutionAdapter(); + } + @Override public Adapter defaultCase(EObject object) { return createEObjectAdapter(); } @@ -1257,6 +1261,20 @@ public class LogiclanguageAdapterFactory extends AdapterFactoryImpl { return null; } + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution Aggregated Parameter Substitution}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregatedParameterSubstitution + * @generated + */ + public Adapter createAggregatedParameterSubstitutionAdapter() { + return null; + } + /** * Creates a new adapter for the default case. * diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageSwitch.java b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageSwitch.java index fc443484..ac821567 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageSwitch.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/ecore-gen/hu/bme/mit/inf/dslreasoner/logic/model/logiclanguage/util/LogiclanguageSwitch.java @@ -617,6 +617,12 @@ public class LogiclanguageSwitch extends Switch { if (result == null) result = defaultCase(theEObject); return result; } + case LogiclanguagePackage.AGGREGATED_PARAMETER_SUBSTITUTION: { + AggregatedParameterSubstitution aggregatedParameterSubstitution = (AggregatedParameterSubstitution)theEObject; + T result = caseAggregatedParameterSubstitution(aggregatedParameterSubstitution); + if (result == null) result = defaultCase(theEObject); + return result; + } default: return defaultCase(theEObject); } } @@ -1596,6 +1602,21 @@ public class LogiclanguageSwitch extends Switch { return null; } + /** + * Returns the result of interpreting the object as an instance of 'Aggregated Parameter Substitution'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Aggregated Parameter Substitution'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAggregatedParameterSubstitution(AggregatedParameterSubstitution object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'EObject'. * diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.aird b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.aird index 5673d66a..0a49e388 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.aird +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.aird @@ -7805,7 +7805,7 @@ - + @@ -7814,7 +7814,7 @@ - + @@ -7823,7 +7823,7 @@ - + @@ -7832,7 +7832,7 @@ - + @@ -7841,7 +7841,7 @@ - + @@ -7854,7 +7854,16 @@ - + + + + + + + + + + @@ -9011,17 +9020,17 @@ - + - + - + - + @@ -9105,6 +9114,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9199,7 +9240,7 @@ - + KEEP_LOCATION @@ -10473,7 +10514,7 @@ - + KEEP_LOCATION @@ -10635,6 +10676,44 @@ + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.ecore b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.ecore index fdbc1c27..fb94b598 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.ecore +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.ecore @@ -215,6 +215,8 @@ + @@ -225,4 +227,7 @@ + + + diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.genmodel b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.genmodel index 303080e7..cb14ae5b 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.genmodel +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/model/logiclanguage.genmodel @@ -168,6 +168,7 @@ + @@ -176,6 +177,9 @@ + + + diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicProblemBuilder.xtend b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicProblemBuilder.xtend index f6bd9541..09bfbb39 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicProblemBuilder.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicProblemBuilder.xtend @@ -1,5 +1,6 @@ package hu.bme.mit.inf.dslreasoner.logic.model.builder +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.AggregateExpression import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference @@ -8,6 +9,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Function import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ProjectedAggregateExpression import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.QuantifiedExpression import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation @@ -46,16 +48,16 @@ class LogicProblemBuilderException extends Exception { } } -public class LogicProblemBuilder{ +class LogicProblemBuilder{ val protected extension LogiclanguageFactory logicFactiory = LogiclanguageFactory.eINSTANCE val protected extension LogicproblemFactory problemFactory = LogicproblemFactory.eINSTANCE val protected advancedConstructs = new LogicProblemBuilder_AdvancedConstructs(this) - def public createProblem(){ createLogicProblem } + def createProblem(){ createLogicProblem } // Names def protected String canonize(CharSequence name) { - if(name == null) return "" + if(name === null) return "" val result = name.toString.split("\\s+"); if(result.size == 1) { val element = result.get(0); @@ -82,23 +84,23 @@ public class LogicProblemBuilder{ } // Type builders - def public Element(CharSequence elementName) { return createDefinedElement => [x|x.name = elementName.canonize] } - def public Element() { return createDefinedElement } - def public TypeDeclaration(CharSequence name, boolean isAbstract) { TypeDeclaration => [x | x.name = name.canonize x.isAbstract = isAbstract] } - def public TypeDeclaration() { createTypeDeclaration } - def public TypeDefinition(CharSequence name, boolean isAbstract, DefinedElement... elements) { TypeDefinition(name, isAbstract, elements as Iterable) } - def public TypeDefinition(CharSequence name, boolean isAbstract, Iterable elements) { createTypeDefinition => [x | x.name = name.canonize x.isAbstract = isAbstract x.elements += elements ] } - - def public Supertype(Type subtype, Type supertype) { + def Element(CharSequence elementName) { return createDefinedElement => [x|x.name = elementName.canonize] } + def Element() { return createDefinedElement } + def TypeDeclaration(CharSequence name, boolean isAbstract) { TypeDeclaration => [x | x.name = name.canonize x.isAbstract = isAbstract] } + def TypeDeclaration() { createTypeDeclaration } + def TypeDefinition(CharSequence name, boolean isAbstract, DefinedElement... elements) { TypeDefinition(name, isAbstract, elements as Iterable) } + def TypeDefinition(CharSequence name, boolean isAbstract, Iterable elements) { createTypeDefinition => [x | x.name = name.canonize x.isAbstract = isAbstract x.elements += elements ] } + + def Supertype(Type subtype, Type supertype) { subtype.supertypes+=supertype } - def public SetSupertype(Type subtype, Type supertype, boolean value) { + def SetSupertype(Type subtype, Type supertype, boolean value) { if(value) subtype.supertypes+=supertype else subtype.subtypes-=supertype } // Type add - def public add(LogicProblem problem, Type type) { + def add(LogicProblem problem, Type type) { problem.nameIfAnonymType(type) problem.types+=type if(type instanceof TypeDefinition) { @@ -118,10 +120,10 @@ public class LogicProblemBuilder{ element.name = typeDefinition.elements.map[it.name].generateUniqueName[i | '''type «i.toString»'''] } - def public LogicBool() { createBoolTypeReference } - def public LogicInt() { createIntTypeReference } - def public LogicReal() { createRealTypeReference } - def public LogicString() { createStringTypeReference } + def LogicBool() { createBoolTypeReference } + def LogicInt() { createIntTypeReference } + def LogicReal() { createRealTypeReference } + def LogicString() { createStringTypeReference } def toTypeReference(TypeDescriptor descriptor) { if(descriptor instanceof TypeReference) { return EcoreUtil.copy(descriptor); } else if(descriptor instanceof Type) { return createComplexTypeReference => [referred = descriptor]} @@ -129,31 +131,31 @@ public class LogicProblemBuilder{ } // Variables - def public createVar(CharSequence name, TypeDescriptor range) { + def createVar(CharSequence name, TypeDescriptor range) { return createVariable => [it.name = name.canonize it.range = range.toTypeReference] } // Functions - def public FunctionDescription ->(TypeDescriptor parameter, TypeDescriptor range) { return #[parameter] -> range } - def public FunctionDescription ->(Iterable parameters, TypeDescriptor range) { return new FunctionDescription(parameters.map[toTypeReference], range.toTypeReference); } - def public FunctionDeclaration(CharSequence name, FunctionDescription functionDescription) { FunctionDeclaration(name,functionDescription.range, functionDescription.parameters) } - def public FunctionDeclaration(FunctionDescription functionDescription) { FunctionDeclaration(functionDescription.range, functionDescription.parameters) } - def public FunctionDeclaration(CharSequence name, TypeDescriptor range, TypeDescriptor... parameters) { FunctionDeclaration(name, range, parameters as Iterable) } - def public FunctionDeclaration(TypeDescriptor range, TypeDescriptor... parameters) { FunctionDeclaration(range, parameters as Iterable) } - def public FunctionDeclaration(CharSequence name, TypeDescriptor range, Iterable parameters) { return FunctionDeclaration(range,parameters) => [x|x.name = name.canonize] } - def public FunctionDeclaration(TypeDescriptor range, Iterable parameters) { + def FunctionDescription ->(TypeDescriptor parameter, TypeDescriptor range) { return #[parameter] -> range } + def FunctionDescription ->(Iterable parameters, TypeDescriptor range) { return new FunctionDescription(parameters.map[toTypeReference], range.toTypeReference); } + def FunctionDeclaration(CharSequence name, FunctionDescription functionDescription) { FunctionDeclaration(name,functionDescription.range, functionDescription.parameters) } + def FunctionDeclaration(FunctionDescription functionDescription) { FunctionDeclaration(functionDescription.range, functionDescription.parameters) } + def FunctionDeclaration(CharSequence name, TypeDescriptor range, TypeDescriptor... parameters) { FunctionDeclaration(name, range, parameters as Iterable) } + def FunctionDeclaration(TypeDescriptor range, TypeDescriptor... parameters) { FunctionDeclaration(range, parameters as Iterable) } + def FunctionDeclaration(CharSequence name, TypeDescriptor range, Iterable parameters) { return FunctionDeclaration(range,parameters) => [x|x.name = name.canonize] } + def FunctionDeclaration(TypeDescriptor range, Iterable parameters) { val function = createFunctionDeclaration for(parameter : parameters) function.parameters+=parameter.toTypeReference function.range = range.toTypeReference return function } - def public FunctionDefinition(CharSequence name, TypeDescriptor range, Function1 expression) { + def FunctionDefinition(CharSequence name, TypeDescriptor range, Function1 expression) { val context = new VariableContext(this,logicFactiory) val definition = expression.apply(context) return FunctionDefinition(name,range,context.variables,definition); } - def public FunctionDefinition(CharSequence name, TypeDescriptor range, Iterable variables, TermDescription definition) { + def FunctionDefinition(CharSequence name, TypeDescriptor range, Iterable variables, TermDescription definition) { return createFunctionDefinition => [ it.name = name.canonize it.parameters += variables.map[it.range.toTypeReference] @@ -162,23 +164,23 @@ public class LogicProblemBuilder{ it.value = definition.toTerm ] } - def public FunctionDefinition(CharSequence name, TypeDescriptor range, Iterable parameters, Map,Term> parametersToValue) { + def FunctionDefinition(CharSequence name, TypeDescriptor range, Iterable parameters, Map,Term> parametersToValue) { return FunctionDefinition(name,range,parameters,parametersToValue,null) } - def public FunctionDefinition(CharSequence name, TypeDescriptor range, Iterable parameters, Map,Term> parametersToValue, Term defaultValue) { + def FunctionDefinition(CharSequence name, TypeDescriptor range, Iterable parameters, Map,Term> parametersToValue, Term defaultValue) { val parameterList = parameters.toList; val variableList = (1..parameterList.size).map[index | '''param «index»'''.createVar(parameterList.get(index-1))].toList return FunctionDefinition(name,range,variableList,advancedConstructs.FunctionDefinitionBody(variableList,parametersToValue,defaultValue)) } // Add function to a problem - def public add(LogicProblem input, Function function) { + def add(LogicProblem input, Function function) { input.nameIfAnonymFunction(function) input.checkFunction(function) input.functions += function return function } - def public add(LogicProblem input, FunctionDescription functionDescription) { input.add(FunctionDeclaration(functionDescription)) } + def add(LogicProblem input, FunctionDescription functionDescription) { input.add(FunctionDeclaration(functionDescription)) } def protected nameIfAnonymFunction(LogicProblem problem, Function functionDeclaration) { if(functionDeclaration.name.nullOrEmpty) { functionDeclaration.name = problem.functions.map[it.name].generateUniqueName[i | "function"+i] @@ -199,15 +201,15 @@ public class LogicProblemBuilder{ } // Constants - def public ConstantDeclaration(CharSequence name, TypeDescriptor type) { ConstantDeclaration(type) => [it.name = name.canonize] } - def public ConstantDeclaration(TypeDescriptor type) { createConstantDeclaration => [it.type = type.toTypeReference] } + def ConstantDeclaration(CharSequence name, TypeDescriptor type) { ConstantDeclaration(type) => [it.name = name.canonize] } + def ConstantDeclaration(TypeDescriptor type) { createConstantDeclaration => [it.type = type.toTypeReference] } - def public ConstantDefinition(CharSequence name, TypeDescriptor type, TermDescription value) { + def ConstantDefinition(CharSequence name, TypeDescriptor type, TermDescription value) { createConstantDefinition => [it.name = name.canonize it.type = type.toTypeReference it.value = value.toTerm] } // Add constant to a problem - def public add(LogicProblem problem, Constant constant) { + def add(LogicProblem problem, Constant constant) { problem.nameIfAnonymConstant(constant); problem.checkConstant(constant) problem.constants += constant @@ -226,10 +228,10 @@ public class LogicProblemBuilder{ } // Relations - def public RelationDeclaration(CharSequence name, TypeDescriptor... parameters) { return RelationDeclaration(name, parameters as Iterable) } - def public RelationDeclaration(CharSequence name, Iterable parameters) { return RelationDeclaration(parameters) => [x|x.name = name.canonize] } - def public RelationDeclaration(TypeDescriptor... parameters) { RelationDeclaration( parameters as Iterable) } - def public RelationDeclaration(Iterable parameters) { + def RelationDeclaration(CharSequence name, TypeDescriptor... parameters) { return RelationDeclaration(name, parameters as Iterable) } + def RelationDeclaration(CharSequence name, Iterable parameters) { return RelationDeclaration(parameters) => [x|x.name = name.canonize] } + def RelationDeclaration(TypeDescriptor... parameters) { RelationDeclaration( parameters as Iterable) } + def RelationDeclaration(Iterable parameters) { val relation = createRelationDeclaration for(parameter : parameters) { relation.parameters+=parameter.toTypeReference @@ -237,12 +239,12 @@ public class LogicProblemBuilder{ return relation } - def public RelationDefinition(CharSequence name, Function1 expression) { + def RelationDefinition(CharSequence name, Function1 expression) { val context = new VariableContext(this,logicFactiory); val definition = expression.apply(context); return RelationDefinition(name,context.variables,definition) } - def public RelationDefinition(CharSequence name, Iterable variables, TermDescription definition) { + def RelationDefinition(CharSequence name, Iterable variables, TermDescription definition) { return createRelationDefinition => [ it.name = name.canonize it.parameters += variables.map[it.range.toTypeReference] @@ -250,7 +252,7 @@ public class LogicProblemBuilder{ it.value = definition?.toTerm ] } - def public RelationDefinition(CharSequence name, Iterable parameters, Iterable> possibleValues) { + def RelationDefinition(CharSequence name, Iterable parameters, Iterable> possibleValues) { val res = createRelationDefinition => [it.name = name.canonize] val variableMap = new ArrayList(parameters.size) var index = 0 @@ -267,7 +269,7 @@ public class LogicProblemBuilder{ } // Add Relation to a problem - def public add(LogicProblem input, Relation relation) { + def add(LogicProblem input, Relation relation) { input.nameIfAnonymRelation(relation) input.checkRelation(relation) input.relations+=relation @@ -293,17 +295,17 @@ public class LogicProblemBuilder{ } // Assertion - def public Assertion(TermDescription term) { + def Assertion(TermDescription term) { val result = term.toTerm result.nameAnonymVariables(Collections.EMPTY_LIST) createAssertion => [it.value = result] } - def public Assertion(CharSequence name, TermDescription term) { + def Assertion(CharSequence name, TermDescription term) { val result = term.toTerm result.nameAnonymVariables(Collections.EMPTY_LIST) createAssertion => [it.value = result it.name=name.canonize] } - def public add(LogicProblem problem, Assertion assertion) { + def add(LogicProblem problem, Assertion assertion) { if(assertion.name.nullOrEmpty) { val name = problem.assertions.map[name].generateUniqueName["assertion"+it] assertion.name=name @@ -313,7 +315,7 @@ public class LogicProblemBuilder{ return assertion } - def public add(LogicProblem problem, TermDescription term) { + def add(LogicProblem problem, TermDescription term) { problem.add(Assertion(term)) } @@ -329,7 +331,7 @@ public class LogicProblemBuilder{ } } - def public checkDefinition(EObject definition) { + def checkDefinition(EObject definition) { /*for(value : definition.eAllContents.filter(SymbolicValue).toIterable) { var referred = value.symbolicReference if(referred instanceof Variable) { @@ -341,7 +343,7 @@ public class LogicProblemBuilder{ } // Containment - def public ContainmentHierarchy( + def ContainmentHierarchy( Iterable typesInHierarchy, Iterable containmentFunctions, Iterable containmentRelations, @@ -355,7 +357,7 @@ public class LogicProblemBuilder{ ] return result } - def public add(LogicProblem problem, ContainmentHierarchy hierarchy) { + def add(LogicProblem problem, ContainmentHierarchy hierarchy) { problem.containmentHierarchies+=hierarchy return hierarchy } @@ -413,7 +415,7 @@ public class LogicProblemBuilder{ return result; } - def public Term toTerm(TermDescription term) { + def Term toTerm(TermDescription term) { if(term instanceof Term) return term else if (term instanceof Variable) return createSymbolicValue => [symbolicReference = term] else if (term instanceof Constant) return term.call() @@ -421,74 +423,74 @@ public class LogicProblemBuilder{ else throw new UnsupportedOperationException("Can not create reference for symbolic declaration " + term.class.name) } - def public !(TermDescription term) { Not(term) } - def public Not(TermDescription term) { createNot => [operand = term.toTerm] } + def !(TermDescription term) { Not(term) } + def Not(TermDescription term) { createNot => [operand = term.toTerm] } - def public &&(TermDescription a, TermDescription b) { And(a,b) } - def public And(TermDescription... terms) { return And(terms as Iterable) } - def public And(Iterable terms) { createAnd => [operands += terms.map[toTerm]] } + def &&(TermDescription a, TermDescription b) { And(a,b) } + def And(TermDescription... terms) { return And(terms as Iterable) } + def And(Iterable terms) { createAnd => [operands += terms.map[toTerm]] } - def public ||(TermDescription a, TermDescription b) { Or(a,b) } - def public Or(TermDescription... terms) { Or(terms as Iterable) } - def public Or(Iterable terms) { createOr => [operands += terms.map[toTerm]] } + def ||(TermDescription a, TermDescription b) { Or(a,b) } + def Or(TermDescription... terms) { Or(terms as Iterable) } + def Or(Iterable terms) { createOr => [operands += terms.map[toTerm]] } - def public =>(TermDescription a, TermDescription b) { Impl(a,b) } - def public Impl(TermDescription a, TermDescription b) { createImpl => [leftOperand = a.toTerm rightOperand = b.toTerm] } + def =>(TermDescription a, TermDescription b) { Impl(a,b) } + def Impl(TermDescription a, TermDescription b) { createImpl => [leftOperand = a.toTerm rightOperand = b.toTerm] } - def public <=>(TermDescription a, TermDescription b) { Iff(a,b)} - def public Iff(TermDescription a, TermDescription b) { createIff =>[leftOperand=a.toTerm rightOperand=b.toTerm] } + def <=>(TermDescription a, TermDescription b) { Iff(a,b)} + def Iff(TermDescription a, TermDescription b) { createIff =>[leftOperand=a.toTerm rightOperand=b.toTerm] } - def public ITE(TermDescription condition, TermDescription ifTrue, TermDescription ifFalse) { + def ITE(TermDescription condition, TermDescription ifTrue, TermDescription ifFalse) { createIfThenElse => [it.condition = condition.toTerm it.ifTrue = ifTrue.toTerm it.ifFalse = ifFalse.toTerm] } - def public >(TermDescription left, TermDescription right) { MoreThan(left,right)} - def public MoreThan(TermDescription left, TermDescription right) { createMoreThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def >(TermDescription left, TermDescription right) { MoreThan(left,right)} + def MoreThan(TermDescription left, TermDescription right) { createMoreThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public <(TermDescription left, TermDescription right) { LessThan(left,right)} - def public LessThan(TermDescription left, TermDescription right) { createLessThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def <(TermDescription left, TermDescription right) { LessThan(left,right)} + def LessThan(TermDescription left, TermDescription right) { createLessThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public <=(TermDescription left, TermDescription right) { LessOrEqual(left,right) } - def public LessOrEqual(TermDescription left, TermDescription right) { createLessOrEqualThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def <=(TermDescription left, TermDescription right) { LessOrEqual(left,right) } + def LessOrEqual(TermDescription left, TermDescription right) { createLessOrEqualThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public >=(TermDescription left, TermDescription right) { MoreOrEqual(left,right) } - def public MoreOrEqual(TermDescription left, TermDescription right) { createMoreOrEqualThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def >=(TermDescription left, TermDescription right) { MoreOrEqual(left,right) } + def MoreOrEqual(TermDescription left, TermDescription right) { createMoreOrEqualThan => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public ==(TermDescription left, TermDescription right) {Equals(left,right)} - def public Equals(TermDescription left, TermDescription right) { createEquals => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def ==(TermDescription left, TermDescription right) {Equals(left,right)} + def Equals(TermDescription left, TermDescription right) { createEquals => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public !=(TermDescription left, TermDescription right) { Distinct(left,right) } - def public Distinct(TermDescription... terms) { return Distinct(terms as Iterable) } - def public Distinct(Iterable terms) { createDistinct => [operands += terms.map[toTerm]] } + def !=(TermDescription left, TermDescription right) { Distinct(left,right) } + def Distinct(TermDescription... terms) { return Distinct(terms as Iterable) } + def Distinct(Iterable terms) { createDistinct => [operands += terms.map[toTerm]] } - def public +(TermDescription left, TermDescription right) { Plus(left,right) } - def public Plus(TermDescription left, TermDescription right) { createPlus => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def +(TermDescription left, TermDescription right) { Plus(left,right) } + def Plus(TermDescription left, TermDescription right) { createPlus => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public -(TermDescription left, TermDescription right) { Minus(left,right) } - def public Minus(TermDescription left, TermDescription right) { createMinus => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def -(TermDescription left, TermDescription right) { Minus(left,right) } + def Minus(TermDescription left, TermDescription right) { createMinus => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public *(TermDescription left, TermDescription right) { Multiply(left,right) } - def public Multiply(TermDescription left, TermDescription right) { createMultiply => [leftOperand=left.toTerm rightOperand=right.toTerm] } + def *(TermDescription left, TermDescription right) { Multiply(left,right) } + def Multiply(TermDescription left, TermDescription right) { createMultiply => [leftOperand=left.toTerm rightOperand=right.toTerm] } - def public /(TermDescription left, TermDescription right) { Divide(left,right) } - def public Divide(TermDescription left, TermDescription right) { createDivison => [leftOperand = left.toTerm rightOperand = right.toTerm]} + def /(TermDescription left, TermDescription right) { Divide(left,right) } + def Divide(TermDescription left, TermDescription right) { createDivison => [leftOperand = left.toTerm rightOperand = right.toTerm]} - def public %(TermDescription left, TermDescription right) { Modulo(left,right) } - def public Modulo(TermDescription left, TermDescription right) { createMod => [leftOperand = left.toTerm rightOperand = right.toTerm]} + def %(TermDescription left, TermDescription right) { Modulo(left,right) } + def Modulo(TermDescription left, TermDescription right) { createMod => [leftOperand = left.toTerm rightOperand = right.toTerm]} - def public asTerm(boolean value) { createBoolLiteral => [x|x.value = value] } - def public asTerm(int value) { createIntLiteral => [x|x.value = value] } - def public asTerm(double value) { BigDecimal.valueOf(value).asTerm } - def public asTerm(float value) { BigDecimal.valueOf(value).asTerm } - def public asTerm(BigDecimal value) { createRealLiteral => [x|x.value = value] } - def public asTerm(String value) { createStringLiteral => [x|x.value = value]} - def public InstanceOf(TermDescription term, TypeDescriptor type) { + def asTerm(boolean value) { createBoolLiteral => [x|x.value = value] } + def asTerm(int value) { createIntLiteral => [x|x.value = value] } + def asTerm(double value) { BigDecimal.valueOf(value).asTerm } + def asTerm(float value) { BigDecimal.valueOf(value).asTerm } + def asTerm(BigDecimal value) { createRealLiteral => [x|x.value = value] } + def asTerm(String value) { createStringLiteral => [x|x.value = value]} + def InstanceOf(TermDescription term, TypeDescriptor type) { createInstanceOf => [ it.value = term.toTerm it.range = type.toTypeReference ] } - def public transitiveClosure(Relation relation, TermDescription source, TermDescription target) { + def transitiveClosure(Relation relation, TermDescription source, TermDescription target) { createTransitiveClosure => [ it.relation = relation it.leftOperand = leftOperand @@ -498,38 +500,79 @@ public class LogicProblemBuilder{ // QuantifiedExpressions - def public Forall(Function1 expression) { + def Forall(Function1 expression) { val context = new VariableContext(this,logicFactiory) val term = expression.apply(context) return createForall => [x| x.quantifiedVariables+=context.variables x.expression = term.toTerm] } - def public Forall(TermDescription expression, Variable... variables) { + def Forall(TermDescription expression, Variable... variables) { Forall(variables,expression) } - def public Forall(Iterable variables,TermDescription expression) { + def Forall(Iterable variables,TermDescription expression) { val forallExpression = createForall for(variable : variables) forallExpression.quantifiedVariables += variable forallExpression.expression = expression.toTerm return forallExpression } - def public Exists(Function1 expression) { + def Exists(Function1 expression) { val context = new VariableContext(this,logicFactiory) val term = expression.apply(context) return createExists => [x| x.quantifiedVariables+=context.variables x.expression = term.toTerm] } - def public Exists(TermDescription expression, Variable... variables) { + def Exists(TermDescription expression, Variable... variables) { Exists(variables,expression) } - def public Exists(Iterable variables, TermDescription expression) { + def Exists(Iterable variables, TermDescription expression) { val existsExpression = createExists for(variable : variables) existsExpression.quantifiedVariables += variable existsExpression.expression = expression.toTerm return existsExpression } + // AggregatedExpression + + private def configureAggregateExpression(T expression, Relation referred, List terms) { + if(terms.size != referred.parameters.size) { + throw new LogicProblemBuilderException( + '''The function called has «referred.parameters.size» parameters but it is called with «terms.size»!''') + } else { + expression.relation = referred + for(var i=0; i [it.variable = target] + expression.parameterSubstitution += substitution + } + return expression + } + } + private def configureProjectedAggregateExpression(T expression, Relation referred, List terms, int projection) { + if(projection < 0 || projection >= referred.parameters.size) { + throw new LogicProblemBuilderException( + '''The function called has «referred.parameters.size» parameters but it is called with «terms.size»!''') + } else { + val res = expression.configureAggregateExpression(referred, terms) + if(res.parameterSubstitution.get(projection) !== null) { + throw new LogicProblemBuilderException( + '''Projection over set variable!''') + } + val projectionType = referred.parameters.get(projection) + if(!(projectionType instanceof IntTypeReference || projectionType instanceof RealTypeReference)) { + throw new LogicProblemBuilderException('''Projection over nunnumeric parameter!''' + ) + } + res.projectionIndex = projection + return res + } + + } + def Count(Relation referred, List terms) { createCount.configureAggregateExpression(referred,terms) } + def Sum(Relation referred, List terms, int projection) { createSum.configureProjectedAggregateExpression(referred,terms,projection) } + def Min(Relation referred, List terms, int projection) { createMin.configureProjectedAggregateExpression(referred,terms,projection) } + def Max(Relation referred, List terms, int projection) { createMax.configureProjectedAggregateExpression(referred,terms,projection) } + // Function calls - def public call(Function function, TermDescription... substitutions) { + def call(Function function, TermDescription... substitutions) { call(function, substitutions as Iterable) } - def public call(Function function, Iterable substitutions) { + def call(Function function, Iterable substitutions) { val functionReference = createSymbolicValue functionReference.symbolicReference=function val List l= new LinkedList() @@ -546,8 +589,8 @@ public class LogicProblemBuilder{ } // Relation calls - def public call(Relation relation, TermDescription... substitution) { relation.call(substitution as Iterable)} - def public call(Relation relation, Iterable substitution) { + def call(Relation relation, TermDescription... substitution) { relation.call(substitution as Iterable)} + def call(Relation relation, Iterable substitution) { val relationReference = createSymbolicValue relationReference.symbolicReference = relation //println('''«relation.name»(«substitution.size»->«relation.parameters»)''') @@ -567,11 +610,9 @@ public class LogicProblemBuilder{ } // constant evaluation - def public call(Constant constant) { + def call(Constant constant) { val constantReference = createSymbolicValue constantReference.symbolicReference = constant return constantReference - } - - + } } -- cgit v1.2.3-54-g00ecf