1 (* Title: HOL/Matrix/LP.thy
6 imports Main "~~/src/HOL/Library/Lattice_Algebras"
9 lemma le_add_right_mono:
11 "a <= b + (c::'a::ordered_ab_group_add)"
14 apply (rule_tac order_trans[where y = "b+c"])
15 apply (simp_all add: assms)
18 lemma linprog_dual_estimate:
20 "A * x \<le> (b::'a::lattice_ring)"
22 "abs (A - A') \<le> \<delta>A"
24 "abs (c - c') \<le> \<delta>c"
27 "c * x \<le> y * b' + (y * \<delta>A + abs (y * A' - c') + \<delta>c) * r"
29 from assms have 1: "y * b <= y * b'" by (simp add: mult_left_mono)
30 from assms have 2: "y * (A * x) <= y * b" by (simp add: mult_left_mono)
31 have 3: "y * (A * x) = c * x + (y * (A - A') + (y * A' - c') + (c'-c)) * x" by (simp add: algebra_simps)
32 from 1 2 3 have 4: "c * x + (y * (A - A') + (y * A' - c') + (c'-c)) * x <= y * b'" by simp
33 have 5: "c * x <= y * b' + abs((y * (A - A') + (y * A' - c') + (c'-c)) * x)"
34 by (simp only: 4 estimate_by_abs)
35 have 6: "abs((y * (A - A') + (y * A' - c') + (c'-c)) * x) <= abs (y * (A - A') + (y * A' - c') + (c'-c)) * abs x"
36 by (simp add: abs_le_mult)
37 have 7: "(abs (y * (A - A') + (y * A' - c') + (c'-c))) * abs x <= (abs (y * (A-A') + (y*A'-c')) + abs(c'-c)) * abs x"
38 by(rule abs_triangle_ineq [THEN mult_right_mono]) simp
39 have 8: " (abs (y * (A-A') + (y*A'-c')) + abs(c'-c)) * abs x <= (abs (y * (A-A')) + abs (y*A'-c') + abs(c'-c)) * abs x"
40 by (simp add: abs_triangle_ineq mult_right_mono)
41 have 9: "(abs (y * (A-A')) + abs (y*A'-c') + abs(c'-c)) * abs x <= (abs y * abs (A-A') + abs (y*A'-c') + abs (c'-c)) * abs x"
42 by (simp add: abs_le_mult mult_right_mono)
43 have 10: "c'-c = -(c-c')" by (simp add: algebra_simps)
44 have 11: "abs (c'-c) = abs (c-c')"
45 by (subst 10, subst abs_minus_cancel, simp)
46 have 12: "(abs y * abs (A-A') + abs (y*A'-c') + abs (c'-c)) * abs x <= (abs y * abs (A-A') + abs (y*A'-c') + \<delta>c) * abs x"
47 by (simp add: 11 assms mult_right_mono)
48 have 13: "(abs y * abs (A-A') + abs (y*A'-c') + \<delta>c) * abs x <= (abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * abs x"
49 by (simp add: assms mult_right_mono mult_left_mono)
50 have r: "(abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * abs x <= (abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * r"
51 apply (rule mult_left_mono)
52 apply (simp add: assms)
53 apply (rule_tac add_mono[of "0::'a" _ "0", simplified])+
54 apply (rule mult_left_mono[of "0" "\<delta>A", simplified])
56 apply (rule order_trans[where y="abs (A-A')"], simp_all add: assms)
57 apply (rule order_trans[where y="abs (c-c')"], simp_all add: assms)
59 from 6 7 8 9 12 13 r have 14:" abs((y * (A - A') + (y * A' - c') + (c'-c)) * x) <=(abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * r"
62 apply (rule le_add_right_mono[of _ _ "abs((y * (A - A') + (y * A' - c') + (c'-c)) * x)"])
63 apply (simp_all only: 5 14[simplified abs_of_nonneg[of y, simplified assms]])
67 lemma le_ge_imp_abs_diff_1:
69 "A1 <= (A::'a::lattice_ring)"
71 shows "abs (A-A1) <= A2-A1"
75 have 1: "A - A1 = A + (- A1)" by simp
76 show ?thesis by (simp only: 1 add_right_mono[of A1 A "-A1", simplified, simplified assms])
78 then have "abs (A-A1) = A-A1" by (rule abs_of_nonneg)
79 with assms show "abs (A-A1) <= (A2-A1)" by simp
84 "a1 <= (a::'a::lattice_ring)"
89 "a * b <= pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1"
91 have "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
92 apply (subst prts[symmetric])+
95 then have "a * b = pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
96 by (simp add: algebra_simps)
97 moreover have "pprt a * pprt b <= pprt a2 * pprt b2"
98 by (simp_all add: assms mult_mono)
99 moreover have "pprt a * nprt b <= pprt a1 * nprt b2"
101 have "pprt a * nprt b <= pprt a * nprt b2"
102 by (simp add: mult_left_mono assms)
103 moreover have "pprt a * nprt b2 <= pprt a1 * nprt b2"
104 by (simp add: mult_right_mono_neg assms)
105 ultimately show ?thesis
108 moreover have "nprt a * pprt b <= nprt a2 * pprt b1"
110 have "nprt a * pprt b <= nprt a2 * pprt b"
111 by (simp add: mult_right_mono assms)
112 moreover have "nprt a2 * pprt b <= nprt a2 * pprt b1"
113 by (simp add: mult_left_mono_neg assms)
114 ultimately show ?thesis
117 moreover have "nprt a * nprt b <= nprt a1 * nprt b1"
119 have "nprt a * nprt b <= nprt a * nprt b1"
120 by (simp add: mult_left_mono_neg assms)
121 moreover have "nprt a * nprt b1 <= nprt a1 * nprt b1"
122 by (simp add: mult_right_mono_neg assms)
123 ultimately show ?thesis
126 ultimately show ?thesis
127 by - (rule add_mono | simp)+
130 lemma mult_le_dual_prts:
132 "A * x \<le> (b::'a::lattice_ring)"
141 "c * x \<le> y * b + (let s1 = c1 - y * A2; s2 = c2 - y * A1 in pprt s2 * pprt r2 + pprt s1 * nprt r2 + nprt s2 * pprt r1 + nprt s1 * nprt r1)"
144 from assms have "y * (A * x) <= y * b" by (simp add: mult_left_mono)
145 moreover have "y * (A * x) = c * x + (y * A - c) * x" by (simp add: algebra_simps)
146 ultimately have "c * x + (y * A - c) * x <= y * b" by simp
147 then have "c * x <= y * b - (y * A - c) * x" by (simp add: le_diff_eq)
148 then have cx: "c * x <= y * b + (c - y * A) * x" by (simp add: algebra_simps)
149 have s2: "c - y * A <= c2 - y * A1"
150 by (simp add: diff_minus assms add_mono mult_left_mono)
151 have s1: "c1 - y * A2 <= c - y * A"
152 by (simp add: diff_minus assms add_mono mult_left_mono)
153 have prts: "(c - y * A) * x <= ?C"
154 apply (simp add: Let_def)
155 apply (rule mult_le_prts)
156 apply (simp_all add: assms s1 s2)
158 then have "y * b + (c - y * A) * x <= y * b + ?C"