コード例 #1
0
 public void AssumeInDisInterval(Variable x, DisInterval value)
 {
     for (int i = 0; i < this.disjuncts.Length; i++)
     {
         this.disjuncts[i].AssumeInDisInterval(x, value);
     }
 }
コード例 #2
0
        protected override void AssumeInDisInterval_Internal(Variable x, DisInterval value)
        {
            if (value.IsTop)
            {
                return;
            }
            DisInterval prev, next;

            if (this.TryGetValue(x, out prev))
            {
                next = prev.Meet(value);
            }
            else
            {
                next = value;
            }

            if (next.IsBottom)
            {
                this.State = AbstractState.Bottom;
            }
            else
            {
                this[x] = next;
            }
        }
コード例 #3
0
        public NonRelationalValueAbstraction(
            DisInterval interval, SymbolicExpressionTracker <Variable, Expression> symbolicConditions,
            SetOfConstraints <Variable> equalities, SetOfConstraints <Variable> disequalities,
            SetOfConstraints <Variable> weakUpperBounds, SetOfConstraints <Variable> strictUpperBounds,
            SetOfConstraints <Variable> existential)
        {
            Contract.Requires(interval != null);
            Contract.Requires(symbolicConditions != null);
            Contract.Requires(disequalities != null);
            Contract.Requires(equalities != null);
            Contract.Requires(weakUpperBounds != null);
            Contract.Requires(strictUpperBounds != null);
            Contract.Requires(existential != null);

            disInterval             = interval;
            this.symbolicConditions = symbolicConditions;
            weaklyRelationalDomains = new SetOfConstraints <Variable>[WeaklyRelationalDomainsCount]
            {
                equalities,
                disequalities,
                weakUpperBounds,
                strictUpperBounds,
                existential
            };
        }
コード例 #4
0
        protected override void AssumeInDisInterval_Internal(Variable x, DisInterval disIntv)
        {
            Rational r;

            if (disIntv.TryGetSingletonValue(out r))
            {
                Interval_IEEE754 value;
                long             intValue;
                if (r.TryInt64(out intValue))
                {
                    value = Interval_IEEE754.For(intValue);
                }
                else
                {
                    value = Interval_IEEE754.For((double)r);
                }

                Interval_IEEE754 prev;
                if (this.TryGetValue(x, out prev))
                {
                    value = value.Meet(prev);
                }

                this[x] = value;
            }
        }
コード例 #5
0
        // Meaning:
        // weaklyRelationalDomains[0] == Equalities
        // weaklyRelationalDomains[1] == DisEqualities
        // weaklyRelationalDomains[2] == WeakUpperBounds
        // weaklyRelationalDomains[3] == StrictUpperBounds
        // weaklyRelationalDomains[4] == Existential

        #endregion

        #region Constructor

        public NonRelationalValueAbstraction(DisInterval interval)
            : this(interval, SymbolicExpressionTracker <Variable, Expression> .Unknown,
                   SetOfConstraints <Variable> .Unknown, SetOfConstraints <Variable> .Unknown,
                   SetOfConstraints <Variable> .Unknown,
                   SetOfConstraints <Variable> .Unknown, SetOfConstraints <Variable> .Unknown)
        {
            Contract.Requires(interval != null);
        }
コード例 #6
0
        protected override void AssumeLeftLessThanK(Variable left, DisInterval k)
        {
            DisInterval refined;

            if (IntervalInference.TryRefine_LeftLessThanK(true, left, k, this, out refined))
            {
                this[left] = refined;
            }
        }
コード例 #7
0
        protected override void AssumeKLessThanRight(DisInterval k, Variable right)
        {
            DisInterval refined;

            if (IntervalInference.TryRefine_KLessThanRight(true, k, right, Rational.For(1), this, out refined))
            {
                this[right] = refined;
            }
        }
コード例 #8
0
            public static DisInterval EnumValues <Type>(Type t, Func <Type, List <int> > enumranges)
            {
                var ranges = enumranges(t);

                if (ranges != null)
                {
                    return(DisInterval.For(ranges.ConvertAll <Interval>(x => Interval.For(x))));
                }

                return(Ranges.Int32Range);
            }
コード例 #9
0
        private NonRelationalValueAbstraction(
            DisInterval interval, SymbolicExpressionTracker <Variable, Expression> symbolicConditions,
            SetOfConstraints <Variable>[] domains)
        {
            Contract.Requires(interval != null);
            Contract.Requires(symbolicConditions != null);
            Contract.Requires(domains != null);

            Contract.Requires(domains.Length == WeaklyRelationalDomainsCount);
            Contract.Requires(Contract.ForAll(domains, el => el != null));

            disInterval             = interval;
            this.symbolicConditions = symbolicConditions;
            weaklyRelationalDomains = domains;
        }
