src/HOL/ex/Erdoes_Szekeres.thy
author wenzelm
Fri, 19 Jun 2020 16:12:32 +0200
changeset 71960 6a64205b491a
parent 71472 c213d067e60f
permissions -rw-r--r--
avoid redundant export handling for build;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
     1
(*   Title: HOL/ex/Erdős_Szekeres.thy
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
     2
     Author: Lukas Bulwahn <lukas.bulwahn-at-gmail.com>
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
     3
*)
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
     4
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
     5
section \<open>The Erdös-Szekeres Theorem\<close>
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
     6
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
     7
theory Erdoes_Szekeres
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
     8
imports Main
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
     9
begin
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    10
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    11
lemma exists_set_with_max_card:
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    12
  assumes "finite S" "S \<noteq> {}"
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    13
  shows "\<exists>s \<in> S. card s = Max (card ` S)"
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    14
  by (metis (mono_tags, lifting) Max_in assms finite_imageI imageE image_is_empty)
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    15
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
    16
subsection \<open>Definition of Monotonicity over a Carrier Set\<close>
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    17
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    18
definition
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    19
  "gen_mono_on f R S = (\<forall>i\<in>S. \<forall>j\<in>S. i \<le> j \<longrightarrow> R (f i) (f j))"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    20
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    21
lemma gen_mono_on_empty [simp]: "gen_mono_on f R {}"
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    22
  unfolding gen_mono_on_def by auto
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    23
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    24
lemma gen_mono_on_singleton [simp]: "reflp R \<Longrightarrow> gen_mono_on f R {x}"
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    25
  unfolding gen_mono_on_def reflp_def by auto
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    26
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    27
lemma gen_mono_on_subset: "T \<subseteq> S \<Longrightarrow> gen_mono_on f R S \<Longrightarrow> gen_mono_on f R T"
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    28
  unfolding gen_mono_on_def by (simp add: subset_iff)
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    29
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    30
lemma not_gen_mono_on_subset: "T \<subseteq> S \<Longrightarrow> \<not> gen_mono_on f R T \<Longrightarrow> \<not> gen_mono_on f R S"
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    31
  unfolding gen_mono_on_def by blast
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    32
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    33
lemma [simp]:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    34
  "reflp ((\<le>) :: 'a::order \<Rightarrow> _ \<Rightarrow> bool)"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    35
  "reflp ((\<ge>) :: 'a::order \<Rightarrow> _ \<Rightarrow> bool)"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    36
  "transp ((\<le>) :: 'a::order \<Rightarrow> _ \<Rightarrow> bool)"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    37
  "transp ((\<ge>) :: 'a::order \<Rightarrow> _ \<Rightarrow> bool)"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    38
unfolding reflp_def transp_def by auto
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    39
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
    40
subsection \<open>The Erdoes-Szekeres Theorem following Seidenberg's (1959) argument\<close>
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    41
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    42
lemma Erdoes_Szekeres:
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    43
  fixes f :: "_ \<Rightarrow> 'a::linorder"
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    44
  shows "(\<exists>S. S \<subseteq> {0..m * n} \<and> card S = m + 1 \<and> gen_mono_on f (\<le>) S) \<or>
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    45
         (\<exists>S. S \<subseteq> {0..m * n} \<and> card S = n + 1 \<and> gen_mono_on f (\<ge>) S)"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    46
