src/HOL/Order_Relation.thy
author wenzelm
Sun, 31 Dec 2023 19:24:37 +0100
changeset 79409 e1895596e1b9
parent 75669 43f5dfb7fa35
permissions -rw-r--r--
minor performance tuning: proper Same.operation; clarified modules;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54552
5d57cbec0f0f moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
blanchet
parents: 54551
diff changeset
     1
(*  Title:      HOL/Order_Relation.thy
5d57cbec0f0f moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
blanchet
parents: 54551
diff changeset
     2
    Author:     Tobias Nipkow
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
     3
    Author:     Andrei Popescu, TU Muenchen
54552
5d57cbec0f0f moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
blanchet
parents: 54551
diff changeset
     4
*)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     5
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
     6
section \<open>Orders as Relations\<close>
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     7
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
     8
theory Order_Relation
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
     9
imports Wfrec
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    10
begin
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    11
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    12
subsection \<open>Orders on a set\<close>
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    13
30198
922f944f03b2 name changes
nipkow
parents: 29859
diff changeset
    14
definition "preorder_on A r \<equiv> refl_on A r \<and> trans r"
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    15
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    16
definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    17
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    18
definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    19
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    20
definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    21
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    22
definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    23
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    24
lemmas order_on_defs =
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    25
  preorder_on_def partial_order_on_def linear_order_on_def
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    26
  strict_linear_order_on_def well_order_on_def
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    27
68745
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
    28
lemma partial_order_onD:
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
    29
  assumes "partial_order_on A r" shows "refl_on A r" and "trans r" and "antisym r"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
    30
  using assms unfolding partial_order_on_def preorder_on_def by auto
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    31
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    32
lemma preorder_on_empty[simp]: "preorder_on {} {}"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    33
  by (simp add: preorder_on_def trans_def)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    34
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    35
lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    36
  by (simp add: partial_order_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    37
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    38
lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    39
  by (simp add: linear_order_on_def)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    40
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    41
lemma well_order_on_empty[simp]: "well_order_on {} {}"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    42
  by (simp add: well_order_on_def)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    43
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    44
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    45
lemma preorder_on_converse[simp]: "preorder_on A (r\<inverse>) = preorder_on A r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    46
  by (simp add: preorder_on_def)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    47
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    48
lemma partial_order_on_converse[simp]: "partial_order_on A (r\<inverse>) = partial_order_on A r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    49
  by (simp add: partial_order_on_def)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    50
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    51
lemma linear_order_on_converse[simp]: "linear_order_on A (r\<inverse>) = linear_order_on A r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    52
  by (simp add: linear_order_on_def)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    53
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    54
70180
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    55
lemma partial_order_on_acyclic:
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    56
  "partial_order_on A r \<Longrightarrow> acyclic (r - Id)"
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    57
  by (simp add: acyclic_irrefl partial_order_on_def preorder_on_def trans_diff_Id)
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    58
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    59
lemma partial_order_on_well_order_on:               
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    60
  "finite r \<Longrightarrow> partial_order_on A r \<Longrightarrow> wf (r - Id)" 
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    61
  by (simp add: finite_acyclic_wf partial_order_on_acyclic) 
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
    62
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    63
lemma strict_linear_order_on_diff_Id: "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r - Id)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    64
  by (simp add: order_on_defs trans_diff_Id)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    65
63563
0bcd79da075b prefer [simp] over [iff] as [iff] break HOL-UNITY
Andreas Lochbihler
parents: 63561
diff changeset
    66
lemma linear_order_on_singleton [simp]: "linear_order_on {x} {(x, x)}"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    67
  by (simp add: order_on_defs)
63561
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    68
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    69
lemma linear_order_on_acyclic:
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    70
  assumes "linear_order_on A r"
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    71
  shows "acyclic (r - Id)"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    72
  using strict_linear_order_on_diff_Id[OF assms]
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    73
  by (auto simp add: acyclic_irrefl strict_linear_order_on_def)
63561
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    74
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    75
lemma linear_order_on_well_order_on:
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    76
  assumes "finite r"
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    77
  shows "linear_order_on A r \<longleftrightarrow> well_order_on A r"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    78
  unfolding well_order_on_def
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    79
  using assms finite_acyclic_wf[OF _ linear_order_on_acyclic, of r] by blast
63561
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
    80
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    81
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    82
subsection \<open>Orders on the field\<close>
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    83
30198
922f944f03b2 name changes
nipkow
parents: 29859
diff changeset
    84
abbreviation "Refl r \<equiv> refl_on (Field r) r"
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    85
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    86
abbreviation "Preorder r \<equiv> preorder_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    87
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    88
abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    89
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    90
abbreviation "Total r \<equiv> total_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    91
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    92
abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    93
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    94
abbreviation "Well_order r \<equiv> well_order_on (Field r) r"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
    95
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    96
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
    97
lemma subset_Image_Image_iff:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    98
  "Preorder r \<Longrightarrow> A \<subseteq> Field r \<Longrightarrow> B \<subseteq> Field r \<Longrightarrow>
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
    99
    r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b, a) \<in> r)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   100
  apply (simp add: preorder_on_def refl_on_def Image_def subset_eq)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   101
  apply (simp only: trans_def)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   102
  apply fast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   103
  done
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   104
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   105
lemma subset_Image1_Image1_iff:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   106
  "Preorder r \<Longrightarrow> a \<in> Field r \<Longrightarrow> b \<in> Field r \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b, a) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   107
  by (simp add: subset_Image_Image_iff)
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   108
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   109
lemma Refl_antisym_eq_Image1_Image1_iff:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   110
  assumes "Refl r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   111
    and as: "antisym r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   112
    and abf: "a \<in> Field r" "b \<in> Field r"
