author | wenzelm |
Fri, 24 Feb 2023 11:07:31 +0100 | |
changeset 77363 | cbd053fff24c |
parent 76217 | 8655344f1cf6 |
permissions | -rw-r--r-- |
35762 | 1 |
(* Title: ZF/ex/Ramsey.thy |
1478 | 2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
0 | 3 |
Copyright 1992 University of Cambridge |
4 |
||
5 |
Ramsey's Theorem (finite exponent 2 version) |
|
6 |
||
7 |
Based upon the article |
|
8 |
D Basin and M Kaufmann, |
|
9 |
The Boyer-Moore Prover and Nuprl: An Experimental Comparison. |
|
10 |
In G Huet and G Plotkin, editors, Logical Frameworks. |
|
12867 | 11 |
(CUP, 1991), pages 89-119 |
0 | 12 |
|
13 |
See also |
|
14 |
M Kaufmann, |
|
15 |
An example in NQTHM: Ramsey's Theorem |
|
16 |
Internal Note, Computational Logic, Inc., Austin, Texas 78703 |
|
17 |
Available from the author: kaufmann@cli.com |
|
12867 | 18 |
|
19 |
This function compute Ramsey numbers according to the proof given below |
|
20 |
(which, does not constrain the base case values at all. |
|
21 |
||
22 |
fun ram 0 j = 1 |
|
23 |
| ram i 0 = 1 |
|
24 |
| ram i j = ram (i-1) j + ram i (j-1) |
|
0 | 25 |
*) |
26 |
||
65449
c82e63b11b8b
clarified main ZF.thy / ZFC.thy, and avoid name clash with global HOL/Main.thy;
wenzelm
parents:
61798
diff
changeset
|
27 |
theory Ramsey imports ZF begin |
21233 | 28 |
|
29 |
definition |
|
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
30 |
Symmetric :: "i\<Rightarrow>o" where |
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
31 |
"Symmetric(E) \<equiv> (\<forall>x y. \<langle>x,y\<rangle>:E \<longrightarrow> \<langle>y,x\<rangle>:E)" |
12867 | 32 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21233
diff
changeset
|
33 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
34 |
Atleast :: "[i,i]\<Rightarrow>o" where \<comment> \<open>not really necessary: ZF defines cardinality\<close> |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
35 |
"Atleast(n,S) \<equiv> (\<exists>f. f \<in> inj(n,S))" |
12867 | 36 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21233
diff
changeset
|
37 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
38 |
Clique :: "[i,i,i]\<Rightarrow>o" where |
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
39 |
"Clique(C,V,E) \<equiv> (C \<subseteq> V) \<and> (\<forall>x \<in> C. \<forall>y \<in> C. x\<noteq>y \<longrightarrow> \<langle>x,y\<rangle> \<in> E)" |
12867 | 40 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21233
diff
changeset
|
41 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
42 |
Indept :: "[i,i,i]\<Rightarrow>o" where |
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
43 |
"Indept(I,V,E) \<equiv> (I \<subseteq> V) \<and> (\<forall>x \<in> I. \<forall>y \<in> I. x\<noteq>y \<longrightarrow> \<langle>x,y\<rangle> \<notin> E)" |
12867 | 44 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21233
diff
changeset
|
45 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
46 |
Ramsey :: "[i,i,i]\<Rightarrow>o" where |
76214 | 47 |
"Ramsey(n,i,j) \<equiv> \<forall>V E. Symmetric(E) \<and> Atleast(n,V) \<longrightarrow> |
48 |
(\<exists>C. Clique(C,V,E) \<and> Atleast(i,C)) | |
|
49 |
(\<exists>I. Indept(I,V,E) \<and> Atleast(j,I))" |
|
12867 | 50 |
|
51 |
(*** Cliques and Independent sets ***) |
|
52 |
||
53 |
lemma Clique0 [intro]: "Clique(0,V,E)" |
|
54 |
by (unfold Clique_def, blast) |
|
55 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
56 |
lemma Clique_superset: "\<lbrakk>Clique(C,V',E); V'<=V\<rbrakk> \<Longrightarrow> Clique(C,V,E)" |
12867 | 57 |
by (unfold Clique_def, blast) |
58 |
||
59 |
lemma Indept0 [intro]: "Indept(0,V,E)" |
|
60 |
by (unfold Indept_def, blast) |
|
0 | 61 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
62 |
lemma Indept_superset: "\<lbrakk>Indept(I,V',E); V'<=V\<rbrakk> \<Longrightarrow> Indept(I,V,E)" |
12867 | 63 |
by (unfold Indept_def, blast) |
64 |
||
65 |
(*** Atleast ***) |
|
66 |
||
67 |
lemma Atleast0 [intro]: "Atleast(0,A)" |
|
68 |
by (unfold Atleast_def inj_def Pi_def function_def, blast) |
|
69 |
||
70 |
lemma Atleast_succD: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
71 |
"Atleast(succ(m),A) \<Longrightarrow> \<exists>x \<in> A. Atleast(m, A-{x})" |
76216
9fc34f76b4e8
getting rid of apply (unfold ...)
paulson <lp15@cam.ac.uk>
parents:
76215
diff
changeset
|
72 |
unfolding Atleast_def |
12867 | 73 |
apply (blast dest: inj_is_fun [THEN apply_type] inj_succ_restrict) |
74 |
done |
|
0 | 75 |
|
12867 | 76 |
lemma Atleast_superset: |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
77 |
"\<lbrakk>Atleast(n,A); A \<subseteq> B\<rbrakk> \<Longrightarrow> Atleast(n,B)" |
12867 | 78 |
by (unfold Atleast_def, blast intro: inj_weaken_type) |
79 |
||
80 |
lemma Atleast_succI: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
81 |
"\<lbrakk>Atleast(m,B); b\<notin> B\<rbrakk> \<Longrightarrow> Atleast(succ(m), cons(b,B))" |
76217 | 82 |
unfolding Atleast_def succ_def |
12867 | 83 |
apply (blast intro: inj_extend elim: mem_irrefl) |
84 |
done |
|
85 |
||
86 |
lemma Atleast_Diff_succI: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
87 |
"\<lbrakk>Atleast(m, B-{x}); x \<in> B\<rbrakk> \<Longrightarrow> Atleast(succ(m), B)" |
12867 | 88 |
by (blast intro: Atleast_succI [THEN Atleast_superset]) |
89 |
||
90 |
(*** Main Cardinality Lemma ***) |
|
0 | 91 |
|
12867 | 92 |
(*The #-succ(0) strengthens the original theorem statement, but precisely |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
93 |
the same proof could be used\<And>*) |
12867 | 94 |
lemma pigeon2 [rule_format]: |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
95 |
"m \<in> nat \<Longrightarrow> |
46822
95f1e700b712
mathematical symbols for Isabelle/ZF example theories
paulson
parents:
35762
diff
changeset
|
96 |
\<forall>n \<in> nat. \<forall>A B. Atleast((m#+n) #- succ(0), A \<union> B) \<longrightarrow> |
12867 | 97 |
Atleast(m,A) | Atleast(n,B)" |
98 |
apply (induct_tac "m") |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
99 |
apply (blast intro!: Atleast0, simp) |
12867 | 100 |
apply (rule ballI) |
101 |
apply (rename_tac m' n) (*simplifier does NOT preserve bound names!*) |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
102 |
apply (induct_tac "n", auto) |
12867 | 103 |
apply (erule Atleast_succD [THEN bexE]) |
104 |
apply (rename_tac n' A B z) |
|
105 |
apply (erule UnE) |
|
106 |
(**case z \<in> B. Instantiate the '\<forall>A B' induction hypothesis. **) |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
107 |
apply (drule_tac [2] x1 = A and x = "B-{z}" in spec [THEN spec]) |
12867 | 108 |
apply (erule_tac [2] mp [THEN disjE]) |
109 |
(*cases Atleast(succ(m1),A) and Atleast(succ(k),B)*) |
|
110 |
apply (erule_tac [3] asm_rl notE Atleast_Diff_succI)+ |
|
111 |
(*proving the condition*) |
|
112 |
prefer 2 apply (blast intro: Atleast_superset) |
|
113 |
(**case z \<in> A. Instantiate the '\<forall>n \<in> nat. \<forall>A B' induction hypothesis. **) |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
114 |
apply (drule_tac x2="succ(n')" and x1="A-{z}" and x=B |
12867 | 115 |
in bspec [THEN spec, THEN spec]) |
116 |
apply (erule nat_succI) |
|
117 |
apply (erule mp [THEN disjE]) |
|
118 |
(*cases Atleast(succ(m1),A) and Atleast(succ(k),B)*) |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
119 |
apply (erule_tac [2] asm_rl Atleast_Diff_succI notE)+ |
12867 | 120 |
(*proving the condition*) |
121 |
apply simp |
|
122 |
apply (blast intro: Atleast_superset) |
|
123 |
done |
|
0 | 124 |
|
12867 | 125 |
|
126 |
(**** Ramsey's Theorem ****) |
|
127 |
||
128 |
(** Base cases of induction; they now admit ANY Ramsey number **) |
|
129 |
||
130 |
lemma Ramsey0j: "Ramsey(n,0,j)" |
|
131 |
by (unfold Ramsey_def, blast) |
|
132 |
||
133 |
lemma Ramseyi0: "Ramsey(n,i,0)" |
|
134 |
by (unfold Ramsey_def, blast) |
|
135 |
||
136 |
(** Lemmas for induction step **) |
|
0 | 137 |
|
12867 | 138 |
(*The use of succ(m) here, rather than #-succ(0), simplifies the proof of |
139 |
Ramsey_step_lemma.*) |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
140 |
lemma Atleast_partition: "\<lbrakk>Atleast(m #+ n, A); m \<in> nat; n \<in> nat\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
141 |
\<Longrightarrow> Atleast(succ(m), {x \<in> A. \<not>P(x)}) | Atleast(n, {x \<in> A. P(x)})" |
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
142 |
apply (rule nat_succI [THEN pigeon2], assumption+) |
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
143 |
apply (rule Atleast_superset, auto) |
12867 | 144 |
done |
145 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
146 |
(*For the Atleast part, proves \<not>(a \<in> I) from the second premise!*) |
12867 | 147 |
lemma Indept_succ: |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
148 |
"\<lbrakk>Indept(I, {z \<in> V-{a}. \<langle>a,z\<rangle> \<notin> E}, E); Symmetric(E); a \<in> V; |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
149 |
Atleast(j,I)\<rbrakk> \<Longrightarrow> |
76214 | 150 |
Indept(cons(a,I), V, E) \<and> Atleast(succ(j), cons(a,I))" |
76217 | 151 |
unfolding Symmetric_def Indept_def |
12867 | 152 |
apply (blast intro!: Atleast_succI) |
153 |
done |
|
154 |
||
155 |
||
156 |
lemma Clique_succ: |
|
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
157 |
"\<lbrakk>Clique(C, {z \<in> V-{a}. \<langle>a,z\<rangle>:E}, E); Symmetric(E); a \<in> V; |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
158 |
Atleast(j,C)\<rbrakk> \<Longrightarrow> |
76214 | 159 |
Clique(cons(a,C), V, E) \<and> Atleast(succ(j), cons(a,C))" |
76217 | 160 |
unfolding Symmetric_def Clique_def |
12867 | 161 |
apply (blast intro!: Atleast_succI) |
162 |
done |
|
163 |
||
164 |
(** Induction step **) |
|
0 | 165 |
|
12867 | 166 |
(*Published proofs gloss over the need for Ramsey numbers to be POSITIVE.*) |
167 |
lemma Ramsey_step_lemma: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
168 |
"\<lbrakk>Ramsey(succ(m), succ(i), j); Ramsey(n, i, succ(j)); |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
169 |
m \<in> nat; n \<in> nat\<rbrakk> \<Longrightarrow> Ramsey(succ(m#+n), succ(i), succ(j))" |
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12867
diff
changeset
|
170 |
apply (unfold Ramsey_def, clarify) |
12867 | 171 |
apply (erule Atleast_succD [THEN bexE]) |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76214
diff
changeset
|
172 |
apply (erule_tac P1 = "\<lambda>z.\<langle>x,z\<rangle>:E" in Atleast_partition [THEN disjE], |
12867 | 173 |
assumption+) |
174 |
(*case m*) |
|
175 |
apply (fast dest!: Indept_succ elim: Clique_superset) |
|
176 |
(*case n*) |
|
177 |
apply (fast dest!: Clique_succ elim: Indept_superset) |
|
178 |
done |
|
179 |
||
180 |
||
181 |
(** The actual proof **) |
|
182 |
||
183 |
(*Again, the induction requires Ramsey numbers to be positive.*) |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
184 |
lemma ramsey_lemma: "i \<in> nat \<Longrightarrow> \<forall>j \<in> nat. \<exists>n \<in> nat. Ramsey(succ(n), i, j)" |
12867 | 185 |
apply (induct_tac "i") |
186 |
apply (blast intro!: Ramsey0j) |
|
187 |
apply (rule ballI) |
|
188 |
apply (induct_tac "j") |
|
189 |
apply (blast intro!: Ramseyi0) |
|
190 |
apply (blast intro!: add_type Ramsey_step_lemma) |
|
191 |
done |
|
192 |
||
193 |
(*Final statement in a tidy form, without succ(...) *) |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
67443
diff
changeset
|
194 |
lemma ramsey: "\<lbrakk>i \<in> nat; j \<in> nat\<rbrakk> \<Longrightarrow> \<exists>n \<in> nat. Ramsey(n,i,j)" |
12867 | 195 |
by (blast dest: ramsey_lemma) |
0 | 196 |
|
197 |
end |