src/ZF/ex/misc.thy
author wenzelm
Mon, 07 Dec 2015 10:23:50 +0100
changeset 61798 27f3c10b0b50
parent 61337 4645502c3c64
child 65449 c82e63b11b8b
permissions -rw-r--r--
isabelle update_cartouches -c -t;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35762
af3ff2ba4c54 removed old CVS Ids;
wenzelm
parents: 17093
diff changeset
     1
(*  Title:      ZF/ex/misc.thy
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     3
    Copyright   1993  University of Cambridge
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     4
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     5
Composition of homomorphisms, Pastre's examples, ...
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     6
*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     7
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
     8
section\<open>Miscellaneous ZF Examples\<close>
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13339
diff changeset
     9
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14120
diff changeset
    10
theory misc imports Main begin
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    11
17093
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    12
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    13
subsection\<open>Various Small Problems\<close>
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    14
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    15
text\<open>The singleton problems are much harder in HOL.\<close>
17093
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    16
lemma singleton_example_1:
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    17
     "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    18
  by blast
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    19
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    20
lemma singleton_example_2:
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    21
     "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
61798
27f3c10b0b50 isabelle update_cartouches -c -t;
wenzelm
parents: 61337
diff changeset
    22
  \<comment> \<open>Variant of the problem above.\<close>
17093
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    23
  by blast
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    24
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    25
lemma "\<exists>!x. f (g(x)) = x \<Longrightarrow> \<exists>!y. g (f(y)) = y"
61798
27f3c10b0b50 isabelle update_cartouches -c -t;
wenzelm
parents: 61337
diff changeset
    26
  \<comment> \<open>A unique fixpoint theorem --- \<open>fast\<close>/\<open>best\<close>/\<open>auto\<close> all fail.\<close> 
17093
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    27
  apply (erule ex1E, rule ex1I, erule subst_context)
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    28
  apply (rule subst, assumption, erule allE, rule subst_context, erule mp)
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    29
  apply (erule subst_context)
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    30
  done
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    31
7e3828a6ebcc new examples
paulson
parents: 16417
diff changeset
    32
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    33
text\<open>A weird property of ordered pairs.\<close>
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    34
lemma "b\<noteq>c ==> <a,b> \<inter> <a,c> = <a,a>"
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13339
diff changeset
    35
by (simp add: Pair_def Int_cons_left Int_cons_right doubleton_eq_iff, blast)
3a73850c6c7d Tidied some examples
paulson
parents: 13339
diff changeset
    36
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    37
text\<open>These two are cited in Benzmueller and Kohlhase's system description of
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    38
 LEO, CADE-15, 1998 (page 139-143) as theorems LEO could not prove.\<close>
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    39
lemma "(X = Y \<union> Z) \<longleftrightarrow> (Y \<subseteq> X & Z \<subseteq> X & (\<forall>V. Y \<subseteq> V & Z \<subseteq> V \<longrightarrow> X \<subseteq> V))"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    40
by (blast intro!: equalityI)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    41
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    42
text\<open>the dual of the previous one\<close>
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    43
lemma "(X = Y \<inter> Z) \<longleftrightarrow> (X \<subseteq> Y & X \<subseteq> Z & (\<forall>V. V \<subseteq> Y & V \<subseteq> Z \<longrightarrow> V \<subseteq> X))"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    44
by (blast intro!: equalityI)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    45
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    46
text\<open>trivial example of term synthesis: apparently hard for some provers!\<close>
61337
4645502c3c64 fewer aliases for toplevel theorem statements;
wenzelm
parents: 60770
diff changeset
    47
schematic_goal "a \<noteq> b ==> a:?X & b \<notin> ?X"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    48
by blast
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    49
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    50
text\<open>Nice blast benchmark.  Proved in 0.3s; old tactics can't manage it!\<close>
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    51
lemma "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y ==> \<exists>z. S \<subseteq> {z}"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    52
by blast
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    53
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    54
text\<open>variant of the benchmark above\<close>
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    55
lemma "\<forall>x \<in> S. \<Union>(S) \<subseteq> x ==> \<exists>z. S \<subseteq> {z}"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    56
by blast
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    57
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    58
(*Example 12 (credited to Peter Andrews) from
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    59
 W. Bledsoe.  A Maximal Method for Set Variables in Automatic Theorem-proving.
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    60
 In: J. Hayes and D. Michie and L. Mikulich, eds.  Machine Intelligence 9.
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    61
 Ellis Horwood, 53-100 (1979). *)
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    62
lemma "(\<forall>F. {x} \<in> F \<longrightarrow> {y} \<in> F) \<longrightarrow> (\<forall>A. x \<in> A \<longrightarrow> y \<in> A)"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    63
by best
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    64
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    65
text\<open>A characterization of functions suggested by Tobias Nipkow\<close>
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    66
lemma "r \<in> domain(r)->B  \<longleftrightarrow>  r \<subseteq> domain(r)*B & (\<forall>X. r `` (r -`` X) \<subseteq> X)"
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13339
diff changeset
    67
by (unfold Pi_def function_def, best)
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    68
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    69
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    70
subsection\<open>Composition of homomorphisms is a Homomorphism\<close>
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13339
diff changeset
    71
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    72
text\<open>Given as a challenge problem in
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    73
  R. Boyer et al.,
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    74
  Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    75
  JAR 2 (1986), 287-327\<close>
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    76
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    77
text\<open>collecting the relevant lemmas\<close>
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    78
declare comp_fun [simp] SigmaI [simp] apply_funtype [simp]
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    79
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    80
(*Force helps prove conditions of rewrites such as comp_fun_apply, since
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    81
  rewriting does not instantiate Vars.*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    82
lemma "(\<forall>A f B g. hom(A,f,B,g) =  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    83
           {H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &  
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    84
                     (\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)}) \<longrightarrow>  
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    85
       J \<in> hom(A,f,B,g) & K \<in> hom(B,g,C,h) \<longrightarrow>   
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    86
       (K O J) \<in> hom(A,f,C,h)"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    87
by force
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    88
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    89
text\<open>Another version, with meta-level rewriting\<close>
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    90
lemma "(!! A f B g. hom(A,f,B,g) ==  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    91
           {H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    92
                     (\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)}) 