54552
5d57cbec0f0f moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
blanchet
parents: 54551
diff changeset
   113
  shows "r `` {a} = r `` {b} \<longleftrightarrow> a = b"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   114
    (is "?lhs \<longleftrightarrow> ?rhs")
54552
5d57cbec0f0f moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
blanchet
parents: 54551
diff changeset
   115
proof
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   116
  assume ?lhs
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   117
  then have *: "\<And>x. (a, x) \<in> r \<longleftrightarrow> (b, x) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   118
    by (simp add: set_eq_iff)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   119
  have "(a, a) \<in> r" "(b, b) \<in> r" using \<open>Refl r\<close> abf by (simp_all add: refl_on_def)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   120
  then have "(a, b) \<in> r" "(b, a) \<in> r" using *[of a] *[of b] by simp_all
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   121
  then show ?rhs
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   122
    using \<open>antisym r\<close>[unfolded antisym_def] by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   123
next
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   124
  assume ?rhs
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   125
  then show ?lhs by fast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   126
qed
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   127
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   128
lemma Partial_order_eq_Image1_Image1_iff:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   129
  "Partial_order r \<Longrightarrow> a \<in> Field r \<Longrightarrow> b \<in> Field r \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a = b"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   130
  by (auto simp: order_on_defs Refl_antisym_eq_Image1_Image1_iff)
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   131
52182
57b4fdc59d3b well-order extension (by Christian Sternagel)
popescua
parents: 48750
diff changeset
   132
lemma Total_Id_Field:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   133
  assumes "Total r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   134
    and not_Id: "\<not> r \<subseteq> Id"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   135
  shows "Field r = Field (r - Id)"
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   136
proof -
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   137
  have "Field r \<subseteq> Field (r - Id)"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   138
  proof (rule subsetI)
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   139
    fix a assume *: "a \<in> Field r"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   140
    from not_Id have "r \<noteq> {}" by fast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   141
    with not_Id obtain b and c where "b \<noteq> c \<and> (b,c) \<in> r" by auto
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   142
    then have "b \<noteq> c \<and> {b, c} \<subseteq> Field r" by (auto simp: Field_def)
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   143
    with * obtain d where "d \<in> Field r" "d \<noteq> a" by auto
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   144
    with * \<open>Total r\<close> have "(a, d) \<in> r \<or> (d, a) \<in> r" by (simp add: total_on_def)
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   145
    with \<open>d \<noteq> a\<close> show "a \<in> Field (r - Id)" unfolding Field_def by blast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   146
  qed
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   147
  then show ?thesis
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   148
    using mono_Field[of "r - Id" r] Diff_subset[of r Id] by auto
