1
- # Simple Symmetric Metaprogramming
1
+ ---
2
+ layout : doc-page
3
+ title : " The Meta-theory of Symmetric Meta-programming"
4
+ ---
5
+
6
+ # The Meta-theory of Symmetric Meta-programming
2
7
3
8
23.12.2017
4
9
5
- This note presents a simplified variant of symmetric metaprogramming
6
- which only treats dialgogues between two stages. We could have quotes
7
- containing splices (which can contain quotes, which can contain
8
- splices, and so on). Or we could start with a splice with embedded
9
- quotes. The important restriction is that (1) a term contains toplevel
10
- quotes or toplevel splices, but not both and (2) quotes cannot appear
10
+ This note presents a simplified variant of symmetric meta-programming
11
+ and sketches its soundness proof. The variant treats only dialogues
12
+ between two stages. A program can have quotes which can contain
13
+ splices (which can contain quotes, which can contain splices, and so
14
+ on). Or the program could start with a splice with embedded
15
+ quotes. The essential restriction is that (1) a term can contain top-level
16
+ quotes or top-level splices, but not both, and (2) quotes cannot appear
11
17
directly inside quotes and splices cannot appear directly inside
12
18
splices. In other words, the universe is restricted to two phases
13
19
only.
@@ -95,12 +101,12 @@ Typing judgments are of the form `E1 * E2 |- t: T` where `E1, E2` are environme
95
101
E1 * E2 |- t1 t2: T
96
102
97
103
98
- E1 ’ E2 |- t: T
104
+ E2 ’ E1 |- t: T
99
105
-----------------
100
106
E1 ~ E2 |- ’t: ’T
101
107
102
108
103
- E1 ~ E2 |- t: ’T
109
+ E2 ~ E1 |- t: ’T
104
110
----------------
105
111
E1 ’ E2 |- ~t: T
106
112
@@ -109,7 +115,7 @@ Typing judgments are of the form `E1 * E2 |- t: T` where `E1, E2` are environme
109
115
110
116
## Soundness
111
117
112
- The meta-theory typically requires mutual inductions over two judgements .
118
+ The meta-theory typically requires mutual inductions over two judgments .
113
119
114
120
### Progress Theorem
115
121
@@ -122,7 +128,7 @@ To prove (1):
122
128
123
129
- the cases for variables, lambdas and applications are as in STL.
124
130
- If ` t = ’t2 ` , then by inversion we have ` ’ E1 |- t2: T2 ` for some type ` T2 ` .
125
- By second I.H., we have one of:
131
+ By the second I.H., we have one of:
126
132
- ` t2 = u ` , hence ` ’t2 ` is a value,
127
133
- ` t2 ==> t3 ` , hence ` ’t2 --> ’t3 ` .
128
134
- The case ` t = ~t2 ` is not typable.
@@ -150,7 +156,7 @@ To prove (2):
150
156
### Substitution Lemma
151
157
152
158
1 . If ` E1 ~ E2 |- s: S ` and ` E1 ~ E2, x: S |- t: T ` then ` E1 ~ E2 |- [x := s]t: T ` .
153
- 2 . If ` E1 ’ E2 |- s: S ` and ` E2, x: S ’ E1 |- t: T ` then ` E2 ’ E1 |- [x := s]t: T ` .
159
+ 2 . If ` E1 ~ E2 |- s: S ` and ` E2, x: S ’ E1 |- t: T ` then ` E2 ’ E1 |- [x := s]t: T ` .
154
160
155
161
The proofs are by induction on typing derivations for ` t ` , analogous
156
162
to the proof for STL (with (2) a bit simpler than (1) since we do not
0 commit comments