Reduce(IntervalEnvironment < Rational, Expression> left, WeakUpperBounds <Expression,  Rational> right)
    {
        ALog.BeginReduce("IntervalsWithSymbolicUpperBounds");

        foreach (Expression x in left.Keys)
        {
            foreach (Expression y in left.Keys)
            {
                if (x.Equals(y))
                {
                    continue;
                }

                FlatAbstractDomain <bool> b = left.CheckIfLessThan(x, y);

                if (b.IsTop || b.IsBottom)
                {
                    continue;
                }

                if (b.BoxedElement == true)
                {
                    ALog.Message("Adding " + ExpressionPrinter <Expression> .ToString(x, this.decoder) + " < " + ExpressionPrinter <Expression> .ToString(y, this.decoder)
                                 + " as " + left.BoundsFor(x) + " < " + left.BoundsFor(y));

                    right.TestTrueLessThan(x, y); // Add the constraint x < y
                }
            }
        }

        ALog.EndReduce();

        return(this.Factory(left, right));
    }
    public IAbstractDomainWithTransferFunctions <Expression> TestFalse(Expression guard)
    {
        IntervalEnvironment < Rational, Expression> resultLeft  = (IntervalEnvironment < Rational, Expression>)left.TestFalse(guard);
        WeakUpperBounds <Expression,  Rational>     resultRight = (WeakUpperBounds <Expression,  Rational>)right.TestFalse(guard);

        return((IAbstractDomainWithTransferFunctions <Expression>)Factory(resultLeft, resultRight));
    }
Beispiel #3
0
        private Pentagons <Variable, Expression> FactoryOfPentagons(
            IIntervalAbstraction <Variable, Expression> left, WeakUpperBounds <Variable, Expression> right)
        {
            Contract.Requires(left != null);
            Contract.Requires(right != null);

            Contract.Ensures(Contract.Result <Pentagons <Variable, Expression> >() != null);

            return(new Pentagons <Variable, Expression>(left, right, this.expManager));
        }
Beispiel #4
0
        /// <summary>
        /// Please note that the decoder MUST be already be set for the <code>left</code> and <code>right</code> abstract domains
        /// </summary>
        public Pentagons(
            IIntervalAbstraction <Variable, Expression> left,
            WeakUpperBounds <Variable, Expression> right,
            ExpressionManagerWithEncoder <Variable, Expression> expManager)
            : base(left, right)
        {
            Contract.Requires(left != null);
            Contract.Requires(right != null);
            Contract.Requires(expManager != null);

            this.expManager = expManager;
        }
Beispiel #5
0
        private void AssignInParallel
            (WeakUpperBoundsEqual <Variable, Expression> wubeq, WeakUpperBounds <Variable, Expression> wub,
            Dictionary <Variable, FList <Variable> > sourcesToTargets, INumericalAbstractDomain <Variable, Expression> oracleDomain)
        {
            Contract.Requires(wubeq != null);
            Contract.Requires(wub != null);

            // adding the domain-generated variables to the map as identity
            var oldToNewMap = new Dictionary <Variable, FList <Variable> >(sourcesToTargets);

            if (!wubeq.IsTop)
            {
                foreach (var e in wubeq.SlackVariables)
                {
                    oldToNewMap[e] = FList <Variable> .Cons(e, FList <Variable> .Empty);
                }
            }

            if (!wub.IsTop)
            {
                foreach (var e in wub.SlackVariables)
                {
                    oldToNewMap[e] = FList <Variable> .Cons(e, FList <Variable> .Empty);
                }
            }

            // when x has several targets including itself, the canonical element shouldn't be itself
            foreach (var sourceToTargets in sourcesToTargets)
            {
                var source  = sourceToTargets.Key;
                var targets = sourceToTargets.Value;

                Contract.Assume(targets != null);

                if (targets.Length() > 1 && targets.Head.Equals(source))
                {
                    var tail = targets.Tail;
                    Contract.Assert(tail != null);

                    var newTargets = FList <Variable> .Cons(tail.Head, FList <Variable> .Cons(source, tail.Tail));

                    oldToNewMap[source] = newTargets;
                }
            }

            AssignInParallelWUBSpecific(wub, oldToNewMap);
            AssignInParallelWUBEQSpecific(wubeq, sourcesToTargets, oldToNewMap);
        }
    /// <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 Pentagons < Rational, Expression>, "Wrong type of the domain for the widening...");

        Pentagons < Rational, Expression> asIntWSUB = (Pentagons < Rational, Expression>)prev;

        IntervalEnvironment < Rational, Expression> widenLeft  = (IntervalEnvironment < Rational, Expression>) this.Left.Widening(asIntWSUB.Left);
        WeakUpperBounds <Expression,  Rational>     widenRight = (WeakUpperBounds <Expression,  Rational>) this.Right.Widening(asIntWSUB.Right);

        Pentagons < Rational, Expression> result = (Pentagons < Rational, Expression>) this.Factory(widenLeft, widenRight);

        return(result);
    }
 Factory(IntervalEnvironment <Rational, Expression> left, WeakUpperBounds <Expression, Rational> right)
 {
     return(new ProductIntervalsWeakUpperBounds <Expression>(left, right, this.decoder));
 }
