public override WExpr InterpretModel(Context context, Model model, ProgramBuilder builder) { int opChoice = GetConcChoice(context, model); WCComparison.CompareType op = (opChoice == 0) ? WCComparison.CompareType.eq : WCComparison.CompareType.neq; WExpr rv = new WCComparison((WEVar)x.InterpretModel(context, model, builder), op, new WEConst(0)); builder.CheckExpr(rv); return(rv); }
public override WExpr InterpretModel(Context context, Model model, ProgramBuilder builder) { WEVar arg1Conc = (WEVar)arg1.InterpretModel(context, model, builder); WCComparison.CompareType comp = (WCComparison.CompareType) this.GetConcChoice(context, model); WEOperand arg2Conc = (WEOperand)arg2.InterpretModel(context, model, builder); WExpr rv = new WCComparison(arg1Conc, comp, arg2Conc); builder.CheckExpr(rv); return(rv); }
public override bool KeepProgram(WExpr expr) { #region filter out: x_i = x_i if (expr is WEArith) { WEArith e = (WEArith)expr; if (e.op == WEArith.ArithOp.plus || e.op == WEArith.ArithOp.minus) { if (e.arg1 is WEVar && e.arg2 is WEConst) { if (e.lhs.id == ((WEVar)e.arg1).id && ((WEConst)e.arg2).value == 0) { return(false); } } if (e.arg2 is WEVar && e.arg1 is WEConst) { if (e.lhs.id == ((WEVar)e.arg2).id && ((WEConst)e.arg1).value == 0) { return(false); } } } } #endregion #region filter out: x = x_i - x_i if (expr is WEArith) { WEArith e = (WEArith)expr; if (e.op == WEArith.ArithOp.minus) { if (e.arg1 is WEVar && e.arg2 is WEVar) { if (((WEVar)e.arg1).id == ((WEVar)e.arg2).id) { return(false); } } } } #endregion #region filter out: unsatisfiable and tautological comparisons if (expr is WCComparison) { WCComparison e = (WCComparison)expr; if (e.arg2 is WEVar) { if (e.arg1.id == ((WEVar)e.arg2).id) { return(false); } } else { if (e.arg2.IsZero() && e.op == WCComparison.CompareType.l) { return(false); } } } #endregion #region filter out: if statements where the <then> and <else> parts are the same if (expr is WEIf) { WEIf e = (WEIf)expr; if (e.elseBody != null) { if (e.thenBody.ToString() == e.elseBody.ToString()) { return(false); } } } #endregion #region filter out: compound conditions of the form C_i op C_i if (expr is WCCompound) { WCCompound e = (WCCompound)expr; if (e.cond1.ToString() == e.cond2.ToString()) { return(false); } } #endregion return(true); }