@@ -41,29 +41,38 @@ open table_bs_propertiesTheory;
4141
4242open bdd_utilsLib;
4343
44+
4445
46+ fun time_stage (stage_name, timer_cpu, timer_real) =
47+ let
48+ val cpu_time = Timer.checkCPUTimer timer_cpu
49+ val real_time = Timer.checkRealTimer timer_real
50+ val _ = HOL_MESG (stage_name ^ " completed in: " ^
51+ Time.toString (#usr cpu_time) ^ " user, " ^
52+ Time.toString (#sys cpu_time) ^ " system, " ^
53+ Time.toString real_time ^ " real\n " )
54+ in
55+ (cpu_time, real_time)
56+ end
4557
46- (* a few types abbreviations *)
47- (*
48- val _ = type_abbrev("BDD_tbl_type", “:(( (string# num list) var_table_list, (string# num list) action_expr) BDD)”);
49-
50- val _ = type_abbrev("struc_tbl_type", “:((( atom_var list # num # (string# num list) action_expr) list list # num,
51- (string# num list) action_expr) decision_structure)”);
52-
53- val _ = type_abbrev("action_rule_type", “:((string# num list) action_expr) rule”);
54- val _ = type_abbrev("action_policy_type", “:((string# num list) action_expr) policy”);
55- *)
56-
5758
5859
5960 fun convert_arith_policy_to_interval_tables (arith_policy, policy_me, test_pd_type, policy_full_order, policy_order) =
6061
6162 let
6263
64+ val start_cpu_total = Timer.startCPUTimer ();
65+ val start_real_total = Timer.startRealTimer ();
66+
67+
6368 (* **********************)
6469 (* STAGE 1 *)
6570 (* **********************)
6671
72+ val start_cpu_stage1 = Timer.startCPUTimer ();
73+ val start_real_stage1 = Timer.startRealTimer ();
74+
75+
6776 (* convert arith policy to var policy*)
6877 val arith_policy_eval = EVAL “convert_arith_to_var_policy ^arith_policy ^policy_me”;
6978 val var_policy = optionSyntax.dest_some (rhs (concl arith_policy_eval));
@@ -81,25 +90,44 @@ val _ = type_abbrev("action_policy_type", “:((string# num list) action_expr) p
8190 (ISPECL[arith_policy, var_policy, policy_me] policy_airth_to_var_sem_conversion_correct);
8291
8392
93+ val _ = time_stage (" Stage 1" , start_cpu_stage1, start_real_stage1)
94+
95+
8496 (* **********************)
8597 (* STAGE 2 *)
8698 (* **********************)
8799
100+
101+ val start_cpu_stage2 = Timer.startCPUTimer ();
102+ val start_real_stage2 = Timer.startRealTimer ();
103+
104+
88105 (* create BDD of var policy *)
89106 val eval_policy_full_opt = EVAL “mk_BDDPred_opt policy_structure (0 ,[],[(0 , non_termn (NONE , ^var_policy))]) [] ^policy_order 1 ”;
90107 val eval_policy_full_opt_rhs = optionSyntax.dest_some (rhs (concl eval_policy_full_opt));
91108
109+ val _ = time_stage (" Stage 2 from var policy to BDD" , start_cpu_stage2, start_real_stage2);
110+ val start_cpu_stage2_vbdd = Timer.startCPUTimer ();
111+ val start_real_stage2_vbdd = Timer.startRealTimer ();
92112
93113 (* automatically generate a var table from the var policy's BDD via sml*)
94114 val test_groupings = rhs(concl(EVAL policy_full_order));
95115 val gen_var_table_auto = bdd_utilsLib.bdd_to_tables_iterative eval_policy_full_opt_rhs test_groupings;
96116
97117
118+ val _ = time_stage (" Stage 2 from var BDD to table" , start_cpu_stage2_vbdd, start_real_stage2_vbdd);
119+ val start_cpu_stage2_tbl = Timer.startCPUTimer ();
120+ val start_real_stage2_tbl = Timer.startRealTimer ();
121+
98122 (* now create a BDD for the table*)
99123 val eval_table_full_opt_auto = EVAL “mk_BDDPred_opt table_structure (0 ,[],[(0 , non_termn (NONE , ^gen_var_table_auto))]) [] ^policy_order 1 ”;
100124 val eval_table_full_opt_auto_rhs = optionSyntax.dest_some (rhs (concl eval_table_full_opt_auto));
101125
102126
127+ val _ = time_stage (" Stage 2 from table to table BDD" , start_cpu_stage2_tbl, start_real_stage2_tbl);
128+ val start_cpu_stage2_tbdd = Timer.startCPUTimer ();
129+ val start_real_stage2_tbdd = Timer.startRealTimer ();
130+
103131 (* get I (pairs isomorphic in the graph), and check if isisIsomorph *)
104132 val get_i_policy = bdd_utilsLib.pairBDDs (eval_policy_full_opt_rhs, eval_table_full_opt_auto_rhs);
105133 (* val is_tbl_policy1_iso = EVAL “isIsomorph_exec ^get_i_policy ^eval_policy_full_opt_rhs
@@ -109,16 +137,23 @@ val _ = type_abbrev("action_policy_type", “:((string# num list) action_expr) p
109137
110138 (* Theorem of correctness for conversion from var policy to var table *)
111139
112- (* method 1 *)
113140 val policy_thm_init = computeLib.RESTR_EVAL_CONV [“sem_tables”,“sem_policy”, “mv_dom_vars”] “correct_var_policy_var_tables_exec ^var_policy ^gen_var_table_auto ^policy_order ^get_i_policy ”;
114141 val var_policy_var_table_thm = SIMP_RULE bool_ss [correct_var_policy_var_tables_exec_thm1] policy_thm_init;
115142
143+ val _ = time_stage (" Stage 2 proof" , start_cpu_stage2_tbdd, start_real_stage2_tbdd);
144+
145+ val _ = time_stage (" Stage 2 total" , start_cpu_stage2, start_real_stage2);
146+
116147
117148
118149 (* **********************)
119150 (* STAGE 3 *)
120151 (* **********************)
121152
153+ val start_cpu_stage3 = Timer.startCPUTimer ();
154+ val start_real_stage3 = Timer.startRealTimer ();
155+
156+
122157 (* covert var table to interval table *)
123158 val only_var_table = fst (dest_pair gen_var_table_auto);
124159 val convert_to_interval = EVAL “convert_var_to_sinterval_tables ^only_var_table ^policy_me ^test_pd_type”;
@@ -129,8 +164,17 @@ val _ = type_abbrev("action_policy_type", “:((string# num list) action_expr) p
129164 val var_table_sinterval_tbl_thm =
130165 REWRITE_RULE [convert_to_interval] (ISPECL[only_var_table, only_interval_table1, “0 :num”, policy_me, test_pd_type ] correct_tables_from_var_to_sinterval_thm);
131166
167+ val _ = time_stage (" Stage 3" , start_cpu_stage3, start_real_stage3);
168+
169+
170+
171+
172+ (* **********************)
173+ (* FINAL PROOF *)
174+ (* **********************)
175+ val start_cpu_final = Timer.startCPUTimer ();
176+ val start_real_final = Timer.startRealTimer ();
132177
133-
134178 (* to glue the theorems we need to take care of the conditions/ assumptions *)
135179
136180 (* condition1 *)
@@ -176,6 +220,13 @@ val _ = type_abbrev("action_policy_type", “:((string# num list) action_expr) p
176220 fs[cond1_thm, cond2_thm, cond3_thm]
177221 );
178222
223+
224+ val _ = time_stage (" Final glue proof" , start_cpu_final, start_real_final);
225+
226+ val _ = time_stage (" Total time of everything" , start_cpu_total, start_real_total);
227+
228+
229+
179230 in
180231 final_thm
181232 end ;
0 commit comments