src/HOL/ex/svc_test.thy
author nipkow
Fri Mar 06 17:38:47 2009 +0100 (2009-03-06)
changeset 30313 b2441b0c8d38
parent 20807 bd3b60f9a343
child 41589 bbd861837ebc
permissions -rw-r--r--
added lemmas
     1 
     2 (* $Id$ *)
     3 
     4 header {* Demonstrating the interface SVC *}
     5 
     6 theory svc_test
     7 imports SVC_Oracle
     8 begin
     9 
    10 subsubsection {* Propositional Logic *}
    11 
    12 text {*
    13   @{text "blast"}'s runtime for this type of problem appears to be exponential
    14   in its length, though @{text "fast"} manages.
    15 *}
    16 lemma "P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P=P"
    17   by (tactic {* svc_tac 1 *})
    18 
    19 
    20 subsection {* Some big tautologies supplied by John Harrison *}
    21 
    22 text {*
    23   @{text "auto"} manages; @{text "blast"} and @{text "fast"} take a minute or more.
    24 *}
    25 lemma puz013_1: "~(~v12 &
    26    v0 &
    27    v10 &
    28    (v4 | v5) &
    29    (v9 | v2) &
    30    (v8 | v1) &
    31    (v7 | v0) &
    32    (v3 | v12) &
    33    (v11 | v10) &
    34    (~v12 | ~v6 | v7) &
    35    (~v10 | ~v3 | v1) &
    36    (~v10 | ~v0 | ~v4 | v11) &
    37    (~v5 | ~v2 | ~v8) &
    38    (~v12 | ~v9 | ~v7) &
    39    (~v0 | ~v1 | v4) &
    40    (~v4 | v7 | v2) &
    41    (~v12 | ~v3 | v8) &
    42    (~v4 | v5 | v6) &
    43    (~v7 | ~v8 | v9) &
    44    (~v10 | ~v11 | v12))"
    45   by (tactic {* svc_tac 1 *})
    46 
    47 lemma dk17_be:
    48   "(GE17 <-> ~IN4 & ~IN3 & ~IN2 & ~IN1) &
    49     (GE0 <-> GE17 & ~IN5) &
    50     (GE22 <-> ~IN9 & ~IN7 & ~IN6 & IN0) &
    51     (GE19 <-> ~IN5 & ~IN4 & ~IN3 & ~IN0) &
    52     (GE20 <-> ~IN7 & ~IN6) &
    53     (GE18 <-> ~IN6 & ~IN2 & ~IN1 & ~IN0) &
    54     (GE21 <-> IN9 & ~IN7 & IN6 & ~IN0) &
    55     (GE23 <-> GE22 & GE0) &
    56     (GE25 <-> ~IN9 & ~IN7 & IN6 & ~IN0) &
    57     (GE26 <-> IN9 & ~IN7 & ~IN6 & IN0) &
    58     (GE2 <-> GE20 & GE19) &
    59     (GE1 <-> GE18 & ~IN7) &
    60     (GE24 <-> GE23 | GE21 & GE0) &
    61     (GE5 <-> ~IN5 & IN4 | IN5 & ~IN4) &
    62     (GE6 <-> GE0 & IN7 & ~IN6 & ~IN0) &
    63     (GE12 <-> GE26 & GE0 | GE25 & GE0) &
    64     (GE14 <-> GE2 & IN8 & ~IN2 & IN1) &
    65     (GE27 <-> ~IN8 & IN5 & ~IN4 & ~IN3) &
    66     (GE9 <-> GE1 & ~IN5 & ~IN4 & IN3) &
    67     (GE7 <-> GE24 | GE2 & IN2 & ~IN1) &
    68     (GE10 <-> GE6 | GE5 & GE1 & ~IN3) &
    69     (GE15 <-> ~IN8 | IN9) &
    70     (GE16 <-> GE12 | GE14 & ~IN9) &
    71     (GE4 <->
    72      GE5 & GE1 & IN8 & ~IN3 |
    73      GE0 & ~IN7 & IN6 & ~IN0 |
    74      GE2 & IN2 & ~IN1) &
    75     (GE13 <-> GE27 & GE1) &
    76     (GE11 <-> GE9 | GE6 & ~IN8) &
    77     (GE8 <-> GE1 & ~IN5 & IN4 & ~IN3 | GE2 & ~IN2 & IN1) &
    78     (OUT0 <-> GE7 & ~IN8) &
    79     (OUT1 <-> GE7 & IN8) &
    80     (OUT2 <-> GE8 & ~IN9 | GE10 & IN8) &
    81     (OUT3 <-> GE8 & IN9 & ~IN8 | GE11 & ~IN9 | GE12 & ~IN8) &
    82     (OUT4 <-> GE11 & IN9 | GE12 & IN8) &
    83     (OUT5 <-> GE14 & IN9) &
    84     (OUT6 <-> GE13 & ~IN9) &
    85     (OUT7 <-> GE13 & IN9) &
    86     (OUT8 <-> GE9 & ~IN8 | GE15 & GE6 | GE4 & IN9) &
    87     (OUT9 <-> GE9 & IN8 | ~GE15 & GE10 | GE16) &
    88     (OUT10 <-> GE7) &
    89     (WRES0 <-> ~IN5 & ~IN4 & ~IN3 & ~IN2 & ~IN1) &
    90     (WRES1 <-> ~IN7 & ~IN6 & ~IN2 & ~IN1 & ~IN0) &
    91     (WRES2 <-> ~IN7 & ~IN6 & ~IN5 & ~IN4 & ~IN3 & ~IN0) &
    92     (WRES5 <-> ~IN5 & IN4 | IN5 & ~IN4) &
    93     (WRES6 <-> WRES0 & IN7 & ~IN6 & ~IN0) &
    94     (WRES9 <-> WRES1 & ~IN5 & ~IN4 & IN3) &
    95     (WRES7 <->
    96      WRES0 & ~IN9 & ~IN7 & ~IN6 & IN0 |
    97      WRES0 & IN9 & ~IN7 & IN6 & ~IN0 |
    98      WRES2 & IN2 & ~IN1) &
    99     (WRES10 <-> WRES6 | WRES5 & WRES1 & ~IN3) &
   100     (WRES12 <->
   101      WRES0 & IN9 & ~IN7 & ~IN6 & IN0 |
   102      WRES0 & ~IN9 & ~IN7 & IN6 & ~IN0) &
   103     (WRES14 <-> WRES2 & IN8 & ~IN2 & IN1) &
   104     (WRES15 <-> ~IN8 | IN9) &
   105     (WRES4 <->
   106      WRES5 & WRES1 & IN8 & ~IN3 |
   107      WRES2 & IN2 & ~IN1 |
   108      WRES0 & ~IN7 & IN6 & ~IN0) &
   109     (WRES13 <-> WRES1 & ~IN8 & IN5 & ~IN4 & ~IN3) &
   110     (WRES11 <-> WRES9 | WRES6 & ~IN8) &
   111     (WRES8 <-> WRES1 & ~IN5 & IN4 & ~IN3 | WRES2 & ~IN2 & IN1)
   112     --> (OUT10 <-> WRES7) &
   113         (OUT9 <-> WRES9 & IN8 | WRES12 | WRES14 & ~IN9 | ~WRES15 & WRES10) &
   114         (OUT8 <-> WRES9 & ~IN8 | WRES15 & WRES6 | WRES4 & IN9) &
   115         (OUT7 <-> WRES13 & IN9) &
   116         (OUT6 <-> WRES13 & ~IN9) &
   117         (OUT5 <-> WRES14 & IN9) &
   118         (OUT4 <-> WRES11 & IN9 | WRES12 & IN8) &
   119         (OUT3 <-> WRES8 & IN9 & ~IN8 | WRES11 & ~IN9 | WRES12 & ~IN8) &
   120         (OUT2 <-> WRES8 & ~IN9 | WRES10 & IN8) &
   121         (OUT1 <-> WRES7 & IN8) &
   122         (OUT0 <-> WRES7 & ~IN8)"
   123   by (tactic {* svc_tac 1 *})
   124 
   125 text {* @{text "fast"} only takes a couple of seconds. *}
   126 
   127 lemma sqn_be: "(GE0 <-> IN6 & IN1 | ~IN6 & ~IN1) &
   128    (GE8 <-> ~IN3 & ~IN1) &
   129    (GE5 <-> IN6 | IN5) &
   130    (GE9 <-> ~GE0 | IN2 | ~IN5) &
   131    (GE1 <-> IN3 | ~IN0) &
   132    (GE11 <-> GE8 & IN4) &
   133    (GE3 <-> ~IN4 | ~IN2) &
   134    (GE34 <-> ~GE5 & IN4 | ~GE9) &
   135    (GE2 <-> ~IN4 & IN1) &
   136    (GE14 <-> ~GE1 & ~IN4) &
   137    (GE19 <-> GE11 & ~GE5) &
   138    (GE13 <-> GE8 & ~GE3 & ~IN0) &
   139    (GE20 <-> ~IN5 & IN2 | GE34) &
   140    (GE12 <-> GE2 & ~IN3) &
   141    (GE27 <-> GE14 & IN6 | GE19) &
   142    (GE10 <-> ~IN6 | IN5) &
   143    (GE28 <-> GE13 | GE20 & ~GE1) &
   144    (GE6 <-> ~IN5 | IN6) &
   145    (GE15 <-> GE2 & IN2) &
   146    (GE29 <-> GE27 | GE12 & GE5) &
   147    (GE4 <-> IN3 & ~IN0) &
   148    (GE21 <-> ~GE10 & ~IN1 | ~IN5 & ~IN2) &
   149    (GE30 <-> GE28 | GE14 & IN2) &
   150    (GE31 <-> GE29 | GE15 & ~GE6) &
   151    (GE7 <-> ~IN6 | ~IN5) &
   152    (GE17 <-> ~GE3 & ~IN1) &
   153    (GE18 <-> GE4 & IN2) &
   154    (GE16 <-> GE2 & IN0) &
   155    (GE23 <-> GE19 | GE9 & ~GE1) &
   156    (GE32 <-> GE15 & ~IN6 & ~IN0 | GE21 & GE4 & ~IN4 | GE30 | GE31) &
   157    (GE33 <->
   158     GE18 & ~GE6 & ~IN4 |
   159     GE17 & ~GE7 & IN3 |
   160     ~GE7 & GE4 & ~GE3 |
   161     GE11 & IN5 & ~IN0) &
   162    (GE25 <-> GE14 & ~GE6 | GE13 & ~GE5 | GE16 & ~IN5 | GE15 & GE1) &
   163    (GE26 <->
   164     GE12 & IN5 & ~IN2 |
   165     GE10 & GE4 & IN1 |
   166     GE17 & ~GE6 & IN0 |
   167     GE2 & ~IN6) &
   168    (GE24 <-> GE23 | GE16 & GE7) &
   169    (OUT0 <->
   170     GE6 & IN4 & ~IN1 & IN0 | GE18 & GE0 & ~IN5 | GE12 & ~GE10 | GE24) &
   171    (OUT1 <-> GE26 | GE25 | ~GE5 & GE4 & GE3 | GE7 & ~GE1 & IN1) &
   172    (OUT2 <-> GE33 | GE32) &
   173    (WRES8 <-> ~IN3 & ~IN1) &
   174    (WRES0 <-> IN6 & IN1 | ~IN6 & ~IN1) &
   175    (WRES2 <-> ~IN4 & IN1) &
   176    (WRES3 <-> ~IN4 | ~IN2) &
   177    (WRES1 <-> IN3 | ~IN0) &
   178    (WRES4 <-> IN3 & ~IN0) &
   179    (WRES5 <-> IN6 | IN5) &
   180    (WRES11 <-> WRES8 & IN4) &
   181    (WRES9 <-> ~WRES0 | IN2 | ~IN5) &
   182    (WRES10 <-> ~IN6 | IN5) &
   183    (WRES6 <-> ~IN5 | IN6) &
   184    (WRES7 <-> ~IN6 | ~IN5) &
   185    (WRES12 <-> WRES2 & ~IN3) &
   186    (WRES13 <-> WRES8 & ~WRES3 & ~IN0) &
   187    (WRES14 <-> ~WRES1 & ~IN4) &
   188    (WRES15 <-> WRES2 & IN2) &
   189    (WRES17 <-> ~WRES3 & ~IN1) &
   190    (WRES18 <-> WRES4 & IN2) &
   191    (WRES19 <-> WRES11 & ~WRES5) &
   192    (WRES20 <-> ~IN5 & IN2 | ~WRES5 & IN4 | ~WRES9) &
   193    (WRES21 <-> ~WRES10 & ~IN1 | ~IN5 & ~IN2) &
   194    (WRES16 <-> WRES2 & IN0)
   195    --> (OUT2 <->
   196         WRES11 & IN5 & ~IN0 |
   197         ~WRES7 & WRES4 & ~WRES3 |
   198         WRES12 & WRES5 |
   199         WRES13 |
   200         WRES14 & IN2 |
   201         WRES14 & IN6 |
   202         WRES15 & ~WRES6 |
   203         WRES15 & ~IN6 & ~IN0 |
   204         WRES17 & ~WRES7 & IN3 |
   205         WRES18 & ~WRES6 & ~IN4 |
   206         WRES20 & ~WRES1 |
   207         WRES21 & WRES4 & ~IN4 |
   208         WRES19) &
   209        (OUT1 <->
   210         ~WRES5 & WRES4 & WRES3 |
   211         WRES7 & ~WRES1 & IN1 |
   212         WRES2 & ~IN6 |
   213         WRES10 & WRES4 & IN1 |
   214         WRES12 & IN5 & ~IN2 |
   215         WRES13 & ~WRES5 |
   216         WRES14 & ~WRES6 |
   217         WRES15 & WRES1 |
   218         WRES16 & ~IN5 |
   219         WRES17 & ~WRES6 & IN0) &
   220        (OUT0 <->
   221         WRES6 & IN4 & ~IN1 & IN0 |
   222         WRES9 & ~WRES1 |
   223         WRES12 & ~WRES10 |
   224         WRES16 & WRES7 |
   225         WRES18 & WRES0 & ~IN5 |
   226         WRES19)"
   227   by (tactic {* svc_tac 1 *})
   228 
   229 
   230 subsection {* Linear arithmetic *}
   231 
   232 lemma "x ~= 14 & x ~= 13 & x ~= 12 & x ~= 11 & x ~= 10 & x ~= 9 &
   233       x ~= 8 & x ~= 7 & x ~= 6 & x ~= 5 & x ~= 4 & x ~= 3 &
   234       x ~= 2 & x ~= 1 & 0 < x & x < 16 --> 15 = (x::int)"
   235   by (tactic {* svc_tac 1 *})
   236 
   237 text {*merely to test polarity handling in the presence of biconditionals*}
   238 lemma "(x < (y::int)) = (x+1 <= y)"
   239   by (tactic {* svc_tac 1 *})
   240 
   241 
   242 subsection {* Natural number examples requiring implicit "non-negative" assumptions *}
   243 
   244 lemma "(3::nat)*a <= 2 + 4*b + 6*c  & 11 <= 2*a + b + 2*c &
   245       a + 3*b <= 5 + 2*c  --> 2 + 3*b <= 2*a + 6*c"
   246   by (tactic {* svc_tac 1 *})
   247 
   248 lemma "(n::nat) < 2 ==> (n = 0) | (n = 1)"
   249   by (tactic {* svc_tac 1 *})
   250 
   251 end