public void addLiteral(Literal literal) { if (isImmutable()) { throw new InvalidOperationException( "Clause is immutable, cannot be updated."); } int origSize = literals.Count; literals.Add(literal); if (literals.Count > origSize) { if (literal.isPositiveLiteral()) { positiveLiterals.Add(literal); } else { negativeLiterals.Add(literal); } } recalculateIdentity(); }
public override bool Equals(Object o) { if (this == o) { return(true); } if (o.GetType() != this.GetType()) { // This prevents ReducedLiterals // being treated as equivalent to // normal Literals. return(false); } if (!(o is Literal)) { return(false); } Literal l = (Literal)o; return(l.isPositiveLiteral() == isPositiveLiteral() && l.getAtomicSentence().getSymbolicName().Equals( atom.getSymbolicName()) && l.getAtomicSentence().getArgs().Equals(atom.getArgs())); }
private String getFactKey(Literal l) { StringBuilder key = new StringBuilder(); if (l.isPositiveLiteral()) { key.Append("+"); } else { key.Append("-"); } key.Append(l.getAtomicSentence().getSymbolicName()); return key.ToString(); }
// Note: see pg. 281 public bool isRenaming(Literal l, List<Literal> possibleMatches) { foreach (Literal q in possibleMatches) { if (l.isPositiveLiteral() != q.isPositiveLiteral()) { continue; } Dictionary<Variable, Term> subst = unifier.unify(l.getAtomicSentence(), q .getAtomicSentence()); if (null != subst) { int cntVarTerms = 0; foreach (Term t in subst.Values) { if (t is Variable) { cntVarTerms++; } } // If all the substitutions, even if none, map to Variables // then this is a renaming if (subst.Count == cntVarTerms) { return true; } } } return false; }