@@ -14,21 +14,21 @@ open fromSexpTheory;
1414val _ = translation_extends " sptrees_bdd_trans_Prog" ;
1515
1616
17-
1817val _ = type_abbrev(" action_policy_type" , “:((string# num list) action_expr) policy”);
1918
19+
20+ fun sptrees_gen_bdds_policy_and_table (var_policy, policy_order, policy_full_order) =
21+
22+ let
23+
2024Definition policy_order_test_def:
21- policy_order_test = ([ " x " ; " y " ; " z " ] :string list)
25+ policy_order_test = (^policy_order :string list)
2226End
2327
2428val r = translate policy_order_test_def;
2529
2630Definition policy_content_test_def:
27- policy_content_test = [
28- (Var " x" , action (" allow" ,[1 ]));
29- (And (Var " y" ) (Var " z" ), action (" allow" ,[2 ]));
30- (True, action (" drop" ,[]))
31- ]:action_policy_type
31+ policy_content_test = (^var_policy:action_policy_type)
3232End
3333
3434val r = translate policy_content_test_def;
@@ -84,20 +84,34 @@ val prog =
8484 (Dlet unknown_loc (Pcon NONE [])
8585 (App Opapp [Var (Short " main" ); Con NONE []]))
8686 ^(get_ml_prog_state() |> get_prog)
87- `` |> EVAL |> concl |> rhs
87+ `` |> EVAL |> concl |> rhs;
8888
8989
9090
9191val _ = astToSexprLib.write_ast_to_file " ../bdd_cake_test/test_bdd_policy.sexp" prog;
9292
9393
94- val status = OS.Process.system " cd ../bdd_cake_test/ && CML_STACK_SIZE=2048 CML_HEAP_SIZE=8192 ./cake --sexp=true --exclude_prelude=true --skip_type_inference=false --jump=false --reg_alg=0 < test_bdd_policy.sexp > test_bdd_policy.cake.S && cc test_bdd_policy.cake.S basis_ffi.c -lm -o test_bdd_policy.cake -lm && cd ../bdd_cake_test/ && time ./test_bdd_policy.cake > bdd_policy_cakeml_export.txt "
94+ val status_compile_sexp = OS.Process.system " cd ../bdd_cake_test/ && CML_STACK_SIZE=2048 CML_HEAP_SIZE=8192 ./cake --sexp=true --exclude_prelude=true --skip_type_inference=false --jump=false --reg_alg=0 < test_bdd_policy.sexp > test_bdd_policy.cake.S"
9595
96- val _ = if OS.Process.isSuccess status
96+ val _ = if OS.Process.isSuccess status_compile_sexp
9797 then print " Ja, policy cakeML compilation completed\n "
9898 else (print " Nej, policy cakeML compilation failed\n " ;
9999 OS.Process.exit OS.Process.failure)
100100
101+ val status_cc = OS.Process.system " cd ../bdd_cake_test/ && cc test_bdd_policy.cake.S basis_ffi.c -lm -o test_bdd_policy.cake -lm"
102+
103+ val _ = if OS.Process.isSuccess status_cc
104+ then print " Ja, policy cc compilation completed\n "
105+ else (print " Nej, policy cc compilation failed\n " ;
106+ OS.Process.exit OS.Process.failure)
107+
108+ val status_exec = OS.Process.system " cd ../bdd_cake_test/ && time ./test_bdd_policy.cake > bdd_policy_cakeml_export.txt" ;
109+
110+ val _ = if OS.Process.isSuccess status_exec
111+ then print " Ja, policy cc compilation completed\n "
112+ else (print " Nej, policy cc compilation failed\n " ;
113+ OS.Process.exit OS.Process.failure)
114+
101115
102116
103117(*
@@ -121,12 +135,12 @@ time ./test_bdd_policy.cake > bdd_policy_cakeml_export.txt
121135
122136
123137val ins = TextIO.openIn " ../bdd_cake_test/bdd_policy_cakeml_export.txt" ;
124- val content_str = TextIO.inputAll ins;
138+ val policy_content_str = TextIO.inputAll ins;
125139val _ = TextIO.closeIn ins;
126140
127141(* open Term;*)
128142
129- val content_term =
143+ val policy_bdd_content_term =
130144 let
131145 (* Clean the string by removing newlines and backslash escapes *)
132146 fun clean s =
@@ -139,7 +153,7 @@ val content_term =
139153 String.implode (process chars)
140154 end
141155
142- val cleaned = clean content_str
156+ val cleaned = clean policy_content_str
143157 val parsed = Parse.Term [QUOTE cleaned]
144158 in
145159 parsed
@@ -149,24 +163,11 @@ end;
149163
150164
151165
152-
153- val policy_full_order = “[
154- (" A" ,[" x" ;" y" ]);
155- (" B" ,[" z" ])
156- ]”;
157-
158-
159166val test_groupings = rhs(concl(EVAL policy_full_order));
160- val gen_var_table_auto = bdd_utilsLib.bdd_to_tables_iterative content_term test_groupings;
161-
167+ val gen_var_table_auto = bdd_utilsLib.bdd_to_tables_iterative policy_bdd_content_term test_groupings;
162168
163169
164170
165- (*
166- val eval_table_full_opt_auto = EVAL “mk_BDDPred_opt table_structure (0,[],[(0, non_termn (NONE, ^gen_var_table_auto))]) [] ["x";"y";"z"] 1”;
167- *)
168-
169-
170171Definition table_content_test_def:
171172 table_content_test = (^gen_var_table_auto : action_table_type)
172173End
@@ -219,7 +220,7 @@ val prog =
219220 (Dlet unknown_loc (Pcon NONE [])
220221 (App Opapp [Var (Short " main" ); Con NONE []]))
221222 ^(get_ml_prog_state() |> get_prog)
222- `` |> EVAL |> concl |> rhs
223+ `` |> EVAL |> concl |> rhs;
223224
224225
225226
@@ -243,14 +244,14 @@ val _ = (max_print_depth := 200);
243244
244245
245246
246- val ins = TextIO.openIn " ../bdd_cake_test/bdd_cake_cakeml_export .txt" ;
247- val content_str = TextIO.inputAll ins;
247+ val ins = TextIO.openIn " ../bdd_cake_test/bdd_table_cakeml_export .txt" ;
248+ val tbl_content_str = TextIO.inputAll ins;
248249val _ = TextIO.closeIn ins;
249250
250251
251252
252253
253- val content_term =
254+ val table_bdd_content_term =
254255 let
255256 (* Clean the string by removing newlines and backslash escapes *)
256257 fun clean s =
@@ -263,7 +264,7 @@ val content_term =
263264 String.implode (process chars)
264265 end
265266
266- val cleaned = clean content_str
267+ val cleaned = clean tbl_content_str
267268 val parsed = Parse.Term [QUOTE cleaned]
268269 in
269270 parsed
@@ -272,4 +273,13 @@ end;
272273
273274
274275
276+
277+
278+
279+ in
280+ (policy_bdd_content_term, gen_var_table_auto, table_bdd_content_term)
281+ end ;
282+
283+
284+
275285end ;
0 commit comments