Пример #1
0
        public SimpleArrayAbstraction <Variable, Expression> Meet(SimpleArrayAbstraction <Variable, Expression> right)
        {
            SimpleArrayAbstraction <Variable, Expression> trivialResult;

            if (AbstractDomainsHelper.TryTrivialMeet(this, right, out trivialResult))
            {
                return(trivialResult);
            }

            var result = new SimpleArrayAbstraction <Variable, Expression>(this.encoder, this.decoder);

            foreach (var e in this.content)
            {
                IAbstractDomainForEnvironments <Variable, Expression> rightProperty;
                var leftProperty = e.Value;

                if (right.content.TryGetValue(e.Key, out rightProperty))
                {
                    result.content.Add(e.Key, (IAbstractDomainForEnvironments <Variable, Expression>)leftProperty.Meet(rightProperty));
                }
                else
                {
                    throw new AbstractInterpretationException();
                }
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Order ...
        /// </summary>
        ///
        public bool LessEqual(SimpleArrayAbstraction <Variable, Expression> right)
        {
            bool result;

            if (AbstractDomainsHelper.TryTrivialLessEqual(this, right, out result))
            {
                return(result);
            }

            foreach (var e in this.content)
            {
                IAbstractDomainForEnvironments <Variable, Expression> rightProperty;
                var leftProperty = e.Value;

                if (right.content.TryGetValue(e.Key, out rightProperty))
                {
                    if (!leftProperty.LessEqual(rightProperty))
                    {
                        return(false);
                    }
                }
                else
                {
                    throw new AbstractInterpretationException();
                }
            }

            return(true);
        }
Пример #3
0
        public IArrayAbstraction <Variable, Expression> ArrayUnknown(Set <int> dimensions, ExpressionType type)
        {
            var result = new SimpleArrayAbstraction <Variable, Expression>(this.encoder, this.decoder);
            IAbstractDomainForEnvironments <Variable, Expression> topProperty;

            switch (type)
            {
            case ExpressionType.Int8:
            case ExpressionType.Int16:
            case ExpressionType.Int32:
            case ExpressionType.Int64:
            case ExpressionType.UInt8:
            case ExpressionType.UInt16:
            case ExpressionType.UInt32:
                topProperty = new OctagonEnvironment <Variable, Expression>(this.decoder, this.encoder, OctagonEnvironment <Variable, Expression> .OctagonPrecision.FullPrecision);
                break;

            default:
                topProperty = new FakeAbstractDomain <Variable, Expression>(this.decoder);
                break;
            }

            foreach (var dim in dimensions)
            {
                result.content.Add(dim, (IAbstractDomainForEnvironments <Variable, Expression>)topProperty.Clone());
            }

            return((IArrayAbstraction <Variable, Expression>)result);
        }
Пример #4
0
        public IArrayAbstraction <Variable, Expression> Transform(Dictionary <int, Set <int> > transformationMap)
        {
            var result = new SimpleArrayAbstraction <Variable, Expression>(this.encoder, this.decoder);

            foreach (var e in transformationMap)
            {
                var dimensionsEnumerator = e.Value.GetEnumerator();

                if (dimensionsEnumerator.MoveNext())
                {
                    IAbstractDomainForEnvironments <Variable, Expression> aProperty;

                    if (this.content.TryGetValue(dimensionsEnumerator.Current, out aProperty))
                    {
                        var property = (IAbstractDomainForEnvironments <Variable, Expression>)aProperty.Clone();

                        while (dimensionsEnumerator.MoveNext())
                        {
                            if (this.content.TryGetValue(dimensionsEnumerator.Current, out aProperty))
                            {
                                property = (IAbstractDomainForEnvironments <Variable, Expression>)property.Join(aProperty);
                            }
                            else
                            {
                                throw new AbstractInterpretationException("incorrect transformation map");
                            }
                        }

                        result.content.Add(e.Key, property);
                    }
                    else
                    {
                        throw new AbstractInterpretationException("incorrect transformation map");
                    }
                }
                else
                {
                    throw new AbstractInterpretationException("incorrect transformation map");
                }
            }

            return(result);
        }
Пример #5
0
 public SimpleArrayAbstraction(SimpleArrayAbstraction <Variable, Expression> source)
 {
     this.encoder = source.encoder;
     this.decoder = source.decoder;
     this.content = new Dictionary <int, IAbstractDomainForEnvironments <Variable, Expression> >(source.content);
 }