src/HOL/Complete_Partial_Order.thy
author wenzelm
Fri, 08 Feb 2019 14:42:28 +0100
changeset 69794 a19fdf64726c
parent 69593 3dda49e08b9d
child 73252 b4552595b04e
permissions -rw-r--r--
tuned signature: proper exports;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
     1
(*  Title:      HOL/Complete_Partial_Order.thy
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
     2
    Author:     Brian Huffman, Portland State University
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
     3
    Author:     Alexander Krauss, TU Muenchen
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
     4
*)
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
     5
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
     6
section \<open>Chain-complete partial orders and their fixpoints\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
     7
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
     8
theory Complete_Partial_Order
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
     9
  imports Product_Type
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    10
begin
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    11
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
    12
subsection \<open>Monotone functions\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    13
69593
3dda49e08b9d isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
    14
text \<open>Dictionary-passing version of \<^const>\<open>Orderings.mono\<close>.\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    15
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    16
definition monotone :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    17
  where "monotone orda ordb f \<longleftrightarrow> (\<forall>x y. orda x y \<longrightarrow> ordb (f x) (f y))"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    18
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    19
lemma monotoneI[intro?]: "(\<And>x y. orda x y \<Longrightarrow> ordb (f x) (f y)) \<Longrightarrow> monotone orda ordb f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    20
  unfolding monotone_def by iprover
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    21
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    22
lemma monotoneD[dest?]: "monotone orda ordb f \<Longrightarrow> orda x y \<Longrightarrow> ordb (f x) (f y)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    23
  unfolding monotone_def by iprover
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    24
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    25
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
    26
subsection \<open>Chains\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    27
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    28
text \<open>
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    29
  A chain is a totally-ordered set. Chains are parameterized over
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    30
  the order for maximal flexibility, since type classes are not enough.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
    31
\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    32
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    33
definition chain :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> bool"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    34
  where "chain ord S \<longleftrightarrow> (\<forall>x\<in>S. \<forall>y\<in>S. ord x y \<or> ord y x)"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    35
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    36
lemma chainI:
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    37
  assumes "\<And>x y. x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> ord x y \<or> ord y x"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    38
  shows "chain ord S"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    39
  using assms unfolding chain_def by fast
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    40
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    41
lemma chainD:
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    42
  assumes "chain ord S" and "x \<in> S" and "y \<in> S"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    43
  shows "ord x y \<or> ord y x"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    44
  using assms unfolding chain_def by fast
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    45
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    46
lemma chainE:
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    47
  assumes "chain ord S" and "x \<in> S" and "y \<in> S"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    48
  obtains "ord x y" | "ord y x"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    49
  using assms unfolding chain_def by fast
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    50
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
    51
lemma chain_empty: "chain ord {}"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    52
  by (simp add: chain_def)
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
    53
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
    54
lemma chain_equality: "chain (=) A \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>A. x = y)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    55
  by (auto simp add: chain_def)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    56
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    57
lemma chain_subset: "chain ord A \<Longrightarrow> B \<subseteq> A \<Longrightarrow> chain ord B"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    58
  by (rule chainI) (blast dest: chainD)
60057
86fa63ce8156 add lemmas
Andreas Lochbihler
parents: 58889
diff changeset
    59
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    60
lemma chain_imageI:
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    61
  assumes chain: "chain le_a Y"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    62
    and mono: "\<And>x y. x \<in> Y \<Longrightarrow> y \<in> Y \<Longrightarrow> le_a x y \<Longrightarrow> le_b (f x) (f y)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    63
  shows "chain le_b (f ` Y)"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    64
  by (blast intro: chainI dest: chainD[OF chain] mono)
60061
279472fa0b1d move some lemmas from AFP/Coinductive
Andreas Lochbihler
parents: 60057
diff changeset
    65
279472fa0b1d move some lemmas from AFP/Coinductive
Andreas Lochbihler
parents: 60057
diff changeset
    66
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
    67
subsection \<open>Chain-complete partial orders\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    68
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
    69
text \<open>
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    70
  A \<open>ccpo\<close> has a least upper bound for any chain.  In particular, the
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    71
  empty set is a chain, so every \<open>ccpo\<close> must have a bottom element.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
    72
\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    73
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
    74
