public FlatAbstractDomain <int> /*!*/ CompareTo(IStringAbstraction /*!*/ param) { FlatAbstractDomain <int> result; FlatAbstractDomain <int> top = (FlatAbstractDomain <int>) new FlatAbstractDomain <int>(1).Top; if (this.IsTop || param.IsTop) { return(top); } else { StringAbstraction who = param as StringAbstraction; //^ assert who != null; Debug.Assert(who != null); if (content == ContentType.String && who.content == ContentType.String) { result = new FlatAbstractDomain <int>(fullstring.CompareTo(who.fullstring)); } else { result = top; } } return(result); }
public FlatAbstractDomain <bool> /*!*/ StartsWith(IStringAbstraction /*!*/ param) { FlatAbstractDomain <bool> result; FlatAbstractDomain <bool> top = new FlatAbstractDomain <bool>(false).Top; if (this.IsTop || param.IsTop) { result = top; } else { StringAbstraction what = param as StringAbstraction; //^ assert what != null; Debug.Assert(what != null); if (content == ContentType.String && what.content == ContentType.String) { result = new FlatAbstractDomain <bool>(fullstring.StartsWith(what.fullstring)); } else if (content == ContentType.Prefix && what.content == ContentType.String) { result = new FlatAbstractDomain <bool>(prefix.StartsWith(what.fullstring)); } else { result = top; } } return(result); }
public FlatAbstractDomain <bool> /*!*/ Contains(IStringAbstraction /*!*/ param) { FlatAbstractDomain <bool> result; FlatAbstractDomain <bool> top = new FlatAbstractDomain <bool>(false).Top; if (this.IsTop || param.IsTop) { result = top; } else { StringAbstraction what = param as StringAbstraction; //^ assert what != null; Debug.Assert(what != null); if (content == what.content) { #region All the cases... switch (content) { case ContentType.Prefix: result = top; break; case ContentType.SetOfCharacters: result = top; break; case ContentType.String: result = new FlatAbstractDomain <bool>(fullstring.Contains(what.fullstring)); break; default: throw new AbstractInterpretationException("Impossible case?"); } #endregion } else { switch (content) { #region All the cases case ContentType.Prefix: if (what.content == ContentType.String && prefix.Contains(what.fullstring)) { result = new FlatAbstractDomain <bool>(true); } else { result = top; } break; case ContentType.SetOfCharacters: case ContentType.String: result = top; break; default: throw new AbstractInterpretationException("Impossible case?"); #endregion } } } return(result); }
public IStringAbstraction Insert(int where, IStringAbstraction /*!*/ param) //^ requires where >= 0; { Debug.Assert(where >= 0); IStringAbstraction result; if (this.IsTop || param.IsTop) { result = CachedTop; } else { StringAbstraction what = param as StringAbstraction; //^ assert what != null; Debug.Assert(what != null); if (content == what.content) { switch (content) { #region All the cases case ContentType.Prefix: if (where < prefix.Length) { string tmp = prefix.Substring(0, where); result = new StringAbstraction(tmp + prefix, true); } else { result = CachedTop; } break; case ContentType.SetOfCharacters: result = new StringAbstraction(characters.Union(what.characters)); break; case ContentType.String: result = new StringAbstraction(fullstring.Insert(where, what.fullstring)); break; default: throw new AbstractInterpretationException("Impossible case?"); #endregion } } else { switch (content) { #region All the cases case ContentType.Prefix: if (what.content == ContentType.SetOfCharacters) { result = CachedTop; } else if (what.content == ContentType.String) { if (where < fullstring.Length) { result = new StringAbstraction(prefix.Insert(where, what.fullstring)); } else { result = this; } } else { goto default; } break; case ContentType.SetOfCharacters: if (what.content == ContentType.Prefix) { result = CachedTop; } else if (what.content == ContentType.String) { result = new StringAbstraction(characters.Union(AlphaToSetOfCharacters(what.fullstring))); } else { goto default; } break; case ContentType.String: if (what.content == ContentType.SetOfCharacters) { result = new StringAbstraction(AlphaToSetOfCharacters(fullstring).Union(what.characters)); } else if (what.content == ContentType.Prefix) { if (where < fullstring.Length) { string tmp = fullstring.Substring(0, where); result = new StringAbstraction(tmp + what.prefix, true); } else { result = this; } } else { goto default; } break; default: throw new AbstractInterpretationException("Impossible case?"); #endregion } } } return(result); }
/// <summary> /// Do the concatenation /// </summary> /// <param name="param"></param> /// <returns></returns> public IStringAbstraction ConcatWith(IStringAbstraction /*!*/ param) { IStringAbstraction result; if (this.IsTop || param.IsTop) { result = CachedTop; } else { StringAbstraction what = param as StringAbstraction; //^ assert what != null; Debug.Assert(what != null); if (content == what.content) { switch (content) { #region All the cases case ContentType.Prefix: result = this; // prefix1 \cdot prefix2 = prefix1 break; case ContentType.SetOfCharacters: result = new StringAbstraction(characters.Union(what.characters)); // { bla1 bla12 } \code {bla2 bla22} = {bla1, bla12, bla2, bla22} break; case ContentType.String: // Simple concatenation result = new StringAbstraction(fullstring + what.fullstring); break; default: throw new AbstractInterpretationException("Impossible case?"); #endregion } } else { switch (content) { #region All the cases case ContentType.Prefix: if (what.content == ContentType.SetOfCharacters) { result = this; // prefix \cdot {bla bla} = prefix } else if (what.content == ContentType.String) { // prefix \cdot string = prefix result = this; } else { goto default; } break; case ContentType.SetOfCharacters: if (what.content == ContentType.Prefix) { result = (StringAbstraction)this.Top; } else if (what.content == ContentType.String) { result = new StringAbstraction(characters.Union(AlphaToSetOfCharacters(what.fullstring))); } else { goto default; } break; case ContentType.String: if (what.content == ContentType.SetOfCharacters) { result = new StringAbstraction(AlphaToSetOfCharacters(fullstring).Union(what.characters)); } else if (what.content == ContentType.Prefix) { result = new StringAbstraction(fullstring + what.prefix, true); } else { goto default; } break; default: throw new AbstractInterpretationException("Impossible case?"); #endregion } } } return(result); }
protected override T To <T>(Variable d, IStringAbstraction c, IFactory <T> factory) { return(factory.Constant(true)); }
protected override string ToLogicalFormula(Variable d, IStringAbstraction c) { return(null); }