src/ZF/ex/misc.thy
changeset 60770 240563fbf41d
parent 58871 c399ae4b836f
child 61337 4645502c3c64
equal deleted inserted replaced
60769:cf7f3465eaf1 60770:240563fbf41d
     3     Copyright   1993  University of Cambridge
     3     Copyright   1993  University of Cambridge
     4 
     4 
     5 Composition of homomorphisms, Pastre's examples, ...
     5 Composition of homomorphisms, Pastre's examples, ...
     6 *)
     6 *)
     7 
     7 
     8 section{*Miscellaneous ZF Examples*}
     8 section\<open>Miscellaneous ZF Examples\<close>
     9 
     9 
    10 theory misc imports Main begin
    10 theory misc imports Main begin
    11 
    11 
    12 
    12 
    13 subsection{*Various Small Problems*}
    13 subsection\<open>Various Small Problems\<close>
    14 
    14 
    15 text{*The singleton problems are much harder in HOL.*}
    15 text\<open>The singleton problems are much harder in HOL.\<close>
    16 lemma singleton_example_1:
    16 lemma singleton_example_1:
    17      "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
    17      "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
    18   by blast
    18   by blast
    19 
    19 
    20 lemma singleton_example_2:
    20 lemma singleton_example_2:
    21      "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
    21      "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
    22   -- {*Variant of the problem above. *}
    22   -- \<open>Variant of the problem above.\<close>
    23   by blast
    23   by blast
    24 
    24 
    25 lemma "\<exists>!x. f (g(x)) = x \<Longrightarrow> \<exists>!y. g (f(y)) = y"
    25 lemma "\<exists>!x. f (g(x)) = x \<Longrightarrow> \<exists>!y. g (f(y)) = y"
    26   -- {* A unique fixpoint theorem --- @{text fast}/@{text best}/@{text auto} all fail. *} 
    26   -- \<open>A unique fixpoint theorem --- @{text fast}/@{text best}/@{text auto} all fail.\<close> 
    27   apply (erule ex1E, rule ex1I, erule subst_context)
    27   apply (erule ex1E, rule ex1I, erule subst_context)
    28   apply (rule subst, assumption, erule allE, rule subst_context, erule mp)
    28   apply (rule subst, assumption, erule allE, rule subst_context, erule mp)
    29   apply (erule subst_context)
    29   apply (erule subst_context)
    30   done
    30   done
    31 
    31 
    32 
    32 
    33 text{*A weird property of ordered pairs.*}
    33 text\<open>A weird property of ordered pairs.\<close>
    34 lemma "b\<noteq>c ==> <a,b> \<inter> <a,c> = <a,a>"
    34 lemma "b\<noteq>c ==> <a,b> \<inter> <a,c> = <a,a>"
    35 by (simp add: Pair_def Int_cons_left Int_cons_right doubleton_eq_iff, blast)
    35 by (simp add: Pair_def Int_cons_left Int_cons_right doubleton_eq_iff, blast)
    36 
    36 
    37 text{*These two are cited in Benzmueller and Kohlhase's system description of
    37 text\<open>These two are cited in Benzmueller and Kohlhase's system description of
    38  LEO, CADE-15, 1998 (page 139-143) as theorems LEO could not prove.*}
    38  LEO, CADE-15, 1998 (page 139-143) as theorems LEO could not prove.\<close>
    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))"
    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))"
    40 by (blast intro!: equalityI)
    40 by (blast intro!: equalityI)
    41 
    41 
    42 text{*the dual of the previous one*}
    42 text\<open>the dual of the previous one\<close>
    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))"
    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))"
    44 by (blast intro!: equalityI)
    44 by (blast intro!: equalityI)
    45 
    45 
    46 text{*trivial example of term synthesis: apparently hard for some provers!*}
    46 text\<open>trivial example of term synthesis: apparently hard for some provers!\<close>
    47 schematic_lemma "a \<noteq> b ==> a:?X & b \<notin> ?X"
    47 schematic_lemma "a \<noteq> b ==> a:?X & b \<notin> ?X"
    48 by blast
    48 by blast
    49 
    49 
    50 text{*Nice blast benchmark.  Proved in 0.3s; old tactics can't manage it!*}
    50 text\<open>Nice blast benchmark.  Proved in 0.3s; old tactics can't manage it!\<close>
    51 lemma "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y ==> \<exists>z. S \<subseteq> {z}"
    51 lemma "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y ==> \<exists>z. S \<subseteq> {z}"
    52 by blast
    52 by blast
    53 
    53 
    54 text{*variant of the benchmark above*}
    54 text\<open>variant of the benchmark above\<close>
    55 lemma "\<forall>x \<in> S. \<Union>(S) \<subseteq> x ==> \<exists>z. S \<subseteq> {z}"
    55 lemma "\<forall>x \<in> S. \<Union>(S) \<subseteq> x ==> \<exists>z. S \<subseteq> {z}"
    56 by blast
    56 by blast
    57 
    57 
    58 (*Example 12 (credited to Peter Andrews) from
    58 (*Example 12 (credited to Peter Andrews) from
    59  W. Bledsoe.  A Maximal Method for Set Variables in Automatic Theorem-proving.
    59  W. Bledsoe.  A Maximal Method for Set Variables in Automatic Theorem-proving.
    60  In: J. Hayes and D. Michie and L. Mikulich, eds.  Machine Intelligence 9.
    60  In: J. Hayes and D. Michie and L. Mikulich, eds.  Machine Intelligence 9.
    61  Ellis Horwood, 53-100 (1979). *)
    61  Ellis Horwood, 53-100 (1979). *)
    62 lemma "(\<forall>F. {x} \<in> F \<longrightarrow> {y} \<in> F) \<longrightarrow> (\<forall>A. x \<in> A \<longrightarrow> y \<in> A)"
    62 lemma "(\<forall>F. {x} \<in> F \<longrightarrow> {y} \<in> F) \<longrightarrow> (\<forall>A. x \<in> A \<longrightarrow> y \<in> A)"
    63 by best
    63 by best
    64 
    64 
    65 text{*A characterization of functions suggested by Tobias Nipkow*}
    65 text\<open>A characterization of functions suggested by Tobias Nipkow\<close>
    66 lemma "r \<in> domain(r)->B  \<longleftrightarrow>  r \<subseteq> domain(r)*B & (\<forall>X. r `` (r -`` X) \<subseteq> X)"
    66 lemma "r \<in> domain(r)->B  \<longleftrightarrow>  r \<subseteq> domain(r)*B & (\<forall>X. r `` (r -`` X) \<subseteq> X)"
    67 by (unfold Pi_def function_def, best)
    67 by (unfold Pi_def function_def, best)
    68 
    68 
    69 
    69 
    70 subsection{*Composition of homomorphisms is a Homomorphism*}
    70 subsection\<open>Composition of homomorphisms is a Homomorphism\<close>
    71 
    71 
    72 text{*Given as a challenge problem in
    72 text\<open>Given as a challenge problem in
    73   R. Boyer et al.,
    73   R. Boyer et al.,
    74   Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
    74   Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
    75   JAR 2 (1986), 287-327 *}
    75   JAR 2 (1986), 287-327\<close>
    76 
    76 
    77 text{*collecting the relevant lemmas*}
    77 text\<open>collecting the relevant lemmas\<close>
    78 declare comp_fun [simp] SigmaI [simp] apply_funtype [simp]
    78 declare comp_fun [simp] SigmaI [simp] apply_funtype [simp]
    79 
    79 
    80 (*Force helps prove conditions of rewrites such as comp_fun_apply, since
    80 (*Force helps prove conditions of rewrites such as comp_fun_apply, since
    81   rewriting does not instantiate Vars.*)
    81   rewriting does not instantiate Vars.*)
    82 lemma "(\<forall>A f B g. hom(A,f,B,g) =  
    82 lemma "(\<forall>A f B g. hom(A,f,B,g) =  
    84                      (\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)}) \<longrightarrow>  
    84                      (\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)}) \<longrightarrow>  
    85        J \<in> hom(A,f,B,g) & K \<in> hom(B,g,C,h) \<longrightarrow>   
    85        J \<in> hom(A,f,B,g) & K \<in> hom(B,g,C,h) \<longrightarrow>   
    86        (K O J) \<in> hom(A,f,C,h)"
    86        (K O J) \<in> hom(A,f,C,h)"
    87 by force
    87 by force
    88 
    88 
    89 text{*Another version, with meta-level rewriting*}
    89 text\<open>Another version, with meta-level rewriting\<close>
    90 lemma "(!! A f B g. hom(A,f,B,g) ==  
    90 lemma "(!! A f B g. hom(A,f,B,g) ==  
    91            {H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &  
    91            {H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &  
    92                      (\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)}) 
    92                      (\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)}) 
    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)"
    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)"
    94 by force
    94 by force
    95 
    95 
    96 
    96 
    97 subsection{*Pastre's Examples*}
    97 subsection\<open>Pastre's Examples\<close>
    98 
    98 
    99 text{*D Pastre.  Automatic theorem proving in set theory. 
    99 text\<open>D Pastre.  Automatic theorem proving in set theory. 
   100         Artificial Intelligence, 10:1--27, 1978.
   100         Artificial Intelligence, 10:1--27, 1978.
   101 Previously, these were done using ML code, but blast manages fine.*}
   101 Previously, these were done using ML code, but blast manages fine.\<close>
   102 
   102 
   103 lemmas compIs [intro] = comp_surj comp_inj comp_fun [intro]
   103 lemmas compIs [intro] = comp_surj comp_inj comp_fun [intro]
   104 lemmas compDs [dest] =  comp_mem_injD1 comp_mem_surjD1 
   104 lemmas compDs [dest] =  comp_mem_injD1 comp_mem_surjD1 
   105                         comp_mem_injD2 comp_mem_surjD2
   105                         comp_mem_injD2 comp_mem_surjD2
   106 
   106