author | huffman |
Fri, 02 Sep 2011 20:58:31 -0700 | |
changeset 44678 | 21eb31192850 |
parent 42986 | 11fd8c04ea24 |
child 44845 | 5e51075cbd97 |
permissions | -rw-r--r-- |
35719
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1 |
(* Title: HOL/Big_Operators.thy |
12396 | 2 |
Author: Tobias Nipkow, Lawrence C Paulson and Markus Wenzel |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
3 |
with contributions by Jeremy Avigad |
12396 | 4 |
*) |
5 |
||
35719
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
6 |
header {* Big operators and finite (non-empty) sets *} |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
7 |
|
35719
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
8 |
theory Big_Operators |
35722
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
9 |
imports Plain |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
10 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
11 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
12 |
subsection {* Generic monoid operation over a set *} |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
13 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
14 |
no_notation times (infixl "*" 70) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
15 |
no_notation Groups.one ("1") |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
16 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
17 |
locale comm_monoid_big = comm_monoid + |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
18 |
fixes F :: "('b \<Rightarrow> 'a) \<Rightarrow> 'b set \<Rightarrow> 'a" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
19 |
assumes F_eq: "F g A = (if finite A then fold_image (op *) g 1 A else 1)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
20 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
21 |
sublocale comm_monoid_big < folding_image proof |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
22 |
qed (simp add: F_eq) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
23 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
24 |
context comm_monoid_big |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
25 |
begin |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
26 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
27 |
lemma infinite [simp]: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
28 |
"\<not> finite A \<Longrightarrow> F g A = 1" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
29 |
by (simp add: F_eq) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
30 |
|
42986 | 31 |
lemma F_cong: |
32 |
assumes "A = B" "\<And>x. x \<in> B \<Longrightarrow> h x = g x" |
|
33 |
shows "F h A = F g B" |
|
34 |
proof cases |
|
35 |
assume "finite A" |
|
36 |
with assms show ?thesis unfolding `A = B` by (simp cong: cong) |
|
37 |
next |
|
38 |
assume "\<not> finite A" |
|
39 |
then show ?thesis unfolding `A = B` by simp |
|
40 |
qed |
|
41 |
||
42 |
lemma If_cases: |
|
43 |
fixes P :: "'b \<Rightarrow> bool" and g h :: "'b \<Rightarrow> 'a" |
|
44 |
assumes fA: "finite A" |
|
45 |
shows "F (\<lambda>x. if P x then h x else g x) A = |
|
46 |
F h (A \<inter> {x. P x}) * F g (A \<inter> - {x. P x})" |
|
47 |
proof- |
|
48 |
have a: "A = A \<inter> {x. P x} \<union> A \<inter> -{x. P x}" |
|
49 |
"(A \<inter> {x. P x}) \<inter> (A \<inter> -{x. P x}) = {}" |
|
50 |
by blast+ |
|
51 |
from fA |
|
52 |
have f: "finite (A \<inter> {x. P x})" "finite (A \<inter> -{x. P x})" by auto |
|
53 |
let ?g = "\<lambda>x. if P x then h x else g x" |
|
54 |
from union_disjoint[OF f a(2), of ?g] a(1) |
|
55 |
show ?thesis |
|
56 |
by (subst (1 2) F_cong) simp_all |
|
57 |
qed |
|
58 |
||
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
59 |
end |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
60 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
61 |
text {* for ad-hoc proofs for @{const fold_image} *} |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
62 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
63 |
lemma (in comm_monoid_add) comm_monoid_mult: |
36635
080b755377c0
locale predicates of classes carry a mandatory "class" prefix
haftmann
parents:
36622
diff
changeset
|
64 |
"class.comm_monoid_mult (op +) 0" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
65 |
proof qed (auto intro: add_assoc add_commute) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
66 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
67 |
notation times (infixl "*" 70) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
68 |
notation Groups.one ("1") |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
69 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
70 |
|
15402 | 71 |
subsection {* Generalized summation over a set *} |
72 |
||
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
73 |
definition (in comm_monoid_add) setsum :: "('b \<Rightarrow> 'a) => 'b set => 'a" where |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
74 |
"setsum f A = (if finite A then fold_image (op +) f 0 A else 0)" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
75 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
76 |
sublocale comm_monoid_add < setsum!: comm_monoid_big "op +" 0 setsum proof |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
77 |
qed (fact setsum_def) |
15402 | 78 |
|
19535 | 79 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21249
diff
changeset
|
80 |
Setsum ("\<Sum>_" [1000] 999) where |
19535 | 81 |
"\<Sum>A == setsum (%x. x) A" |
82 |
||
15402 | 83 |
text{* Now: lot's of fancy syntax. First, @{term "setsum (%x. e) A"} is |
84 |
written @{text"\<Sum>x\<in>A. e"}. *} |
|
85 |
||
86 |
syntax |
|
17189 | 87 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3SUM _:_. _)" [0, 51, 10] 10) |
15402 | 88 |
syntax (xsymbols) |
17189 | 89 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3\<Sum>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 90 |
syntax (HTML output) |
17189 | 91 |
"_setsum" :: "pttrn => 'a set => 'b => 'b::comm_monoid_add" ("(3\<Sum>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 92 |
|
93 |
translations -- {* Beware of argument permutation! *} |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
94 |
"SUM i:A. b" == "CONST setsum (%i. b) A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
95 |
"\<Sum>i\<in>A. b" == "CONST setsum (%i. b) A" |
15402 | 96 |
|
97 |
text{* Instead of @{term"\<Sum>x\<in>{x. P}. e"} we introduce the shorter |
|
98 |
@{text"\<Sum>x|P. e"}. *} |
|
99 |
||
100 |
syntax |
|
17189 | 101 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3SUM _ |/ _./ _)" [0,0,10] 10) |
15402 | 102 |
syntax (xsymbols) |
17189 | 103 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Sum>_ | (_)./ _)" [0,0,10] 10) |
15402 | 104 |
syntax (HTML output) |
17189 | 105 |
"_qsetsum" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Sum>_ | (_)./ _)" [0,0,10] 10) |
15402 | 106 |
|
107 |
translations |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
108 |
"SUM x|P. t" => "CONST setsum (%x. t) {x. P}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
109 |
"\<Sum>x|P. t" => "CONST setsum (%x. t) {x. P}" |
15402 | 110 |
|
111 |
print_translation {* |
|
112 |
let |
|
35115 | 113 |
fun setsum_tr' [Abs (x, Tx, t), Const (@{const_syntax Collect}, _) $ Abs (y, Ty, P)] = |
114 |
if x <> y then raise Match |
|
115 |
else |
|
116 |
let |
|
42284 | 117 |
val x' = Syntax_Trans.mark_bound x; |
35115 | 118 |
val t' = subst_bound (x', t); |
119 |
val P' = subst_bound (x', P); |
|
42284 | 120 |
in Syntax.const @{syntax_const "_qsetsum"} $ Syntax_Trans.mark_bound x $ P' $ t' end |
35115 | 121 |
| setsum_tr' _ = raise Match; |
122 |
in [(@{const_syntax setsum}, setsum_tr')] end |
|
15402 | 123 |
*} |
124 |
||
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
125 |
lemma setsum_empty: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
126 |
"setsum f {} = 0" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
127 |
by (fact setsum.empty) |
15402 | 128 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
129 |
lemma setsum_insert: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
130 |
"finite F ==> a \<notin> F ==> setsum f (insert a F) = f a + setsum f F" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
131 |
by (fact setsum.insert) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
132 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
133 |
lemma setsum_infinite: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
134 |
"~ finite A ==> setsum f A = 0" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
135 |
by (fact setsum.infinite) |
15402 | 136 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
137 |
lemma (in comm_monoid_add) setsum_reindex: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
138 |
assumes "inj_on f B" shows "setsum h (f ` B) = setsum (h \<circ> f) B" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
139 |
proof - |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
140 |
interpret comm_monoid_mult "op +" 0 by (fact comm_monoid_mult) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
141 |
from assms show ?thesis by (auto simp add: setsum_def fold_image_reindex dest!:finite_imageD) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
142 |
qed |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
143 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
144 |
lemma (in comm_monoid_add) setsum_reindex_id: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
145 |
"inj_on f B ==> setsum f B = setsum id (f ` B)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
146 |
by (simp add: setsum_reindex) |
15402 | 147 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
148 |
lemma (in comm_monoid_add) setsum_reindex_nonzero: |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
149 |
assumes fS: "finite S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
150 |
and nz: "\<And> x y. x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x \<noteq> y \<Longrightarrow> f x = f y \<Longrightarrow> h (f x) = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
151 |
shows "setsum h (f ` S) = setsum (h o f) S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
152 |
using nz |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
153 |
proof(induct rule: finite_induct[OF fS]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
154 |
case 1 thus ?case by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
155 |
next |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
156 |
case (2 x F) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
157 |
{assume fxF: "f x \<in> f ` F" hence "\<exists>y \<in> F . f y = f x" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
158 |
then obtain y where y: "y \<in> F" "f x = f y" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
159 |
from "2.hyps" y have xy: "x \<noteq> y" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
160 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
161 |
from "2.prems"[of x y] "2.hyps" xy y have h0: "h (f x) = 0" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
162 |
have "setsum h (f ` insert x F) = setsum h (f ` F)" using fxF by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
163 |
also have "\<dots> = setsum (h o f) (insert x F)" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
164 |
unfolding setsum.insert[OF `finite F` `x\<notin>F`] |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
165 |
using h0 |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
166 |
apply simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
167 |
apply (rule "2.hyps"(3)) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
168 |
apply (rule_tac y="y" in "2.prems") |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
169 |
apply simp_all |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
170 |
done |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
171 |
finally have ?case .} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
172 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
173 |
{assume fxF: "f x \<notin> f ` F" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
174 |
have "setsum h (f ` insert x F) = h (f x) + setsum h (f ` F)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
175 |
using fxF "2.hyps" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
176 |
also have "\<dots> = setsum (h o f) (insert x F)" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
177 |
unfolding setsum.insert[OF `finite F` `x\<notin>F`] |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
178 |
apply simp |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
179 |
apply (rule cong [OF refl [of "op + (h (f x))"]]) |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
180 |
apply (rule "2.hyps"(3)) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
181 |
apply (rule_tac y="y" in "2.prems") |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
182 |
apply simp_all |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
183 |
done |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
184 |
finally have ?case .} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
185 |
ultimately show ?case by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
186 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
187 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
188 |
lemma (in comm_monoid_add) setsum_cong: |
15402 | 189 |
"A = B ==> (!!x. x:B ==> f x = g x) ==> setsum f A = setsum g B" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
190 |
by (cases "finite A") (auto intro: setsum.cong) |
15402 | 191 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
192 |
lemma (in comm_monoid_add) strong_setsum_cong [cong]: |
16733
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
193 |
"A = B ==> (!!x. x:B =simp=> f x = g x) |
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
nipkow
parents:
16632
diff
changeset
|
194 |
==> setsum (%x. f x) A = setsum (%x. g x) B" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
195 |
by (rule setsum_cong) (simp_all add: simp_implies_def) |
16632
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
196 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
197 |
lemma (in comm_monoid_add) setsum_cong2: "\<lbrakk>\<And>x. x \<in> A \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> setsum f A = setsum g A" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
198 |
by (auto intro: setsum_cong) |
15554 | 199 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
200 |
lemma (in comm_monoid_add) setsum_reindex_cong: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
201 |
"[|inj_on f A; B = f ` A; !!a. a:A \<Longrightarrow> g a = h (f a)|] |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
202 |
==> setsum h B = setsum g A" |
41550 | 203 |
by (simp add: setsum_reindex) |
15402 | 204 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
205 |
lemma (in comm_monoid_add) setsum_0[simp]: "setsum (%i. 0) A = 0" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
206 |
by (cases "finite A") (erule finite_induct, auto) |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
207 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
208 |
lemma (in comm_monoid_add) setsum_0': "ALL a:A. f a = 0 ==> setsum f A = 0" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
209 |
by (simp add:setsum_cong) |
15402 | 210 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
211 |
lemma (in comm_monoid_add) setsum_Un_Int: "finite A ==> finite B ==> |
15402 | 212 |
setsum g (A Un B) + setsum g (A Int B) = setsum g A + setsum g B" |
213 |
-- {* The reversed orientation looks more natural, but LOOPS as a simprule! *} |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
214 |
by (fact setsum.union_inter) |
15402 | 215 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
216 |
lemma (in comm_monoid_add) setsum_Un_disjoint: "finite A ==> finite B |
15402 | 217 |
==> A Int B = {} ==> setsum g (A Un B) = setsum g A + setsum g B" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
218 |
by (fact setsum.union_disjoint) |
15402 | 219 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
220 |
lemma setsum_mono_zero_left: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
221 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
222 |
and z: "\<forall>i \<in> T - S. f i = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
223 |
shows "setsum f S = setsum f T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
224 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
225 |
have eq: "T = S \<union> (T - S)" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
226 |
have d: "S \<inter> (T - S) = {}" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
227 |
from fT ST have f: "finite S" "finite (T - S)" by (auto intro: finite_subset) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
228 |
show ?thesis |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
229 |
by (simp add: setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] setsum_0'[OF z]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
230 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
231 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
232 |
lemma setsum_mono_zero_right: |
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
233 |
"finite T \<Longrightarrow> S \<subseteq> T \<Longrightarrow> \<forall>i \<in> T - S. f i = 0 \<Longrightarrow> setsum f T = setsum f S" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
234 |
by(blast intro!: setsum_mono_zero_left[symmetric]) |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
235 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
236 |
lemma setsum_mono_zero_cong_left: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
237 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
238 |
and z: "\<forall>i \<in> T - S. g i = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
239 |
and fg: "\<And>x. x \<in> S \<Longrightarrow> f x = g x" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
240 |
shows "setsum f S = setsum g T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
241 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
242 |
have eq: "T = S \<union> (T - S)" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
243 |
have d: "S \<inter> (T - S) = {}" using ST by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
244 |
from fT ST have f: "finite S" "finite (T - S)" by (auto intro: finite_subset) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
245 |
show ?thesis |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
246 |
using fg by (simp add: setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] setsum_0'[OF z]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
247 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
248 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
249 |
lemma setsum_mono_zero_cong_right: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
250 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
251 |
and z: "\<forall>i \<in> T - S. f i = 0" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
252 |
and fg: "\<And>x. x \<in> S \<Longrightarrow> f x = g x" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
253 |
shows "setsum f T = setsum g S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
254 |
using setsum_mono_zero_cong_left[OF fT ST z] fg[symmetric] by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
255 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
256 |
lemma setsum_delta: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
257 |
assumes fS: "finite S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
258 |
shows "setsum (\<lambda>k. if k=a then b k else 0) S = (if a \<in> S then b a else 0)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
259 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
260 |
let ?f = "(\<lambda>k. if k=a then b k else 0)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
261 |
{assume a: "a \<notin> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
262 |
hence "\<forall> k\<in> S. ?f k = 0" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
263 |
hence ?thesis using a by simp} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
264 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
265 |
{assume a: "a \<in> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
266 |
let ?A = "S - {a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
267 |
let ?B = "{a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
268 |
have eq: "S = ?A \<union> ?B" using a by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
269 |
have dj: "?A \<inter> ?B = {}" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
270 |
from fS have fAB: "finite ?A" "finite ?B" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
271 |
have "setsum ?f S = setsum ?f ?A + setsum ?f ?B" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
272 |
using setsum_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
273 |
by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
274 |
then have ?thesis using a by simp} |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
275 |
ultimately show ?thesis by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
276 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
277 |
lemma setsum_delta': |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
278 |
assumes fS: "finite S" shows |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
279 |
"setsum (\<lambda>k. if a = k then b k else 0) S = |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
280 |
(if a\<in> S then b a else 0)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
281 |
using setsum_delta[OF fS, of a b, symmetric] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
282 |
by (auto intro: setsum_cong) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
283 |
|
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
284 |
lemma setsum_restrict_set: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
285 |
assumes fA: "finite A" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
286 |
shows "setsum f (A \<inter> B) = setsum (\<lambda>x. if x \<in> B then f x else 0) A" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
287 |
proof- |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
288 |
from fA have fab: "finite (A \<inter> B)" by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
289 |
have aba: "A \<inter> B \<subseteq> A" by blast |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
290 |
let ?g = "\<lambda>x. if x \<in> A\<inter>B then f x else 0" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
291 |
from setsum_mono_zero_left[OF fA aba, of ?g] |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
292 |
show ?thesis by simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
293 |
qed |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
294 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
295 |
lemma setsum_cases: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
296 |
assumes fA: "finite A" |
35577 | 297 |
shows "setsum (\<lambda>x. if P x then f x else g x) A = |
298 |
setsum f (A \<inter> {x. P x}) + setsum g (A \<inter> - {x. P x})" |
|
42986 | 299 |
using setsum.If_cases[OF fA] . |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
300 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
301 |
(*But we can't get rid of finite I. If infinite, although the rhs is 0, |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
302 |
the lhs need not be, since UNION I A could still be finite.*) |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
303 |
lemma (in comm_monoid_add) setsum_UN_disjoint: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
304 |
assumes "finite I" and "ALL i:I. finite (A i)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
305 |
and "ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
306 |
shows "setsum f (UNION I A) = (\<Sum>i\<in>I. setsum f (A i))" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
307 |
proof - |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
308 |
interpret comm_monoid_mult "op +" 0 by (fact comm_monoid_mult) |
41550 | 309 |
from assms show ?thesis by (simp add: setsum_def fold_image_UN_disjoint) |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
310 |
qed |
15402 | 311 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
312 |
text{*No need to assume that @{term C} is finite. If infinite, the rhs is |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
313 |
directly 0, and @{term "Union C"} is also infinite, hence the lhs is also 0.*} |
15402 | 314 |
lemma setsum_Union_disjoint: |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
315 |
"[| (ALL A:C. finite A); |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
316 |
(ALL A:C. ALL B:C. A \<noteq> B --> A Int B = {}) |] |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
317 |
==> setsum f (Union C) = setsum (setsum f) C" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
318 |
apply (cases "finite C") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
319 |
prefer 2 apply (force dest: finite_UnionD simp add: setsum_def) |
15402 | 320 |
apply (frule setsum_UN_disjoint [of C id f]) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
321 |
apply (unfold Union_def id_def, assumption+) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
322 |
done |
15402 | 323 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
324 |
(*But we can't get rid of finite A. If infinite, although the lhs is 0, |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
325 |
the rhs need not be, since SIGMA A B could still be finite.*) |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
326 |
lemma (in comm_monoid_add) setsum_Sigma: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
327 |
assumes "finite A" and "ALL x:A. finite (B x)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
328 |
shows "(\<Sum>x\<in>A. (\<Sum>y\<in>B x. f x y)) = (\<Sum>(x,y)\<in>(SIGMA x:A. B x). f x y)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
329 |
proof - |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
330 |
interpret comm_monoid_mult "op +" 0 by (fact comm_monoid_mult) |
41550 | 331 |
from assms show ?thesis by (simp add: setsum_def fold_image_Sigma split_def) |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
332 |
qed |
15402 | 333 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
334 |
text{*Here we can eliminate the finiteness assumptions, by cases.*} |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
335 |
lemma setsum_cartesian_product: |
17189 | 336 |
"(\<Sum>x\<in>A. (\<Sum>y\<in>B. f x y)) = (\<Sum>(x,y) \<in> A <*> B. f x y)" |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
337 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
338 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
339 |
apply (simp add: setsum_Sigma) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
340 |
apply (cases "A={}", simp) |
15543 | 341 |
apply (simp) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
342 |
apply (auto simp add: setsum_def |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
343 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
344 |
done |
15402 | 345 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
346 |
lemma (in comm_monoid_add) setsum_addf: "setsum (%x. f x + g x) A = (setsum f A + setsum g A)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
347 |
by (cases "finite A") (simp_all add: setsum.distrib) |
15402 | 348 |
|
349 |
||
350 |
subsubsection {* Properties in more restricted classes of structures *} |
|
351 |
||
352 |
lemma setsum_SucD: "setsum f A = Suc n ==> EX a:A. 0 < f a" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
353 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
354 |
prefer 2 apply (simp add: setsum_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
355 |
apply (erule rev_mp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
356 |
apply (erule finite_induct, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
357 |
done |
15402 | 358 |
|
359 |
lemma setsum_eq_0_iff [simp]: |
|
360 |
"finite F ==> (setsum f F = 0) = (ALL a:F. f a = (0::nat))" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
361 |
by (induct set: finite) auto |
15402 | 362 |
|
30859 | 363 |
lemma setsum_eq_Suc0_iff: "finite A \<Longrightarrow> |
364 |
(setsum f A = Suc 0) = (EX a:A. f a = Suc 0 & (ALL b:A. a\<noteq>b \<longrightarrow> f b = 0))" |
|
365 |
apply(erule finite_induct) |
|
366 |
apply (auto simp add:add_is_1) |
|
367 |
done |
|
368 |
||
369 |
lemmas setsum_eq_1_iff = setsum_eq_Suc0_iff[simplified One_nat_def[symmetric]] |
|
370 |
||
15402 | 371 |
lemma setsum_Un_nat: "finite A ==> finite B ==> |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
372 |
(setsum f (A Un B) :: nat) = setsum f A + setsum f B - setsum f (A Int B)" |
15402 | 373 |
-- {* For the natural numbers, we have subtraction. *} |
29667 | 374 |
by (subst setsum_Un_Int [symmetric], auto simp add: algebra_simps) |
15402 | 375 |
|
376 |
lemma setsum_Un: "finite A ==> finite B ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
377 |
(setsum f (A Un B) :: 'a :: ab_group_add) = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
378 |
setsum f A + setsum f B - setsum f (A Int B)" |
29667 | 379 |
by (subst setsum_Un_Int [symmetric], auto simp add: algebra_simps) |
15402 | 380 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
381 |
lemma (in comm_monoid_add) setsum_eq_general_reverses: |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
382 |
assumes fS: "finite S" and fT: "finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
383 |
and kh: "\<And>y. y \<in> T \<Longrightarrow> k y \<in> S \<and> h (k y) = y" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
384 |
and hk: "\<And>x. x \<in> S \<Longrightarrow> h x \<in> T \<and> k (h x) = x \<and> g (h x) = f x" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
385 |
shows "setsum f S = setsum g T" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
386 |
proof - |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
387 |
interpret comm_monoid_mult "op +" 0 by (fact comm_monoid_mult) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
388 |
show ?thesis |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
389 |
apply (simp add: setsum_def fS fT) |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
390 |
apply (rule fold_image_eq_general_inverses) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
391 |
apply (rule fS) |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
392 |
apply (erule kh) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
393 |
apply (erule hk) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
394 |
done |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
395 |
qed |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
396 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
397 |
lemma (in comm_monoid_add) setsum_Un_zero: |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
398 |
assumes fS: "finite S" and fT: "finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
399 |
and I0: "\<forall>x \<in> S\<inter>T. f x = 0" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
400 |
shows "setsum f (S \<union> T) = setsum f S + setsum f T" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
401 |
proof - |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
402 |
interpret comm_monoid_mult "op +" 0 by (fact comm_monoid_mult) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
403 |
show ?thesis |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
404 |
using fS fT |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
405 |
apply (simp add: setsum_def) |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
406 |
apply (rule fold_image_Un_one) |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
407 |
using I0 by auto |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
408 |
qed |
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
409 |
|
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
410 |
lemma setsum_UNION_zero: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
411 |
assumes fS: "finite S" and fSS: "\<forall>T \<in> S. finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
412 |
and f0: "\<And>T1 T2 x. T1\<in>S \<Longrightarrow> T2\<in>S \<Longrightarrow> T1 \<noteq> T2 \<Longrightarrow> x \<in> T1 \<Longrightarrow> x \<in> T2 \<Longrightarrow> f x = 0" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
413 |
shows "setsum f (\<Union>S) = setsum (\<lambda>T. setsum f T) S" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
414 |
using fSS f0 |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
415 |
proof(induct rule: finite_induct[OF fS]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
416 |
case 1 thus ?case by simp |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
417 |
next |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
418 |
case (2 T F) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
419 |
then have fTF: "finite T" "\<forall>T\<in>F. finite T" "finite F" and TF: "T \<notin> F" |
35216 | 420 |
and H: "setsum f (\<Union> F) = setsum (setsum f) F" by auto |
421 |
from fTF have fUF: "finite (\<Union>F)" by auto |
|
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
422 |
from "2.prems" TF fTF |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
423 |
show ?case |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
424 |
by (auto simp add: H[symmetric] intro: setsum_Un_zero[OF fTF(1) fUF, of f]) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
425 |
qed |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
426 |
|
15402 | 427 |
lemma setsum_diff1_nat: "(setsum f (A - {a}) :: nat) = |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
428 |
(if a:A then setsum f A - f a else setsum f A)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
429 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
430 |
prefer 2 apply (simp add: setsum_def) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
431 |
apply (erule finite_induct) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
432 |
apply (auto simp add: insert_Diff_if) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
433 |
apply (drule_tac a = a in mk_disjoint_insert, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
434 |
done |
15402 | 435 |
|
436 |
lemma setsum_diff1: "finite A \<Longrightarrow> |
|
437 |
(setsum f (A - {a}) :: ('a::ab_group_add)) = |
|
438 |
(if a:A then setsum f A - f a else setsum f A)" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
439 |
by (erule finite_induct) (auto simp add: insert_Diff_if) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
440 |
|
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
441 |
lemma setsum_diff1'[rule_format]: |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
442 |
"finite A \<Longrightarrow> a \<in> A \<longrightarrow> (\<Sum> x \<in> A. f x) = f a + (\<Sum> x \<in> (A - {a}). f x)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
443 |
apply (erule finite_induct[where F=A and P="% A. (a \<in> A \<longrightarrow> (\<Sum> x \<in> A. f x) = f a + (\<Sum> x \<in> (A - {a}). f x))"]) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
444 |
apply (auto simp add: insert_Diff_if add_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
445 |
done |
15552
8ab8e425410b
added setsum_diff1' which holds in more general cases than setsum_diff1
obua
parents:
15543
diff
changeset
|
446 |
|
31438 | 447 |
lemma setsum_diff1_ring: assumes "finite A" "a \<in> A" |
448 |
shows "setsum f (A - {a}) = setsum f A - (f a::'a::ring)" |
|
449 |
unfolding setsum_diff1'[OF assms] by auto |
|
450 |
||
15402 | 451 |
(* By Jeremy Siek: *) |
452 |
||
453 |
lemma setsum_diff_nat: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
454 |
assumes "finite B" and "B \<subseteq> A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
455 |
shows "(setsum f (A - B) :: nat) = (setsum f A) - (setsum f B)" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
456 |
using assms |
19535 | 457 |
proof induct |
15402 | 458 |
show "setsum f (A - {}) = (setsum f A) - (setsum f {})" by simp |
459 |
next |
|
460 |
fix F x assume finF: "finite F" and xnotinF: "x \<notin> F" |
|
461 |
and xFinA: "insert x F \<subseteq> A" |
|
462 |
and IH: "F \<subseteq> A \<Longrightarrow> setsum f (A - F) = setsum f A - setsum f F" |
|
463 |
from xnotinF xFinA have xinAF: "x \<in> (A - F)" by simp |
|
464 |
from xinAF have A: "setsum f ((A - F) - {x}) = setsum f (A - F) - f x" |
|
465 |
by (simp add: setsum_diff1_nat) |
|
466 |
from xFinA have "F \<subseteq> A" by simp |
|
467 |
with IH have "setsum f (A - F) = setsum f A - setsum f F" by simp |
|
468 |
with A have B: "setsum f ((A - F) - {x}) = setsum f A - setsum f F - f x" |
|
469 |
by simp |
|
470 |
from xnotinF have "A - insert x F = (A - F) - {x}" by auto |
|
471 |
with B have C: "setsum f (A - insert x F) = setsum f A - setsum f F - f x" |
|
472 |
by simp |
|
473 |
from finF xnotinF have "setsum f (insert x F) = setsum f F + f x" by simp |
|
474 |
with C have "setsum f (A - insert x F) = setsum f A - setsum f (insert x F)" |
|
475 |
by simp |
|
476 |
thus "setsum f (A - insert x F) = setsum f A - setsum f (insert x F)" by simp |
|
477 |
qed |
|
478 |
||
479 |
lemma setsum_diff: |
|
480 |
assumes le: "finite A" "B \<subseteq> A" |
|
481 |
shows "setsum f (A - B) = setsum f A - ((setsum f B)::('a::ab_group_add))" |
|
482 |
proof - |
|
483 |
from le have finiteB: "finite B" using finite_subset by auto |
|
484 |
show ?thesis using finiteB le |
|
21575 | 485 |
proof induct |
19535 | 486 |
case empty |
487 |
thus ?case by auto |
|
488 |
next |
|
489 |
case (insert x F) |
|
490 |
thus ?case using le finiteB |
|
491 |
by (simp add: Diff_insert[where a=x and B=F] setsum_diff1 insert_absorb) |
|
15402 | 492 |
qed |
19535 | 493 |
qed |
15402 | 494 |
|
495 |
lemma setsum_mono: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
496 |
assumes le: "\<And>i. i\<in>K \<Longrightarrow> f (i::'a) \<le> ((g i)::('b::{comm_monoid_add, ordered_ab_semigroup_add}))" |
15402 | 497 |
shows "(\<Sum>i\<in>K. f i) \<le> (\<Sum>i\<in>K. g i)" |
498 |
proof (cases "finite K") |
|
499 |
case True |
|
500 |
thus ?thesis using le |
|
19535 | 501 |
proof induct |
15402 | 502 |
case empty |
503 |
thus ?case by simp |
|
504 |
next |
|
505 |
case insert |
|
19535 | 506 |
thus ?case using add_mono by fastsimp |
15402 | 507 |
qed |
508 |
next |
|
509 |
case False |
|
510 |
thus ?thesis |
|
511 |
by (simp add: setsum_def) |
|
512 |
qed |
|
513 |
||
15554 | 514 |
lemma setsum_strict_mono: |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
515 |
fixes f :: "'a \<Rightarrow> 'b::{ordered_cancel_ab_semigroup_add,comm_monoid_add}" |
19535 | 516 |
assumes "finite A" "A \<noteq> {}" |
517 |
and "!!x. x:A \<Longrightarrow> f x < g x" |
|
518 |
shows "setsum f A < setsum g A" |
|
41550 | 519 |
using assms |
15554 | 520 |
proof (induct rule: finite_ne_induct) |
521 |
case singleton thus ?case by simp |
|
522 |
next |
|
523 |
case insert thus ?case by (auto simp: add_strict_mono) |
|
524 |
qed |
|
525 |
||
15535 | 526 |
lemma setsum_negf: |
19535 | 527 |
"setsum (%x. - (f x)::'a::ab_group_add) A = - setsum f A" |
15535 | 528 |
proof (cases "finite A") |
22262 | 529 |
case True thus ?thesis by (induct set: finite) auto |
15535 | 530 |
next |
531 |
case False thus ?thesis by (simp add: setsum_def) |
|
532 |
qed |
|
15402 | 533 |
|
15535 | 534 |
lemma setsum_subtractf: |
19535 | 535 |
"setsum (%x. ((f x)::'a::ab_group_add) - g x) A = |
536 |
setsum f A - setsum g A" |
|
15535 | 537 |
proof (cases "finite A") |
538 |
case True thus ?thesis by (simp add: diff_minus setsum_addf setsum_negf) |
|
539 |
next |
|
540 |
case False thus ?thesis by (simp add: setsum_def) |
|
541 |
qed |
|
15402 | 542 |
|
15535 | 543 |
lemma setsum_nonneg: |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
544 |
assumes nn: "\<forall>x\<in>A. (0::'a::{ordered_ab_semigroup_add,comm_monoid_add}) \<le> f x" |
19535 | 545 |
shows "0 \<le> setsum f A" |
15535 | 546 |
proof (cases "finite A") |
547 |
case True thus ?thesis using nn |
|
21575 | 548 |
proof induct |
19535 | 549 |
case empty then show ?case by simp |
550 |
next |
|
551 |
case (insert x F) |
|
552 |
then have "0 + 0 \<le> f x + setsum f F" by (blast intro: add_mono) |
|
553 |
with insert show ?case by simp |
|
554 |
qed |
|
15535 | 555 |
next |
556 |
case False thus ?thesis by (simp add: setsum_def) |
|
557 |
qed |
|
15402 | 558 |
|
15535 | 559 |
lemma setsum_nonpos: |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
560 |
assumes np: "\<forall>x\<in>A. f x \<le> (0::'a::{ordered_ab_semigroup_add,comm_monoid_add})" |
19535 | 561 |
shows "setsum f A \<le> 0" |
15535 | 562 |
proof (cases "finite A") |
563 |
case True thus ?thesis using np |
|
21575 | 564 |
proof induct |
19535 | 565 |
case empty then show ?case by simp |
566 |
next |
|
567 |
case (insert x F) |
|
568 |
then have "f x + setsum f F \<le> 0 + 0" by (blast intro: add_mono) |
|
569 |
with insert show ?case by simp |
|
570 |
qed |
|
15535 | 571 |
next |
572 |
case False thus ?thesis by (simp add: setsum_def) |
|
573 |
qed |
|
15402 | 574 |
|
36622
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
575 |
lemma setsum_nonneg_leq_bound: |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
576 |
fixes f :: "'a \<Rightarrow> 'b::{ordered_ab_group_add}" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
577 |
assumes "finite s" "\<And>i. i \<in> s \<Longrightarrow> f i \<ge> 0" "(\<Sum>i \<in> s. f i) = B" "i \<in> s" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
578 |
shows "f i \<le> B" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
579 |
proof - |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
580 |
have "0 \<le> (\<Sum> i \<in> s - {i}. f i)" and "0 \<le> f i" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
581 |
using assms by (auto intro!: setsum_nonneg) |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
582 |
moreover |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
583 |
have "(\<Sum> i \<in> s - {i}. f i) + f i = B" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
584 |
using assms by (simp add: setsum_diff1) |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
585 |
ultimately show ?thesis by auto |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
586 |
qed |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
587 |
|
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
588 |
lemma setsum_nonneg_0: |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
589 |
fixes f :: "'a \<Rightarrow> 'b::{ordered_ab_group_add}" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
590 |
assumes "finite s" and pos: "\<And> i. i \<in> s \<Longrightarrow> f i \<ge> 0" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
591 |
and "(\<Sum> i \<in> s. f i) = 0" and i: "i \<in> s" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
592 |
shows "f i = 0" |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
593 |
using setsum_nonneg_leq_bound[OF assms] pos[OF i] by auto |
e393a91f86df
Generalize swap_inj_on; add simps for Times; add Ex_list_of_length, log_inj; Added missing locale edges for linordered semiring with 1.
hoelzl
parents:
36409
diff
changeset
|
594 |
|
15539 | 595 |
lemma setsum_mono2: |
36303 | 596 |
fixes f :: "'a \<Rightarrow> 'b :: ordered_comm_monoid_add" |
15539 | 597 |
assumes fin: "finite B" and sub: "A \<subseteq> B" and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b" |
598 |
shows "setsum f A \<le> setsum f B" |
|
599 |
proof - |
|
600 |
have "setsum f A \<le> setsum f A + setsum f (B-A)" |
|
601 |
by(simp add: add_increasing2[OF setsum_nonneg] nn Ball_def) |
|
602 |
also have "\<dots> = setsum f (A \<union> (B-A))" using fin finite_subset[OF sub fin] |
|
603 |
by (simp add:setsum_Un_disjoint del:Un_Diff_cancel) |
|
604 |
also have "A \<union> (B-A) = B" using sub by blast |
|
605 |
finally show ?thesis . |
|
606 |
qed |
|
15542 | 607 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
608 |
lemma setsum_mono3: "finite B ==> A <= B ==> |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
609 |
ALL x: B - A. |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
610 |
0 <= ((f x)::'a::{comm_monoid_add,ordered_ab_semigroup_add}) ==> |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
611 |
setsum f A <= setsum f B" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
612 |
apply (subgoal_tac "setsum f B = setsum f A + setsum f (B - A)") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
613 |
apply (erule ssubst) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
614 |
apply (subgoal_tac "setsum f A + 0 <= setsum f A + setsum f (B - A)") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
615 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
616 |
apply (rule add_left_mono) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
617 |
apply (erule setsum_nonneg) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
618 |
apply (subst setsum_Un_disjoint [THEN sym]) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
619 |
apply (erule finite_subset, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
620 |
apply (rule finite_subset) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
621 |
prefer 2 |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
622 |
apply assumption |
32698
be4b248616c0
inf/sup_absorb are no default simp rules any longer
haftmann
parents:
32697
diff
changeset
|
623 |
apply (auto simp add: sup_absorb2) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
624 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
625 |
|
19279 | 626 |
lemma setsum_right_distrib: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
627 |
fixes f :: "'a => ('b::semiring_0)" |
15402 | 628 |
shows "r * setsum f A = setsum (%n. r * f n) A" |
629 |
proof (cases "finite A") |
|
630 |
case True |
|
631 |
thus ?thesis |
|
21575 | 632 |
proof induct |
15402 | 633 |
case empty thus ?case by simp |
634 |
next |
|
635 |
case (insert x A) thus ?case by (simp add: right_distrib) |
|
636 |
qed |
|
637 |
next |
|
638 |
case False thus ?thesis by (simp add: setsum_def) |
|
639 |
qed |
|
640 |
||
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
641 |
lemma setsum_left_distrib: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
642 |
"setsum f A * (r::'a::semiring_0) = (\<Sum>n\<in>A. f n * r)" |
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
643 |
proof (cases "finite A") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
644 |
case True |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
645 |
then show ?thesis |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
646 |
proof induct |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
647 |
case empty thus ?case by simp |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
648 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
649 |
case (insert x A) thus ?case by (simp add: left_distrib) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
650 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
651 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
652 |
case False thus ?thesis by (simp add: setsum_def) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
653 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
654 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
655 |
lemma setsum_divide_distrib: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
656 |
"setsum f A / (r::'a::field) = (\<Sum>n\<in>A. f n / r)" |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
657 |
proof (cases "finite A") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
658 |
case True |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
659 |
then show ?thesis |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
660 |
proof induct |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
661 |
case empty thus ?case by simp |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
662 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
663 |
case (insert x A) thus ?case by (simp add: add_divide_distrib) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
664 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
665 |
next |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
666 |
case False thus ?thesis by (simp add: setsum_def) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
667 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
668 |
|
15535 | 669 |
lemma setsum_abs[iff]: |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
670 |
fixes f :: "'a => ('b::ordered_ab_group_add_abs)" |
15402 | 671 |
shows "abs (setsum f A) \<le> setsum (%i. abs(f i)) A" |
15535 | 672 |
proof (cases "finite A") |
673 |
case True |
|
674 |
thus ?thesis |
|
21575 | 675 |
proof induct |
15535 | 676 |
case empty thus ?case by simp |
677 |
next |
|
678 |
case (insert x A) |
|
679 |
thus ?case by (auto intro: abs_triangle_ineq order_trans) |
|
680 |
qed |
|
15402 | 681 |
next |
15535 | 682 |
case False thus ?thesis by (simp add: setsum_def) |
15402 | 683 |
qed |
684 |
||
15535 | 685 |
lemma setsum_abs_ge_zero[iff]: |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
686 |
fixes f :: "'a => ('b::ordered_ab_group_add_abs)" |
15402 | 687 |
shows "0 \<le> setsum (%i. abs(f i)) A" |
15535 | 688 |
proof (cases "finite A") |
689 |
case True |
|
690 |
thus ?thesis |
|
21575 | 691 |
proof induct |
15535 | 692 |
case empty thus ?case by simp |
693 |
next |
|
36977
71c8973a604b
declare add_nonneg_nonneg [simp]; remove now-redundant lemmas realpow_two_le_order(2)
huffman
parents:
36635
diff
changeset
|
694 |
case (insert x A) thus ?case by auto |
15535 | 695 |
qed |
15402 | 696 |
next |
15535 | 697 |
case False thus ?thesis by (simp add: setsum_def) |
15402 | 698 |
qed |
699 |
||
15539 | 700 |
lemma abs_setsum_abs[simp]: |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
701 |
fixes f :: "'a => ('b::ordered_ab_group_add_abs)" |
15539 | 702 |
shows "abs (\<Sum>a\<in>A. abs(f a)) = (\<Sum>a\<in>A. abs(f a))" |
703 |
proof (cases "finite A") |
|
704 |
case True |
|
705 |
thus ?thesis |
|
21575 | 706 |
proof induct |
15539 | 707 |
case empty thus ?case by simp |
708 |
next |
|
709 |
case (insert a A) |
|
710 |
hence "\<bar>\<Sum>a\<in>insert a A. \<bar>f a\<bar>\<bar> = \<bar>\<bar>f a\<bar> + (\<Sum>a\<in>A. \<bar>f a\<bar>)\<bar>" by simp |
|
711 |
also have "\<dots> = \<bar>\<bar>f a\<bar> + \<bar>\<Sum>a\<in>A. \<bar>f a\<bar>\<bar>\<bar>" using insert by simp |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
712 |
also have "\<dots> = \<bar>f a\<bar> + \<bar>\<Sum>a\<in>A. \<bar>f a\<bar>\<bar>" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16760
diff
changeset
|
713 |
by (simp del: abs_of_nonneg) |
15539 | 714 |
also have "\<dots> = (\<Sum>a\<in>insert a A. \<bar>f a\<bar>)" using insert by simp |
715 |
finally show ?case . |
|
716 |
qed |
|
717 |
next |
|
718 |
case False thus ?thesis by (simp add: setsum_def) |
|
719 |
qed |
|
720 |
||
31080 | 721 |
lemma setsum_Plus: |
722 |
fixes A :: "'a set" and B :: "'b set" |
|
723 |
assumes fin: "finite A" "finite B" |
|
724 |
shows "setsum f (A <+> B) = setsum (f \<circ> Inl) A + setsum (f \<circ> Inr) B" |
|
725 |
proof - |
|
726 |
have "A <+> B = Inl ` A \<union> Inr ` B" by auto |
|
727 |
moreover from fin have "finite (Inl ` A :: ('a + 'b) set)" "finite (Inr ` B :: ('a + 'b) set)" |
|
40786
0a54cfc9add3
gave more standard finite set rules simp and intro attribute
nipkow
parents:
39302
diff
changeset
|
728 |
by auto |
31080 | 729 |
moreover have "Inl ` A \<inter> Inr ` B = ({} :: ('a + 'b) set)" by auto |
730 |
moreover have "inj_on (Inl :: 'a \<Rightarrow> 'a + 'b) A" "inj_on (Inr :: 'b \<Rightarrow> 'a + 'b) B" by(auto intro: inj_onI) |
|
731 |
ultimately show ?thesis using fin by(simp add: setsum_Un_disjoint setsum_reindex) |
|
732 |
qed |
|
733 |
||
734 |
||
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
735 |
text {* Commuting outer and inner summation *} |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
736 |
|
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
737 |
lemma setsum_commute: |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
738 |
"(\<Sum>i\<in>A. \<Sum>j\<in>B. f i j) = (\<Sum>j\<in>B. \<Sum>i\<in>A. f i j)" |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
739 |
proof (simp add: setsum_cartesian_product) |
17189 | 740 |
have "(\<Sum>(x,y) \<in> A <*> B. f x y) = |
741 |
(\<Sum>(y,x) \<in> (%(i, j). (j, i)) ` (A \<times> B). f x y)" |
|
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
742 |
(is "?s = _") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
743 |
apply (simp add: setsum_reindex [where f = "%(i, j). (j, i)"] swap_inj_on) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
744 |
apply (simp add: split_def) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
745 |
done |
17189 | 746 |
also have "... = (\<Sum>(y,x)\<in>B \<times> A. f x y)" |
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
747 |
(is "_ = ?t") |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
748 |
apply (simp add: swap_product) |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
749 |
done |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
750 |
finally show "?s = ?t" . |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
751 |
qed |
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
752 |
|
19279 | 753 |
lemma setsum_product: |
22934
64ecb3d6790a
generalize setsum lemmas from semiring_0_cancel to semiring_0
huffman
parents:
22917
diff
changeset
|
754 |
fixes f :: "'a => ('b::semiring_0)" |
19279 | 755 |
shows "setsum f A * setsum g B = (\<Sum>i\<in>A. \<Sum>j\<in>B. f i * g j)" |
756 |
by (simp add: setsum_right_distrib setsum_left_distrib) (rule setsum_commute) |
|
757 |
||
34223 | 758 |
lemma setsum_mult_setsum_if_inj: |
759 |
fixes f :: "'a => ('b::semiring_0)" |
|
760 |
shows "inj_on (%(a,b). f a * g b) (A \<times> B) ==> |
|
761 |
setsum f A * setsum g B = setsum id {f a * g b|a b. a:A & b:B}" |
|
762 |
by(auto simp: setsum_product setsum_cartesian_product |
|
763 |
intro!: setsum_reindex_cong[symmetric]) |
|
764 |
||
35722
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
765 |
lemma setsum_constant [simp]: "(\<Sum>x \<in> A. y) = of_nat(card A) * y" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
766 |
apply (cases "finite A") |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
767 |
apply (erule finite_induct) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
768 |
apply (auto simp add: algebra_simps) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
769 |
done |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
770 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
771 |
lemma setsum_bounded: |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
772 |
assumes le: "\<And>i. i\<in>A \<Longrightarrow> f i \<le> (K::'a::{semiring_1, ordered_ab_semigroup_add})" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
773 |
shows "setsum f A \<le> of_nat(card A) * K" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
774 |
proof (cases "finite A") |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
775 |
case True |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
776 |
thus ?thesis using le setsum_mono[where K=A and g = "%x. K"] by simp |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
777 |
next |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
778 |
case False thus ?thesis by (simp add: setsum_def) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
779 |
qed |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
780 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
781 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
782 |
subsubsection {* Cardinality as special case of @{const setsum} *} |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
783 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
784 |
lemma card_eq_setsum: |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
785 |
"card A = setsum (\<lambda>x. 1) A" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
786 |
by (simp only: card_def setsum_def) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
787 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
788 |
lemma card_UN_disjoint: |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
789 |
"finite I ==> (ALL i:I. finite (A i)) ==> |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
790 |
(ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
791 |
==> card (UNION I A) = (\<Sum>i\<in>I. card(A i))" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
792 |
apply (simp add: card_eq_setsum del: setsum_constant) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
793 |
apply (subgoal_tac |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
794 |
"setsum (%i. card (A i)) I = setsum (%i. (setsum (%x. 1) (A i))) I") |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
795 |
apply (simp add: setsum_UN_disjoint del: setsum_constant) |
41550 | 796 |
apply simp |
35722
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
797 |
done |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
798 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
799 |
lemma card_Union_disjoint: |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
800 |
"finite C ==> (ALL A:C. finite A) ==> |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
801 |
(ALL A:C. ALL B:C. A \<noteq> B --> A Int B = {}) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
802 |
==> card (Union C) = setsum card C" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
803 |
apply (frule card_UN_disjoint [of C id]) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
804 |
apply (unfold Union_def id_def, assumption+) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
805 |
done |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
806 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
807 |
text{*The image of a finite set can be expressed using @{term fold_image}.*} |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
808 |
lemma image_eq_fold_image: |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
809 |
"finite A ==> f ` A = fold_image (op Un) (%x. {f x}) {} A" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
810 |
proof (induct rule: finite_induct) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
811 |
case empty then show ?case by simp |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
812 |
next |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
813 |
interpret ab_semigroup_mult "op Un" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
814 |
proof qed auto |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
815 |
case insert |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
816 |
then show ?case by simp |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
817 |
qed |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
818 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
819 |
subsubsection {* Cardinality of products *} |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
820 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
821 |
lemma card_SigmaI [simp]: |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
822 |
"\<lbrakk> finite A; ALL a:A. finite (B a) \<rbrakk> |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
823 |
\<Longrightarrow> card (SIGMA x: A. B x) = (\<Sum>a\<in>A. card (B a))" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
824 |
by(simp add: card_eq_setsum setsum_Sigma del:setsum_constant) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
825 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
826 |
(* |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
827 |
lemma SigmaI_insert: "y \<notin> A ==> |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
828 |
(SIGMA x:(insert y A). B x) = (({y} <*> (B y)) \<union> (SIGMA x: A. B x))" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
829 |
by auto |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
830 |
*) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
831 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
832 |
lemma card_cartesian_product: "card (A <*> B) = card(A) * card(B)" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
833 |
by (cases "finite A \<and> finite B") |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
834 |
(auto simp add: card_eq_0_iff dest: finite_cartesian_productD1 finite_cartesian_productD2) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
835 |
|
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
836 |
lemma card_cartesian_product_singleton: "card({x} <*> A) = card(A)" |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
837 |
by (simp add: card_cartesian_product) |
69419a09a7ff
moved cardinality to Finite_Set as far as appropriate; added locales for fold_image
haftmann
parents:
35719
diff
changeset
|
838 |
|
17149
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents:
17085
diff
changeset
|
839 |
|
15402 | 840 |
subsection {* Generalized product over a set *} |
841 |
||
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
842 |
definition (in comm_monoid_mult) setprod :: "('b \<Rightarrow> 'a) => 'b set => 'a" where |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
843 |
"setprod f A = (if finite A then fold_image (op *) f 1 A else 1)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
844 |
|
35938
93faaa15c3d5
sublocale comm_monoid_add < setprod --> sublocale comm_monoid_mult < setprod
huffman
parents:
35831
diff
changeset
|
845 |
sublocale comm_monoid_mult < setprod!: comm_monoid_big "op *" 1 setprod proof |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
846 |
qed (fact setprod_def) |
15402 | 847 |
|
19535 | 848 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21249
diff
changeset
|
849 |
Setprod ("\<Prod>_" [1000] 999) where |
19535 | 850 |
"\<Prod>A == setprod (%x. x) A" |
851 |
||
15402 | 852 |
syntax |
17189 | 853 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3PROD _:_. _)" [0, 51, 10] 10) |
15402 | 854 |
syntax (xsymbols) |
17189 | 855 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
15402 | 856 |
syntax (HTML output) |
17189 | 857 |
"_setprod" :: "pttrn => 'a set => 'b => 'b::comm_monoid_mult" ("(3\<Prod>_\<in>_. _)" [0, 51, 10] 10) |
16550 | 858 |
|
859 |
translations -- {* Beware of argument permutation! *} |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
860 |
"PROD i:A. b" == "CONST setprod (%i. b) A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
861 |
"\<Prod>i\<in>A. b" == "CONST setprod (%i. b) A" |
16550 | 862 |
|
863 |
text{* Instead of @{term"\<Prod>x\<in>{x. P}. e"} we introduce the shorter |
|
864 |
@{text"\<Prod>x|P. e"}. *} |
|
865 |
||
866 |
syntax |
|
17189 | 867 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3PROD _ |/ _./ _)" [0,0,10] 10) |
16550 | 868 |
syntax (xsymbols) |
17189 | 869 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
16550 | 870 |
syntax (HTML output) |
17189 | 871 |
"_qsetprod" :: "pttrn \<Rightarrow> bool \<Rightarrow> 'a \<Rightarrow> 'a" ("(3\<Prod>_ | (_)./ _)" [0,0,10] 10) |
16550 | 872 |
|
15402 | 873 |
translations |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
874 |
"PROD x|P. t" => "CONST setprod (%x. t) {x. P}" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
875 |
"\<Prod>x|P. t" => "CONST setprod (%x. t) {x. P}" |
16550 | 876 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
877 |
lemma setprod_empty: "setprod f {} = 1" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
878 |
by (fact setprod.empty) |
15402 | 879 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
880 |
lemma setprod_insert: "[| finite A; a \<notin> A |] ==> |
15402 | 881 |
setprod f (insert a A) = f a * setprod f A" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
882 |
by (fact setprod.insert) |
15402 | 883 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
884 |
lemma setprod_infinite: "~ finite A ==> setprod f A = 1" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
885 |
by (fact setprod.infinite) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
886 |
|
15402 | 887 |
lemma setprod_reindex: |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
888 |
"inj_on f B ==> setprod h (f ` B) = setprod (h \<circ> f) B" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
889 |
by(auto simp: setprod_def fold_image_reindex dest!:finite_imageD) |
15402 | 890 |
|
891 |
lemma setprod_reindex_id: "inj_on f B ==> setprod f B = setprod id (f ` B)" |
|
892 |
by (auto simp add: setprod_reindex) |
|
893 |
||
894 |
lemma setprod_cong: |
|
895 |
"A = B ==> (!!x. x:B ==> f x = g x) ==> setprod f A = setprod g B" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
896 |
by(fastsimp simp: setprod_def intro: fold_image_cong) |
15402 | 897 |
|
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
898 |
lemma strong_setprod_cong[cong]: |
16632
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
899 |
"A = B ==> (!!x. x:B =simp=> f x = g x) ==> setprod f A = setprod g B" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
900 |
by(fastsimp simp: simp_implies_def setprod_def intro: fold_image_cong) |
16632
ad2895beef79
Added strong_setsum_cong and strong_setprod_cong.
berghofe
parents:
16550
diff
changeset
|
901 |
|
15402 | 902 |
lemma setprod_reindex_cong: "inj_on f A ==> |
903 |
B = f ` A ==> g = h \<circ> f ==> setprod h B = setprod g A" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
904 |
by (frule setprod_reindex, simp) |
15402 | 905 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
906 |
lemma strong_setprod_reindex_cong: assumes i: "inj_on f A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
907 |
and B: "B = f ` A" and eq: "\<And>x. x \<in> A \<Longrightarrow> g x = (h \<circ> f) x" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
908 |
shows "setprod h B = setprod g A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
909 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
910 |
have "setprod h B = setprod (h o f) A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
911 |
by (simp add: B setprod_reindex[OF i, of h]) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
912 |
then show ?thesis apply simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
913 |
apply (rule setprod_cong) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
914 |
apply simp |
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
915 |
by (simp add: eq) |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
916 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
917 |
|
30260
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
918 |
lemma setprod_Un_one: |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
919 |
assumes fS: "finite S" and fT: "finite T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
920 |
and I0: "\<forall>x \<in> S\<inter>T. f x = 1" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
921 |
shows "setprod f (S \<union> T) = setprod f S * setprod f T" |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
922 |
using fS fT |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
923 |
apply (simp add: setprod_def) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
924 |
apply (rule fold_image_Un_one) |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
925 |
using I0 by auto |
be39acd3ac85
Added general theorems for fold_image, setsum and set_prod
chaieb
parents:
29966
diff
changeset
|
926 |
|
15402 | 927 |
|
928 |
lemma setprod_1: "setprod (%i. 1) A = 1" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
929 |
apply (case_tac "finite A") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
930 |
apply (erule finite_induct, auto simp add: mult_ac) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
931 |
done |
15402 | 932 |
|
933 |
lemma setprod_1': "ALL a:F. f a = 1 ==> setprod f F = 1" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
934 |
apply (subgoal_tac "setprod f F = setprod (%x. 1) F") |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
935 |
apply (erule ssubst, rule setprod_1) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
936 |
apply (rule setprod_cong, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
937 |
done |
15402 | 938 |
|
939 |
lemma setprod_Un_Int: "finite A ==> finite B |
|
940 |
==> setprod g (A Un B) * setprod g (A Int B) = setprod g A * setprod g B" |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
941 |
by(simp add: setprod_def fold_image_Un_Int[symmetric]) |
15402 | 942 |
|
943 |
lemma setprod_Un_disjoint: "finite A ==> finite B |
|
944 |
==> A Int B = {} ==> setprod g (A Un B) = setprod g A * setprod g B" |
|
945 |
by (subst setprod_Un_Int [symmetric], auto) |
|
946 |
||
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
947 |
lemma setprod_mono_one_left: |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
948 |
assumes fT: "finite T" and ST: "S \<subseteq> T" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
949 |
and z: "\<forall>i \<in> T - S. f i = 1" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
950 |
shows "setprod f S = setprod f T" |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
951 |
proof- |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
952 |
have eq: "T = S \<union> (T - S)" using ST by blast |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
953 |
have d: "S \<inter> (T - S) = {}" using ST by blast |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
954 |
from fT ST have f: "finite S" "finite (T - S)" by (auto intro: finite_subset) |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
955 |
show ?thesis |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
956 |
by (simp add: setprod_Un_disjoint[OF f d, unfolded eq[symmetric]] setprod_1'[OF z]) |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
957 |
qed |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
958 |
|
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
959 |
lemmas setprod_mono_one_right = setprod_mono_one_left [THEN sym] |
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30729
diff
changeset
|
960 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
961 |
lemma setprod_delta: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
962 |
assumes fS: "finite S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
963 |
shows "setprod (\<lambda>k. if k=a then b k else 1) S = (if a \<in> S then b a else 1)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
964 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
965 |
let ?f = "(\<lambda>k. if k=a then b k else 1)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
966 |
{assume a: "a \<notin> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
967 |
hence "\<forall> k\<in> S. ?f k = 1" by simp |
41550 | 968 |
hence ?thesis using a by (simp add: setprod_1) } |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
969 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
970 |
{assume a: "a \<in> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
971 |
let ?A = "S - {a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
972 |
let ?B = "{a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
973 |
have eq: "S = ?A \<union> ?B" using a by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
974 |
have dj: "?A \<inter> ?B = {}" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
975 |
from fS have fAB: "finite ?A" "finite ?B" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
976 |
have fA1: "setprod ?f ?A = 1" apply (rule setprod_1') by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
977 |
have "setprod ?f ?A * setprod ?f ?B = setprod ?f S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
978 |
using setprod_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
979 |
by simp |
41550 | 980 |
then have ?thesis using a by (simp add: fA1 cong: setprod_cong cong del: if_weak_cong)} |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
981 |
ultimately show ?thesis by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
982 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
983 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
984 |
lemma setprod_delta': |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
985 |
assumes fS: "finite S" shows |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
986 |
"setprod (\<lambda>k. if a = k then b k else 1) S = |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
987 |
(if a\<in> S then b a else 1)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
988 |
using setprod_delta[OF fS, of a b, symmetric] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
989 |
by (auto intro: setprod_cong) |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
990 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
991 |
|
15402 | 992 |
lemma setprod_UN_disjoint: |
993 |
"finite I ==> (ALL i:I. finite (A i)) ==> |
|
994 |
(ALL i:I. ALL j:I. i \<noteq> j --> A i Int A j = {}) ==> |
|
995 |
setprod f (UNION I A) = setprod (%i. setprod f (A i)) I" |
|
41550 | 996 |
by (simp add: setprod_def fold_image_UN_disjoint) |
15402 | 997 |
|
998 |
lemma setprod_Union_disjoint: |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
999 |
"[| (ALL A:C. finite A); |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1000 |
(ALL A:C. ALL B:C. A \<noteq> B --> A Int B = {}) |] |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1001 |
==> setprod f (Union C) = setprod (setprod f) C" |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1002 |
apply (cases "finite C") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1003 |
prefer 2 apply (force dest: finite_UnionD simp add: setprod_def) |
15402 | 1004 |
apply (frule setprod_UN_disjoint [of C id f]) |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1005 |
apply (unfold Union_def id_def, assumption+) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1006 |
done |
15402 | 1007 |
|
1008 |
lemma setprod_Sigma: "finite A ==> ALL x:A. finite (B x) ==> |
|
16550 | 1009 |
(\<Prod>x\<in>A. (\<Prod>y\<in> B x. f x y)) = |
17189 | 1010 |
(\<Prod>(x,y)\<in>(SIGMA x:A. B x). f x y)" |
41550 | 1011 |
by(simp add:setprod_def fold_image_Sigma split_def) |
15402 | 1012 |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1013 |
text{*Here we can eliminate the finiteness assumptions, by cases.*} |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1014 |
lemma setprod_cartesian_product: |
17189 | 1015 |
"(\<Prod>x\<in>A. (\<Prod>y\<in> B. f x y)) = (\<Prod>(x,y)\<in>(A <*> B). f x y)" |
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1016 |
apply (cases "finite A") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1017 |
apply (cases "finite B") |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1018 |
apply (simp add: setprod_Sigma) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1019 |
apply (cases "A={}", simp) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1020 |
apply (simp add: setprod_1) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1021 |
apply (auto simp add: setprod_def |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1022 |
dest: finite_cartesian_productD1 finite_cartesian_productD2) |
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1023 |
done |
15402 | 1024 |
|
1025 |
lemma setprod_timesf: |
|
15409
a063687d24eb
new and stronger lemmas and improved simplification for finite sets
paulson
parents:
15402
diff
changeset
|
1026 |
"setprod (%x. f x * g x) A = (setprod f A * setprod g A)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1027 |
by(simp add:setprod_def fold_image_distrib) |
15402 | 1028 |
|
1029 |
||
1030 |
subsubsection {* Properties in more restricted classes of structures *} |
|
1031 |
||
1032 |
lemma setprod_eq_1_iff [simp]: |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1033 |
"finite F ==> (setprod f F = 1) = (ALL a:F. f a = (1::nat))" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1034 |
by (induct set: finite) auto |
15402 | 1035 |
|
1036 |
lemma setprod_zero: |
|
23277 | 1037 |
"finite A ==> EX x: A. f x = (0::'a::comm_semiring_1) ==> setprod f A = 0" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1038 |
apply (induct set: finite, force, clarsimp) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1039 |
apply (erule disjE, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1040 |
done |
15402 | 1041 |
|
1042 |
lemma setprod_nonneg [rule_format]: |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1043 |
"(ALL x: A. (0::'a::linordered_semidom) \<le> f x) --> 0 \<le> setprod f A" |
30841
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1044 |
by (cases "finite A", induct set: finite, simp_all add: mult_nonneg_nonneg) |
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1045 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1046 |
lemma setprod_pos [rule_format]: "(ALL x: A. (0::'a::linordered_semidom) < f x) |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1047 |
--> 0 < setprod f A" |
30841
0813afc97522
generalized setprod_nonneg and setprod_pos to ordered_semidom, simplified proofs
huffman
parents:
30729
diff
changeset
|
1048 |
by (cases "finite A", induct set: finite, simp_all add: mult_pos_pos) |
15402 | 1049 |
|
30843 | 1050 |
lemma setprod_zero_iff[simp]: "finite A ==> |
1051 |
(setprod f A = (0::'a::{comm_semiring_1,no_zero_divisors})) = |
|
1052 |
(EX x: A. f x = 0)" |
|
1053 |
by (erule finite_induct, auto simp:no_zero_divisors) |
|
1054 |
||
1055 |
lemma setprod_pos_nat: |
|
1056 |
"finite S ==> (ALL x : S. f x > (0::nat)) ==> setprod f S > 0" |
|
1057 |
using setprod_zero_iff by(simp del:neq0_conv add:neq0_conv[symmetric]) |
|
15402 | 1058 |
|
30863 | 1059 |
lemma setprod_pos_nat_iff[simp]: |
1060 |
"finite S ==> (setprod f S > 0) = (ALL x : S. f x > (0::nat))" |
|
1061 |
using setprod_zero_iff by(simp del:neq0_conv add:neq0_conv[symmetric]) |
|
1062 |
||
15402 | 1063 |
lemma setprod_Un: "finite A ==> finite B ==> (ALL x: A Int B. f x \<noteq> 0) ==> |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1064 |
(setprod f (A Un B) :: 'a ::{field}) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1065 |
= setprod f A * setprod f B / setprod f (A Int B)" |
30843 | 1066 |
by (subst setprod_Un_Int [symmetric], auto) |
15402 | 1067 |
|
1068 |
lemma setprod_diff1: "finite A ==> f a \<noteq> 0 ==> |
|
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1069 |
(setprod f (A - {a}) :: 'a :: {field}) = |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1070 |
(if a:A then setprod f A / f a else setprod f A)" |
36303 | 1071 |
by (erule finite_induct) (auto simp add: insert_Diff_if) |
15402 | 1072 |
|
31906
b41d61c768e2
Removed unnecessary conditions concerning nonzero divisors
paulson
parents:
31465
diff
changeset
|
1073 |
lemma setprod_inversef: |
36409 | 1074 |
fixes f :: "'b \<Rightarrow> 'a::field_inverse_zero" |
31906
b41d61c768e2
Removed unnecessary conditions concerning nonzero divisors
paulson
parents:
31465
diff
changeset
|
1075 |
shows "finite A ==> setprod (inverse \<circ> f) A = inverse (setprod f A)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1076 |
by (erule finite_induct) auto |
15402 | 1077 |
|
1078 |
lemma setprod_dividef: |
|
36409 | 1079 |
fixes f :: "'b \<Rightarrow> 'a::field_inverse_zero" |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1080 |
shows "finite A |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1081 |
==> setprod (%x. f x / g x) A = setprod f A / setprod g A" |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1082 |
apply (subgoal_tac |
15402 | 1083 |
"setprod (%x. f x / g x) A = setprod (%x. f x * (inverse \<circ> g) x) A") |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1084 |
apply (erule ssubst) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1085 |
apply (subst divide_inverse) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1086 |
apply (subst setprod_timesf) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1087 |
apply (subst setprod_inversef, assumption+, rule refl) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1088 |
apply (rule setprod_cong, rule refl) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1089 |
apply (subst divide_inverse, auto) |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1090 |
done |
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1091 |
|
29925 | 1092 |
lemma setprod_dvd_setprod [rule_format]: |
1093 |
"(ALL x : A. f x dvd g x) \<longrightarrow> setprod f A dvd setprod g A" |
|
1094 |
apply (cases "finite A") |
|
1095 |
apply (induct set: finite) |
|
1096 |
apply (auto simp add: dvd_def) |
|
1097 |
apply (rule_tac x = "k * ka" in exI) |
|
1098 |
apply (simp add: algebra_simps) |
|
1099 |
done |
|
1100 |
||
1101 |
lemma setprod_dvd_setprod_subset: |
|
1102 |
"finite B \<Longrightarrow> A <= B \<Longrightarrow> setprod f A dvd setprod f B" |
|
1103 |
apply (subgoal_tac "setprod f B = setprod f A * setprod f (B - A)") |
|
1104 |
apply (unfold dvd_def, blast) |
|
1105 |
apply (subst setprod_Un_disjoint [symmetric]) |
|
1106 |
apply (auto elim: finite_subset intro: setprod_cong) |
|
1107 |
done |
|
1108 |
||
1109 |
lemma setprod_dvd_setprod_subset2: |
|
1110 |
"finite B \<Longrightarrow> A <= B \<Longrightarrow> ALL x : A. (f x::'a::comm_semiring_1) dvd g x \<Longrightarrow> |
|
1111 |
setprod f A dvd setprod g B" |
|
1112 |
apply (rule dvd_trans) |
|
1113 |
apply (rule setprod_dvd_setprod, erule (1) bspec) |
|
1114 |
apply (erule (1) setprod_dvd_setprod_subset) |
|
1115 |
done |
|
1116 |
||
1117 |
lemma dvd_setprod: "finite A \<Longrightarrow> i:A \<Longrightarrow> |
|
1118 |
(f i ::'a::comm_semiring_1) dvd setprod f A" |
|
1119 |
by (induct set: finite) (auto intro: dvd_mult) |
|
1120 |
||
1121 |
lemma dvd_setsum [rule_format]: "(ALL i : A. d dvd f i) \<longrightarrow> |
|
1122 |
(d::'a::comm_semiring_1) dvd (SUM x : A. f x)" |
|
1123 |
apply (cases "finite A") |
|
1124 |
apply (induct set: finite) |
|
1125 |
apply auto |
|
1126 |
done |
|
1127 |
||
35171
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1128 |
lemma setprod_mono: |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1129 |
fixes f :: "'a \<Rightarrow> 'b\<Colon>linordered_semidom" |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1130 |
assumes "\<forall>i\<in>A. 0 \<le> f i \<and> f i \<le> g i" |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1131 |
shows "setprod f A \<le> setprod g A" |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1132 |
proof (cases "finite A") |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1133 |
case True |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1134 |
hence ?thesis "setprod f A \<ge> 0" using subset_refl[of A] |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1135 |
proof (induct A rule: finite_subset_induct) |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1136 |
case (insert a F) |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1137 |
thus "setprod f (insert a F) \<le> setprod g (insert a F)" "0 \<le> setprod f (insert a F)" |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1138 |
unfolding setprod_insert[OF insert(1,3)] |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1139 |
using assms[rule_format,OF insert(2)] insert |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1140 |
by (auto intro: mult_mono mult_nonneg_nonneg) |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1141 |
qed auto |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1142 |
thus ?thesis by simp |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1143 |
qed auto |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1144 |
|
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1145 |
lemma abs_setprod: |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1146 |
fixes f :: "'a \<Rightarrow> 'b\<Colon>{linordered_field,abs}" |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1147 |
shows "abs (setprod f A) = setprod (\<lambda>x. abs (f x)) A" |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1148 |
proof (cases "finite A") |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1149 |
case True thus ?thesis |
35216 | 1150 |
by induct (auto simp add: field_simps abs_mult) |
35171
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1151 |
qed auto |
28f824c7addc
Moved setprod_mono, abs_setprod and setsum_le_included to the Main image. Is used in Multivariate_Analysis.
hoelzl
parents:
35115
diff
changeset
|
1152 |
|
31017 | 1153 |
lemma setprod_constant: "finite A ==> (\<Prod>x\<in> A. (y::'a::{comm_monoid_mult})) = y^(card A)" |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1154 |
apply (erule finite_induct) |
35216 | 1155 |
apply auto |
28853
69eb69659bf3
Added new fold operator and renamed the old oe to fold_image.
nipkow
parents:
28823
diff
changeset
|
1156 |
done |
15402 | 1157 |
|
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1158 |
lemma setprod_gen_delta: |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1159 |
assumes fS: "finite S" |
31017 | 1160 |
shows "setprod (\<lambda>k. if k=a then b k else c) S = (if a \<in> S then (b a ::'a::{comm_monoid_mult}) * c^ (card S - 1) else c^ card S)" |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1161 |
proof- |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1162 |
let ?f = "(\<lambda>k. if k=a then b k else c)" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1163 |
{assume a: "a \<notin> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1164 |
hence "\<forall> k\<in> S. ?f k = c" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1165 |
hence ?thesis using a setprod_constant[OF fS, of c] by (simp add: setprod_1 cong add: setprod_cong) } |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1166 |
moreover |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1167 |
{assume a: "a \<in> S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1168 |
let ?A = "S - {a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1169 |
let ?B = "{a}" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1170 |
have eq: "S = ?A \<union> ?B" using a by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1171 |
have dj: "?A \<inter> ?B = {}" by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1172 |
from fS have fAB: "finite ?A" "finite ?B" by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1173 |
have fA0:"setprod ?f ?A = setprod (\<lambda>i. c) ?A" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1174 |
apply (rule setprod_cong) by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1175 |
have cA: "card ?A = card S - 1" using fS a by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1176 |
have fA1: "setprod ?f ?A = c ^ card ?A" unfolding fA0 apply (rule setprod_constant) using fS by auto |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1177 |
have "setprod ?f ?A * setprod ?f ?B = setprod ?f S" |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1178 |
using setprod_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]] |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1179 |
by simp |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1180 |
then have ?thesis using a cA |
36349 | 1181 |
by (simp add: fA1 field_simps cong add: setprod_cong cong del: if_weak_cong)} |
29674
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1182 |
ultimately show ?thesis by blast |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1183 |
qed |
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1184 |
|
3857d7eba390
Added theorems setsum_reindex_nonzero, setsum_mono_zero_left, setsum_mono_zero_right, setsum_mono_zero_cong_left, setsum_mono_zero_cong_right, setsum_delta, strong_setprod_reindex_cong, setprod_delta
chaieb
parents:
29609
diff
changeset
|
1185 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1186 |
subsection {* Versions of @{const inf} and @{const sup} on non-empty sets *} |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1187 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1188 |
no_notation times (infixl "*" 70) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1189 |
no_notation Groups.one ("1") |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1190 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1191 |
locale semilattice_big = semilattice + |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1192 |
fixes F :: "'a set \<Rightarrow> 'a" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1193 |
assumes F_eq: "finite A \<Longrightarrow> F A = fold1 (op *) A" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1194 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1195 |
sublocale semilattice_big < folding_one_idem proof |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1196 |
qed (simp_all add: F_eq) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1197 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1198 |
notation times (infixl "*" 70) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1199 |
notation Groups.one ("1") |
22917 | 1200 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1201 |
context lattice |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1202 |
begin |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1203 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1204 |
definition Inf_fin :: "'a set \<Rightarrow> 'a" ("\<Sqinter>\<^bsub>fin\<^esub>_" [900] 900) where |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1205 |
"Inf_fin = fold1 inf" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1206 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1207 |
definition Sup_fin :: "'a set \<Rightarrow> 'a" ("\<Squnion>\<^bsub>fin\<^esub>_" [900] 900) where |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1208 |
"Sup_fin = fold1 sup" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1209 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1210 |
end |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1211 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1212 |
sublocale lattice < Inf_fin!: semilattice_big inf Inf_fin proof |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1213 |
qed (simp add: Inf_fin_def) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1214 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1215 |
sublocale lattice < Sup_fin!: semilattice_big sup Sup_fin proof |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1216 |
qed (simp add: Sup_fin_def) |
22917 | 1217 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1218 |
context semilattice_inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1219 |
begin |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1220 |
|
36635
080b755377c0
locale predicates of classes carry a mandatory "class" prefix
haftmann
parents:
36622
diff
changeset
|
1221 |
lemma ab_semigroup_idem_mult_inf: |
080b755377c0
locale predicates of classes carry a mandatory "class" prefix
haftmann
parents:
36622
diff
changeset
|
1222 |
"class.ab_semigroup_idem_mult inf" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1223 |
proof qed (rule inf_assoc inf_commute inf_idem)+ |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1224 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1225 |
lemma fold_inf_insert[simp]: "finite A \<Longrightarrow> fold inf b (insert a A) = inf a (fold inf b A)" |
42871
1c0b99f950d9
names of fold_set locales resemble name of characteristic property more closely
haftmann
parents:
42284
diff
changeset
|
1226 |
by(rule comp_fun_idem.fold_insert_idem[OF ab_semigroup_idem_mult.comp_fun_idem[OF ab_semigroup_idem_mult_inf]]) |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1227 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1228 |
lemma inf_le_fold_inf: "finite A \<Longrightarrow> ALL a:A. b \<le> a \<Longrightarrow> inf b c \<le> fold inf c A" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1229 |
by (induct pred: finite) (auto intro: le_infI1) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1230 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1231 |
lemma fold_inf_le_inf: "finite A \<Longrightarrow> a \<in> A \<Longrightarrow> fold inf b A \<le> inf a b" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1232 |
proof(induct arbitrary: a pred:finite) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1233 |
case empty thus ?case by simp |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1234 |
next |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1235 |
case (insert x A) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1236 |
show ?case |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1237 |
proof cases |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1238 |
assume "A = {}" thus ?thesis using insert by simp |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1239 |
next |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1240 |
assume "A \<noteq> {}" thus ?thesis using insert by (auto intro: le_infI2) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1241 |
qed |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1242 |
qed |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1243 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1244 |
lemma below_fold1_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1245 |
assumes "finite A" "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1246 |
shows "x \<le> fold1 inf A \<longleftrightarrow> (\<forall>a\<in>A. x \<le> a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1247 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1248 |
interpret ab_semigroup_idem_mult inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1249 |
by (rule ab_semigroup_idem_mult_inf) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1250 |
show ?thesis using assms by (induct rule: finite_ne_induct) simp_all |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1251 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1252 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1253 |
lemma fold1_belowI: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1254 |
assumes "finite A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1255 |
and "a \<in> A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1256 |
shows "fold1 inf A \<le> a" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1257 |
proof - |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1258 |
from assms have "A \<noteq> {}" by auto |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1259 |
from `finite A` `A \<noteq> {}` `a \<in> A` show ?thesis |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1260 |
proof (induct rule: finite_ne_induct) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1261 |
case singleton thus ?case by simp |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1262 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1263 |
interpret ab_semigroup_idem_mult inf |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1264 |
by (rule ab_semigroup_idem_mult_inf) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1265 |
case (insert x F) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1266 |
from insert(5) have "a = x \<or> a \<in> F" by simp |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1267 |
thus ?case |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1268 |
proof |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1269 |
assume "a = x" thus ?thesis using insert |
29667 | 1270 |
by (simp add: mult_ac) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1271 |
next |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1272 |
assume "a \<in> F" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1273 |
hence bel: "fold1 inf F \<le> a" by (rule insert) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1274 |
have "inf (fold1 inf (insert x F)) a = inf x (inf (fold1 inf F) a)" |
29667 | 1275 |
using insert by (simp add: mult_ac) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1276 |
also have "inf (fold1 inf F) a = fold1 inf F" |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1277 |
using bel by (auto intro: antisym) |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1278 |
also have "inf x \<dots> = fold1 inf (insert x F)" |
29667 | 1279 |
using insert by (simp add: mult_ac) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1280 |
finally have aux: "inf (fold1 inf (insert x F)) a = fold1 inf (insert x F)" . |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1281 |
moreover have "inf (fold1 inf (insert x F)) a \<le> a" by simp |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1282 |
ultimately show ?thesis by simp |
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1283 |
qed |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1284 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1285 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1286 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1287 |
end |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1288 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1289 |
context semilattice_sup |
22917 | 1290 |
begin |
1291 |
||
36635
080b755377c0
locale predicates of classes carry a mandatory "class" prefix
haftmann
parents:
36622
diff
changeset
|
1292 |
lemma ab_semigroup_idem_mult_sup: "class.ab_semigroup_idem_mult sup" |
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1293 |
by (rule semilattice_inf.ab_semigroup_idem_mult_inf)(rule dual_semilattice) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1294 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1295 |
lemma fold_sup_insert[simp]: "finite A \<Longrightarrow> fold sup b (insert a A) = sup a (fold sup b A)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1296 |
by(rule semilattice_inf.fold_inf_insert)(rule dual_semilattice) |
22917 | 1297 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1298 |
lemma fold_sup_le_sup: "finite A \<Longrightarrow> ALL a:A. a \<le> b \<Longrightarrow> fold sup c A \<le> sup b c" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1299 |
by(rule semilattice_inf.inf_le_fold_inf)(rule dual_semilattice) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1300 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1301 |
lemma sup_le_fold_sup: "finite A \<Longrightarrow> a \<in> A \<Longrightarrow> sup a b \<le> fold sup b A" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1302 |
by(rule semilattice_inf.fold_inf_le_inf)(rule dual_semilattice) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1303 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1304 |
end |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1305 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1306 |
context lattice |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1307 |
begin |
25062 | 1308 |
|
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1309 |
lemma Inf_le_Sup [simp]: "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> \<Sqinter>\<^bsub>fin\<^esub>A \<le> \<Squnion>\<^bsub>fin\<^esub>A" |
24342 | 1310 |
apply(unfold Sup_fin_def Inf_fin_def) |
15500 | 1311 |
apply(subgoal_tac "EX a. a:A") |
1312 |
prefer 2 apply blast |
|
1313 |
apply(erule exE) |
|
22388 | 1314 |
apply(rule order_trans) |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1315 |
apply(erule (1) fold1_belowI) |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1316 |
apply(erule (1) semilattice_inf.fold1_belowI [OF dual_semilattice]) |
15500 | 1317 |
done |
1318 |
||
24342 | 1319 |
lemma sup_Inf_absorb [simp]: |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1320 |
"finite A \<Longrightarrow> a \<in> A \<Longrightarrow> sup a (\<Sqinter>\<^bsub>fin\<^esub>A) = a" |
15512
ed1fa4617f52
Extracted generic lattice stuff to new Lattice_Locales.thy
nipkow
parents:
15510
diff
changeset
|
1321 |
apply(subst sup_commute) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1322 |
apply(simp add: Inf_fin_def sup_absorb2 fold1_belowI) |
15504 | 1323 |
done |
1324 |
||
24342 | 1325 |
lemma inf_Sup_absorb [simp]: |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1326 |
"finite A \<Longrightarrow> a \<in> A \<Longrightarrow> inf a (\<Squnion>\<^bsub>fin\<^esub>A) = a" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1327 |
by (simp add: Sup_fin_def inf_absorb1 |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1328 |
semilattice_inf.fold1_belowI [OF dual_semilattice]) |
24342 | 1329 |
|
1330 |
end |
|
1331 |
||
1332 |
context distrib_lattice |
|
1333 |
begin |
|
1334 |
||
1335 |
lemma sup_Inf1_distrib: |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1336 |
assumes "finite A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1337 |
and "A \<noteq> {}" |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1338 |
shows "sup x (\<Sqinter>\<^bsub>fin\<^esub>A) = \<Sqinter>\<^bsub>fin\<^esub>{sup x a|a. a \<in> A}" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1339 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1340 |
interpret ab_semigroup_idem_mult inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1341 |
by (rule ab_semigroup_idem_mult_inf) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1342 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1343 |
by (simp add: Inf_fin_def image_def |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1344 |
hom_fold1_commute [where h="sup x", OF sup_inf_distrib1]) |
26792 | 1345 |
(rule arg_cong [where f="fold1 inf"], blast) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1346 |
qed |
18423 | 1347 |
|
24342 | 1348 |
lemma sup_Inf2_distrib: |
1349 |
assumes A: "finite A" "A \<noteq> {}" and B: "finite B" "B \<noteq> {}" |
|
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1350 |
shows "sup (\<Sqinter>\<^bsub>fin\<^esub>A) (\<Sqinter>\<^bsub>fin\<^esub>B) = \<Sqinter>\<^bsub>fin\<^esub>{sup a b|a b. a \<in> A \<and> b \<in> B}" |
24342 | 1351 |
using A proof (induct rule: finite_ne_induct) |
15500 | 1352 |
case singleton thus ?case |
41550 | 1353 |
by (simp add: sup_Inf1_distrib [OF B]) |
15500 | 1354 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1355 |
interpret ab_semigroup_idem_mult inf |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1356 |
by (rule ab_semigroup_idem_mult_inf) |
15500 | 1357 |
case (insert x A) |
25062 | 1358 |
have finB: "finite {sup x b |b. b \<in> B}" |
1359 |
by(rule finite_surj[where f = "sup x", OF B(1)], auto) |
|
1360 |
have finAB: "finite {sup a b |a b. a \<in> A \<and> b \<in> B}" |
|
15500 | 1361 |
proof - |
25062 | 1362 |
have "{sup a b |a b. a \<in> A \<and> b \<in> B} = (UN a:A. UN b:B. {sup a b})" |
15500 | 1363 |
by blast |
15517 | 1364 |
thus ?thesis by(simp add: insert(1) B(1)) |
15500 | 1365 |
qed |
25062 | 1366 |
have ne: "{sup a b |a b. a \<in> A \<and> b \<in> B} \<noteq> {}" using insert B by blast |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1367 |
have "sup (\<Sqinter>\<^bsub>fin\<^esub>(insert x A)) (\<Sqinter>\<^bsub>fin\<^esub>B) = sup (inf x (\<Sqinter>\<^bsub>fin\<^esub>A)) (\<Sqinter>\<^bsub>fin\<^esub>B)" |
41550 | 1368 |
using insert by simp |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1369 |
also have "\<dots> = inf (sup x (\<Sqinter>\<^bsub>fin\<^esub>B)) (sup (\<Sqinter>\<^bsub>fin\<^esub>A) (\<Sqinter>\<^bsub>fin\<^esub>B))" by(rule sup_inf_distrib2) |
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1370 |
also have "\<dots> = inf (\<Sqinter>\<^bsub>fin\<^esub>{sup x b|b. b \<in> B}) (\<Sqinter>\<^bsub>fin\<^esub>{sup a b|a b. a \<in> A \<and> b \<in> B})" |
15500 | 1371 |
using insert by(simp add:sup_Inf1_distrib[OF B]) |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1372 |
also have "\<dots> = \<Sqinter>\<^bsub>fin\<^esub>({sup x b |b. b \<in> B} \<union> {sup a b |a b. a \<in> A \<and> b \<in> B})" |
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1373 |
(is "_ = \<Sqinter>\<^bsub>fin\<^esub>?M") |
15500 | 1374 |
using B insert |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1375 |
by (simp add: Inf_fin_def fold1_Un2 [OF finB _ finAB ne]) |
25062 | 1376 |
also have "?M = {sup a b |a b. a \<in> insert x A \<and> b \<in> B}" |
15500 | 1377 |
by blast |
1378 |
finally show ?case . |
|
1379 |
qed |
|
1380 |
||
24342 | 1381 |
lemma inf_Sup1_distrib: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1382 |
assumes "finite A" and "A \<noteq> {}" |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1383 |
shows "inf x (\<Squnion>\<^bsub>fin\<^esub>A) = \<Squnion>\<^bsub>fin\<^esub>{inf x a|a. a \<in> A}" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1384 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1385 |
interpret ab_semigroup_idem_mult sup |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1386 |
by (rule ab_semigroup_idem_mult_sup) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1387 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1388 |
by (simp add: Sup_fin_def image_def hom_fold1_commute [where h="inf x", OF inf_sup_distrib1]) |
26792 | 1389 |
(rule arg_cong [where f="fold1 sup"], blast) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1390 |
qed |
18423 | 1391 |
|
24342 | 1392 |
lemma inf_Sup2_distrib: |
1393 |
assumes A: "finite A" "A \<noteq> {}" and B: "finite B" "B \<noteq> {}" |
|
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1394 |
shows "inf (\<Squnion>\<^bsub>fin\<^esub>A) (\<Squnion>\<^bsub>fin\<^esub>B) = \<Squnion>\<^bsub>fin\<^esub>{inf a b|a b. a \<in> A \<and> b \<in> B}" |
24342 | 1395 |
using A proof (induct rule: finite_ne_induct) |
18423 | 1396 |
case singleton thus ?case |
24342 | 1397 |
by(simp add: inf_Sup1_distrib [OF B] fold1_singleton_def [OF Sup_fin_def]) |
18423 | 1398 |
next |
1399 |
case (insert x A) |
|
25062 | 1400 |
have finB: "finite {inf x b |b. b \<in> B}" |
1401 |
by(rule finite_surj[where f = "%b. inf x b", OF B(1)], auto) |
|
1402 |
have finAB: "finite {inf a b |a b. a \<in> A \<and> b \<in> B}" |
|
18423 | 1403 |
proof - |
25062 | 1404 |
have "{inf a b |a b. a \<in> A \<and> b \<in> B} = (UN a:A. UN b:B. {inf a b})" |
18423 | 1405 |
by blast |
1406 |
thus ?thesis by(simp add: insert(1) B(1)) |
|
1407 |
qed |
|
25062 | 1408 |
have ne: "{inf a b |a b. a \<in> A \<and> b \<in> B} \<noteq> {}" using insert B by blast |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1409 |
interpret ab_semigroup_idem_mult sup |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1410 |
by (rule ab_semigroup_idem_mult_sup) |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1411 |
have "inf (\<Squnion>\<^bsub>fin\<^esub>(insert x A)) (\<Squnion>\<^bsub>fin\<^esub>B) = inf (sup x (\<Squnion>\<^bsub>fin\<^esub>A)) (\<Squnion>\<^bsub>fin\<^esub>B)" |
41550 | 1412 |
using insert by simp |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1413 |
also have "\<dots> = sup (inf x (\<Squnion>\<^bsub>fin\<^esub>B)) (inf (\<Squnion>\<^bsub>fin\<^esub>A) (\<Squnion>\<^bsub>fin\<^esub>B))" by(rule inf_sup_distrib2) |
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1414 |
also have "\<dots> = sup (\<Squnion>\<^bsub>fin\<^esub>{inf x b|b. b \<in> B}) (\<Squnion>\<^bsub>fin\<^esub>{inf a b|a b. a \<in> A \<and> b \<in> B})" |
18423 | 1415 |
using insert by(simp add:inf_Sup1_distrib[OF B]) |
31916
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1416 |
also have "\<dots> = \<Squnion>\<^bsub>fin\<^esub>({inf x b |b. b \<in> B} \<union> {inf a b |a b. a \<in> A \<and> b \<in> B})" |
f3227bb306a4
recovered subscripts, which were lost in b41d61c768e2 (due to Emacs accident?);
wenzelm
parents:
31907
diff
changeset
|
1417 |
(is "_ = \<Squnion>\<^bsub>fin\<^esub>?M") |
18423 | 1418 |
using B insert |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1419 |
by (simp add: Sup_fin_def fold1_Un2 [OF finB _ finAB ne]) |
25062 | 1420 |
also have "?M = {inf a b |a b. a \<in> insert x A \<and> b \<in> B}" |
18423 | 1421 |
by blast |
1422 |
finally show ?case . |
|
1423 |
qed |
|
1424 |
||
24342 | 1425 |
end |
1426 |
||
35719
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1427 |
context complete_lattice |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1428 |
begin |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1429 |
|
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1430 |
lemma Inf_fin_Inf: |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1431 |
assumes "finite A" and "A \<noteq> {}" |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1432 |
shows "\<Sqinter>\<^bsub>fin\<^esub>A = Inf A" |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1433 |
proof - |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1434 |
interpret ab_semigroup_idem_mult inf |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1435 |
by (rule ab_semigroup_idem_mult_inf) |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1436 |
from `A \<noteq> {}` obtain b B where "A = insert b B" by auto |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1437 |
moreover with `finite A` have "finite B" by simp |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1438 |
ultimately show ?thesis |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1439 |
by (simp add: Inf_fin_def fold1_eq_fold_idem inf_Inf_fold_inf [symmetric]) |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1440 |
(simp add: Inf_fold_inf) |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1441 |
qed |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1442 |
|
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1443 |
lemma Sup_fin_Sup: |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1444 |
assumes "finite A" and "A \<noteq> {}" |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1445 |
shows "\<Squnion>\<^bsub>fin\<^esub>A = Sup A" |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1446 |
proof - |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1447 |
interpret ab_semigroup_idem_mult sup |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1448 |
by (rule ab_semigroup_idem_mult_sup) |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1449 |
from `A \<noteq> {}` obtain b B where "A = insert b B" by auto |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1450 |
moreover with `finite A` have "finite B" by simp |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1451 |
ultimately show ?thesis |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1452 |
by (simp add: Sup_fin_def fold1_eq_fold_idem sup_Sup_fold_sup [symmetric]) |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1453 |
(simp add: Sup_fold_sup) |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1454 |
qed |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1455 |
|
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1456 |
end |
99b6152aedf5
split off theory Big_Operators from theory Finite_Set
haftmann
parents:
35577
diff
changeset
|
1457 |
|
22917 | 1458 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1459 |
subsection {* Versions of @{const min} and @{const max} on non-empty sets *} |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1460 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1461 |
definition (in linorder) Min :: "'a set \<Rightarrow> 'a" where |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1462 |
"Min = fold1 min" |
22917 | 1463 |
|
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1464 |
definition (in linorder) Max :: "'a set \<Rightarrow> 'a" where |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1465 |
"Max = fold1 max" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1466 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1467 |
sublocale linorder < Min!: semilattice_big min Min proof |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1468 |
qed (simp add: Min_def) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1469 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1470 |
sublocale linorder < Max!: semilattice_big max Max proof |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1471 |
qed (simp add: Max_def) |
22917 | 1472 |
|
24342 | 1473 |
context linorder |
22917 | 1474 |
begin |
1475 |
||
35816
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1476 |
lemmas Min_singleton = Min.singleton |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1477 |
lemmas Max_singleton = Max.singleton |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1478 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1479 |
lemma Min_insert: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1480 |
assumes "finite A" and "A \<noteq> {}" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1481 |
shows "Min (insert x A) = min x (Min A)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1482 |
using assms by simp |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1483 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1484 |
lemma Max_insert: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1485 |
assumes "finite A" and "A \<noteq> {}" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1486 |
shows "Max (insert x A) = max x (Max A)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1487 |
using assms by simp |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1488 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1489 |
lemma Min_Un: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1490 |
assumes "finite A" and "A \<noteq> {}" and "finite B" and "B \<noteq> {}" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1491 |
shows "Min (A \<union> B) = min (Min A) (Min B)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1492 |
using assms by (rule Min.union_idem) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1493 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1494 |
lemma Max_Un: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1495 |
assumes "finite A" and "A \<noteq> {}" and "finite B" and "B \<noteq> {}" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1496 |
shows "Max (A \<union> B) = max (Max A) (Max B)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1497 |
using assms by (rule Max.union_idem) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1498 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1499 |
lemma hom_Min_commute: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1500 |
assumes "\<And>x y. h (min x y) = min (h x) (h y)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1501 |
and "finite N" and "N \<noteq> {}" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1502 |
shows "h (Min N) = Min (h ` N)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1503 |
using assms by (rule Min.hom_commute) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1504 |
|
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1505 |
lemma hom_Max_commute: |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1506 |
assumes "\<And>x y. h (max x y) = max (h x) (h y)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1507 |
and "finite N" and "N \<noteq> {}" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1508 |
shows "h (Max N) = Max (h ` N)" |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1509 |
using assms by (rule Max.hom_commute) |
2449e026483d
generic locale for big operators in monoids; dropped odd interpretation of comm_monoid_mult into comm_monoid_add
haftmann
parents:
35722
diff
changeset
|
1510 |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1511 |
lemma ab_semigroup_idem_mult_min: |
36635
080b755377c0
locale predicates of classes carry a mandatory "class" prefix
haftmann
parents:
36622
diff
changeset
|
1512 |
"class.ab_semigroup_idem_mult min" |
28823 | 1513 |
proof qed (auto simp add: min_def) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1514 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1515 |
lemma ab_semigroup_idem_mult_max: |
36635
080b755377c0
locale predicates of classes carry a mandatory "class" prefix
haftmann
parents:
36622
diff
changeset
|
1516 |
"class.ab_semigroup_idem_mult max" |
28823 | 1517 |
proof qed (auto simp add: max_def) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1518 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1519 |
lemma max_lattice: |
36635
080b755377c0
locale predicates of classes carry a mandatory "class" prefix
haftmann
parents:
36622
diff
changeset
|
1520 |
"class.semilattice_inf (op \<ge>) (op >) max" |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1521 |
by (fact min_max.dual_semilattice) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1522 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1523 |
lemma dual_max: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1524 |
"ord.max (op \<ge>) = min" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
1525 |
by (auto simp add: ord.max_def_raw min_def fun_eq_iff) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1526 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1527 |
lemma dual_min: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1528 |
"ord.min (op \<ge>) = max" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
1529 |
by (auto simp add: ord.min_def_raw max_def fun_eq_iff) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1530 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1531 |
lemma strict_below_fold1_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1532 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1533 |
shows "x < fold1 min A \<longleftrightarrow> (\<forall>a\<in>A. x < a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1534 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1535 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1536 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1537 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1538 |
by (induct rule: finite_ne_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1539 |
(simp_all add: fold1_insert) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1540 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1541 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1542 |
lemma fold1_below_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1543 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1544 |
shows "fold1 min A \<le> x \<longleftrightarrow> (\<exists>a\<in>A. a \<le> x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1545 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1546 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1547 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1548 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1549 |
by (induct rule: finite_ne_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1550 |
(simp_all add: fold1_insert min_le_iff_disj) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1551 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1552 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1553 |
lemma fold1_strict_below_iff: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1554 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1555 |
shows "fold1 min A < x \<longleftrightarrow> (\<exists>a\<in>A. a < x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1556 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1557 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1558 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1559 |
from assms show ?thesis |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1560 |
by (induct rule: finite_ne_induct) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1561 |
(simp_all add: fold1_insert min_less_iff_disj) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1562 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1563 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1564 |
lemma fold1_antimono: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1565 |
assumes "A \<noteq> {}" and "A \<subseteq> B" and "finite B" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1566 |
shows "fold1 min B \<le> fold1 min A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1567 |
proof cases |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1568 |
assume "A = B" thus ?thesis by simp |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1569 |
next |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1570 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1571 |
by (rule ab_semigroup_idem_mult_min) |
41550 | 1572 |
assume neq: "A \<noteq> B" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1573 |
have B: "B = A \<union> (B-A)" using `A \<subseteq> B` by blast |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1574 |
have "fold1 min B = fold1 min (A \<union> (B-A))" by(subst B)(rule refl) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1575 |
also have "\<dots> = min (fold1 min A) (fold1 min (B-A))" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1576 |
proof - |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1577 |
have "finite A" by(rule finite_subset[OF `A \<subseteq> B` `finite B`]) |
41550 | 1578 |
moreover have "finite(B-A)" by(rule finite_Diff[OF `finite B`]) |
1579 |
moreover have "(B-A) \<noteq> {}" using assms neq by blast |
|
1580 |
moreover have "A Int (B-A) = {}" using assms by blast |
|
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1581 |
ultimately show ?thesis using `A \<noteq> {}` by (rule_tac fold1_Un) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1582 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1583 |
also have "\<dots> \<le> fold1 min A" by (simp add: min_le_iff_disj) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1584 |
finally show ?thesis . |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1585 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1586 |
|
24427 | 1587 |
lemma Min_in [simp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1588 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1589 |
shows "Min A \<in> A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1590 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1591 |
interpret ab_semigroup_idem_mult min |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1592 |
by (rule ab_semigroup_idem_mult_min) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1593 |
from assms fold1_in show ?thesis by (fastsimp simp: Min_def min_def) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1594 |
qed |
15392 | 1595 |
|
24427 | 1596 |
lemma Max_in [simp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1597 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1598 |
shows "Max A \<in> A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1599 |
proof - |
29509
1ff0f3f08a7b
migrated class package to new locale implementation
haftmann
parents:
29223
diff
changeset
|
1600 |
interpret ab_semigroup_idem_mult max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1601 |
by (rule ab_semigroup_idem_mult_max) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1602 |
from assms fold1_in [of A] show ?thesis by (fastsimp simp: Max_def max_def) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1603 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1604 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1605 |
lemma Min_le [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1606 |
assumes "finite A" and "x \<in> A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1607 |
shows "Min A \<le> x" |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1608 |
using assms by (simp add: Min_def min_max.fold1_belowI) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1609 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1610 |
lemma Max_ge [simp]: |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1611 |
assumes "finite A" and "x \<in> A" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1612 |
shows "x \<le> Max A" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1613 |
proof - |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1614 |
interpret semilattice_inf "op \<ge>" "op >" max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1615 |
by (rule max_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1616 |
from assms show ?thesis by (simp add: Max_def fold1_belowI) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1617 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1618 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1619 |
lemma Min_ge_iff [simp, no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1620 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1621 |
shows "x \<le> Min A \<longleftrightarrow> (\<forall>a\<in>A. x \<le> a)" |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1622 |
using assms by (simp add: Min_def min_max.below_fold1_iff) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1623 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1624 |
lemma Max_le_iff [simp, no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1625 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1626 |
shows "Max A \<le> x \<longleftrightarrow> (\<forall>a\<in>A. a \<le> x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1627 |
proof - |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1628 |
interpret semilattice_inf "op \<ge>" "op >" max |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1629 |
by (rule max_lattice) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1630 |
from assms show ?thesis by (simp add: Max_def below_fold1_iff) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1631 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1632 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1633 |
lemma Min_gr_iff [simp, no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1634 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1635 |
shows "x < Min A \<longleftrightarrow> (\<forall>a\<in>A. x < a)" |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1636 |
using assms by (simp add: Min_def strict_below_fold1_iff) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1637 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1638 |
lemma Max_less_iff [simp, no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1639 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1640 |
shows "Max A < x \<longleftrightarrow> (\<forall>a\<in>A. a < x)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1641 |
proof - |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1642 |
interpret dual: linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1643 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1644 |
from assms show ?thesis |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1645 |
by (simp add: Max_def dual.strict_below_fold1_iff [folded dual.dual_max]) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1646 |
qed |
18493 | 1647 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1648 |
lemma Min_le_iff [no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1649 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1650 |
shows "Min A \<le> x \<longleftrightarrow> (\<exists>a\<in>A. a \<le> x)" |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1651 |
using assms by (simp add: Min_def fold1_below_iff) |
15497
53bca254719a
Added semi-lattice locales and reorganized fold1 lemmas
nipkow
parents:
15487
diff
changeset
|
1652 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1653 |
lemma Max_ge_iff [no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1654 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1655 |
shows "x \<le> Max A \<longleftrightarrow> (\<exists>a\<in>A. x \<le> a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1656 |
proof - |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1657 |
interpret dual: linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1658 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1659 |
from assms show ?thesis |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1660 |
by (simp add: Max_def dual.fold1_below_iff [folded dual.dual_max]) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1661 |
qed |
22917 | 1662 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1663 |
lemma Min_less_iff [no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1664 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1665 |
shows "Min A < x \<longleftrightarrow> (\<exists>a\<in>A. a < x)" |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1666 |
using assms by (simp add: Min_def fold1_strict_below_iff) |
22917 | 1667 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
35722
diff
changeset
|
1668 |
lemma Max_gr_iff [no_atp]: |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1669 |
assumes "finite A" and "A \<noteq> {}" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1670 |
shows "x < Max A \<longleftrightarrow> (\<exists>a\<in>A. x < a)" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1671 |
proof - |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1672 |
interpret dual: linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1673 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1674 |
from assms show ?thesis |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1675 |
by (simp add: Max_def dual.fold1_strict_below_iff [folded dual.dual_max]) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1676 |
qed |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1677 |
|
30325 | 1678 |
lemma Min_eqI: |
1679 |
assumes "finite A" |
|
1680 |
assumes "\<And>y. y \<in> A \<Longrightarrow> y \<ge> x" |
|
1681 |
and "x \<in> A" |
|
1682 |
shows "Min A = x" |
|
1683 |
proof (rule antisym) |
|
1684 |
from `x \<in> A` have "A \<noteq> {}" by auto |
|
1685 |
with assms show "Min A \<ge> x" by simp |
|
1686 |
next |
|
1687 |
from assms show "x \<ge> Min A" by simp |
|
1688 |
qed |
|
1689 |
||
1690 |
lemma Max_eqI: |
|
1691 |
assumes "finite A" |
|
1692 |
assumes "\<And>y. y \<in> A \<Longrightarrow> y \<le> x" |
|
1693 |
and "x \<in> A" |
|
1694 |
shows "Max A = x" |
|
1695 |
proof (rule antisym) |
|
1696 |
from `x \<in> A` have "A \<noteq> {}" by auto |
|
1697 |
with assms show "Max A \<le> x" by simp |
|
1698 |
next |
|
1699 |
from assms show "x \<le> Max A" by simp |
|
1700 |
qed |
|
1701 |
||
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1702 |
lemma Min_antimono: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1703 |
assumes "M \<subseteq> N" and "M \<noteq> {}" and "finite N" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1704 |
shows "Min N \<le> Min M" |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1705 |
using assms by (simp add: Min_def fold1_antimono) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1706 |
|
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1707 |
lemma Max_mono: |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1708 |
assumes "M \<subseteq> N" and "M \<noteq> {}" and "finite N" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1709 |
shows "Max M \<le> Max N" |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1710 |
proof - |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1711 |
interpret dual: linorder "op \<ge>" "op >" |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1712 |
by (rule dual_linorder) |
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1713 |
from assms show ?thesis |
32203
992ac8942691
adapted to localized interpretation of min/max-lattice
haftmann
parents:
32075
diff
changeset
|
1714 |
by (simp add: Max_def dual.fold1_antimono [folded dual.dual_max]) |
26041
c2e15e65165f
locales ACf, ACIf, ACIfSL and ACIfSLlin have been abandoned in favour of the existing algebraic classes ab_semigroup_mult, ab_semigroup_idem_mult, lower_semilattice (resp. uper_semilattice) and linorder
haftmann
parents:
25571
diff
changeset
|
1715 |
qed |
22917 | 1716 |
|
32006 | 1717 |
lemma finite_linorder_max_induct[consumes 1, case_names empty insert]: |
36079
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1718 |
assumes fin: "finite A" |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1719 |
and empty: "P {}" |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1720 |
and insert: "(!!b A. finite A \<Longrightarrow> ALL a:A. a < b \<Longrightarrow> P A \<Longrightarrow> P(insert b A))" |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1721 |
shows "P A" |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1722 |
using fin empty insert |
32006 | 1723 |
proof (induct rule: finite_psubset_induct) |
36079
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1724 |
case (psubset A) |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1725 |
have IH: "\<And>B. \<lbrakk>B < A; P {}; (\<And>A b. \<lbrakk>finite A; \<forall>a\<in>A. a<b; P A\<rbrakk> \<Longrightarrow> P (insert b A))\<rbrakk> \<Longrightarrow> P B" by fact |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1726 |
have fin: "finite A" by fact |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1727 |
have empty: "P {}" by fact |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1728 |
have step: "\<And>b A. \<lbrakk>finite A; \<forall>a\<in>A. a < b; P A\<rbrakk> \<Longrightarrow> P (insert b A)" by fact |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
1729 |
show "P A" |
26757
e775accff967
thms Max_ge, Min_le: dropped superfluous premise
haftmann
parents:
26748
diff
changeset
|
1730 |
proof (cases "A = {}") |
36079
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1731 |
assume "A = {}" |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1732 |
then show "P A" using `P {}` by simp |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
1733 |
next |
36079
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1734 |
let ?B = "A - {Max A}" |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1735 |
let ?A = "insert (Max A) ?B" |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1736 |
have "finite ?B" using `finite A` by simp |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
1737 |
assume "A \<noteq> {}" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
1738 |
with `finite A` have "Max A : A" by auto |
36079
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1739 |
then have A: "?A = A" using insert_Diff_single insert_absorb by auto |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1740 |
then have "P ?B" using `P {}` step IH[of ?B] by blast |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1741 |
moreover |
fa0e354e6a39
simplified induction case in finite_psubset_induct; tuned the proof that uses this induction principle
Christian Urban <urbanc@in.tum.de>
parents:
35938
diff
changeset
|
1742 |
have "\<forall>a\<in>?B. a < Max A" using Max_ge [OF `finite A`] by fastsimp |
32006 | 1743 |
ultimately show "P A" using A insert_Diff_single step[OF `finite ?B`] by fastsimp |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
1744 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
1745 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
26465
diff
changeset
|
1746 |
|
32006 | 1747 |
lemma finite_linorder_min_induct[consumes 1, case_names empty insert]: |
33434 | 1748 |
"\<lbrakk>finite A; P {}; \<And>b A. \<lbrakk>finite A; \<forall>a\<in>A. b < a; P A\<rbrakk> \<Longrightarrow> P (insert b A)\<rbrakk> \<Longrightarrow> P A" |
32006 | 1749 |
by(rule linorder.finite_linorder_max_induct[OF dual_linorder]) |
1750 |
||
22917 | 1751 |
end |
1752 |
||
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34223
diff
changeset
|
1753 |
context linordered_ab_semigroup_add |
22917 | 1754 |
begin |
1755 |
||
1756 |
lemma add_Min_commute: |
|
1757 |
fixes k |
|
25062 | 1758 |
assumes "finite N" and "N \<noteq> {}" |
1759 |
shows "k + Min N = Min {k + m | m. m \<in> N}" |
|
1760 |
proof - |
|
1761 |
have "\<And>x y. k + min x y = min (k + x) (k + y)" |
|
1762 |
by (simp add: min_def not_le) |
|
1763 |
(blast intro: antisym less_imp_le add_left_mono) |
|
1764 |
with assms show ?thesis |
|
1765 |
using hom_Min_commute [of "plus k" N] |
|
1766 |
by simp (blast intro: arg_cong [where f = Min]) |
|
1767 |
qed |
|
22917 | 1768 |
|
1769 |
lemma add_Max_commute: |
|
1770 |
fixes k |
|
25062 | 1771 |
assumes "finite N" and "N \<noteq> {}" |
1772 |
shows "k + Max N = Max {k + m | m. m \<in> N}" |
|
1773 |
proof - |
|
1774 |
have "\<And>x y. k + max x y = max (k + x) (k + y)" |
|
1775 |
by (simp add: max_def not_le) |
|
1776 |
(blast intro: antisym less_imp_le add_left_mono) |
|
1777 |
with assms show ?thesis |
|
1778 |
using hom_Max_commute [of "plus k" N] |
|
1779 |
by simp (blast intro: arg_cong [where f = Max]) |
|
1780 |
qed |
|
22917 | 1781 |
|
1782 |
end |
|
1783 |
||
35034 | 1784 |
context linordered_ab_group_add |
1785 |
begin |
|
1786 |
||
1787 |
lemma minus_Max_eq_Min [simp]: |
|
1788 |
"finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> - (Max S) = Min (uminus ` S)" |
|
1789 |
by (induct S rule: finite_ne_induct) (simp_all add: minus_max_eq_min) |
|
1790 |
||
1791 |
lemma minus_Min_eq_Max [simp]: |
|
1792 |
"finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> - (Min S) = Max (uminus ` S)" |
|
1793 |
by (induct S rule: finite_ne_induct) (simp_all add: minus_min_eq_max) |
|
1794 |
||
1795 |
end |
|
1796 |
||
25571
c9e39eafc7a0
instantiation target rather than legacy instance
haftmann
parents:
25502
diff
changeset
|
1797 |
end |