/// <summary> /// Coerces an integer into a natural. /// </summary> public Z3Expr MkNegCoercion(Z3IntExpr i) { var zero = Context.MkInt(0); var one = Context.MkInt(1); var two = Context.MkInt(2); var oddCase = BoxingFun.Apply(i.Add(Context, one).Div(Context, two)); var coercion = i.IsEven(Context).Ite( Context, BoxingFun.Apply(i.Neg(Context).Div(Context, two)), oddCase); return(coercion); }
/// <summary> /// Coerces an integer into a pos integer. /// </summary> public Z3Expr MkPosCoercion(Z3IntExpr i) { var zero = Context.MkInt(0); var one = Context.MkInt(1); var two = Context.MkInt(2); var oddCase = BoxingFun.Apply(one.Sub(Context, i).Div(Context, two)); var coercion = i.IsEven(Context).Ite( Context, BoxingFun.Apply(i.Div(Context, two)), oddCase); coercion = i.Eq(Context, one).Ite( Context, BoxingFun.Apply(zero), coercion); return(coercion); }
/// <summary> /// Coerces an integer into a natural. /// </summary> public Z3Expr MkNatCoercion(Z3IntExpr i) { var zero = Context.MkInt(0); var one = Context.MkInt(1); var two = Context.MkInt(2); var evenCase = BoxingFun.Apply(i.Neg(Context).Div(Context, two)); var coercion = i.IsEven(Context).Not(Context).Ite( Context, BoxingFun.Apply(i.Add(Context, one).Div(Context, two)), evenCase); coercion = i.Eq(Context, zero).Ite( Context, BoxingFun.Apply(zero), coercion); return(coercion); }