コード例 #1
0
def eresolution(clause) -> list:
    res = []
    for l in range(len(clause)):
        lit = clause.getLiteral(l)
        if lit.atom[0] == '=' and lit.isNegative():
            left = lit.atom[1]
            right = lit.atom[2]

            unifier = mgu(left, right)
            if unifier is not None:
                others = []

                for ll in range(len(clause)):
                    lit2 = clause.getLiteral(ll)
                    if ll != l:
                        if unifier is None:
                            others.append(lit2)
                        else:
                            others.append(lit2.instantiate(unifier))

                new_clause = Clause(others)

                new_clause.setDerivation(
                    flatDerivation("eresolution", [clause, clause]))

                res.append(new_clause)
    return res
コード例 #2
0
ファイル: eqaxioms.py プロジェクト: sourabhjain14/PyRes
def generateFunCompatAx(f, arity):
    """
    Generate axioms for the form
    X1!=Y1|...|Xn!=Yn|f(X1,...,Xn)=f(Y1,...Yn)    
    for f with the given arity.
    """
    res = generateEqPremise(arity)
    lterm = list([f])
    lterm.extend(generateVarList("X", arity))
    rterm = list([f])
    rterm.extend(generateVarList("Y", arity))
    concl = Literal(["=", lterm, rterm], False)
    res.append(concl)

    resclause = Clause(res)
    resclause.setDerivation(Derivation("eq_axiom"))
    return resclause
コード例 #3
0
ファイル: eqaxioms.py プロジェクト: sourabhjain14/PyRes
def generatePredCompatAx(p, arity):
    """
    Generate axioms for the form
    X1!=Y1|...|Xn!=Yn|~p(X1,...,Xn)|p(Y1,...Yn)    
    for f with the given arity.
    """
    res = generateEqPremise(arity)

    negp = list([p])
    negp.extend(generateVarList("X", arity))
    res.append(Literal(negp, True))

    posp = list([p])
    posp.extend(generateVarList("Y", arity))
    res.append(Literal(posp, False))

    resclause = Clause(res)
    resclause.setDerivation(Derivation("eq_axiom"))
    return resclause