-
Notifications
You must be signed in to change notification settings - Fork 1
/
G3ipCalculus.hs
131 lines (108 loc) · 2.75 KB
/
G3ipCalculus.hs
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
module G3ipCalculus where
--General Approach:
--given: a goal
--step 1: check whether its an axion, if so we are done
--step 2: Use one of 6 inference rules to replace the goal by simpler subgoals. Recurse.
import List (elem, delete)
import Haskelle
data G3ipCalculus = G3ipCalculus
instance LogicalCalculus G3ipCalculus where
rules G3ipCalculus = tacticsG3ip
tacticsG3ip = (\sequent ->
axiomRule sequent ++
leftConjRule sequent ++
rightConjRule sequent ++
leftDisjRule sequent ++
rightDisjRule sequent ++
leftImplRule sequent ++
rightImplRule sequent
)
--rules in G3ip Calculus
{-
Axiom -------- (p atomic)
p,A |- p
-}
axiomRule :: Sequent -> [([Sequent], Rule)]
axiomRule (Sequent assumptions [p])
| (isAtomic p) && (List.elem p assumptions) = [([], Axiom)]
| otherwise = []
{-
p,q,A |- r
LeftConj ----------
p&q,A |- r
-}
leftConjRule :: Sequent -> [([Sequent], Rule)]
leftConjRule (Sequent assumptions [r]) =
zip
[
[Sequent (p:q: (List.delete pandq assumptions)) [r]]
| pandq@(Conjunction p q) <- assumptions
]
(repeat LeftConj)
{-
A |- p A |- q
RightConj ----------------
A |- p&q
-}
rightConjRule :: Sequent -> [([Sequent], Rule)]
rightConjRule seq =
case seq of
(Sequent assumptions [Conjunction p q]) ->
[( [Sequent assumptions [p], Sequent assumptions [q]], RightConj)]
_ -> []
{-
p,A |- r q,A |- r
LeftDisj --------------------
p|q,A |- r
-}
leftDisjRule :: Sequent -> [([Sequent], Rule)]
leftDisjRule (Sequent assumptions [r]) =
zip
[
[Sequent (p : (List.delete porq assumptions)) [r], Sequent (q : (List.delete porq assumptions)) [r]]
| porq@(Disjunction p q) <- assumptions
]
(repeat LeftDisj)
{-
A |- p A |- q
RightDisj -------- --------
A |- p|q A |- p|q
-}
rightDisjRule :: Sequent -> [([Sequent], Rule)]
rightDisjRule seq =
case seq of
(Sequent assumptions [Disjunction p q]) ->
zip
[
[Sequent assumptions [p]], [Sequent assumptions [q]]
]
(repeat RightDisj)
_ -> []
{-
p->q,A |- p q,A |- r
LeftImpl -----------------------
p->q,A |- r
-}
leftImplRule :: Sequent -> [([Sequent], Rule)]
leftImplRule (Sequent assumptions [r]) =
zip
[
[Sequent assumptions [p], Sequent (q : (List.delete pimpq assumptions)) [r]]
| pimpq@(Implication p q) <- assumptions
]
(repeat LeftImpl)
{-
p,A |- q
RightImpl --------
A |- p->q
-}
rightImplRule :: Sequent -> [([Sequent], Rule)]
rightImplRule seq =
case seq of
(Sequent assumptions [Implication p q]) ->
[( [Sequent (p:assumptions) [q]], RightImpl )]
_ -> []
--helpers
isAtomic :: Proposition -> Bool
isAtomic (Atomic _) = True
isAtomic _ = False