Exemple #1
0
        public bool initializeFromModel(Z3.Model model, ref Z3Context z3Context)
        {
            Debug.Assert(model != null);
            Context context = z3Context.context;
            Term termHasFirst = context.MkConst(this.str + "_hf", z3Context.boolSort);
            Term termHasSecond = context.MkConst(this.str + "_hs", z3Context.boolSort);
            Term termSign1 = context.MkConst(this.str + "_s1", z3Context.boolSort);
            Term termSign2 = context.MkConst(this.str + "_s2", z3Context.boolSort);
            Term termVar1 = context.MkConst(this.str + "_v1", z3Context.intSort);
            Term termVar2 = context.MkConst(this.str + "_v2", z3Context.intSort);
            Term termOp = context.MkConst(this.str + "_op", z3Context.boolSort);
            Term termConstant = context.MkConst(this.str + "_c", z3Context.intSort);

            bool ret = false;

            bool hf = context.GetBoolValue(model.Eval(termHasFirst)).getBool();
            bool hs = context.GetBoolValue(model.Eval(termHasSecond)).getBool();
            bool s1 = context.GetBoolValue(model.Eval(termSign1)).getBool();
            bool s2 = context.GetBoolValue(model.Eval(termSign2)).getBool();
            int v1 = context.GetNumeralInt(model.Eval(termVar1));
            int v2 = context.GetNumeralInt(model.Eval(termVar2));
            bool op = context.GetBoolValue(model.Eval(termOp)).getBool();
            int c = context.GetNumeralInt(model.Eval(termConstant));

            if (this.hasFirst != hf)
            {
                ret = true;
                goto init;
            }
            if (!this.hasFirst && !hf)
            {
                bool oldVal = this.op ? 0 == this.constant : 0 <= this.constant;
                bool newVal = op ? 0 == c : 0 <= c;
                if (oldVal != newVal)
                {
                    ret = true;
                }
                goto init;
            }
            // hf && this.hasFirst
            if (this.sign1 != s1 || this.var1 != v1)
            {
                ret = true;
                goto init;
            }
            if (this.hasSecond != hs)
            {
                ret = true;
                goto init;
            }
            if (this.hasSecond && hs)
            {
                if (this.sign2 != s2 || this.var2 != v2)
                {
                    ret = true;
                    goto init;
                }
            }
            if (this.op != op || this.constant != c)
            {
                ret = true;
                goto init;
            }

            init:
            this.hasFirst = hf;
            this.hasSecond = hs;
            this.sign1 = s1;
            this.sign2 = s2;
            this.var1 = v1;
            this.var2 = v2;
            this.op = op;
            this.constant = c;

            return ret;
        }
Exemple #2
0
        public bool initializeFromModel(Z3.Model model, ref Z3Context z3Context)
        {
            Debug.Assert(model != null);
            Context context = z3Context.context;

            Term termUpperLimit = context.MkConst(this.str + "_ul", z3Context.intSort);
            Term termLowerLimit = context.MkConst(this.str + "_ll", z3Context.intSort);
            Term termHasUpperLimit = context.MkConst(this.str + "_hul", z3Context.boolSort);
            Term termHasLowerLimit = context.MkConst(this.str + "_hll", z3Context.boolSort);

            bool ret = false;

            int ul = context.GetNumeralInt(model.Eval(termUpperLimit));
            int ll = context.GetNumeralInt(model.Eval(termLowerLimit));
            bool hul = context.GetBoolValue(model.Eval(termHasUpperLimit)).getBool();
            bool hll = context.GetBoolValue(model.Eval(termHasLowerLimit)).getBool();

            if((hasUpperLimit != hul) || (hasUpperLimit && hul && (upperLimit != ul)))
                ret = true;

            if ((hasLowerLimit != hll) || (hasLowerLimit && hll && (lowerLimit != ll)))
                ret = true;

            upperLimit = ul;
            lowerLimit = ll;
            hasUpperLimit = hul;
            hasLowerLimit = hll;
            return ret;
        }