private CardExpr MkAnyUnion(DependencyNode node, AppFreeCanUnn arg) { CardExpr expr = MkConstantCount(arg); if (expr.IsInfinity) { return(expr); } foreach (var m in arg.NonRangeMembers) { if (m.Kind != SymbolKind.UserSortSymb) { continue; } var data = varMap[((UserSortSymb)m).DataSymbol]; if (data.Item1 == node) { return(new CardCnst(Cardinality.Infinity)); } else { expr += data.Item2; } } return(expr); }
private Cardinality Eval(CardExpr expr, CardVar cvar, Cardinality val, bool evalOnLower) { switch (expr.Kind) { case CardExpr.ExprKind.Cnst: return(((CardCnst)expr).Value); case CardExpr.ExprKind.Var: if (expr == cvar) { return(val); } else if (evalOnLower) { return(GetRange((CardVar)expr).Lower); } else { return(GetRange((CardVar)expr).Upper); } case CardExpr.ExprKind.Prod: return(Eval(expr[0], cvar, val, evalOnLower) * Eval(expr[1], cvar, val, evalOnLower)); case CardExpr.ExprKind.Unn: return(Eval(expr[0], cvar, val, evalOnLower) + Eval(expr[1], cvar, val, evalOnLower)); default: throw new NotImplementedException(); } }
public CardConstraint(OpKind op, CardVar lhs, CardExpr rhs) { Contract.Requires(lhs != null && rhs != null); Op = op; Lhs = lhs; Rhs = rhs; GetRHSVars(rhs); }
private void GetRHSVars(CardExpr subexpr) { if (subexpr.Kind == CardExpr.ExprKind.Var) { rhsVars.Add((CardVar)subexpr); } else { for (int i = 0; i < subexpr.Arity; ++i) { GetRHSVars(subexpr[i]); } } }
private CardRange Eval(CardExpr expr) { switch (expr.Kind) { case CardExpr.ExprKind.Cnst: return(((CardCnst)expr).ValueAsRange); case CardExpr.ExprKind.Var: return(GetRange((CardVar)expr)); case CardExpr.ExprKind.Prod: return(Eval(expr[0]) * Eval(expr[1])); case CardExpr.ExprKind.Unn: return(Eval(expr[0]) + Eval(expr[1])); default: throw new NotImplementedException(); } }
private CardExpr MkRelationalUnion(DependencyNode node, AppFreeCanUnn arg) { CardExpr expr = MkConstantCount(arg); if (expr.IsInfinity) { return(expr); } foreach (var m in arg.NonRangeMembers) { if (m.Kind != SymbolKind.UserSortSymb) { continue; } var data = varMap[((UserSortSymb)m).DataSymbol]; Contract.Assert(data.Item1 != node); expr += data.Item3; } return(expr); }
public CardCartProd(CardExpr expr1, CardExpr expr2) { Contract.Requires(expr1 != null && expr2 != null); Expr1 = expr1; Expr2 = expr2; }
public CardDisjUnion(CardExpr expr1, CardExpr expr2) { Contract.Requires(expr1 != null && expr2 != null); Expr1 = expr1; Expr2 = expr2; }