-
Notifications
You must be signed in to change notification settings - Fork 1
/
notation_gen_spec.py
161 lines (148 loc) · 4.47 KB
/
notation_gen_spec.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
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
from notation_lib import generate_notation
mask_opts = [
{
'mask_not1': '⟨ E1 , E2 ⟩ ',
'mask_not2': '⟨ E1 , E2 ⟩ ',
'mask_open': '(fupd E1 E2)',
'mask_close': '(fupd E2 E1)',
'mask_levels': 'E1, E2 at level 9, ',
'mask_arg': 'E1',
},
{
'mask_not1': '⟨ E1 ⟩ ',
'mask_not2': '⟨ E1 ⟩ ',
'mask_open': '(fupd E1 E1)',
'mask_close': '(fupd E1 E1)',
'mask_levels': 'E1 at level 9, ',
'mask_arg': 'E1',
},
{
'mask_not1': '',
'mask_not2': '',
'mask_open': '(fupd ⊤ ⊤)',
'mask_close': '(fupd ⊤ ⊤)',
'mask_levels': '',
'mask_arg': '(⊤ : coPset)',
},
]
binder_pre_opts = [
{
'binders_pre1': 'x1 .. xn , ',
'binders_pre2': 'x1 .. xn , ',
'binders_tele': '(TeleS (λ x1, .. (TeleS (λ xn, TeleO)) .. ))',
'binders_levels': 'x1 closed binder, xn closed binder, ',
'binders_pre_lmask': '(λ x1, .. (λ xn, ',
'binders_pre_rmask': ') .. )',
},
{
'binders_pre1': '',
'binders_pre2': '',
'binders_tele': 'TeleO',
'binders_levels': '',
'binders_pre_lmask': '',
'binders_pre_rmask': '',
},
]
key_hyp_opts = [
{
'key_hyp1': '[ pre ] ',
'key_hyp2': '[ pre ] ',
'key_hyp_arg': 'pre',
'key_hyp_levels': 'pre, ',
},
{
'key_hyp1': '',
'key_hyp2': '',
'key_hyp_arg': 'empty_hyp_first',
'key_hyp_levels': '',
},
]
later_opts = [
{
'laters_not1': '[ ▷^ n ] ',
'laters_not2': '[ ▷^ n ] ',
'laters_arg': 'n',
'laters_levels': 'n at level 9, ',
},
{
'laters_not1': '',
'laters_not2': '',
'laters_arg': '1',
'laters_levels': '',
},
]
binder_post_opts = [
{
'binders_post1': 'y1 .. yn , ',
'binders_post_tele': '(TeleS (λ y1, .. (TeleS (λ yn, TeleO)) .. ))',
'binders_post2': 'y1 .. yn , ',
'binders_post_lmask': '(λ y1, .. (λ yn, ',
'binders_post_rmask': ') .. )',
'binders_post_levels': 'y1 closed binder, yn closed binder, '
},
{
'binders_post1': '',
'binders_post_tele': 'TeleO',
'binders_post2': '',
'binders_post_lmask': '',
'binders_post_rmask': '',
'binders_post_levels': ''
}
]
header = '''From iris.bi Require Export bi telescopes.
From iris.proofmode Require Import tactics notation reduction.
From iris.program_logic Require Import weakestpre lifting.
From diaframe Require Import util_classes tele_utils solve_defs.
From diaframe.symb_exec Require Import defs.
From gpfsl.diaframe Require Import vprop_weakestpre.
Import bi.
'''
if __name__ == '__main__':
print(header)
generate_notation('''Notation "'SPEC' {key_hyp1}{mask_not1}{binders_pre1}{{{{ Ps }} }} e {{{{ {laters_not1}{binders_post1}'RET' e' ; Qs }} }}" :=
(ReductionStep'
wp_red_cond
{key_hyp_arg}%I
{laters_arg}
{mask_open}
{mask_close}
{binders_tele}
{binders_post_tele}
{binders_pre_lmask}Ps%I{binders_pre_rmask}
{binders_pre_lmask}{binders_post_lmask}Qs%I{binders_post_rmask}{binders_pre_rmask}
e%E
{binders_pre_lmask}{binders_post_lmask}e'{binders_post_rmask}{binders_pre_rmask}
[tele_arg3 {mask_arg}] )
(at level 20, {laters_levels}{mask_levels}{binders_levels}{binders_post_levels}e, Ps, {key_hyp_levels}e', Qs at level 200, format
"'[hv' SPEC {key_hyp2}{mask_not2}{binders_pre2}'/ ' {{{{ Ps }} }} '/ ' e '/ ' {{{{ '[hv' {laters_not2}{binders_post2}'RET' e' ; '/ ' Qs ']' }} }} ']'"
).
''', [
mask_opts,
binder_pre_opts,
key_hyp_opts,
later_opts,
binder_post_opts,
])
generate_notation('''Notation "'SPEC2' {key_hyp1}{mask_not1}{binders_pre1}{{{{ Ps }} }} e {{{{ {laters_not1}'RET' [ e' ] ; Qs }} }}" :=
(ReductionStep'
wp_red_cond
{key_hyp_arg}%I
{laters_arg}
{mask_open}
{mask_close}
{binders_tele}
_
{binders_pre_lmask}Ps%I{binders_pre_rmask}
Qs%I
e
e'
[tele_arg3 {mask_arg}] )
(at level 20, {laters_levels}{mask_levels}{binders_levels}e, Ps, {key_hyp_levels}e', Qs at level 200, format
"'[hv' SPEC2 {key_hyp2}{mask_not2}{binders_pre2}'/ ' {{{{ Ps }} }} '/ ' e '/ ' {{{{ {laters_not2}'RET' [ e' ] ; '/ ' Qs }} }} ']'", only printing
).
''', [
mask_opts,
[binder_pre_opts[0]],
key_hyp_opts,
later_opts,
])