// The next few routines convert a set of axioms from a StatementSource // into a data structure of use for the algorithm, with Sequents and things. private static Hashtable RulesToCases(StatementSource rules) { Hashtable cases = new Hashtable(); MemoryStore rules_store = new MemoryStore(rules); foreach (Statement p in rules_store) { if (p.Meta == Statement.DefaultMeta) { if (p.Predicate == entLOGIMPLIES && p.Object is Entity) { MemoryStore body = new MemoryStore(); MemoryStore head = new MemoryStore(); rules_store.Select(new Statement(null, null, null, (Entity)p.Subject), new RemoveMeta(body)); rules_store.Select(new Statement(null, null, null, (Entity)p.Object), new RemoveMeta(head)); // Any variables in the head not bound in the body represent existentially closed bnodes. // (Euler's OWL test case does this. Wish they had used bnodes instead of vars...) ResSet bodyvars = new ResSet(); foreach (Statement b in body) { if (b.Subject is Variable) bodyvars.Add(b.Subject); if (b.Predicate is Variable) bodyvars.Add(b.Predicate); if (b.Object is Variable) bodyvars.Add(b.Object); } foreach (Entity v in head.GetEntities()) { if (v is Variable && !bodyvars.Contains(v)) head.Replace(v, new BNode(((Variable)v).LocalName)); } // Replace (...) lists in the body that are tied to the subjects // of user predicates with callArgs objects. Hashtable callArgs = new Hashtable(); CollectCallArgs(body, callArgs); // Rules can't have more than one statement in their // consequent. The best we can do is break up // the consequent into multiple rules. (Since all head // variables are bound in body, it's equivalent...?) foreach (Statement h in head) AddSequent(cases, new Sequent(h, body.ToArray(), callArgs)); } else { AddSequent(cases, new Sequent(p, new Statement[0], null)); } } } return cases; }