src/HOL/Matrix/Matrix.thy
changeset 25303 0699e20feabd
parent 23879 4776af8be741
child 25502 9200b36280c0
equal deleted inserted replaced
25302:19b1729f1bd4 25303:0699e20feabd
    20   diff_matrix_def: "A - B \<equiv> combine_matrix (op -) A B" ..
    20   diff_matrix_def: "A - B \<equiv> combine_matrix (op -) A B" ..
    21 
    21 
    22 instance matrix :: ("{plus, times, zero}") times
    22 instance matrix :: ("{plus, times, zero}") times
    23   times_matrix_def: "A * B \<equiv> mult_matrix (op *) (op +) A B" ..
    23   times_matrix_def: "A * B \<equiv> mult_matrix (op *) (op +) A B" ..
    24 
    24 
    25 instance matrix :: (lordered_ab_group) abs
    25 instance matrix :: (lordered_ab_group_add) abs
    26   abs_matrix_def: "abs A \<equiv> sup A (- A)" ..
    26   abs_matrix_def: "abs A \<equiv> sup A (- A)" ..
    27 
    27 
    28 instance matrix :: (lordered_ab_group) lordered_ab_group_meet
    28 instance matrix :: (lordered_ab_group_add) lordered_ab_group_add_meet
    29 proof 
    29 proof 
    30   fix A B C :: "('a::lordered_ab_group) matrix"
    30   fix A B C :: "('a::lordered_ab_group_add) matrix"
    31   show "A + B + C = A + (B + C)"    
    31   show "A + B + C = A + (B + C)"    
    32     apply (simp add: plus_matrix_def)
    32     apply (simp add: plus_matrix_def)
    33     apply (rule combine_matrix_assoc[simplified associative_def, THEN spec, THEN spec, THEN spec])
    33     apply (rule combine_matrix_assoc[simplified associative_def, THEN spec, THEN spec, THEN spec])
    34     apply (simp_all add: add_assoc)
    34     apply (simp_all add: add_assoc)
    35     done
    35     done
    87     apply (rule le_right_mult)
    87     apply (rule le_right_mult)
    88     apply (simp_all add: add_mono mult_right_mono)
    88     apply (simp_all add: add_mono mult_right_mono)
    89     done
    89     done
    90 qed 
    90 qed 
    91 
    91 
    92 lemma Rep_matrix_add[simp]: "Rep_matrix ((a::('a::lordered_ab_group)matrix)+b) j i  = (Rep_matrix a j i) + (Rep_matrix b j i)"
    92 lemma Rep_matrix_add[simp]:
       
    93   "Rep_matrix ((a::('a::lordered_ab_group_add)matrix)+b) j i  = (Rep_matrix a j i) + (Rep_matrix b j i)"
    93 by (simp add: plus_matrix_def)
    94 by (simp add: plus_matrix_def)
    94 
    95 
    95 lemma Rep_matrix_mult: "Rep_matrix ((a::('a::lordered_ring) matrix) * b) j i = 
    96 lemma Rep_matrix_mult: "Rep_matrix ((a::('a::lordered_ring) matrix) * b) j i = 
    96   foldseq (op +) (% k.  (Rep_matrix a j k) * (Rep_matrix b k i)) (max (ncols a) (nrows b))"
    97   foldseq (op +) (% k.  (Rep_matrix a j k) * (Rep_matrix b k i)) (max (ncols a) (nrows b))"
    97 apply (simp add: times_matrix_def)
    98 apply (simp add: times_matrix_def)
    98 apply (simp add: Rep_mult_matrix)
    99 apply (simp add: Rep_mult_matrix)
    99 done
   100 done
   100 
   101 
   101 lemma apply_matrix_add: "! x y. f (x+y) = (f x) + (f y) \<Longrightarrow> f 0 = (0::'a) \<Longrightarrow> apply_matrix f ((a::('a::lordered_ab_group) matrix) + b) = (apply_matrix f a) + (apply_matrix f b)"
   102 lemma apply_matrix_add: "! x y. f (x+y) = (f x) + (f y) \<Longrightarrow> f 0 = (0::'a) \<Longrightarrow> apply_matrix f ((a::('a::lordered_ab_group_add) matrix) + b) = (apply_matrix f a) + (apply_matrix f b)"
   102 apply (subst Rep_matrix_inject[symmetric])
   103 apply (subst Rep_matrix_inject[symmetric])
   103 apply (rule ext)+
   104 apply (rule ext)+
   104 apply (simp)
   105 apply (simp)
   105 done
   106 done
   106 
   107 
   107 lemma singleton_matrix_add: "singleton_matrix j i ((a::_::lordered_ab_group)+b) = (singleton_matrix j i a) + (singleton_matrix j i b)"
   108 lemma singleton_matrix_add: "singleton_matrix j i ((a::_::lordered_ab_group_add)+b) = (singleton_matrix j i a) + (singleton_matrix j i b)"
   108 apply (subst Rep_matrix_inject[symmetric])
   109 apply (subst Rep_matrix_inject[symmetric])
   109 apply (rule ext)+
   110 apply (rule ext)+
   110 apply (simp)
   111 apply (simp)
   111 done
   112 done
   112 
   113 
   160 apply (simp add: times_matrix_def)
   161 apply (simp add: times_matrix_def)
   161 apply (subst transpose_mult_matrix)
   162 apply (subst transpose_mult_matrix)
   162 apply (simp_all add: mult_commute)
   163 apply (simp_all add: mult_commute)
   163 done
   164 done
   164 
   165 
   165 lemma transpose_matrix_add: "transpose_matrix ((A::('a::lordered_ab_group) matrix)+B) = transpose_matrix A + transpose_matrix B"
   166 lemma transpose_matrix_add: "transpose_matrix ((A::('a::lordered_ab_group_add) matrix)+B) = transpose_matrix A + transpose_matrix B"
   166 by (simp add: plus_matrix_def transpose_combine_matrix)
   167 by (simp add: plus_matrix_def transpose_combine_matrix)
   167 
   168 
   168 lemma transpose_matrix_diff: "transpose_matrix ((A::('a::lordered_ab_group) matrix)-B) = transpose_matrix A - transpose_matrix B"
   169 lemma transpose_matrix_diff: "transpose_matrix ((A::('a::lordered_ab_group_add) matrix)-B) = transpose_matrix A - transpose_matrix B"
   169 by (simp add: diff_matrix_def transpose_combine_matrix)
   170 by (simp add: diff_matrix_def transpose_combine_matrix)
   170 
   171 
   171 lemma transpose_matrix_minus: "transpose_matrix (-(A::('a::lordered_ring) matrix)) = - transpose_matrix (A::('a::lordered_ring) matrix)"
   172 lemma transpose_matrix_minus: "transpose_matrix (-(A::('a::lordered_ring) matrix)) = - transpose_matrix (A::('a::lordered_ring) matrix)"
   172 by (simp add: minus_matrix_def transpose_apply_matrix)
   173 by (simp add: minus_matrix_def transpose_apply_matrix)
   173 
   174 
   250 apply (rule order_trans)
   251 apply (rule order_trans)
   251 apply (rule nrows_move_matrix_le)
   252 apply (rule nrows_move_matrix_le)
   252 apply (simp add: max2)
   253 apply (simp add: max2)
   253 done
   254 done
   254 
   255 
   255 lemma move_matrix_add: "((move_matrix (A + B) j i)::(('a::lordered_ab_group) matrix)) = (move_matrix A j i) + (move_matrix B j i)" 
   256 lemma move_matrix_add: "((move_matrix (A + B) j i)::(('a::lordered_ab_group_add) matrix)) = (move_matrix A j i) + (move_matrix B j i)" 
   256 apply (subst Rep_matrix_inject[symmetric])
   257 apply (subst Rep_matrix_inject[symmetric])
   257 apply (rule ext)+
   258 apply (rule ext)+
   258 apply (simp)
   259 apply (simp)
   259 done
   260 done
   260 
   261 
   278 apply (subst Rep_matrix_inject[symmetric])
   279 apply (subst Rep_matrix_inject[symmetric])
   279 apply (rule ext)+
   280 apply (rule ext)+
   280 apply (auto)
   281 apply (auto)
   281 done
   282 done
   282 
   283 
   283 lemma Rep_minus[simp]: "Rep_matrix (-(A::_::lordered_ab_group)) x y = - (Rep_matrix A x y)"
   284 lemma Rep_minus[simp]: "Rep_matrix (-(A::_::lordered_ab_group_add)) x y = - (Rep_matrix A x y)"
   284 by (simp add: minus_matrix_def)
   285 by (simp add: minus_matrix_def)
   285 
   286 
   286 lemma Rep_abs[simp]: "Rep_matrix (abs (A::_::lordered_ring)) x y = abs (Rep_matrix A x y)"
   287 lemma Rep_abs[simp]: "Rep_matrix (abs (A::_::lordered_ring)) x y = abs (Rep_matrix A x y)"
   287 by (simp add: abs_lattice sup_matrix_def)
   288 by (simp add: abs_lattice sup_matrix_def)
   288 
   289