src/HOL/MetisExamples/set.thy
author haftmann
Tue, 14 Jul 2009 10:54:04 +0200
changeset 31998 2c7a24f74db9
parent 28592 824f8390aaa2
child 32519 e9644b497e1c
permissions -rw-r--r--
code attributes use common underscore convention
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     1
(*  Title:      HOL/MetisExamples/set.thy
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     2
    ID:         $Id$
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     4
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     5
Testing the metis method
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     6
*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     7
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     8
theory set imports Main
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
     9
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    10
begin
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    11
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    12
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
    13
               (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
    14
               (Q(X,y) | ~Q(y,Z) | S(X,X))" 
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23449
diff changeset
    15
by metis
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23449
diff changeset
    16
(*??But metis can't prove the single-step version...*)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    17
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23449
diff changeset
    18
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    19
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    20
lemma "P(n::nat) ==> ~P(0) ==> n ~= 0"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    21
by metis
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    22
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 26312
diff changeset
    23
declare [[sledgehammer_modulus = 1]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    24
28486
873726bdfd47 updated to new AtpManager;
wenzelm
parents: 26806
diff changeset
    25
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    26
(*multiple versions of this example*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    27
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    28
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    29
    (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
    30
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    31
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    32
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    33
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    34
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
    35
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
    36
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
    37
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
    38
have 6: "sup Y Z = X \<or> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    39
  by (metis 0 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    40
have 7: "sup Y Z = X \<or> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    41
  by (metis 1 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    42
have 8: "\<And>X3. sup Y Z = X \<or> X \<subseteq> X3 \<or> \<not> Y \<subseteq> X3 \<or> \<not> Z \<subseteq> X3"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    43
  by (metis 5 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    44
have 9: "Y \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    45
  by (metis 2 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    46
have 10: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    47
  by (metis 3 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    48
have 11: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    49
  by (metis 4 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    50
have 12: "Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    51
  by (metis Un_upper2 sup_set_eq 7)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    52
have 13: "\<And>X3. sup Y Z = X \<or> X \<subseteq> sup X3 Z \<or> \<not> Y \<subseteq> sup X3 Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    53
  by (metis 8 Un_upper2 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    54
have 14: "Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    55
  by (metis Un_upper1 sup_set_eq 6)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    56
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
    57
  by (metis 10 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    58
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
    59
  by (metis 9 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    60
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
    61
  by (metis 11 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    62
have 18: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    63
  by (metis 17 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    64
have 19: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    65
  by (metis 15 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    66
have 20: "Y \<subseteq> x \<or> sup Y Z \<noteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    67
  by (metis 16 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    68
have 21: "sup Y Z = X \<or> X \<subseteq> sup Y Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    69
  by (metis 13 Un_upper1 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    70
have 22: "sup Y Z = X \<or> \<not> sup Y Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    71
  by (metis equalityI 21)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    72
have 23: "sup Y Z = X \<or> \<not> Z \<subseteq> X \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    73
  by (metis 22 Un_least sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    74
have 24: "sup Y Z = X \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    75
  by (metis 23 12)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    76
have 25: "sup Y Z = X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    77
  by (metis 24 14)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    78
have 26: "\<And>X3. X \<subseteq> X3 \<or> \<not> Z \<subseteq> X3 \<or> \<not> Y \<subseteq> X3"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    79
  by (metis Un_least sup_set_eq 25)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    80
have 27: "Y \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    81
  by (metis 20 25)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    82
have 28: "Z \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    83
  by (metis 19 25)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    84
have 29: "\<not> X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    85
  by (metis 18 25)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    86
have 30: "X \<subseteq> x \<or> \<not> Y \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    87
  by (metis 26 28)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    88
have 31: "X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    89
  by (metis 30 27)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    90
show "False"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    91
  by (metis 31 29)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    92
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    93
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 26312
diff changeset
    94
declare [[sledgehammer_modulus = 2]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    95
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    96
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    97
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
    98
    (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
    99
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   100
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   101
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   102
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   103
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
   104
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
   105
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
   106
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
   107
have 6: "sup Y Z = X \<or> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   108
  by (metis 0 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   109
have 7: "Y \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   110
  by (metis 2 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   111
have 8: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   112
  by (metis 4 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   113
have 9: "\<And>X3. sup Y Z = X \<or> X \<subseteq> sup X3 Z \<or> \<not> Y \<subseteq> sup X3 Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   114
  by (metis 5 sup_set_eq Un_upper2 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   115
have 10: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   116
  by (metis 3 sup_set_eq Un_upper2 sup_set_eq sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   117
have 11: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   118
  by (metis 8 Un_upper2 sup_set_eq sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   119
have 12: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   120
  by (metis 10 Un_upper1 sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   121
have 13: "sup Y Z = X \<or> X \<subseteq> sup Y Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   122
  by (metis 9 Un_upper1 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   123
have 14: "sup Y Z = X \<or> \<not> Z \<subseteq> X \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   124
  by (metis equalityI 13 Un_least sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   125
have 15: "sup Y Z = X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   126
  by (metis 14 sup_set_eq 1 sup_set_eq sup_set_eq 6)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   127
have 16: "Y \<subseteq> x"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   128
  by (metis 7 Un_upper2 sup_set_eq sup_set_eq Un_upper1 sup_set_eq 15)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   129
have 17: "\<not> X \<subseteq> x"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   130
  by (metis 11 Un_upper1 sup_set_eq 15)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   131
have 18: "X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   132
  by (metis Un_least sup_set_eq 15 12 15 16)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   133
show "False"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   134
  by (metis 18 17)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   135
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   136
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 26312
diff changeset
   137
declare [[sledgehammer_modulus = 3]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   138
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   139
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   140
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   141
    (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
   142
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   143
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   144
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   145
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   146
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
   147
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
   148
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
   149
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
   150
have 6: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   151
  by (metis 3 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   152
have 7: "\<And>X3. sup Y Z = X \<or> X \<subseteq> sup X3 Z \<or> \<not> Y \<subseteq> sup X3 Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   153
  by (metis 5 sup_set_eq Un_upper2 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   154
have 8: "Y \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   155
  by (metis 2 sup_set_eq Un_upper2 sup_set_eq sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   156
have 9: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   157
  by (metis 6 Un_upper2 sup_set_eq sup_set_eq Un_upper1 sup_set_eq sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   158
have 10: "sup Y Z = X \<or> \<not> sup Y Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   159
  by (metis equalityI 7 Un_upper1 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   160
have 11: "sup Y Z = X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   161
  by (metis 10 Un_least sup_set_eq sup_set_eq 1 sup_set_eq sup_set_eq 0 sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   162
have 12: "Z \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   163
  by (metis 9 11)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   164
have 13: "X \<subseteq> x"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   165
  by (metis Un_least sup_set_eq 11 12 8 Un_upper1 sup_set_eq sup_set_eq 11)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   166
show "False"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   167
  by (metis 13 4 sup_set_eq Un_upper2 sup_set_eq sup_set_eq Un_upper1 sup_set_eq sup_set_eq 11)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   168
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   169
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   170
(*Example included in TPHOLs paper*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   171
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 26312
diff changeset
   172
declare [[sledgehammer_modulus = 4]]
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   173
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   174
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   175
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   176
    (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
   177
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   178
fix x
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   179
assume 0: "Y \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   180
assume 1: "Z \<subseteq> X \<or> X = Y \<union> Z"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   181
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
   182
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
   183
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
   184
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
   185
have 6: "sup Y Z \<noteq> X \<or> \<not> X \<subseteq> x \<or> \<not> Y \<subseteq> X \<or> \<not> Z \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   186
  by (metis 4 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   187
have 7: "Z \<subseteq> x \<or> sup Y Z \<noteq> X \<or> \<not> Y \<subseteq> X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   188
  by (metis 3 sup_set_eq Un_upper2 sup_set_eq sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   189
have 8: "Z \<subseteq> x \<or> sup Y Z \<noteq> X"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   190
  by (metis 7 Un_upper1 sup_set_eq sup_set_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   191
have 9: "sup Y Z = X \<or> \<not> Z \<subseteq> X \<or> \<not> Y \<subseteq> X"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   192
  by (metis equalityI 5 sup_set_eq Un_upper2 sup_set_eq Un_upper1 sup_set_eq Un_least sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   193
have 10: "Y \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   194
  by (metis 2 sup_set_eq Un_upper2 sup_set_eq 1 sup_set_eq Un_upper1 sup_set_eq 0 sup_set_eq 9 Un_upper2 sup_set_eq 1 sup_set_eq Un_upper1 sup_set_eq 0 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   195
have 11: "X \<subseteq> x"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   196
  by (metis Un_least sup_set_eq 9 Un_upper2 sup_set_eq 1 sup_set_eq Un_upper1 sup_set_eq 0 sup_set_eq 8 9 Un_upper2 sup_set_eq 1 sup_set_eq Un_upper1 sup_set_eq 0 sup_set_eq 10)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   197
show "False"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   198
  by (metis 11 6 Un_upper2 sup_set_eq 1 sup_set_eq Un_upper1 sup_set_eq 0 sup_set_eq 9 Un_upper2 sup_set_eq 1 sup_set_eq Un_upper1 sup_set_eq 0 sup_set_eq)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   199
qed 
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   200
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents: 28486
diff changeset
   201
ML {*AtpWrapper.problem_name := "set__equal_union"*}
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   202
lemma (*equal_union: *)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   203
   "(X = Y \<union> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   204
    (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
   205
(*One shot proof: hand-reduced. Metis can't do the full proof any more.*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   206
by (metis Un_least Un_upper1 Un_upper2 set_eq_subset)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   207
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   208
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents: 28486
diff changeset
   209
ML {*AtpWrapper.problem_name := "set__equal_inter"*}
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   210
lemma "(X = Y \<inter> Z) =
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   211
    (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
   212
by (metis Int_greatest Int_lower1 Int_lower2 set_eq_subset)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   213
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents: 28486
diff changeset
   214
ML {*AtpWrapper.problem_name := "set__fixedpoint"*}
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   215
lemma fixedpoint:
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
by metis
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   218
26312
e9a65675e5e8 avoid rebinding of existing facts;
wenzelm
parents: 25710
diff changeset
   219
lemma (*fixedpoint:*)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   220
    "\<exists>!x. f (g x) = x \<Longrightarrow> \<exists>!y. g (f y) = y"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   221
proof (neg_clausify)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   222
fix x xa
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   223
assume 0: "f (g x) = x"
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   224
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
   225
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
   226
assume 3: "\<And>x. g (f x) \<noteq> x \<or> xa x \<noteq> x"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   227
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
   228
  by (metis 3 1 2)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   229
show "False"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   230
  by (metis 4 0)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   231
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   232
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents: 28486
diff changeset
   233
ML {*AtpWrapper.problem_name := "set__singleton_example"*}
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   234
lemma (*singleton_example_2:*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   235
     "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   236
by (metis Set.subsetI Union_upper insertCI set_eq_subset)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   237
  --{*found by SPASS*}
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}"
26806
40b411ec05aa Adapted to encoding of sets as predicates
berghofe
parents: 26333
diff changeset
   241
by (metis Un_absorb2 Union_insert insertI1 insert_Diff insert_Diff_single subset_eq)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   242
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   243
lemma singleton_example_2:
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   244
     "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   245
proof (neg_clausify)
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24855
diff changeset
   246
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
   247
assume 1: "\<And>x. x \<notin> S \<or> \<Union>S \<subseteq> x"
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   248
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
   249
  by (metis set_eq_subset 1)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   250
have 3: "\<And>X3. S \<subseteq> insert (\<Union>S) X3"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   251
  by (metis insert_iff Set.subsetI Union_upper 2 Set.subsetI)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   252
show "False"
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   253
  by (metis 3 0)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   254
qed
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   255
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   256
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   257
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   258
text {*
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   259
  From W. W. Bledsoe and Guohui Feng, SET-VAR. JAR 11 (3), 1993, pages
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   260
  293-314.
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   261
*}
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   262
28592
824f8390aaa2 renamed AtpThread to AtpWrapper;
wenzelm
parents: 28486
diff changeset
   263
ML {*AtpWrapper.problem_name := "set__Bledsoe_Fung"*}
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   264
(*Notes: 1, the numbering doesn't completely agree with the paper. 
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   265
2, we must rename set variables to avoid type clashes.*)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   266
lemma "\<exists>B. (\<forall>x \<in> B. x \<le> (0::int))"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   267
      "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
   268
      "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
   269
      "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
   270
      "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
   271
      "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
   272
      "\<exists>A. a \<notin> A"
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   273
      "(\<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" 
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   274
apply (metis atMost_iff)
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   275
apply (metis emptyE)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   276
apply (metis insert_iff singletonE)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   277
apply (metis insertCI singletonE zless_le)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   278
apply (metis insert_iff singletonE)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   279
apply (metis insert_iff singletonE)
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   280
apply (metis DiffE)
24855
161eb8381b49 metis method: used theorems
paulson
parents: 24742
diff changeset
   281
apply (metis pair_in_Id_conv) 
23449
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   282
done
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   283
dd874e6a3282 integration of Metis prover
paulson
parents:
diff changeset
   284
end