52182
57b4fdc59d3b well-order extension (by Christian Sternagel)
popescua
parents: 48750
diff changeset
   149
qed
57b4fdc59d3b well-order extension (by Christian Sternagel)
popescua
parents: 48750
diff changeset
   150
68745
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   151
subsection\<open>Relations given by a predicate and the field\<close>
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   152
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   153
definition relation_of :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   154
  where "relation_of P A \<equiv> { (a, b) \<in> A \<times> A. P a b }"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   155
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   156
lemma Field_relation_of:
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   157
  assumes "refl_on A (relation_of P A)" shows "Field (relation_of P A) = A"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   158
  using assms unfolding refl_on_def Field_def by auto
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   159
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   160
lemma partial_order_on_relation_ofI:
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   161
  assumes refl: "\<And>a. a \<in> A \<Longrightarrow> P a a"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   162
    and trans: "\<And>a b c. \<lbrakk> a \<in> A; b \<in> A; c \<in> A \<rbrakk> \<Longrightarrow> P a b \<Longrightarrow> P b c \<Longrightarrow> P a c"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   163
    and antisym: "\<And>a b. \<lbrakk> a \<in> A; b \<in> A \<rbrakk> \<Longrightarrow> P a b \<Longrightarrow> P b a \<Longrightarrow> a = b"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   164
  shows "partial_order_on A (relation_of P A)"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   165
proof -
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   166
  from refl have "refl_on A (relation_of P A)"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   167
    unfolding refl_on_def relation_of_def by auto
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   168
  moreover have "trans (relation_of P A)" and "antisym (relation_of P A)"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   169
    unfolding relation_of_def
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   170
    by (auto intro: transI dest: trans, auto intro: antisymI dest: antisym)
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   171
  ultimately show ?thesis
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   172
    unfolding partial_order_on_def preorder_on_def by simp
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   173
qed
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   174
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   175
lemma Partial_order_relation_ofI:
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   176
  assumes "partial_order_on A (relation_of P A)" shows "Partial_order (relation_of P A)"
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   177
  using Field_relation_of assms partial_order_on_def preorder_on_def by fastforce
345ce5f262ea Zorn's lemma for relations defined by predicates
paulson <lp15@cam.ac.uk>
parents: 68484
diff changeset
   178
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   179
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   180
subsection \<open>Orders on a type\<close>
26295
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   181
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   182
abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   183
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   184
abbreviation "linear_order \<equiv> linear_order_on UNIV"
afc43168ed85 More defns and thms
nipkow
parents: 26273
diff changeset
   185
54551
4cd6deb430c3 fixed apparent copy-paste bug
blanchet
parents: 54482
diff changeset
   186
