Skip to content

Commit cfe72d5

Browse files
committed
Move def of decs_allowed into own theory for better deps
1 parent 0509868 commit cfe72d5

File tree

3 files changed

+51
-32
lines changed

3 files changed

+51
-32
lines changed

compiler/repl/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The REPL type checks and modifies the decs given as input. This file
66
defines the function that implements this and proves that the
77
function will only produce type checked and allowed declarations.
88

9+
[repl_decs_allowedScript.sml](repl_decs_allowedScript.sml):
10+
The REPL puts some restrictions on what decs are acceptable as user input.
11+
This file defines what those restrictions are.
12+
913
[repl_init_envProgScript.sml](repl_init_envProgScript.sml):
1014
This file partially instantiates the eval_state and inserts a Denv declaration.
1115

compiler/repl/repl_check_and_tweakScript.sml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@
55
*)
66
open preamble
77
open semanticsPropsTheory evaluateTheory semanticPrimitivesTheory
8-
open inferTheory compilerTheory candle_prover_invTheory
8+
open inferTheory compilerTheory repl_decs_allowedTheory
99

1010
val _ = Parse.hide "types"
1111

1212
val _ = new_theory "repl_check_and_tweak";
1313

14-
val _ = patternMatchesLib.ENABLE_PMATCH_CASES();
15-
16-
Definition decs_allowed_def:
17-
decs_allowed (decs:ast$dec list) = EVERY candle_prover_inv$safe_dec decs
18-
End
19-
2014
val read_next_dec =
2115
“[Dlet (Locs UNKNOWNpt UNKNOWNpt) Pany
2216
(App Opapp
@@ -26,7 +20,7 @@ val read_next_dec =
2620
Definition check_and_tweak_def:
2721
check_and_tweak (decs, types, input_str) =
2822
let all_decs = decs ++ ^read_next_dec in
29-
dtcase infertype_prog types all_decs of
23+
case infertype_prog types all_decs of
3024
| Success new_types =>
3125
if decs_allowed all_decs then INR (all_decs, new_types)
3226
else INL (strlit "ERROR: input contains reserved constructor/FFI names")
@@ -43,28 +37,4 @@ Proof
4337
\\ fs [decs_allowed_def]
4438
QED
4539

46-
(* pmatch lemmas *)
47-
48-
Triviality safe_exp_pmatch_lemma:
49-
safe_exp =
50-
every_exp $ λx. case x of
51-
| Con opt xs => (dtcase opt of
52-
| SOME id => let n = id_to_n id in n ∉ kernel_ctors
53-
| NONE => T)
54-
| App op xs' => op ≠ FFI kernel_ffi
55-
| _ => T
56-
Proof
57-
CONV_TAC(ONCE_DEPTH_CONV patternMatchesLib.PMATCH_ELIM_CONV)
58-
\\ rw [safe_exp_def,FUN_EQ_THM]
59-
\\ AP_THM_TAC \\ AP_TERM_TAC
60-
\\ rw [safe_exp_def,FUN_EQ_THM]
61-
\\ CASE_TAC \\ fs []
62-
\\ CASE_TAC \\ fs []
63-
QED
64-
65-
Theorem safe_exp_pmatch = safe_exp_pmatch_lemma
66-
|> SIMP_RULE std_ss [candle_kernel_valsTheory.kernel_ctors_def,
67-
candle_kernel_valsTheory.kernel_ffi_def,
68-
IN_UNION,IN_INSERT,NOT_IN_EMPTY,GSYM CONJ_ASSOC]
69-
7040
val _ = export_theory();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
(*
2+
The REPL puts some restrictions on what decs are acceptable as user input.
3+
This file defines what those restrictions are.
4+
*)
5+
open preamble
6+
open semanticsPropsTheory evaluateTheory semanticPrimitivesTheory
7+
open candle_prover_invTheory
8+
9+
val _ = Parse.hide "types"
10+
11+
val _ = new_theory "repl_decs_allowed";
12+
13+
val _ = patternMatchesLib.ENABLE_PMATCH_CASES();
14+
15+
(* definition *)
16+
17+
Definition decs_allowed_def:
18+
decs_allowed (decs:ast$dec list) = EVERY candle_prover_inv$safe_dec decs
19+
End
20+
21+
(* pmatch lemmas *)
22+
23+
Triviality safe_exp_pmatch_lemma:
24+
safe_exp =
25+
every_exp $ λx. case x of
26+
| Con opt xs => (dtcase opt of
27+
| SOME id => let n = id_to_n id in n ∉ kernel_ctors
28+
| NONE => T)
29+
| App op xs' => op ≠ FFI kernel_ffi
30+
| _ => T
31+
Proof
32+
CONV_TAC(ONCE_DEPTH_CONV patternMatchesLib.PMATCH_ELIM_CONV)
33+
\\ rw [safe_exp_def,FUN_EQ_THM]
34+
\\ AP_THM_TAC \\ AP_TERM_TAC
35+
\\ rw [safe_exp_def,FUN_EQ_THM]
36+
\\ CASE_TAC \\ fs []
37+
\\ CASE_TAC \\ fs []
38+
QED
39+
40+
Theorem safe_exp_pmatch = safe_exp_pmatch_lemma
41+
|> SIMP_RULE std_ss [candle_kernel_valsTheory.kernel_ctors_def,
42+
candle_kernel_valsTheory.kernel_ffi_def,
43+
IN_UNION,IN_INSERT,NOT_IN_EMPTY,GSYM CONJ_ASSOC]
44+
45+
val _ = export_theory();

0 commit comments

Comments
 (0)