-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathop_sem_rules_new.txt
182 lines (93 loc) · 4.74 KB
/
op_sem_rules_new.txt
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
F(x,...,xn) = e
G(y,...,yn) = e
------------------------------------------------Rules-------------------------------------------------------
D, rho |- e => v
-------------------Lit
D, rho |- v => v
(x,v) in rho
------------------LocalVar
D, rho |- x => v
(x,e) in D D, [] |- e => v
-----------------------------------GlobalVar
D, rho |- x => v
D, rho |- e1 => v1 D, rho |- e2 => v2 op(v1,v2) = v
------------------------------------------------------------------Op
D, rho |- e1 op e2 => v
-----------------------------------------------Abs
D, rho |- \x -> e => (closure x -> e, rho)
D, rho |- e1 => (closure x -> e',rho') D, rho |- e2 => v2 D, rho'[x |-> v2] |- e' => v
---------------------------------------------------------------------------------------------------App
D, rho |- e1 e2 => v
D, rho |- e1 => v' D, rho[x |-> v'] |- e2 => v
------------------------------------------------------Let
D, rho |- let x = e1 in e2 => v
D, rho |- e1 => True D, rho |- e1 => v1
-----------------------------------------------IfTrue
D, rho |- if e1 then e2 else e3 => v1
D, rho |- e1 => False D, rho |- e2 => v2
-----------------------------------------------IfFalse
D, rho |- if e1 then e2 else e3 => v2
D, rho |- ei => vi f(e1,...,en) arity(f) = n
-------------------------------------------------------------------BuiltInApp
D, rho |- f e1 ... en => v (where f ranges over builtin vars)
--------------------ListNil
D, rho |- [] => []
D, rho |- ei => vi
------------------------------------------List
D, rho |- [e1, ..., en] |- [v1, ..., vn]
------------------------------------------------------Explanation Rules---------------------------------------
X { D, rho |- e => v | (e => v)* }
-----------------------XLit
X{ D, rho |- v => v | [] }
(x,v) in rho
----------------------------XVar
X{ D, rho |- x => v | [] }
-----------------------------------XGlobalVar
X{ D, rho |- f => v | }
?????? START
--------------------------------------------------- <---- probably need this rule
X{ D, rho |- e => (closure x -> e',rho') | [] }
flip sub x y = y - x
flip sub => \x y -> y - x
---------------------------------------------------
X{ D, rho |- e => (closure x -> e',rho') | e => ? maybe something in the premises }
(f,...) , (g,...) in D
----------------------------------------------------
X{ D, rho |- f g => v | f g => v}
?????? END
D, rho |- e1 => v' D, rho[x |-> v'] |- e2 => v
----------------------------------------------------------XLetVal
X{ D, rho |- let x = e1 in e2 => v | [v'/x]e2 => v}
D, rho |- e1 => v' v' = (closure y -> e') D, rho[x |-> v'] |- e2 => v
-----------------------------------------------------------------------------------XLetClosure
X{ D, rho |- let x = e1 in e2 => v | e2 => v }
X{ D, rho |- e1 => v' | e1' => v' } X{ D, rho[x |-> v'] |- e2 => v | e2' => v } x must not be free in e2'
--------------------------------------------------------------------------------------------------------------------XLetVal(XPrem)
X{ D, rho |- let x = e1 in e2 => v | e1' => v', e2' => v}
X{ D, rho |- e1 => v' | [] } v' = (closure y -> e') X{ D, rho[x |-> v'] |- e2 => v | e2' => v : XS}
-----------------------------------------------------------------------------------XLetClosure(XPrem)
X{ D, rho |- let x = e1 in e2 => v | e2' => v : XS }
P{ e1 => \x -> e' } e2 e3 => v [v/x]e' => w
-------------------------------------------------------APP-X-INTROS
X{ e1 (e2 e3) => w | e1 v => w, e2 e3 => v }
P{ e1 => \x -> e' } X{ e2 e3 => v | Delta} [v/x]e' => w
------------------------------------------------------------------APP-X-ACC
X{ e1 (e2 e3) => w | e1 v => w, e2 e3 => v, Delta }
-------------------------------------------------------APP-X-INTROS
X{ D, rho |- e1 (e2 e3) => w | }
----------------------------------------------------------------------
X{ {}, [] |- let x = 5 in let y = 3 in x + y => 10 | ? }
---------------------------------------------------------
X{ {}, [] |- let x = 5 in x + x => 10 | 5 + 5 => 10 }
x = 10
f = \x -> x + 1
D = {x |-> 10, f |-> \x -> x + 1}
------------------------------------------------Abs
D, [] |- \x -> x + 1 => (closure x -> x + 1, []) (f,\x -> x + 1) in D
------------------------------------------------------------------------------GlobalVar ----------------------------
D, [] |- f => (closure x -> x + 1, []) D, [] |- 5 => 5 D, [][x |-> 5] |- x + 1 => 6
-----------------------------------------------------------------------------------------------------App
D , [] |- f 5 => 6
(x,10) in D {x |-> 10}, [] |- 10 => 10
---------------------------------------------------
{x |-> 10}, [] |- x => 10