1970 |
1970 |
1971 subsubsection{* Semi-Lattices *} |
1971 subsubsection{* Semi-Lattices *} |
1972 |
1972 |
1973 locale ACIfSL = ACIf + |
1973 locale ACIfSL = ACIf + |
1974 fixes below :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubseteq>" 50) |
1974 fixes below :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubseteq>" 50) |
|
1975 and strict_below :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubset>" 50) |
1975 assumes below_def: "(x \<sqsubseteq> y) = (x\<cdot>y = x)" |
1976 assumes below_def: "(x \<sqsubseteq> y) = (x\<cdot>y = x)" |
|
1977 defines strict_below_def: "(x \<sqsubset> y) \<equiv> (x \<sqsubseteq> y \<and> x \<noteq> y)" |
1976 |
1978 |
1977 locale ACIfSLlin = ACIfSL + |
1979 locale ACIfSLlin = ACIfSL + |
1978 assumes lin: "x\<cdot>y \<in> {x,y}" |
1980 assumes lin: "x\<cdot>y \<in> {x,y}" |
1979 |
1981 |
1980 lemma (in ACIfSL) below_refl[simp]: "x \<sqsubseteq> x" |
1982 lemma (in ACIfSL) below_refl[simp]: "x \<sqsubseteq> x" |
2034 finally show "x \<cdot> y \<sqsubseteq> z" by(simp add:below_def) |
2036 finally show "x \<cdot> y \<sqsubseteq> z" by(simp add:below_def) |
2035 qed |
2037 qed |
2036 qed |
2038 qed |
2037 |
2039 |
2038 |
2040 |
|
2041 lemma (in ACIfSLlin) strict_below_f_conv[simp]: "x \<sqsubset> y \<cdot> z = (x \<sqsubset> y \<and> x \<sqsubset> z)" |
|
2042 apply(simp add: strict_below_def) |
|
2043 using lin[of y z] by (auto simp:below_def ACI) |
|
2044 |
|
2045 |
|
2046 lemma (in ACIfSLlin) strict_above_f_conv: |
|
2047 "x \<cdot> y \<sqsubset> z = (x \<sqsubset> z \<or> y \<sqsubset> z)" |
|
2048 apply(simp add: strict_below_def above_f_conv) |
|
2049 using lin[of y z] lin[of x z] by (auto simp:below_def ACI) |
|
2050 |
|
2051 |
2039 subsubsection{* Lemmas about @{text fold1} *} |
2052 subsubsection{* Lemmas about @{text fold1} *} |
2040 |
2053 |
2041 lemma (in ACf) fold1_Un: |
2054 lemma (in ACf) fold1_Un: |
2042 assumes A: "finite A" "A \<noteq> {}" |
2055 assumes A: "finite A" "A \<noteq> {}" |
2043 shows "finite B \<Longrightarrow> B \<noteq> {} \<Longrightarrow> A Int B = {} \<Longrightarrow> |
2056 shows "finite B \<Longrightarrow> B \<noteq> {} \<Longrightarrow> A Int B = {} \<Longrightarrow> |
2073 lemma (in ACIfSL) below_fold1_iff: |
2086 lemma (in ACIfSL) below_fold1_iff: |
2074 assumes A: "finite A" "A \<noteq> {}" |
2087 assumes A: "finite A" "A \<noteq> {}" |
2075 shows "x \<sqsubseteq> fold1 f A = (\<forall>a\<in>A. x \<sqsubseteq> a)" |
2088 shows "x \<sqsubseteq> fold1 f A = (\<forall>a\<in>A. x \<sqsubseteq> a)" |
2076 using A |
2089 using A |
2077 by(induct rule:finite_ne_induct) simp_all |
2090 by(induct rule:finite_ne_induct) simp_all |
|
2091 |
|
2092 lemma (in ACIfSLlin) strict_below_fold1_iff: |
|
2093 "finite A \<Longrightarrow> A \<noteq> {} \<Longrightarrow> x \<sqsubset> fold1 f A = (\<forall>a\<in>A. x \<sqsubset> a)" |
|
2094 by(induct rule:finite_ne_induct) simp_all |
|
2095 |
2078 |
2096 |
2079 lemma (in ACIfSL) fold1_belowI: |
2097 lemma (in ACIfSL) fold1_belowI: |
2080 assumes A: "finite A" "A \<noteq> {}" |
2098 assumes A: "finite A" "A \<noteq> {}" |
2081 shows "a \<in> A \<Longrightarrow> fold1 f A \<sqsubseteq> a" |
2099 shows "a \<in> A \<Longrightarrow> fold1 f A \<sqsubseteq> a" |
2082 using A |
2100 using A |
2099 using insert by(simp add:below_def ACI) |
2117 using insert by(simp add:below_def ACI) |
2100 finally show ?thesis by(simp add:below_def) |
2118 finally show ?thesis by(simp add:below_def) |
2101 qed |
2119 qed |
2102 qed |
2120 qed |
2103 |
2121 |
|
2122 |
2104 lemma (in ACIfSLlin) fold1_below_iff: |
2123 lemma (in ACIfSLlin) fold1_below_iff: |
2105 assumes A: "finite A" "A \<noteq> {}" |
2124 assumes A: "finite A" "A \<noteq> {}" |
2106 shows "fold1 f A \<sqsubseteq> x = (\<exists>a\<in>A. a \<sqsubseteq> x)" |
2125 shows "fold1 f A \<sqsubseteq> x = (\<exists>a\<in>A. a \<sqsubseteq> x)" |
2107 using A |
2126 using A |
2108 by(induct rule:finite_ne_induct)(simp_all add:above_f_conv) |
2127 by(induct rule:finite_ne_induct)(simp_all add:above_f_conv) |
|
2128 |
|
2129 lemma (in ACIfSLlin) fold1_strict_below_iff: |
|
2130 assumes A: "finite A" "A \<noteq> {}" |
|
2131 shows "fold1 f A \<sqsubset> x = (\<exists>a\<in>A. a \<sqsubset> x)" |
|
2132 using A |
|
2133 by(induct rule:finite_ne_induct)(simp_all add:strict_above_f_conv) |
2109 |
2134 |
2110 |
2135 |
2111 lemma (in ACIfSLlin) fold1_antimono: |
2136 lemma (in ACIfSLlin) fold1_antimono: |
2112 assumes "A \<noteq> {}" and "A \<subseteq> B" and "finite B" |
2137 assumes "A \<noteq> {}" and "A \<subseteq> B" and "finite B" |
2113 shows "fold1 f B \<sqsubseteq> fold1 f A" |
2138 shows "fold1 f B \<sqsubseteq> fold1 f A" |
2118 have B: "B = A \<union> (B-A)" using `A \<subseteq> B` by blast |
2143 have B: "B = A \<union> (B-A)" using `A \<subseteq> B` by blast |
2119 have "fold1 f B = fold1 f (A \<union> (B-A))" by(subst B)(rule refl) |
2144 have "fold1 f B = fold1 f (A \<union> (B-A))" by(subst B)(rule refl) |
2120 also have "\<dots> = f (fold1 f A) (fold1 f (B-A))" |
2145 also have "\<dots> = f (fold1 f A) (fold1 f (B-A))" |
2121 proof - |
2146 proof - |
2122 have "finite A" by(rule finite_subset[OF `A \<subseteq> B` `finite B`]) |
2147 have "finite A" by(rule finite_subset[OF `A \<subseteq> B` `finite B`]) |
2123 moreover have "finite(B-A)" by(blast intro:finite_Diff prems) |
2148 moreover have "finite(B-A)" by(rule finite_Diff[OF `finite B`]) (* by(blast intro:finite_Diff prems) fails *) |
2124 moreover have "(B-A) \<noteq> {}" using prems by blast |
2149 moreover have "(B-A) \<noteq> {}" using prems by blast |
2125 moreover have "A Int (B-A) = {}" using prems by blast |
2150 moreover have "A Int (B-A) = {}" using prems by blast |
2126 ultimately show ?thesis using `A \<noteq> {}` by(rule_tac fold1_Un) |
2151 ultimately show ?thesis using `A \<noteq> {}` by(rule_tac fold1_Un) |
2127 qed |
2152 qed |
2128 also have "\<dots> \<sqsubseteq> fold1 f A" by(simp add: above_f_conv) |
2153 also have "\<dots> \<sqsubseteq> fold1 f A" by(simp add: above_f_conv) |
2129 finally show ?thesis . |
2154 finally show ?thesis . |
2130 qed |
2155 qed |
|
2156 |
2131 |
2157 |
2132 |
2158 |
2133 subsubsection{* Lattices *} |
2159 subsubsection{* Lattices *} |
2134 |
2160 |
2135 locale Lattice = lattice + |
2161 locale Lattice = lattice + |
2340 apply(rule ACIf_axioms.intro) |
2366 apply(rule ACIf_axioms.intro) |
2341 apply(auto simp:max_def) |
2367 apply(auto simp:max_def) |
2342 done |
2368 done |
2343 |
2369 |
2344 interpretation min: |
2370 interpretation min: |
2345 ACIfSL ["min:: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "op \<le>"] |
2371 ACIfSL ["min:: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "op \<le>" "op <"] |
|
2372 apply(simp add:order_less_le) |
2346 apply(rule ACIfSL_axioms.intro) |
2373 apply(rule ACIfSL_axioms.intro) |
2347 apply(auto simp:min_def) |
2374 apply(auto simp:min_def) |
2348 done |
2375 done |
2349 |
2376 |
2350 interpretation min: |
2377 interpretation min: |
2351 ACIfSLlin ["min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "op \<le>"] |
2378 ACIfSLlin ["min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "op \<le>" "op <"] |
2352 apply(rule ACIfSLlin_axioms.intro) |
2379 apply(rule ACIfSLlin_axioms.intro) |
2353 apply(auto simp:min_def) |
2380 apply(auto simp:min_def) |
2354 done |
2381 done |
2355 |
2382 |
2356 interpretation max: |
2383 interpretation max: |
2357 ACIfSL ["max :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "%x y. y\<le>x"] |
2384 ACIfSL ["max :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "%x y. y\<le>x" "%x y. y<x"] |
|
2385 apply(simp add:order_less_le eq_sym_conv) |
2358 apply(rule ACIfSL_axioms.intro) |
2386 apply(rule ACIfSL_axioms.intro) |
2359 apply(auto simp:max_def) |
2387 apply(auto simp:max_def) |
2360 done |
2388 done |
2361 |
2389 |
2362 interpretation max: |
2390 interpretation max: |
2363 ACIfSLlin ["max :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "%x y. y\<le>x"] |
2391 ACIfSLlin ["max :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "%x y. y\<le>x" "%x y. y<x"] |
2364 apply(rule ACIfSLlin_axioms.intro) |
2392 apply(rule ACIfSLlin_axioms.intro) |
2365 apply(auto simp:max_def) |
2393 apply(auto simp:max_def) |
2366 done |
2394 done |
2367 |
2395 |
2368 interpretation min_max: |
2396 interpretation min_max: |
2422 |
2450 |
2423 lemma Max_le_iff[simp]: |
2451 lemma Max_le_iff[simp]: |
2424 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (Max A \<le> x) = (\<forall>a\<in>A. a \<le> x)" |
2452 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (Max A \<le> x) = (\<forall>a\<in>A. a \<le> x)" |
2425 by(simp add: Max_def max.below_fold1_iff) |
2453 by(simp add: Max_def max.below_fold1_iff) |
2426 |
2454 |
|
2455 lemma Min_gr_iff[simp]: |
|
2456 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (x < Min A) = (\<forall>a\<in>A. x < a)" |
|
2457 by(simp add: Min_def min.strict_below_fold1_iff) |
|
2458 |
|
2459 lemma Max_less_iff[simp]: |
|
2460 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (Max A < x) = (\<forall>a\<in>A. a < x)" |
|
2461 by(simp add: Max_def max.strict_below_fold1_iff) |
|
2462 |
2427 lemma Min_le_iff: |
2463 lemma Min_le_iff: |
2428 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (Min A \<le> x) = (\<exists>a\<in>A. a \<le> x)" |
2464 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (Min A \<le> x) = (\<exists>a\<in>A. a \<le> x)" |
2429 by(simp add: Min_def min.fold1_below_iff) |
2465 by(simp add: Min_def min.fold1_below_iff) |
2430 |
2466 |
2431 lemma Max_ge_iff: |
2467 lemma Max_ge_iff: |
2432 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (x \<le> Max A) = (\<exists>a\<in>A. x \<le> a)" |
2468 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (x \<le> Max A) = (\<exists>a\<in>A. x \<le> a)" |
2433 by(simp add: Max_def max.fold1_below_iff) |
2469 by(simp add: Max_def max.fold1_below_iff) |
|
2470 |
|
2471 lemma Min_le_iff: |
|
2472 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (Min A < x) = (\<exists>a\<in>A. a < x)" |
|
2473 by(simp add: Min_def min.fold1_strict_below_iff) |
|
2474 |
|
2475 lemma Max_ge_iff: |
|
2476 "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> (x < Max A) = (\<exists>a\<in>A. x < a)" |
|
2477 by(simp add: Max_def max.fold1_strict_below_iff) |
2434 |
2478 |
2435 lemma Min_Un: "\<lbrakk>finite A; A \<noteq> {}; finite B; B \<noteq> {}\<rbrakk> |
2479 lemma Min_Un: "\<lbrakk>finite A; A \<noteq> {}; finite B; B \<noteq> {}\<rbrakk> |
2436 \<Longrightarrow> Min (A \<union> B) = min (Min A) (Min B)" |
2480 \<Longrightarrow> Min (A \<union> B) = min (Min A) (Min B)" |
2437 by(simp add:Min_def min.f.fold1_Un2) |
2481 by(simp add:Min_def min.f.fold1_Un2) |
2438 |
2482 |