-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintroductionRules.py
91 lines (73 loc) · 3.61 KB
/
introductionRules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import formulaTypes as ft
import state
from abc import ABC, abstractmethod
from copy import deepcopy
class NegationIntroduction(ft.Rule):
@abstractmethod
def __init__(self):
pass
def use_rule(current_state: state.SingleState)->tuple[state.SingleState]:
assert isinstance(current_state, state.SingleState), "Given argument is not a proof state!"
assert isinstance(current_state.formulaToBeProved, ft.Negation), "Formula not a negation!"
notNegatedFormula = current_state.formulaToBeProved.formula
new_assumptions = deepcopy(current_state.assumptions)
new_assumptions.append(notNegatedFormula)
new_state = state.SingleState(
ft.FalseF(),
new_assumptions,
current_state.depth + 1)
return new_state,
class ConjunctionIntroduction(ft.Rule):
@abstractmethod
def __init__(self):
pass
def use_rule(current_state: state.SingleState)->tuple[state.SingleState]:
assert isinstance(current_state, state.SingleState), "Given argument is not a proof state!"
assert isinstance(current_state.formulaToBeProved, ft.Conjunction), "Formula not a conjunction!"
new_state1 = state.SingleState(
current_state.formulaToBeProved.formula1,
current_state.assumptions,
current_state.depth + 1)
new_state2 = state.SingleState(
current_state.formulaToBeProved.formula2,
current_state.assumptions,
current_state.depth + 1)
return (new_state1, new_state2)
class DisjunctionIntroduction(ft.Rule, ABC):
@abstractmethod
def use_rule(current_state: state.SingleState) -> state.SingleState:
pass
class DisjunctionIntroduction1(DisjunctionIntroduction):
def use_rule(current_state: state.SingleState) -> state.SingleState:
assert isinstance(current_state, state.SingleState), "Given argument is not a proof state!"
assert isinstance(current_state.formulaToBeProved, ft.Disjunction), "Formula not a disjunction!"
new_state1 = state.SingleState(
current_state.formulaToBeProved.formula1,
current_state.assumptions,
current_state.depth + 1)
return new_state1,
class DisjunctionIntroduction2(DisjunctionIntroduction):
def use_rule(current_state: state.SingleState) -> state.SingleState:
assert isinstance(current_state, state.SingleState), "Given argument is not a proof state!"
assert isinstance(current_state.formulaToBeProved, ft.Disjunction), "Formula not a disjunction!"
new_state2 = state.SingleState(
current_state.formulaToBeProved.formula2,
current_state.assumptions,
current_state.depth + 1)
return new_state2,
class ImplicationIntroduction(ft.Rule):
@abstractmethod
def __init__(self):
pass
def use_rule(current_state: state.SingleState)->tuple[state.SingleState]:
assert isinstance(current_state, state.SingleState), "Given argument is not a proof state!"
assert isinstance(current_state.formulaToBeProved, ft.Implication), "Formula not an implication!"
alpha = current_state.formulaToBeProved.formula1
beta = current_state.formulaToBeProved.formula2
new_assumptions = deepcopy(current_state.assumptions)
new_assumptions.append(alpha)
new_state = state.SingleState(
beta,
new_assumptions,
current_state.depth + 1)
return new_state,