public IAbstractDomainForEnvironments <Variable, Expression> TestFalse(Expression guard)
        {
            StripeWithIntervals <Variable, Expression, MetaDataDecoder> resultLeft  = (StripeWithIntervals <Variable, Expression, MetaDataDecoder>)Left.TestFalse(guard);
            LinearEqualitiesEnvironment <Variable, Expression>          resultRight = (LinearEqualitiesEnvironment <Variable, Expression>)Right.TestFalse(guard);

            return((IAbstractDomainForEnvironments <Variable, Expression>)Factory(resultLeft, resultRight));
        }
        public SubPoly(IExpressionDecoder <Expression> decoder, IExpressionEncoder <Expression> encoder)
        {
            IntervalEnvironment <Expression>         intv  = new IntervalEnvironment <Expression>(decoder, encoder);
            LinearEqualitiesEnvironment <Expression> lineq = new LinearEqualitiesEnvironment <Expression>(decoder, encoder, true, false);

            this.subpoly = new SubPolyhedra <Expression>(lineq, intv, decoder, encoder);
        }
        public FlatAbstractDomain <bool> /*!*/ CheckIfLessThan(Expression /*!*/ e1, Expression /*!*/ e2)
        {
            FlatAbstractDomain <bool> /*!*/ checkLeft  = this.Left.CheckIfLessThan(e1, e2);
            FlatAbstractDomain <bool> /*!*/ checkRight = this.Right.CheckIfLessThan(e1, e2);

            FlatAbstractDomain <bool> result = (FlatAbstractDomain <bool> /*!*/)checkLeft.Meet(checkRight);

            if (result.Equals(result.Top) && !light)
            { //If we do not arrive to check the condition, we try to refine the information in the stripe domain with the state of the Karr domain
                LinearEqualitiesEnvironment <Variable, Expression> karrRefined = this.Right;
                var refined = this.Left.Right;
                if (strong)
                { //If we want to perform a precise but slow analysis, we refine the information for all the variables of the state of the Karr Domain
                    var variables = this.ExtractVariable(e1);
                    variables.AddRange(this.ExtractVariable(e2));

                    //foreach (var e in variables)
                    //  refined = refined.Refine(karrRefined, e);

                    //foreach (var e in karrRefined.Variables)
                    //  refined = refined.Refine(karrRefined, e);
                }
                else
                {//Otherwise we refine only on the variables of the condition
                    var variables = this.ExtractVariable(e1);
                    variables.AddRange(this.ExtractVariable(e2));

                    //foreach (var e in variables)
                    //  refined = refined.Refine(karrRefined, e);
                }
                checkRight = refined.CheckIfLessThan(e1, e2 /*, this.Left.Left*/);
                result     = checkLeft.Meet(checkRight);
            }
            return(result);
        }
        public INumericalAbstractDomain <Variable, Expression> TestTrueGeqZero(Expression /*!*/ exp)
        {
            StripeWithIntervals <Variable, Expression, MetaDataDecoder> resultLeft  = (StripeWithIntervals <Variable, Expression, MetaDataDecoder>)Left.TestTrueGeqZero(exp);
            LinearEqualitiesEnvironment <Variable, Expression>          resultRight = (LinearEqualitiesEnvironment <Variable, Expression>)Right.TestTrueGeqZero(exp);

            return((INumericalAbstractDomain <Variable, Expression>)Factory(resultLeft, resultRight));
        }
        public StripeIntervalsKarr <Variable, Expression, MetaDataDecoder> TestTrueEqual(Expression /*!*/ exp1, Expression /*!*/ exp2)
        {
            StripeWithIntervals <Variable, Expression, MetaDataDecoder> resultLeft  = (StripeWithIntervals <Variable, Expression, MetaDataDecoder>)Left.TestTrueEqual(exp1, exp2);
            LinearEqualitiesEnvironment <Variable, Expression>          resultRight = (LinearEqualitiesEnvironment <Variable, Expression>)Right.TestTrueEqual(exp1, exp2);

            return((StripeIntervalsKarr <Variable, Expression, MetaDataDecoder>)Factory(resultLeft, resultRight));
        }