46822
95f1e700b712 mathematical symbols for Isabelle/ZF example theories
paulson
parents: 39991
diff changeset
    93
       ==> J \<in> hom(A,f,B,g) & K \<in> hom(B,g,C,h) \<longrightarrow> (K O J) \<in> hom(A,f,C,h)"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    94
by force
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    95
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    96
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    97
subsection\<open>Pastre's Examples\<close>
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    98
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
    99
text\<open>D Pastre.  Automatic theorem proving in set theory. 
14120
3a73850c6c7d Tidied some examples
paulson
parents: 13339
diff changeset
   100
        Artificial Intelligence, 10:1--27, 1978.
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58871
diff changeset
   101
Previously, these were done using ML code, but blast manages fine.\<close>
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   102
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   103
lemmas compIs [intro] = comp_surj comp_inj comp_fun [intro]
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   104
lemmas compDs [dest] =  comp_mem_injD1 comp_mem_surjD1 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   105
                        comp_mem_injD2 comp_mem_surjD2
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   106
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   107
lemma pastre1: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   108
    "[| (h O g O f) \<in> inj(A,A);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   109
        (f O h O g) \<in> surj(B,B);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   110
        (g O f O h) \<in> surj(C,C);          
39991
8a2c75478357 reactivated
krauss
parents: 35762
diff changeset
   111
        f \<in> A->B;  g \<in> B->C;  h \<in> C->A |] ==> h \<in> bij(C,A)"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   112
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   113
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   114
lemma pastre3: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   115
    "[| (h O g O f) \<in> surj(A,A);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   116
        (f O h O g) \<in> surj(B,B);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   117
        (g O f O h) \<in> inj(C,C);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   118
        f \<in> A->B;  g \<in> B->C;  h \<in> C->A |] ==> h \<in> bij(C,A)"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   119
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   120
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   121
lemma pastre4: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   122
    "[| (h O g O f) \<in> surj(A,A);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   123
        (f O h O g) \<in> inj(B,B);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   124
        (g O f O h) \<in> inj(C,C);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   125
        f \<in> A->B;  g \<in> B->C;  h \<in> C->A |] ==> h \<in> bij(C,A)"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   126
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   127
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   128
lemma pastre5: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   129
    "[| (h O g O f) \<in> inj(A,A);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   130
        (f O h O g) \<in> surj(B,B);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   131
        (g O f O h) \<in> inj(C,C);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   132
        f \<in> A->B;  g \<in> B->C;  h \<in> C->A |] ==> h \<in> bij(C,A)"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   133
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   134
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   135
lemma pastre6: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   136
    "[| (h O g O f) \<in> inj(A,A);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   137
        (f O h O g) \<in> inj(B,B);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   138
        (g O f O h) \<in> surj(C,C);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   139
        f \<in> A->B;  g \<in> B->C;  h \<in> C->A |] ==> h \<in> bij(C,A)"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   140
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   141
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   142
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   143
end
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   144