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