class ccpo = order + Sup +
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
    75
  assumes ccpo_Sup_upper: "chain (\<le>) A \<Longrightarrow> x \<in> A \<Longrightarrow> x \<le> Sup A"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
    76
  assumes ccpo_Sup_least: "chain (\<le>) A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> x \<le> z) \<Longrightarrow> Sup A \<le> z"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    77
begin
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    78
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
    79
lemma chain_singleton: "Complete_Partial_Order.chain (\<le>) {x}"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    80
  by (rule chainI) simp
60061
279472fa0b1d move some lemmas from AFP/Coinductive
Andreas Lochbihler
parents: 60057
diff changeset
    81
279472fa0b1d move some lemmas from AFP/Coinductive
Andreas Lochbihler
parents: 60057
diff changeset
    82
lemma ccpo_Sup_singleton [simp]: "\<Squnion>{x} = x"
63810
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
    83
  by (rule antisym) (auto intro: ccpo_Sup_least ccpo_Sup_upper simp add: chain_singleton)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    84
60061
279472fa0b1d move some lemmas from AFP/Coinductive
Andreas Lochbihler
parents: 60057
diff changeset
    85
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
    86
subsection \<open>Transfinite iteration of a function\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    87
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    88
context notes [[inductive_internals]]
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    89
begin
61689
e4d7972402ed export internal definition
Andreas Lochbihler
parents: 61169
diff changeset
    90
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    91
inductive_set iterates :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a set"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    92
  for f :: "'a \<Rightarrow> 'a"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    93
  where
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
    94
    step: "x \<in> iterates f \<Longrightarrow> f x \<in> iterates f"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
    95
  | Sup: "chain (\<le>) M \<Longrightarrow> \<forall>x\<in>M. x \<in> iterates f \<Longrightarrow> Sup M \<in> iterates f"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
    96
61689
e4d7972402ed export internal definition
Andreas Lochbihler
parents: 61169
diff changeset
    97
end
e4d7972402ed export internal definition
Andreas Lochbihler
parents: 61169
diff changeset
    98
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
    99
lemma iterates_le_f: "x \<in> iterates f \<Longrightarrow> monotone (\<le>) (\<le>) f \<Longrightarrow> x \<le> f x"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   100
  by (induct x rule: iterates.induct)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   101
    (force dest: monotoneD intro!: ccpo_Sup_upper ccpo_Sup_least)+
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   102
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   103
lemma chain_iterates:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   104
  assumes f: "monotone (\<le>) (\<le>) f"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   105
  shows "chain (\<le>) (iterates f)" (is "chain _ ?C")
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   106
proof (rule chainI)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   107
  fix x y
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   108
  assume "x \<in> ?C" "y \<in> ?C"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   109
  then show "x \<le> y \<or> y \<le> x"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   110
  proof (induct x arbitrary: y rule: iterates.induct)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   111
    fix x y
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   112
    assume y: "y \<in> ?C"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   113
      and IH: "\<And>z. z \<in> ?C \<Longrightarrow> x \<le> z \<or> z \<le> x"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   114
    from y show "f x \<le> y \<or> y \<le> f x"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   115
    proof (induct y rule: iterates.induct)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   116
      case (step y)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   117
      with IH f show ?case by (auto dest: monotoneD)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   118
    next
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   119
      case (Sup M)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   120
      then have chM: "chain (\<le>) M"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   121
        and IH': "\<And>z. z \<in> M \<Longrightarrow> f x \<le> z \<or> z \<le> f x" by auto
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   122
      show "f x \<le> Sup M \<or> Sup M \<le> f x"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   123
      proof (cases "\<exists>z\<in>M. f x \<le> z")
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   124
        case True
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   125
        then have "f x \<le> Sup M"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   126
          apply rule
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   127
          apply (erule order_trans)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   128
          apply (rule ccpo_Sup_upper[OF chM])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   129
          apply assumption
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   130
          done
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   131
        then show ?thesis ..
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   132
      next
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   133
        case False
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   134
        with IH' show ?thesis
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   135
          by (auto intro: ccpo_Sup_least[OF chM])
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   136
      qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   137
    qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   138
  next
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   139
    case (Sup M y)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   140
    show ?case
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   141
    proof (cases "\<exists>x\<in>M. y \<le> x")
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   142
      case True
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   143
      then have "y \<le> Sup M"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   144
        apply rule
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   145
        apply (erule order_trans)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   146
        apply (rule ccpo_Sup_upper[OF Sup(1)])
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   147
        apply assumption
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   148
        done
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   149
      then show ?thesis ..
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   150
    next
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   151
      case False with Sup
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   152
      show ?thesis by (auto intro: ccpo_Sup_least)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   153
    qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   154
  qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   155
qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   156
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   157
lemma bot_in_iterates: "Sup {} \<in> iterates f"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   158
  by (auto intro: iterates.Sup simp add: chain_empty)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   159
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   160
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
   161
subsection \<open>Fixpoint combinator\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   162
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   163
definition fixp :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   164
  where "fixp f = Sup (iterates f)"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   165
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   166
lemma iterates_fixp:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   167
  assumes f: "monotone (\<le>) (\<le>) f"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   168
  shows "fixp f \<in> iterates f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   169
  unfolding fixp_def
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   170
  by (simp add: iterates.Sup chain_iterates f)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   171
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   172
lemma fixp_unfold:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   173
  assumes f: "monotone (\<le>) (\<le>) f"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   174
  shows "fixp f = f (fixp f)"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   175
proof (rule antisym)
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   176
  show "fixp f \<le> f (fixp f)"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   177
    by (intro iterates_le_f iterates_fixp f)
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   178
  have "f (fixp f) \<le> Sup (iterates f)"
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   179
    by (intro ccpo_Sup_upper chain_iterates f iterates.step iterates_fixp)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   180
  then show "f (fixp f) \<le> fixp f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   181
    by (simp only: fixp_def)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   182
qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   183
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   184
lemma fixp_lowerbound:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   185
  assumes f: "monotone (\<le>) (\<le>) f"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   186
    and z: "f z \<le> z"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   187
  shows "fixp f \<le> z"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   188
  unfolding fixp_def
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   189
proof (rule ccpo_Sup_least[OF chain_iterates[OF f]])
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   190
  fix x
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   191
  assume "x \<in> iterates f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   192
  then show "x \<le> z"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   193
  proof (induct x rule: iterates.induct)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   194
    case (step x)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   195
    from f \<open>x \<le> z\<close> have "f x \<le> f z" by (rule monotoneD)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   196
    also note z
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   197
    finally show "f x \<le> z" .
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   198
  next
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   199
    case (Sup M)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   200
    then show ?case
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   201
      by (auto intro: ccpo_Sup_least)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   202
  qed
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   203
qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   204
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   205
end
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   206
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   207
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
   208
subsection \<open>Fixpoint induction\<close>
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   209
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
   210
setup \<open>Sign.map_naming (Name_Space.mandatory_path "ccpo")\<close>
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   211
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   212
definition admissible :: "('a set \<Rightarrow> 'a) \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   213
  where "admissible lub ord P \<longleftrightarrow> (\<forall>A. chain ord A \<longrightarrow> A \<noteq> {} \<longrightarrow> (\<forall>x\<in>A. P x) \<longrightarrow> P (lub A))"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   214
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   215
lemma admissibleI:
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   216
  assumes "\<And>A. chain ord A \<Longrightarrow> A \<noteq> {} \<Longrightarrow> \<forall>x\<in>A. P x \<Longrightarrow> P (lub A)"
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   217
  shows "ccpo.admissible lub ord P"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   218
  using assms unfolding ccpo.admissible_def by fast
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   219
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   220
lemma admissibleD:
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   221
  assumes "ccpo.admissible lub ord P"
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   222
  assumes "chain ord A"
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   223
  assumes "A \<noteq> {}"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   224
  assumes "\<And>x. x \<in> A \<Longrightarrow> P x"
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   225
  shows "P (lub A)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   226
  using assms by (auto simp: ccpo.admissible_def)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   227
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60061
diff changeset
   228