Exemplo n.º 6
0
 public LinearEquations(LinearEqualitiesEnvironment <Variable, Expression> parent, SparseRationalArray[] matrix)
 {
     this.matrix = matrix;
     sharinglist = new List <LinearEqualitiesEnvironment <Variable, Expression> >()
     {
         parent
     };
 }
Exemplo n.º 7
0
        public LinearEquations <Variable, Expression> AddSharing(LinearEqualitiesEnvironment <Variable, Expression> newSharing)
        {
            Contract.Ensures(Contract.Result <LinearEquations <Variable, Expression> >() != null);

            sharinglist.Add(newSharing);

            return(this);
        }
        Reduce(StripeWithIntervals <Variable, Expression, MetaDataDecoder> left, LinearEqualitiesEnvironment <Variable, Expression> right)
        {
            // We want to propagate this information as the join for Stripes and Lineq is very smart, but the one for intervals is not
            foreach (var constant in right.ConstantValues())
            {
                left.AssignInterval(constant.One, Interval.For(constant.Two));
            }

            return(this.Factory(left, right));
        }
Exemplo n.º 9
0
        private List <LinearEqualitiesEnvironment <Variable, Expression> > sharinglist;     // The list of linearequalities environments sharing those equations

        public LinearEquations(LinearEqualitiesEnvironment <Variable, Expression> parent, int equationsCount)
        {
            Contract.Requires(equationsCount >= 0);

            matrix      = new SparseRationalArray[equationsCount];
            sharinglist = new List <LinearEqualitiesEnvironment <Variable, Expression> >()
            {
                parent
            };
        }
Exemplo n.º 10
0
 public LinearEqualitiesForUnsafeCode(
     LinearEqualitiesEnvironment <BoxedExpression> /*!*/ val,
     BoxedExpressionDecoder <Type, ExternalExpression> decoder,
     IExpressionContext <APC, Local, Parameter, Method, Field, Type, ExternalExpression, Variable> context,
     IDecodeMetaData <Local, Parameter, Method, Field, Property, Type, Attribute, Assembly> mdDecoder)
     : base(val)
 {
     this.bdecoder  = decoder;
     this.context   = context;
     this.mdDecoder = mdDecoder;
 }
