src/HOL/Library/Lattice_Constructions.thy
author wenzelm
Wed, 17 Jun 2015 20:05:21 +0200
changeset 60508 2127bee2069a
parent 60500 903bb1495239
child 60509 0928cf63920f
permissions -rw-r--r--
tuned proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57998
8b7508f848ef rename Quickcheck_Types to Lattice_Constructions and remove quickcheck setup
Andreas Lochbihler
parents: 57997
diff changeset
     1
(*  Title:      HOL/Library/Lattice_Constructions.thy
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
     2
    Author:     Lukas Bulwahn
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
     3
    Copyright   2010 TU Muenchen
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
     4
*)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
     5
57998
8b7508f848ef rename Quickcheck_Types to Lattice_Constructions and remove quickcheck setup
Andreas Lochbihler
parents: 57997
diff changeset
     6
theory Lattice_Constructions
57645
ee55e667dedc tuned imports;
wenzelm
parents: 57544
diff changeset
     7
imports Main
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
     8
begin
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
     9
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58310
diff changeset
    10
subsection \<open>Values extended by a bottom element\<close>
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    11
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
    12
datatype 'a bot = Value 'a | Bot
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    13
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    14
instantiation bot :: (preorder) preorder
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    15
begin
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    16
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    17
definition less_eq_bot where
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    18
  "x \<le> y \<longleftrightarrow> (case x of Bot \<Rightarrow> True | Value x \<Rightarrow> (case y of Bot \<Rightarrow> False | Value y \<Rightarrow> x \<le> y))"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    19
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    20
definition less_bot where
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    21
  "x < y \<longleftrightarrow> (case y of Bot \<Rightarrow> False | Value y \<Rightarrow> (case x of Bot \<Rightarrow> True | Value x \<Rightarrow> x < y))"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    22
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    23
lemma less_eq_bot_Bot [simp]: "Bot \<le> x"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    24
  by (simp add: less_eq_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    25
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    26
lemma less_eq_bot_Bot_code [code]: "Bot \<le> x \<longleftrightarrow> True"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    27
  by simp
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    28
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    29
lemma less_eq_bot_Bot_is_Bot: "x \<le> Bot \<Longrightarrow> x = Bot"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    30
  by (cases x) (simp_all add: less_eq_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    31
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    32
lemma less_eq_bot_Value_Bot [simp, code]: "Value x \<le> Bot \<longleftrightarrow> False"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    33
  by (simp add: less_eq_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    34
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    35
lemma less_eq_bot_Value [simp, code]: "Value x \<le> Value y \<longleftrightarrow> x \<le> y"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    36
  by (simp add: less_eq_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    37
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    38
lemma less_bot_Bot [simp, code]: "x < Bot \<longleftrightarrow> False"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    39
  by (simp add: less_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    40
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    41
lemma less_bot_Bot_is_Value: "Bot < x \<Longrightarrow> \<exists>z. x = Value z"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    42
  by (cases x) (simp_all add: less_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    43
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    44
lemma less_bot_Bot_Value [simp]: "Bot < Value x"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    45
  by (simp add: less_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    46
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    47
lemma less_bot_Bot_Value_code [code]: "Bot < Value x \<longleftrightarrow> True"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    48
  by simp
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    49
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    50
lemma less_bot_Value [simp, code]: "Value x < Value y \<longleftrightarrow> x < y"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    51
  by (simp add: less_bot_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    52
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    53
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    54
  by default
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    55
    (auto simp add: less_eq_bot_def less_bot_def less_le_not_le elim: order_trans split: bot.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    56
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    57
end
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    58
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    59
instance bot :: (order) order
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    60
  by default (auto simp add: less_eq_bot_def less_bot_def split: bot.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    61
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    62
instance bot :: (linorder) linorder
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    63
  by default (auto simp add: less_eq_bot_def less_bot_def split: bot.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    64
43815
4f6e2965d821 adjusted to tightened specification of classes bot and top
haftmann
parents: 40654
diff changeset
    65
instantiation bot :: (order) bot
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    66
begin
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    67
  definition "bot = Bot"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    68
  instance ..
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    69
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    70
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    71
instantiation bot :: (top) top
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    72
begin
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    73
  definition "top = Value top"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    74
  instance ..
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    75
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    76
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    77
instantiation bot :: (semilattice_inf) semilattice_inf
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    78
begin
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    79
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    80
definition inf_bot
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    81
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    82
  "inf x y =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    83
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    84
      Bot \<Rightarrow> Bot
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    85
    | Value v \<Rightarrow>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    86
        (case y of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    87
          Bot \<Rightarrow> Bot
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    88
        | Value v' \<Rightarrow> Value (inf v v')))"
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    89
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    90
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
    91
  by default (auto simp add: inf_bot_def less_eq_bot_def split: bot.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    92
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    93
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    94
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    95
instantiation bot :: (semilattice_sup) semilattice_sup
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    96
begin
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    97
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    98
definition sup_bot
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
    99
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   100
  "sup x y =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   101
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   102
      Bot \<Rightarrow> y
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   103
    | Value v \<Rightarrow>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   104
        (case y of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   105
          Bot \<Rightarrow> x
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   106
        | Value v' \<Rightarrow> Value (sup v v')))"
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   107
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   108
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   109
  by default (auto simp add: sup_bot_def less_eq_bot_def split: bot.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   110
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   111
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   112
57543
36041934e429 adapt and reactivate Quickcheck_Types and add two test cases
Andreas Lochbihler
parents: 44890
diff changeset
   113
instance bot :: (lattice) bounded_lattice_bot
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   114
  by intro_classes (simp add: bot_bot_def)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   115
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   116
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   117
subsection \<open>Values extended by a top element\<close>
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   118
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
   119
datatype 'a top = Value 'a | Top
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   120
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   121
instantiation top :: (preorder) preorder
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   122
begin
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   123
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   124
definition less_eq_top where
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   125
  "x \<le> y \<longleftrightarrow> (case y of Top \<Rightarrow> True | Value y \<Rightarrow> (case x of Top \<Rightarrow> False | Value x \<Rightarrow> x \<le> y))"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   126
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   127
definition less_top where
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   128
  "x < y \<longleftrightarrow> (case x of Top \<Rightarrow> False | Value x \<Rightarrow> (case y of Top \<Rightarrow> True | Value y \<Rightarrow> x < y))"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   129
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   130
lemma less_eq_top_Top [simp]: "x \<le> Top"
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   131
  by (simp add: less_eq_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   132
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   133
lemma less_eq_top_Top_code [code]: "x \<le> Top \<longleftrightarrow> True"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   134
  by simp
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   135
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   136
lemma less_eq_top_is_Top: "Top \<le> x \<Longrightarrow> x = Top"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   137
  by (cases x) (simp_all add: less_eq_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   138
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   139
lemma less_eq_top_Top_Value [simp, code]: "Top \<le> Value x \<longleftrightarrow> False"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   140
  by (simp add: less_eq_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   141
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   142
lemma less_eq_top_Value_Value [simp, code]: "Value x \<le> Value y \<longleftrightarrow> x \<le> y"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   143
  by (simp add: less_eq_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   144
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   145
lemma less_top_Top [simp, code]: "Top < x \<longleftrightarrow> False"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   146
  by (simp add: less_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   147
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   148
lemma less_top_Top_is_Value: "x < Top \<Longrightarrow> \<exists>z. x = Value z"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   149
  by (cases x) (simp_all add: less_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   150
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   151
lemma less_top_Value_Top [simp]: "Value x < Top"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   152
  by (simp add: less_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   153
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   154
lemma less_top_Value_Top_code [code]: "Value x < Top \<longleftrightarrow> True"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   155
  by simp
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   156
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   157
lemma less_top_Value [simp, code]: "Value x < Value y \<longleftrightarrow> x < y"
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   158
  by (simp add: less_top_def)
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   159
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   160
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   161
  by default
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   162
    (auto simp add: less_eq_top_def less_top_def less_le_not_le elim: order_trans split: top.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   163
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   164
end
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   165
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   166
instance top :: (order) order
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   167
  by default (auto simp add: less_eq_top_def less_top_def split: top.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   168
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   169
instance top :: (linorder) linorder
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   170
  by default (auto simp add: less_eq_top_def less_top_def split: top.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   171
43815
4f6e2965d821 adjusted to tightened specification of classes bot and top
haftmann
parents: 40654
diff changeset
   172
instantiation top :: (order) top
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   173
begin
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   174
  definition "top = Top"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   175
  instance ..
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   176
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   177
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   178
instantiation top :: (bot) bot
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   179
begin
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   180
  definition "bot = Value bot"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   181
  instance ..
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   182
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   183
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   184
instantiation top :: (semilattice_inf) semilattice_inf
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   185
begin
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   186
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   187
definition inf_top
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   188
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   189
  "inf x y =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   190
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   191
      Top \<Rightarrow> y
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   192
    | Value v \<Rightarrow>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   193
        (case y of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   194
          Top \<Rightarrow> x
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   195
        | Value v' \<Rightarrow> Value (inf v v')))"
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   196
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   197
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   198
  by default (auto simp add: inf_top_def less_eq_top_def split: top.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   199
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   200
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   201
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   202
instantiation top :: (semilattice_sup) semilattice_sup
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   203
begin
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   204
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   205
definition sup_top
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   206
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   207
  "sup x y =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   208
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   209
      Top \<Rightarrow> Top
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   210
    | Value v \<Rightarrow>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   211
        (case y of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   212
          Top \<Rightarrow> Top
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   213
        | Value v' \<Rightarrow> Value (sup v v')))"
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   214
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   215
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   216
  by default (auto simp add: sup_top_def less_eq_top_def split: top.splits)
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   217
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   218
end
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   219
57543
36041934e429 adapt and reactivate Quickcheck_Types and add two test cases
Andreas Lochbihler
parents: 44890
diff changeset
   220
instance top :: (lattice) bounded_lattice_top
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   221
  by default (simp add: top_top_def)
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   222
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   223
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58310
diff changeset
   224
subsection \<open>Values extended by a top and a bottom element\<close>
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   225
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
   226
datatype 'a flat_complete_lattice = Value 'a | Bot | Top
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   227
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   228
instantiation flat_complete_lattice :: (type) order
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   229
begin
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   230
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   231
definition less_eq_flat_complete_lattice
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   232
where
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   233
  "x \<le> y \<equiv>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   234
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   235
      Bot \<Rightarrow> True
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   236
    | Value v1 \<Rightarrow>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   237
        (case y of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   238
          Bot \<Rightarrow> False
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   239
        | Value v2 \<Rightarrow> v1 = v2
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   240
        | Top \<Rightarrow> True)
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   241
    | Top \<Rightarrow> y = Top)"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   242
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   243
definition less_flat_complete_lattice
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   244
where
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   245
  "x < y =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   246
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   247
      Bot \<Rightarrow> y \<noteq> Bot
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   248
    | Value v1 \<Rightarrow> y = Top
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   249
    | Top \<Rightarrow> False)"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   250
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   251
lemma [simp]: "Bot \<le> y"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   252
  unfolding less_eq_flat_complete_lattice_def by auto
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   253
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   254
lemma [simp]: "y \<le> Top"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   255
  unfolding less_eq_flat_complete_lattice_def by (auto split: flat_complete_lattice.splits)
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   256
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   257
lemma greater_than_two_values:
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   258
  assumes "a \<noteq> aa" "Value a \<le> z" "Value aa \<le> z"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   259
  shows "z = Top"
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   260
  using assms
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   261
  by (cases z) (auto simp add: less_eq_flat_complete_lattice_def)
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   262
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   263
lemma lesser_than_two_values:
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   264
  assumes "a \<noteq> aa" "z \<le> Value a" "z \<le> Value aa"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   265
  shows "z = Bot"
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   266
  using assms
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   267
  by (cases z) (auto simp add: less_eq_flat_complete_lattice_def)
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   268
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   269
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   270
  by default
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   271
    (auto simp add: less_eq_flat_complete_lattice_def less_flat_complete_lattice_def
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   272
      split: flat_complete_lattice.splits)
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   273
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   274
end
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   275
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   276
instantiation flat_complete_lattice :: (type) bot
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   277
begin
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   278
  definition "bot = Bot"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   279
  instance ..
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   280
end
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   281
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   282
instantiation flat_complete_lattice :: (type) top
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   283
begin
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   284
  definition "top = Top"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   285
  instance ..
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   286
end
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   287
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   288
instantiation flat_complete_lattice :: (type) lattice
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   289
begin
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   290
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   291
definition inf_flat_complete_lattice
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   292
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   293
  "inf x y =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   294
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   295
      Bot \<Rightarrow> Bot
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   296
    | Value v1 \<Rightarrow>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   297
        (case y of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   298
          Bot \<Rightarrow> Bot
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   299
        | Value v2 \<Rightarrow> if v1 = v2 then x else Bot
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   300
        | Top \<Rightarrow> x)
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   301
    | Top \<Rightarrow> y)"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   302
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   303
definition sup_flat_complete_lattice
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   304
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   305
  "sup x y =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   306
    (case x of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   307
      Bot \<Rightarrow> y
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   308
    | Value v1 \<Rightarrow>
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   309
        (case y of
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   310
          Bot \<Rightarrow> x
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   311
        | Value v2 \<Rightarrow> if v1 = v2 then x else Top
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   312
        | Top \<Rightarrow> Top)
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   313
    | Top \<Rightarrow> Top)"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   314
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   315
instance
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   316
  by default
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   317
    (auto simp add: inf_flat_complete_lattice_def sup_flat_complete_lattice_def
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   318
      less_eq_flat_complete_lattice_def split: flat_complete_lattice.splits)
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   319
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   320
end
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   321
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   322
instantiation flat_complete_lattice :: (type) complete_lattice
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   323
begin
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   324
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   325
definition Sup_flat_complete_lattice
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   326
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   327
  "Sup A =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   328
    (if A = {} \<or> A = {Bot} then Bot
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   329
     else if \<exists>v. A - {Bot} = {Value v} then Value (THE v. A - {Bot} = {Value v})
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   330
     else Top)"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   331
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   332
definition Inf_flat_complete_lattice
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   333
where
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   334
  "Inf A =
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   335
    (if A = {} \<or> A = {Top} then Top
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   336
     else if \<exists>v. A - {Top} = {Value v} then Value (THE v. A - {Top} = {Value v})
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   337
     else Bot)"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   338
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   339
instance
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   340
proof
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   341
  fix x :: "'a flat_complete_lattice"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   342
  fix A
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   343
  assume "x \<in> A"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   344
  {
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   345
    fix v
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   346
    assume "A - {Top} = {Value v}"
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   347
    then have "(THE v. A - {Top} = {Value v}) = v"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   348
      by (auto intro!: the1_equality)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   349
    moreover
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   350
    from \<open>x \<in> A\<close> \<open>A - {Top} = {Value v}\<close> have "x = Top \<or> x = Value v"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   351
      by auto
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   352
    ultimately have "Value (THE v. A - {Top} = {Value v}) \<le> x"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   353
      by auto
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   354
  }
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   355
  with \<open>x \<in> A\<close> show "Inf A \<le> x"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   356
    unfolding Inf_flat_complete_lattice_def
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 43815
diff changeset
   357
    by fastforce
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   358
next
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   359
  fix z :: "'a flat_complete_lattice"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   360
  fix A
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   361
  assume z: "\<And>x. x \<in> A \<Longrightarrow> z \<le> x"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   362
  {
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   363
    fix v
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   364
    assume *: "A - {Top} = {Value v}"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   365
    then have "(THE v. A - {Top} = {Value v}) = v"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   366
      by (auto intro!: the1_equality)
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   367
    with * have "z \<le> Value (THE v::'a. A - {Top} = {Value v})"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   368
      using z by auto
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   369
  }
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   370
  moreover
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   371
  {
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   372
    assume not_one_value: "A \<noteq> {}" "A \<noteq> {Top}" "\<not> (\<exists>v::'a. A - {Top} = {Value v})"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   373
    have "z \<le> Bot"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   374
    proof (cases "A - {Top} = {Bot}")
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   375
      case True
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   376
      with z show ?thesis
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   377
        by auto
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   378
    next
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   379
      case False
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   380
      from not_one_value
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   381
      obtain a1 where a1: "a1 \<in> A - {Top}" by auto
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   382
      from not_one_value False a1
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   383
      obtain a2 where "a2 \<in> A - {Top} \<and> a1 \<noteq> a2"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   384
        by (cases a1) auto
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   385
      with a1 z[of "a1"] z[of "a2"] show ?thesis
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   386
        apply (cases a1)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   387
        apply auto
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   388
        apply (cases a2)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   389
        apply auto
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   390
        apply (auto dest!: lesser_than_two_values)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   391
        done
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   392
    qed
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   393
  }
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   394
  ultimately show "z \<le> Inf A"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   395
    using z unfolding Inf_flat_complete_lattice_def by auto  -- slow
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   396
next
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   397
  fix x :: "'a flat_complete_lattice"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   398
  fix A
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   399
  assume "x \<in> A"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   400
  {
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   401
    fix v
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   402
    assume "A - {Bot} = {Value v}"
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   403
    then have "(THE v. A - {Bot} = {Value v}) = v"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   404
      by (auto intro!: the1_equality)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   405
    moreover
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   406
    from \<open>x \<in> A\<close> \<open>A - {Bot} = {Value v}\<close> have "x = Bot \<or> x = Value v"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   407
      by auto
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   408
    ultimately have "x \<le> Value (THE v. A - {Bot} = {Value v})"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   409
      by auto
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   410
  }
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   411
  with \<open>x \<in> A\<close> show "x \<le> Sup A"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   412
    unfolding Sup_flat_complete_lattice_def
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 43815
diff changeset
   413
    by fastforce
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   414
next
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   415
  fix z :: "'a flat_complete_lattice"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   416
  fix A
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   417
  assume z: "\<And>x. x \<in> A \<Longrightarrow> x \<le> z"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   418
  {
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   419
    fix v
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   420
    assume "A - {Bot} = {Value v}"
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   421
    moreover
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   422
    then have "(THE v. A - {Bot} = {Value v}) = v"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   423
      by (auto intro!: the1_equality)
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   424
    ultimately have "Value (THE v::'a. A - {Bot} = {Value v}) \<le> z"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   425
      using z by auto
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   426
  }
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   427
  moreover
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   428
  {
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   429
    assume not_one_value: "A \<noteq> {}" "A \<noteq> {Bot}" "\<not> (\<exists>v::'a. A - {Bot} = {Value v})"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   430
    have "Top \<le> z"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   431
    proof (cases "A - {Bot} = {Top}")
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   432
      case True
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   433
      with z show ?thesis
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   434
        by auto
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   435
    next
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   436
      case False
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   437
      from not_one_value obtain a1 where a1: "a1 \<in> A - {Bot}"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   438
        by auto
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   439
      from not_one_value False a1 obtain a2 where "a2 \<in> A - {Bot} \<and> a1 \<noteq> a2"
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   440
        by (cases a1) auto
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   441
      with a1 z[of "a1"] z[of "a2"] show ?thesis
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   442
        apply (cases a1)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   443
        apply auto
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   444
        apply (cases a2)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   445
        apply (auto dest!: greater_than_two_values)
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   446
        done
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   447
    qed
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   448
  }
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   449
  ultimately show "Sup A \<le> z"
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   450
    using z unfolding Sup_flat_complete_lattice_def by auto  -- slow
57543
36041934e429 adapt and reactivate Quickcheck_Types and add two test cases
Andreas Lochbihler
parents: 44890
diff changeset
   451
next
36041934e429 adapt and reactivate Quickcheck_Types and add two test cases
Andreas Lochbihler
parents: 44890
diff changeset
   452
  show "Inf {} = (top :: 'a flat_complete_lattice)"
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   453
    by (simp add: Inf_flat_complete_lattice_def top_flat_complete_lattice_def)
57543
36041934e429 adapt and reactivate Quickcheck_Types and add two test cases
Andreas Lochbihler
parents: 44890
diff changeset
   454
  show "Sup {} = (bot :: 'a flat_complete_lattice)"
60508
2127bee2069a tuned proofs;
wenzelm
parents: 60500
diff changeset
   455
    by (simp add: Sup_flat_complete_lattice_def bot_flat_complete_lattice_def)
37918
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   456
qed
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   457
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   458
end
eda5faaca9e2 adding a type for flat complete lattice to Quickcheck_Types
bulwahn
parents: 37915
diff changeset
   459
37915
e709e764f20c adding Library theory for other quickcheck default types
bulwahn
parents:
diff changeset
   460
end