src/HOL/Metis_Examples/set.thy
author blanchet
Fri, 30 Apr 2010 09:36:45 +0200
changeset 36569 3a29eb7606c3
parent 36566 f91342f218a9
child 36573 badb32303d1e
permissions -rw-r--r--
added "no_atp" for theorems that are automatically used or included by Sledgehammer when appropriate (about combinators and fequal)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33027
9cf389429f6d modernized session Metis_Examples;
wenzelm
parents: 32864
diff changeset
     1
(*  Title:      HOL/Metis_Examples/set.thy
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     3
33027
9cf389429f6d modernized session Metis_Examples;
wenzelm
parents: 32864
diff changeset
     4
Testing the metis method.
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     5
*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     6
33027
9cf389429f6d modernized session Metis_Examples;
wenzelm
parents: 32864
diff changeset
     7
theory set
9cf389429f6d modernized session Metis_Examples;
wenzelm
parents: 32864
diff changeset
     8
imports Main
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     9
begin
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    10
36566
f91342f218a9 redid some Sledgehammer/Metis proofs
blanchet
parents: 36407
diff changeset
    11
sledgehammer_params [isar_proof, debug, overlord]
f91342f218a9 redid some Sledgehammer/Metis proofs
blanchet
parents: 36407
diff changeset
    12
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    13
lemma "EX x X. ALL y. EX z Z. (~P(y,y) | P(x,x) | ~S(z,x)) &
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    14
               (S(x,y) | ~S(y,z) | Q(Z,Z))  &
24742
73b8b42a36b6 removal of some "ref"s from res_axioms.ML; a side-effect is that the ordering
paulson
parents: 23519
diff changeset
    15
               (Q(X,y) | ~Q(y,Z) | S(X,X))" 
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23449
diff changeset
    16
by metis
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    17
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    18
lemma "P(n::nat) ==> ~P(0) ==> n ~= 0"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    19
by metis
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    20
36407
d733c1a624f4 renamed option
blanchet
parents: 36067
diff changeset
    21
sledgehammer_params [shrink_factor = 1]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    22
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    23
(*multiple versions of this example*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    24
lemma (*equal_union: *)
36566
f91342f218a9 redid some Sledgehammer/Metis proofs
blanchet
parents: 36407
diff changeset
    25
   "(X = Y \<union> Z) = (Y \<subseteq> X \<and> Z \<subseteq> X \<and> (\<forall>V. Y \<subseteq> V \<and> Z \<subseteq> V \<longrightarrow> X \<subseteq> V))"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    26
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    27
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    28
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    29
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    30
assume 2: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Y \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    31
assume 3: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Z \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    32
assume 4: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> \<not> X \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
    33
assume 5: "\<And>V. ((\<not> Y \<subseteq> V \<or> \<not> Z \<subseteq> V) \<or> X \<subseteq> V) \<or> X = Y \<union> Z"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    34
have 6: "sup Y Z = X \<or> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    35
  by (metis 0)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    36
have 7: "sup Y Z = X \<or> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    37
  by (metis 1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    38
have 8: "\<And>X3. sup Y Z = X \<or> X \<subseteq> X3 \<or> \<not> Y \<subseteq> X3 \<or> \<not> Z \<subseteq> X3"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    39
  by (metis 5)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    40
have 9: "Y \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    41
  by (metis 2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    42
have 10: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    43
  by (metis 3)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    44
have 11: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    45
  by (metis 4)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    46
have 12: "Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    47
  by (metis Un_upper2 7)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    48
have 13: "\<And>X3. sup Y Z = X \<or> X \<subseteq> sup X3 Z \<or> \<not> Y \<subseteq> sup X3 Z"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    49
  by (metis 8 Un_upper2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    50
have 14: "Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    51
  by (metis Un_upper1 6)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    52
have 15: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    53
  by (metis 10 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    54
have 16: "Y \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    55
  by (metis 9 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    56
have 17: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    57
  by (metis 11 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    58
have 18: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    59
  by (metis 17 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    60
have 19: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    61
  by (metis 15 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    62
have 20: "Y \<subseteq> x \<or> sup Y Z \<noteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    63
  by (metis 16 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    64
have 21: "sup Y Z = X \<or> X \<subseteq> sup Y Z"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    65
  by (metis 13 Un_upper1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    66
have 22: "sup Y Z = X \<or> \<not> sup Y Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    67
  by (metis equalityI 21)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    68
have 23: "sup Y Z = X \<or> \<not> Z \<subseteq> X \<or> \<not> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    69
  by (metis 22 Un_least)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    70
have 24: "sup Y Z = X \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    71
  by (metis 23 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    72
have 25: "sup Y Z = X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    73
  by (metis 24 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    74
have 26: "\<And>X3. X \<subseteq> X3 \<or> \<not> Z \<subseteq> X3 \<or> \<not> Y \<subseteq> X3"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
    75
  by (metis Un_least 25)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    76
have 27: "Y \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    77
  by (metis 20 25)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    78
have 28: "Z \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    79
  by (metis 19 25)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    80
have 29: "\<not> X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    81
  by (metis 18 25)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    82
have 30: "X \<subseteq> x \<or> \<not> Y \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    83
  by (metis 26 28)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    84
have 31: "X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    85
  by (metis 30 27)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    86
show "False"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    87
  by (metis 31 29)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    88
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    89
36407
d733c1a624f4 renamed option
blanchet
parents: 36067
diff changeset
    90
sledgehammer_params [shrink_factor = 2]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    91
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    92
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    93
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    94
    (Y \<subseteq> X \<and> Z \<subseteq> X \<and> (\<forall>V. Y \<subseteq> V \<and> Z \<subseteq> V \<longrightarrow> X \<subseteq> V))"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    95
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    96
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    97
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    98
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    99
assume 2: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Y \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   100
assume 3: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Z \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   101
assume 4: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> \<not> X \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   102
assume 5: "\<And>V. ((\<not> Y \<subseteq> V \<or> \<not> Z \<subseteq> V) \<or> X \<subseteq> V) \<or> X = Y \<union> Z"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   103
have 6: "sup Y Z = X \<or> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   104
  by (metis 0)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   105
have 7: "Y \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   106
  by (metis 2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   107
have 8: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   108
  by (metis 4)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   109
have 9: "\<And>X3. sup Y Z = X \<or> X \<subseteq> sup X3 Z \<or> \<not> Y \<subseteq> sup X3 Z"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   110
  by (metis 5 Un_upper2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   111
have 10: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   112
  by (metis 3 Un_upper2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   113
have 11: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   114
  by (metis 8 Un_upper2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   115
have 12: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   116
  by (metis 10 Un_upper1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   117
have 13: "sup Y Z = X \<or> X \<subseteq> sup Y Z"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   118
  by (metis 9 Un_upper1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   119
have 14: "sup Y Z = X \<or> \<not> Z \<subseteq> X \<or> \<not> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   120
  by (metis equalityI 13 Un_least)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   121
have 15: "sup Y Z = X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   122
  by (metis 14 1 6)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   123
have 16: "Y \<subseteq> x"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   124
  by (metis 7 Un_upper2 Un_upper1 15)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   125
have 17: "\<not> X \<subseteq> x"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   126
  by (metis 11 Un_upper1 15)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   127
have 18: "X \<subseteq> x"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   128
  by (metis Un_least 15 12 15 16)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   129
show "False"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   130
  by (metis 18 17)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   131
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   132
36407
d733c1a624f4 renamed option
blanchet
parents: 36067
diff changeset
   133
sledgehammer_params [shrink_factor = 3]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   134
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   135
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   136
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   137
    (Y \<subseteq> X \<and> Z \<subseteq> X \<and> (\<forall>V. Y \<subseteq> V \<and> Z \<subseteq> V \<longrightarrow> X \<subseteq> V))"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   138
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   139
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   140
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   141
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   142
assume 2: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Y \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   143
assume 3: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Z \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   144
assume 4: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> \<not> X \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   145
assume 5: "\<And>V. ((\<not> Y \<subseteq> V \<or> \<not> Z \<subseteq> V) \<or> X \<subseteq> V) \<or> X = Y \<union> Z"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   146
have 6: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   147
  by (metis 3)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   148
have 7: "\<And>X3. sup Y Z = X \<or> X \<subseteq> sup X3 Z \<or> \<not> Y \<subseteq> sup X3 Z"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   149
  by (metis 5 Un_upper2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   150
have 8: "Y \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   151
  by (metis 2 Un_upper2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   152
have 9: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   153
  by (metis 6 Un_upper2 Un_upper1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   154
have 10: "sup Y Z = X \<or> \<not> sup Y Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   155
  by (metis equalityI 7 Un_upper1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   156
have 11: "sup Y Z = X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   157
  by (metis 10 Un_least 1 0)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   158
have 12: "Z \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   159
  by (metis 9 11)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   160
have 13: "X \<subseteq> x"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   161
  by (metis Un_least 11 12 8 Un_upper1 11)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   162
show "False"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   163
  by (metis 13 4 Un_upper2 Un_upper1 11)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   164
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   165
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   166
(*Example included in TPHOLs paper*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   167
36407
d733c1a624f4 renamed option
blanchet
parents: 36067
diff changeset
   168
sledgehammer_params [shrink_factor = 4]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   169
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   170
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   171
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   172
    (Y \<subseteq> X \<and> Z \<subseteq> X \<and> (\<forall>V. Y \<subseteq> V \<and> Z \<subseteq> V \<longrightarrow> X \<subseteq> V))"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   173
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   174
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   175
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   176
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   177
assume 2: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Y \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   178
assume 3: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> Z \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   179
assume 4: "(\<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X \<or> \<not> X \<subseteq> x) \<or> X \<noteq> Y \<union> Z"
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   180
assume 5: "\<And>V. ((\<not> Y \<subseteq> V \<or> \<not> Z \<subseteq> V) \<or> X \<subseteq> V) \<or> X = Y \<union> Z"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   181
have 6: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   182
  by (metis 4)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   183
have 7: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   184
  by (metis 3 Un_upper2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   185
have 8: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   186
  by (metis 7 Un_upper1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   187
have 9: "sup Y Z = X \<or> \<not> Z \<subseteq> X \<or> \<not> Y \<subseteq> X"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   188
  by (metis equalityI 5 Un_upper2 Un_upper1 Un_least)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   189
have 10: "Y \<subseteq> x"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   190
  by (metis 2 Un_upper2 1 Un_upper1 0 9 Un_upper2 1 Un_upper1 0)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   191
have 11: "X \<subseteq> x"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   192
  by (metis Un_least 9 Un_upper2 1 Un_upper1 0 8 9 Un_upper2 1 Un_upper1 0 10)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   193
show "False"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   194
  by (metis 11 6 Un_upper2 1 Un_upper1 0 9 Un_upper2 1 Un_upper1 0)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   195
qed 
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   196
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32685
diff changeset
   197
declare [[ atp_problem_prefix = "set__equal_union" ]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   198
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   199
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   200
    (Y \<subseteq> X \<and> Z \<subseteq> X \<and> (\<forall>V. Y \<subseteq> V \<and> Z \<subseteq> V \<longrightarrow> X \<subseteq> V))" 
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   201
(*One shot proof: hand-reduced. Metis can't do the full proof any more.*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   202
by (metis Un_least Un_upper1 Un_upper2 set_eq_subset)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   203
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   204
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32685
diff changeset
   205
declare [[ atp_problem_prefix = "set__equal_inter" ]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   206
lemma "(X = Y \<inter> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   207
    (X \<subseteq> Y \<and> X \<subseteq> Z \<and> (\<forall>V. V \<subseteq> Y \<and> V \<subseteq> Z \<longrightarrow> V \<subseteq> X))"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   208
by (metis Int_greatest Int_lower1 Int_lower2 set_eq_subset)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   209
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32685
diff changeset
   210
declare [[ atp_problem_prefix = "set__fixedpoint" ]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   211
lemma fixedpoint:
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   212
    "\<exists>!x. f (g x) = x \<Longrightarrow> \<exists>!y. g (f y) = y"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   213
by metis
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   214
26312
e9a65675e5e8 avoid rebinding of existing facts;
wenzelm
parents: 25710
diff changeset
   215
lemma (*fixedpoint:*)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   216
    "\<exists>!x. f (g x) = x \<Longrightarrow> \<exists>!y. g (f y) = y"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   217
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   218
fix x xa
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   219
assume 0: "f (g x) = x"
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   220
assume 1: "\<And>y. y = x \<or> f (g y) \<noteq> y"
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   221
assume 2: "\<And>x. g (f (xa x)) = xa x \<or> g (f x) \<noteq> x"
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   222
assume 3: "\<And>x. g (f x) \<noteq> x \<or> xa x \<noteq> x"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   223
have 4: "\<And>X1. g (f X1) \<noteq> X1 \<or> g x \<noteq> X1"
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23449
diff changeset
   224
  by (metis 3 1 2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   225
show "False"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   226
  by (metis 4 0)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   227
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   228
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32685
diff changeset
   229
declare [[ atp_problem_prefix = "set__singleton_example" ]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   230
lemma (*singleton_example_2:*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   231
     "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   232
by (metis Set.subsetI Union_upper insertCI set_eq_subset)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   233
  --{*found by SPASS*}
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   234
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   235
lemma (*singleton_example_2:*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   236
     "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
32685
29e4e567b5f4 tuned proofs
haftmann
parents: 32519
diff changeset
   237
by (metis Set.subsetI Union_upper insert_iff set_eq_subset)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   238
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   239
lemma singleton_example_2:
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   240
     "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   241
proof (neg_clausify)
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   242
assume 0: "\<And>x. \<not> S \<subseteq> {x}"
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   243
assume 1: "\<And>x. x \<notin> S \<or> \<Union>S \<subseteq> x"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   244
have 2: "\<And>X3. X3 = \<Union>S \<or> \<not> X3 \<subseteq> \<Union>S \<or> X3 \<notin> S"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   245
  by (metis set_eq_subset 1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   246
have 3: "\<And>X3. S \<subseteq> insert (\<Union>S) X3"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   247
  by (metis insert_iff Set.subsetI Union_upper 2 Set.subsetI)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   248
show "False"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   249
  by (metis 3 0)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   250
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   251
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   252
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   253
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   254
text {*
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   255
  From W. W. Bledsoe and Guohui Feng, SET-VAR. JAR 11 (3), 1993, pages
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   256
  293-314.
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   257
*}
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   258
32864
a226f29d4bdc re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents: 32685
diff changeset
   259
declare [[ atp_problem_prefix = "set__Bledsoe_Fung" ]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   260
(*Notes: 1, the numbering doesn't completely agree with the paper. 
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   261
2, we must rename set variables to avoid type clashes.*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   262
lemma "\<exists>B. (\<forall>x \<in> B. x \<le> (0::int))"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   263
      "D \<in> F \<Longrightarrow> \<exists>G. \<forall>A \<in> G. \<exists>B \<in> F. A \<subseteq> B"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   264
      "P a \<Longrightarrow> \<exists>A. (\<forall>x \<in> A. P x) \<and> (\<exists>y. y \<in> A)"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   265
      "a < b \<and> b < (c::int) \<Longrightarrow> \<exists>B. a \<notin> B \<and> b \<in> B \<and> c \<notin> B"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   266
      "P (f b) \<Longrightarrow> \<exists>s A. (\<forall>x \<in> A. P x) \<and> f s \<in> A"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   267
      "P (f b) \<Longrightarrow> \<exists>s A. (\<forall>x \<in> A. P x) \<and> f s \<in> A"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   268
      "\<exists>A. a \<notin> A"
36566
f91342f218a9 redid some Sledgehammer/Metis proofs
blanchet
parents: 36407
diff changeset
   269
      "(\<forall>C. (0, 0) \<in> C \<and> (\<forall>x y. (x, y) \<in> C \<longrightarrow> (Suc x, Suc y) \<in> C) \<longrightarrow> (n, m) \<in> C) \<and> Q n \<longrightarrow> Q m"
f91342f218a9 redid some Sledgehammer/Metis proofs
blanchet
parents: 36407
diff changeset
   270
apply (metis all_not_in_conv)+
f91342f218a9 redid some Sledgehammer/Metis proofs
blanchet
parents: 36407
diff changeset
   271
apply (metis mem_def)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   272
apply (metis insertCI singletonE zless_le)
32519
e9644b497e1c tuned metis proofs
haftmann
parents: 28592
diff changeset
   273
apply (metis Collect_def Collect_mem_eq)
e9644b497e1c tuned metis proofs
haftmann
parents: 28592
diff changeset
   274
apply (metis Collect_def Collect_mem_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   275
apply (metis DiffE)
36566
f91342f218a9 redid some Sledgehammer/Metis proofs
blanchet
parents: 36407
diff changeset
   276
apply (metis pair_in_Id_conv)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   277
done
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   278
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   279
end