Exemplo n.º 11
0
        public void ZeroCol(LinearEqualitiesEnvironment <Variable, Expression> env, int col, ref LinearEquations <Variable, Expression> equations)
        {
            if (sharinglist.Count == 1)
            {
                ZeroCol(matrix, col);

                equations = this;
            }
            else
            {
                var result = this.Unshare(env, ref equations);
                ZeroCol(result, col);

                equations = new LinearEquations <Variable, Expression>(env, result);
            }
        }
        /// <summary>
        /// The pairwise widening
        /// </summary>
        public override IAbstractDomain Widening(IAbstractDomain prev)
        {
            if (this.IsBottom)
            {
                return(prev);
            }
            if (prev.IsBottom)
            {
                return(this);
            }

            Debug.Assert(prev is StripeIntervalsKarr <Variable, Expression, MetaDataDecoder>, "Wrong type of the domain for the widening...");
            StripeIntervalsKarr <Variable, Expression, MetaDataDecoder> asIntWSUB = (StripeIntervalsKarr <Variable, Expression, MetaDataDecoder>)prev;

            StripeWithIntervals <Variable, Expression, MetaDataDecoder> widenLeft  = (StripeWithIntervals <Variable, Expression, MetaDataDecoder>) this.Left.Widening(asIntWSUB.Left);
            LinearEqualitiesEnvironment <Variable, Expression>          widenRight = (LinearEqualitiesEnvironment <Variable, Expression>) this.Right.Widening(asIntWSUB.Right);

            StripeIntervalsKarr <Variable, Expression, MetaDataDecoder> result = (StripeIntervalsKarr <Variable, Expression, MetaDataDecoder>) this.Factory(widenLeft, widenRight);

            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// If <code>who</code>is the only one sharing this set of equations, then we simply return the set of equations
        /// Otherwise, we create a copy of the set of equations, we remove <code>who</code> from the sharing list of those equations, and
        /// we update equations
        /// </summary>
        /// <param name="equations">The new set of linear equations</param>
        public SparseRationalArray[] Unshare(LinearEqualitiesEnvironment <Variable, Expression> who, ref LinearEquations <Variable, Expression> equations)
        {
            Contract.Ensures(Contract.Result <SparseRationalArray[]>() != null);
            Contract.Ensures(Contract.Result <SparseRationalArray[]>().Length == matrix.Length);

            lock (sharinglist)
            {
                if (sharinglist.Count > 1)
                {
                    sharinglist.Remove(who);

                    var result = this.GetClonedEquations();

                    equations = new LinearEquations <Variable, Expression>(who, result);

                    return(result);
                }
                else
                { // Nothing to do, we just return the previous ones
                    equations = this;
                    return(matrix);
                }
            }
        }
 Factory(StripeWithIntervals <Variable, Expression, MetaDataDecoder> left, LinearEqualitiesEnvironment <Variable, Expression> right)
 {
     return(new StripeIntervalsKarr <Variable, Expression, MetaDataDecoder>(left, right, this.Decoder, this.Encoder, this.Log));
 }
 public StripeIntervalsKarr(StripeWithIntervals <Variable, Expression, MetaDataDecoder> /*!*/ left, LinearEqualitiesEnvironment <Variable, Expression> /*!*/ right, IExpressionDecoder <Variable, Expression> decoder, IExpressionEncoder <Variable, Expression> encoder, Logger Log)
     : base(left, right, Log)
 {
     this.decoder = decoder;
     this.encoder = encoder;
 }
                protected override ReducedCartesianAbstractDomain <StripeWithIntervals <BoxedExpression, IDecodeMetaData <Local, Parameter, Method, Field, Property, Type, Attribute, Assembly> >, LinearEqualitiesEnvironment <BoxedExpression> > Factory(StripeWithIntervals <BoxedExpression, IDecodeMetaData <Local, Parameter, Method, Field, Property, Type, Attribute, Assembly> > left, LinearEqualitiesEnvironment <BoxedExpression> right)
                {
                    StripeWithIntervalsForUnsafeCode l;

                    if (left is StripeWithIntervalsForUnsafeCode)
                    {
                        l = (StripeWithIntervalsForUnsafeCode)left;
                    }
                    else
                    {
                        l = new StripeWithIntervalsForUnsafeCode((IntervalsForUnsafeCode)left.Left, (StripeForUnsafeCode)left.Right, this.decoder, this.context, this.mdDecoder);
                    }

                    LinearEqualitiesForUnsafeCode r;

                    if (right is LinearEqualitiesForUnsafeCode)
                    {
                        r = (LinearEqualitiesForUnsafeCode)right;
                    }
                    else
                    {
                        r = new LinearEqualitiesForUnsafeCode(right, this.decoder, this.context, this.mdDecoder);
                    }
                    StripeIntervalsKarrForUnsafeCode result = new StripeIntervalsKarrForUnsafeCode(l, r, decoder, encoder, context, this.mdDecoder);

                    foreach (BoxedExpression exp in this.nullPointers)
                    {
                        result.nullPointers.Add(exp);
                    }
                    return(result);
                }
Exemplo n.º 17
0
 public bool AreSharingTheEquations(LinearEqualitiesEnvironment <Variable, Expression> left, LinearEqualitiesEnvironment <Variable, Expression> right)
 {
     return(sharinglist.Contains(left) && sharinglist.Contains(right));
 }