use of com.sri.ai.grinder.sgdpllt.core.constraint.AbstractSingleVariableConstraintWithDependentNormalizedAtoms in project aic-expresso by aic-sri-international.
the class AbstractSingleVariableConstraintWithBinaryAtomsIncludingEquality method conjoinNonTrivialSignAndNormalizedAtomToConstraintWithBoundVariable.
private AbstractSingleVariableConstraintWithDependentNormalizedAtoms conjoinNonTrivialSignAndNormalizedAtomToConstraintWithBoundVariable(boolean sign, Expression normalizedAtom, Context context) {
Constraint result;
// first, use super's implementation to detect inconsistencies
AbstractSingleVariableConstraintWithDependentNormalizedAtoms conjunctionWithSignAndNormalizedAtom = super.conjoinNonTrivialSignAndNormalizedAtom(sign, normalizedAtom, context);
if (conjunctionWithSignAndNormalizedAtom == null) {
result = makeContradiction();
} else {
// this assumes the original single positive normalized atom stays as the first one in the conjoined constraint
Expression binding = getPositiveNormalizedAtoms().get(0);
// create a fresh constraint with the binding and external literals only
result = makeSimplification(arrayList(binding), arrayList(), getExternalLiterals());
// apply new normalized atom after replacing constraint's variable by its value (making it an external literal)
Expression newExternalLiteral = rewriteSignAndNormalizedAtomForValueVariableIsBoundTo(sign, normalizedAtom, binding.get(1), context);
result = result.conjoinWithLiteral(newExternalLiteral, context);
}
return (AbstractSingleVariableConstraintWithDependentNormalizedAtoms) result;
// Note: a simpler, more expensive version of this method could create an empty constraint,
// conjoin it with the binding, with each external literal, and the new normalized atom, converted to external literal,
// as opposed to using makeRefinementWith with all external literals at once.
// That solution would require the application of external literals one by one, however, whereas the above just copies them all at once.
}
use of com.sri.ai.grinder.sgdpllt.core.constraint.AbstractSingleVariableConstraintWithDependentNormalizedAtoms in project aic-expresso by aic-sri-international.
the class AbstractSingleVariableConstraintWithBinaryAtomsIncludingEquality method conjoinNonTrivialNormalizedEqualityToConstraintWithNonBoundVariable.
protected AbstractSingleVariableConstraintWithDependentNormalizedAtoms conjoinNonTrivialNormalizedEqualityToConstraintWithNonBoundVariable(boolean sign, Expression normalizedAtom, Context context) {
Constraint result;
// first, use super's implementation to detect inconsistencies
AbstractSingleVariableConstraintWithDependentNormalizedAtoms conjunctionWithSignAndNormalizedAtom = super.conjoinNonTrivialSignAndNormalizedAtom(sign, normalizedAtom, context);
if (conjunctionWithSignAndNormalizedAtom == null) {
result = makeContradiction();
} else {
Expression binding = normalizedAtom;
Expression valueVariableIsBoundTo = binding.get(1);
// create a fresh constraint with the binding only and external literals
result = makeSimplification(arrayList(binding), arrayList(), getExternalLiterals());
// convert all other normalized atoms to external literals with valueVariableIsBoundTo standing for constraint's variable
result = conjoinWithSignAndNormalizedAtomsOnValueVariableIsBoundTo(result, true, in(getPositiveNormalizedAtomsIncludingImplicitOnes(context)), valueVariableIsBoundTo, context);
if (result != null) {
result = conjoinWithSignAndNormalizedAtomsOnValueVariableIsBoundTo(result, false, in(getNegativeNormalizedAtomsIncludingImplicitOnes(context)), valueVariableIsBoundTo, context);
}
}
return (AbstractSingleVariableConstraintWithDependentNormalizedAtoms) result;
}
Aggregations