setup \<open>Sign.map_naming Name_Space.parent_path\<close>
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   229
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   230
lemma (in ccpo) fixp_induct:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   231
  assumes adm: "ccpo.admissible Sup (\<le>) P"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   232
  assumes mono: "monotone (\<le>) (\<le>) f"
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   233
  assumes bot: "P (Sup {})"
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   234
  assumes step: "\<And>x. P x \<Longrightarrow> P (f x)"
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   235
  shows "P (fixp f)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   236
  unfolding fixp_def
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   237
  using adm chain_iterates[OF mono]
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   238
proof (rule ccpo.admissibleD)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   239
  show "iterates f \<noteq> {}"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   240
    using bot_in_iterates by auto
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   241
next
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   242
  fix x
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   243
  assume "x \<in> iterates f"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   244
  then show "P x"
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   245
  proof (induct rule: iterates.induct)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   246
    case prems: (step x)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   247
    from this(2) show ?case by (rule step)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   248
  next
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   249
    case (Sup M)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   250
    then show ?case by (cases "M = {}") (auto intro: step bot ccpo.admissibleD adm)
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   251
  qed
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   252
qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   253
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   254
lemma admissible_True: "ccpo.admissible lub ord (\<lambda>x. True)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   255
  unfolding ccpo.admissible_def by simp
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   256
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   257
(*lemma admissible_False: "\<not> ccpo.admissible lub ord (\<lambda>x. False)"
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   258
unfolding ccpo.admissible_def chain_def by simp
54630
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   259
*)
9061af4d5ebc restrict admissibility to non-empty chains to allow more syntax-directed proof rules
Andreas Lochbihler
parents: 53361
diff changeset
   260
lemma admissible_const: "ccpo.admissible lub ord (\<lambda>x. t)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   261
  by (auto intro: ccpo.admissibleI)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   262
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   263
lemma admissible_conj:
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   264
  assumes "ccpo.admissible lub ord (\<lambda>x. P x)"
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   265
  assumes "ccpo.admissible lub ord (\<lambda>x. Q x)"
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   266
  shows "ccpo.admissible lub ord (\<lambda>x. P x \<and> Q x)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   267
  using assms unfolding ccpo.admissible_def by simp
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   268
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   269
lemma admissible_all:
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   270
  assumes "\<And>y. ccpo.admissible lub ord (\<lambda>x. P x y)"
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   271
  shows "ccpo.admissible lub ord (\<lambda>x. \<forall>y. P x y)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   272
  using assms unfolding ccpo.admissible_def by fast
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   273
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   274
lemma admissible_ball:
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   275
  assumes "\<And>y. y \<in> A \<Longrightarrow> ccpo.admissible lub ord (\<lambda>x. P x y)"
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   276
  shows "ccpo.admissible lub ord (\<lambda>x. \<forall>y\<in>A. P x y)"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   277
  using assms unfolding ccpo.admissible_def by fast
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   278
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   279
lemma chain_compr: "chain ord A \<Longrightarrow> chain ord {x \<in> A. P x}"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   280
  unfolding chain_def by fast
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   281
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   282
context ccpo
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   283
begin
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   284
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   285
lemma admissible_disj:
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   286
  fixes P Q :: "'a \<Rightarrow> bool"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   287
  assumes P: "ccpo.admissible Sup (\<le>) (\<lambda>x. P x)"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   288
  assumes Q: "ccpo.admissible Sup (\<le>) (\<lambda>x. Q x)"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   289
  shows "ccpo.admissible Sup (\<le>) (\<lambda>x. P x \<or> Q x)"
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   290
proof (rule ccpo.admissibleI)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   291
  fix A :: "'a set"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   292
  assume chain: "chain (\<le>) A"
63810
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   293
  assume A: "A \<noteq> {}" and P_Q: "\<forall>x\<in>A. P x \<or> Q x"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   294
  have "(\<exists>x\<in>A. P x) \<and> (\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> P y) \<or> (\<exists>x\<in>A. Q x) \<and> (\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> Q y)"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   295
    (is "?P \<or> ?Q" is "?P1 \<and> ?P2 \<or> _")
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   296
  proof (rule disjCI)
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   297
    assume "\<not> ?Q"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   298
    then consider "\<forall>x\<in>A. \<not> Q x" | a where "a \<in> A" "\<forall>y\<in>A. a \<le> y \<longrightarrow> \<not> Q y"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   299
      by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   300
    then show ?P
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   301
    proof cases
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   302
      case 1
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   303
      with P_Q have "\<forall>x\<in>A. P x" by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   304
      with A show ?P by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   305
    next
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   306
      case 2
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   307
      note a = \<open>a \<in> A\<close>
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   308
      show ?P
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   309
      proof
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   310
        from P_Q 2 have *: "\<forall>y\<in>A. a \<le> y \<longrightarrow> P y" by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   311
        with a have "P a" by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   312
        with a show ?P1 by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   313
        show ?P2
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   314
        proof
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   315
          fix x
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   316
          assume x: "x \<in> A"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   317
          with chain a show "\<exists>y\<in>A. x \<le> y \<and> P y"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   318
          proof (rule chainE)
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   319
            assume le: "a \<le> x"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   320
            with * a x have "P x" by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   321
            with x le show ?thesis by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   322
          next
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   323
            assume "a \<ge> x"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   324
            with a \<open>P a\<close> show ?thesis by blast
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   325
          qed
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   326
        qed
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   327
      qed
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   328
    qed
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   329
  qed
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   330
  moreover
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   331
  have "Sup A = Sup {x \<in> A. P x}" if "\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> P y" for P
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   332
  proof (rule antisym)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   333
    have chain_P: "chain (\<le>) {x \<in> A. P x}"
