src/ZF/ex/misc.thy
author paulson
Fri, 06 Jul 2001 16:04:32 +0200
changeset 11399 1605aeb98fd5
child 13339 0f89104dd377
permissions -rw-r--r--
two Isar tactic scripts
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
Miscellaneous examples for Zermelo-Fraenkel Set Theory 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     7
Composition of homomorphisms, Pastre's examples, ...
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     8
*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     9
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    10
theory misc = Main:
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    11
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    12
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    13
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    14
(*These two are cited in Benzmueller and Kohlhase's system description of LEO,
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    15
  CADE-15, 1998 (page 139-143) as theorems LEO could not prove.*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    16
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
    17
by (blast intro!: equalityI)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    18
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    19
(*the dual of the previous one*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    20
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
    21
by (blast intro!: equalityI)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    22
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    23
(*trivial example of term synthesis: apparently hard for some provers!*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    24
lemma "a \<noteq> b ==> a:?X & b \<notin> ?X"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    25
by blast
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    26
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    27
(*Nice Blast_tac benchmark.  Proved in 0.3s; old tactics can't manage it!*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    28
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
    29
by blast
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    30
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    31
(*variant of the benchmark above*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    32
lemma "\<forall>x \<in> S. Union(S) \<subseteq> x ==> \<exists>z. S \<subseteq> {z}"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    33
by blast
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    34
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    35
(*Example 12 (credited to Peter Andrews) from
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    36
 W. Bledsoe.  A Maximal Method for Set Variables in Automatic Theorem-proving.
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    37
 In: J. Hayes and D. Michie and L. Mikulich, eds.  Machine Intelligence 9.
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    38
 Ellis Horwood, 53-100 (1979). *)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    39
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
    40
by best
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    41
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    42
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    43
(*** Composition of homomorphisms is a homomorphism ***)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    44
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    45
(*Given as a challenge problem in
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    46
  R. Boyer et al.,
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    47
  Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    48
  JAR 2 (1986), 287-327 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    49
*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    50
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    51
(*collecting the relevant lemmas*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    52
declare comp_fun [simp] SigmaI [simp] apply_funtype [simp]
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    53
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    54
(*Force helps prove conditions of rewrites such as comp_fun_apply, since
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    55
  rewriting does not instantiate Vars.*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    56
lemma "(\<forall>A f B g. hom(A,f,B,g) =  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    57
           {H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    58
                     (\<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
    59
       J \<in> hom(A,f,B,g) & K \<in> hom(B,g,C,h) -->   
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    60
       (K O J) \<in> hom(A,f,C,h)"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    61
by force
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    62
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    63
(*Another version , with meta-level rewriting*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    64
lemma "(!! A f B g. hom(A,f,B,g) ==  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    65
           {H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    66
                     (\<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
    67
       ==> 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
    68
by force
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    69
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    70
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    71
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    72
(** A characterization of functions suggested by Tobias Nipkow **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    73
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    74
lemma "r \<in> domain(r)->B  <->  r \<subseteq> domain(r)*B & (\<forall>X. r `` (r -`` X) \<subseteq> X)"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    75
apply (unfold Pi_def function_def)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    76
apply best
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    77
done
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    78
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    79
(**** From D Pastre.  Automatic theorem proving in set theory. 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    80
         Artificial Intelligence, 10:1--27, 1978.
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    81
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    82
      Previously, these were done using ML code, but blast manages fine.
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    83
****)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    84
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    85
lemmas compIs [intro] = comp_surj comp_inj comp_fun [intro]
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    86
lemmas compDs [dest] =  comp_mem_injD1 comp_mem_surjD1 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    87
                        comp_mem_injD2 comp_mem_surjD2
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    88
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    89
lemma pastre1: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    90
    "[| (h O g O f) \<in> inj(A,A);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    91
        (f O h O g) \<in> surj(B,B);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    92
        (g O f O h) \<in> surj(C,C);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    93
        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
    94
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    95
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    96
lemma pastre3: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    97
    "[| (h O g O f) \<in> surj(A,A);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    98
        (f O h O g) \<in> surj(B,B);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    99
        (g O f O h) \<in> inj(C,C);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   100
        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
   101
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   102
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   103
lemma pastre4: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   104
    "[| (h O g O f) \<in> surj(A,A);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   105
        (f O h O g) \<in> inj(B,B);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   106
        (g O f O h) \<in> inj(C,C);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   107
        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
   108
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   109
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   110
lemma pastre5: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   111
    "[| (h O g O f) \<in> inj(A,A);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   112
        (f O h O g) \<in> surj(B,B);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   113
        (g O f O h) \<in> inj(C,C);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   114
        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
   115
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   116
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   117
lemma pastre6: 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   118
    "[| (h O g O f) \<in> inj(A,A);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   119
        (f O h O g) \<in> inj(B,B);           
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   120
        (g O f O h) \<in> surj(C,C);          
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   121
        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
   122
by (unfold bij_def, blast)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   123
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   124
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   125
(** Yet another example... **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   126
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   127
lemma Pow_sum_bij:
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   128
    "(\<lambda>Z \<in> Pow(A+B). <{x \<in> A. Inl(x) \<in> Z}, {y \<in> B. Inr(y) \<in> Z}>)  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   129
     \<in> bij(Pow(A+B), Pow(A)*Pow(B))"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   130
apply (rule_tac d = "%<X,Y>. {Inl (x). x \<in> X} Un {Inr (y). y \<in> Y}" 
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   131
       in lam_bijective)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   132
apply force+
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   133
done
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   134
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   135
(*As a special case, we have  bij(Pow(A*B), A -> Pow B)  *)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   136
lemma Pow_Sigma_bij:
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   137
    "(\<lambda>r \<in> Pow(Sigma(A,B)). \<lambda>x \<in> A. r``{x})  
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   138
     \<in> bij(Pow(Sigma(A,B)), \<Pi>x \<in> A. Pow(B(x)))"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   139
apply (rule_tac d = "%f. \<Union>x \<in> A. \<Union>y \<in> f`x. {<x,y>}" in lam_bijective)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   140
apply (blast intro: lam_type)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   141
apply (blast dest: apply_type)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   142
apply simp_all
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   143
apply fast (*strange, but blast can't do it*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   144
apply (rule fun_extension)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   145
apply auto
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   146
by blast
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   147
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   148
end
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
   149