Exemplo n.º 1
0
    def verify_t_justification(self, line):
        """ Returns whether the line with the given number is a (first-order
            logic) tautology """
        assert line < len(self.lines)
        justification = self.lines[line].justification
        assert justification[0] == 'T'
        assert len(justification) == 1
        # Task 9.7

        formula = self.lines[line].formula.propositional_skeleton()[0]
        return is_propositional_tautology(formula)
Exemplo n.º 2
0
def prove_tautology(tautology: Formula) -> Proof:
    """Proves the given predicate-logic tautology.

    Parameters:
        tautology: predicate-logic tautology to prove.

    Returns:
        A valid proof of the given predicate-logic tautology from the axioms
        `PROPOSITIONAL_AXIOMATIC_SYSTEM_SCHEMAS` via only assumption lines
        and MP lines.
    """
    assert is_propositional_tautology(tautology.propositional_skeleton()[0])
Exemplo n.º 3
0
        def is_valid(self, assumptions: AbstractSet[Schema],
                     lines: Sequence[Proof.Line], line_number: int) -> bool:
            """Checks if the current line is validly justified in the context of
            the specified proof.

            Parameters:
                assumptions: assumptions/axioms of the proof.
                lines: lines of the proof.
                line_number: line number of the current line in the given lines.

            Returns:
                ``True`` if the formula justified by the current line is a
                (predicate-logic) tautology, ``False`` otherwise.
            """
            assert line_number < len(lines) and lines[line_number] is self
            propositional_formula = self.formula.propositional_skeleton()[0]
            return is_propositional_tautology(propositional_formula)
Exemplo n.º 4
0
def prove_tautology(tautology: Formula) -> Proof:
    """Proves the given predicate-logic tautology.

    Parameters:
        tautology: predicate-logic tautology to prove.

    Returns:
        A valid proof of the given predicate-logic tautology from the axioms
        `PROPOSITIONAL_AXIOMATIC_SYSTEM_SCHEMAS` via only assumption lines
        and MP lines.
    """
    assert is_propositional_tautology(tautology.propositional_skeleton()[0])
    # Task 9.12
    prop_tautology, translation_map = tautology.propositional_skeleton()
    prop_tautology_proof = prove_propositional_tautology(prop_tautology)
    return prove_from_skeleton_proof(tautology, prop_tautology_proof,
                                     translation_map)