Skip to content

Commit 29d14fd

Browse files
debugging forward proof
1 parent 99153f6 commit 29d14fd

File tree

1 file changed

+56
-13
lines changed

1 file changed

+56
-13
lines changed

hol/bdd_test_casesScript.sml

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ val _ = load "bdd_utils";
4242

4343
val _ = new_theory "bdd_test_cases";
4444

45-
46-
4745
(* a few types abbreviations *)
4846
val _ = type_abbrev("BDD_tbl_type", “:(( (string# num list) var_table_list, (string# num list) action_expr) BDD)”);
4947

@@ -53,10 +51,7 @@ val _ = type_abbrev("struc_tbl_type", “:((( atom_var list # num # (string# num
5351
val _ = type_abbrev("action_rule_type", “:((string# num list) action_expr) rule”);
5452
val _ = type_abbrev("action_policy_type", “:((string# num list) action_expr) policy”);
5553

56-
(*
57-
val _ = type_abbrev("arith_rule_typ", “:((string# num list) action_expr) arith_rule”);
58-
val _ = type_abbrev("arith_policy_typ", “:((string# num list) action_expr) arith_policy”);
59-
*)
54+
6055

6156

6257

@@ -73,6 +68,9 @@ val _ = type_abbrev("arith_policy_typ", “:((string# num list) action_expr) ari
7368

7469
(* policy 1: arith POLICY representation *)
7570

71+
72+
73+
(*
7674
val test_pd_type1 = “[("h" , type_record [("ttl", type_length 8);
7775
("flag", type_length 4)])]”;
7876
@@ -103,9 +101,57 @@ val arith_policy1_rule3 = “(arith_a a_True, action ("drop",[])):((string# num
103101
val arith_policy1 = “[^arith_policy1_rule1 ;
104102
^arith_policy1_rule2 ;
105103
^arith_policy1_rule3]:((string# num list) action_expr) arith_policy”;
104+
*)
105+
106+
107+
108+
val test_pd_type1 = “[("ip", type_record [("priority", type_length 3);
109+
("size", type_length 16);
110+
("age", type_length 8);
111+
("type", type_length 4)])]”;
112+
113+
val is_high_priority = “(arithm_le (lv_acc (lv_x "ip") "priority") ^(BDDUtils.make_bv 2 3))”;
114+
val is_medium_priority = “(arithm_ge (lv_acc (lv_x "ip") "priority") ^(BDDUtils.make_bv 4 3))”;
115+
val is_small_packet = “(arithm_le (lv_acc (lv_x "ip") "size") ^(BDDUtils.make_bv 500 16))”;
116+
val is_young_packet = “(arithm_ge (lv_acc (lv_x "ip") "age") ^(BDDUtils.make_bv 200 8))”;
117+
val is_control_type = “(arithm_le (lv_acc (lv_x "ip") "type") ^(BDDUtils.make_bv 3 4))”;
118+
val is_data_type = “(arithm_ge (lv_acc (lv_x "ip") "type") ^(BDDUtils.make_bv 8 4))”;
106119

120+
val policy1_me1 = “[("x", ^is_high_priority);
121+
("y", ^is_medium_priority);
122+
("z", ^is_small_packet);
123+
("w", ^is_young_packet);
124+
("q", ^is_control_type);
125+
("r", ^is_data_type)]”;
107126

127+
val policy1_full_order = “[("a",["x";"y"]);
128+
("b",["z"]);
129+
("c",["w"]);
130+
("d",["q";"r"])]”;
108131

132+
val policy1_order = “["x";"y";"z";"w";"q";"r"]”;
133+
134+
(* Rule 1: High priority small control packets - expedited forwarding *)
135+
val arith_policy1_rule1 = “(arith_and (arith_a ^is_high_priority)
136+
(arith_and (arith_a ^is_small_packet) (arith_a ^is_control_type)),
137+
action ("fwd_priority",[1; 255])):((string# num list) action_expr) arith_rule”;
138+
139+
(* Rule 2: High priority data packets *)
140+
val arith_policy1_rule2 = “(arith_and (arith_a ^is_high_priority) (arith_a ^is_data_type),
141+
action ("fwd",[1])):((string# num list) action_expr) arith_rule”;
142+
143+
(* Rule 3: Medium priority young packets *)
144+
val arith_policy1_rule3 = “(arith_and (arith_a ^is_medium_priority) (arith_a ^is_young_packet),
145+
action ("fwd",[2])):((string# num list) action_expr) arith_rule”;
146+
147+
(* Rule 7: Default forward rule *)
148+
val arith_policy1_rule7 = “(arith_a a_True,
149+
action ("fwd",[5])):((string# num list) action_expr) arith_rule”;
150+
151+
val arith_policy1 = “[^arith_policy1_rule1;
152+
^arith_policy1_rule2;
153+
^arith_policy1_rule3;
154+
^arith_policy1_rule7]:((string# num list) action_expr) arith_policy”;
109155

110156

111157
(********************************)
@@ -144,8 +190,9 @@ val eval_table1_full_opt_auto_rhs = optionSyntax.dest_some (rhs (concl eval_tabl
144190

145191

146192
(* get I (pairs isomorphic in the graph), and check if isisIsomorph *)
147-
val get_i_policy1 = BDDUtils.pairBDDs (eval_table1_full_opt_auto_rhs , eval_table1_full_opt_auto_rhs);
148-
val is_tbl_policy1_iso = EVAL “isIsomorph_exec ^get_i_policy1 ^eval_table1_full_opt_auto_rhs ^eval_table1_full_opt_auto_rhs”;
193+
val get_i_policy1 = BDDUtils.pairBDDs (eval_policy1_full_opt_rhs, eval_table1_full_opt_auto_rhs);
194+
val is_tbl_policy1_iso = EVAL “isIsomorph_exec ^get_i_policy1 ^eval_policy1_full_opt_rhs
195+
^eval_table1_full_opt_auto_rhs”;
149196

150197

151198
(* Theorem of correctness for conversion from var policy to var table *)
@@ -214,9 +261,6 @@ val final_thm = prove(
214261

215262

216263

217-
218-
219-
220264
(*
221265
TODO:
222266
1. sota review: why is this work more complete than anything we have found
@@ -401,5 +445,4 @@ val _ = export_theory ();
401445

402446

403447

404-
405-
448+

0 commit comments

Comments
 (0)