src/HOL/Isar_Examples/Knaster_Tarski.thy
author wenzelm
Tue, 03 Sep 2013 01:12:40 +0200
changeset 53374 a14d2a854c02
parent 41413 64cd30d6b0b8
child 58614 7338eb25226c
permissions -rw-r--r--
tuned proofs -- clarified flow of facts wrt. calculation;
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
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
     7
header {* Textbook-style reasoning: the Knaster-Tarski Theorem *}
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
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    14
subsection {* Prose version *}
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    15
37671
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    16
text {* According to the textbook \cite[pages
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    17
  93--94]{davey-priestley}, the Knaster-Tarski fixpoint theorem is as
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    18
  follows.\footnote{We have dualized the argument, and tuned the
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    19
  notation a little bit.}
7153
wenzelm
parents: 7133
diff changeset
    20
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
    21
  \textbf{The Knaster-Tarski Fixpoint Theorem.}  Let @{text L} be 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
    22
  complete lattice and @{text "f: L \<rightarrow> L"} an order-preserving map.
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    23
  Then @{text "\<Sqinter>{x \<in> L | f(x) \<le> x}"} is a fixpoint of @{text f}.
7153
wenzelm
parents: 7133
diff changeset
    24
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
    25
  \textbf{Proof.} Let @{text "H = {x \<in> L | f(x) \<le> x}"} and @{text "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
    26
  \<Sqinter>H"}.  For all @{text "x \<in> H"} we have @{text "a \<le> x"}, so @{text
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    27
  "f(a) \<le> f(x) \<le> x"}.  Thus @{text "f(a)"} is a lower bound of @{text
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    28
  H}, whence @{text "f(a) \<le> a"}.  We now use this inequality to prove
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    29
  the reverse one (!) and thereby complete the proof that @{text a} is
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    30
  a fixpoint.  Since @{text f} is order-preserving, @{text "f(f(a)) \<le>
37671
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    31
  f(a)"}.  This says @{text "f(a) \<in> H"}, so @{text "a \<le> f(a)"}. *}
6883
f898679685b7 fixed order_trans;
wenzelm
parents: 6882
diff changeset
    32
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    33
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    34
subsection {* Formal versions *}
7761
7fab9592384f improved presentation;
wenzelm
parents: 7480
diff changeset
    35
37671
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    36
text {* The Isar proof below closely follows the original
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    37
  presentation.  Virtually all of the prose narration has been
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    38
  rephrased in terms of formal Isar language elements.  Just as many
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    39
  textbook-style proofs, there is a strong bias towards forward proof,
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    40
  and several bends in the course of reasoning. *}
6882
fe4e3d26fa8f added KnasterTarski.thy;
wenzelm
parents:
diff changeset
    41
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
    42
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
    43
  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
    44
  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
    45
  shows "\<exists>a. f a = a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    46
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
    47
  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
    48
  let ?a = "\<Sqinter>?H"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    49
  show "f ?a = ?a"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    50
  proof -
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    51
    {
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    52
      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
    53
      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
    54
      then have "?a \<le> x" by (rule Inf_lower)
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    55
      with `mono f` have "f ?a \<le> f x" ..
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
      also from `x \<in> ?H` have "\<dots> \<le> x" ..
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    57
      finally have "f ?a \<le> x" .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    58
    }
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
    59
    then have "f ?a \<le> ?a" by (rule Inf_greatest)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    60
    {
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
    61
      also presume "\<dots> \<le> f ?a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    62
      finally (order_antisym) show ?thesis .
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    63
    }
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
    from `mono f` and `f ?a \<le> ?a` have "f (f ?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
    65
    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
    66
    then show "?a \<le> f ?a" by (rule Inf_lower)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    67
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    68
qed
6898
2650bd68c0ba variant version;
wenzelm
parents: 6897
diff changeset
    69
37671
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    70
text {* Above we have used several advanced Isar language elements,
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    71
  such as explicit block structure and weak assumptions.  Thus we have
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
    72
  mimicked the particular way of reasoning of the original text.
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
    73
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
    74
  In the subsequent version the order of reasoning is changed to
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    75
  achieve structured top-down decomposition of the problem at the
4de62c902f9a replaced 'a set by abstract 'a::complete_lattice, and recover plain reasoning instead of adhoc automation (by simp);
wenzelm
parents: 26812
diff changeset
    76
  outer level, while only the inner steps of reasoning are done in 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
    77
  forward manner.  We are certainly more at ease here, requiring only
37671
fa53d267dab3 misc tuning and modernization;
wenzelm
parents: 33026
diff changeset
    78
  the most basic features of the Isar language. *}
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
    79
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
    80
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
    81
  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
    82
  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
    83
  shows "\<exists>a. f a = a"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    84
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
    85
  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
    86
  let ?a = "\<Sqinter>?H"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    87
  show "f ?a = ?a"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    88
  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
    89
    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
    90
    proof (rule Inf_greatest)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    91
      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
    92
      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
    93
      then have "?a \<le> x" by (rule Inf_lower)
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
      with `mono f` have "f ?a \<le> f x" ..
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
      also from `x \<in> ?H` have "\<dots> \<le> x" ..
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
      finally show "f ?a \<le> x" .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
    97
    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
    98
    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
    99
    proof (rule Inf_lower)
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
      from `mono f` and `f ?a \<le> ?a` have "f (f ?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
   101
      then show "f ?a \<in> ?H" ..
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   102
    qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   103
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   104
qed
7818
1acfb8cc3720 added structured version of the proof;
wenzelm
parents: 7761
diff changeset
   105
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 8902
diff changeset
   106
end