-
Notifications
You must be signed in to change notification settings - Fork 0
/
BDD_simplify.thy
67 lines (56 loc) · 2.27 KB
/
BDD_simplify.thy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
theory BDD_simplify
imports Main BDD_basic BDD_union BDD_intersect BDD_uniqueness
begin
fun simplify_n :: "nat \<Rightarrow> BDD \<Rightarrow> BDD \<Rightarrow> BDD" where
"simplify_n _ Nothing _ = Nothing" |
"simplify_n _ Top b = b" |
"simplify_n _ (Select va ta ea) Nothing = Nothing" |
"simplify_n _ (Select va ta ea) Top = Top" |
"simplify_n 0 (Select _ _ _) (Select _ _ _) = Top" |
"simplify_n (Suc n) (Select va ta ea) (Select vb tb eb) =
(if va > vb then
simplify_n n (union ta ea) (Select vb tb eb)
else if va = vb then
if ta = Nothing then
simplify_n n ea eb
else if ea = Nothing then
simplify_n n ta tb
else
select va (simplify_n n ta tb) (simplify_n n ea eb)
else
select vb (simplify_n n (Select va ta ea) tb)
(simplify_n n (Select va ta ea) eb))"
fun simplify :: "BDD \<Rightarrow> BDD \<Rightarrow> BDD" where
"simplify Nothing _ = Nothing" |
"simplify Top b = b" |
"simplify (Select va ta ea) Nothing = Nothing" |
"simplify (Select va ta ea) Top = Top" |
"simplify (Select va ta ea) (Select vb tb eb) =
(if va > vb then
simplify_n (Suc va) (Select va ta ea) (Select vb tb eb)
else
simplify_n (Suc vb) (Select va ta ea) (Select vb tb eb))"
lemma simplify_n_top[simp]: "simplify_n n ta Top = (if ta = Nothing then Nothing else Top)"
by (metis BDD.exhaust simplify_n.simps(1) simplify_n.simps(2) simplify_n.simps(4))
lemma not_norm_0_select[simp]: "~norm 0 (Select v t e)"
using norm.cases by blast
lemma simplify_n_nothing [simp]: "simplify_n n a Nothing = Nothing"
apply (induction a arbitrary: n)
by auto
lemma simplify_nothing [simp]: "simplify a Nothing = Nothing"
apply (case_tac a)
by auto
lemma simplify_top: "a \<noteq> Nothing \<Longrightarrow> simplify a Top = Top"
apply (case_tac a)
by auto
lemma union_select_contains: "contains (Select v t e) f \<Longrightarrow> contains (union t e) f"
apply simp
apply (case_tac "f v")
apply (simp add: contains_p_correct)
apply (simp add: contains_p_correct)
done
lemma simplify_n_idem: "norm n a \<Longrightarrow> norm n b \<Longrightarrow> s = simplify_n n a b \<Longrightarrow> simplify_n n a s = s"
apply (induction n arbitrary: s a b)
apply simp
oops
end