コード例 #10
0
        public override FlatAbstractDomain <bool> IsNotZero(DisInterval intv)
        {
            Contract.Assume(intv != null); // F: just lazy

            if (intv.IsSingleton && intv.LowerBound.IsZero)
            {
                return(CheckOutcome.False);
            }

            if (intv.Meet(this.IntervalZero).IsBottom)
            {
                return(CheckOutcome.True);
            }

            return(CheckOutcome.Top);
        }
コード例 #11
0
        private DisIntervalEnvironment <Variable, Expression> TestTrueEqualToDisinterval(Variable v, DisInterval dis)
        {
            Contract.Requires(dis != null);
            Contract.Ensures(Contract.Result <DisIntervalEnvironment <Variable, Expression> >() != null);

            DisInterval prevVal;

            if (this.TryGetValue(v, out prevVal))
            {
                dis = prevVal.Meet(dis);
            }

            this[v] = dis;

            return(this);
        }
コード例 #12
0
        public override DisIntervalEnvironment <Variable, Expression> TestNotEqual(Expression e1, Expression e2)
        {
            var v2 = this.Eval(e2);

            if (v2.IsSingleton)
            {
                var notV2 = DisInterval.NotInThisInterval(v2);

                var e1Var = this.ExpressionManager.Decoder.UnderlyingVariable(this.ExpressionManager.Decoder.Stripped(e1));

                this.RefineWith(e1Var, notV2);
            }

            bool isBottomLT, isBottomGT;

            var constraintsLT = IntervalInference.InferConstraints_LT(true, e1, e2, this.ExpressionManager.Decoder, this, out isBottomLT);
            var constraintsGT = IntervalInference.InferConstraints_LT(true, e2, e1, this.ExpressionManager.Decoder, this, out isBottomGT);

            if (isBottomLT)
            {
                // Bottom join Bottom = Bottom
                if (isBottomGT)
                {
                    return(this.Bottom);
                }
                this.TestTrueListOfFacts(constraintsGT);
            }
            else if (isBottomGT)
            {
                this.TestTrueListOfFacts(constraintsLT);
            }
            else
            {
                var join = JoinConstraints(constraintsLT, constraintsGT);

                this.TestTrueListOfFacts(join);
            }

            return(this);
        }
コード例 #13
0
        public override DisInterval Interval_Not(DisInterval left)
        {
            if (!left.IsNormal)
            {
                return(left);
            }
            // !(!0) is 0
            if (left.IsNotZero)
            {
                return(DisInterval.For(0));
            }
            // !(0) is !=0
            if (left.IsZero)
            {
                return(DisInterval.NotZero);
            }
            // !([0, +oo]) is [-oo, -1]
            if (left.IsPositiveOrZero)
            {
                return(DisInterval.Negative);
            }

            return(left);
        }
コード例 #14
0
 public override DisInterval For(uint u)
 {
     return(DisInterval.For(u));
 }
コード例 #15
0
 public override DisInterval For(Rational r)
 {
     return(DisInterval.For(r));
 }
コード例 #16
0
 public override DisInterval For(long v)
 {
     return(DisInterval.For(v));
 }
コード例 #17
0
 public override DisInterval For(sbyte s)
 {
     return(DisInterval.For(s));
 }
コード例 #18
0
 public override DisInterval For(double d)
 {
     return(DisInterval.For(d));
 }
コード例 #19
0
 public override DisInterval For(short v)
 {
     return(DisInterval.For(v));
 }
コード例 #20
0
 protected override DisInterval ApplyConversion(ExpressionOperator conversionType, DisInterval val)
 {
     return(val.Map(intv => Interval.ApplyConversion(conversionType, intv)));
 }
コード例 #21
0
 public override DisInterval For(byte v)
 {
     return(DisInterval.For(v));
 }
コード例 #22
0
 public override DisInterval Interval_ShiftRight(DisInterval left, DisInterval right)
 {
     return(DisInterval.ShiftRight(left, right));
 }
コード例 #23
0
 public override DisInterval Interval_BitwiseOr(DisInterval left, DisInterval right)
 {
     return(left | right);
 }
コード例 #24
0
 public override DisInterval Interval_UnaryMinus(DisInterval left)
 {
     return(-left);
 }
コード例 #25
0
 void IIntervalAbstraction <Variable, Expression> .AssumeInDisInterval(Variable x, DisInterval value)
 {
     this.AssumeInDisInterval(x, value);
 }
コード例 #26
0
 public override DisInterval For(Rational inf, Rational sup)
 {
     return(DisInterval.For(inf, sup));
 }
コード例 #27
0
 protected override DisInterval ConvertInterval(Interval intv)
 {
     return(DisInterval.For(intv));
 }
コード例 #28
0
 public override DisInterval Interval_Rem(DisInterval left, DisInterval right)
 {
     return(left % right);
 }
コード例 #29
0
 public void AssumeInDisInterval(Variable x, DisInterval value)
 {
     // does nothing
 }
コード例 #30
0
 public override DisInterval Interval_BitwiseAnd(DisInterval left, DisInterval right)
 {
     return(left & right);
 }