5 theory Complete_Lattice |
5 theory Complete_Lattice |
6 imports Set |
6 imports Set |
7 begin |
7 begin |
8 |
8 |
9 notation |
9 notation |
10 less_eq (infix "\<sqsubseteq>" 50) and |
10 less_eq (infix "\<sqsubseteq>" 50) and |
11 less (infix "\<sqsubset>" 50) and |
11 less (infix "\<sqsubset>" 50) and |
12 inf (infixl "\<sqinter>" 70) and |
12 inf (infixl "\<sqinter>" 70) and |
13 sup (infixl "\<squnion>" 65) and |
13 sup (infixl "\<squnion>" 65) and |
14 top ("\<top>") and |
14 top ("\<top>") and |
15 bot ("\<bottom>") |
15 bot ("\<bottom>") |
16 |
16 |
17 |
17 |
18 subsection {* Syntactic infimum and supremum operations *} |
18 subsection {* Syntactic infimum and supremum operations *} |
23 class Sup = |
23 class Sup = |
24 fixes Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900) |
24 fixes Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900) |
25 |
25 |
26 subsection {* Abstract complete lattices *} |
26 subsection {* Abstract complete lattices *} |
27 |
27 |
28 class complete_lattice = lattice + bot + top + Inf + Sup + |
28 class complete_lattice = bounded_lattice + Inf + Sup + |
29 assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x" |
29 assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x" |
30 and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A" |
30 and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A" |
31 assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A" |
31 assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A" |
32 and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z" |
32 and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z" |
33 begin |
33 begin |
34 |
34 |
35 lemma dual_complete_lattice: |
35 lemma dual_complete_lattice: |
36 "complete_lattice Sup Inf (op \<ge>) (op >) (op \<squnion>) (op \<sqinter>) \<top> \<bottom>" |
36 "complete_lattice Sup Inf (op \<ge>) (op >) (op \<squnion>) (op \<sqinter>) \<top> \<bottom>" |
37 by (auto intro!: complete_lattice.intro dual_lattice |
37 by (auto intro!: complete_lattice.intro dual_bounded_lattice) |
38 bot.intro top.intro dual_preorder, unfold_locales) |
38 (unfold_locales, (fact bot_least top_greatest |
39 (fact bot_least top_greatest |
39 Sup_upper Sup_least Inf_lower Inf_greatest)+) |
40 Sup_upper Sup_least Inf_lower Inf_greatest)+ |
40 |
41 |
41 lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<sqsubseteq> a}" |
42 lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<le> a}" |
|
43 by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) |
42 by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) |
44 |
43 |
45 lemma Sup_Inf: "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<le> b}" |
44 lemma Sup_Inf: "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<sqsubseteq> b}" |
46 by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) |
45 by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) |
47 |
46 |
48 lemma Inf_Univ: "\<Sqinter>UNIV = \<Squnion>{}" |
47 lemma Inf_empty: |
49 unfolding Sup_Inf by auto |
48 "\<Sqinter>{} = \<top>" |
50 |
49 by (auto intro: antisym Inf_greatest) |
51 lemma Sup_Univ: "\<Squnion>UNIV = \<Sqinter>{}" |
50 |
52 unfolding Inf_Sup by auto |
51 lemma Sup_empty: |
|
52 "\<Squnion>{} = \<bottom>" |
|
53 by (auto intro: antisym Sup_least) |
53 |
54 |
54 lemma Inf_insert: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A" |
55 lemma Inf_insert: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A" |
55 by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower) |
56 by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower) |
56 |
57 |
57 lemma Sup_insert: "\<Squnion>insert a A = a \<squnion> \<Squnion>A" |
58 lemma Sup_insert: "\<Squnion>insert a A = a \<squnion> \<Squnion>A" |
63 |
64 |
64 lemma Sup_singleton [simp]: |
65 lemma Sup_singleton [simp]: |
65 "\<Squnion>{a} = a" |
66 "\<Squnion>{a} = a" |
66 by (auto intro: antisym Sup_upper Sup_least) |
67 by (auto intro: antisym Sup_upper Sup_least) |
67 |
68 |
68 lemma Inf_insert_simp: |
|
69 "\<Sqinter>insert a A = (if A = {} then a else a \<sqinter> \<Sqinter>A)" |
|
70 by (cases "A = {}") (simp_all, simp add: Inf_insert) |
|
71 |
|
72 lemma Sup_insert_simp: |
|
73 "\<Squnion>insert a A = (if A = {} then a else a \<squnion> \<Squnion>A)" |
|
74 by (cases "A = {}") (simp_all, simp add: Sup_insert) |
|
75 |
|
76 lemma Inf_binary: |
69 lemma Inf_binary: |
77 "\<Sqinter>{a, b} = a \<sqinter> b" |
70 "\<Sqinter>{a, b} = a \<sqinter> b" |
78 by (auto simp add: Inf_insert_simp) |
71 by (simp add: Inf_empty Inf_insert) |
79 |
72 |
80 lemma Sup_binary: |
73 lemma Sup_binary: |
81 "\<Squnion>{a, b} = a \<squnion> b" |
74 "\<Squnion>{a, b} = a \<squnion> b" |
82 by (auto simp add: Sup_insert_simp) |
75 by (simp add: Sup_empty Sup_insert) |
83 |
76 |
84 lemma bot_def: |
77 lemma Inf_UNIV: |
85 "bot = \<Squnion>{}" |
78 "\<Sqinter>UNIV = bot" |
86 by (auto intro: antisym Sup_least) |
79 by (simp add: Sup_Inf Sup_empty [symmetric]) |
87 |
80 |
88 lemma top_def: |
81 lemma Sup_UNIV: |
89 "top = \<Sqinter>{}" |
82 "\<Squnion>UNIV = top" |
90 by (auto intro: antisym Inf_greatest) |
83 by (simp add: Inf_Sup Inf_empty [symmetric]) |
91 |
|
92 lemma sup_bot [simp]: |
|
93 "x \<squnion> bot = x" |
|
94 using bot_least [of x] by (simp add: sup_commute sup_absorb2) |
|
95 |
|
96 lemma inf_top [simp]: |
|
97 "x \<sqinter> top = x" |
|
98 using top_greatest [of x] by (simp add: inf_commute inf_absorb2) |
|
99 |
84 |
100 definition SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where |
85 definition SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where |
101 "SUPR A f = \<Squnion> (f ` A)" |
86 "SUPR A f = \<Squnion> (f ` A)" |
102 |
87 |
103 definition INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where |
88 definition INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where |
127 ] *} -- {* to avoid eta-contraction of body *} |
112 ] *} -- {* to avoid eta-contraction of body *} |
128 |
113 |
129 context complete_lattice |
114 context complete_lattice |
130 begin |
115 begin |
131 |
116 |
132 lemma le_SUPI: "i : A \<Longrightarrow> M i \<le> (SUP i:A. M i)" |
117 lemma le_SUPI: "i : A \<Longrightarrow> M i \<sqsubseteq> (SUP i:A. M i)" |
133 by (auto simp add: SUPR_def intro: Sup_upper) |
118 by (auto simp add: SUPR_def intro: Sup_upper) |
134 |
119 |
135 lemma SUP_leI: "(\<And>i. i : A \<Longrightarrow> M i \<le> u) \<Longrightarrow> (SUP i:A. M i) \<le> u" |
120 lemma SUP_leI: "(\<And>i. i : A \<Longrightarrow> M i \<sqsubseteq> u) \<Longrightarrow> (SUP i:A. M i) \<sqsubseteq> u" |
136 by (auto simp add: SUPR_def intro: Sup_least) |
121 by (auto simp add: SUPR_def intro: Sup_least) |
137 |
122 |
138 lemma INF_leI: "i : A \<Longrightarrow> (INF i:A. M i) \<le> M i" |
123 lemma INF_leI: "i : A \<Longrightarrow> (INF i:A. M i) \<sqsubseteq> M i" |
139 by (auto simp add: INFI_def intro: Inf_lower) |
124 by (auto simp add: INFI_def intro: Inf_lower) |
140 |
125 |
141 lemma le_INFI: "(\<And>i. i : A \<Longrightarrow> u \<le> M i) \<Longrightarrow> u \<le> (INF i:A. M i)" |
126 lemma le_INFI: "(\<And>i. i : A \<Longrightarrow> u \<sqsubseteq> M i) \<Longrightarrow> u \<sqsubseteq> (INF i:A. M i)" |
142 by (auto simp add: INFI_def intro: Inf_greatest) |
127 by (auto simp add: INFI_def intro: Inf_greatest) |
143 |
128 |
144 lemma SUP_const[simp]: "A \<noteq> {} \<Longrightarrow> (SUP i:A. M) = M" |
129 lemma SUP_const[simp]: "A \<noteq> {} \<Longrightarrow> (SUP i:A. M) = M" |
145 by (auto intro: antisym SUP_leI le_SUPI) |
130 by (auto intro: antisym SUP_leI le_SUPI) |
146 |
131 |