Class CnfUtils

java.lang.Object
org.aksw.jenax.arq.util.expr.CnfUtils

public class CnfUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<org.apache.jena.sparql.expr.ExprList>
    cnfToClauses(Iterable<org.apache.jena.sparql.expr.Expr> exprs)
    This method only words if the input expressions are in DNF, otherwise you will likely get junk back.
    static void
    collectAnd(org.apache.jena.sparql.expr.Expr expr, List<org.apache.jena.sparql.expr.ExprList> list)
     
    static void
    collectOr(org.apache.jena.sparql.expr.Expr expr, org.apache.jena.sparql.expr.ExprList list)
     
    static org.apache.jena.sparql.expr.Expr
    eval(org.apache.jena.sparql.expr.Expr expr)
     
    static Map.Entry<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node>
    extractEquality(Collection<? extends org.apache.jena.sparql.expr.Expr> clause)
     
    static Map<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node>
    getConstants(Iterable<? extends Collection<? extends org.apache.jena.sparql.expr.Expr>> cnf, boolean suppressConflicts)
    Extract from the CNF all mappings from a variable to constant, i.e.
    static <E extends org.apache.jena.sparql.expr.Expr, C extends Collection<? extends E>>
    Set<C>
     
    static org.apache.jena.sparql.expr.Expr
    handle(org.apache.jena.sparql.expr.ExprFunction expr)
     
    static boolean
    isSubsumedBy(Set<Set<org.apache.jena.sparql.expr.Expr>> cand, Set<Set<org.apache.jena.sparql.expr.Expr>> ref)
    Test if the candidate is subsumed by the reference.
    static <T extends org.apache.jena.sparql.expr.ExprFunction2>
    T
    normalize(T expr)
    Returns the input unchanged, unless it is (const op var) which becomes (var op const).
    static List<org.apache.jena.sparql.expr.ExprList>
    toClauses(org.apache.jena.sparql.expr.Expr expr)
     
    static List<org.apache.jena.sparql.expr.ExprList>
    toClauses(org.apache.jena.sparql.expr.ExprList exprs)
     
    static org.apache.jena.sparql.expr.Expr
    toExpr(Iterable<Set<org.apache.jena.sparql.expr.Expr>> cnf)
     
    static org.apache.jena.sparql.expr.ExprList
    toExprList(Iterable<Set<org.apache.jena.sparql.expr.Expr>> cnf)
     
    static Set<Set<org.apache.jena.sparql.expr.Expr>>
    toSetCnf(org.apache.jena.sparql.expr.Expr expr)
     
    static Set<Set<org.apache.jena.sparql.expr.Expr>>
    toSetCnf(org.apache.jena.sparql.expr.ExprList exprs)
    Return a sub cnf that where each element of a clause contains all variables

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CnfUtils

      public CnfUtils()
  • Method Details

    • normalize

      public static <T extends org.apache.jena.sparql.expr.ExprFunction2> T normalize(T expr)
      Returns the input unchanged, unless it is (const op var) which becomes (var op const). Use for (in-)equalities.
    • extractEquality

      public static Map.Entry<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> extractEquality(Collection<? extends org.apache.jena.sparql.expr.Expr> clause)
    • getEqualityClauses

      public static <E extends org.apache.jena.sparql.expr.Expr, C extends Collection<? extends E>> Set<C> getEqualityClauses(Iterable<C> cnf)
    • getConstants

      public static Map<org.apache.jena.sparql.core.Var,org.apache.jena.graph.Node> getConstants(Iterable<? extends Collection<? extends org.apache.jena.sparql.expr.Expr>> cnf, boolean suppressConflicts)
      Extract from the CNF all mappings from a variable to constant, i.e. if there is ?x = foo, then the result will contain the mapping ?x -> foo. If there are conflicting mappings, return an arbitrary one. The idea is, that using these mappings, one can evaluate remaining expressions. In the case of conflicts, these will simply evaluate to FALSE.
      Parameters:
      cnf -
      Returns:
    • toExpr

      public static org.apache.jena.sparql.expr.Expr toExpr(Iterable<Set<org.apache.jena.sparql.expr.Expr>> cnf)
    • toExprList

      public static org.apache.jena.sparql.expr.ExprList toExprList(Iterable<Set<org.apache.jena.sparql.expr.Expr>> cnf)
    • isSubsumedBy

      public static boolean isSubsumedBy(Set<Set<org.apache.jena.sparql.expr.Expr>> cand, Set<Set<org.apache.jena.sparql.expr.Expr>> ref)
      Test if the candidate is subsumed by the reference. This means that the candidate must contain at least all constraints of ref
      Parameters:
      cand -
      ref -
      Returns:
    • toSetCnf

      public static Set<Set<org.apache.jena.sparql.expr.Expr>> toSetCnf(org.apache.jena.sparql.expr.ExprList exprs)
      Return a sub cnf that where each element of a clause contains all variables
      Parameters:
      clauses -
      requiredVars -
      Returns:
    • toSetCnf

      public static Set<Set<org.apache.jena.sparql.expr.Expr>> toSetCnf(org.apache.jena.sparql.expr.Expr expr)
    • toClauses

      public static List<org.apache.jena.sparql.expr.ExprList> toClauses(org.apache.jena.sparql.expr.Expr expr)
    • toClauses

      public static List<org.apache.jena.sparql.expr.ExprList> toClauses(org.apache.jena.sparql.expr.ExprList exprs)
    • cnfToClauses

      public static List<org.apache.jena.sparql.expr.ExprList> cnfToClauses(Iterable<org.apache.jena.sparql.expr.Expr> exprs)
      This method only words if the input expressions are in DNF, otherwise you will likely get junk back.
      Parameters:
      exprs -
      Returns:
    • collectAnd

      public static void collectAnd(org.apache.jena.sparql.expr.Expr expr, List<org.apache.jena.sparql.expr.ExprList> list)
    • collectOr

      public static void collectOr(org.apache.jena.sparql.expr.Expr expr, org.apache.jena.sparql.expr.ExprList list)
    • eval

      public static org.apache.jena.sparql.expr.Expr eval(org.apache.jena.sparql.expr.Expr expr)
    • handle

      public static org.apache.jena.sparql.expr.Expr handle(org.apache.jena.sparql.expr.ExprFunction expr)