예제 #1
0
 /// <summary>
 ///  A default implementation of the <see cref="CheckVariableDisequality"/> given
 ///  the appropriate expression factories by calling CheckPredicate.
 /// </summary>
 protected Answer DefaultCheckVariableDisequality(IPropExprFactory /*!*/ propExprFactory, IValueExprFactory /*!*/ valExprFactory, Element /*!*/ e, IVariable /*!*/ var1, IVariable /*!*/ var2)
 {
     Contract.Requires(propExprFactory != null);
     Contract.Requires(valExprFactory != null);
     Contract.Requires(e != null);
     Contract.Requires(var1 != null);
     Contract.Requires(var2 != null);
     return(this.CheckPredicate(e, propExprFactory.Not(valExprFactory.Eq(var1, var2))));
 }
예제 #2
0
        private Element /*!*/ ApplyCombineNameMap(Element /*!*/ e, ICombineNameMap /*!*/ eToResult)
        {
            Contract.Requires(eToResult != null);
            Contract.Requires(e != null);
            Contract.Ensures(Contract.Result <Element>() != null);
            Element /*!*/ result = e;

            foreach (G.KeyValuePair <IVariable /*!*/, ISet /*<IVariable!>*//*!*/> entry in eToResult.GetSourceToResult())
            {
                IVariable /*!*/ sourceName = entry.Key;
                Contract.Assert(sourceName != null);
                ISet /*<IVariable!*//*!*/ resultNames = entry.Value;
                Contract.Assert(resultNames != null);
                // Renaming s to r is okay if
                //       (1) s is not used in the result
                //   and (2) s has not been renamed already
                bool            renameOkay     = !resultNames.Contains(sourceName);
                IVariable /*!*/ representative = sourceName;
                Contract.Assert(representative != null);

                foreach (IVariable /*!*/ rname in resultNames)
                {
                    Contract.Assert(rname != null);
                    // skip if sourceName and rname are the same
                    if (object.Equals(sourceName, rname))
                    {
                        continue;
                    }

                    if (renameOkay)
                    {
                        result         = this.Rename(result, sourceName, rname);
                        representative = rname; // representative now rname
                        renameOkay     = false; // no longer okay to rename
                    }
                    else
                    {
                        result = this.Constrain(result, valueExprFactory.Eq(representative, rname));
                    }
                }
            }

            return(result);
        }
예제 #3
0
 /// <summary>
 ///  A default implementation of the <see cref="CheckVariableDisequality"/> given
 ///  the appropriate expression factories by calling CheckPredicate.
 /// </summary>
 protected Answer DefaultCheckVariableDisequality(IPropExprFactory/*!*/ propExprFactory, IValueExprFactory/*!*/ valExprFactory, Element/*!*/ e, IVariable/*!*/ var1, IVariable/*!*/ var2) {
   Contract.Requires(propExprFactory != null);
   Contract.Requires(valExprFactory != null);
   Contract.Requires(e != null);
   Contract.Requires(var1 != null);
   Contract.Requires(var2 != null);
   return this.CheckPredicate(e, propExprFactory.Not(valExprFactory.Eq(var1, var2)));
 }