コード例 #1
0
ファイル: Proof.py プロジェクト: slibby05/pred
def existsI(ac, c, eax):
    ret = step(eax, "∃ I", [ac])
    if eax.type() != Node.EXISTS:
        raise ProofException("∃ I", eax, "premise is not in the form ∃  x. A", ret)
    if eax.expr.sub(eax.var, c) != ac.expr:
        raise ProofException("∃ I", ac.expr, "premise doesn't match conclusion", ret)
    return ret
コード例 #2
0
ファイル: Proof.py プロジェクト: slibby05/pred
def andEL(ab, a):
    ret = step(a,"∧ EL", [ab])
    if ab.expr.type() != Node.AND:
        raise ProofException("∧ EL", ab.expr, "premise is not in the form A ∧ B", ret)
    if ab.expr.lhs != a:
        raise ProofException("∧ EL", a, "conslusion doesn't match left hand side of premise", ret)
    return ret
コード例 #3
0
ファイル: Proof.py プロジェクト: slibby05/pred
def forallE(fax, c, ac):
    ret = step(ac, "∀ E", [fax])
    if fax.expr.type() != Node.FORALL:
        raise ProofException("∀ E", fax.expr, "premise is not in the form ∀  x. A", ret)
    if fax.expr.expr.sub(fax.expr.var, c) != ac:
        raise ProofException("∀ E", ac, "premise doesn't match conclusion", ret)
    return ret
コード例 #4
0
def notI(af, na):
    ret = step(na, "¬I", [af])
    if af.expr.type() != Node.ARROW or af.expr.rhs != false():
        raise ProofException("¬I", af.expr, "premise doesn't match A → F", ret)
    if Not(af.expr.lhs) != na:
        raise ProofException("¬I", na, "conclusion doesn't match premise", ret)
    return ret
コード例 #5
0
ファイル: Proof.py プロジェクト: slibby05/pred
def orIR(b, ab):
    ret = step(ab,"∨ IL", [b])
    if ab.type() != Node.OR:
        raise ProofException("∨ IR", ab, "conclusion is not in the form A ∧ B", ret)
    if ab.rhs != b.expr:
        raise ProofException("∨ IR", b.expr, "right hand side of conclusion doesn't match premise", ret)
    return ret
コード例 #6
0
ファイル: Proof.py プロジェクト: slibby05/pred
def orIL(a, ab):
    ret = step(ab,"∨ IL", [a])
    if ab.type() != Node.OR:
        raise ProofException("∨ IL", ab, "conclusion is not in the form A ∧ B", ret)
    if ab.lhs != a.expr:
        raise ProofException("∨ IL", a.expr, "left hand side of conclusion doesn't match premise", ret)
    return ret
コード例 #7
0
ファイル: Proof.py プロジェクト: slibby05/pred
def andER(ab, b):
    ret = step(b,"∧ ER", [ab])
    if ab.expr.type() != Node.AND:
        raise ProofException("∧ ER", ab.expr, "premise is not in the form A ∧ B", ret)
    if ab.expr.rhs != b:
        raise ProofException("∧ ER", b, "conslusion doesn't match right hand side of premise", ret)
    return ret
コード例 #8
0
ファイル: Proof.py プロジェクト: slibby05/pred
def arrowE(a, ab, b):
    ret = step(b, "→ E", [a,ab])
    if ab.expr.type() != Node.ARROW:
        raise ProofException("→ E", ab.expr, "premise doesn't match A → B", ret)
    if ab.expr.lhs != a.expr:
        raise ProofException("→ E", a.expr, "left hand side doens't match", ret)
    if ab.expr.rhs != b:
        raise ProofException("→ E", b.expr, "conclusion doens't match right hand side", ret)
    return ret
コード例 #9
0
ファイル: Proof.py プロジェクト: slibby05/pred
def andI(a, b, ab):
    ret = step(ab, "∧ I", [a,b])
    if ab.type() != Node.AND:
        raise ProofException("∧ I", ab, "conclusion is not in the form A ∧ B", ret)
    if ab.lhs != a.expr:
        raise ProofException("∧ I", a.expr, "left hand side doesn't match conclusion", ret)
    if ab.rhs != b.expr:
        raise ProofException("∧ I", a.expr, "right hand side doesn't match conclusion", ret)
    return ret
コード例 #10
0
def notE(a, na, f):
    ret = step(f, "¬E", [a, na])
    if na.expr.type() != Node.NOT:
        raise ProofException("¬E", na.expr, "premise doesn't match ¬A", ret)
    if na.expr.lhs != a.expr:
        raise ProofException("¬E", a.expr, "premises don't match", ret)
    if f != false():
        raise ProofException("¬E", f, "conclusion must be false", ret)
    return ret
