src/ZF/ex/misc.ML
author paulson
Fri, 03 Jan 1997 15:01:55 +0100
changeset 2469 b50b8c0eec01
parent 1782 ab45b881fa62
child 2496 40efb87985b5
permissions -rw-r--r--
Implicit simpsets and clasets for FOL and ZF
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
     1
(*  Title:      ZF/ex/misc
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Miscellaneous examples for Zermelo-Fraenkel Set Theory 
1646
f48fafc18a88 updated comments
paulson
parents: 1461
diff changeset
     7
Composition of homomorphisms, Pastre's examples, ...
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
writeln"ZF/ex/misc";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    12
set_current_thy"Perm";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
(*Example 12 (credited to Peter Andrews) from
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
 W. Bledsoe.  A Maximal Method for Set Variables in Automatic Theorem-proving.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
 In: J. Hayes and D. Michie and L. Mikulich, eds.  Machine Intelligence 9.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
 Ellis Horwood, 53-100 (1979). *)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    18
goal thy "(ALL F. {x}: F --> {y}:F) --> (ALL A. x:A --> y:A)";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    19
by (Best_tac 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
(*** Composition of homomorphisms is a homomorphism ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
(*Given as a challenge problem in
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
  R. Boyer et al.,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
  Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
  JAR 2 (1986), 287-327 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
    31
(*collecting the relevant lemmas*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    32
Addsimps [comp_fun, SigmaI, apply_funtype];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
736
a8d1758bb113 moved Cantors theorem to ZF/ZF.ML and ZF/Perm.ML
lcp
parents: 695
diff changeset
    34
(*This version uses a super application of simp_tac.  Needs setloop to help
a8d1758bb113 moved Cantors theorem to ZF/ZF.ML and ZF/Perm.ML
lcp
parents: 695
diff changeset
    35
  proving conditions of rewrites such as comp_fun_apply;
a8d1758bb113 moved Cantors theorem to ZF/ZF.ML and ZF/Perm.ML
lcp
parents: 695
diff changeset
    36
  rewriting does not instantiate Vars*)
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
    37
goal Perm.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
    "(ALL A f B g. hom(A,f,B,g) = \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
\          {H: A->B. f:A*A->A & g:B*B->B & \
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
    40
\                    (ALL x:A. ALL y:A. H`(f`<x,y>) = g`<H`x,H`y>)}) --> \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
\    J : hom(A,f,B,g) & K : hom(B,g,C,h) -->  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
\    (K O J) : hom(A,f,C,h)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    43
by (asm_simp_tac (!simpset setloop (K (safe_tac (!claset)))) 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
val comp_homs = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
    46
(*This version uses meta-level rewriting, safe_tac and asm_simp_tac*)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
val [hom_def] = goal Perm.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
    "(!! A f B g. hom(A,f,B,g) == \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
\          {H: A->B. f:A*A->A & g:B*B->B & \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
\                    (ALL x:A. ALL y:A. H`(f`<x,y>) = g`<H`x,H`y>)}) ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
\    J : hom(A,f,B,g) & K : hom(B,g,C,h) -->  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
\    (K O J) : hom(A,f,C,h)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
by (rewtac hom_def);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    54
by (safe_tac (!claset));
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    55
by (Asm_simp_tac 1);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    56
by (Asm_simp_tac 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 736
diff changeset
    57
qed "comp_homs";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
(** A characterization of functions, suggested by Tobias Nipkow **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    62
goalw thy [Pi_def, function_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
    "r: domain(r)->B  <->  r <= domain(r)*B & (ALL X. r `` (r -`` X) <= X)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
    64
by (Best_tac 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
(**** From D Pastre.  Automatic theorem proving in set theory. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
         Artificial Intelligence, 10:1--27, 1978.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
             These examples require forward reasoning! ****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
(*reduce the clauses to units by type checking -- beware of nontermination*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
fun forw_typechk tyrls [] = []
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
  | forw_typechk tyrls clauses =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
    let val (units, others) = partition (has_fewer_prems 1) clauses
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
    in  gen_union eq_thm (units, forw_typechk tyrls (tyrls RL others))
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
    end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
(*A crude form of forward reasoning*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
fun forw_iterate tyrls rls facts 0 = facts
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
  | forw_iterate tyrls rls facts n =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
      let val facts' = 
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
    83
          gen_union eq_thm (forw_typechk (tyrls@facts) (facts RL rls), facts);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
      in  forw_iterate tyrls rls facts' (n-1)  end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
val pastre_rls =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
    [comp_mem_injD1, comp_mem_surjD1, comp_mem_injD2, comp_mem_surjD2];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
fun pastre_facts (fact1::fact2::fact3::prems) = 
434
89d45187f04d Various updates and tidying
lcp
parents: 38
diff changeset
    90
    forw_iterate (prems @ [comp_surj, comp_inj, comp_fun])
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
               pastre_rls [fact1,fact2,fact3] 4;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
val prems = goalw Perm.thy [bij_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
    94
    "[| (h O g O f): inj(A,A);          \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
    95
\       (f O h O g): surj(B,B);         \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
    96
\       (g O f O h): surj(C,C);         \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
\       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 736
diff changeset
    99
qed "pastre1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
val prems = goalw Perm.thy [bij_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   102
    "[| (h O g O f): surj(A,A);         \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   103
\       (f O h O g): inj(B,B);          \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   104
\       (g O f O h): surj(C,C);         \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
\       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 736
diff changeset
   107
qed "pastre2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
val prems = goalw Perm.thy [bij_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   110
    "[| (h O g O f): surj(A,A);         \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   111
\       (f O h O g): surj(B,B);         \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   112
\       (g O f O h): inj(C,C);          \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
\       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 736
diff changeset
   115
qed "pastre3";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
val prems = goalw Perm.thy [bij_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   118
    "[| (h O g O f): surj(A,A);         \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   119
\       (f O h O g): inj(B,B);          \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   120
\       (g O f O h): inj(C,C);          \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
\       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 736
diff changeset
   123
qed "pastre4";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
val prems = goalw Perm.thy [bij_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   126
    "[| (h O g O f): inj(A,A);          \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   127
\       (f O h O g): surj(B,B);         \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   128
\       (g O f O h): inj(C,C);          \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
\       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 736
diff changeset
   131
qed "pastre5";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
val prems = goalw Perm.thy [bij_def]
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   134
    "[| (h O g O f): inj(A,A);          \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   135
\       (f O h O g): inj(B,B);          \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 1110
diff changeset
   136
\       (g O f O h): surj(C,C);         \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
\       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 736
diff changeset
   139
qed "pastre6";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
   141
(** Yet another example... **)
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
   142
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
   143
goal Perm.thy
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
   144
    "(lam Z:Pow(A+B). <{x:A. Inl(x):Z}, {y:B. Inr(y):Z}>) \
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
   145
\    : bij(Pow(A+B), Pow(A)*Pow(B))";
1110
756aa2e81f6e Changed some definitions and proofs to use pattern-matching.
lcp
parents: 782
diff changeset
   146
by (res_inst_tac [("d", "%<X,Y>.{Inl(x).x:X} Un {Inr(y).y:Y}")] 
695
a1586fa1b755 ZF/ex/Ramsey,Rmap,misc.ML: modified for new definition of Pi(A,B)
lcp
parents: 434
diff changeset
   147
    lam_bijective 1);
a1586fa1b755 ZF/ex/Ramsey,Rmap,misc.ML: modified for new definition of Pi(A,B)
lcp
parents: 434
diff changeset
   148
by (TRYALL (etac SigmaE));
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
   149
by (ALLGOALS Asm_simp_tac);
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1782
diff changeset
   150
by (ALLGOALS (fast_tac (!claset addSIs [equalityI])));
7
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
   151
val Pow_bij = result();
268f93ab3bc4 Installation of new simplifier for ZF/ex. The hom_ss example in misc.ML is
lcp
parents: 0
diff changeset
   152
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
writeln"Reached end of file.";