Example #1
0
def naive_doublenot(branch: list[Sentence], sentenceID: SentenceID):
    f = branch[sentenceID]
    res = utils.reduce_prefix(
        utils.reduce_prefix(utils.empty_creator(f), 'not'), 'not')
    if res is None:
        raise RaisedUserMistake('cannot perform',
                                "This rule cannot be performed")
    return res
Example #2
0
def check_closure(
        branch: list[utils.Sentence], used: set[tuple[str]]
) -> tp.Union[None, tuple[utils.close.Close, str]]:
    """Sprawdza możliwość zamknięcia gałęzi, zwraca obiekty zamknięcia oraz komunikat do wyświetlenia"""
    for num1, statement_1 in enumerate(branch):
        for num2, statement_2 in enumerate(branch):
            if statement_1[0].startswith(
                    'not') and not statement_2[0].startswith('not'):
                negated, statement = statement_1, statement_2
            elif statement_2[0].startswith(
                    'not') and not statement_1[0].startswith('not'):
                negated, statement = statement_2, statement_1
            else:
                continue

            if utils.reduce_prefix(negated, 'not', PRECEDENCE) == statement:
                return utils.close.Contradiction(
                    sentenceID1=num1 + 1, sentenceID2=num2 +
                    1), "Sentences contradict. The branch was closed."

    return None
Example #3
0
def check_closure(
        branch: list[Sentence],
        used: History) -> tp.Union[None, tuple[utils.close.Close, str]]:
    """Sprawdza możliwość zamknięcia gałęzi, zwraca obiekty zamknięcia oraz komunikat do wyświetlenia"""
    for num1, statement_1 in enumerate(branch):
        for num2, statement_2 in enumerate(branch):
            if statement_1[0].startswith(
                    'not') and not statement_2[0].startswith('not'):
                negated, statement = statement_1, statement_2
            elif statement_2[0].startswith(
                    'not') and not statement_1[0].startswith('not'):
                negated, statement = statement_2, statement_1
            else:
                continue

            if utils.reduce_prefix(negated, 'not') == statement:
                return utils.close.Contradiction(
                    sentenceID1=num1 + 1, sentenceID2=num2 +
                    1), "Sentences contradict. The branch was closed."

    if all(i in used or i.isLiteral() for i in branch):
        return utils.close.Emptiness, "Nothing else to be done, branch was closed."
    return None
Example #4
0
def red_neg(x):
    return utils.reduce_prefix(x, 'not', PRECEDENCE)
Example #5
0
    'true imp':
    utils.Rule(
        symbolic="(A -> B) / ~A | B",
        docs=
        "Rozkładanie prawdziwej implikacji. Wymaga wskazania zdania w gałęzi.",
        func=lambda x: utils.select(
            utils.strip_around(x, 'imp', True, PRECEDENCE),
            ((True, ), (False, )), lambda y: utils.add_prefix(y, 'not', '~')),
        context=None,
        reusable=False),
    'double not':
    utils.Rule(
        symbolic="~~A / A",
        docs="Usuwanie podwójnej negacji. Wymaga wskazania zdania w gałęzi.",
        func=lambda x: utils.reduce_prefix(
            utils.reduce_prefix(utils.empty_creator(x), 'not', PRECEDENCE),
            'not', PRECEDENCE),
        context=None,
        reusable=False)
}

# __template__


@utils.cleaned
def prepare_for_proving(statement: utils.Sentence) -> utils.Sentence:
    """Przygotowuje zdanie do dowodzenia - czyszczenie, dodawanie elementów"""
    return statement


def check_closure(
Example #6
0
def strict_doublenot(sentence: Sentence):
    return utils.reduce_prefix(
        utils.reduce_prefix(utils.empty_creator(sentence), 'not'), 'not')
Example #7
0
def strict_doublenot(sentence: Sentence):
    return convert_to_signed(
        utils.reduce_prefix(
            utils.reduce_prefix(
                utils.empty_creator(convert_from_signed(sentence)), 'not'),
            'not'))