src/HOL/Metis_Examples/Clausification.thy
author blanchet
Tue Jun 07 08:52:35 2011 +0200 (2011-06-07)
changeset 43228 2ed2f092e990
parent 43197 c71657bbdbc0
child 47308 9caab698dbe4
permissions -rw-r--r--
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
     1 (*  Title:      HOL/Metis_Examples/Clausification.thy
     2     Author:     Jasmin Blanchette, TU Muenchen
     3 
     4 Example that exercises Metis's Clausifier.
     5 *)
     6 
     7 header {* Example that Exercises Metis's Clausifier *}
     8 
     9 theory Clausification
    10 imports Complex_Main
    11 begin
    12 
    13 (* FIXME: shouldn't need this *)
    14 declare [[unify_search_bound = 100]]
    15 declare [[unify_trace_bound = 100]]
    16 
    17 
    18 text {* Definitional CNF for facts *}
    19 
    20 declare [[meson_max_clauses = 10]]
    21 
    22 axiomatization q :: "nat \<Rightarrow> nat \<Rightarrow> bool" where
    23 qax: "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)"
    24 
    25 declare [[metis_new_skolemizer = false]]
    26 
    27 lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)"
    28 by (metis qax)
    29 
    30 lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)"
    31 by (metis (full_types) qax)
    32 
    33 lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)"
    34 by (metis qax)
    35 
    36 lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)"
    37 by (metis (full_types) qax)
    38 
    39 declare [[metis_new_skolemizer]]
    40 
    41 lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)"
    42 by (metis qax)
    43 
    44 lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)"
    45 by (metis (full_types) qax)
    46 
    47 lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)"
    48 by (metis qax)
    49 
    50 lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)"
    51 by (metis (full_types) qax)
    52 
    53 declare [[meson_max_clauses = 60]]
    54 
    55 axiomatization r :: "nat \<Rightarrow> nat \<Rightarrow> bool" where
    56 rax: "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or>
    57       (r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or>
    58       (r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or>
    59       (r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)"
    60 
    61 declare [[metis_new_skolemizer = false]]
    62 
    63 lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3"
    64 by (metis rax)
    65 
    66 lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3"
    67 by (metis (full_types) rax)
    68 
    69 declare [[metis_new_skolemizer]]
    70 
    71 lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3"
    72 by (metis rax)
    73 
    74 lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3"
    75 by (metis (full_types) rax)
    76 
    77 lemma "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or>
    78        (r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or>
    79        (r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or>
    80        (r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)"
    81 by (metis rax)
    82 
    83 lemma "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or>
    84        (r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or>
    85        (r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or>
    86        (r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)"
    87 by (metis (full_types) rax)
    88 
    89 
    90 text {* Definitional CNF for goal *}
    91 
    92 axiomatization p :: "nat \<Rightarrow> nat \<Rightarrow> bool" where
    93 pax: "\<exists>b. \<forall>a. (p b a \<and> p 0 0 \<and> p 1 a) \<or> (p 0 1 \<and> p 1 0 \<and> p a b)"
    94 
    95 declare [[metis_new_skolemizer = false]]
    96 
    97 lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and>
    98                    (p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)"
    99 by (metis pax)
   100 
   101 lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and>
   102                    (p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)"
   103 by (metis (full_types) pax)
   104 
   105 declare [[metis_new_skolemizer]]
   106 
   107 lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and>
   108                    (p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)"
   109 by (metis pax)
   110 
   111 lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and>
   112                    (p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)"
   113 by (metis (full_types) pax)
   114 
   115 
   116 text {* New Skolemizer *}
   117 
   118 declare [[metis_new_skolemizer]]
   119 
   120 lemma
   121   fixes x :: real
   122   assumes fn_le: "!!n. f n \<le> x" and 1: "f ----> lim f"
   123   shows "lim f \<le> x"
   124 by (metis 1 LIMSEQ_le_const2 fn_le)
   125 
   126 definition
   127   bounded :: "'a::metric_space set \<Rightarrow> bool" where
   128   "bounded S \<longleftrightarrow> (\<exists>x eee. \<forall>y\<in>S. dist x y \<le> eee)"
   129 
   130 lemma "bounded T \<Longrightarrow> S \<subseteq> T ==> bounded S"
   131 by (metis bounded_def subset_eq)
   132 
   133 lemma
   134   assumes a: "Quotient R Abs Rep"
   135   shows "symp R"
   136 using a unfolding Quotient_def using sympI
   137 by (metis (full_types))
   138 
   139 lemma
   140   "(\<exists>x \<in> set xs. P x) \<longleftrightarrow>
   141    (\<exists>ys x zs. xs = ys @ x # zs \<and> P x \<and> (\<forall>z \<in> set zs. \<not> P z))"
   142 by (metis split_list_last_prop [where P = P] in_set_conv_decomp)
   143 
   144 lemma ex_tl: "EX ys. tl ys = xs"
   145 using tl.simps(2) by fast
   146 
   147 lemma "(\<exists>ys\<Colon>nat list. tl ys = xs) \<and> (\<exists>bs\<Colon>int list. tl bs = as)"
   148 by (metis ex_tl)
   149 
   150 end