abbreviation "well_order \<equiv> well_order_on UNIV"
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   187
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   188
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   189
subsection \<open>Order-like relations\<close>
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   190
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   191
text \<open>
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   192
  In this subsection, we develop basic concepts and results pertaining
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   193
  to order-like relations, i.e., to reflexive and/or transitive and/or symmetric and/or
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   194
  total relations. We also further define upper and lower bounds operators.
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   195
\<close>
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   196
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   197
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   198
subsubsection \<open>Auxiliaries\<close>
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   199
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   200
lemma refl_on_domain: "refl_on A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> a \<in> A \<and> b \<in> A"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   201
  by (auto simp add: refl_on_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   202
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   203
corollary well_order_on_domain: "well_order_on A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> a \<in> A \<and> b \<in> A"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   204
  by (auto simp add: refl_on_domain order_on_defs)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   205
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   206
lemma well_order_on_Field: "well_order_on A r \<Longrightarrow> A = Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   207
  by (auto simp add: refl_on_def Field_def order_on_defs)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   208
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   209
lemma well_order_on_Well_order: "well_order_on A r \<Longrightarrow> A = Field r \<and> Well_order r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   210
  using well_order_on_Field [of A] by auto
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   211
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   212
lemma Total_subset_Id:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   213
  assumes "Total r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   214
    and "r \<subseteq> Id"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   215
  shows "r = {} \<or> (\<exists>a. r = {(a, a)})"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   216
proof -
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   217
  have "\<exists>a. r = {(a, a)}" if "r \<noteq> {}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   218
  proof -
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   219
    from that obtain a b where ab: "(a, b) \<in> r" by fast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   220
    with \<open>r \<subseteq> Id\<close> have "a = b" by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   221
    with ab have aa: "(a, a) \<in> r" by simp
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   222
    have "a = c \<and> a = d" if "(c, d) \<in> r" for c d
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   223
    proof -
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   224
      from that have "{a, c, d} \<subseteq> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   225
        using ab unfolding Field_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   226
      then have "((a, c) \<in> r \<or> (c, a) \<in> r \<or> a = c) \<and> ((a, d) \<in> r \<or> (d, a) \<in> r \<or> a = d)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   227
        using \<open>Total r\<close> unfolding total_on_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   228
      with \<open>r \<subseteq> Id\<close> show ?thesis by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   229
    qed
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   230
    then have "r \<subseteq> {(a, a)}" by auto
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   231
    with aa show ?thesis by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   232
  qed
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   233
  then show ?thesis by blast
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   234
qed
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   235
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   236
lemma Linear_order_in_diff_Id:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   237
  assumes "Linear_order r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   238
    and "a \<in> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   239
    and "b \<in> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   240
  shows "(a, b) \<in> r \<longleftrightarrow> (b, a) \<notin> r - Id"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   241
  using assms unfolding order_on_defs total_on_def antisym_def Id_def refl_on_def by force
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   242
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   243
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   244
subsubsection \<open>The upper and lower bounds operators\<close>
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   245
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   246
text \<open>
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   247
  Here we define upper (``above") and lower (``below") bounds operators. We
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   248
  think of \<open>r\<close> as a \<^emph>\<open>non-strict\<close> relation. The suffix \<open>S\<close> at the names of
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   249
  some operators indicates that the bounds are strict -- e.g., \<open>underS a\<close> is
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   250
  the set of all strict lower bounds of \<open>a\<close> (w.r.t. \<open>r\<close>). Capitalization of
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   251
  the first letter in the name reminds that the operator acts on sets, rather
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   252
  than on individual elements.
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   253
\<close>
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   254
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   255
definition under :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   256
  where "under r a \<equiv> {b. (b, a) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   257
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   258
definition underS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   259
  where "underS r a \<equiv> {b. b \<noteq> a \<and> (b, a) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   260
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   261
definition Under :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   262
  where "Under r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (b, a) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   263
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   264
definition UnderS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   265
  where "UnderS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (b, a) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   266
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   267
definition above :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   268
  where "above r a \<equiv> {b. (a, b) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   269
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   270
definition aboveS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   271
  where "aboveS r a \<equiv> {b. b \<noteq> a \<and> (a, b) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   272
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   273
definition Above :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   274
  where "Above r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (a, b) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   275
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   276
definition AboveS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   277
  where "AboveS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (a, b) \<in> r}"
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   278
55173
5556470a02b7 define ofilter outside of wo_rel
traytel
parents: 55027
diff changeset
   279
definition ofilter :: "'a rel \<Rightarrow> 'a set \<Rightarrow> bool"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   280
  where "ofilter r A \<equiv> A \<subseteq> Field r \<and> (\<forall>a \<in> A. under r a \<subseteq> A)"
55173
5556470a02b7 define ofilter outside of wo_rel
traytel
parents: 55027
diff changeset
   281
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   282
text \<open>
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   283
  Note: In the definitions of \<open>Above[S]\<close> and \<open>Under[S]\<close>, we bounded
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   284
  comprehension by \<open>Field r\<close> in order to properly cover the case of \<open>A\<close> being
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   285
  empty.
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   286
\<close>
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   287
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   288
lemma underS_subset_under: "underS r a \<subseteq> under r a"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   289
  by (auto simp add: underS_def under_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   290
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   291
lemma underS_notIn: "a \<notin> underS r a"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   292
  by (simp add: underS_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   293
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   294
lemma Refl_under_in: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> a \<in> under r a"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   295
  by (simp add: refl_on_def under_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   296
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   297
lemma AboveS_disjoint: "A \<inter> (AboveS r A) = {}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   298
  by (auto simp add: AboveS_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   299
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   300
lemma in_AboveS_underS: "a \<in> Field r \<Longrightarrow> a \<in> AboveS r (underS r a)"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   301
  by (auto simp add: AboveS_def underS_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   302
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   303
lemma Refl_under_underS: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> under r a = underS r a \<union> {a}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   304
  unfolding under_def underS_def
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   305
  using refl_on_def[of _ r] by fastforce
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   306
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   307
lemma underS_empty: "a \<notin> Field r \<Longrightarrow> underS r a = {}"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   308
  by (auto simp: Field_def underS_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   309
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   310
lemma under_Field: "under r a \<subseteq> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   311
  by (auto simp: under_def Field_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   312
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   313
lemma underS_Field: "underS r a \<subseteq> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   314
  by (auto simp: underS_def Field_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   315
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   316
lemma underS_Field2: "a \<in> Field r \<Longrightarrow> underS r a \<subset> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   317
  using underS_notIn underS_Field by fast
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   318
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   319
lemma underS_Field3: "Field r \<noteq> {} \<Longrightarrow> underS r a \<subset> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   320
  by (cases "a \<in> Field r") (auto simp: underS_Field2 underS_empty)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   321
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   322
lemma AboveS_Field: "AboveS r A \<subseteq> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   323
  by (auto simp: AboveS_def Field_def)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   324
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   325
lemma under_incr:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   326
  assumes "trans r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   327
    and "(a, b) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   328
  shows "under r a \<subseteq> under r b"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   329
  unfolding under_def
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   330
proof safe
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   331
  fix x assume "(x, a) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   332
  with assms trans_def[of r] show "(x, b) \<in> r" by blast
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   333
qed
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   334
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   335
lemma underS_incr:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   336
  assumes "trans r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   337
    and "antisym r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   338
    and ab: "(a, b) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   339
  shows "underS r a \<subseteq> underS r b"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   340
  unfolding underS_def
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   341
proof safe
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   342
  assume *: "b \<noteq> a" and **: "(b, a) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   343
  with \<open>antisym r\<close> antisym_def[of r] ab show False
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   344
    by blast
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   345
next
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   346
  fix x assume "x \<noteq> a" "(x, a) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   347
  with ab \<open>trans r\<close> trans_def[of r] show "(x, b) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   348
    by blast
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   349
qed
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   350
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   351
lemma underS_incl_iff:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   352
  assumes LO: "Linear_order r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   353
    and INa: "a \<in> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   354
    and INb: "b \<in> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   355
  shows "underS r a \<subseteq> underS r b \<longleftrightarrow> (a, b) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   356
    (is "?lhs \<longleftrightarrow> ?rhs")
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   357
proof
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   358
  assume ?rhs
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   359
  with \<open>Linear_order r\<close> show ?lhs
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   360
    by (simp add: order_on_defs underS_incr)
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   361
next
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   362
  assume *: ?lhs
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   363
  have "(a, b) \<in> r" if "a = b"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   364
    using assms that by (simp add: order_on_defs refl_on_def)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   365
  moreover have False if "a \<noteq> b" "(b, a) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   366
  proof -
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   367
    from that have "b \<in> underS r a" unfolding underS_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   368
    with * have "b \<in> underS r b" by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   369
    then show ?thesis by (simp add: underS_notIn)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   370
  qed
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   371
  ultimately show "(a,b) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   372
    using assms order_on_defs[of "Field r" r] total_on_def[of "Field r" r] by blast
55026
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   373
qed
258fa7b5a621 folded 'Order_Relation_More_FP' into 'Order_Relation'
blanchet
parents: 54552
diff changeset
   374
70180
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   375
lemma finite_Partial_order_induct[consumes 3, case_names step]:
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   376
  assumes "Partial_order r"
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   377
    and "x \<in> Field r"
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   378
    and "finite r"
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   379
    and step: "\<And>x. x \<in> Field r \<Longrightarrow> (\<And>y. y \<in> aboveS r x \<Longrightarrow> P y) \<Longrightarrow> P x"
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   380
  shows "P x"
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   381
  using assms(2)
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   382
proof (induct rule: wf_induct[of "r\<inverse> - Id"])
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   383
  case 1
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   384
  from assms(1,3) show "wf (r\<inverse> - Id)"
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   385
    using partial_order_on_well_order_on partial_order_on_converse by blast
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   386
next
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   387
  case prems: (2 x)
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   388
  show ?case
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   389
    by (rule step) (use prems in \<open>auto simp: aboveS_def intro: FieldI2\<close>)
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   390
qed
5beca7396282 added lemmas
nipkow
parents: 68745
diff changeset
   391
63561
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   392
lemma finite_Linear_order_induct[consumes 3, case_names step]:
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   393
  assumes "Linear_order r"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   394
    and "x \<in> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   395
    and "finite r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   396
    and step: "\<And>x. x \<in> Field r \<Longrightarrow> (\<And>y. y \<in> aboveS r x \<Longrightarrow> P y) \<Longrightarrow> P x"
63561
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   397
  shows "P x"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   398
  using assms(2)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   399
proof (induct rule: wf_induct[of "r\<inverse> - Id"])
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   400
  case 1
63561
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   401
  from assms(1,3) show "wf (r\<inverse> - Id)"
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   402
    using linear_order_on_well_order_on linear_order_on_converse
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   403
    unfolding well_order_on_def by blast
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   404
next
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   405
  case prems: (2 x)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   406
  show ?case
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   407
    by (rule step) (use prems in \<open>auto simp: aboveS_def intro: FieldI2\<close>)
63561
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   408
qed
fba08009ff3e add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents: 61799
diff changeset
   409
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   410
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   411
subsection \<open>Variations on Well-Founded Relations\<close>
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   412
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   413
text \<open>
68484
59793df7f853 clarified document antiquotation @{theory};
wenzelm
parents: 63952
diff changeset
   414
  This subsection contains some variations of the results from \<^theory>\<open>HOL.Wellfounded\<close>:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   415
    \<^item> means for slightly more direct definitions by well-founded recursion;
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   416
    \<^item> variations of well-founded induction;
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   417
    \<^item> means for proving a linear order to be a well-order.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   418
\<close>
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   419
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   420
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   421
subsubsection \<open>Characterizations of well-foundedness\<close>
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   422
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   423
text \<open>
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   424
  A transitive relation is well-founded iff it is ``locally'' well-founded,
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   425
  i.e., iff its restriction to the lower bounds of of any element is
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   426
  well-founded.
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   427
\<close>
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   428
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   429
lemma trans_wf_iff:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   430
  assumes "trans r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   431
  shows "wf r \<longleftrightarrow> (\<forall>a. wf (r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})))"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   432
proof -
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   433
  define R where "R a = r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})" for a
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   434
  have "wf (R a)" if "wf r" for a
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   435
    using that R_def wf_subset[of r "R a"] by auto
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   436
  moreover
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   437
  have "wf r" if *: "\<forall>a. wf(R a)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   438
    unfolding wf_def
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   439
  proof clarify
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   440
    fix phi a
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   441
    assume **: "\<forall>a. (\<forall>b. (b, a) \<in> r \<longrightarrow> phi b) \<longrightarrow> phi a"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   442
    define chi where "chi b \<longleftrightarrow> (b, a) \<in> r \<longrightarrow> phi b" for b
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   443
    with * have "wf (R a)" by auto
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   444
    then have "(\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b) \<longrightarrow> (\<forall>b. chi b)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   445
      unfolding wf_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   446
    also have "\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b"
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   447
    proof safe
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   448
      fix b
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   449
      assume "\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   450
      moreover have "(b, a) \<in> r \<Longrightarrow> \<forall>c. (c, b) \<in> r \<and> (c, a) \<in> r \<longrightarrow> phi c \<Longrightarrow> phi b"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   451
      proof -
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   452
        assume "(b, a) \<in> r" and "\<forall>c. (c, b) \<in> r \<and> (c, a) \<in> r \<longrightarrow> phi c"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   453
        then have "\<forall>c. (c, b) \<in> r \<longrightarrow> phi c"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   454
          using assms trans_def[of r] by blast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   455
        with ** show "phi b" by blast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   456
      qed
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   457
      ultimately show "chi b"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   458
        by (auto simp add: chi_def R_def)
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   459
    qed
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   460
    finally have  "\<forall>b. chi b" .
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   461
    with ** chi_def show "phi a" by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   462
  qed
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   463
  ultimately show ?thesis unfolding R_def by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   464
qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   465
63952
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 63572
diff changeset
   466
text\<open>A transitive relation is well-founded if all initial segments are finite.\<close>
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 63572
diff changeset
   467
corollary wf_finite_segments:
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 63572
diff changeset
   468
  assumes "irrefl r" and "trans r" and "\<And>x. finite {y. (y, x) \<in> r}"
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   469
  shows "wf r"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   470
proof -
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   471
  have "\<And>a. acyclic (r \<inter> {x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r})"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   472
  proof -
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   473
    fix a
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   474
    have "trans (r \<inter> ({x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r}))"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   475
      using assms unfolding trans_def Field_def by blast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   476
    then show "acyclic (r \<inter> {x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r})"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   477
      using assms acyclic_def assms irrefl_def by fastforce
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   478
  qed
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   479
  then show ?thesis
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   480
    by (clarsimp simp: trans_wf_iff wf_iff_acyclic_if_finite converse_def assms)
63952
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 63572
diff changeset
   481
qed
354808e9f44b new material connected with HOL Light measure theory, plus more rationalisation
paulson <lp15@cam.ac.uk>
parents: 63572
diff changeset
   482
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   483
text \<open>The next lemma is a variation of \<open>wf_eq_minimal\<close> from Wellfounded,
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   484
  allowing one to assume the set included in the field.\<close>
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   485
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   486
lemma wf_eq_minimal2: "wf r \<longleftrightarrow> (\<forall>A. A \<subseteq> Field r \<and> A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a', a) \<notin> r))"
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   487
proof-
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   488
  let ?phi = "\<lambda>A. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   489
  have "wf r \<longleftrightarrow> (\<forall>A. ?phi A)"
75669
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   490
  proof
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   491
    assume "wf r"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   492
    show  "\<forall>A. ?phi A"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   493
    proof clarify
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   494
      fix A:: "'a set"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   495
      assume "A \<noteq> {}"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   496
      then obtain x where "x \<in> A"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   497
        by auto
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   498
      show "\<exists>a\<in>A. \<forall>a'\<in>A. (a', a) \<notin> r"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   499
        apply (rule wfE_min[of r x A])
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   500
          apply fact+
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   501
        by blast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   502
    qed
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   503
  next
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   504
    assume *: "\<forall>A. ?phi A"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   505
    then show "wf r"
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   506
      apply (clarsimp simp: ex_in_conv [THEN sym])
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   507
      apply (rule wfI_min)
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   508
      by fast
43f5dfb7fa35 tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents: 70180
diff changeset
   509
  qed
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   510
  also have "(\<forall>A. ?phi A) \<longleftrightarrow> (\<forall>B \<subseteq> Field r. ?phi B)"
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   511
  proof
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   512
    assume "\<forall>A. ?phi A"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   513
    then show "\<forall>B \<subseteq> Field r. ?phi B" by simp
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   514
  next
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   515
    assume *: "\<forall>B \<subseteq> Field r. ?phi B"
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   516
    show "\<forall>A. ?phi A"
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   517
    proof clarify
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   518
      fix A :: "'a set"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   519
      assume **: "A \<noteq> {}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   520
      define B where "B = A \<inter> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   521
      show "\<exists>a \<in> A. \<forall>a' \<in> A. (a', a) \<notin> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   522
      proof (cases "B = {}")
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   523
        case True
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   524
        with ** obtain a where a: "a \<in> A" "a \<notin> Field r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   525
          unfolding B_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   526
        with a have "\<forall>a' \<in> A. (a',a) \<notin> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   527
          unfolding Field_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   528
        with a show ?thesis by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   529
      next
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   530
        case False
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   531
        have "B \<subseteq> Field r" unfolding B_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   532
        with False * obtain a where a: "a \<in> B" "\<forall>a' \<in> B. (a', a) \<notin> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   533
          by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   534
        have "(a', a) \<notin> r" if "a' \<in> A" for a'
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   535
        proof
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   536
          assume a'a: "(a', a) \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   537
          with that have "a' \<in> B" unfolding B_def Field_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   538
          with a a'a show False by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   539
        qed
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   540
        with a show ?thesis unfolding B_def by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   541
      qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   542
    qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   543
  qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   544
  finally show ?thesis by blast
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   545
qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   546
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   547
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   548
subsubsection \<open>Characterizations of well-foundedness\<close>
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   549
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   550
text \<open>
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   551
  The next lemma and its corollary enable one to prove that a linear order is
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   552
  a well-order in a way which is more standard than via well-foundedness of
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   553
  the strict version of the relation.
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   554
\<close>
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   555
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   556
lemma Linear_order_wf_diff_Id:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   557
  assumes "Linear_order r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   558
  shows "wf (r - Id) \<longleftrightarrow> (\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r))"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   559
proof (cases "r \<subseteq> Id")
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   560
  case True
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   561
  then have *: "r - Id = {}" by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   562
  have "wf (r - Id)" by (simp add: *)
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   563
  moreover have "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   564
    if *: "A \<subseteq> Field r" and **: "A \<noteq> {}" for A
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   565
  proof -
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   566
    from \<open>Linear_order r\<close> True
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   567
    obtain a where a: "r = {} \<or> r = {(a, a)}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   568
      unfolding order_on_defs using Total_subset_Id [of r] by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   569
    with * ** have "A = {a} \<and> r = {(a, a)}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   570
      unfolding Field_def by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   571
    with a show ?thesis by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   572
  qed
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   573
  ultimately show ?thesis by blast
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   574
next
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   575
  case False
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   576
  with \<open>Linear_order r\<close> have Field: "Field r = Field (r - Id)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   577
    unfolding order_on_defs using Total_Id_Field [of r] by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   578
  show ?thesis
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   579
  proof
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   580
    assume *: "wf (r - Id)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   581
    show "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   582
    proof clarify
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   583
      fix A
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   584
      assume **: "A \<subseteq> Field r" and ***: "A \<noteq> {}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   585
      then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   586
        using Field * unfolding wf_eq_minimal2 by simp
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   587
      moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   588
        using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   589
      ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r" by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   590
    qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   591
  next
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   592
    assume *: "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   593
    show "wf (r - Id)"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   594
      unfolding wf_eq_minimal2
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   595
    proof clarify
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   596
      fix A
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   597
      assume **: "A \<subseteq> Field(r - Id)" and ***: "A \<noteq> {}"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   598
      then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   599
        using Field * by simp
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   600
      moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   601
        using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** mono_Field[of "r - Id" r] by blast
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   602
      ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   603
        by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   604
    qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   605
  qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   606
qed
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   607
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   608
corollary Linear_order_Well_order_iff:
63572
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   609
  "Linear_order r \<Longrightarrow>
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   610
    Well_order r \<longleftrightarrow> (\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r))"
c0cbfd2b5a45 misc tuning and modernization;
wenzelm
parents: 63563
diff changeset
   611
  unfolding well_order_on_def using Linear_order_wf_diff_Id[of r] by blast
55027
a74ea6d75571 folded 'Wellfounded_More_FP' into 'Wellfounded'
blanchet
parents: 55026
diff changeset
   612
26273
6c4d534af98d Orders as relations
nipkow
parents:
diff changeset
   613
end