14593
|
1 |
(* Title: HOL/Matrix/LinProg.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Steven Obua
|
|
4 |
License: 2004 Technische Universität München
|
|
5 |
*)
|
|
6 |
|
|
7 |
theory LinProg = Matrix:
|
|
8 |
|
|
9 |
lemma linprog_by_duality_approx_general:
|
|
10 |
assumes
|
|
11 |
fmuladdprops:
|
|
12 |
"! a b c d. a <= b & c <= d \<longrightarrow> fadd a c <= fadd b d"
|
|
13 |
"! c a b. 0 <= c & a <= b \<longrightarrow> fmul c a <= fmul c b"
|
|
14 |
"! a. fmul 0 a = 0"
|
|
15 |
"! a. fmul a 0 = 0"
|
|
16 |
"fadd 0 0 = 0"
|
|
17 |
"associative fadd"
|
|
18 |
"commutative fadd"
|
|
19 |
"associative fmul"
|
|
20 |
"distributive fmul fadd"
|
|
21 |
and specificprops:
|
|
22 |
"mult_matrix fmul fadd (combine_matrix fadd A dA) x <= (b::('a::{order, zero}) matrix)"
|
|
23 |
"mult_matrix fmul fadd y A = c"
|
|
24 |
"0 <= y"
|
|
25 |
shows
|
|
26 |
"combine_matrix fadd (mult_matrix fmul fadd c x) (mult_matrix fmul fadd (mult_matrix fmul fadd y dA) x)
|
|
27 |
<= mult_matrix fmul fadd y b"
|
|
28 |
proof -
|
|
29 |
let ?mul = "mult_matrix fmul fadd"
|
|
30 |
let ?add = "combine_matrix fadd"
|
|
31 |
let ?t1 = "?mul y (?mul (?add A dA) x)"
|
|
32 |
have a: "?t1 <= ?mul y b" by (rule le_left_mult, simp_all!)
|
|
33 |
have b: "?t1 = ?mul (?mul y (?add A dA)) x" by (simp! add: mult_matrix_assoc_simple[THEN sym])
|
|
34 |
have assoc: "associative ?add" by (simp! add: combine_matrix_assoc)
|
|
35 |
have r_distr: "r_distributive ?mul ?add"
|
|
36 |
apply (rule r_distributive_matrix)
|
|
37 |
by (simp! add: distributive_def)+
|
|
38 |
have l_distr: "l_distributive ?mul ?add"
|
|
39 |
apply (rule l_distributive_matrix)
|
|
40 |
by (simp! add: distributive_def)+
|
|
41 |
have c:"?mul y (?add A dA) = ?add (?mul y A) (?mul y dA)"
|
|
42 |
by (insert r_distr, simp add: r_distributive_def)
|
|
43 |
have d:"?mul (?add (?mul y A) (?mul y dA)) x = ?add (?mul (?mul y A) x) (?mul (?mul y dA) x)"
|
|
44 |
by (insert l_distr, simp add: l_distributive_def)
|
|
45 |
have e:"\<dots> = ?add (?mul c x) (?mul (?mul y dA) x)" by (simp!)
|
|
46 |
from a b c d e show "?add (?mul c x) (?mul (?mul y dA) x) <= ?mul y b" by simp
|
|
47 |
qed
|
|
48 |
|
|
49 |
lemma linprog_by_duality_approx:
|
|
50 |
assumes
|
|
51 |
"(A + dA) * x <= (b::('a::pordered_matrix_element) matrix)"
|
|
52 |
"y * A = c"
|
|
53 |
"0 <= y"
|
|
54 |
shows
|
|
55 |
"c * x + (y * dA) * x <= y * b"
|
|
56 |
apply (simp add: times_matrix_def plus_matrix_def)
|
|
57 |
apply (rule linprog_by_duality_approx_general)
|
|
58 |
apply (simp_all)
|
|
59 |
apply (simp_all add: associative_def matrix_add_assoc matrix_mult_assoc)
|
|
60 |
apply (simp_all add: commutative_def matrix_add_commute)
|
|
61 |
apply (simp_all add: distributive_def l_distributive_def r_distributive_def matrix_left_distrib matrix_right_distrib)
|
|
62 |
apply (simp_all! add: plus_matrix_def times_matrix_def)
|
|
63 |
apply (simp add: pordered_add)
|
|
64 |
apply (simp add: pordered_mult_left)
|
|
65 |
done
|
|
66 |
|
|
67 |
lemma linprog_by_duality:
|
|
68 |
assumes
|
|
69 |
"A * x <= (b::('a::pordered_g_semiring) matrix)"
|
|
70 |
"y * A = c"
|
|
71 |
"0 <= y"
|
|
72 |
shows
|
|
73 |
"c * x <= y * b"
|
|
74 |
proof -
|
|
75 |
have a:"(A + 0) * x <= b" by (simp!)
|
|
76 |
have b:"c * x + (y*0)*x <= y * b" by (rule linprog_by_duality_approx, simp_all!)
|
|
77 |
show "c * x <= y*b" by (insert b, simp)
|
|
78 |
qed
|
|
79 |
|
|
80 |
end
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|