theory LiveDemo02 imports Main begin section \Eigenvariable Condition\ lemma "\ y. y = x" proof (rule allI) fix y show "y = x" oops lemma "\ y. y = x" proof (rule allI) fix z show "z = x" (* we can choose a different name than y *) oops text \The upcoming examples just show that it is not possible to cheat. They are definitely not good style!\ lemma "\ y. y = x" proof (rule allI) fix x show "x = x" (* it is not allowed to choose x *) oops lemma "\ y. y = x" proof (rule allI) let ?blue_x = x (* let can be used to abbreviate terms within proofs *) fix x show "x = ?blue_x" (* orange x \ blue x *) using refl[of x] refl[of ?blue_x] oops lemma "\ x y. x = y" proof (rule allI) fix x :: 'a let ?orange_x = x show "\y. x = y" proof (rule allI) fix x show "?orange_x = x" (* automatic renaming *) oops section \The rule method (in introduction mode)\ lemma "x < 5 \ x < 3 \ x < 2" proof (rule conjI) oops lemma "\ y. 5 < y" proof (rule exI) show "5 < 7" oops section \Equality of Terms\ thm refl (* reflexivity of equality: t = t *) text \\-conversion is implicitly done\ lemma alpha: "(\ x. P x) = (\ y. P y)" by (rule refl) thm alpha[of "Q x"] text \\-reduction "(\ x. t) s \\ t [ x / s]" is implicitly done\ lemma beta: "(\ x. P (x + x)) y = P (y + y)" by (rule refl) text \\-expansion "f = (\ x. f x)" if f has function-type is implicitly invoked\ lemma eta: "(\ x. f x) = f" by (rule refl) section \Drinker's paradox\ find_theorems (5) "?x + ?y = ?y + ?x" lemma drinkers_paradox: "\ p. drinks p \ (\ x. drinks x)" proof - have "\ (\ p. \ drinks p) \ (\ p. \ drinks p)" by (rule excluded_middle) from this show ?thesis proof { assume "\p. \ drinks p " from this show ?thesis by auto } { assume *: "\p. \ drinks p" from * show ?thesis proof fix p assume "\ drinks p" show ?thesis proof show "drinks p \ (\x. drinks x)" proof assume "drinks p" from \\ drinks p\ this show "\x. drinks x" by (rule notE) qed qed qed } qed qed lemma drinkers_paradox_v2: "\ p. drinks p \ (\ x. drinks x)" proof - { assume "\p. \ drinks p" from this have "\ p. drinks p" by auto from this have ?thesis by auto } from this have case1: "\p. \ drinks p \ ?thesis" by auto { fix p assume "\ drinks p" have ?thesis proof (intro exI impI allI) fix x assume "drinks p" from \\ drinks p\ this show "drinks x" by (rule notE) qed } from this have case2: "\p. \ drinks p \ ?thesis" by auto from case1 case2 show ?thesis by auto qed text \Actually the drinker's paradox is so simple, that automation can do it on its own.\ lemma drinkers_paradox_v3: "\ p. drinks p \ (\ x. drinks x)" by auto end