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