diff -r 8f35633c4922 -r 9cf389429f6d src/HOL/MetisExamples/set.thy --- a/src/HOL/MetisExamples/set.thy Tue Oct 20 19:37:09 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -(* Title: HOL/MetisExamples/set.thy - Author: Lawrence C Paulson, Cambridge University Computer Laboratory - -Testing the metis method -*) - -theory set imports Main - -begin - -lemma "EX x X. ALL y. EX z Z. (~P(y,y) | P(x,x) | ~S(z,x)) & - (S(x,y) | ~S(y,z) | Q(Z,Z)) & - (Q(X,y) | ~Q(y,Z) | S(X,X))" -by metis -(*??But metis can't prove the single-step version...*) - - - -lemma "P(n::nat) ==> ~P(0) ==> n ~= 0" -by metis - -declare [[sledgehammer_modulus = 1]] - - -(*multiple versions of this example*) -lemma (*equal_union: *) - "(X = Y \ Z) = - (Y \ X \ Z \ X \ (\V. Y \ V \ Z \ V \ X \ V))" -proof (neg_clausify) -fix x -assume 0: "Y \ X \ X = Y \ Z" -assume 1: "Z \ X \ X = Y \ Z" -assume 2: "(\ Y \ X \ \ Z \ X \ Y \ x) \ X \ Y \ Z" -assume 3: "(\ Y \ X \ \ Z \ X \ Z \ x) \ X \ Y \ Z" -assume 4: "(\ Y \ X \ \ Z \ X \ \ X \ x) \ X \ Y \ Z" -assume 5: "\V. ((\ Y \ V \ \ Z \ V) \ X \ V) \ X = Y \ Z" -have 6: "sup Y Z = X \ Y \ X" - by (metis 0) -have 7: "sup Y Z = X \ Z \ X" - by (metis 1) -have 8: "\X3. sup Y Z = X \ X \ X3 \ \ Y \ X3 \ \ Z \ X3" - by (metis 5) -have 9: "Y \ x \ sup Y Z \ X \ \ Y \ X \ \ Z \ X" - by (metis 2) -have 10: "Z \ x \ sup Y Z \ X \ \ Y \ X \ \ Z \ X" - by (metis 3) -have 11: "sup Y Z \ X \ \ X \ x \ \ Y \ X \ \ Z \ X" - by (metis 4) -have 12: "Z \ X" - by (metis Un_upper2 7) -have 13: "\X3. sup Y Z = X \ X \ sup X3 Z \ \ Y \ sup X3 Z" - by (metis 8 Un_upper2) -have 14: "Y \ X" - by (metis Un_upper1 6) -have 15: "Z \ x \ sup Y Z \ X \ \ Y \ X" - by (metis 10 12) -have 16: "Y \ x \ sup Y Z \ X \ \ Y \ X" - by (metis 9 12) -have 17: "sup Y Z \ X \ \ X \ x \ \ Y \ X" - by (metis 11 12) -have 18: "sup Y Z \ X \ \ X \ x" - by (metis 17 14) -have 19: "Z \ x \ sup Y Z \ X" - by (metis 15 14) -have 20: "Y \ x \ sup Y Z \ X" - by (metis 16 14) -have 21: "sup Y Z = X \ X \ sup Y Z" - by (metis 13 Un_upper1) -have 22: "sup Y Z = X \ \ sup Y Z \ X" - by (metis equalityI 21) -have 23: "sup Y Z = X \ \ Z \ X \ \ Y \ X" - by (metis 22 Un_least) -have 24: "sup Y Z = X \ \ Y \ X" - by (metis 23 12) -have 25: "sup Y Z = X" - by (metis 24 14) -have 26: "\X3. X \ X3 \ \ Z \ X3 \ \ Y \ X3" - by (metis Un_least 25) -have 27: "Y \ x" - by (metis 20 25) -have 28: "Z \ x" - by (metis 19 25) -have 29: "\ X \ x" - by (metis 18 25) -have 30: "X \ x \ \ Y \ x" - by (metis 26 28) -have 31: "X \ x" - by (metis 30 27) -show "False" - by (metis 31 29) -qed - -declare [[sledgehammer_modulus = 2]] - -lemma (*equal_union: *) - "(X = Y \ Z) = - (Y \ X \ Z \ X \ (\V. Y \ V \ Z \ V \ X \ V))" -proof (neg_clausify) -fix x -assume 0: "Y \ X \ X = Y \ Z" -assume 1: "Z \ X \ X = Y \ Z" -assume 2: "(\ Y \ X \ \ Z \ X \ Y \ x) \ X \ Y \ Z" -assume 3: "(\ Y \ X \ \ Z \ X \ Z \ x) \ X \ Y \ Z" -assume 4: "(\ Y \ X \ \ Z \ X \ \ X \ x) \ X \ Y \ Z" -assume 5: "\V. ((\ Y \ V \ \ Z \ V) \ X \ V) \ X = Y \ Z" -have 6: "sup Y Z = X \ Y \ X" - by (metis 0) -have 7: "Y \ x \ sup Y Z \ X \ \ Y \ X \ \ Z \ X" - by (metis 2) -have 8: "sup Y Z \ X \ \ X \ x \ \ Y \ X \ \ Z \ X" - by (metis 4) -have 9: "\X3. sup Y Z = X \ X \ sup X3 Z \ \ Y \ sup X3 Z" - by (metis 5 Un_upper2) -have 10: "Z \ x \ sup Y Z \ X \ \ Y \ X" - by (metis 3 Un_upper2) -have 11: "sup Y Z \ X \ \ X \ x \ \ Y \ X" - by (metis 8 Un_upper2) -have 12: "Z \ x \ sup Y Z \ X" - by (metis 10 Un_upper1) -have 13: "sup Y Z = X \ X \ sup Y Z" - by (metis 9 Un_upper1) -have 14: "sup Y Z = X \ \ Z \ X \ \ Y \ X" - by (metis equalityI 13 Un_least) -have 15: "sup Y Z = X" - by (metis 14 1 6) -have 16: "Y \ x" - by (metis 7 Un_upper2 Un_upper1 15) -have 17: "\ X \ x" - by (metis 11 Un_upper1 15) -have 18: "X \ x" - by (metis Un_least 15 12 15 16) -show "False" - by (metis 18 17) -qed - -declare [[sledgehammer_modulus = 3]] - -lemma (*equal_union: *) - "(X = Y \ Z) = - (Y \ X \ Z \ X \ (\V. Y \ V \ Z \ V \ X \ V))" -proof (neg_clausify) -fix x -assume 0: "Y \ X \ X = Y \ Z" -assume 1: "Z \ X \ X = Y \ Z" -assume 2: "(\ Y \ X \ \ Z \ X \ Y \ x) \ X \ Y \ Z" -assume 3: "(\ Y \ X \ \ Z \ X \ Z \ x) \ X \ Y \ Z" -assume 4: "(\ Y \ X \ \ Z \ X \ \ X \ x) \ X \ Y \ Z" -assume 5: "\V. ((\ Y \ V \ \ Z \ V) \ X \ V) \ X = Y \ Z" -have 6: "Z \ x \ sup Y Z \ X \ \ Y \ X \ \ Z \ X" - by (metis 3) -have 7: "\X3. sup Y Z = X \ X \ sup X3 Z \ \ Y \ sup X3 Z" - by (metis 5 Un_upper2) -have 8: "Y \ x \ sup Y Z \ X \ \ Y \ X" - by (metis 2 Un_upper2) -have 9: "Z \ x \ sup Y Z \ X" - by (metis 6 Un_upper2 Un_upper1) -have 10: "sup Y Z = X \ \ sup Y Z \ X" - by (metis equalityI 7 Un_upper1) -have 11: "sup Y Z = X" - by (metis 10 Un_least 1 0) -have 12: "Z \ x" - by (metis 9 11) -have 13: "X \ x" - by (metis Un_least 11 12 8 Un_upper1 11) -show "False" - by (metis 13 4 Un_upper2 Un_upper1 11) -qed - -(*Example included in TPHOLs paper*) - -declare [[sledgehammer_modulus = 4]] - -lemma (*equal_union: *) - "(X = Y \ Z) = - (Y \ X \ Z \ X \ (\V. Y \ V \ Z \ V \ X \ V))" -proof (neg_clausify) -fix x -assume 0: "Y \ X \ X = Y \ Z" -assume 1: "Z \ X \ X = Y \ Z" -assume 2: "(\ Y \ X \ \ Z \ X \ Y \ x) \ X \ Y \ Z" -assume 3: "(\ Y \ X \ \ Z \ X \ Z \ x) \ X \ Y \ Z" -assume 4: "(\ Y \ X \ \ Z \ X \ \ X \ x) \ X \ Y \ Z" -assume 5: "\V. ((\ Y \ V \ \ Z \ V) \ X \ V) \ X = Y \ Z" -have 6: "sup Y Z \ X \ \ X \ x \ \ Y \ X \ \ Z \ X" - by (metis 4) -have 7: "Z \ x \ sup Y Z \ X \ \ Y \ X" - by (metis 3 Un_upper2) -have 8: "Z \ x \ sup Y Z \ X" - by (metis 7 Un_upper1) -have 9: "sup Y Z = X \ \ Z \ X \ \ Y \ X" - by (metis equalityI 5 Un_upper2 Un_upper1 Un_least) -have 10: "Y \ x" - by (metis 2 Un_upper2 1 Un_upper1 0 9 Un_upper2 1 Un_upper1 0) -have 11: "X \ x" - by (metis Un_least 9 Un_upper2 1 Un_upper1 0 8 9 Un_upper2 1 Un_upper1 0 10) -show "False" - by (metis 11 6 Un_upper2 1 Un_upper1 0 9 Un_upper2 1 Un_upper1 0) -qed - -declare [[ atp_problem_prefix = "set__equal_union" ]] -lemma (*equal_union: *) - "(X = Y \ Z) = - (Y \ X \ Z \ X \ (\V. Y \ V \ Z \ V \ X \ V))" -(*One shot proof: hand-reduced. Metis can't do the full proof any more.*) -by (metis Un_least Un_upper1 Un_upper2 set_eq_subset) - - -declare [[ atp_problem_prefix = "set__equal_inter" ]] -lemma "(X = Y \ Z) = - (X \ Y \ X \ Z \ (\V. V \ Y \ V \ Z \ V \ X))" -by (metis Int_greatest Int_lower1 Int_lower2 set_eq_subset) - -declare [[ atp_problem_prefix = "set__fixedpoint" ]] -lemma fixedpoint: - "\!x. f (g x) = x \ \!y. g (f y) = y" -by metis - -lemma (*fixedpoint:*) - "\!x. f (g x) = x \ \!y. g (f y) = y" -proof (neg_clausify) -fix x xa -assume 0: "f (g x) = x" -assume 1: "\y. y = x \ f (g y) \ y" -assume 2: "\x. g (f (xa x)) = xa x \ g (f x) \ x" -assume 3: "\x. g (f x) \ x \ xa x \ x" -have 4: "\X1. g (f X1) \ X1 \ g x \ X1" - by (metis 3 1 2) -show "False" - by (metis 4 0) -qed - -declare [[ atp_problem_prefix = "set__singleton_example" ]] -lemma (*singleton_example_2:*) - "\x \ S. \S \ x \ \z. S \ {z}" -by (metis Set.subsetI Union_upper insertCI set_eq_subset) - --{*found by SPASS*} - -lemma (*singleton_example_2:*) - "\x \ S. \S \ x \ \z. S \ {z}" -by (metis Set.subsetI Union_upper insert_iff set_eq_subset) - -lemma singleton_example_2: - "\x \ S. \S \ x \ \z. S \ {z}" -proof (neg_clausify) -assume 0: "\x. \ S \ {x}" -assume 1: "\x. x \ S \ \S \ x" -have 2: "\X3. X3 = \S \ \ X3 \ \S \ X3 \ S" - by (metis set_eq_subset 1) -have 3: "\X3. S \ insert (\S) X3" - by (metis insert_iff Set.subsetI Union_upper 2 Set.subsetI) -show "False" - by (metis 3 0) -qed - - - -text {* - From W. W. Bledsoe and Guohui Feng, SET-VAR. JAR 11 (3), 1993, pages - 293-314. -*} - -declare [[ atp_problem_prefix = "set__Bledsoe_Fung" ]] -(*Notes: 1, the numbering doesn't completely agree with the paper. -2, we must rename set variables to avoid type clashes.*) -lemma "\B. (\x \ B. x \ (0::int))" - "D \ F \ \G. \A \ G. \B \ F. A \ B" - "P a \ \A. (\x \ A. P x) \ (\y. y \ A)" - "a < b \ b < (c::int) \ \B. a \ B \ b \ B \ c \ B" - "P (f b) \ \s A. (\x \ A. P x) \ f s \ A" - "P (f b) \ \s A. (\x \ A. P x) \ f s \ A" - "\A. a \ A" - "(\C. (0, 0) \ C \ (\x y. (x, y) \ C \ (Suc x, Suc y) \ C) \ (n, m) \ C) \ Q n \ Q m" -apply (metis atMost_iff) -apply (metis emptyE) -apply (metis insert_iff singletonE) -apply (metis insertCI singletonE zless_le) -apply (metis Collect_def Collect_mem_eq) -apply (metis Collect_def Collect_mem_eq) -apply (metis DiffE) -apply (metis pair_in_Id_conv) -done - -end