proof (rule ccontr)
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    47
  let ?max_subseq = "\<lambda>R k. Max (card ` {S. S \<subseteq> {0..k} \<and> gen_mono_on f R S \<and> k \<in> S})"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    48
  define phi where "phi k = (?max_subseq (\<le>) k, ?max_subseq (\<ge>) k)" for k
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    49
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    50
  have one_member: "\<And>R k. reflp R \<Longrightarrow> {k} \<in> {S. S \<subseteq> {0..k} \<and> gen_mono_on f R S \<and> k \<in> S}" by auto
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    51
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    52
  {
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    53
    fix R
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    54
    assume reflp: "reflp (R :: 'a::linorder \<Rightarrow> _)"
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    55
    from one_member[OF this] have non_empty: "\<And>k. {S. S \<subseteq> {0..k} \<and> gen_mono_on f R S \<and> k \<in> S} \<noteq> {}" by force
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    56
    from one_member[OF reflp] have "\<And>k. card {k} \<in> card ` {S. S \<subseteq> {0..k} \<and> gen_mono_on f R S \<and> k \<in> S}" by blast
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    57
    from this have lower_bound: "\<And>k. k \<le> m * n \<Longrightarrow> ?max_subseq R k \<ge> 1"
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    58
      by (auto intro!: Max_ge)
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    59
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    60
    fix b
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    61
    assume not_mono_at: "\<forall>S. S \<subseteq> {0..m * n} \<and> card S = b + 1 \<longrightarrow> \<not> gen_mono_on f R S"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    62
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    63
    {
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    64
      fix S
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    65
      assume "S \<subseteq> {0..m * n}" "card S \<ge> b + 1"
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
    66
      moreover from \<open>card S \<ge> b + 1\<close> obtain T where "T \<subseteq> S \<and> card T = Suc b"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    67
        using obtain_subset_with_card_n by (metis Suc_eq_plus1)
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    68
      ultimately have "\<not> gen_mono_on f R S" using not_mono_at by (auto dest: not_gen_mono_on_subset)
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    69
    }
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    70
    from this have "\<forall>S. S \<subseteq> {0..m * n} \<and> gen_mono_on f R S \<longrightarrow> card S \<le> b"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    71
      by (metis Suc_eq_plus1 Suc_leI not_le)
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    72
    from this have "\<And>k. k \<le> m * n \<Longrightarrow> \<forall>S. S \<subseteq> {0..k} \<and> gen_mono_on f R S \<longrightarrow> card S \<le> b"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    73
      using order_trans by force
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    74
    from this non_empty have upper_bound: "\<And>k. k \<le> m * n \<Longrightarrow> ?max_subseq R k \<le> b"
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    75
      by (auto intro: Max.boundedI)
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    76
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    77
    from upper_bound lower_bound have "\<And>k. k \<le> m * n \<Longrightarrow> 1 \<le> ?max_subseq R k \<and> ?max_subseq R k \<le> b"
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    78
      by auto
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    79
  } note bounds = this
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    80
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    81
  assume contraposition: "\<not> ?thesis"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    82
  from contraposition bounds[of "(\<le>)" "m"] bounds[of "(\<ge>)" "n"]
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    83
    have "\<And>k. k \<le> m * n \<Longrightarrow> 1 \<le> ?max_subseq (\<le>) k \<and> ?max_subseq (\<le>) k \<le> m"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
    84
    and  "\<And>k. k \<le> m * n \<Longrightarrow> 1 \<le> ?max_subseq (\<ge>) k \<and> ?max_subseq (\<ge>) k \<le> n"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    85
    using reflp_def by simp+
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    86
  from this have "\<forall>i \<in> {0..m * n}. phi i \<in> {1..m} \<times> {1..n}"
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    87
    unfolding phi_def by auto
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    88
  from this have subseteq: "phi ` {0..m * n} \<subseteq> {1..m} \<times> {1..n}" by blast
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    89
  have card_product: "card ({1..m} \<times> {1..n}) = m * n" by (simp add: card_cartesian_product)
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    90
  have "finite ({1..m} \<times> {1..n})" by blast
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    91
  from subseteq card_product this have card_le: "card (phi ` {0..m * n}) \<le> m * n" by (metis card_mono)
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    92
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    93
  {
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    94
    fix i j
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    95
    assume "i < (j :: nat)"
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    96
    {
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    97
      fix R
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
    98
      assume R: "reflp (R :: 'a::linorder \<Rightarrow> _)" "transp R" "R (f i) (f j)"
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
    99
      from one_member[OF \<open>reflp R\<close>, of "i"] have
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   100
        "\<exists>S \<in> {S. S \<subseteq> {0..i} \<and> gen_mono_on f R S \<and> i \<in> S}. card S = ?max_subseq R i"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   101
        by (intro exists_set_with_max_card) auto
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   102
      from this obtain S where S: "S \<subseteq> {0..i} \<and> gen_mono_on f R S \<and> i \<in> S" "card S = ?max_subseq R i" by auto
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
   103
      from S \<open>i < j\<close> finite_subset have "j \<notin> S" "finite S" "insert j S \<subseteq> {0..j}" by auto
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   104
      from S(1) R \<open>i < j\<close> this have "gen_mono_on f R (insert j S)"
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   105
        unfolding gen_mono_on_def reflp_def transp_def
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   106
        by (metis atLeastAtMost_iff insert_iff le_antisym subsetCE)
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   107
      from this have d: "insert j S \<in> {S. S \<subseteq> {0..j} \<and> gen_mono_on f R S \<and> j \<in> S}"
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
   108
        using \<open>insert j S \<subseteq> {0..j}\<close> by blast
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
   109
      from this \<open>j \<notin> S\<close> S(1) have "card (insert j S) \<in>
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   110
        card ` {S. S \<subseteq> {0..j} \<and> gen_mono_on f R S \<and> j \<in> S} \<and> card S < card (insert j S)"
61343
5b5656a63bd6 isabelle update_cartouches;
wenzelm
parents: 60603
diff changeset
   111
        by (auto intro!: imageI) (auto simp add: \<open>finite S\<close>)
71472
c213d067e60f Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   112
      from this S(2) have "?max_subseq R i < ?max_subseq R j" by (auto intro!: Max_gr_iff [THEN iffD2])
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   113
    } note max_subseq_increase = this
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
   114
    have "?max_subseq (\<le>) i < ?max_subseq (\<le>) j \<or> ?max_subseq (\<ge>) i < ?max_subseq (\<ge>) j"
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   115
    proof (cases "f j \<ge> f i")
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   116
      case True
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
   117
      from this max_subseq_increase[of "(\<le>)", simplified] show ?thesis by simp
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   118
    next
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   119
      case False
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63040
diff changeset
   120
      from this max_subseq_increase[of "(\<ge>)", simplified] show ?thesis by simp
60603
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   121
    qed
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   122
    from this have "phi i \<noteq> phi j" using phi_def by auto
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   123
  }
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   124
  from this have "inj phi" unfolding inj_on_def by (metis less_linear)
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   125
  from this have card_eq: "card (phi ` {0..m * n}) = m * n + 1" by (simp add: card_image inj_on_def)
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   126
  from card_le card_eq show False by simp
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   127
qed
09ecbd791d4a add examples from Freek's top 100 theorems (thms 30, 73, 77)
bulwahn
parents:
diff changeset
   128
62390
842917225d56 more canonical names
nipkow
parents: 61343
diff changeset
   129
end