public static BooleanExpression containmentCondition(SymbolicString s, ArithmeticLanguage l, BooleanExpression additionalConstraints) { // Console.WriteLine("Checking containment of " + s + " in " + l); var goodMatches = Matcher .match(s, l.symbolic_string) .Select(x => x.forceFinish()) .Select(x => x.withAdditionalConstraint(l.constraint)) .Where(x => x.isFeasible()) ; if (goodMatches.Count() == 0) { return(LogicalExpression.False()); } var matchCondition = LogicalExpression.False(); foreach (var match in goodMatches) { System.Diagnostics.Debug.WriteLine("Got good match: " + match); matchCondition = LogicalExpression.Or(matchCondition, match.constraint); } var condition = LogicalExpression.Implies(additionalConstraints, matchCondition); var variables = condition.GetVariables(); var pVariables = s.GetIntegerVariables(); // Most of the times, should be 1 var nonPVariables = variables.Where(x => !pVariables.Contains(x)); var eCondition = QuantifiedExpression.Exists(nonPVariables, condition); var aCondition = QuantifiedExpression.Forall(pVariables, eCondition); return(aCondition); }
public static BooleanExpression Implies(BooleanExpression op1, BooleanExpression op2) { return(LogicalExpression.Or(LogicalExpression.Not(op1), op2)); }