# -*- coding: utf-8 -*- from parser_ import Parser_ parser = Parser_() axioms = ["a=b->a'=b'", "a=b->a=c->b=c", "a'=b'->a=b", "!a'=0", "a+b'=(a+b)'", "a+0=a", "a*0=a", "a*b'=a*b+a"] axioms = [parser.parse(axiom) for axiom in axioms] scheme_axiom = [ "A->B->A", # 1 "(A->B)->(A->B->C)->(A->C)", # 2 "A->B->A&B", # 3 "A&B->A", # 4 "A&B->B", # 5 "A->A|B", # 6 "B->A|B", # 7 "(A->B)->(C->B)->(A|C->B)", # 8 "(A->B)->(A->!B)->!A", # 9 "!!A->A", ] # 10 semi_cons = ["A->A->A", "(A->A->A)->(A->(A->A)->A)->(A->A)", "(A->(A->A)->A)->(A->A)", "A->(A->A)->A", "A->A"] semi_cons = [parser.parse(line) for line in semi_cons] axiom_induction = "F(0)&@x(F(x)->F(x'))->F(x)" axiom_universal = "@xF(x)->F(o)" axiom_existence = "F(o)->?xF(x)" axiom_induction = parser.parse(axiom_induction) axiom_universal = parser.parse(axiom_universal) axiom_existence = parser.parse(axiom_existence)
tmp.append( assumption_pop([Negation(t) if i & (1 << (ind + 1)) == 0 else t for ind, t in enumerate(popped)], alpha, formula, masked_proofs[i], masked_proofs[i + 1]) ) masked_proofs = tmp variables = popped # debug_test() # return return masked_proofs[0] t = time.time() parser.set_formula('') line = fr.read() ex = parser.parse(line) q = disproof_test(ex) if q != {}: fw.write('Высказывание ложно при ') for key in q: fw.write('{0}={1} '.format(str(key), 'И' if q[key] else 'Л')) else: l = proove(ex) fw.write('|-{}\n'.format(str(ex))) for line in l: fw.write(str(line) + '\n') print('prooving time: {} sec.'.format(str(time.time() - t)))
if len(ans) > 0 and assump[last_pos] == ',': ans.append(assump[last_pos:]) if len(ans) > 1: for i in range(1, len(ans)): ans[i] = ans[i][1:] return ans parser = Parser_() proof = [] deduction = [] annot = [] cache = {} assumptions, formula = read.readline().split('|-') formula = parser.parse(formula) assumptions = [parser.parse(assumption) for assumption in split_by_comma(assumptions)] uni_rule = [parser.parse(line) for line in uni_rule] exist_rule = [parser.parse(line) for line in exist_rule] if assumptions != []: alpha = assumptions.pop() else: alpha = None def axiom_deduct(epression): cons = subst_pred(scheme_axiom[0], {'A': expression, 'B': alpha}) deduction.append(cons) deduction.append(expression) deduction.append(cons.args[1])
"((!(A|!A)->(!A->!(A|!A)))->((!(A|!A)->((!A->!(A|!A))->!!A))->(!(A|!A)->!!A)))", "((!(A|!A)->((!A->!(A|!A))->!!A))->(!(A|!A)->!!A))", "(!(A|!A)->!!A)", "(!(A|!A)->!A)->(!(A|!A)->!!A)->!!(A|!A)", "(!(A|!A)->!!A)->!!(A|!A)", "!!(A|!A)", "!!(A|!A)->(A|!A)", "A|!A" ] simpleProves = { '!A,!B|-!(A|B)': FF_F_OR, '!A,B|-(A|B)': FT_T_OR, 'A,!B|-(A|B)': TF_T_OR, 'A,B|-(A|B)': TT_T_OR, '!A,!B|-!(A&B)': FF_F_AND, '!A,B|-!(A&B)': FT_F_AND, 'A,!B|-!(A&B)': TF_F_AND, 'A,B|-(A&B)': TT_T_AND, '!A,!B|-(A->B)': FF_T_CONS, '!A,B|-(A->B)': FT_T_CONS, 'A,!B|-!(A->B)': TF_F_CONS, 'A,B|-(A->B)': TT_T_CONS, '|-A|!A': T_F_OR, '!A|-!A': F_F_NOT, 'A|-!!A': T_F_NOT } for key in simpleProves: simpleProves[key] = [parser.parse(line) for line in simpleProves[key]]