| author | wenzelm | 
| Wed, 06 Apr 2022 11:09:58 +0200 | |
| changeset 75408 | e859c9f30db2 | 
| parent 67613 | ce654b0e6d69 | 
| child 80067 | c40bdfc84640 | 
| permissions | -rw-r--r-- | 
| 41777 | 1 | (* Title: HOL/ZF/Games.thy | 
| 19203 | 2 | Author: Steven Obua | 
| 3 | ||
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 4 | An application of HOLZF: Partizan Games. See "Partizan Games in | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 5 | Isabelle/HOLZF", available from http://www4.in.tum.de/~obua/partizan | 
| 19203 | 6 | *) | 
| 7 | ||
| 8 | theory Games | |
| 9 | imports MainZF | |
| 10 | begin | |
| 11 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 12 | definition fixgames :: "ZF set \<Rightarrow> ZF set" where | 
| 19203 | 13 |   "fixgames A \<equiv> { Opair l r | l r. explode l \<subseteq> A & explode r \<subseteq> A}"
 | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 14 | |
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 15 | definition games_lfp :: "ZF set" where | 
| 19203 | 16 | "games_lfp \<equiv> lfp fixgames" | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 17 | |
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 18 | definition games_gfp :: "ZF set" where | 
| 19203 | 19 | "games_gfp \<equiv> gfp fixgames" | 
| 20 | ||
| 21 | lemma mono_fixgames: "mono (fixgames)" | |
| 46557 
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
 haftmann parents: 
46555diff
changeset | 22 | apply (auto simp add: mono_def fixgames_def) | 
| 
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
 haftmann parents: 
46555diff
changeset | 23 | apply (rule_tac x=l in exI) | 
| 
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
 haftmann parents: 
46555diff
changeset | 24 | apply (rule_tac x=r in exI) | 
| 
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
 haftmann parents: 
46555diff
changeset | 25 | apply auto | 
| 
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
 haftmann parents: 
46555diff
changeset | 26 | done | 
| 19203 | 27 | |
| 28 | lemma games_lfp_unfold: "games_lfp = fixgames games_lfp" | |
| 29 | by (auto simp add: def_lfp_unfold games_lfp_def mono_fixgames) | |
| 30 | ||
| 31 | lemma games_gfp_unfold: "games_gfp = fixgames games_gfp" | |
| 32 | by (auto simp add: def_gfp_unfold games_gfp_def mono_fixgames) | |
| 33 | ||
| 34 | lemma games_lfp_nonempty: "Opair Empty Empty \<in> games_lfp" | |
| 35 | proof - | |
| 36 |   have "fixgames {} \<subseteq> games_lfp" 
 | |
| 37 | apply (subst games_lfp_unfold) | |
| 38 | apply (simp add: mono_fixgames[simplified mono_def, rule_format]) | |
| 39 | done | |
| 40 |   moreover have "fixgames {} = {Opair Empty Empty}"
 | |
| 41 | by (simp add: fixgames_def explode_Empty) | |
| 42 | finally show ?thesis | |
| 43 | by auto | |
| 44 | qed | |
| 45 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 46 | definition left_option :: "ZF \<Rightarrow> ZF \<Rightarrow> bool" where | 
| 19203 | 47 | "left_option g opt \<equiv> (Elem opt (Fst g))" | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 48 | |
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 49 | definition right_option :: "ZF \<Rightarrow> ZF \<Rightarrow> bool" where | 
| 19203 | 50 | "right_option g opt \<equiv> (Elem opt (Snd g))" | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 51 | |
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 52 | definition is_option_of :: "(ZF * ZF) set" where | 
| 19203 | 53 |   "is_option_of \<equiv> { (opt, g) | opt g. g \<in> games_gfp \<and> (left_option g opt \<or> right_option g opt) }"
 | 
