Skip to content

Commit 704e36e

Browse files
committed
Replace export_rewrites with simp where possible
There are a few things worth pointing out: 1. I've slightly restructured some new_specification calls. In particular, I factored out the proof into a local theorem, and more importantly, I factored out the string name into a variable (see clFFIScript.sml). The motivation for the latter was to ultimately ban `export_rewrites["`, but it turns out that there are still good uses for this (for example when adding definitions/theorems from other theories to the simpset). Arguably, it gets rid of some duplication, which is why I haven't reverted it. 2. I've adjusted various tutorial files to use simp tags, since presumably we want newcomers to be exposed to that. simple_bstScript.sml still mentions what it desugars to at some point, so it should be fine. 3. I deleted astPropsScript.sml -- there was a TODO that said to do it, and it also had commented out export_rewrites.
1 parent 26022cf commit 704e36e

File tree

64 files changed

+346
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+346
-524
lines changed

basis/DoubleFFIScript.sml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ Proof
123123
qexists_tac `\f. some c. encode c = f` \\ fs [encode_11]
124124
QED
125125

126+
val decode_encode_name = "decode_encode";
126127
val decode_encode = new_specification(
127-
"decode_encode",
128+
decode_encode_name,
128129
["decode"],
129130
encode_decode_exists);
130-
val _ = export_rewrites ["decode_encode"];
131+
val _ = export_rewrites [decode_encode_name];
131132

132133
Definition double_ffi_part_def:
133134
double_ffi_part = (encode,decode,
@@ -140,4 +141,3 @@ Definition double_ffi_part_def:
140141
("double_ln",ffi_ln);
141142
("double_floor",ffi_floor)])
142143
End
143-

