| author | wenzelm |
| Wed, 29 May 2013 18:25:11 +0200 | |
| changeset 52223 | 5bb6ae8acb87 |
| parent 51989 | 700693cb96f1 |
| child 53737 | eab25a77af39 |
| permissions | -rw-r--r-- |
| 47455 | 1 |
(* Title: HOL/Matrix_LP/matrixlp.ML |
|
20787
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
2 |
Author: Steven Obua |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
3 |
*) |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
4 |
|
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
5 |
signature MATRIX_LP = |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
6 |
sig |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
7 |
val matrix_compute : cterm -> thm |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
8 |
val matrix_simplify : thm -> thm |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
9 |
end |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
10 |
|
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
11 |
structure MatrixLP : MATRIX_LP = |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
12 |
struct |
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
13 |
|
| 46540 | 14 |
val compute_thms = ComputeHOL.prep_thms @{thms "ComputeHOL.compute_list_case" "ComputeHOL.compute_let"
|
15 |
"ComputeHOL.compute_if" "ComputeFloat.arith" "SparseMatrix.sparse_row_matrix_arith_simps" |
|
16 |
"ComputeHOL.compute_bool" "ComputeHOL.compute_pair" |
|
| 46544 | 17 |
"SparseMatrix.sorted_sp_simps" |
18 |
"ComputeNumeral.natnorm"}; (*"ComputeNumeral.number_norm"*) |
|
|
23665
825bea0266db
adopted to new computing oracle and fixed bugs introduced by tuning
obua
parents:
22964
diff
changeset
|
19 |
|
| 46540 | 20 |
val spm_mult_le_dual_prts_no_let_real = @{thm "spm_mult_le_dual_prts_no_let" [where ?'a = real]}
|
|
20787
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
21 |
|
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
22 |
fun lp_dual_estimate_prt lptfile prec = |
| 46540 | 23 |
let |
24 |
val cert = cterm_of @{theory}
|
|
25 |
fun var s x = (cert (Var ((s, 0), FloatSparseMatrixBuilder.spmatT)), x) |
|
26 |
val l = Fspmlp.load lptfile prec false |
|
27 |
val (y, (A1, A2), (c1, c2), b, (r1, r2)) = |
|
28 |
let |
|
29 |
open Fspmlp |
|
30 |
in |
|
31 |
(y l |> cert, A l |> pairself cert, c l |> pairself cert, b l |> cert, r12 l |> pairself cert) |
|
32 |
end |
|
33 |
in |
|
34 |
Thm.instantiate ([], |
|
35 |
[var "A1" A1, var "A2" A2, var "y" y, var "c1" c1, var "c2" c2, var "r1" r1, var "r2" r2, var "b" b]) |
|
36 |
spm_mult_le_dual_prts_no_let_real |
|
37 |
end |
|
|
20787
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
38 |
|
| 46540 | 39 |
val computer = PCompute.make Compute.SML @{theory} compute_thms []
|
|
20787
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
40 |
|
|
23665
825bea0266db
adopted to new computing oracle and fixed bugs introduced by tuning
obua
parents:
22964
diff
changeset
|
41 |
fun matrix_compute c = hd (PCompute.rewrite computer [c]) |
|
20787
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
42 |
|
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
43 |
fun matrix_simplify th = |
| 46540 | 44 |
let |
45 |
val simp_th = matrix_compute (cprop_of th) |
|
46 |
val th = Thm.strip_shyps (Thm.equal_elim simp_th th) |
|
47 |
fun removeTrue th = removeTrue (Thm.implies_elim th TrueI) handle THM _ => th |
|
48 |
in |
|
49 |
removeTrue th |
|
50 |
end |
|
|
20787
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
51 |
|
| 46541 | 52 |
val prove_bound = matrix_simplify oo lp_dual_estimate_prt; |
|
20787
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
53 |
|
|
406d990006af
moved Matrix/cplex/MatrixLP.ML to Matrix/cplex/matrixlp.ML;
wenzelm
parents:
diff
changeset
|
54 |
end |