src/HOL/Isar_Examples/Knaster_Tarski.thy
author wenzelm
Tue, 10 Nov 2015 19:56:51 +0100
changeset 61616 abbecf4e6601
parent 61541 846c72206207
child 61932 2e48182cc82c
permissions -rw-r--r--
unused;
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
6882
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
     2
    Author:     Markus Wenzel, TU Muenchen
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
41413
64cd30d6b0b8 explicit file specifications -- avoid secondary load path;
wenzelm
parents: 37671
diff changeset
    10
imports Main "~~/src/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
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    16
text \<open>According to the textbook @{cite \<open>pages 93--94\<close> "davey-priestley"},
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    17
  the Knaster-Tarski fixpoint theorem is as follows.\footnote{We have
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    18
  dualized the argument, and tuned the notation a little bit.}
7153
wenzelm
parents: 7133
diff changeset
    19
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    20
  \<^bold>\<open>The Knaster-Tarski Fixpoint Theorem.\<close> Let \<open>L\<close> be a complete lattice and
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    21
  \<open>f: L \<rightarrow> L\<close> an order-preserving map. Then \<open>\<Sqinter>{x \<in> L | f(x) \<le> x}\<close> is a
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    22
  fixpoint of \<open>f\<close>.
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    23
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    24
  \<^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
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    25
  have \<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>,
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    26
  whence \<open>f(a) \<le> a\<close>. We now use this inequality to prove the reverse one (!)
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    27
  and thereby complete the proof that \<open>a\<close> is a fixpoint. Since \<open>f\<close> is
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    28
  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
    29
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    30
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    31
subsection \<open>Formal versions\<close>
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    32
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    33
text \<open>The Isar proof below closely follows the original presentation.
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    34
  Virtually all of the prose narration has been rephrased in terms of formal
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    35
  Isar language elements. Just as many textbook-style proofs, there is a
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    36
  strong bias towards forward proof, and several bends in the course of
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    37
  reasoning.\<close>
6882
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
    38
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
    39
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
    40
  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
    41
  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
    42
  shows "\<exists>a. f a = a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    43
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
    44
  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
    45
  let ?a = "\<Sqinter>?H"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    46
  show "f ?a = ?a"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    47
  proof -
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    48
    {
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    49
      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
    50
      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
    51
      then have "?a \<le> x" by (rule Inf_lower)
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    52
      with \<open>mono f\<close> have "f ?a \<le> f x" ..
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    53
      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
    54
      finally have "f ?a \<le> x" .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    55
    }
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
    then have "f ?a \<le> ?a" by (rule Inf_greatest)
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
      also presume "\<dots> \<le> f ?a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    59
      finally (order_antisym) show ?thesis .
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    60
    }
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    61
    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
    62
    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
    63
    then show "?a \<le> f ?a" by (rule Inf_lower)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    64
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    65
qed
6898
2650bd68c0ba variant version;
wenzelm
parents: 6897
diff changeset
    66
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    67
text \<open>Above we have used several advanced Isar language elements, such as
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    68
  explicit block structure and weak assumptions. Thus we have mimicked the
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    69
  particular way of reasoning of the original text.
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
    70
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    71
  In the subsequent version the order of reasoning is changed to achieve
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    72
  structured top-down decomposition of the problem at the outer level, while
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    73
  only the inner steps of reasoning are done in a forward manner. We are
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    74
  certainly more at ease here, requiring only the most basic features of the
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    75
  Isar language.\<close>
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
    76
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
    77
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
    78
  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
    79
  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
    80
  shows "\<exists>a. f a = a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    81
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
    82
  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
    83
  let ?a = "\<Sqinter>?H"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    84
  show "f ?a = ?a"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    85
  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
    86
    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
    87
    proof (rule Inf_greatest)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    88
      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
    89
      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
    90
      then have "?a \<le> x" by (rule Inf_lower)
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    91
      with \<open>mono f\<close> have "f ?a \<le> f x" ..
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    92
      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
    93
      finally show "f ?a \<le> x" .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    94
    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
    95
    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
    96
    proof (rule Inf_lower)
58614
7338eb25226c more cartouches;
wenzelm
parents: 41413
diff changeset
    97
      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
    98
      then show "f ?a \<in> ?H" ..
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    99
    qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   100
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   101
qed
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
   102
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   103
end