コード例 #11
0
ファイル: Proof.py プロジェクト: slibby05/pred
def arrowI(a, b, ab):
    ret = step(ab, "→ I", [a,b])
    if ab.type() != Node.ARROW:
        raise ProofException("→ I", ab, "conclusion doesn't match A → B", ret)
    if ab.lhs != a.expr:
        raise ProofException("→ I", a.expr, "left hand side doens't match conclusion", ret)
    if ab.rhs != b.expr:
        raise ProofException("→ I", b.expr, "right hand side doens't match conclusion", ret)
    if assumptions.pop() != a.expr:
        raise ProofException("→ I", a.expr, "A was not the last assumption made", ret)
    return ret
コード例 #12
0
ファイル: Proof.py プロジェクト: slibby05/pred
def forallI(c, ac, fax):
    ret = step(fax, "∀ I", [c,ac])
    if fax.type() != Node.FORALL:
        raise ProofException("∀ I", fax, "conclusion is not in the form ∀  x. A", ret)
    if c.expr.type() != Node.VAR:
        raise ProofException("∀ I", c.expr, "assumption must be a variable", ret)
    if fax.expr.sub(fax.var, c.expr.name) != ac.expr:
        raise ProofException("∀ I", fax.expr, "premise doesn't match conclusion", ret)
    if assumptions.pop() != c.expr:
        raise ProofException("∀ I", c.expr, "ins't the most recent assumption", ret)
    return ret
コード例 #13
0
ファイル: Proof.py プロジェクト: slibby05/pred
def existsE(eax, c, ab, b):
    ret = step(b, "∃ E", [eax,ab])
    if eax.expr.type() != Node.EXISTS:
        raise ProofException("∃ I", eax.expr, "premise is not in the form ∃  x. A", ret)
    if ab.expr.type() != Node.ARROW:
        raise ProofException("∃ I", ab.expr, "premise is not in the form A[c] →  B", ret)
    if eax.expr.expr.sub(eax.expr.var, c) != ab.expr.lhs:
        raise ProofException("∃ I", eax.expr, "existential and concrete term don't match", ret)
    if ab.expr.rhs != b:
        raise ProofException("∃ I", ab.expr, "premise doesn't match conclusion", ret)
    return ret
コード例 #14
0
def LEM(a):
    ret = step(a, "LEM", [])
    if a.type() != Node.OR or \
       a.rhs.type() != Node.NOT or \
       a.lhs != a.rhs.lhs:
        raise ProofException("LEM", a, "conclusion doens't match A ∨ ¬A", ret)
    return ret
コード例 #15
0
def orE(ab, ac, bc, c):
    ret = step(c, "∨ E", [ab, ac, bc])
    if ab.expr.type() != Node.OR:
        raise ProofException("∨ E", ab.expr, "premise doesn't match A ∨ B",
                             ret)
    if ac.expr.type() != Node.ARROW:
        raise ProofException("∨ E", ac.expr, "premise doesn't match A → C",
                             ret)
    if bc.expr.type() != Node.ARROW:
        raise ProofException("∨ E", bc.expr, "premise doesn't match B → C",
                             ret)
    if ab.expr.lhs != ac.expr.lhs:
        raise ProofException(
            "∨ E", ab.expr,
            "A doesn't match: %s != %s" % (str(ab.expr.lhs), str(ac.expr.lhs)),
            ret)
    if ab.expr.rhs != bc.expr.lhs:
        raise ProofException(
            "∨ E", ab.expr,
            "B doesn't match: %s != %s" % (str(ab.expr.rhs), str(bc.expr.lhs)),
            ret)
    if ac.expr.rhs != bc.expr.rhs:
        raise ProofException(
            "∨ E", ac.expr,
            "C doesn't match: %s != %s" % (str(ac.expr.rhs), str(bc.expr.rhs)),
            ret)
    if ac.expr.rhs != c:
        raise ProofException("∨ E", c, "C doesn't match conclusion", ret)
    return ret
コード例 #16
0
def FE(f, a):
    ret = step(a, "⊥ E", [f])
    if f.expr != false():
        raise ProofException("⊥ E", f.expr, "premise must be flase", ret)
    return ret
コード例 #17
0
def TI(t):
    ret = step(t, "TI", [])
    if t != true():
        raise ProofException("TI", t, "conclusion must be true", ret)
    return ret
コード例 #18
0
def assumed(a):
    ret = step(a, "assumed", [])
    if a not in assumptions:
        raise ProofException("assumption", a,
                             "conclusion has not yet been assumed", ret)
    return ret