private SymbolValuePair findUnitClause(List <Sentence> clauseList, Model model, List <Symbol> symbols) { for (int i = 0; i < clauseList.Count; i++) { Sentence clause = (Sentence)clauseList[i]; if ((clause is Symbol) && (!(model.getAssignedSymbols().Contains(clause)))) { // System.Console.WriteLine("found unit clause - assigning"); return(new SymbolValuePair(new Symbol(((Symbol)clause) .getValue()), true)); } if (clause is UnarySentence) { UnarySentence sentence = (UnarySentence)clause; Sentence negated = sentence.getNegated(); if ((negated is Symbol) && (!(model.getAssignedSymbols().Contains(negated)))) { // System.Console.WriteLine("found unit clause type 2 - // assigning"); return(new SymbolValuePair(new Symbol(((Symbol)negated) .getValue()), false)); } } } return(new SymbolValuePair());// failed to find any unit clause; }
private Sentence TransformImpliedSentence(BinarySentence bs) { Sentence first = new UnarySentence((Sentence)bs.First.Accept( this, null)); return(new BinarySentence("OR", first, (Sentence)bs.Second .Accept(this, null))); }
private Sentence transformImpliedSentence(BinarySentence bs) { Sentence first = new UnarySentence((Sentence)bs.getFirst().accept( this, null)); return(new BinarySentence("OR", first, (Sentence)bs.getSecond() .accept(this, null))); }
public object VisitNotSentence(UnarySentence fs, ISet <Sentence> arg) { object negatedValue = fs.Negated.Accept(this, null); if (negatedValue != null) { return((bool)(!((bool)negatedValue))); } return(null); }
public override object VisitNotSentence(UnarySentence ns, ISet <Sentence> arg) { if (ns.Negated is Symbol) { // do nothing .do NOT add a negated Symbol } else { //arg.UnionWith((ISet<Symbol>)ns.Negated.Accept(this, arg)); arg.UnionWith((ISet <Sentence>)ns.Negated.Accept(this, arg)); } return(arg); }
public Object visitNotSentence(UnarySentence fs, Object arg) { Object negatedValue = fs.getNegated().accept(this, null); if (negatedValue != null) { return(!((bool)negatedValue)); } else { return(null); } }
public override object VisitNotSentence(UnarySentence ns, ISet <Sentence> arg) { ISet <Symbol> s = (ISet <Symbol>)arg; if (ns.Negated is Symbol) { s.Add((Symbol)ns.Negated); } else { s.UnionWith((ISet <Symbol>)ns.Negated.Accept(this, arg)); } return(s); }
public override Object visitNotSentence(UnarySentence ns, Object arg) { List <Symbol> s = (List <Symbol>)arg; if (ns.getNegated() is Symbol) { s.Add((Symbol)ns.getNegated()); } else { s = SetOps .union(s, (List <Symbol>)ns.getNegated().accept(this, arg)); } return(s); }
public override Object visitNotSentence(UnarySentence ns, Object arg) { List <Symbol> s = (List <Symbol>)arg; if (ns.getNegated() is Symbol) { // do nothing .do NOT add a negated Symbol } else { s = SetOps .union(s, (List <Symbol>)ns.getNegated().accept(this, arg)); } return(s); }
public void testComplexSentenceParse() { BinarySentence sen = (BinarySentence)parser .parse("((OR NORVIG AIMA LISP) AND TRUE)"); Assert.AreEqual(typeof(BinarySentence), sen.GetType()); sen = (BinarySentence)parser .parse("((OR NORVIG AIMA LISP) AND (((LISP => COOL))))"); Assert.AreEqual(typeof(BinarySentence), sen.GetType()); Assert.AreEqual( " ( ( OR NORVIG AIMA LISP ) AND ( LISP => COOL ) )", sen .ToString()); String s = "((NOT (P AND Q )) AND ((NOT (R AND S))))"; sen = (BinarySentence)parser.parse(s); Assert.AreEqual( " ( ( NOT ( P AND Q ) ) AND ( NOT ( R AND S ) ) )", sen .ToString()); s = "((P AND Q) OR (S AND T))"; sen = (BinarySentence)parser.parse(s); Assert .AreEqual(" ( ( P AND Q ) OR ( S AND T ) )", sen .ToString()); Assert.AreEqual("OR", sen.getOperator()); s = "(NOT ((P AND Q) => (S AND T)))"; UnarySentence nsen = (UnarySentence)parser.parse(s); // AreEqual("=>",sen.getOperator()); s = "(NOT (P <=> (S AND T)))"; nsen = (UnarySentence)parser.parse(s); Assert.AreEqual(" ( NOT ( P <=> ( S AND T ) ) ) ", nsen .ToString()); s = "(P <=> (S AND T))"; sen = (BinarySentence)parser.parse(s); s = "(P => Q)"; sen = (BinarySentence)parser.parse(s); s = "((P AND Q) => R)"; sen = (BinarySentence)parser.parse(s); }
private Sentence transformNotSentence(UnarySentence us) { if (us.getNegated() is UnarySentence) { return((Sentence)((UnarySentence)us.getNegated()).getNegated() .accept(this, null)); } else if (us.getNegated() is BinarySentence) { BinarySentence bs = (BinarySentence)us.getNegated(); if (bs.isAndSentence()) { Sentence first = new UnarySentence((Sentence)bs.getFirst() .accept(this, null)); Sentence second = new UnarySentence((Sentence)bs.getSecond() .accept(this, null)); return(new BinarySentence("OR", first, second)); } else if (bs.isOrSentence()) { Sentence first = new UnarySentence((Sentence)bs.getFirst() .accept(this, null)); Sentence second = new UnarySentence((Sentence)bs.getSecond() .accept(this, null)); return(new BinarySentence("AND", first, second)); } else { return((Sentence)base.visitNotSentence(us, null)); } } else { return((Sentence)base.visitNotSentence(us, null)); } }
private Sentence TransformNotSentence(UnarySentence us) { if (us.Negated is UnarySentence) { return((Sentence)((UnarySentence)us.Negated).Negated .Accept(this, null)); } else if (us.Negated is BinarySentence) { BinarySentence bs = (BinarySentence)us.Negated; if (bs.IsAndSentence()) { Sentence first = new UnarySentence((Sentence)bs.First .Accept(this, null)); Sentence second = new UnarySentence((Sentence)bs.Second .Accept(this, null)); return(new BinarySentence("OR", first, second)); } else if (bs.IsOrSentence()) { Sentence first = new UnarySentence((Sentence)bs.First .Accept(this, null)); Sentence second = new UnarySentence((Sentence)bs.Second .Accept(this, null)); return(new BinarySentence("AND", first, second)); } else { return((Sentence)base.VisitNotSentence(us, null)); } } else { return((Sentence)base.VisitNotSentence(us, null)); } }
public virtual Object visitNotSentence(UnarySentence fs, Object arg) { return(new UnarySentence((Sentence)fs.getNegated().accept(this, arg))); }
public virtual Object visitNotSentence(UnarySentence ns, Object arg) { List <Sentence> s = (List <Sentence>)arg; return(SetOps.union(s, (List <Sentence>)ns.getNegated().accept(this, arg))); }
public override object VisitNotSentence(UnarySentence us, ISet <Sentence> arg) { return(this.TransformNotSentence(us)); }
public Object visitNotSentence(UnarySentence fs, Object arg) { return(fs.getNegated().accept(this, null)); }
public object VisitNotSentence(UnarySentence fs, ISet <Sentence> arg) { return(fs.Negated.Accept(this, null)); }
public virtual Object visitNotSentence(UnarySentence ns, Object arg) { Hashtable s = (Hashtable)arg; return(new SetOps().union(s, (Hashtable)ns.getNegated().accept(this, arg))); }
public virtual object VisitNotSentence(UnarySentence ns, ISet <Sentence> arg) { return(new HashSet <Sentence>(arg.Union((ISet <Sentence>)ns.Negated.Accept(this, arg)))); }
public void testNotSentenceParse() { UnarySentence sen = (UnarySentence)parser.parse("NOT AIMA"); Assert.AreEqual(typeof(UnarySentence), sen.GetType()); }
public virtual object VisitNotSentence(UnarySentence fs, ISet <Sentence> arg) { return(new UnarySentence((Sentence)fs.Negated.Accept(this, arg))); }
public override Object visitNotSentence(UnarySentence us, Object arg) { return(transformNotSentence(us)); }