src/HOL/Isar_Examples/Knaster_Tarski.thy
author paulson
Tue, 29 Aug 2017 17:41:27 +0100
changeset 66553 6ab32ffb2bdd
parent 66453 cc19f7ca2ed6
permissions -rw-r--r--
merged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33026
8f35633c4922 modernized session Isar_Examples;
wenzelm
parents: 31758
diff changeset
     1
(*  Title:      HOL/Isar_Examples/Knaster_Tarski.thy
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
     2
    Author:     Makarius
6882
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
     3
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
     4
Typical textbook proof example.
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
     5
*)
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
     6
58882
6e2010ab8bd9 modernized header;
wenzelm
parents: 58614
diff changeset
     7
section \<open>Textbook-style reasoning: the Knaster-Tarski Theorem\<close>
6882
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
     8
31758
3edd5f813f01 observe standard theory naming conventions;
wenzelm
parents: 30816
diff changeset
     9
theory Knaster_Tarski
66453
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 63583
diff changeset
    10
  imports Main "HOL-Library.Lattice_Syntax"
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    11
begin
6882
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
    12
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    13
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    14
subsection \<open>Prose version\<close>
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    15
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    16
text \<open>
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    17
  According to the textbook @{cite \<open>pages 93--94\<close> "davey-priestley"}, the
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    18
  Knaster-Tarski fixpoint theorem is as follows.\<^footnote>\<open>We have dualized the
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    19
  argument, and tuned the notation a little bit.\<close>
7153
wenzelm
parents: 7133
diff changeset
    20
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    21
  \<^bold>\<open>The Knaster-Tarski Fixpoint Theorem.\<close> Let \<open>L\<close> be a complete lattice and
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    22
  \<open>f: L \<rightarrow> L\<close> an order-preserving map. Then \<open>\<Sqinter>{x \<in> L | f(x) \<le> x}\<close> is a fixpoint
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    23
  of \<open>f\<close>.
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    24
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    25
  \<^bold>\<open>Proof.\<close> Let \<open>H = {x \<in> L | f(x) \<le> x}\<close> and \<open>a = \<Sqinter>H\<close>. For all \<open>x \<in> H\<close> we have
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    26
  \<open>a \<le> x\<close>, so \<open>f(a) \<le> f(x) \<le> x\<close>. Thus \<open>f(a)\<close> is a lower bound of \<open>H\<close>, whence
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    27
  \<open>f(a) \<le> a\<close>. We now use this inequality to prove the reverse one (!) and
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    28
  thereby complete the proof that \<open>a\<close> is a fixpoint. Since \<open>f\<close> is
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    29
  order-preserving, \<open>f(f(a)) \<le> f(a)\<close>. This says \<open>f(a) \<in> H\<close>, so \<open>a \<le> f(a)\<close>.\<close>
6883
f898679685b7 fixed order_trans;
wenzelm
parents: 6882
diff changeset
    30
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    31
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    32
subsection \<open>Formal versions\<close>
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    33
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    34
text \<open>
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    35
  The Isar proof below closely follows the original presentation. Virtually
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    36
  all of the prose narration has been rephrased in terms of formal Isar
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    37
  language elements. Just as many textbook-style proofs, there is a strong
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    38
  bias towards forward proof, and several bends in the course of reasoning.
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    39
\<close>
6882
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
    40
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    41
theorem Knaster_Tarski:
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    42
  fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    43
  assumes "mono f"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    44
  shows "\<exists>a. f a = a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    45
proof
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    46
  let ?H = "{u. f u \<le> u}"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    47
  let ?a = "\<Sqinter>?H"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    48
  show "f ?a = ?a"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    49
  proof -
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    50
    {
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    51
      fix x
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    52
      assume "x \<in> ?H"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    53
      then have "?a \<le> x" by (rule Inf_lower)
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    54
      with \<open>mono f\<close> have "f ?a \<le> f x" ..
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    55
      also from \<open>x \<in> ?H\<close> have "\<dots> \<le> x" ..
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    56
      finally have "f ?a \<le> x" .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    57
    }
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    58
    then have "f ?a \<le> ?a" by (rule Inf_greatest)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    59
    {
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    60
      also presume "\<dots> \<le> f ?a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    61
      finally (order_antisym) show ?thesis .
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    62
    }
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    63
    from \<open>mono f\<close> and \<open>f ?a \<le> ?a\<close> have "f (f ?a) \<le> f ?a" ..
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    64
    then have "f ?a \<in> ?H" ..
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    65
    then show "?a \<le> f ?a" by (rule Inf_lower)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    66
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    67
qed
6898
2650bd68c0ba variant version;
wenzelm
parents: 6897
diff changeset
    68
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    69
text \<open>
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    70
  Above we have used several advanced Isar language elements, such as explicit
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    71
  block structure and weak assumptions. Thus we have mimicked the particular
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    72
  way of reasoning of the original text.
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
    73
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    74
  In the subsequent version the order of reasoning is changed to achieve
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    75
  structured top-down decomposition of the problem at the outer level, while
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    76
  only the inner steps of reasoning are done in a forward manner. We are
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    77
  certainly more at ease here, requiring only the most basic features of the
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    78
  Isar language.
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    79
\<close>
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
    80
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    81
theorem Knaster_Tarski':
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    82
  fixes f :: "'a::complete_lattice \<Rightarrow> 'a"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    83
  assumes "mono f"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    84
  shows "\<exists>a. f a = a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    85
proof
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    86
  let ?H = "{u. f u \<le> u}"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    87
  let ?a = "\<Sqinter>?H"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    88
  show "f ?a = ?a"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    89
  proof (rule order_antisym)
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    90
    show "f ?a \<le> ?a"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    91
    proof (rule Inf_greatest)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    92
      fix x
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    93
      assume "x \<in> ?H"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    94
      then have "?a \<le> x" by (rule Inf_lower)
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    95
      with \<open>mono f\<close> have "f ?a \<le> f x" ..
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    96
      also from \<open>x \<in> ?H\<close> have "\<dots> \<le> x" ..
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    97
      finally show "f ?a \<le> x" .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    98
    qed
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    99
    show "?a \<le> f ?a"
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
   100
    proof (rule Inf_lower)
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
   101
      from \<open>mono f\<close> and \<open>f ?a \<le> ?a\<close> have "f (f ?a) \<le> f ?a" ..
30816
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
   102
      then show "f ?a \<in> ?H" ..
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   103
    qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   104
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   105
qed
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
   106
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   107
end