| 54 | ||
| 55 | lemma games_lfp_subset_gfp: "games_lfp \<subseteq> games_gfp" | |
| 56 | proof - | |
| 57 | have "games_lfp \<subseteq> fixgames games_lfp" | |
| 58 | by (simp add: games_lfp_unfold[symmetric]) | |
| 59 | then show ?thesis | |
| 60 | by (simp add: games_gfp_def gfp_upperbound) | |
| 61 | qed | |
| 62 | ||
| 63 | lemma games_option_stable: | |
| 64 | assumes fixgames: "games = fixgames games" | |
| 65 | and g: "g \<in> games" | |
| 66 | and opt: "left_option g opt \<or> right_option g opt" | |
| 67 | shows "opt \<in> games" | |
| 68 | proof - | |
| 69 | from g fixgames have "g \<in> fixgames games" by auto | |
| 70 | then have "\<exists> l r. g = Opair l r \<and> explode l \<subseteq> games \<and> explode r \<subseteq> games" | |
| 71 | by (simp add: fixgames_def) | |
| 72 | then obtain l where "\<exists> r. g = Opair l r \<and> explode l \<subseteq> games \<and> explode r \<subseteq> games" .. | |
| 73 | then obtain r where lr: "g = Opair l r \<and> explode l \<subseteq> games \<and> explode r \<subseteq> games" .. | |
| 74 | with opt show ?thesis | |
| 75 | by (auto intro: Elem_explode_in simp add: left_option_def right_option_def Fst Snd) | |
| 76 | qed | |
| 77 | ||
| 78 | lemma option2elem: "(opt,g) \<in> is_option_of \<Longrightarrow> \<exists> u v. Elem opt u \<and> Elem u v \<and> Elem v g" | |
| 79 | apply (simp add: is_option_of_def) | |
| 80 | apply (subgoal_tac "(g \<in> games_gfp) = (g \<in> (fixgames games_gfp))") | |
| 81 | prefer 2 | |
| 82 | apply (simp add: games_gfp_unfold[symmetric]) | |
| 83 | apply (auto simp add: fixgames_def left_option_def right_option_def Fst Snd) | |
| 84 | apply (rule_tac x=l in exI, insert Elem_Opair_exists, blast) | |
| 85 | apply (rule_tac x=r in exI, insert Elem_Opair_exists, blast) | |
| 86 | done | |
| 87 | ||
| 67613 | 88 | lemma is_option_of_subset_is_Elem_of: "is_option_of \<subseteq> (is_Elem_of\<^sup>+)" | 
| 19203 | 89 | proof - | 
| 90 |   {
 | |
| 91 | fix opt | |
| 92 | fix g | |
| 93 | assume "(opt, g) \<in> is_option_of" | |
| 67613 | 94 | then have "\<exists> u v. (opt, u) \<in> (is_Elem_of\<^sup>+) \<and> (u,v) \<in> (is_Elem_of\<^sup>+) \<and> (v,g) \<in> (is_Elem_of\<^sup>+)" | 
| 19203 | 95 | apply - | 
| 96 | apply (drule option2elem) | |
| 97 | apply (auto simp add: r_into_trancl' is_Elem_of_def) | |
| 98 | done | |
| 67613 | 99 | then have "(opt, g) \<in> (is_Elem_of\<^sup>+)" | 
| 19203 | 100 | by (blast intro: trancl_into_rtrancl trancl_rtrancl_trancl) | 
| 101 | } | |
| 102 | then show ?thesis by auto | |
| 103 | qed | |
| 104 | ||
| 105 | lemma wfzf_is_option_of: "wfzf is_option_of" | |
| 106 | proof - | |
| 67613 | 107 | have "wfzf (is_Elem_of\<^sup>+)" by (simp add: wfzf_trancl wfzf_is_Elem_of) | 
| 19203 | 108 | then show ?thesis | 
| 109 | apply (rule wfzf_subset) | |
| 110 | apply (rule is_option_of_subset_is_Elem_of) | |
| 111 | done | |
| 112 | qed | |
| 113 | ||
| 114 | lemma games_gfp_imp_lfp: "g \<in> games_gfp \<longrightarrow> g \<in> games_lfp" | |
| 115 | proof - | |
| 116 | have unfold_gfp: "\<And> x. x \<in> games_gfp \<Longrightarrow> x \<in> (fixgames games_gfp)" | |
| 117 | by (simp add: games_gfp_unfold[symmetric]) | |
| 118 | have unfold_lfp: "\<And> x. (x \<in> games_lfp) = (x \<in> (fixgames games_lfp))" | |
| 119 | by (simp add: games_lfp_unfold[symmetric]) | |
| 120 | show ?thesis | |
| 121 | apply (rule wf_induct[OF wfzf_implies_wf[OF wfzf_is_option_of]]) | |
| 122 | apply (auto simp add: is_option_of_def) | |
| 123 | apply (drule_tac unfold_gfp) | |
| 124 | apply (simp add: fixgames_def) | |
| 125 | apply (auto simp add: left_option_def Fst right_option_def Snd) | |
| 126 | apply (subgoal_tac "explode l \<subseteq> games_lfp") | |
| 127 | apply (subgoal_tac "explode r \<subseteq> games_lfp") | |
| 128 | apply (subst unfold_lfp) | |
| 129 | apply (auto simp add: fixgames_def) | |
| 130 | apply (simp_all add: explode_Elem Elem_explode_in) | |
| 131 | done | |
| 132 | qed | |
| 133 | ||
| 134 | theorem games_lfp_eq_gfp: "games_lfp = games_gfp" | |
| 135 | apply (auto simp add: games_gfp_imp_lfp) | |
| 136 | apply (insert games_lfp_subset_gfp) | |
| 137 | apply auto | |
| 138 | done | |
| 139 | ||
| 140 | theorem unique_games: "(g = fixgames g) = (g = games_lfp)" | |
| 141 | proof - | |
| 142 |   {
 | |
| 143 | fix g | |
| 144 | assume g: "g = fixgames g" | |
| 145 | from g have "fixgames g \<subseteq> g" by auto | |
| 146 | then have l:"games_lfp \<subseteq> g" | |
| 147 | by (simp add: games_lfp_def lfp_lowerbound) | |
| 148 | from g have "g \<subseteq> fixgames g" by auto | |
| 149 | then have u:"g \<subseteq> games_gfp" | |
| 150 | by (simp add: games_gfp_def gfp_upperbound) | |
| 151 | from l u games_lfp_eq_gfp[symmetric] have "g = games_lfp" | |
| 152 | by auto | |
| 153 | } | |
| 154 | note games = this | |
| 155 | show ?thesis | |
| 66894 | 156 | apply (rule iffI) | 
| 19203 | 157 | apply (erule games) | 
| 158 | apply (simp add: games_lfp_unfold[symmetric]) | |
| 159 | done | |
| 160 | qed | |
| 161 | ||
| 162 | lemma games_lfp_option_stable: | |
| 163 | assumes g: "g \<in> games_lfp" | |
| 164 | and opt: "left_option g opt \<or> right_option g opt" | |
| 165 | shows "opt \<in> games_lfp" | |
| 166 | apply (rule games_option_stable[where g=g]) | |
| 167 | apply (simp add: games_lfp_unfold[symmetric]) | |
| 41528 | 168 | apply (simp_all add: assms) | 
| 19203 | 169 | done | 
| 170 | ||
| 171 | lemma is_option_of_imp_games: | |
| 172 | assumes hyp: "(opt, g) \<in> is_option_of" | |
| 173 | shows "opt \<in> games_lfp \<and> g \<in> games_lfp" | |
| 174 | proof - | |
| 175 | from hyp have g_game: "g \<in> games_lfp" | |
| 176 | by (simp add: is_option_of_def games_lfp_eq_gfp) | |
| 177 | from hyp have "left_option g opt \<or> right_option g opt" | |
| 178 | by (auto simp add: is_option_of_def) | |
| 179 | with g_game games_lfp_option_stable[OF g_game, OF this] show ?thesis | |
| 180 | by auto | |
| 181 | qed | |
| 182 | ||
| 183 | lemma games_lfp_represent: "x \<in> games_lfp \<Longrightarrow> \<exists> l r. x = Opair l r" | |
| 184 | apply (rule exI[where x="Fst x"]) | |
| 185 | apply (rule exI[where x="Snd x"]) | |
| 186 | apply (subgoal_tac "x \<in> (fixgames games_lfp)") | |
| 187 | apply (simp add: fixgames_def) | |
| 188 | apply (auto simp add: Fst Snd) | |
| 189 | apply (simp add: games_lfp_unfold[symmetric]) | |
| 190 | done | |
| 191 | ||
| 45694 
4a8743618257
prefer typedef without extra definition and alternative name;
 wenzelm parents: 
44011diff
changeset | 192 | definition "game = games_lfp" | 
| 
4a8743618257
prefer typedef without extra definition and alternative name;
 wenzelm parents: 
44011diff
changeset | 193 | |
| 49834 | 194 | typedef game = game | 
| 45694 
4a8743618257
prefer typedef without extra definition and alternative name;
 wenzelm parents: 
44011diff
changeset | 195 | unfolding game_def by (blast intro: games_lfp_nonempty) | 
| 19203 | 196 | |
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 197 | definition left_options :: "game \<Rightarrow> game zet" where | 
| 19203 | 198 | "left_options g \<equiv> zimage Abs_game (zexplode (Fst (Rep_game g)))" | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 199 | |
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 200 | definition right_options :: "game \<Rightarrow> game zet" where | 
| 19203 | 201 | "right_options g \<equiv> zimage Abs_game (zexplode (Snd (Rep_game g)))" | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 202 | |
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 203 | definition options :: "game \<Rightarrow> game zet" where | 
| 19203 | 204 | "options g \<equiv> zunion (left_options g) (right_options g)" | 
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 205 | |
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 206 | definition Game :: "game zet \<Rightarrow> game zet \<Rightarrow> game" where | 
| 19203 | 207 | "Game L R \<equiv> Abs_game (Opair (zimplode (zimage Rep_game L)) (zimplode (zimage Rep_game R)))" | 
| 208 | ||
| 209 | lemma Repl_Rep_game_Abs_game: "\<forall> e. Elem e z \<longrightarrow> e \<in> games_lfp \<Longrightarrow> Repl z (Rep_game o Abs_game) = z" | |
| 210 | apply (subst Ext) | |
| 211 | apply (simp add: Repl) | |
| 212 | apply auto | |
| 213 | apply (subst Abs_game_inverse, simp_all add: game_def) | |
| 214 | apply (rule_tac x=za in exI) | |
| 215 | apply (subst Abs_game_inverse, simp_all add: game_def) | |
| 216 | done | |
| 217 | ||
| 218 | lemma game_split: "g = Game (left_options g) (right_options g)" | |
| 219 | proof - | |
| 220 | have "\<exists> l r. Rep_game g = Opair l r" | |
| 221 | apply (insert Rep_game[of g]) | |
| 222 | apply (simp add: game_def games_lfp_represent) | |
| 223 | done | |
| 224 | then obtain l r where lr: "Rep_game g = Opair l r" by auto | |
| 225 | have partizan_g: "Rep_game g \<in> games_lfp" | |
| 226 | apply (insert Rep_game[of g]) | |
| 227 | apply (simp add: game_def) | |
| 228 | done | |
| 229 | have "\<forall> e. Elem e l \<longrightarrow> left_option (Rep_game g) e" | |
| 230 | by (simp add: lr left_option_def Fst) | |
| 231 | then have partizan_l: "\<forall> e. Elem e l \<longrightarrow> e \<in> games_lfp" | |
| 232 | apply auto | |
| 233 | apply (rule games_lfp_option_stable[where g="Rep_game g", OF partizan_g]) | |
| 234 | apply auto | |
| 235 | done | |
| 236 | have "\<forall> e. Elem e r \<longrightarrow> right_option (Rep_game g) e" | |
| 237 | by (simp add: lr right_option_def Snd) | |
| 238 | then have partizan_r: "\<forall> e. Elem e r \<longrightarrow> e \<in> games_lfp" | |
| 239 | apply auto | |
| 240 | apply (rule games_lfp_option_stable[where g="Rep_game g", OF partizan_g]) | |
| 241 | apply auto | |
| 242 | done | |
| 243 | let ?L = "zimage (Abs_game) (zexplode l)" | |
| 244 | let ?R = "zimage (Abs_game) (zexplode r)" | |
| 245 | have L:"?L = left_options g" | |
| 246 | by (simp add: left_options_def lr Fst) | |
| 247 | have R:"?R = right_options g" | |
| 248 | by (simp add: right_options_def lr Snd) | |
| 249 | have "g = Game ?L ?R" | |
| 250 | apply (simp add: Game_def Rep_game_inject[symmetric] comp_zimage_eq zimage_zexplode_eq zimplode_zexplode) | |
| 251 | apply (simp add: Repl_Rep_game_Abs_game partizan_l partizan_r) | |
| 252 | apply (subst Abs_game_inverse) | |
| 253 | apply (simp_all add: lr[symmetric] Rep_game) | |
| 254 | done | |
| 255 | then show ?thesis | |
| 256 | by (simp add: L R) | |
| 257 | qed | |
| 258 | ||
| 259 | lemma Opair_in_games_lfp: | |
| 260 | assumes l: "explode l \<subseteq> games_lfp" | |
| 261 | and r: "explode r \<subseteq> games_lfp" | |
| 262 | shows "Opair l r \<in> games_lfp" | |
| 263 | proof - | |
| 264 | note f = unique_games[of games_lfp, simplified] | |
| 265 | show ?thesis | |
| 266 | apply (subst f) | |
| 267 | apply (simp add: fixgames_def) | |
| 268 | apply (rule exI[where x=l]) | |
| 269 | apply (rule exI[where x=r]) | |
| 270 | apply (auto simp add: l r) | |
| 271 | done | |
| 272 | qed | |
| 273 | ||
| 274 | lemma left_options[simp]: "left_options (Game l r) = l" | |
| 275 | apply (simp add: left_options_def Game_def) | |
| 276 | apply (subst Abs_game_inverse) | |
| 277 | apply (simp add: game_def) | |
| 278 | apply (rule Opair_in_games_lfp) | |
| 279 | apply (auto simp add: explode_Elem Elem_zimplode zimage_iff Rep_game[simplified game_def]) | |
| 280 | apply (simp add: Fst zexplode_zimplode comp_zimage_eq) | |
| 281 | apply (simp add: zet_ext_eq zimage_iff Rep_game_inverse) | |
| 282 | done | |
| 283 | ||
| 284 | lemma right_options[simp]: "right_options (Game l r) = r" | |
| 285 | apply (simp add: right_options_def Game_def) | |
| 286 | apply (subst Abs_game_inverse) | |
| 287 | apply (simp add: game_def) | |
| 288 | apply (rule Opair_in_games_lfp) | |
| 289 | apply (auto simp add: explode_Elem Elem_zimplode zimage_iff Rep_game[simplified game_def]) | |
| 290 | apply (simp add: Snd zexplode_zimplode comp_zimage_eq) | |
| 291 | apply (simp add: zet_ext_eq zimage_iff Rep_game_inverse) | |
| 292 | done | |
| 293 | ||
| 294 | lemma Game_ext: "(Game l1 r1 = Game l2 r2) = ((l1 = l2) \<and> (r1 = r2))" | |
| 295 | apply auto | |
| 296 | apply (subst left_options[where l=l1 and r=r1,symmetric]) | |
| 297 | apply (subst left_options[where l=l2 and r=r2,symmetric]) | |
| 298 | apply simp | |
| 299 | apply (subst right_options[where l=l1 and r=r1,symmetric]) | |
| 300 | apply (subst right_options[where l=l2 and r=r2,symmetric]) | |
| 301 | apply simp | |
| 302 | done | |
| 303 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 304 | definition option_of :: "(game * game) set" where | 
| 19203 | 305 | "option_of \<equiv> image (\<lambda> (option, g). (Abs_game option, Abs_game g)) is_option_of" | 
| 306 | ||
| 307 | lemma option_to_is_option_of: "((option, g) \<in> option_of) = ((Rep_game option, Rep_game g) \<in> is_option_of)" | |
| 308 | apply (auto simp add: option_of_def) | |
| 309 | apply (subst Abs_game_inverse) | |
| 310 | apply (simp add: is_option_of_imp_games game_def) | |
| 311 | apply (subst Abs_game_inverse) | |
| 312 | apply (simp add: is_option_of_imp_games game_def) | |
| 313 | apply simp | |
| 314 | apply (auto simp add: Bex_def image_def) | |
| 315 | apply (rule exI[where x="Rep_game option"]) | |
| 316 | apply (rule exI[where x="Rep_game g"]) | |
| 317 | apply (simp add: Rep_game_inverse) | |
| 318 | done | |
| 319 | ||
| 320 | lemma wf_is_option_of: "wf is_option_of" | |
| 321 | apply (rule wfzf_implies_wf) | |
| 322 | apply (simp add: wfzf_is_option_of) | |
| 323 | done | |
| 324 | ||
| 44011 
f67c93f52d13
eliminated obsolete recdef/wfrec related declarations
 krauss parents: 
41777diff
changeset | 325 | lemma wf_option_of[simp, intro]: "wf option_of" | 
| 19203 | 326 | proof - | 
| 327 | have option_of: "option_of = inv_image is_option_of Rep_game" | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
35440diff
changeset | 328 | apply (rule set_eqI) | 
| 19203 | 329 | apply (case_tac "x") | 
| 19769 
c40ce2de2020
Added [simp]-lemmas "in_inv_image" and "in_lex_prod" in the spirit of "in_measure".
 krauss parents: 
19203diff
changeset | 330 | by (simp add: option_to_is_option_of) | 
| 19203 | 331 | show ?thesis | 
| 332 | apply (simp add: option_of) | |
| 46752 
e9e7209eb375
more fundamental pred-to-set conversions, particularly by means of inductive_set; associated consolidation of some theorem names (c.f. NEWS)
 haftmann parents: 
46557diff
changeset | 333 | apply (auto intro: wf_is_option_of) | 
| 19203 | 334 | done | 
| 335 | qed | |
| 336 | ||
| 337 | lemma right_option_is_option[simp, intro]: "zin x (right_options g) \<Longrightarrow> zin x (options g)" | |
| 338 | by (simp add: options_def zunion) | |
| 339 | ||
| 340 | lemma left_option_is_option[simp, intro]: "zin x (left_options g) \<Longrightarrow> zin x (options g)" | |
| 341 | by (simp add: options_def zunion) | |
| 342 | ||
| 343 | lemma zin_options[simp, intro]: "zin x (options g) \<Longrightarrow> (x, g) \<in> option_of" | |
| 344 | apply (simp add: options_def zunion left_options_def right_options_def option_of_def | |
| 345 | image_def is_option_of_def zimage_iff zin_zexplode_eq) | |
| 346 | apply (cases g) | |
| 347 | apply (cases x) | |
| 348 | apply (auto simp add: Abs_game_inverse games_lfp_eq_gfp[symmetric] game_def | |
| 349 | right_option_def[symmetric] left_option_def[symmetric]) | |
| 350 | done | |
| 351 | ||
| 35440 | 352 | function | 
| 19203 | 353 | neg_game :: "game \<Rightarrow> game" | 
| 35440 | 354 | where | 
| 355 | [simp del]: "neg_game g = Game (zimage neg_game (right_options g)) (zimage neg_game (left_options g))" | |
| 356 | by auto | |
| 357 | termination by (relation "option_of") auto | |
| 19203 | 358 | |
| 359 | lemma "neg_game (neg_game g) = g" | |
| 360 | apply (induct g rule: neg_game.induct) | |
| 361 | apply (subst neg_game.simps)+ | |
| 46752 
e9e7209eb375
more fundamental pred-to-set conversions, particularly by means of inductive_set; associated consolidation of some theorem names (c.f. NEWS)
 haftmann parents: 
46557diff
changeset | 362 | apply (simp add: comp_zimage_eq) | 
| 19203 | 363 | apply (subgoal_tac "zimage (neg_game o neg_game) (left_options g) = left_options g") | 
| 364 | apply (subgoal_tac "zimage (neg_game o neg_game) (right_options g) = right_options g") | |
| 365 | apply (auto simp add: game_split[symmetric]) | |
| 366 | apply (auto simp add: zet_ext_eq zimage_iff) | |
| 367 | done | |
| 368 | ||
| 35440 | 369 | function | 
| 19203 | 370 | ge_game :: "(game * game) \<Rightarrow> bool" | 
| 35440 | 371 | where | 
| 372 | [simp del]: "ge_game (G, H) = (\<forall> x. if zin x (right_options G) then ( | |
| 19203 | 373 | if zin x (left_options H) then \<not> (ge_game (H, x) \<or> (ge_game (x, G))) | 
| 374 | else \<not> (ge_game (H, x))) | |
| 375 | else (if zin x (left_options H) then \<not> (ge_game (x, G)) else True))" | |
| 35440 | 376 | by auto | 
| 377 | termination by (relation "(gprod_2_1 option_of)") | |
| 378 | (simp, auto simp: gprod_2_1_def) | |
| 19203 | 379 | |
| 26304 | 380 | lemma ge_game_eq: "ge_game (G, H) = (\<forall> x. (zin x (right_options G) \<longrightarrow> \<not> ge_game (H, x)) \<and> (zin x (left_options H) \<longrightarrow> \<not> ge_game (x, G)))" | 
| 19203 | 381 | apply (subst ge_game.simps[where G=G and H=H]) | 
| 382 | apply (auto) | |
| 383 | done | |
| 384 | ||
| 385 | lemma ge_game_leftright_refl[rule_format]: | |
| 386 | "\<forall> y. (zin y (right_options x) \<longrightarrow> \<not> ge_game (x, y)) \<and> (zin y (left_options x) \<longrightarrow> \<not> (ge_game (y, x))) \<and> ge_game (x, x)" | |
| 387 | proof (induct x rule: wf_induct[OF wf_option_of]) | |
| 388 | case (1 "g") | |
| 389 |   { 
 | |
| 390 | fix y | |
| 391 | assume y: "zin y (right_options g)" | |
| 392 | have "\<not> ge_game (g, y)" | |
| 393 | proof - | |
| 394 | have "(y, g) \<in> option_of" by (auto intro: y) | |
| 395 | with 1 have "ge_game (y, y)" by auto | |
| 26304 | 396 | with y show ?thesis by (subst ge_game_eq, auto) | 
| 19203 | 397 | qed | 
| 398 | } | |
| 399 | note right = this | |
| 400 |   { 
 | |
| 401 | fix y | |
| 402 | assume y: "zin y (left_options g)" | |
| 403 | have "\<not> ge_game (y, g)" | |
| 404 | proof - | |
| 405 | have "(y, g) \<in> option_of" by (auto intro: y) | |
| 406 | with 1 have "ge_game (y, y)" by auto | |
| 26304 | 407 | with y show ?thesis by (subst ge_game_eq, auto) | 
| 19203 | 408 | qed | 
| 409 | } | |
| 410 | note left = this | |
| 411 | from left right show ?case | |
| 26304 | 412 | by (auto, subst ge_game_eq, auto) | 
| 19203 | 413 | qed | 
| 414 | ||
| 415 | lemma ge_game_refl: "ge_game (x,x)" by (simp add: ge_game_leftright_refl) | |
| 416 | ||
| 417 | lemma "\<forall> y. (zin y (right_options x) \<longrightarrow> \<not> ge_game (x, y)) \<and> (zin y (left_options x) \<longrightarrow> \<not> (ge_game (y, x))) \<and> ge_game (x, x)" | |
| 418 | proof (induct x rule: wf_induct[OF wf_option_of]) | |
| 419 | case (1 "g") | |
| 420 | show ?case | |
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
60585diff
changeset | 421 | proof (auto, goal_cases) | 
| 60580 | 422 |     {case prems: (1 y) 
 | 
| 423 | from prems have "(y, g) \<in> option_of" by (auto) | |
| 19203 | 424 | with 1 have "ge_game (y, y)" by auto | 
| 60580 | 425 | with prems have "\<not> ge_game (g, y)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 426 | by (subst ge_game_eq, auto) | 
| 60580 | 427 | with prems show ?case by auto} | 
| 19203 | 428 | note right = this | 
| 60580 | 429 |     {case prems: (2 y)
 | 
| 430 | from prems have "(y, g) \<in> option_of" by (auto) | |
| 19203 | 431 | with 1 have "ge_game (y, y)" by auto | 
| 60580 | 432 | with prems have "\<not> ge_game (y, g)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 433 | by (subst ge_game_eq, auto) | 
| 60580 | 434 | with prems show ?case by auto} | 
| 19203 | 435 | note left = this | 
| 60580 | 436 |     {case 3
 | 
| 19203 | 437 | from left right show ?case | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 438 | by (subst ge_game_eq, auto) | 
| 19203 | 439 | } | 
| 440 | qed | |
| 441 | qed | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 442 | |
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 443 | definition eq_game :: "game \<Rightarrow> game \<Rightarrow> bool" where | 
| 19203 | 444 | "eq_game G H \<equiv> ge_game (G, H) \<and> ge_game (H, G)" | 
| 445 | ||
| 446 | lemma eq_game_sym: "(eq_game G H) = (eq_game H G)" | |
| 447 | by (auto simp add: eq_game_def) | |
| 448 | ||
| 449 | lemma eq_game_refl: "eq_game G G" | |
| 450 | by (simp add: ge_game_refl eq_game_def) | |
| 451 | ||
| 23771 | 452 | lemma induct_game: "(\<And>x. \<forall>y. (y, x) \<in> lprod option_of \<longrightarrow> P y \<Longrightarrow> P x) \<Longrightarrow> P a" | 
| 453 | by (erule wf_induct[OF wf_lprod[OF wf_option_of]]) | |
| 19203 | 454 | |
| 455 | lemma ge_game_trans: | |
| 456 | assumes "ge_game (x, y)" "ge_game (y, z)" | |
| 457 | shows "ge_game (x, z)" | |
| 458 | proof - | |
| 459 |   { 
 | |
| 460 | fix a | |
| 461 | have "\<forall> x y z. a = [x,y,z] \<longrightarrow> ge_game (x,y) \<longrightarrow> ge_game (y,z) \<longrightarrow> ge_game (x, z)" | |
| 462 | proof (induct a rule: induct_game) | |
| 463 | case (1 a) | |
| 464 | show ?case | |
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
60585diff
changeset | 465 | proof ((rule allI | rule impI)+, goal_cases) | 
| 60580 | 466 | case prems: (1 x y z) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 467 | show ?case | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 468 | proof - | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 469 |           { fix xr
 | 
| 19203 | 470 | assume xr:"zin xr (right_options x)" | 
| 41528 | 471 | assume a: "ge_game (z, xr)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 472 | have "ge_game (y, xr)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 473 | apply (rule 1[rule_format, where y="[y,z,xr]"]) | 
| 60580 | 474 | apply (auto intro: xr lprod_3_1 simp add: prems a) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 475 | done | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 476 | moreover from xr have "\<not> ge_game (y, xr)" | 
| 60580 | 477 | by (simp add: prems(2)[simplified ge_game_eq[of x y], rule_format, of xr, simplified xr]) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 478 | ultimately have "False" by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 479 | } | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 480 | note xr = this | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 481 |           { fix zl
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 482 | assume zl:"zin zl (left_options z)" | 
| 41528 | 483 | assume a: "ge_game (zl, x)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 484 | have "ge_game (zl, y)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 485 | apply (rule 1[rule_format, where y="[zl,x,y]"]) | 
| 60580 | 486 | apply (auto intro: zl lprod_3_2 simp add: prems a) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 487 | done | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 488 | moreover from zl have "\<not> ge_game (zl, y)" | 
| 60580 | 489 | by (simp add: prems(3)[simplified ge_game_eq[of y z], rule_format, of zl, simplified zl]) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 490 | ultimately have "False" by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 491 | } | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 492 | note zl = this | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 493 | show ?thesis | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 494 | by (auto simp add: ge_game_eq[of x z] intro: xr zl) | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 495 | qed | 
| 19203 | 496 | qed | 
| 497 | qed | |
| 498 | } | |
| 499 | note trans = this[of "[x, y, z]", simplified, rule_format] | |
| 41528 | 500 | with assms show ?thesis by blast | 
| 19203 | 501 | qed | 
| 502 | ||
| 503 | lemma eq_game_trans: "eq_game a b \<Longrightarrow> eq_game b c \<Longrightarrow> eq_game a c" | |
| 504 | by (auto simp add: eq_game_def intro: ge_game_trans) | |
| 505 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 506 | definition zero_game :: game | 
| 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 507 | where "zero_game \<equiv> Game zempty zempty" | 
| 19203 | 508 | |
| 35440 | 509 | function | 
| 510 | plus_game :: "game \<Rightarrow> game \<Rightarrow> game" | |
| 511 | where | |
| 512 | [simp del]: "plus_game G H = Game (zunion (zimage (\<lambda> g. plus_game g H) (left_options G)) | |
| 513 | (zimage (\<lambda> h. plus_game G h) (left_options H))) | |
| 514 | (zunion (zimage (\<lambda> g. plus_game g H) (right_options G)) | |
| 515 | (zimage (\<lambda> h. plus_game G h) (right_options H)))" | |
| 516 | by auto | |
| 517 | termination by (relation "gprod_2_2 option_of") | |
| 518 | (simp, auto simp: gprod_2_2_def) | |
| 19203 | 519 | |
| 35440 | 520 | lemma plus_game_comm: "plus_game G H = plus_game H G" | 
| 19203 | 521 | proof (induct G H rule: plus_game.induct) | 
| 522 | case (1 G H) | |
| 523 | show ?case | |
| 524 | by (auto simp add: | |
| 525 | plus_game.simps[where G=G and H=H] | |
| 526 | plus_game.simps[where G=H and H=G] | |
| 41528 | 527 | Game_ext zet_ext_eq zunion zimage_iff 1) | 
| 19203 | 528 | qed | 
| 529 | ||
| 530 | lemma game_ext_eq: "(G = H) = (left_options G = left_options H \<and> right_options G = right_options H)" | |
| 531 | proof - | |
| 532 | have "(G = H) = (Game (left_options G) (right_options G) = Game (left_options H) (right_options H))" | |
| 533 | by (simp add: game_split[symmetric]) | |
| 534 | then show ?thesis by auto | |
| 535 | qed | |
| 536 | ||
| 537 | lemma left_zero_game[simp]: "left_options (zero_game) = zempty" | |
| 538 | by (simp add: zero_game_def) | |
| 539 | ||
| 540 | lemma right_zero_game[simp]: "right_options (zero_game) = zempty" | |
| 541 | by (simp add: zero_game_def) | |
| 542 | ||
| 35440 | 543 | lemma plus_game_zero_right[simp]: "plus_game G zero_game = G" | 
| 19203 | 544 | proof - | 
| 60580 | 545 | have "H = zero_game \<longrightarrow> plus_game G H = G " for G H | 
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
60585diff
changeset | 546 | proof (induct G H rule: plus_game.induct, rule impI, goal_cases) | 
| 60580 | 547 | case prems: (1 G H) | 
| 548 | note induct_hyp = this[simplified prems, simplified] and this | |
| 549 | show ?case | |
| 550 | apply (simp only: plus_game.simps[where G=G and H=H]) | |
| 551 | apply (simp add: game_ext_eq prems) | |
| 552 | apply (auto simp add: | |
| 553 | zimage_cong [where f = "\<lambda> g. plus_game g zero_game" and g = "id"] | |
| 554 | induct_hyp) | |
| 555 | done | |
| 556 | qed | |
| 19203 | 557 | then show ?thesis by auto | 
| 558 | qed | |
| 559 | ||
| 35440 | 560 | lemma plus_game_zero_left: "plus_game zero_game G = G" | 
| 19203 | 561 | by (simp add: plus_game_comm) | 
| 562 | ||
| 563 | lemma left_imp_options[simp]: "zin opt (left_options g) \<Longrightarrow> zin opt (options g)" | |
| 564 | by (simp add: options_def zunion) | |
| 565 | ||
| 566 | lemma right_imp_options[simp]: "zin opt (right_options g) \<Longrightarrow> zin opt (options g)" | |
| 567 | by (simp add: options_def zunion) | |
| 568 | ||
| 569 | lemma left_options_plus: | |
| 35440 | 570 | "left_options (plus_game u v) = zunion (zimage (\<lambda>g. plus_game g v) (left_options u)) (zimage (\<lambda>h. plus_game u h) (left_options v))" | 
| 19203 | 571 | by (subst plus_game.simps, simp) | 
| 572 | ||
| 573 | lemma right_options_plus: | |
| 35440 | 574 | "right_options (plus_game u v) = zunion (zimage (\<lambda>g. plus_game g v) (right_options u)) (zimage (\<lambda>h. plus_game u h) (right_options v))" | 
| 19203 | 575 | by (subst plus_game.simps, simp) | 
| 576 | ||
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 577 | lemma left_options_neg: "left_options (neg_game u) = zimage neg_game (right_options u)" | 
| 19203 | 578 | by (subst neg_game.simps, simp) | 
| 579 | ||
| 580 | lemma right_options_neg: "right_options (neg_game u) = zimage neg_game (left_options u)" | |
| 581 | by (subst neg_game.simps, simp) | |
| 582 | ||
| 35440 | 583 | lemma plus_game_assoc: "plus_game (plus_game F G) H = plus_game F (plus_game G H)" | 
| 19203 | 584 | proof - | 
| 60580 | 585 | have "\<forall>F G H. a = [F, G, H] \<longrightarrow> plus_game (plus_game F G) H = plus_game F (plus_game G H)" for a | 
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
60585diff
changeset | 586 | proof (induct a rule: induct_game, (rule impI | rule allI)+, goal_cases) | 
| 60580 | 587 | case prems: (1 x F G H) | 
| 588 | let ?L = "plus_game (plus_game F G) H" | |
| 589 | let ?R = "plus_game F (plus_game G H)" | |
| 590 | note options_plus = left_options_plus right_options_plus | |
| 591 |     {
 | |
| 592 | fix opt | |
| 593 | note hyp = prems(1)[simplified prems(2), rule_format] | |
| 594 | have F: "zin opt (options F) \<Longrightarrow> plus_game (plus_game opt G) H = plus_game opt (plus_game G H)" | |
| 595 | by (blast intro: hyp lprod_3_3) | |
| 596 | have G: "zin opt (options G) \<Longrightarrow> plus_game (plus_game F opt) H = plus_game F (plus_game opt H)" | |
| 597 | by (blast intro: hyp lprod_3_4) | |
| 598 | have H: "zin opt (options H) \<Longrightarrow> plus_game (plus_game F G) opt = plus_game F (plus_game G opt)" | |
| 599 | by (blast intro: hyp lprod_3_5) | |
| 600 | note F and G and H | |
| 601 | } | |
| 602 | note induct_hyp = this | |
| 603 | have "left_options ?L = left_options ?R \<and> right_options ?L = right_options ?R" | |
| 604 | by (auto simp add: | |
| 605 | plus_game.simps[where G="plus_game F G" and H=H] | |
| 606 | plus_game.simps[where G="F" and H="plus_game G H"] | |
| 607 | zet_ext_eq zunion zimage_iff options_plus | |
| 608 | induct_hyp left_imp_options right_imp_options) | |
| 609 | then show ?case | |
| 610 | by (simp add: game_ext_eq) | |
| 611 | qed | |
| 19203 | 612 | then show ?thesis by auto | 
| 613 | qed | |
| 614 | ||
| 35440 | 615 | lemma neg_plus_game: "neg_game (plus_game G H) = plus_game (neg_game G) (neg_game H)" | 
| 19203 | 616 | proof (induct G H rule: plus_game.induct) | 
| 617 | case (1 G H) | |
| 618 | note opt_ops = | |
| 619 | left_options_plus right_options_plus | |
| 620 | left_options_neg right_options_neg | |
| 621 | show ?case | |
| 622 | by (auto simp add: opt_ops | |
| 35440 | 623 | neg_game.simps[of "plus_game G H"] | 
| 19203 | 624 | plus_game.simps[of "neg_game G" "neg_game H"] | 
| 41528 | 625 | Game_ext zet_ext_eq zunion zimage_iff 1) | 
| 19203 | 626 | qed | 
| 627 | ||
| 35440 | 628 | lemma eq_game_plus_inverse: "eq_game (plus_game x (neg_game x)) zero_game" | 
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
60585diff
changeset | 629 | proof (induct x rule: wf_induct[OF wf_option_of], goal_cases) | 
| 60580 | 630 | case prems: (1 x) | 
| 631 | then have ihyp: "eq_game (plus_game y (neg_game y)) zero_game" if "zin y (options x)" for y | |
| 632 | using that by (auto simp add: prems) | |
| 633 | have case1: "\<not> (ge_game (zero_game, plus_game y (neg_game x)))" | |
| 634 | if y: "zin y (right_options x)" for y | |
| 635 | apply (subst ge_game.simps, simp) | |
| 636 | apply (rule exI[where x="plus_game y (neg_game y)"]) | |
| 637 | apply (auto simp add: ihyp[of y, simplified y right_imp_options eq_game_def]) | |
| 638 | apply (auto simp add: left_options_plus left_options_neg zunion zimage_iff intro: y) | |
| 639 | done | |
| 640 | have case2: "\<not> (ge_game (zero_game, plus_game x (neg_game y)))" | |
| 641 | if y: "zin y (left_options x)" for y | |
| 642 | apply (subst ge_game.simps, simp) | |
| 643 | apply (rule exI[where x="plus_game y (neg_game y)"]) | |
| 644 | apply (auto simp add: ihyp[of y, simplified y left_imp_options eq_game_def]) | |
| 645 | apply (auto simp add: left_options_plus zunion zimage_iff intro: y) | |
| 646 | done | |
| 647 | have case3: "\<not> (ge_game (plus_game y (neg_game x), zero_game))" | |
| 648 | if y: "zin y (left_options x)" for y | |
| 649 | apply (subst ge_game.simps, simp) | |
| 650 | apply (rule exI[where x="plus_game y (neg_game y)"]) | |
| 651 | apply (auto simp add: ihyp[of y, simplified y left_imp_options eq_game_def]) | |
| 652 | apply (auto simp add: right_options_plus right_options_neg zunion zimage_iff intro: y) | |
| 653 | done | |
| 654 | have case4: "\<not> (ge_game (plus_game x (neg_game y), zero_game))" | |
| 655 | if y: "zin y (right_options x)" for y | |
| 656 | apply (subst ge_game.simps, simp) | |
| 657 | apply (rule exI[where x="plus_game y (neg_game y)"]) | |
| 658 | apply (auto simp add: ihyp[of y, simplified y right_imp_options eq_game_def]) | |
| 659 | apply (auto simp add: right_options_plus zunion zimage_iff intro: y) | |
| 660 | done | |
| 19203 | 661 | show ?case | 
| 662 | apply (simp add: eq_game_def) | |
| 35440 | 663 | apply (simp add: ge_game.simps[of "plus_game x (neg_game x)" "zero_game"]) | 
| 664 | apply (simp add: ge_game.simps[of "zero_game" "plus_game x (neg_game x)"]) | |
| 19203 | 665 | apply (simp add: right_options_plus left_options_plus right_options_neg left_options_neg zunion zimage_iff) | 
| 666 | apply (auto simp add: case1 case2 case3 case4) | |
| 667 | done | |
| 668 | qed | |
| 669 | ||
| 35440 | 670 | lemma ge_plus_game_left: "ge_game (y,z) = ge_game (plus_game x y, plus_game x z)" | 
| 19203 | 671 | proof - | 
| 60580 | 672 | have "\<forall>x y z. a = [x,y,z] \<longrightarrow> ge_game (y,z) = ge_game (plus_game x y, plus_game x z)" for a | 
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
60585diff
changeset | 673 | proof (induct a rule: induct_game, (rule impI | rule allI)+, goal_cases) | 
| 60580 | 674 | case prems: (1 a x y z) | 
| 675 | note induct_hyp = prems(1)[rule_format, simplified prems(2)] | |
| 676 |     { 
 | |
| 677 | assume hyp: "ge_game(plus_game x y, plus_game x z)" | |
| 678 | have "ge_game (y, z)" | |
| 679 | proof - | |
| 680 |         { fix yr
 | |
| 681 | assume yr: "zin yr (right_options y)" | |
| 682 | from hyp have "\<not> (ge_game (plus_game x z, plus_game x yr))" | |
| 683 | by (auto simp add: ge_game_eq[of "plus_game x y" "plus_game x z"] | |
| 684 | right_options_plus zunion zimage_iff intro: yr) | |
| 685 | then have "\<not> (ge_game (z, yr))" | |
| 686 | apply (subst induct_hyp[where y="[x, z, yr]", of "x" "z" "yr"]) | |
| 687 | apply (simp_all add: yr lprod_3_6) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 688 | done | 
| 60580 | 689 | } | 
| 690 | note yr = this | |
| 691 |         { fix zl
 | |
| 692 | assume zl: "zin zl (left_options z)" | |
| 693 | from hyp have "\<not> (ge_game (plus_game x zl, plus_game x y))" | |
| 694 | by (auto simp add: ge_game_eq[of "plus_game x y" "plus_game x z"] | |
| 695 | left_options_plus zunion zimage_iff intro: zl) | |
| 696 | then have "\<not> (ge_game (zl, y))" | |
| 697 | apply (subst prems(1)[rule_format, where y="[x, zl, y]", of "x" "zl" "y"]) | |
| 698 | apply (simp_all add: prems(2) zl lprod_3_7) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 699 | done | 
| 60580 | 700 | } | 
| 701 | note zl = this | |
| 702 | show "ge_game (y, z)" | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 703 | apply (subst ge_game_eq) | 
| 60580 | 704 | apply (auto simp add: yr zl) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30198diff
changeset | 705 | done | 
| 60580 | 706 | qed | 
| 707 | } | |
| 708 | note right_imp_left = this | |
| 709 |     {
 | |
| 710 | assume yz: "ge_game (y, z)" | |
| 711 |       {
 | |
| 712 | fix x' | |
| 713 | assume x': "zin x' (right_options x)" | |
| 714 | assume hyp: "ge_game (plus_game x z, plus_game x' y)" | |
| 715 | then have n: "\<not> (ge_game (plus_game x' y, plus_game x' z))" | |
| 716 | by (auto simp add: ge_game_eq[of "plus_game x z" "plus_game x' y"] | |
| 717 | right_options_plus zunion zimage_iff intro: x') | |
| 718 | have t: "ge_game (plus_game x' y, plus_game x' z)" | |
| 719 | apply (subst induct_hyp[symmetric]) | |
| 720 | apply (auto intro: lprod_3_3 x' yz) | |
| 721 | done | |
| 722 | from n t have "False" by blast | |
| 723 | } | |
| 724 | note case1 = this | |
| 725 |       {
 | |
| 726 | fix x' | |
| 727 | assume x': "zin x' (left_options x)" | |
| 728 | assume hyp: "ge_game (plus_game x' z, plus_game x y)" | |
| 729 | then have n: "\<not> (ge_game (plus_game x' y, plus_game x' z))" | |
| 730 | by (auto simp add: ge_game_eq[of "plus_game x' z" "plus_game x y"] | |
| 731 | left_options_plus zunion zimage_iff intro: x') | |
| 732 | have t: "ge_game (plus_game x' y, plus_game x' z)" | |
| 733 | apply (subst induct_hyp[symmetric]) | |
| 734 | apply (auto intro: lprod_3_3 x' yz) | |
| 735 | done | |
| 736 | from n t have "False" by blast | |
| 19203 | 737 | } | 
| 60580 | 738 | note case3 = this | 
| 739 |       {
 | |
| 740 | fix y' | |
| 741 | assume y': "zin y' (right_options y)" | |
| 742 | assume hyp: "ge_game (plus_game x z, plus_game x y')" | |
| 743 | then have "ge_game(z, y')" | |
| 744 | apply (subst induct_hyp[of "[x, z, y']" "x" "z" "y'"]) | |
| 745 | apply (auto simp add: hyp lprod_3_6 y') | |
| 746 | done | |
| 747 | with yz have "ge_game (y, y')" | |
| 748 | by (blast intro: ge_game_trans) | |
| 749 | with y' have "False" by (auto simp add: ge_game_leftright_refl) | |
| 750 | } | |
| 751 | note case2 = this | |
| 752 |       {
 | |
| 753 | fix z' | |
| 754 | assume z': "zin z' (left_options z)" | |
| 755 | assume hyp: "ge_game (plus_game x z', plus_game x y)" | |
| 756 | then have "ge_game(z', y)" | |
| 757 | apply (subst induct_hyp[of "[x, z', y]" "x" "z'" "y"]) | |
| 758 | apply (auto simp add: hyp lprod_3_7 z') | |
| 759 | done | |
| 760 | with yz have "ge_game (z', z)" | |
| 761 | by (blast intro: ge_game_trans) | |
| 762 | with z' have "False" by (auto simp add: ge_game_leftright_refl) | |
| 763 | } | |
| 764 | note case4 = this | |
| 765 | have "ge_game(plus_game x y, plus_game x z)" | |
| 766 | apply (subst ge_game_eq) | |
| 767 | apply (auto simp add: right_options_plus left_options_plus zunion zimage_iff) | |
| 768 | apply (auto intro: case1 case2 case3 case4) | |
| 769 | done | |
| 770 | } | |
| 771 | note left_imp_right = this | |
| 772 | show ?case by (auto intro: right_imp_left left_imp_right) | |
| 773 | qed | |
| 774 | from this[of "[x, y, z]"] show ?thesis by blast | |
| 19203 | 775 | qed | 
| 776 | ||
| 35440 | 777 | lemma ge_plus_game_right: "ge_game (y,z) = ge_game(plus_game y x, plus_game z x)" | 
| 19203 | 778 | by (simp add: ge_plus_game_left plus_game_comm) | 
| 779 | ||
| 780 | lemma ge_neg_game: "ge_game (neg_game x, neg_game y) = ge_game (y, x)" | |
| 781 | proof - | |
| 60580 | 782 | have "\<forall>x y. a = [x, y] \<longrightarrow> ge_game (neg_game x, neg_game y) = ge_game (y, x)" for a | 
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
60585diff
changeset | 783 | proof (induct a rule: induct_game, (rule impI | rule allI)+, goal_cases) | 
| 60580 | 784 | case prems: (1 a x y) | 
| 785 | note ihyp = prems(1)[rule_format, simplified prems(2)] | |
| 786 |     { fix xl
 | |
| 787 | assume xl: "zin xl (left_options x)" | |
| 788 | have "ge_game (neg_game y, neg_game xl) = ge_game (xl, y)" | |
| 789 | apply (subst ihyp) | |
| 790 | apply (auto simp add: lprod_2_1 xl) | |
| 791 | done | |
| 792 | } | |
| 793 | note xl = this | |
| 794 |     { fix yr
 | |
| 795 | assume yr: "zin yr (right_options y)" | |
| 796 | have "ge_game (neg_game yr, neg_game x) = ge_game (x, yr)" | |
| 797 | apply (subst ihyp) | |
| 798 | apply (auto simp add: lprod_2_2 yr) | |
| 799 | done | |
| 800 | } | |
| 801 | note yr = this | |
| 802 | show ?case | |
| 803 | by (auto simp add: ge_game_eq[of "neg_game x" "neg_game y"] ge_game_eq[of "y" "x"] | |
| 804 | right_options_neg left_options_neg zimage_iff xl yr) | |
| 805 | qed | |
| 806 | from this[of "[x,y]"] show ?thesis by blast | |
| 19203 | 807 | qed | 
| 808 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
35028diff
changeset | 809 | definition eq_game_rel :: "(game * game) set" where | 
| 19203 | 810 |   "eq_game_rel \<equiv> { (p, q) . eq_game p q }"
 | 
| 811 | ||
| 45694 
4a8743618257
prefer typedef without extra definition and alternative name;
 wenzelm parents: 
44011diff
changeset | 812 | definition "Pg = UNIV//eq_game_rel" | 
| 
4a8743618257
prefer typedef without extra definition and alternative name;
 wenzelm parents: 
44011diff
changeset | 813 | |
| 49834 | 814 | typedef Pg = Pg | 
| 45694 
4a8743618257
prefer typedef without extra definition and alternative name;
 wenzelm parents: 
44011diff
changeset | 815 | unfolding Pg_def by (auto simp add: quotient_def) | 
| 19203 | 816 | |
| 817 | lemma equiv_eq_game[simp]: "equiv UNIV eq_game_rel" | |
| 30198 | 818 | by (auto simp add: equiv_def refl_on_def sym_def trans_def eq_game_rel_def | 
| 19203 | 819 | eq_game_sym intro: eq_game_refl eq_game_trans) | 
| 820 | ||
| 25764 | 821 | instantiation Pg :: "{ord, zero, plus, minus, uminus}"
 | 
| 822 | begin | |
| 823 | ||
| 824 | definition | |
| 825 |   Pg_zero_def: "0 = Abs_Pg (eq_game_rel `` {zero_game})"
 | |
| 826 | ||
| 827 | definition | |
| 828 | Pg_le_def: "G \<le> H \<longleftrightarrow> (\<exists> g h. g \<in> Rep_Pg G \<and> h \<in> Rep_Pg H \<and> ge_game (h, g))" | |
| 829 | ||
| 830 | definition | |
| 831 | Pg_less_def: "G < H \<longleftrightarrow> G \<le> H \<and> G \<noteq> (H::Pg)" | |
| 19203 | 832 | |
| 25764 | 833 | definition | 
| 60585 | 834 |   Pg_minus_def: "- G = the_elem (\<Union>g \<in> Rep_Pg G. {Abs_Pg (eq_game_rel `` {neg_game g})})"
 | 
| 25764 | 835 | |
| 836 | definition | |
| 60585 | 837 |   Pg_plus_def: "G + H = the_elem (\<Union>g \<in> Rep_Pg G. \<Union>h \<in> Rep_Pg H. {Abs_Pg (eq_game_rel `` {plus_game g h})})"
 | 
| 25764 | 838 | |
| 839 | definition | |
| 840 | Pg_diff_def: "G - H = G + (- (H::Pg))" | |
| 841 | ||
| 842 | instance .. | |
| 843 | ||
| 844 | end | |
| 19203 | 845 | |
| 846 | lemma Rep_Abs_eq_Pg[simp]: "Rep_Pg (Abs_Pg (eq_game_rel `` {g})) = eq_game_rel `` {g}"
 | |
| 847 | apply (subst Abs_Pg_inverse) | |
| 848 | apply (auto simp add: Pg_def quotient_def) | |
| 849 | done | |
| 850 | ||
| 851 | lemma char_Pg_le[simp]: "(Abs_Pg (eq_game_rel `` {g}) \<le> Abs_Pg (eq_game_rel `` {h})) = (ge_game (h, g))"
 | |
| 852 | apply (simp add: Pg_le_def) | |
| 853 | apply (auto simp add: eq_game_rel_def eq_game_def intro: ge_game_trans ge_game_refl) | |
| 854 | done | |
| 855 | ||
| 856 | lemma char_Pg_eq[simp]: "(Abs_Pg (eq_game_rel `` {g}) = Abs_Pg (eq_game_rel `` {h})) = (eq_game g h)"
 | |
| 857 | apply (simp add: Rep_Pg_inject [symmetric]) | |
| 858 | apply (subst eq_equiv_class_iff[of UNIV]) | |
| 859 | apply (simp_all) | |
| 860 | apply (simp add: eq_game_rel_def) | |
| 861 | done | |
| 862 | ||
| 35440 | 863 | lemma char_Pg_plus[simp]: "Abs_Pg (eq_game_rel `` {g}) + Abs_Pg (eq_game_rel `` {h}) = Abs_Pg (eq_game_rel `` {plus_game g h})"
 | 
| 19203 | 864 | proof - | 
| 35440 | 865 |   have "(\<lambda> g h. {Abs_Pg (eq_game_rel `` {plus_game g h})}) respects2 eq_game_rel" 
 | 
| 19203 | 866 | apply (simp add: congruent2_def) | 
| 867 | apply (auto simp add: eq_game_rel_def eq_game_def) | |
| 40824 | 868 | apply (rule_tac y="plus_game a ba" in ge_game_trans) | 
| 19203 | 869 | apply (simp add: ge_plus_game_left[symmetric] ge_plus_game_right[symmetric])+ | 
| 40824 | 870 | apply (rule_tac y="plus_game b aa" in ge_game_trans) | 
| 19203 | 871 | apply (simp add: ge_plus_game_left[symmetric] ge_plus_game_right[symmetric])+ | 
| 872 | done | |
| 873 | then show ?thesis | |
| 874 | by (simp add: Pg_plus_def UN_equiv_class2[OF equiv_eq_game equiv_eq_game]) | |
| 875 | qed | |
| 876 | ||
| 877 | lemma char_Pg_minus[simp]: "- Abs_Pg (eq_game_rel `` {g}) = Abs_Pg (eq_game_rel `` {neg_game g})"
 | |
| 878 | proof - | |
| 879 |   have "(\<lambda> g. {Abs_Pg (eq_game_rel `` {neg_game g})}) respects eq_game_rel"
 | |
| 880 | apply (simp add: congruent_def) | |
| 881 | apply (auto simp add: eq_game_rel_def eq_game_def ge_neg_game) | |
| 882 | done | |
| 883 | then show ?thesis | |
| 884 | by (simp add: Pg_minus_def UN_equiv_class[OF equiv_eq_game]) | |
| 885 | qed | |
| 886 | ||
| 887 | lemma eq_Abs_Pg[rule_format, cases type: Pg]: "(\<forall> g. z = Abs_Pg (eq_game_rel `` {g}) \<longrightarrow> P) \<longrightarrow> P"
 | |
| 888 | apply (cases z, simp) | |
| 889 | apply (simp add: Rep_Pg_inject[symmetric]) | |
| 890 | apply (subst Abs_Pg_inverse, simp) | |
| 891 | apply (auto simp add: Pg_def quotient_def) | |
| 892 | done | |
| 893 | ||
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
32960diff
changeset | 894 | instance Pg :: ordered_ab_group_add | 
| 19203 | 895 | proof | 
| 896 | fix a b c :: Pg | |
| 897 | show "a - b = a + (- b)" by (simp add: Pg_diff_def) | |
| 898 |   {
 | |
| 899 | assume ab: "a \<le> b" | |
| 900 | assume ba: "b \<le> a" | |
| 901 | from ab ba show "a = b" | |
| 902 | apply (cases a, cases b) | |
| 903 | apply (simp add: eq_game_def) | |
| 904 | done | |
| 905 | } | |
| 27679 | 906 | then show "(a < b) = (a \<le> b \<and> \<not> b \<le> a)" by (auto simp add: Pg_less_def) | 
| 19203 | 907 | show "a + b = b + a" | 
| 908 | apply (cases a, cases b) | |
| 909 | apply (simp add: eq_game_def plus_game_comm) | |
| 910 | done | |
| 911 | show "a + b + c = a + (b + c)" | |
| 912 | apply (cases a, cases b, cases c) | |
| 913 | apply (simp add: eq_game_def plus_game_assoc) | |
| 914 | done | |
| 915 | show "0 + a = a" | |
| 916 | apply (cases a) | |
| 917 | apply (simp add: Pg_zero_def plus_game_zero_left) | |
| 918 | done | |
| 919 | show "- a + a = 0" | |
| 920 | apply (cases a) | |
| 921 | apply (simp add: Pg_zero_def eq_game_plus_inverse plus_game_comm) | |
| 922 | done | |
| 923 | show "a \<le> a" | |
| 924 | apply (cases a) | |
| 925 | apply (simp add: ge_game_refl) | |
| 926 | done | |
| 927 |   {
 | |
| 928 | assume ab: "a \<le> b" | |
| 929 | assume bc: "b \<le> c" | |
| 930 | from ab bc show "a \<le> c" | |
| 931 | apply (cases a, cases b, cases c) | |
| 932 | apply (auto intro: ge_game_trans) | |
| 933 | done | |
| 934 | } | |
| 935 |   {
 | |
| 936 | assume ab: "a \<le> b" | |
| 937 | from ab show "c + a \<le> c + b" | |
| 938 | apply (cases a, cases b, cases c) | |
| 939 | apply (simp add: ge_plus_game_left[symmetric]) | |
| 940 | done | |
| 941 | } | |
| 942 | qed | |
| 943 | ||
| 944 | end |