src/HOL/Multivariate_Analysis/Linear_Algebra.thy
changeset 63114 27afe7af7379
parent 63075 60a42a4166af
child 63148 6a767355d1a9
equal deleted inserted replaced
63107:932cf444f2fe 63114:27afe7af7379
   221   by (metis subspace_def)
   221   by (metis subspace_def)
   222 
   222 
   223 lemma subspace_neg: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> - x \<in> S"
   223 lemma subspace_neg: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> - x \<in> S"
   224   by (metis scaleR_minus1_left subspace_mul)
   224   by (metis scaleR_minus1_left subspace_mul)
   225 
   225 
   226 lemma subspace_sub: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x - y \<in> S"
   226 lemma subspace_diff: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x - y \<in> S"
   227   using subspace_add [of S x "- y"] by (simp add: subspace_neg)
   227   using subspace_add [of S x "- y"] by (simp add: subspace_neg)
   228 
   228 
   229 lemma (in real_vector) subspace_setsum:
   229 lemma (in real_vector) subspace_setsum:
   230   assumes sA: "subspace A"
   230   assumes sA: "subspace A"
   231     and f: "\<And>x. x \<in> B \<Longrightarrow> f x \<in> A"
   231     and f: "\<And>x. x \<in> B \<Longrightarrow> f x \<in> A"
   432 
   432 
   433 lemma span_neg: "x \<in> span S \<Longrightarrow> - x \<in> span S"
   433 lemma span_neg: "x \<in> span S \<Longrightarrow> - x \<in> span S"
   434   by (metis subspace_neg subspace_span)
   434   by (metis subspace_neg subspace_span)
   435 
   435 
   436 lemma span_sub: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x - y \<in> span S"
   436 lemma span_sub: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x - y \<in> span S"
   437   by (metis subspace_span subspace_sub)
   437   by (metis subspace_span subspace_diff)
   438 
   438 
   439 lemma (in real_vector) span_setsum: "(\<And>x. x \<in> A \<Longrightarrow> f x \<in> span S) \<Longrightarrow> setsum f A \<in> span S"
   439 lemma (in real_vector) span_setsum: "(\<And>x. x \<in> A \<Longrightarrow> f x \<in> span S) \<Longrightarrow> setsum f A \<in> span S"
   440   by (rule subspace_setsum [OF subspace_span])
   440   by (rule subspace_setsum [OF subspace_span])
   441 
   441 
   442 lemma span_add_eq: "x \<in> span S \<Longrightarrow> x + y \<in> span S \<longleftrightarrow> y \<in> span S"
   442 lemma span_add_eq: "x \<in> span S \<Longrightarrow> x + y \<in> span S \<longleftrightarrow> y \<in> span S"
  1522 end
  1522 end
  1523 
  1523 
  1524 lemma orthogonal_commute: "orthogonal x y \<longleftrightarrow> orthogonal y x"
  1524 lemma orthogonal_commute: "orthogonal x y \<longleftrightarrow> orthogonal y x"
  1525   by (simp add: orthogonal_def inner_commute)
  1525   by (simp add: orthogonal_def inner_commute)
  1526 
  1526 
       
  1527 lemma orthogonal_scaleR [simp]: "c \<noteq> 0 \<Longrightarrow> orthogonal (c *\<^sub>R x) = orthogonal x"
       
  1528   by (rule ext) (simp add: orthogonal_def)
       
  1529 
       
  1530 lemma pairwise_ortho_scaleR:
       
  1531     "pairwise (\<lambda>i j. orthogonal (f i) (g j)) B
       
  1532     \<Longrightarrow> pairwise (\<lambda>i j. orthogonal (a i *\<^sub>R f i) (a j *\<^sub>R g j)) B"
       
  1533   by (auto simp: pairwise_def orthogonal_clauses)
       
  1534 
       
  1535 lemma orthogonal_rvsum:
       
  1536     "\<lbrakk>finite s; \<And>y. y \<in> s \<Longrightarrow> orthogonal x (f y)\<rbrakk> \<Longrightarrow> orthogonal x (setsum f s)"
       
  1537   by (induction s rule: finite_induct) (auto simp: orthogonal_clauses)
       
  1538 
       
  1539 lemma orthogonal_lvsum:
       
  1540     "\<lbrakk>finite s; \<And>x. x \<in> s \<Longrightarrow> orthogonal (f x) y\<rbrakk> \<Longrightarrow> orthogonal (setsum f s) y"
       
  1541   by (induction s rule: finite_induct) (auto simp: orthogonal_clauses)
       
  1542 
       
  1543 lemma norm_add_Pythagorean:
       
  1544   assumes "orthogonal a b"
       
  1545     shows "norm(a + b) ^ 2 = norm a ^ 2 + norm b ^ 2"
       
  1546 proof -
       
  1547   from assms have "(a - (0 - b)) \<bullet> (a - (0 - b)) = a \<bullet> a - (0 - b \<bullet> b)"
       
  1548     by (simp add: algebra_simps orthogonal_def inner_commute)
       
  1549   then show ?thesis
       
  1550     by (simp add: power2_norm_eq_inner)
       
  1551 qed
       
  1552 
       
  1553 lemma norm_setsum_Pythagorean:
       
  1554   assumes "finite I" "pairwise (\<lambda>i j. orthogonal (f i) (f j)) I"
       
  1555     shows "(norm (setsum f I))\<^sup>2 = (\<Sum>i\<in>I. (norm (f i))\<^sup>2)"
       
  1556 using assms
       
  1557 proof (induction I rule: finite_induct)
       
  1558   case empty then show ?case by simp
       
  1559 next
       
  1560   case (insert x I)
       
  1561   then have "orthogonal (f x) (setsum f I)"
       
  1562     by (metis pairwise_insert orthogonal_rvsum)
       
  1563   with insert show ?case
       
  1564     by (simp add: pairwise_insert norm_add_Pythagorean)
       
  1565 qed
       
  1566 
  1527 
  1567 
  1528 subsection \<open>Bilinear functions.\<close>
  1568 subsection \<open>Bilinear functions.\<close>
  1529 
  1569 
  1530 definition "bilinear f \<longleftrightarrow> (\<forall>x. linear (\<lambda>y. f x y)) \<and> (\<forall>y. linear (\<lambda>x. f x y))"
  1570 definition "bilinear f \<longleftrightarrow> (\<forall>x. linear (\<lambda>y. f x y)) \<and> (\<forall>y. linear (\<lambda>x. f x y))"
  1531 
  1571