Example #1
0
        public Z3BoolExpr MkTest(Z3Expr t, Term type)
        {
            Term intr;
            var  unn = Owner.GetIntersection(Type, type, out intr);
            var  bt  = (Z3BVExpr)UnboxingFun.Apply(t);

            if (intr == null)
            {
                return(Context.MkFalse());
            }
            else if (intr == Type)
            {
                return(Context.MkTrue());
            }

            Z3BoolExpr test = null;

            foreach (var i in unn.RangeMembers)
            {
                var istart = Context.MkBV((i.Key - Lower).ToString(), bvSort.Size);
                var iend   = Context.MkBV((i.Value - Lower).ToString(), bvSort.Size);
                test = test.Or(Context, bt.UGe(Context, istart).And(Context, bt.ULe(Context, iend)));
            }

            return(test);
        }
Example #2
0
        public Z3BoolExpr MkTest(Z3Expr t, Term type)
        {
            Term intr;
            var  unn = Owner.GetIntersection(Type, type, out intr);
            var  it  = (Z3IntExpr)UnboxingFun.Apply(t);

            if (intr == null)
            {
                return(Context.MkFalse());
            }
            else if (intr == Type)
            {
                return(Context.MkTrue());
            }

            Z3BoolExpr test = null;
            var        iPos = MkIntCoercion(t);

            foreach (var r in unn.RangeMembers)
            {
                test = test.Or(
                    Context,
                    iPos.Ge(
                        Context,
                        Context.MkInt(r.Key.ToString())).And(
                        Context,
                        iPos.Le(Context, Context.MkInt(r.Value.ToString()))));
            }

            return(test);
        }
Example #3
0
        public Z3BoolExpr MkTest(Z3Expr t, Term type)
        {
            Term intr;
            var  unn = Owner.GetIntersection(Type, type, out intr);
            var  bt  = (Z3BVExpr)UnboxingFun.Apply(t);

            if (intr == null)
            {
                return(Context.MkFalse());
            }
            else if (intr == Type)
            {
                return(Context.MkTrue());
            }

            Z3BoolExpr test = null;

            foreach (var m in unn.NonRangeMembers)
            {
                if (m.Kind != SymbolKind.BaseCnstSymb && m.Kind != SymbolKind.UserCnstSymb)
                {
                    continue;
                }

                test = test.Or(Context, bt.Eq(Context, Context.MkBV(symbToVal[m], bvSort.Size)));
            }

            return(test);
        }
Example #4
0
        public Z3IntExpr MkIntCoercion(Z3Expr rng)
        {
            Contract.Requires(rng.Sort.Equals(Representation));
            var i = (Z3BVExpr)UnboxingFun.Apply(rng);
            var c = (Z3IntExpr)z3Lower.Add(Context, i.BV2Int(Context));

            return(c);
        }
Example #5
0
        public Z3IntExpr MkIntCoercion(Z3Expr pos)
        {
            Contract.Requires(pos.Sort.Equals(Representation));
            var i    = (Z3IntExpr)UnboxingFun.Apply(pos);
            var zero = Context.MkInt(0);
            var one  = Context.MkInt(1);
            var two  = Context.MkInt(2);
            var ntwo = Context.MkInt(-2);

            return((Z3IntExpr)i.Eq(Context, zero).Ite(
                       Context,
                       one,
                       i.Gt(Context, zero).Ite(
                           Context,
                           i.Mul(Context, two),
                           i.Mul(Context, ntwo).Add(Context, one))));
        }
Example #6
0
        public Z3BoolExpr MkTest(Z3Expr t, Term type)
        {
            Contract.Assert(t != null && t.Sort.Equals(Representation));

            Term intr;
            var  unn = Owner.GetIntersection(Type, type, out intr);

            if (intr == null)
            {
                return(Context.MkFalse());
            }
            else if (intr == Type)
            {
                return(Context.MkTrue());
            }

            Z3BoolExpr test = null;
            var        nat  = (Z3IntExpr)UnboxingFun.Apply(t);

            if (unn.Contains(Index.SymbolTable.GetSortSymbol(BaseSortKind.PosInteger)))
            {
                test = test.Or(Context, nat.NEq(Context, Context.MkInt(0)));
            }

            var iNat = MkIntCoercion(t);

            foreach (var r in unn.RangeMembers)
            {
                test = test.Or(
                    Context,
                    iNat.Ge(
                        Context,
                        Context.MkInt(r.Key.ToString())).And(
                        Context,
                        iNat.Le(Context, Context.MkInt(r.Value.ToString()))));
            }

            return(test);
        }