public ArrayState Join(ArrayState a) { Contract.Requires(this.PluginsCount == a.PluginsCount); Contract.Ensures(Contract.Result <ArrayState>() != null); Contract.Ensures(Contract.Result <ArrayState>().PluginsCount == this.PluginsCount); ArrayState result; if (AbstractDomainsHelper.TryTrivialJoin(this, a, out result)) { return(result); } ArraySegmentationEnvironment <NonRelationalValueAbstraction <BoxedVariable <Variable>, BoxedExpression>, BoxedVariable <Variable>, BoxedExpression> array = null; INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> numerical = null; #if PARALLEL var arrayTask = Task.Run(() => array = this.Array.Join(a.Array)); var numericalTask = Task.Run(() => numerical = this.Numerical.Join(a.Numerical) as INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression>); #else array = this.Array.Join(a.Array); numerical = this.Numerical.Join(a.Numerical) as INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression>; #endif var plugins = new IAbstractDomainForEnvironments <BoxedVariable <Variable>, BoxedExpression> [this.PluginsCount]; for (var i = 0; i < this.PluginsCount; i++) { plugins[i] = this.PluginAbstractStateAt(i).Join(a.PluginAbstractStateAt(i)) as IAbstractDomainForEnvironments <BoxedVariable <Variable>, BoxedExpression>; } #if PARALLEL Task.WaitAll(arrayTask, numericalTask); #endif return(new ArrayState(array, numerical, plugins, this.mappings)); }
public NonRelationalValueAbstraction <Variable, Expression> Meet(NonRelationalValueAbstraction <Variable, Expression> other) { Contract.Requires(other != null); Contract.Ensures(Contract.Result <NonRelationalValueAbstraction <Variable, Expression> >() != null); NonRelationalValueAbstraction <Variable, Expression> result; if (AbstractDomainsHelper.TryTrivialMeet(this, other, out result)) { return(result); } var intv = disInterval.Meet(other.Interval); Contract.Assert(other.symbolicConditions != null); var symbolicConditions = this.symbolicConditions.Meet(other.symbolicConditions); Contract.Assert(other.weaklyRelationalDomains != null); Contract.Assume(weaklyRelationalDomains.Length == other.weaklyRelationalDomains.Length); var newWeaklyDomains = ParallelOperation(weaklyRelationalDomains, other.weaklyRelationalDomains, (x, y) => x.Meet(y)); return(new NonRelationalValueAbstraction <Variable, Expression>(intv, symbolicConditions, newWeaklyDomains)); }
public FlatAbstractDomain <bool> CheckIfEqual(Expression /*!*/ e1, Expression /*!*/ e2) { return(AbstractDomainsHelper.HelperForCheckLessEqualThan(this, e1, e2)); }
public IAbstractDomain /*!*/ Join(IAbstractDomain /*!*/ a) { IAbstractDomain tryResult; if (AbstractDomainsHelper.TryTrivialJoin(this, a, out tryResult)) { return(tryResult); } StringAbstraction right = a as StringAbstraction; //^ assert right != null; Debug.Assert(right != null, "I was expecting a " + this.GetType().ToString()); IAbstractDomain /*!*/ result; if (content == right.content) { switch (content) { #region All the cases case ContentType.Prefix: result = HelperForPrefixJoin(prefix, right.prefix); break; case ContentType.SetOfCharacters: result = HelperForSetOfCharactersJoin(characters, right.characters); break; case ContentType.String: result = HelperForStringJoin(fullstring, right.fullstring); break; case ContentType.Top: case ContentType.Bottom: default: // Impossible cases as they have already been checked before throw new AbstractInterpretationException("Impossible case?"); #endregion } } else { switch (content) { #region All the cases... case ContentType.Prefix: if (right.content == ContentType.SetOfCharacters) { result = this.Top; } else if (right.content == ContentType.String) { result = HelperForStringPrefixJoin(right.fullstring, prefix); } else { goto default; } break; case ContentType.SetOfCharacters: if (right.content == ContentType.Prefix) { result = this.Top; } else if (right.content == ContentType.String) { result = HelperForSetOfCharactersJoin(characters, AlphaToSetOfCharacters(right.fullstring)); } else { goto default; } break; case ContentType.String: if (right.content == ContentType.Prefix) { result = HelperForStringPrefixJoin(fullstring, right.prefix); } else if (right.content == ContentType.SetOfCharacters) { result = HelperForSetOfCharactersJoin(AlphaToSetOfCharacters(fullstring), right.characters); } else { goto default; } break; case ContentType.Top: case ContentType.Bottom: default: // Impossible cases as they have already been checked before throw new AbstractInterpretationException("Impossible case?"); #endregion } } return(result); }
public bool LessEqual(IAbstractDomain /*!*/ a) { bool tryResult; if (AbstractDomainsHelper.TryTrivialLessEqual(this, a, out tryResult)) { return(tryResult); } StringAbstraction right = a as StringAbstraction; //^ assert right != null; Debug.Assert(right != null, "I was expecting a " + this.GetType().ToString()); bool result; if (content == right.content) { switch (content) { #region All the cases case ContentType.Prefix: result = prefix.StartsWith(right.prefix); // it is larger if it is a substring break; case ContentType.SetOfCharacters: result = characters.IsSubset(right.characters); // it is larger if it is a subset break; case ContentType.String: result = fullstring.CompareTo(right.fullstring) == 0; // must be the same string break; case ContentType.Bottom: case ContentType.Top: default: throw new AbstractInterpretationException("Unexpected case : " + content); #endregion } } else { switch (content) { #region All the cases case ContentType.Prefix: if (right.content == ContentType.SetOfCharacters) { result = false; } else if (right.content == ContentType.String) { result = false; } else { goto default; } break; case ContentType.SetOfCharacters: if (right.content == ContentType.Prefix) { result = false; } else if (right.content == ContentType.String) { result = false; } else { goto default; } break; case ContentType.String: if (right.content == ContentType.Prefix) { result = fullstring.StartsWith(right.prefix); } else if (right.content == ContentType.SetOfCharacters) { Set <SimpleCharacterAbstraction> tmp = AlphaToSetOfCharacters(fullstring); result = tmp.IsSubset(right.characters); } else { goto default; } break; case ContentType.Bottom: case ContentType.Top: default: throw new AbstractInterpretationException("Unexpected case : " + content); #endregion } } return(result); }
/// <summary> /// The meet works only on the same contents /// </summary> public IAbstractDomain /*!*/ Meet(IAbstractDomain /*!*/ a) { IAbstractDomain tryResult; if (AbstractDomainsHelper.TryTrivialMeet(this, a, out tryResult)) { return(tryResult); } StringAbstraction right = a as StringAbstraction; //^ assert right != null; Debug.Assert(right != null, "I was expecting a " + this.GetType().ToString()); IAbstractDomain /*!*/ result; if (content == right.content) { switch (content) { #region All the cases ... case ContentType.Prefix: if (prefix.CompareTo(right.prefix) == 0) { result = this; } else { result = this.Bottom; } break; case ContentType.SetOfCharacters: var intersection = characters.Intersection(right.characters); if (intersection.IsEmpty) { result = this.Bottom; } else { result = new StringAbstraction(intersection); } break; case ContentType.String: if (fullstring.CompareTo(right.fullstring) == 0) { result = this; } else { result = this.Bottom; } break; case ContentType.Top: case ContentType.Bottom: default: // Impossible cases as they have already been checked before throw new AbstractInterpretationException("Impossible case?"); #endregion } } else { result = this.Bottom; } return(result); }