basis/basis_ffiScript.sml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,14 @@ Theorem extract_stdo_extract_fs
287287
\\ rw[] \\ fs[]
288288
stdo_def
289289
290-
Definition is_write_def:
290+
Definition is_write_def[simp]:
291291
(is_write fd (IO_event name _ ((fd',st)::_)) ⇔ name="write" ∧ fd' = fd ∧ st = 0w) ∧
292292
(is_write _ _ ⇔ F)
293293
End
294-
val _ = export_rewrites["is_write_def"];
295294
296-
Definition extract_write_def:
295+
Definition extract_write_def[simp]:
297296
extract_write (IO_event _ _ (_::(_,nw)::bytes)) = TAKE (w2n nw) (MAP FST bytes)
298297
End
299-
val _ = export_rewrites["extract_write_def"];
300298
301299
Definition extract_writes_def:
302300
extract_writes fd io_events =

basis/clFFIScript.sml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,18 @@ Proof
8181
\\ drule encode_list_11 \\ fs [mlstringTheory.explode_11]
8282
QED
8383

84-
val decode_encode = new_specification("decode_encode",["decode"],
85-
prove(``?decode. !cls. decode (encode cls) = SOME cls``,
86-
qexists_tac `\f. some c. encode c = f` \\ fs [encode_11]));
87-
val _ = export_rewrites ["decode_encode"];
84+
Theorem encode_decode_exists[local]:
85+
?decode. !cls. decode (encode cls) = SOME cls
86+
Proof
87+
qexists_tac `\f. some c. encode c = f` \\ fs [encode_11]
88+
QED
89+
90+
val decode_encode_name = "decode_encode";
91+
val decode_encode = new_specification(
92+
decode_encode_name,
93+
["decode"],
94+
encode_decode_exists);
95+
val _ = export_rewrites [decode_encode_name];
8896

8997
Definition cl_ffi_part_def:
9098
cl_ffi_part = (encode,decode,

basis/fsFFIScript.sml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,18 @@ Proof
383383
\\ fs [IO_fs_component_equality]
384384
QED
385385

386-
val decode_encode = new_specification("decode_encode",["decode"],
387-
prove(``?decode. !cls. decode (encode cls) = SOME cls``,
388-
qexists_tac `\f. some c. encode c = f` \\ fs [encode_11]));
389-
val _ = export_rewrites ["decode_encode"];
386+
Theorem encode_decode_exists[local]:
387+
?decode. !cls. decode (encode cls) = SOME cls
388+
Proof
389+
qexists_tac `\f. some c. encode c = f` \\ fs [encode_11]
390+
QED
391+
392+
val decode_encode_name = "decode_encode";
393+
val decode_encode = new_specification(
394+
decode_encode_name,
395+
["decode"],
396+
encode_decode_exists);
397+
val _ = export_rewrites [decode_encode_name];
390398

391399
Definition fs_ffi_part_def:
392400
fs_ffi_part =
@@ -397,4 +405,3 @@ Definition fs_ffi_part_def:
397405
("write",ffi_write);
398406
("close",ffi_close)])
399407
End
400-

basis/pure/mlstringScript.sml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ Definition implode_def:
2525
implode = strlit
2626
End
2727

28-
Definition strlen_def:
28+
Definition strlen_def[simp]:
2929
strlen (strlit s) = LENGTH s
3030
End
3131

32-
Definition strsub_def:
32+
Definition strsub_def[simp]:
3333
strsub (strlit s) n = EL n s
3434
End
3535

@@ -51,14 +51,11 @@ Proof
5151
EVAL_TAC
5252
QED
5353

54-
val _ = export_rewrites["strlen_def","strsub_def"];
55-
56-
Definition explode_aux_def:
54+
Definition explode_aux_def[simp]:
5755
(explode_aux s n 0 = []) ∧
5856
(explode_aux s n (SUC len) =
5957
strsub s n :: (explode_aux s (n + 1) len))
6058
End
61-
val _ = export_rewrites["explode_aux_def"];
6259

6360
Theorem explode_aux_thm:
6461
∀max n ls.
@@ -1369,23 +1366,21 @@ Definition escape_char_def:
13691366
escape_char c = implode ("#\"" ++ char_escaped c ++ "\"")
13701367
End
13711368

1372-
Theorem ALL_DISTINCT_MAP_implode:
1369+
Theorem ALL_DISTINCT_MAP_implode[simp]:
13731370
ALL_DISTINCT ls ⇒ ALL_DISTINCT (MAP implode ls)
13741371
Proof
13751372
strip_tac >>
13761373
match_mp_tac ALL_DISTINCT_MAP_INJ >>
13771374
rw[implode_def]
13781375
QED
1379-
val _ = export_rewrites["ALL_DISTINCT_MAP_implode"]
13801376

1381-
Theorem ALL_DISTINCT_MAP_explode:
1377+
Theorem ALL_DISTINCT_MAP_explode[simp]:
13821378
∀ls. ALL_DISTINCT (MAP explode ls) ⇔ ALL_DISTINCT ls
13831379
Proof
13841380
gen_tac >> EQ_TAC >- MATCH_ACCEPT_TAC ALL_DISTINCT_MAP >>
13851381
STRIP_TAC >> MATCH_MP_TAC ALL_DISTINCT_MAP_INJ >>
13861382
simp[explode_11]
13871383
QED
1388-
val _ = export_rewrites["ALL_DISTINCT_MAP_explode"]
13891384

13901385
(* optimising mlstring app_list *)
13911386

candle/overloading/monadic/holKernelProofScript.sml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4248,12 +4248,11 @@ Proof
42484248
\\ res_tac \\ fs []
42494249
QED
42504250
4251-
Definition sizeof'_def:
4251+
Definition sizeof'_def[simp]:
42524252
(sizeof' (Comb s t) = 1 + sizeof' s + sizeof' t) ∧
42534253
(sizeof' (Abs v t) = 1 + sizeof' v + sizeof' t) ∧
42544254
(sizeof' _ = 1n)
42554255
End
4256-
val _ = export_rewrites["sizeof'_def"];
42574256
42584257
Theorem sizeof'_rev_assocd:
42594258
∀x l d.

candle/overloading/semantics/holBoolScript.sml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,13 @@ End
131131

132132
Overload is_bool_interpretation_ext = ``is_bool_interpretation_ext0 ^mem``
133133

134-
Theorem boolrel_in_funspace:
134+
Theorem boolrel_in_funspace[simp]:
135135
is_set_theory ^mem ⇒ Boolrel R <: Funspace boolset (Funspace boolset boolset)
136136
Proof
137137
rw[Boolrel_def] >> match_mp_tac (UNDISCH abstract_in_funspace) >> rw[] >>
138138
match_mp_tac (UNDISCH abstract_in_funspace) >> rw[boolean_in_boolset]
139139
QED
140140

141-
val _ = export_rewrites["boolrel_in_funspace"]
142141

143142
val Defs = [TrueDef_def, AndDef_def, ImpliesDef_def, ForallDef_def, ExistsDef_def, OrDef_def, FalseDef_def, NotDef_def]
144143

candle/overloading/semantics/holSemanticsScript.sml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Definition terms_of_frag_def:
7777
/\ set(allTypes t) ⊆ tys /\ welltyped t}
7878
End
7979

80-
Definition TYPE_SUBSTf_def:
80+
Definition TYPE_SUBSTf_def[simp]:
8181
(TYPE_SUBSTf i (Tyvar v) = i v) ∧
8282
(TYPE_SUBSTf i (Tyapp v tys) =
8383
Tyapp v (MAP (λa. TYPE_SUBSTf i a) tys))
@@ -87,7 +87,6 @@ Termination
8787
simp[] >> res_tac >> simp[]
8888
End
8989

90-
val _ = export_rewrites["TYPE_SUBSTf_def"]
9190

9291
Definition terms_of_frag_uninst_def:
9392
terms_of_frag_uninst (tys,consts) sigma =

0 commit comments

Comments
 (0)