# -*- 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)
from proofs import simpleProves import re import time import sys read = 'test.in' write = 'test.out' if len(sys.argv) > 1: read = sys.argv[1] if len(sys.argv) > 2: write = sys.argv[2] fr = open(read) fw = open(write, 'w') parser = Parser_() def assumption_pop(assumptions, alpha, formula, old_proof_negated, old_proof): proof = deduction(assumptions, alpha, old_proof) # Вывод Г |- alpha -> formula - (1) proof.extend(deduction(assumptions, Negation(alpha), old_proof_negated)) # Вывод Г |- !alpha -> formula - (2) proof.extend( [eval_by_mapping(line, {'A': alpha}) for line in simpleProves['|-A|!A']] ) # док-во alpha|!alpha - (3) mapping = {'A': alpha, 'B': formula, 'C': Negation(alpha)} proof.append(eval_by_mapping(parsed_axioms[7][0], mapping)) # сх. аксиом 8 - (4) proof.append(eval_by_mapping(parsed_axioms[7][0].right, mapping)) # M.P. последнее выражение в (1), (4) - (5) proof.append(eval_by_mapping(parsed_axioms[7][0].right.right, mapping)) # M.P. последнее выражение в (2), (5) - (6) proof.append(eval_by_mapping(parsed_axioms[7][0].right.right.right, mapping)) # M.P. последнее выражение в (3), (6) return proof
from axioms import axioms, scheme_axiom, axiom_induction, axiom_universal, axiom_existence, semi_cons from substitute import subst, find_mismatch, subst_pred from math_expressions import Variable, Zero, Increment from logic_expressions import Consequence, Universal, Existence, Predicate from util import ConnectedEntryException from copy import copy import sys import time read = 'test.in' write = 'test.out' if len(sys.argv) > 1: read = sys.argv[1] if len(sys.argv) > 2: write = sys.argv[2] parser = Parser_() read = open(read) write = open(write, 'w') uni_rule = open('uni_quantifier.proof') exist_rule = open('exist_quantifier.proof') def split_by_comma(assump): sum = 0 last_pos = 0 ans = [] for i, a in enumerate(assump): if a == '(': sum += 1
# -*- coding: utf-8 -*- from parser_ import Parser_ parser = Parser_() # !a,b|-(a->b) FT_T_CONS = [ "B->A->B", "B", "A->B" ] # a,!b|-!(a&b) TF_F_AND = [ "((A&B)->B)->((A&B)->!B)->!(A&B)", "(A&B)->B ", "(A&B->!B)->!(A&B)", "!B->A&B->!B", "!B", "A&B->!B", "!(A&B)" ] # !a,b|-!(a&b) FT_F_AND = [ "((A&B)->A)->((A&B)->!A)->!(A&B)", "(A&B)->A ", "(A&B->!A)->!(A&B)", "!A->A&B->!A", "!A", "A&B->!A", "!(A&B)" ] # a->b|-(!b->!a)