Ejemplo n.º 1
0
		public override PathCond Or(PathCond other) {
			if (other is CachedAtom && conds.Contains(((CachedAtom)other).Negate())) {
				// Reduce Or(OR(...,e,...), NOT(e)) and Or(OR(...,NOT(e),...), e) to TRUE
				return TRUE;
			}
			else if (other is Disj) {
				HashList<PathCond> result = new HashList<PathCond>();
				result.AddAll(conds);
				foreach (PathCond cond in ((Disj)other).conds) {
					if (cond is CachedAtom && conds.Contains((cond as CachedAtom).Negate())) {
						// Reduce Or(OR(...,e,...),OR(...,NOT(e),...)) to TRUE
						// and    Or(OR(...,NOT(e),...),OR(...,e,...)) to TRUE
						return TRUE;
					}
					result.Add(cond);
				}
				return Disj.Make(result.ToArray());
			}
			else if (other is Conj) {
				if (((Conj)other).conds.Contains(this)) {
					// Reduce (pi | (p1 & ... & pn)) to pi
					return this;
				}
				else {
					if (((Conj)other).conds.Any(cond => conds.Contains(cond))) {
						return this;
					}
				}
				return Disj.Make(AddItem(this.conds, other));
			}
			else {
				return Disj.Make(AddItem(this.conds, other));
			}
		}
Ejemplo n.º 2
0
        protected static PathCond[] AddItem(IEnumerable <PathCond> set, PathCond item)
        {
            HashList <PathCond> result = new HashList <PathCond>();

            result.AddAll(set);
            result.Add(item);
            return(result.ToArray());
        }
Ejemplo n.º 3
0
 public override PathCond Or(PathCond other)
 {
     if (other is CachedAtom && conds.Contains(((CachedAtom)other).Negate()))
     {
         // Reduce Or(OR(...,e,...), NOT(e)) and Or(OR(...,NOT(e),...), e) to TRUE
         return(TRUE);
     }
     else if (other is Disj)
     {
         HashList <PathCond> result = new HashList <PathCond>();
         result.AddAll(conds);
         foreach (PathCond cond in ((Disj)other).conds)
         {
             if (cond is CachedAtom && conds.Contains((cond as CachedAtom).Negate()))
             {
                 // Reduce Or(OR(...,e,...),OR(...,NOT(e),...)) to TRUE
                 // and    Or(OR(...,NOT(e),...),OR(...,e,...)) to TRUE
                 return(TRUE);
             }
             result.Add(cond);
         }
         return(Disj.Make(result.ToArray()));
     }
     else if (other is Conj)
     {
         if (((Conj)other).conds.Contains(this))
         {
             // Reduce (pi | (p1 & ... & pn)) to pi
             return(this);
         }
         else
         {
             if (((Conj)other).conds.Any(cond => conds.Contains(cond)))
             {
                 return(this);
             }
         }
         return(Disj.Make(AddItem(this.conds, other)));
     }
     else
     {
         return(Disj.Make(AddItem(this.conds, other)));
     }
 }