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
27
3823.12.2017
49
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
1117directly inside quotes and splices cannot appear directly inside
1218splices. In other words, the universe is restricted to two phases
1319only.
@@ -95,12 +101,12 @@ Typing judgments are of the form `E1 * E2 |- t: T` where `E1, E2` are environme
95101 E1 * E2 |- t1 t2: T
96102
97103
98- E1 ’ E2 |- t: T
104+ E2 ’ E1 |- t: T
99105 -----------------
100106 E1 ~ E2 |- ’t: ’T
101107
102108
103- E1 ~ E2 |- t: ’T
109+ E2 ~ E1 |- t: ’T
104110 ----------------
105111 E1 ’ E2 |- ~t: T
106112
@@ -109,7 +115,7 @@ Typing judgments are of the form `E1 * E2 |- t: T` where `E1, E2` are environme
109115
110116## Soundness
111117
112- The meta-theory typically requires mutual inductions over two judgements .
118+ The meta-theory typically requires mutual inductions over two judgments .
113119
114120### Progress Theorem
115121
@@ -122,7 +128,7 @@ To prove (1):
122128
123129 - the cases for variables, lambdas and applications are as in STL.
124130 - 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:
126132 - ` t2 = u ` , hence ` ’t2 ` is a value,
127133 - ` t2 ==> t3 ` , hence ` ’t2 --> ’t3 ` .
128134 - The case ` t = ~t2 ` is not typable.
@@ -150,7 +156,7 @@ To prove (2):
150156### Substitution Lemma
151157
152158 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 ` .
154160
155161The proofs are by induction on typing derivations for ` t ` , analogous
156162to the proof for STL (with (2) a bit simpler than (1) since we do not
0 commit comments