Beispiel #8
0
        private void AssignInParallelWUBSpecific(WeakUpperBounds <Variable, Expression> wub, Dictionary <Variable, FList <Variable> > oldToNewMap)
        {
            Contract.Requires(wub != null);
            Contract.Requires(oldToNewMap != null);

            var newMappings = new Dictionary <Variable, List <Variable> >(wub.Count);

            foreach (var oldLeft_pair in wub.Elements)
            {
                if (!oldToNewMap.ContainsKey(oldLeft_pair.Key))
                {
                    continue;
                }

                var target = oldToNewMap[oldLeft_pair.Key];
                Contract.Assume(target != null);

                var newLeft = target.Head; // our canonical element

                var oldBounds = oldLeft_pair.Value;
                if (!oldBounds.IsNormal())
                {
                    continue;
                }

                foreach (var oldRight in oldBounds.Values)
                {
                    FList <Variable> olds;

                    if (oldToNewMap.TryGetValue(oldRight, out olds))
                    {
                        Contract.Assume(olds != null);
                        // This case is so so common that we want to specialize it
                        if (olds.Length() == 1)
                        {
                            var newRight = olds.Head; // our canonical element
                            AddUpperBound(newLeft, newRight, newMappings);
                        }
                        else
                        {
                            foreach (var newRight in olds.GetEnumerable())
                            {
                                AddUpperBound(newLeft, newRight, newMappings);
                            }
                        }
                    }
                }

                // There are some more elements
                for (var list = oldToNewMap[oldLeft_pair.Key].Tail; list != null; list = list.Tail)
                {
                    List <Variable> targets;
                    if (newMappings.TryGetValue(newLeft, out targets))
                    {
                        Contract.Assume(targets != null);
                        foreach (var con in targets)
                        {
                            AddUpperBound(list.Head, con, newMappings);
                        }
                    }
                }
            }

            // Update
            var newConstraints = new Dictionary <Variable, SetOfConstraints <Variable> >(wub.Count);

            foreach (var pair in newMappings)
            {
                Contract.Assume(pair.Value != null);
                newConstraints.Add(pair.Key, new SetOfConstraints <Variable>(pair.Value));
            }

            wub.SetElements(newConstraints);
        }
 protected override ReducedCartesianAbstractDomain <IntervalEnvironment <Rational, Expression>, WeakUpperBounds <Expression, Rational> > Factory(IntervalEnvironment <Rational, Expression> left, WeakUpperBounds <Expression, Rational> right)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 public ProductIntervalsWeakUpperBounds(IntervalEnvironment <Rational, Expression> left, WeakUpperBounds <Expression, Rational> right)
     : base(left, right)
 {
 }
 protected override ReducedCartesianAbstractDomain <IntervalEnvironment <Rational, Expression>, WeakUpperBounds <Expression, Rational> > Factory(IntervalEnvironment <Rational, Expression> left, WeakUpperBounds <Expression, Rational> right)
 {
     return(new IntervalsWithSymbolicBoundsOfRational32 <Expression>(left, right, this.Decoder));
 }
 public IntervalsWithSymbolicBoundsOfRational32(IntervalEnvironment <Rational, Expression> left, WeakUpperBounds <Expression, Rational> right, IExpressionDecoder <Expression> decoder)
     : base(left, right, decoder)
 {
 }
Beispiel #13
0
 Reduce(IIntervalAbstraction <Variable, Expression> left, WeakUpperBounds <Variable, Expression> right)
 {
     return(this.Factory(left, right));
 }
 Reduce(IntervalEnvironment <Rational, Expression> left, WeakUpperBounds <Expression, Rational> right)
 {
     return(this.Factory(left, right));
 }
 /// <summary>
 /// Please note that the decoder MUST be already be set for the <code>left</code> and <code>right</code> abstract domains
 /// </summary>
 public ProductIntervalsWeakUpperBounds(IntervalEnvironment <Rational, Expression> /*!*/ left, WeakUpperBounds <Expression, Rational> /*!*/ right, IExpressionDecoder <Expression> decoder)
     : base(left, right)
 {
     this.decoder = decoder;
 }
 /// <summary>
 /// Please note that the decoder MUST be already be set for the <code>left</code> and <code>right</code> abstract domains
 /// </summary>
 protected Pentagons(IntervalEnvironment < Rational, Expression> /*!*/ left, WeakUpperBounds <Expression,  Rational> /*!*/ right, IExpressionDecoder <Expression> decoder)
     : base(left, right)
 {
     this.decoder = decoder;
 }
 Factory(IntervalEnvironment < Rational, Expression> left, WeakUpperBounds <Expression,  Rational> right);