530 |
500 |
531 |
501 |
532 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Subspace parallel to an affine set\<close> |
502 subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Subspace parallel to an affine set\<close> |
533 |
503 |
534 lemma subspace_affine: "subspace S \<longleftrightarrow> affine S \<and> 0 \<in> S" |
504 lemma subspace_affine: "subspace S \<longleftrightarrow> affine S \<and> 0 \<in> S" |
535 proof - |
505 by (metis add_cancel_right_left affine_alt diff_add_cancel mem_affine_3 scaleR_eq_0_iff subspace_def vector_space_assms(4)) |
536 have h0: "subspace S \<Longrightarrow> affine S \<and> 0 \<in> S" |
|
537 using subspace_imp_affine[of S] subspace_0 by auto |
|
538 { |
|
539 assume assm: "affine S \<and> 0 \<in> S" |
|
540 { |
|
541 fix c :: real |
|
542 fix x |
|
543 assume x: "x \<in> S" |
|
544 have "c *\<^sub>R x = (1-c) *\<^sub>R 0 + c *\<^sub>R x" by auto |
|
545 moreover |
|
546 have "(1 - c) *\<^sub>R 0 + c *\<^sub>R x \<in> S" |
|
547 using affine_alt[of S] assm x by auto |
|
548 ultimately have "c *\<^sub>R x \<in> S" by auto |
|
549 } |
|
550 then have h1: "\<forall>c. \<forall>x \<in> S. c *\<^sub>R x \<in> S" by auto |
|
551 |
|
552 { |
|
553 fix x y |
|
554 assume xy: "x \<in> S" "y \<in> S" |
|
555 define u where "u = (1 :: real)/2" |
|
556 have "(1/2) *\<^sub>R (x+y) = (1/2) *\<^sub>R (x+y)" |
|
557 by auto |
|
558 moreover |
|
559 have "(1/2) *\<^sub>R (x+y)=(1/2) *\<^sub>R x + (1-(1/2)) *\<^sub>R y" |
|
560 by (simp add: algebra_simps) |
|
561 moreover |
|
562 have "(1 - u) *\<^sub>R x + u *\<^sub>R y \<in> S" |
|
563 using affine_alt[of S] assm xy by auto |
|
564 ultimately |
|
565 have "(1/2) *\<^sub>R (x+y) \<in> S" |
|
566 using u_def by auto |
|
567 moreover |
|
568 have "x + y = 2 *\<^sub>R ((1/2) *\<^sub>R (x+y))" |
|
569 by auto |
|
570 ultimately |
|
571 have "x + y \<in> S" |
|
572 using h1[rule_format, of "(1/2) *\<^sub>R (x+y)" "2"] by auto |
|
573 } |
|
574 then have "\<forall>x \<in> S. \<forall>y \<in> S. x + y \<in> S" |
|
575 by auto |
|
576 then have "subspace S" |
|
577 using h1 assm unfolding subspace_def by auto |
|
578 } |
|
579 then show ?thesis using h0 by metis |
|
580 qed |
|
581 |
506 |
582 lemma affine_diffs_subspace: |
507 lemma affine_diffs_subspace: |
583 assumes "affine S" "a \<in> S" |
508 assumes "affine S" "a \<in> S" |
584 shows "subspace ((\<lambda>x. (-a)+x) ` S)" |
509 shows "subspace ((\<lambda>x. (-a)+x) ` S)" |
585 proof - |
510 by (metis ab_left_minus affine_translation assms image_eqI subspace_affine) |
586 have [simp]: "(\<lambda>x. x - a) = plus (- a)" by (simp add: fun_eq_iff) |
|
587 have "affine ((\<lambda>x. (-a)+x) ` S)" |
|
588 using affine_translation assms by blast |
|
589 moreover have "0 \<in> ((\<lambda>x. (-a)+x) ` S)" |
|
590 using assms exI[of "(\<lambda>x. x\<in>S \<and> -a+x = 0)" a] by auto |
|
591 ultimately show ?thesis using subspace_affine by auto |
|
592 qed |
|
593 |
511 |
594 lemma affine_diffs_subspace_subtract: |
512 lemma affine_diffs_subspace_subtract: |
595 "subspace ((\<lambda>x. x - a) ` S)" if "affine S" "a \<in> S" |
513 "subspace ((\<lambda>x. x - a) ` S)" if "affine S" "a \<in> S" |
596 using that affine_diffs_subspace [of _ a] by simp |
514 using that affine_diffs_subspace [of _ a] by simp |
597 |
515 |
598 lemma parallel_subspace_explicit: |
516 lemma parallel_subspace_explicit: |
599 assumes "affine S" |
517 assumes "affine S" |
600 and "a \<in> S" |
518 and "a \<in> S" |
601 assumes "L \<equiv> {y. \<exists>x \<in> S. (-a) + x = y}" |
519 assumes "L \<equiv> {y. \<exists>x \<in> S. (-a) + x = y}" |
602 shows "subspace L \<and> affine_parallel S L" |
520 shows "subspace L \<and> affine_parallel S L" |
603 proof - |
521 by (smt (verit) Collect_cong ab_left_minus affine_parallel_def assms image_def mem_Collect_eq parallel_is_affine subspace_affine) |
604 from assms have "L = plus (- a) ` S" by auto |
|
605 then have par: "affine_parallel S L" |
|
606 unfolding affine_parallel_def .. |
|
607 then have "affine L" using assms parallel_is_affine by auto |
|
608 moreover have "0 \<in> L" |
|
609 using assms by auto |
|
610 ultimately show ?thesis |
|
611 using subspace_affine par by auto |
|
612 qed |
|
613 |
522 |
614 lemma parallel_subspace_aux: |
523 lemma parallel_subspace_aux: |
615 assumes "subspace A" |
524 assumes "subspace A" |
616 and "subspace B" |
525 and "subspace B" |
617 and "affine_parallel A B" |
526 and "affine_parallel A B" |
618 shows "A \<supseteq> B" |
527 shows "A \<supseteq> B" |
619 proof - |
528 by (metis add.right_neutral affine_parallel_expl assms subsetI subspace_def) |
620 from assms obtain a where a: "\<forall>x. x \<in> A \<longleftrightarrow> a + x \<in> B" |
|
621 using affine_parallel_expl[of A B] by auto |
|
622 then have "-a \<in> A" |
|
623 using assms subspace_0[of B] by auto |
|
624 then have "a \<in> A" |
|
625 using assms subspace_neg[of A "-a"] by auto |
|
626 then show ?thesis |
|
627 using assms a unfolding subspace_def by auto |
|
628 qed |
|
629 |
529 |
630 lemma parallel_subspace: |
530 lemma parallel_subspace: |
631 assumes "subspace A" |
531 assumes "subspace A" |
632 and "subspace B" |
532 and "subspace B" |
633 and "affine_parallel A B" |
533 and "affine_parallel A B" |
634 shows "A = B" |
534 shows "A = B" |
635 proof |
535 by (simp add: affine_parallel_commute assms parallel_subspace_aux subset_antisym) |
636 show "A \<supseteq> B" |
|
637 using assms parallel_subspace_aux by auto |
|
638 show "A \<subseteq> B" |
|
639 using assms parallel_subspace_aux[of B A] affine_parallel_commut by auto |
|
640 qed |
|
641 |
536 |
642 lemma affine_parallel_subspace: |
537 lemma affine_parallel_subspace: |
643 assumes "affine S" "S \<noteq> {}" |
538 assumes "affine S" "S \<noteq> {}" |
644 shows "\<exists>!L. subspace L \<and> affine_parallel S L" |
539 shows "\<exists>!L. subspace L \<and> affine_parallel S L" |
645 proof - |
540 by (meson affine_parallel_assoc affine_parallel_commute assms equals0I parallel_subspace parallel_subspace_explicit) |
646 have ex: "\<exists>L. subspace L \<and> affine_parallel S L" |
|
647 using assms parallel_subspace_explicit by auto |
|
648 { |
|
649 fix L1 L2 |
|
650 assume ass: "subspace L1 \<and> affine_parallel S L1" "subspace L2 \<and> affine_parallel S L2" |
|
651 then have "affine_parallel L1 L2" |
|
652 using affine_parallel_commut[of S L1] affine_parallel_assoc[of L1 S L2] by auto |
|
653 then have "L1 = L2" |
|
654 using ass parallel_subspace by auto |
|
655 } |
|
656 then show ?thesis using ex by auto |
|
657 qed |
|
658 |
541 |
659 |
542 |
660 subsection \<open>Affine Dependence\<close> |
543 subsection \<open>Affine Dependence\<close> |
661 |
544 |
662 text "Formalized by Lars Schewe." |
545 text "Formalized by Lars Schewe." |
663 |
546 |
664 definition\<^marker>\<open>tag important\<close> affine_dependent :: "'a::real_vector set \<Rightarrow> bool" |
547 definition\<^marker>\<open>tag important\<close> affine_dependent :: "'a::real_vector set \<Rightarrow> bool" |
665 where "affine_dependent s \<longleftrightarrow> (\<exists>x\<in>s. x \<in> affine hull (s - {x}))" |
548 where "affine_dependent S \<longleftrightarrow> (\<exists>x\<in>S. x \<in> affine hull (S - {x}))" |
666 |
549 |
667 lemma affine_dependent_imp_dependent: "affine_dependent s \<Longrightarrow> dependent s" |
550 lemma affine_dependent_imp_dependent: "affine_dependent S \<Longrightarrow> dependent S" |
668 unfolding affine_dependent_def dependent_def |
551 unfolding affine_dependent_def dependent_def |
669 using affine_hull_subset_span by auto |
552 using affine_hull_subset_span by auto |
670 |
553 |
671 lemma affine_dependent_subset: |
554 lemma affine_dependent_subset: |
672 "\<lbrakk>affine_dependent s; s \<subseteq> t\<rbrakk> \<Longrightarrow> affine_dependent t" |
555 "\<lbrakk>affine_dependent S; S \<subseteq> T\<rbrakk> \<Longrightarrow> affine_dependent T" |
673 apply (simp add: affine_dependent_def Bex_def) |
556 using hull_mono [OF Diff_mono [OF _ subset_refl]] |
674 apply (blast dest: hull_mono [OF Diff_mono [OF _ subset_refl]]) |
557 by (smt (verit) affine_dependent_def subsetD) |
675 done |
|
676 |
558 |
677 lemma affine_independent_subset: |
559 lemma affine_independent_subset: |
678 shows "\<lbrakk>\<not> affine_dependent t; s \<subseteq> t\<rbrakk> \<Longrightarrow> \<not> affine_dependent s" |
560 shows "\<lbrakk>\<not> affine_dependent T; S \<subseteq> T\<rbrakk> \<Longrightarrow> \<not> affine_dependent S" |
679 by (metis affine_dependent_subset) |
561 by (metis affine_dependent_subset) |
680 |
562 |
681 lemma affine_independent_Diff: |
563 lemma affine_independent_Diff: |
682 "\<not> affine_dependent s \<Longrightarrow> \<not> affine_dependent(s - t)" |
564 "\<not> affine_dependent S \<Longrightarrow> \<not> affine_dependent(S - T)" |
683 by (meson Diff_subset affine_dependent_subset) |
565 by (meson Diff_subset affine_dependent_subset) |
684 |
566 |
685 proposition affine_dependent_explicit: |
567 proposition affine_dependent_explicit: |
686 "affine_dependent p \<longleftrightarrow> |
568 "affine_dependent p \<longleftrightarrow> |
687 (\<exists>S u. finite S \<and> S \<subseteq> p \<and> sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) S = 0)" |
569 (\<exists>S U. finite S \<and> S \<subseteq> p \<and> sum U S = 0 \<and> (\<exists>v\<in>S. U v \<noteq> 0) \<and> sum (\<lambda>v. U v *\<^sub>R v) S = 0)" |
688 proof - |
570 proof - |
689 have "\<exists>S u. finite S \<and> S \<subseteq> p \<and> sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> (\<Sum>w\<in>S. u w *\<^sub>R w) = 0" |
571 have "\<exists>S U. finite S \<and> S \<subseteq> p \<and> sum U S = 0 \<and> (\<exists>v\<in>S. U v \<noteq> 0) \<and> (\<Sum>w\<in>S. U w *\<^sub>R w) = 0" |
690 if "(\<Sum>w\<in>S. u w *\<^sub>R w) = x" "x \<in> p" "finite S" "S \<noteq> {}" "S \<subseteq> p - {x}" "sum u S = 1" for x S u |
572 if "(\<Sum>w\<in>S. U w *\<^sub>R w) = x" "x \<in> p" "finite S" "S \<noteq> {}" "S \<subseteq> p - {x}" "sum U S = 1" for x S U |
691 proof (intro exI conjI) |
573 proof (intro exI conjI) |
692 have "x \<notin> S" |
574 have "x \<notin> S" |
693 using that by auto |
575 using that by auto |
694 then show "(\<Sum>v \<in> insert x S. if v = x then - 1 else u v) = 0" |
576 then show "(\<Sum>v \<in> insert x S. if v = x then - 1 else U v) = 0" |
695 using that by (simp add: sum_delta_notmem) |
577 using that by (simp add: sum_delta_notmem) |
696 show "(\<Sum>w \<in> insert x S. (if w = x then - 1 else u w) *\<^sub>R w) = 0" |
578 show "(\<Sum>w \<in> insert x S. (if w = x then - 1 else U w) *\<^sub>R w) = 0" |
697 using that \<open>x \<notin> S\<close> by (simp add: if_smult sum_delta_notmem cong: if_cong) |
579 using that \<open>x \<notin> S\<close> by (simp add: if_smult sum_delta_notmem cong: if_cong) |
698 qed (use that in auto) |
580 qed (use that in auto) |
699 moreover have "\<exists>x\<in>p. \<exists>S u. finite S \<and> S \<noteq> {} \<and> S \<subseteq> p - {x} \<and> sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = x" |
581 moreover have "\<exists>x\<in>p. \<exists>S U. finite S \<and> S \<noteq> {} \<and> S \<subseteq> p - {x} \<and> sum U S = 1 \<and> (\<Sum>v\<in>S. U v *\<^sub>R v) = x" |
700 if "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0" "finite S" "S \<subseteq> p" "sum u S = 0" "v \<in> S" "u v \<noteq> 0" for S u v |
582 if "(\<Sum>v\<in>S. U v *\<^sub>R v) = 0" "finite S" "S \<subseteq> p" "sum U S = 0" "v \<in> S" "U v \<noteq> 0" for S U v |
701 proof (intro bexI exI conjI) |
583 proof (intro bexI exI conjI) |
702 have "S \<noteq> {v}" |
584 have "S \<noteq> {v}" |
703 using that by auto |
585 using that by auto |
704 then show "S - {v} \<noteq> {}" |
586 then show "S - {v} \<noteq> {}" |
705 using that by auto |
587 using that by auto |
706 show "(\<Sum>x \<in> S - {v}. - (1 / u v) * u x) = 1" |
588 show "(\<Sum>x \<in> S - {v}. - (1 / U v) * U x) = 1" |
707 unfolding sum_distrib_left[symmetric] sum_diff1[OF \<open>finite S\<close>] by (simp add: that) |
589 unfolding sum_distrib_left[symmetric] sum_diff1[OF \<open>finite S\<close>] by (simp add: that) |
708 show "(\<Sum>x\<in>S - {v}. (- (1 / u v) * u x) *\<^sub>R x) = v" |
590 show "(\<Sum>x\<in>S - {v}. (- (1 / U v) * U x) *\<^sub>R x) = v" |
709 unfolding sum_distrib_left [symmetric] scaleR_scaleR[symmetric] |
591 unfolding sum_distrib_left [symmetric] scaleR_scaleR[symmetric] |
710 scaleR_right.sum [symmetric] sum_diff1[OF \<open>finite S\<close>] |
592 scaleR_right.sum [symmetric] sum_diff1[OF \<open>finite S\<close>] |
711 using that by auto |
593 using that by auto |
712 show "S - {v} \<subseteq> p - {v}" |
594 show "S - {v} \<subseteq> p - {v}" |
713 using that by auto |
595 using that by auto |
718 |
600 |
719 lemma affine_dependent_explicit_finite: |
601 lemma affine_dependent_explicit_finite: |
720 fixes S :: "'a::real_vector set" |
602 fixes S :: "'a::real_vector set" |
721 assumes "finite S" |
603 assumes "finite S" |
722 shows "affine_dependent S \<longleftrightarrow> |
604 shows "affine_dependent S \<longleftrightarrow> |
723 (\<exists>u. sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) S = 0)" |
605 (\<exists>U. sum U S = 0 \<and> (\<exists>v\<in>S. U v \<noteq> 0) \<and> sum (\<lambda>v. U v *\<^sub>R v) S = 0)" |
724 (is "?lhs = ?rhs") |
606 (is "?lhs = ?rhs") |
725 proof |
607 proof |
726 have *: "\<And>vt u v. (if vt then u v else 0) *\<^sub>R v = (if vt then (u v) *\<^sub>R v else 0::'a)" |
608 have *: "\<And>vt U v. (if vt then U v else 0) *\<^sub>R v = (if vt then (U v) *\<^sub>R v else 0::'a)" |
727 by auto |
609 by auto |
728 assume ?lhs |
610 assume ?lhs |
729 then obtain t u v where |
611 then obtain T U v where |
730 "finite t" "t \<subseteq> S" "sum u t = 0" "v\<in>t" "u v \<noteq> 0" "(\<Sum>v\<in>t. u v *\<^sub>R v) = 0" |
612 "finite T" "T \<subseteq> S" "sum U T = 0" "v\<in>T" "U v \<noteq> 0" "(\<Sum>v\<in>T. U v *\<^sub>R v) = 0" |
731 unfolding affine_dependent_explicit by auto |
613 unfolding affine_dependent_explicit by auto |
732 then show ?rhs |
614 then show ?rhs |
733 apply (rule_tac x="\<lambda>x. if x\<in>t then u x else 0" in exI) |
615 apply (rule_tac x="\<lambda>x. if x\<in>T then U x else 0" in exI) |
734 apply (auto simp: * sum.inter_restrict[OF assms, symmetric] Int_absorb1[OF \<open>t\<subseteq>S\<close>]) |
616 apply (auto simp: * sum.inter_restrict[OF assms, symmetric] Int_absorb1[OF \<open>T\<subseteq>S\<close>]) |
735 done |
617 done |
736 next |
618 next |
737 assume ?rhs |
619 assume ?rhs |
738 then obtain u v where "sum u S = 0" "v\<in>S" "u v \<noteq> 0" "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0" |
620 then obtain U v where "sum U S = 0" "v\<in>S" "U v \<noteq> 0" "(\<Sum>v\<in>S. U v *\<^sub>R v) = 0" |
739 by auto |
621 by auto |
740 then show ?lhs unfolding affine_dependent_explicit |
622 then show ?lhs unfolding affine_dependent_explicit |
741 using assms by auto |
623 using assms by auto |
742 qed |
624 qed |
743 |
625 |
744 lemma dependent_imp_affine_dependent: |
626 lemma dependent_imp_affine_dependent: |
745 assumes "dependent {x - a| x . x \<in> s}" |
627 assumes "dependent {x - a| x . x \<in> S}" |
746 and "a \<notin> s" |
628 and "a \<notin> S" |
747 shows "affine_dependent (insert a s)" |
629 shows "affine_dependent (insert a S)" |
748 proof - |
630 proof - |
749 from assms(1)[unfolded dependent_explicit] obtain S u v |
631 from assms(1)[unfolded dependent_explicit] obtain S' U v |
750 where obt: "finite S" "S \<subseteq> {x - a |x. x \<in> s}" "v\<in>S" "u v \<noteq> 0" "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0" |
632 where S: "finite S'" "S' \<subseteq> {x - a |x. x \<in> S}" "v\<in>S'" "U v \<noteq> 0" "(\<Sum>v\<in>S'. U v *\<^sub>R v) = 0" |
751 by auto |
633 by auto |
752 define t where "t = (\<lambda>x. x + a) ` S" |
634 define T where "T = (\<lambda>x. x + a) ` S'" |
753 |
635 have inj: "inj_on (\<lambda>x. x + a) S'" |
754 have inj: "inj_on (\<lambda>x. x + a) S" |
|
755 unfolding inj_on_def by auto |
636 unfolding inj_on_def by auto |
756 have "0 \<notin> S" |
637 have "0 \<notin> S'" |
757 using obt(2) assms(2) unfolding subset_eq by auto |
638 using S(2) assms(2) unfolding subset_eq by auto |
758 have fin: "finite t" and "t \<subseteq> s" |
639 have fin: "finite T" and "T \<subseteq> S" |
759 unfolding t_def using obt(1,2) by auto |
640 unfolding T_def using S(1,2) by auto |
760 then have "finite (insert a t)" and "insert a t \<subseteq> insert a s" |
641 then have "finite (insert a T)" and "insert a T \<subseteq> insert a S" |
761 by auto |
642 by auto |
762 moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x)) = (\<Sum>x\<in>t. Q x)" |
643 moreover have *: "\<And>P Q. (\<Sum>x\<in>T. (if x = a then P x else Q x)) = (\<Sum>x\<in>T. Q x)" |
763 apply (rule sum.cong) |
644 by (smt (verit, best) \<open>T \<subseteq> S\<close> assms(2) subsetD sum.cong) |
764 using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> |
645 have "(\<Sum>x\<in>insert a T. if x = a then - (\<Sum>x\<in>T. U (x - a)) else U (x - a)) = 0" |
765 apply auto |
646 by (smt (verit) \<open>T \<subseteq> S\<close> assms(2) fin insert_absorb insert_subset sum.insert sum_mono) |
766 done |
647 moreover have "\<exists>v\<in>insert a T. (if v = a then - (\<Sum>x\<in>T. U (x - a)) else U (v - a)) \<noteq> 0" |
767 have "(\<Sum>x\<in>insert a t. if x = a then - (\<Sum>x\<in>t. u (x - a)) else u (x - a)) = 0" |
648 using S(3,4) \<open>0\<notin>S'\<close> |
768 unfolding sum_clauses(2)[OF fin] * using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> by auto |
649 by (rule_tac x="v + a" in bexI) (auto simp: T_def) |
769 moreover have "\<exists>v\<in>insert a t. (if v = a then - (\<Sum>x\<in>t. u (x - a)) else u (v - a)) \<noteq> 0" |
650 moreover have *: "\<And>P Q. (\<Sum>x\<in>T. (if x = a then P x else Q x) *\<^sub>R x) = (\<Sum>x\<in>T. Q x *\<^sub>R x)" |
770 using obt(3,4) \<open>0\<notin>S\<close> |
651 using \<open>a\<notin>S\<close> \<open>T\<subseteq>S\<close> by (auto intro!: sum.cong) |
771 by (rule_tac x="v + a" in bexI) (auto simp: t_def) |
652 have "(\<Sum>x\<in>T. U (x - a)) *\<^sub>R a = (\<Sum>v\<in>T. U (v - a) *\<^sub>R v)" |
772 moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x) *\<^sub>R x) = (\<Sum>x\<in>t. Q x *\<^sub>R x)" |
|
773 using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> by (auto intro!: sum.cong) |
|
774 have "(\<Sum>x\<in>t. u (x - a)) *\<^sub>R a = (\<Sum>v\<in>t. u (v - a) *\<^sub>R v)" |
|
775 unfolding scaleR_left.sum |
653 unfolding scaleR_left.sum |
776 unfolding t_def and sum.reindex[OF inj] and o_def |
654 unfolding T_def and sum.reindex[OF inj] and o_def |
777 using obt(5) |
655 using S(5) |
778 by (auto simp: sum.distrib scaleR_right_distrib) |
656 by (auto simp: sum.distrib scaleR_right_distrib) |
779 then have "(\<Sum>v\<in>insert a t. (if v = a then - (\<Sum>x\<in>t. u (x - a)) else u (v - a)) *\<^sub>R v) = 0" |
657 then have "(\<Sum>v\<in>insert a T. (if v = a then - (\<Sum>x\<in>T. U (x - a)) else U (v - a)) *\<^sub>R v) = 0" |
780 unfolding sum_clauses(2)[OF fin] |
658 unfolding sum_clauses(2)[OF fin] using \<open>a\<notin>S\<close> \<open>T\<subseteq>S\<close> by (auto simp: *) |
781 using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> |
|
782 by (auto simp: *) |
|
783 ultimately show ?thesis |
659 ultimately show ?thesis |
784 unfolding affine_dependent_explicit |
660 unfolding affine_dependent_explicit |
785 apply (rule_tac x="insert a t" in exI, auto) |
661 by (force intro!: exI[where x="insert a T"]) |
786 done |
|
787 qed |
662 qed |
788 |
663 |
789 lemma affine_dependent_biggerset: |
664 lemma affine_dependent_biggerset: |
790 fixes s :: "'a::euclidean_space set" |
665 fixes S :: "'a::euclidean_space set" |
791 assumes "finite s" "card s \<ge> DIM('a) + 2" |
666 assumes "finite S" "card S \<ge> DIM('a) + 2" |
792 shows "affine_dependent s" |
667 shows "affine_dependent S" |
793 proof - |
668 proof - |
794 have "s \<noteq> {}" using assms by auto |
669 have "S \<noteq> {}" using assms by auto |
795 then obtain a where "a\<in>s" by auto |
670 then obtain a where "a\<in>S" by auto |
796 have *: "{x - a |x. x \<in> s - {a}} = (\<lambda>x. x - a) ` (s - {a})" |
671 have *: "{x - a |x. x \<in> S - {a}} = (\<lambda>x. x - a) ` (S - {a})" |
797 by auto |
672 by auto |
798 have "card {x - a |x. x \<in> s - {a}} = card (s - {a})" |
673 have "card {x - a |x. x \<in> S - {a}} = card (S - {a})" |
799 unfolding * by (simp add: card_image inj_on_def) |
674 unfolding * by (simp add: card_image inj_on_def) |
800 also have "\<dots> > DIM('a)" using assms(2) |
675 also have "\<dots> > DIM('a)" using assms(2) |
801 unfolding card_Diff_singleton[OF \<open>a\<in>s\<close>] by auto |
676 unfolding card_Diff_singleton[OF \<open>a\<in>S\<close>] by auto |
802 finally show ?thesis |
677 finally have "affine_dependent (insert a (S - {a}))" |
803 apply (subst insert_Diff[OF \<open>a\<in>s\<close>, symmetric]) |
678 using dependent_biggerset dependent_imp_affine_dependent by blast |
804 apply (rule dependent_imp_affine_dependent) |
679 then show ?thesis |
805 apply (rule dependent_biggerset, auto) |
680 by (simp add: \<open>a \<in> S\<close> insert_absorb) |
806 done |
|
807 qed |
681 qed |
808 |
682 |
809 lemma affine_dependent_biggerset_general: |
683 lemma affine_dependent_biggerset_general: |
810 assumes "finite (S :: 'a::euclidean_space set)" |
684 assumes "finite (S :: 'a::euclidean_space set)" |
811 and "card S \<ge> dim S + 2" |
685 and "card S \<ge> dim S + 2" |
943 qed |
799 qed |
944 |
800 |
945 lemma affine_dependent_iff_dependent2: |
801 lemma affine_dependent_iff_dependent2: |
946 assumes "a \<in> S" |
802 assumes "a \<in> S" |
947 shows "affine_dependent S \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` (S-{a}))" |
803 shows "affine_dependent S \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` (S-{a}))" |
948 proof - |
804 by (metis Diff_iff affine_dependent_iff_dependent assms insert_Diff singletonI) |
949 have "insert a (S - {a}) = S" |
|
950 using assms by auto |
|
951 then show ?thesis |
|
952 using assms affine_dependent_iff_dependent[of a "S-{a}"] by auto |
|
953 qed |
|
954 |
805 |
955 lemma affine_hull_insert_span_gen: |
806 lemma affine_hull_insert_span_gen: |
956 "affine hull (insert a s) = (\<lambda>x. a + x) ` span ((\<lambda>x. - a + x) ` s)" |
807 "affine hull (insert a S) = (\<lambda>x. a + x) ` span ((\<lambda>x. - a + x) ` S)" |
957 proof - |
808 proof - |
958 have h1: "{x - a |x. x \<in> s} = ((\<lambda>x. -a+x) ` s)" |
809 have h1: "{x - a |x. x \<in> S} = ((\<lambda>x. -a+x) ` S)" |
959 by auto |
810 by auto |
960 { |
811 { |
961 assume "a \<notin> s" |
812 assume "a \<notin> S" |
962 then have ?thesis |
813 then have ?thesis |
963 using affine_hull_insert_span[of a s] h1 by auto |
814 using affine_hull_insert_span[of a S] h1 by auto |
964 } |
815 } |
965 moreover |
816 moreover |
966 { |
817 { |
967 assume a1: "a \<in> s" |
818 assume a1: "a \<in> S" |
968 have "\<exists>x. x \<in> s \<and> -a+x=0" |
819 then have "insert 0 ((\<lambda>x. -a+x) ` (S - {a})) = (\<lambda>x. -a+x) ` S" |
969 apply (rule exI[of _ a]) |
|
970 using a1 |
|
971 apply auto |
|
972 done |
|
973 then have "insert 0 ((\<lambda>x. -a+x) ` (s - {a})) = (\<lambda>x. -a+x) ` s" |
|
974 by auto |
820 by auto |
975 then have "span ((\<lambda>x. -a+x) ` (s - {a}))=span ((\<lambda>x. -a+x) ` s)" |
821 then have "span ((\<lambda>x. -a+x) ` (S - {a})) = span ((\<lambda>x. -a+x) ` S)" |
976 using span_insert_0[of "(+) (- a) ` (s - {a})"] by (auto simp del: uminus_add_conv_diff) |
822 using span_insert_0[of "(+) (- a) ` (S - {a})"] |
977 moreover have "{x - a |x. x \<in> (s - {a})} = ((\<lambda>x. -a+x) ` (s - {a}))" |
823 by presburger |
|
824 moreover have "{x - a |x. x \<in> (S - {a})} = ((\<lambda>x. -a+x) ` (S - {a}))" |
978 by auto |
825 by auto |
979 moreover have "insert a (s - {a}) = insert a s" |
826 moreover have "insert a (S - {a}) = insert a S" |
980 by auto |
827 by auto |
981 ultimately have ?thesis |
828 ultimately have ?thesis |
982 using affine_hull_insert_span[of "a" "s-{a}"] by auto |
829 using affine_hull_insert_span[of "a" "S-{a}"] by auto |
983 } |
830 } |
984 ultimately show ?thesis by auto |
831 ultimately show ?thesis by auto |
985 qed |
832 qed |
986 |
833 |
987 lemma affine_hull_span2: |
834 lemma affine_hull_span2: |
988 assumes "a \<in> s" |
835 assumes "a \<in> S" |
989 shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` (s-{a}))" |
836 shows "affine hull S = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` (S-{a}))" |
990 using affine_hull_insert_span_gen[of a "s - {a}", unfolded insert_Diff[OF assms]] |
837 by (metis affine_hull_insert_span_gen assms insert_Diff) |
991 by auto |
|
992 |
838 |
993 lemma affine_hull_span_gen: |
839 lemma affine_hull_span_gen: |
994 assumes "a \<in> affine hull s" |
840 assumes "a \<in> affine hull S" |
995 shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` s)" |
841 shows "affine hull S = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` S)" |
996 proof - |
842 by (metis affine_hull_insert_span_gen assms hull_redundant) |
997 have "affine hull (insert a s) = affine hull s" |
|
998 using hull_redundant[of a affine s] assms by auto |
|
999 then show ?thesis |
|
1000 using affine_hull_insert_span_gen[of a "s"] by auto |
|
1001 qed |
|
1002 |
843 |
1003 lemma affine_hull_span_0: |
844 lemma affine_hull_span_0: |
1004 assumes "0 \<in> affine hull S" |
845 assumes "0 \<in> affine hull S" |
1005 shows "affine hull S = span S" |
846 shows "affine hull S = span S" |
1006 using affine_hull_span_gen[of "0" S] assms by auto |
847 using affine_hull_span_gen[of "0" S] assms by auto |
1270 |
1090 |
1271 lemma aff_dim_inner_basis_exists: |
1091 lemma aff_dim_inner_basis_exists: |
1272 fixes V :: "('n::euclidean_space) set" |
1092 fixes V :: "('n::euclidean_space) set" |
1273 shows "\<exists>B. B \<subseteq> V \<and> affine hull B = affine hull V \<and> |
1093 shows "\<exists>B. B \<subseteq> V \<and> affine hull B = affine hull V \<and> |
1274 \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1" |
1094 \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1" |
1275 proof - |
1095 by (metis aff_dim_unique affine_basis_exists) |
1276 obtain B where B: "\<not> affine_dependent B" "B \<subseteq> V" "affine hull B = affine hull V" |
|
1277 using affine_basis_exists[of V] by auto |
|
1278 then have "of_nat(card B) = aff_dim V+1" using aff_dim_unique by auto |
|
1279 with B show ?thesis by auto |
|
1280 qed |
|
1281 |
1096 |
1282 lemma aff_dim_le_card: |
1097 lemma aff_dim_le_card: |
1283 fixes V :: "'n::euclidean_space set" |
1098 fixes V :: "'n::euclidean_space set" |
1284 assumes "finite V" |
1099 assumes "finite V" |
1285 shows "aff_dim V \<le> of_nat (card V) - 1" |
1100 shows "aff_dim V \<le> of_nat (card V) - 1" |
1286 proof - |
1101 by (metis aff_dim_inner_basis_exists assms card_mono le_diff_eq of_nat_le_iff) |
1287 obtain B where B: "B \<subseteq> V" "of_nat (card B) = aff_dim V + 1" |
1102 |
1288 using aff_dim_inner_basis_exists[of V] by auto |
1103 lemma aff_dim_parallel_le: |
1289 then have "card B \<le> card V" |
1104 fixes S T :: "'n::euclidean_space set" |
1290 using assms card_mono by auto |
1105 assumes "affine_parallel (affine hull S) (affine hull T)" |
1291 with B show ?thesis by auto |
1106 shows "aff_dim S \<le> aff_dim T" |
|
1107 proof (cases "S={} \<or> T={}") |
|
1108 case True |
|
1109 then show ?thesis |
|
1110 by (smt (verit, best) aff_dim_affine_hull2 affine_hull_empty affine_parallel_def assms empty_is_image) |
|
1111 next |
|
1112 case False |
|
1113 then obtain L where L: "subspace L" "affine_parallel (affine hull T) L" |
|
1114 by (metis affine_affine_hull affine_hull_eq_empty affine_parallel_subspace) |
|
1115 with False show ?thesis |
|
1116 by (metis aff_dim_parallel_subspace affine_parallel_assoc assms dual_order.refl) |
1292 qed |
1117 qed |
1293 |
1118 |
1294 lemma aff_dim_parallel_eq: |
1119 lemma aff_dim_parallel_eq: |
1295 fixes S T :: "'n::euclidean_space set" |
1120 fixes S T :: "'n::euclidean_space set" |
1296 assumes "affine_parallel (affine hull S) (affine hull T)" |
1121 assumes "affine_parallel (affine hull S) (affine hull T)" |
1297 shows "aff_dim S = aff_dim T" |
1122 shows "aff_dim S = aff_dim T" |
1298 proof - |
1123 by (smt (verit, del_insts) aff_dim_parallel_le affine_parallel_commute assms) |
1299 { |
|
1300 assume "T \<noteq> {}" "S \<noteq> {}" |
|
1301 then obtain L where L: "subspace L \<and> affine_parallel (affine hull T) L" |
|
1302 using affine_parallel_subspace[of "affine hull T"] |
|
1303 affine_affine_hull[of T] |
|
1304 by auto |
|
1305 then have "aff_dim T = int (dim L)" |
|
1306 using aff_dim_parallel_subspace \<open>T \<noteq> {}\<close> by auto |
|
1307 moreover have *: "subspace L \<and> affine_parallel (affine hull S) L" |
|
1308 using L affine_parallel_assoc[of "affine hull S" "affine hull T" L] assms by auto |
|
1309 moreover from * have "aff_dim S = int (dim L)" |
|
1310 using aff_dim_parallel_subspace \<open>S \<noteq> {}\<close> by auto |
|
1311 ultimately have ?thesis by auto |
|
1312 } |
|
1313 moreover |
|
1314 { |
|
1315 assume "S = {}" |
|
1316 then have "S = {}" and "T = {}" |
|
1317 using assms |
|
1318 unfolding affine_parallel_def |
|
1319 by auto |
|
1320 then have ?thesis using aff_dim_empty by auto |
|
1321 } |
|
1322 moreover |
|
1323 { |
|
1324 assume "T = {}" |
|
1325 then have "S = {}" and "T = {}" |
|
1326 using assms |
|
1327 unfolding affine_parallel_def |
|
1328 by auto |
|
1329 then have ?thesis |
|
1330 using aff_dim_empty by auto |
|
1331 } |
|
1332 ultimately show ?thesis by blast |
|
1333 qed |
|
1334 |
1124 |
1335 lemma aff_dim_translation_eq: |
1125 lemma aff_dim_translation_eq: |
1336 "aff_dim ((+) a ` S) = aff_dim S" for a :: "'n::euclidean_space" |
1126 "aff_dim ((+) a ` S) = aff_dim S" for a :: "'n::euclidean_space" |
1337 proof - |
1127 by (metis aff_dim_parallel_eq affine_hull_translation affine_parallel_def) |
1338 have "affine_parallel (affine hull S) (affine hull ((\<lambda>x. a + x) ` S))" |
|
1339 unfolding affine_parallel_def |
|
1340 apply (rule exI[of _ "a"]) |
|
1341 using affine_hull_translation[of a S] |
|
1342 apply auto |
|
1343 done |
|
1344 then show ?thesis |
|
1345 using aff_dim_parallel_eq[of S "(\<lambda>x. a + x) ` S"] by auto |
|
1346 qed |
|
1347 |
1128 |
1348 lemma aff_dim_translation_eq_subtract: |
1129 lemma aff_dim_translation_eq_subtract: |
1349 "aff_dim ((\<lambda>x. x - a) ` S) = aff_dim S" for a :: "'n::euclidean_space" |
1130 "aff_dim ((\<lambda>x. x - a) ` S) = aff_dim S" for a :: "'n::euclidean_space" |
1350 using aff_dim_translation_eq [of "- a"] by (simp cong: image_cong_simp) |
1131 using aff_dim_translation_eq [of "- a"] by (simp cong: image_cong_simp) |
1351 |
1132 |
1352 lemma aff_dim_affine: |
1133 lemma aff_dim_affine: |
1353 fixes S L :: "'n::euclidean_space set" |
1134 fixes S L :: "'n::euclidean_space set" |
1354 assumes "S \<noteq> {}" |
1135 assumes "affine S" "subspace L" "affine_parallel S L" "S \<noteq> {}" |
1355 and "affine S" |
|
1356 and "subspace L" |
|
1357 and "affine_parallel S L" |
|
1358 shows "aff_dim S = int (dim L)" |
1136 shows "aff_dim S = int (dim L)" |
1359 proof - |
1137 by (simp add: aff_dim_parallel_subspace assms hull_same) |
1360 have *: "affine hull S = S" |
1138 |
1361 using assms affine_hull_eq[of S] by auto |
1139 lemma dim_affine_hull [simp]: |
1362 then have "affine_parallel (affine hull S) L" |
|
1363 using assms by (simp add: *) |
|
1364 then show ?thesis |
|
1365 using assms aff_dim_parallel_subspace[of S L] by blast |
|
1366 qed |
|
1367 |
|
1368 lemma dim_affine_hull: |
|
1369 fixes S :: "'n::euclidean_space set" |
1140 fixes S :: "'n::euclidean_space set" |
1370 shows "dim (affine hull S) = dim S" |
1141 shows "dim (affine hull S) = dim S" |
1371 proof - |
1142 by (metis affine_hull_subset_span dim_eq_span dim_mono hull_subset span_eq_dim) |
1372 have "dim (affine hull S) \<ge> dim S" |
|
1373 using dim_subset by auto |
|
1374 moreover have "dim (span S) \<ge> dim (affine hull S)" |
|
1375 using dim_subset affine_hull_subset_span by blast |
|
1376 moreover have "dim (span S) = dim S" |
|
1377 using dim_span by auto |
|
1378 ultimately show ?thesis by auto |
|
1379 qed |
|
1380 |
1143 |
1381 lemma aff_dim_subspace: |
1144 lemma aff_dim_subspace: |
1382 fixes S :: "'n::euclidean_space set" |
1145 fixes S :: "'n::euclidean_space set" |
1383 assumes "subspace S" |
1146 assumes "subspace S" |
1384 shows "aff_dim S = int (dim S)" |
1147 shows "aff_dim S = int (dim S)" |
1385 proof (cases "S={}") |
1148 by (metis aff_dim_affine affine_parallel_subspace assms empty_iff parallel_subspace subspace_affine) |
1386 case True with assms show ?thesis |
|
1387 by (simp add: subspace_affine) |
|
1388 next |
|
1389 case False |
|
1390 with aff_dim_affine[of S S] assms subspace_imp_affine[of S] affine_parallel_reflex[of S] subspace_affine |
|
1391 show ?thesis by auto |
|
1392 qed |
|
1393 |
1149 |
1394 lemma aff_dim_zero: |
1150 lemma aff_dim_zero: |
1395 fixes S :: "'n::euclidean_space set" |
1151 fixes S :: "'n::euclidean_space set" |
1396 assumes "0 \<in> affine hull S" |
1152 assumes "0 \<in> affine hull S" |
1397 shows "aff_dim S = int (dim S)" |
1153 shows "aff_dim S = int (dim S)" |
1398 proof - |
1154 by (metis aff_dim_affine_hull aff_dim_subspace affine_hull_span_0 assms dim_span subspace_span) |
1399 have "subspace (affine hull S)" |
|
1400 using subspace_affine[of "affine hull S"] affine_affine_hull assms |
|
1401 by auto |
|
1402 then have "aff_dim (affine hull S) = int (dim (affine hull S))" |
|
1403 using assms aff_dim_subspace[of "affine hull S"] by auto |
|
1404 then show ?thesis |
|
1405 using aff_dim_affine_hull[of S] dim_affine_hull[of S] |
|
1406 by auto |
|
1407 qed |
|
1408 |
1155 |
1409 lemma aff_dim_eq_dim: |
1156 lemma aff_dim_eq_dim: |
1410 "aff_dim S = int (dim ((+) (- a) ` S))" if "a \<in> affine hull S" |
1157 fixes S :: "'n::euclidean_space set" |
1411 for S :: "'n::euclidean_space set" |
1158 assumes "a \<in> affine hull S" |
1412 proof - |
1159 shows "aff_dim S = int (dim ((+) (- a) ` S))" |
1413 have "0 \<in> affine hull (+) (- a) ` S" |
1160 by (metis ab_left_minus aff_dim_translation_eq aff_dim_zero affine_hull_translation image_eqI assms) |
1414 unfolding affine_hull_translation |
|
1415 using that by (simp add: ac_simps) |
|
1416 with aff_dim_zero show ?thesis |
|
1417 by (metis aff_dim_translation_eq) |
|
1418 qed |
|
1419 |
1161 |
1420 lemma aff_dim_eq_dim_subtract: |
1162 lemma aff_dim_eq_dim_subtract: |
1421 "aff_dim S = int (dim ((\<lambda>x. x - a) ` S))" if "a \<in> affine hull S" |
1163 fixes S :: "'n::euclidean_space set" |
1422 for S :: "'n::euclidean_space set" |
1164 assumes "a \<in> affine hull S" |
1423 using aff_dim_eq_dim [of a] that by (simp cong: image_cong_simp) |
1165 shows "aff_dim S = int (dim ((\<lambda>x. x - a) ` S))" |
|
1166 using aff_dim_eq_dim assms by auto |
1424 |
1167 |
1425 lemma aff_dim_UNIV [simp]: "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))" |
1168 lemma aff_dim_UNIV [simp]: "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))" |
1426 using aff_dim_subspace[of "(UNIV :: 'n::euclidean_space set)"] |
1169 by (simp add: aff_dim_subspace) |
1427 dim_UNIV[where 'a="'n::euclidean_space"] |
|
1428 by auto |
|
1429 |
1170 |
1430 lemma aff_dim_geq: |
1171 lemma aff_dim_geq: |
1431 fixes V :: "'n::euclidean_space set" |
1172 fixes V :: "'n::euclidean_space set" |
1432 shows "aff_dim V \<ge> -1" |
1173 shows "aff_dim V \<ge> -1" |
1433 proof - |
1174 by (metis add_le_cancel_right aff_dim_basis_exists diff_self of_nat_0_le_iff uminus_add_conv_diff) |
1434 obtain B where "affine hull B = affine hull V" |
|
1435 and "\<not> affine_dependent B" |
|
1436 and "int (card B) = aff_dim V + 1" |
|
1437 using aff_dim_basis_exists by auto |
|
1438 then show ?thesis by auto |
|
1439 qed |
|
1440 |
1175 |
1441 lemma aff_dim_negative_iff [simp]: |
1176 lemma aff_dim_negative_iff [simp]: |
1442 fixes S :: "'n::euclidean_space set" |
1177 fixes S :: "'n::euclidean_space set" |
1443 shows "aff_dim S < 0 \<longleftrightarrow>S = {}" |
1178 shows "aff_dim S < 0 \<longleftrightarrow> S = {}" |
1444 by (metis aff_dim_empty aff_dim_geq diff_0 eq_iff zle_diff1_eq) |
1179 by (metis aff_dim_empty aff_dim_geq diff_0 eq_iff zle_diff1_eq) |
1445 |
1180 |
1446 lemma aff_lowdim_subset_hyperplane: |
1181 lemma aff_lowdim_subset_hyperplane: |
1447 fixes S :: "'a::euclidean_space set" |
1182 fixes S :: "'a::euclidean_space set" |
1448 assumes "aff_dim S < DIM('a)" |
1183 assumes "aff_dim S < DIM('a)" |
1449 obtains a b where "a \<noteq> 0" "S \<subseteq> {x. a \<bullet> x = b}" |
1184 obtains a b where "a \<noteq> 0" "S \<subseteq> {x. a \<bullet> x = b}" |
1480 |
1215 |
1481 lemma affine_independent_card_dim_diffs: |
1216 lemma affine_independent_card_dim_diffs: |
1482 fixes S :: "'a :: euclidean_space set" |
1217 fixes S :: "'a :: euclidean_space set" |
1483 assumes "\<not> affine_dependent S" "a \<in> S" |
1218 assumes "\<not> affine_dependent S" "a \<in> S" |
1484 shows "card S = dim ((\<lambda>x. x - a) ` S) + 1" |
1219 shows "card S = dim ((\<lambda>x. x - a) ` S) + 1" |
1485 proof - |
1220 using aff_dim_affine_independent aff_dim_eq_dim_subtract assms hull_subset by fastforce |
1486 have non: "\<not> affine_dependent (insert a S)" |
|
1487 by (simp add: assms insert_absorb) |
|
1488 have "finite S" |
|
1489 by (meson assms aff_independent_finite) |
|
1490 with \<open>a \<in> S\<close> have "card S \<noteq> 0" by auto |
|
1491 moreover have "dim ((\<lambda>x. x - a) ` S) = card S - 1" |
|
1492 using aff_dim_eq_dim_subtract aff_dim_unique \<open>a \<in> S\<close> hull_inc insert_absorb non by fastforce |
|
1493 ultimately show ?thesis |
|
1494 by auto |
|
1495 qed |
|
1496 |
1221 |
1497 lemma independent_card_le_aff_dim: |
1222 lemma independent_card_le_aff_dim: |
1498 fixes B :: "'n::euclidean_space set" |
1223 fixes B :: "'n::euclidean_space set" |
1499 assumes "B \<subseteq> V" |
1224 assumes "B \<subseteq> V" |
1500 assumes "\<not> affine_dependent B" |
1225 assumes "\<not> affine_dependent B" |
1501 shows "int (card B) \<le> aff_dim V + 1" |
1226 shows "int (card B) \<le> aff_dim V + 1" |
1502 proof - |
1227 by (metis aff_dim_unique aff_independent_finite assms card_mono extend_to_affine_basis of_nat_mono) |
1503 obtain T where T: "\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V" |
|
1504 by (metis assms extend_to_affine_basis[of B V]) |
|
1505 then have "of_nat (card T) = aff_dim V + 1" |
|
1506 using aff_dim_unique by auto |
|
1507 then show ?thesis |
|
1508 using T card_mono[of T B] aff_independent_finite[of T] by auto |
|
1509 qed |
|
1510 |
1228 |
1511 lemma aff_dim_subset: |
1229 lemma aff_dim_subset: |
1512 fixes S T :: "'n::euclidean_space set" |
1230 fixes S T :: "'n::euclidean_space set" |
1513 assumes "S \<subseteq> T" |
1231 assumes "S \<subseteq> T" |
1514 shows "aff_dim S \<le> aff_dim T" |
1232 shows "aff_dim S \<le> aff_dim T" |
1515 proof - |
1233 by (metis add_le_cancel_right aff_dim_inner_basis_exists assms dual_order.trans independent_card_le_aff_dim) |
1516 obtain B where B: "\<not> affine_dependent B" "B \<subseteq> S" "affine hull B = affine hull S" |
|
1517 "of_nat (card B) = aff_dim S + 1" |
|
1518 using aff_dim_inner_basis_exists[of S] by auto |
|
1519 then have "int (card B) \<le> aff_dim T + 1" |
|
1520 using assms independent_card_le_aff_dim[of B T] by auto |
|
1521 with B show ?thesis by auto |
|
1522 qed |
|
1523 |
1234 |
1524 lemma aff_dim_le_DIM: |
1235 lemma aff_dim_le_DIM: |
1525 fixes S :: "'n::euclidean_space set" |
1236 fixes S :: "'n::euclidean_space set" |
1526 shows "aff_dim S \<le> int (DIM('n))" |
1237 shows "aff_dim S \<le> int (DIM('n))" |
1527 proof - |
1238 by (metis aff_dim_UNIV aff_dim_subset top_greatest) |
1528 have "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))" |
|
1529 using aff_dim_UNIV by auto |
|
1530 then show "aff_dim (S:: 'n::euclidean_space set) \<le> int(DIM('n))" |
|
1531 using aff_dim_subset[of S "(UNIV :: ('n::euclidean_space) set)"] subset_UNIV by auto |
|
1532 qed |
|
1533 |
1239 |
1534 lemma affine_dim_equal: |
1240 lemma affine_dim_equal: |
1535 fixes S :: "'n::euclidean_space set" |
1241 fixes S :: "'n::euclidean_space set" |
1536 assumes "affine S" "affine T" "S \<noteq> {}" "S \<subseteq> T" "aff_dim S = aff_dim T" |
1242 assumes "affine S" "affine T" "S \<noteq> {}" "S \<subseteq> T" "aff_dim S = aff_dim T" |
1537 shows "S = T" |
1243 shows "S = T" |
1538 proof - |
1244 proof - |
1539 obtain a where "a \<in> S" using assms by auto |
1245 obtain a where "a \<in> S" "a \<in> T" "T \<noteq> {}" using assms by auto |
1540 then have "a \<in> T" using assms by auto |
|
1541 define LS where "LS = {y. \<exists>x \<in> S. (-a) + x = y}" |
1246 define LS where "LS = {y. \<exists>x \<in> S. (-a) + x = y}" |
1542 then have ls: "subspace LS" "affine_parallel S LS" |
1247 then have ls: "subspace LS" "affine_parallel S LS" |
1543 using assms parallel_subspace_explicit[of S a LS] \<open>a \<in> S\<close> by auto |
1248 using assms parallel_subspace_explicit[of S a LS] \<open>a \<in> S\<close> by auto |
1544 then have h1: "int(dim LS) = aff_dim S" |
1249 then have h1: "int(dim LS) = aff_dim S" |
1545 using assms aff_dim_affine[of S LS] by auto |
1250 using assms aff_dim_affine[of S LS] by auto |
1546 have "T \<noteq> {}" using assms by auto |
|
1547 define LT where "LT = {y. \<exists>x \<in> T. (-a) + x = y}" |
1251 define LT where "LT = {y. \<exists>x \<in> T. (-a) + x = y}" |
1548 then have lt: "subspace LT \<and> affine_parallel T LT" |
1252 then have lt: "subspace LT \<and> affine_parallel T LT" |
1549 using assms parallel_subspace_explicit[of T a LT] \<open>a \<in> T\<close> by auto |
1253 using assms parallel_subspace_explicit[of T a LT] \<open>a \<in> T\<close> by auto |
1550 then have "int(dim LT) = aff_dim T" |
|
1551 using assms aff_dim_affine[of T LT] \<open>T \<noteq> {}\<close> by auto |
|
1552 then have "dim LS = dim LT" |
1254 then have "dim LS = dim LT" |
1553 using h1 assms by auto |
1255 using assms aff_dim_affine[of T LT] \<open>T \<noteq> {}\<close> h1 by auto |
1554 moreover have "LS \<le> LT" |
1256 moreover have "LS \<le> LT" |
1555 using LS_def LT_def assms by auto |
1257 using LS_def LT_def assms by auto |
1556 ultimately have "LS = LT" |
1258 ultimately have "LS = LT" |
1557 using subspace_dim_equal[of LS LT] ls lt by auto |
1259 using subspace_dim_equal[of LS LT] ls lt by auto |
1558 moreover have "S = {x. \<exists>y \<in> LS. a+y=x}" |
1260 moreover have "S = {x. \<exists>y \<in> LS. a+y=x}" "T = {x. \<exists>y \<in> LT. a+y=x}" |
1559 using LS_def by auto |
1261 using LS_def LT_def by auto |
1560 moreover have "T = {x. \<exists>y \<in> LT. a+y=x}" |
|
1561 using LT_def by auto |
|
1562 ultimately show ?thesis by auto |
1262 ultimately show ?thesis by auto |
1563 qed |
1263 qed |
1564 |
1264 |
1565 lemma aff_dim_eq_0: |
1265 lemma aff_dim_eq_0: |
1566 fixes S :: "'a::euclidean_space set" |
1266 fixes S :: "'a::euclidean_space set" |
1567 shows "aff_dim S = 0 \<longleftrightarrow> (\<exists>a. S = {a})" |
1267 shows "aff_dim S = 0 \<longleftrightarrow> (\<exists>a. S = {a})" |
1568 proof (cases "S = {}") |
1268 proof (cases "S = {}") |
1569 case True |
|
1570 then show ?thesis |
|
1571 by auto |
|
1572 next |
|
1573 case False |
1269 case False |
1574 then obtain a where "a \<in> S" by auto |
1270 then obtain a where "a \<in> S" by auto |
1575 show ?thesis |
1271 show ?thesis |
1576 proof safe |
1272 proof safe |
1577 assume 0: "aff_dim S = 0" |
1273 assume 0: "aff_dim S = 0" |
1578 have "\<not> {a,b} \<subseteq> S" if "b \<noteq> a" for b |
1274 have "\<not> {a,b} \<subseteq> S" if "b \<noteq> a" for b |
1579 by (metis "0" aff_dim_2 aff_dim_subset not_one_le_zero that) |
1275 by (metis "0" aff_dim_2 aff_dim_subset not_one_le_zero that) |
1580 then show "\<exists>a. S = {a}" |
1276 then show "\<exists>a. S = {a}" |
1581 using \<open>a \<in> S\<close> by blast |
1277 using \<open>a \<in> S\<close> by blast |
1582 qed auto |
1278 qed auto |
1583 qed |
1279 qed auto |
1584 |
1280 |
1585 lemma affine_hull_UNIV: |
1281 lemma affine_hull_UNIV: |
1586 fixes S :: "'n::euclidean_space set" |
1282 fixes S :: "'n::euclidean_space set" |
1587 assumes "aff_dim S = int(DIM('n))" |
1283 assumes "aff_dim S = int(DIM('n))" |
1588 shows "affine hull S = (UNIV :: ('n::euclidean_space) set)" |
1284 shows "affine hull S = (UNIV :: ('n::euclidean_space) set)" |
1589 proof - |
1285 by (simp add: aff_dim_empty affine_dim_equal assms) |
1590 have "S \<noteq> {}" |
|
1591 using assms aff_dim_empty[of S] by auto |
|
1592 have h0: "S \<subseteq> affine hull S" |
|
1593 using hull_subset[of S _] by auto |
|
1594 have h1: "aff_dim (UNIV :: ('n::euclidean_space) set) = aff_dim S" |
|
1595 using aff_dim_UNIV assms by auto |
|
1596 then have h2: "aff_dim (affine hull S) \<le> aff_dim (UNIV :: ('n::euclidean_space) set)" |
|
1597 using aff_dim_le_DIM[of "affine hull S"] assms h0 by auto |
|
1598 have h3: "aff_dim S \<le> aff_dim (affine hull S)" |
|
1599 using h0 aff_dim_subset[of S "affine hull S"] assms by auto |
|
1600 then have h4: "aff_dim (affine hull S) = aff_dim (UNIV :: ('n::euclidean_space) set)" |
|
1601 using h0 h1 h2 by auto |
|
1602 then show ?thesis |
|
1603 using affine_dim_equal[of "affine hull S" "(UNIV :: ('n::euclidean_space) set)"] |
|
1604 affine_affine_hull[of S] affine_UNIV assms h4 h0 \<open>S \<noteq> {}\<close> |
|
1605 by auto |
|
1606 qed |
|
1607 |
1286 |
1608 lemma disjoint_affine_hull: |
1287 lemma disjoint_affine_hull: |
1609 fixes s :: "'n::euclidean_space set" |
1288 fixes S :: "'n::euclidean_space set" |
1610 assumes "\<not> affine_dependent s" "t \<subseteq> s" "u \<subseteq> s" "t \<inter> u = {}" |
1289 assumes "\<not> affine_dependent S" "T \<subseteq> S" "U \<subseteq> S" "T \<inter> U = {}" |
1611 shows "(affine hull t) \<inter> (affine hull u) = {}" |
1290 shows "(affine hull T) \<inter> (affine hull U) = {}" |
1612 proof - |
1291 proof - |
1613 from assms(1) have "finite s" |
1292 obtain "finite S" "finite T" "finite U" |
1614 by (simp add: aff_independent_finite) |
1293 using assms by (simp add: aff_independent_finite finite_subset) |
1615 with assms(2,3) have "finite t" "finite u" |
1294 have False if "y \<in> affine hull T" and "y \<in> affine hull U" for y |
1616 by (blast intro: finite_subset)+ |
|
1617 have False if "y \<in> affine hull t" and "y \<in> affine hull u" for y |
|
1618 proof - |
1295 proof - |
1619 from that obtain a b |
1296 from that obtain a b |
1620 where a1 [simp]: "sum a t = 1" |
1297 where a1 [simp]: "sum a T = 1" |
1621 and [simp]: "sum (\<lambda>v. a v *\<^sub>R v) t = y" |
1298 and [simp]: "sum (\<lambda>v. a v *\<^sub>R v) T = y" |
1622 and [simp]: "sum b u = 1" "sum (\<lambda>v. b v *\<^sub>R v) u = y" |
1299 and [simp]: "sum b U = 1" "sum (\<lambda>v. b v *\<^sub>R v) U = y" |
1623 by (auto simp: affine_hull_finite \<open>finite t\<close> \<open>finite u\<close>) |
1300 by (auto simp: affine_hull_finite \<open>finite T\<close> \<open>finite U\<close>) |
1624 define c where "c x = (if x \<in> t then a x else if x \<in> u then -(b x) else 0)" for x |
1301 define c where "c x = (if x \<in> T then a x else if x \<in> U then -(b x) else 0)" for x |
1625 from assms(2,3,4) have [simp]: "s \<inter> t = t" "s \<inter> - t \<inter> u = u" |
1302 have [simp]: "S \<inter> T = T" "S \<inter> - T \<inter> U = U" |
1626 by auto |
1303 using assms by auto |
1627 have "sum c s = 0" |
1304 have "sum c S = 0" |
1628 by (simp add: c_def comm_monoid_add_class.sum.If_cases \<open>finite s\<close> sum_negf) |
1305 by (simp add: c_def comm_monoid_add_class.sum.If_cases \<open>finite S\<close> sum_negf) |
1629 moreover have "\<not> (\<forall>v\<in>s. c v = 0)" |
1306 moreover have "\<not> (\<forall>v\<in>S. c v = 0)" |
1630 by (metis (no_types) IntD1 \<open>s \<inter> t = t\<close> a1 c_def sum.neutral zero_neq_one) |
1307 by (metis (no_types) IntD1 \<open>S \<inter> T = T\<close> a1 c_def sum.neutral zero_neq_one) |
1631 moreover have "(\<Sum>v\<in>s. c v *\<^sub>R v) = 0" |
1308 moreover have "(\<Sum>v\<in>S. c v *\<^sub>R v) = 0" |
1632 by (simp add: c_def if_smult sum_negf comm_monoid_add_class.sum.If_cases \<open>finite s\<close>) |
1309 by (simp add: c_def if_smult sum_negf comm_monoid_add_class.sum.If_cases \<open>finite S\<close>) |
1633 ultimately show ?thesis |
1310 ultimately show ?thesis |
1634 using assms(1) \<open>finite s\<close> by (auto simp: affine_dependent_explicit) |
1311 using assms(1) \<open>finite S\<close> by (auto simp: affine_dependent_explicit) |
1635 qed |
1312 qed |
1636 then show ?thesis by blast |
1313 then show ?thesis by blast |
1637 qed |
1314 qed |
1638 |
1315 |
1639 end |
1316 end |