63810
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   334
      by (rule chain_compr [OF chain])
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   335
    show "Sup A \<le> Sup {x \<in> A. P x}"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   336
      apply (rule ccpo_Sup_least [OF chain])
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   337
      apply (drule that [rule_format])
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   338
      apply clarify
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   339
      apply (erule order_trans)
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   340
      apply (simp add: ccpo_Sup_upper [OF chain_P])
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   341
      done
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   342
    show "Sup {x \<in> A. P x} \<le> Sup A"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   343
      apply (rule ccpo_Sup_least [OF chain_P])
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   344
      apply clarify
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   345
      apply (simp add: ccpo_Sup_upper [OF chain])
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   346
      done
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   347
  qed
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   348
  ultimately
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   349
  consider "\<exists>x. x \<in> A \<and> P x" "Sup A = Sup {x \<in> A. P x}"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   350
    | "\<exists>x. x \<in> A \<and> Q x" "Sup A = Sup {x \<in> A. Q x}"
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   351
    by blast
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   352
  then show "P (Sup A) \<or> Q (Sup A)"
63810
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   353
    apply cases
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   354
     apply simp_all
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   355
     apply (rule disjI1)
63810
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   356
     apply (rule ccpo.admissibleD [OF P chain_compr [OF chain]]; simp)
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   357
    apply (rule disjI2)
63810
67b091896158 clarified proof: save 1-2s CPU time;
wenzelm
parents: 63612
diff changeset
   358
    apply (rule ccpo.admissibleD [OF Q chain_compr [OF chain]]; simp)
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   359
    done
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   360
qed
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   361
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   362
end
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   363
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   364
instance complete_lattice \<subseteq> ccpo
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 60758
diff changeset
   365
  by standard (fast intro: Sup_upper Sup_least)+
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   366
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   367
lemma lfp_eq_fixp:
63979
95c3ae4baba8 clarified lfp/gfp statements and proofs;
wenzelm
parents: 63810
diff changeset
   368
  assumes mono: "mono f"
63612
7195acc2fe93 misc tuning and modernization;
wenzelm
parents: 62093
diff changeset
   369
  shows "lfp f = fixp f"
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   370
proof (rule antisym)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63979
diff changeset
   371
  from mono have f': "monotone (\<le>) (\<le>) f"
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   372
    unfolding mono_def monotone_def .
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   373
  show "lfp f \<le> fixp f"
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   374
    by (rule lfp_lowerbound, subst fixp_unfold [OF f'], rule order_refl)
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   375
  show "fixp f \<le> lfp f"
63979
95c3ae4baba8 clarified lfp/gfp statements and proofs;
wenzelm
parents: 63810
diff changeset
   376
    by (rule fixp_lowerbound [OF f']) (simp add: lfp_fixpoint [OF mono])
46041
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   377
qed
1e3ff542e83e remove constant 'ccpo.lub', re-use constant 'Sup' instead
huffman
parents: 40252
diff changeset
   378
53361
1cb7d3c0cf31 move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Andreas Lochbihler
parents: 46041
diff changeset
   379
hide_const (open) iterates fixp
40106
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   380
c58951943cba Complete_Partial_Order.thy: complete partial orders over arbitrary chains, with fixpoint theorem
krauss
parents:
diff changeset
   381
end