# HG changeset patch # User wenzelm # Date 1451129327 -3600 # Node ID 380cbe15cca5b55606467be85297a832ceb96350 # Parent b8e242e52c9717e4e24710440ca7744e7cbb9cf2 modernized example; diff -r b8e242e52c97 -r 380cbe15cca5 src/HOL/Isar_Examples/Cantor.thy --- a/src/HOL/Isar_Examples/Cantor.thy Thu Dec 24 09:42:49 2015 +0100 +++ b/src/HOL/Isar_Examples/Cantor.thy Sat Dec 26 12:28:47 2015 +0100 @@ -1,5 +1,5 @@ (* Title: HOL/Isar_Examples/Cantor.thy - Author: Markus Wenzel, TU Muenchen + Author: Makarius *) section \Cantor's Theorem\ @@ -8,12 +8,49 @@ imports Main begin -text_raw \\footnote{This is an Isar version of the final example of - the Isabelle/HOL manual @{cite "isabelle-HOL"}.}\ +text \ + Cantor's Theorem states that there is no surjection from + a set to its powerset. The proof works by diagonalization. E.g.\ see + \<^item> @{url "http://mathworld.wolfram.com/CantorDiagonalMethod.html"} + \<^item> @{url "https://en.wikipedia.org/wiki/Cantor's_diagonal_argument"} +\ + +theorem Cantor: "\ (\f :: 'a \ 'a set. \A :: 'a set. \x :: 'a. f x = A)" +proof + assume "\f :: 'a \ 'a set. \A. \x. f x = A" + then obtain f :: "'a \ 'a set" where *: "\A. \x. f x = A" .. + let ?D = "{x. x \ f x}" + from * obtain a where "f a = ?D" by blast + moreover have "a \ ?D \ a \ f a" by blast + ultimately show False by blast +qed + -text \Cantor's Theorem states that every set has more subsets than - it has elements. It has become a favourite basic example in pure - higher-order logic since it is so easily expressed: +text \ + Here are shorter proofs via automated proof tools, but without any hints why + and how it works. +\ + +theorem "\ (\f :: 'a \ 'a set. \A. \x. f x = A)" + by best + +theorem "\ (\f :: 'a \ 'a set. \A. \x. f x = A)" + by force + + +subsection \Classic Isabelle/HOL example\ + +text \ + The following treatment of Cantor's Theorem follows the classic from the + early 1990s, e.g.\ see the file @{verbatim "92/HOL/ex/set.ML"} in Isabelle92 + or @{cite \\S18.7\ "paulson-isa-book"}. The old tactic scripts synthesize + key information of the proof by refinement of schematic goal states. In + contrast, the Isar proof needs to say explicitly what is proven. + + \<^bigskip> + Cantor's Theorem states that every set has more subsets than it has + elements. It has become a favourite basic example in pure higher-order logic + since it is so easily expressed: @{text [display] \\f::\ \ \ \ bool. \S::\ \ bool. \x::\. f x \ S\} @@ -21,8 +58,9 @@ Viewing types as sets, \\ \ bool\ represents the powerset of \\\. This version of the theorem states that for every function from \\\ to its powerset, some subset is outside its range. The Isabelle/Isar proofs below - uses HOL's set theory, with the type \\ set\ and the operator - \range :: (\ \ \) \ \ set\.\ + uses HOL's set theory, with the type \\ set\ and the operator \range :: (\ \ + \) \ \ set\. +\ theorem "\S. S \ range (f :: 'a \ 'a set)" proof @@ -36,7 +74,7 @@ assume "y \ f y" assume "y \ ?S" then have "y \ f y" .. - with \y : f y\ show ?thesis by contradiction + with \y \ f y\ show ?thesis by contradiction next assume "y \ ?S" assume "y \ f y" @@ -46,19 +84,15 @@ qed qed -text \How much creativity is required? As it happens, Isabelle can prove - this theorem automatically using best-first search. Depth-first search - would diverge, but best-first search successfully navigates through the - large search space. The context of Isabelle's classical prover contains - rules for the relevant constructs of HOL's set theory.\ +text \ + How much creativity is required? As it happens, Isabelle can prove this + theorem automatically using best-first search. Depth-first search would + diverge, but best-first search successfully navigates through the large + search space. The context of Isabelle's classical prover contains rules for + the relevant constructs of HOL's set theory. +\ theorem "\S. S \ range (f :: 'a \ 'a set)" by best -text \While this establishes the same theorem internally, we do not get any - idea of how the proof actually works. There is currently no way to - transform internal system-level representations of Isabelle proofs back - into Isar text. Writing intelligible proof documents really is a creative - process, after all.\ - end diff -r b8e242e52c97 -r 380cbe15cca5 src/HOL/Isar_Examples/document/root.bib --- a/src/HOL/Isar_Examples/document/root.bib Thu Dec 24 09:42:49 2015 +0100 +++ b/src/HOL/Isar_Examples/document/root.bib Sat Dec 26 12:28:47 2015 +0100 @@ -65,6 +65,13 @@ title = {The {Isabelle} Reference Manual}, institution = CUCL} +@Book{paulson-isa-book, + author = {Lawrence C. Paulson}, + title = {Isabelle: A Generic Theorem Prover}, + publisher = {Springer}, + year = 1994, + note = {LNCS 828}} + @TechReport{paulson-mutilated-board, author = {Lawrence C. Paulson}, title = {A Simple Formalization and Proof for the Mutilated Chess Board},