src/HOL/Predicate.thy
changeset 46631 2c5c003cee35
parent 46557 ae926869a311
child 46636 353731f11559
equal deleted inserted replaced
46630:3abc964cdc45 46631:2c5c003cee35
    21   "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
    21   "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
    22   "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
    22   "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
    23   "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
    23   "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
    24 
    24 
    25 
    25 
    26 subsection {* Predicates as (complete) lattices *}
    26 subsection {* Classical rules for reasoning on predicates *}
    27 
    27 
    28 text {*
    28 declare predicate1D [Pure.dest?, dest?]
    29   Handy introduction and elimination rules for @{text "\<le>"}
    29 declare predicate2I [Pure.intro!, intro!]
    30   on unary and binary predicates
    30 declare predicate2D [Pure.dest, dest]
    31 *}
    31 declare bot1E [elim!]
    32 
    32 declare bot2E [elim!]
    33 lemma predicate1I:
    33 declare top1I [intro!]
    34   assumes PQ: "\<And>x. P x \<Longrightarrow> Q x"
    34 declare top2I [intro!]
    35   shows "P \<le> Q"
    35 declare inf1I [intro!]
    36   apply (rule le_funI)
    36 declare inf2I [intro!]
    37   apply (rule le_boolI)
    37 declare inf1E [elim!]
    38   apply (rule PQ)
    38 declare inf2E [elim!]
    39   apply assumption
    39 declare sup1I1 [intro?]
    40   done
    40 declare sup2I1 [intro?]
    41 
    41 declare sup1I2 [intro?]
    42 lemma predicate1D [Pure.dest?, dest?]:
    42 declare sup2I2 [intro?]
    43   "P \<le> Q \<Longrightarrow> P x \<Longrightarrow> Q x"
    43 declare sup1E [elim!]
    44   apply (erule le_funE)
    44 declare sup2E [elim!]
    45   apply (erule le_boolE)
    45 declare sup1CI [intro!]
    46   apply assumption+
    46 declare sup2CI [intro!]
    47   done
    47 declare INF1_I [intro!]
    48 
    48 declare INF2_I [intro!]
    49 lemma rev_predicate1D:
    49 declare INF1_D [elim]
    50   "P x \<Longrightarrow> P \<le> Q \<Longrightarrow> Q x"
    50 declare INF2_D [elim]
    51   by (rule predicate1D)
    51 declare INF1_E [elim]
    52 
    52 declare INF2_E [elim]
    53 lemma predicate2I [Pure.intro!, intro!]:
    53 declare SUP1_I [intro]
    54   assumes PQ: "\<And>x y. P x y \<Longrightarrow> Q x y"
    54 declare SUP2_I [intro]
    55   shows "P \<le> Q"
    55 declare SUP1_E [elim!]
    56   apply (rule le_funI)+
    56 declare SUP2_E [elim!]
    57   apply (rule le_boolI)
    57 
    58   apply (rule PQ)
    58 
    59   apply assumption
    59 subsection {* Conversion between set and predicate relations *}
    60   done
       
    61 
       
    62 lemma predicate2D [Pure.dest, dest]:
       
    63   "P \<le> Q \<Longrightarrow> P x y \<Longrightarrow> Q x y"
       
    64   apply (erule le_funE)+
       
    65   apply (erule le_boolE)
       
    66   apply assumption+
       
    67   done
       
    68 
       
    69 lemma rev_predicate2D:
       
    70   "P x y \<Longrightarrow> P \<le> Q \<Longrightarrow> Q x y"
       
    71   by (rule predicate2D)
       
    72 
       
    73 
    60 
    74 subsubsection {* Equality *}
    61 subsubsection {* Equality *}
    75 
    62 
    76 lemma pred_equals_eq [pred_set_conv]: "((\<lambda>x. x \<in> R) = (\<lambda>x. x \<in> S)) \<longleftrightarrow> (R = S)"
    63 lemma pred_equals_eq [pred_set_conv]: "((\<lambda>x. x \<in> R) = (\<lambda>x. x \<in> S)) \<longleftrightarrow> (R = S)"
    77   by (simp add: set_eq_iff fun_eq_iff)
    64   by (simp add: set_eq_iff fun_eq_iff)
    89   by (simp add: subset_iff le_fun_def)
    76   by (simp add: subset_iff le_fun_def)
    90 
    77 
    91 
    78 
    92 subsubsection {* Top and bottom elements *}
    79 subsubsection {* Top and bottom elements *}
    93 
    80 
    94 lemma bot1E [no_atp, elim!]: "\<bottom> x \<Longrightarrow> P"
       
    95   by (simp add: bot_fun_def)
       
    96 
       
    97 lemma bot2E [elim!]: "\<bottom> x y \<Longrightarrow> P"
       
    98   by (simp add: bot_fun_def)
       
    99 
       
   100 lemma bot_empty_eq: "\<bottom> = (\<lambda>x. x \<in> {})"
    81 lemma bot_empty_eq: "\<bottom> = (\<lambda>x. x \<in> {})"
   101   by (auto simp add: fun_eq_iff)
    82   by (auto simp add: fun_eq_iff)
   102 
    83 
   103 lemma bot_empty_eq2: "\<bottom> = (\<lambda>x y. (x, y) \<in> {})"
    84 lemma bot_empty_eq2: "\<bottom> = (\<lambda>x y. (x, y) \<in> {})"
   104   by (auto simp add: fun_eq_iff)
    85   by (auto simp add: fun_eq_iff)
   105 
    86 
   106 lemma top1I [intro!]: "\<top> x"
       
   107   by (simp add: top_fun_def)
       
   108 
       
   109 lemma top2I [intro!]: "\<top> x y"
       
   110   by (simp add: top_fun_def)
       
   111 
       
   112 
    87 
   113 subsubsection {* Binary intersection *}
    88 subsubsection {* Binary intersection *}
   114 
       
   115 lemma inf1I [intro!]: "A x \<Longrightarrow> B x \<Longrightarrow> (A \<sqinter> B) x"
       
   116   by (simp add: inf_fun_def)
       
   117 
       
   118 lemma inf2I [intro!]: "A x y \<Longrightarrow> B x y \<Longrightarrow> (A \<sqinter> B) x y"
       
   119   by (simp add: inf_fun_def)
       
   120 
       
   121 lemma inf1E [elim!]: "(A \<sqinter> B) x \<Longrightarrow> (A x \<Longrightarrow> B x \<Longrightarrow> P) \<Longrightarrow> P"
       
   122   by (simp add: inf_fun_def)
       
   123 
       
   124 lemma inf2E [elim!]: "(A \<sqinter> B) x y \<Longrightarrow> (A x y \<Longrightarrow> B x y \<Longrightarrow> P) \<Longrightarrow> P"
       
   125   by (simp add: inf_fun_def)
       
   126 
       
   127 lemma inf1D1: "(A \<sqinter> B) x \<Longrightarrow> A x"
       
   128   by (simp add: inf_fun_def)
       
   129 
       
   130 lemma inf2D1: "(A \<sqinter> B) x y \<Longrightarrow> A x y"
       
   131   by (simp add: inf_fun_def)
       
   132 
       
   133 lemma inf1D2: "(A \<sqinter> B) x \<Longrightarrow> B x"
       
   134   by (simp add: inf_fun_def)
       
   135 
       
   136 lemma inf2D2: "(A \<sqinter> B) x y \<Longrightarrow> B x y"
       
   137   by (simp add: inf_fun_def)
       
   138 
    89 
   139 lemma inf_Int_eq [pred_set_conv]: "(\<lambda>x. x \<in> R) \<sqinter> (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<inter> S)"
    90 lemma inf_Int_eq [pred_set_conv]: "(\<lambda>x. x \<in> R) \<sqinter> (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<inter> S)"
   140   by (simp add: inf_fun_def)
    91   by (simp add: inf_fun_def)
   141 
    92 
   142 lemma inf_Int_eq2 [pred_set_conv]: "(\<lambda>x y. (x, y) \<in> R) \<sqinter> (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<inter> S)"
    93 lemma inf_Int_eq2 [pred_set_conv]: "(\<lambda>x y. (x, y) \<in> R) \<sqinter> (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<inter> S)"
   143   by (simp add: inf_fun_def)
    94   by (simp add: inf_fun_def)
   144 
    95 
   145 
    96 
   146 subsubsection {* Binary union *}
    97 subsubsection {* Binary union *}
   147 
    98 
   148 lemma sup1I1 [intro?]: "A x \<Longrightarrow> (A \<squnion> B) x"
       
   149   by (simp add: sup_fun_def)
       
   150 
       
   151 lemma sup2I1 [intro?]: "A x y \<Longrightarrow> (A \<squnion> B) x y"
       
   152   by (simp add: sup_fun_def)
       
   153 
       
   154 lemma sup1I2 [intro?]: "B x \<Longrightarrow> (A \<squnion> B) x"
       
   155   by (simp add: sup_fun_def)
       
   156 
       
   157 lemma sup2I2 [intro?]: "B x y \<Longrightarrow> (A \<squnion> B) x y"
       
   158   by (simp add: sup_fun_def)
       
   159 
       
   160 lemma sup1E [elim!]: "(A \<squnion> B) x \<Longrightarrow> (A x \<Longrightarrow> P) \<Longrightarrow> (B x \<Longrightarrow> P) \<Longrightarrow> P"
       
   161   by (simp add: sup_fun_def) iprover
       
   162 
       
   163 lemma sup2E [elim!]: "(A \<squnion> B) x y \<Longrightarrow> (A x y \<Longrightarrow> P) \<Longrightarrow> (B x y \<Longrightarrow> P) \<Longrightarrow> P"
       
   164   by (simp add: sup_fun_def) iprover
       
   165 
       
   166 text {*
       
   167   \medskip Classical introduction rule: no commitment to @{text A} vs
       
   168   @{text B}.
       
   169 *}
       
   170 
       
   171 lemma sup1CI [intro!]: "(\<not> B x \<Longrightarrow> A x) \<Longrightarrow> (A \<squnion> B) x"
       
   172   by (auto simp add: sup_fun_def)
       
   173 
       
   174 lemma sup2CI [intro!]: "(\<not> B x y \<Longrightarrow> A x y) \<Longrightarrow> (A \<squnion> B) x y"
       
   175   by (auto simp add: sup_fun_def)
       
   176 
       
   177 lemma sup_Un_eq [pred_set_conv]: "(\<lambda>x. x \<in> R) \<squnion> (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<union> S)"
    99 lemma sup_Un_eq [pred_set_conv]: "(\<lambda>x. x \<in> R) \<squnion> (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<union> S)"
   178   by (simp add: sup_fun_def)
   100   by (simp add: sup_fun_def)
   179 
   101 
   180 lemma sup_Un_eq2 [pred_set_conv]: "(\<lambda>x y. (x, y) \<in> R) \<squnion> (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<union> S)"
   102 lemma sup_Un_eq2 [pred_set_conv]: "(\<lambda>x y. (x, y) \<in> R) \<squnion> (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<union> S)"
   181   by (simp add: sup_fun_def)
   103   by (simp add: sup_fun_def)
   182 
   104 
   183 
   105 
   184 subsubsection {* Intersections of families *}
   106 subsubsection {* Intersections of families *}
   185 
   107 
   186 lemma INF1_iff: "(\<Sqinter>x\<in>A. B x) b = (\<forall>x\<in>A. B x b)"
   108 lemma INF_INT_eq: "(\<Sqinter>i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (\<Inter>i. r i))"
   187   by (simp add: INF_apply)
       
   188 
       
   189 lemma INF2_iff: "(\<Sqinter>x\<in>A. B x) b c = (\<forall>x\<in>A. B x b c)"
       
   190   by (simp add: INF_apply)
       
   191 
       
   192 lemma INF1_I [intro!]: "(\<And>x. x \<in> A \<Longrightarrow> B x b) \<Longrightarrow> (\<Sqinter>x\<in>A. B x) b"
       
   193   by (auto simp add: INF_apply)
       
   194 
       
   195 lemma INF2_I [intro!]: "(\<And>x. x \<in> A \<Longrightarrow> B x b c) \<Longrightarrow> (\<Sqinter>x\<in>A. B x) b c"
       
   196   by (auto simp add: INF_apply)
       
   197 
       
   198 lemma INF1_D [elim]: "(\<Sqinter>x\<in>A. B x) b \<Longrightarrow> a \<in> A \<Longrightarrow> B a b"
       
   199   by (auto simp add: INF_apply)
       
   200 
       
   201 lemma INF2_D [elim]: "(\<Sqinter>x\<in>A. B x) b c \<Longrightarrow> a \<in> A \<Longrightarrow> B a b c"
       
   202   by (auto simp add: INF_apply)
       
   203 
       
   204 lemma INF1_E [elim]: "(\<Sqinter>x\<in>A. B x) b \<Longrightarrow> (B a b \<Longrightarrow> R) \<Longrightarrow> (a \<notin> A \<Longrightarrow> R) \<Longrightarrow> R"
       
   205   by (auto simp add: INF_apply)
       
   206 
       
   207 lemma INF2_E [elim]: "(\<Sqinter>x\<in>A. B x) b c \<Longrightarrow> (B a b c \<Longrightarrow> R) \<Longrightarrow> (a \<notin> A \<Longrightarrow> R) \<Longrightarrow> R"
       
   208   by (auto simp add: INF_apply)
       
   209 
       
   210 lemma INF_INT_eq: "(\<Sqinter>i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (\<Sqinter>i. r i))"
       
   211   by (simp add: INF_apply fun_eq_iff)
   109   by (simp add: INF_apply fun_eq_iff)
   212 
   110 
   213 lemma INF_INT_eq2: "(\<Sqinter>i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (\<Sqinter>i. r i))"
   111 lemma INF_INT_eq2: "(\<Sqinter>i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (\<Inter>i. r i))"
   214   by (simp add: INF_apply fun_eq_iff)
   112   by (simp add: INF_apply fun_eq_iff)
   215 
   113 
   216 
   114 
   217 subsubsection {* Unions of families *}
   115 subsubsection {* Unions of families *}
   218 
       
   219 lemma SUP1_iff: "(\<Squnion>x\<in>A. B x) b = (\<exists>x\<in>A. B x b)"
       
   220   by (simp add: SUP_apply)
       
   221 
       
   222 lemma SUP2_iff: "(\<Squnion>x\<in>A. B x) b c = (\<exists>x\<in>A. B x b c)"
       
   223   by (simp add: SUP_apply)
       
   224 
       
   225 lemma SUP1_I [intro]: "a \<in> A \<Longrightarrow> B a b \<Longrightarrow> (\<Squnion>x\<in>A. B x) b"
       
   226   by (auto simp add: SUP_apply)
       
   227 
       
   228 lemma SUP2_I [intro]: "a \<in> A \<Longrightarrow> B a b c \<Longrightarrow> (\<Squnion>x\<in>A. B x) b c"
       
   229   by (auto simp add: SUP_apply)
       
   230 
       
   231 lemma SUP1_E [elim!]: "(\<Squnion>x\<in>A. B x) b \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> B x b \<Longrightarrow> R) \<Longrightarrow> R"
       
   232   by (auto simp add: SUP_apply)
       
   233 
       
   234 lemma SUP2_E [elim!]: "(\<Squnion>x\<in>A. B x) b c \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> B x b c \<Longrightarrow> R) \<Longrightarrow> R"
       
   235   by (auto simp add: SUP_apply)
       
   236 
   116 
   237 lemma SUP_UN_eq [pred_set_conv]: "(\<Squnion>i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (\<Union>i. r i))"
   117 lemma SUP_UN_eq [pred_set_conv]: "(\<Squnion>i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (\<Union>i. r i))"
   238   by (simp add: SUP_apply fun_eq_iff)
   118   by (simp add: SUP_apply fun_eq_iff)
   239 
   119 
   240 lemma SUP_UN_eq2 [pred_set_conv]: "(\<Squnion>i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (\<Union>i. r i))"
   120 lemma SUP_UN_eq2 [pred_set_conv]: "(\<Squnion>i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (\<Union>i. r i))"