src/HOL/SMT/Examples/SMT_Examples.thy
author boehmes
Wed, 18 Nov 2009 09:34:53 +0100
changeset 33748 dd5513734567
parent 33472 e88f67d679c4
child 34984 faeee0e4ac50
permissions -rw-r--r--
added arithmetic example using div and mod
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
     1
(*  Title:      HOL/SMT/SMT_Examples.thy
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
     2
    Author:     Sascha Boehme, TU Muenchen
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
     3
*)
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
     4
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
     5
header {* Examples for the 'smt' tactic. *}
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
     6
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
     7
theory SMT_Examples
33465
boehmes
parents: 33446
diff changeset
     8
imports SMT
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
     9
begin
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    10
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    11
declare [[smt_solver=z3, z3_proofs=true]]
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    12
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    13
text {*
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    14
To re-generate the certificates, replace the option 'smt_cert' with 'smt_keep'
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    15
(while keeping the paths as they are) and let Isabelle process this theory.
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    16
*}
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    17
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    18
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    19
section {* Propositional and first-order logic *}
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    20
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    21
lemma "True"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    22
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    23
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    24
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    25
lemma "p \<or> \<not>p"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    26
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    27
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    28
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    29
lemma "(p \<and> True) = p"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    30
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_03"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    31
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    32
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    33
lemma "(p \<or> q) \<and> \<not>p \<Longrightarrow> q"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    34
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_04"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    35
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    36
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    37
lemma "(a \<and> b) \<or> (c \<and> d) \<Longrightarrow> (a \<and> b) \<or> (c \<and> d)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    38
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_05"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    39
  using [[z3_proofs=false]] (* no Z3 proof *)
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    40
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    41
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    42
lemma "(p1 \<and> p2) \<or> p3 \<longrightarrow> (p1 \<longrightarrow> (p3 \<and> p2) \<or> (p1 \<and> p3)) \<or> p1"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    43
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_06"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    44
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    45
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    46
lemma "P=P=P=P=P=P=P=P=P=P"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    47
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_07"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    48
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    49
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    50
lemma 
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    51
  assumes "a | b | c | d"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    52
      and "e | f | (a & d)"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    53
      and "~(a | (c & ~c)) | b"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    54
      and "~(b & (x | ~x)) | c"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    55
      and "~(d | False) | c"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    56
      and "~(c | (~p & (p | (q & ~q))))"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    57
  shows False
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    58
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_08"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    59
  using assms by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    60
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    61
axiomatization symm_f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
    62
  symm_f: "symm_f x y = symm_f y x"
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    63
lemma "a = a \<and> symm_f a b = symm_f b a"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
    64
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_09"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
    65
  by (smt symm_f)
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    66
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    67
(* 
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    68
Taken from ~~/src/HOL/ex/SAT_Examples.thy.
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    69
Translated from TPTP problem library: PUZ015-2.006.dimacs
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    70
*)
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    71
lemma 
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    72
  assumes "~x0"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    73
  and "~x30"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    74
  and "~x29"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    75
  and "~x59"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    76
  and "x1 | x31 | x0"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    77
  and "x2 | x32 | x1"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    78
  and "x3 | x33 | x2"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    79
  and "x4 | x34 | x3"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    80
  and "x35 | x4"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    81
  and "x5 | x36 | x30"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    82
  and "x6 | x37 | x5 | x31"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    83
  and "x7 | x38 | x6 | x32"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    84
  and "x8 | x39 | x7 | x33"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    85
  and "x9 | x40 | x8 | x34"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    86
  and "x41 | x9 | x35"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    87
  and "x10 | x42 | x36"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    88
  and "x11 | x43 | x10 | x37"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    89
  and "x12 | x44 | x11 | x38"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    90
  and "x13 | x45 | x12 | x39"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    91
  and "x14 | x46 | x13 | x40"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    92
  and "x47 | x14 | x41"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    93
  and "x15 | x48 | x42"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    94
  and "x16 | x49 | x15 | x43"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    95
  and "x17 | x50 | x16 | x44"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    96
  and "x18 | x51 | x17 | x45"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    97
  and "x19 | x52 | x18 | x46"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    98
  and "x53 | x19 | x47"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
    99
  and "x20 | x54 | x48"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   100
  and "x21 | x55 | x20 | x49"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   101
  and "x22 | x56 | x21 | x50"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   102
  and "x23 | x57 | x22 | x51"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   103
  and "x24 | x58 | x23 | x52"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   104
  and "x59 | x24 | x53"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   105
  and "x25 | x54"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   106
  and "x26 | x25 | x55"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   107
  and "x27 | x26 | x56"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   108
  and "x28 | x27 | x57"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   109
  and "x29 | x28 | x58"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   110
  and "~x1 | ~x31"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   111
  and "~x1 | ~x0"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   112
  and "~x31 | ~x0"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   113
  and "~x2 | ~x32"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   114
  and "~x2 | ~x1"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   115
  and "~x32 | ~x1"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   116
  and "~x3 | ~x33"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   117
  and "~x3 | ~x2"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   118
  and "~x33 | ~x2"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   119
  and "~x4 | ~x34"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   120
  and "~x4 | ~x3"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   121
  and "~x34 | ~x3"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   122
  and "~x35 | ~x4"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   123
  and "~x5 | ~x36"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   124
  and "~x5 | ~x30"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   125
  and "~x36 | ~x30"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   126
  and "~x6 | ~x37"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   127
  and "~x6 | ~x5"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   128
  and "~x6 | ~x31"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   129
  and "~x37 | ~x5"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   130
  and "~x37 | ~x31"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   131
  and "~x5 | ~x31"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   132
  and "~x7 | ~x38"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   133
  and "~x7 | ~x6"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   134
  and "~x7 | ~x32"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   135
  and "~x38 | ~x6"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   136
  and "~x38 | ~x32"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   137
  and "~x6 | ~x32"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   138
  and "~x8 | ~x39"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   139
  and "~x8 | ~x7"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   140
  and "~x8 | ~x33"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   141
  and "~x39 | ~x7"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   142
  and "~x39 | ~x33"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   143
  and "~x7 | ~x33"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   144
  and "~x9 | ~x40"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   145
  and "~x9 | ~x8"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   146
  and "~x9 | ~x34"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   147
  and "~x40 | ~x8"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   148
  and "~x40 | ~x34"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   149
  and "~x8 | ~x34"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   150
  and "~x41 | ~x9"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   151
  and "~x41 | ~x35"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   152
  and "~x9 | ~x35"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   153
  and "~x10 | ~x42"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   154
  and "~x10 | ~x36"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   155
  and "~x42 | ~x36"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   156
  and "~x11 | ~x43"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   157
  and "~x11 | ~x10"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   158
  and "~x11 | ~x37"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   159
  and "~x43 | ~x10"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   160
  and "~x43 | ~x37"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   161
  and "~x10 | ~x37"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   162
  and "~x12 | ~x44"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   163
  and "~x12 | ~x11"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   164
  and "~x12 | ~x38"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   165
  and "~x44 | ~x11"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   166
  and "~x44 | ~x38"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   167
  and "~x11 | ~x38"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   168
  and "~x13 | ~x45"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   169
  and "~x13 | ~x12"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   170
  and "~x13 | ~x39"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   171
  and "~x45 | ~x12"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   172
  and "~x45 | ~x39"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   173
  and "~x12 | ~x39"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   174
  and "~x14 | ~x46"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   175
  and "~x14 | ~x13"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   176
  and "~x14 | ~x40"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   177
  and "~x46 | ~x13"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   178
  and "~x46 | ~x40"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   179
  and "~x13 | ~x40"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   180
  and "~x47 | ~x14"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   181
  and "~x47 | ~x41"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   182
  and "~x14 | ~x41"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   183
  and "~x15 | ~x48"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   184
  and "~x15 | ~x42"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   185
  and "~x48 | ~x42"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   186
  and "~x16 | ~x49"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   187
  and "~x16 | ~x15"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   188
  and "~x16 | ~x43"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   189
  and "~x49 | ~x15"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   190
  and "~x49 | ~x43"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   191
  and "~x15 | ~x43"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   192
  and "~x17 | ~x50"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   193
  and "~x17 | ~x16"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   194
  and "~x17 | ~x44"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   195
  and "~x50 | ~x16"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   196
  and "~x50 | ~x44"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   197
  and "~x16 | ~x44"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   198
  and "~x18 | ~x51"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   199
  and "~x18 | ~x17"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   200
  and "~x18 | ~x45"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   201
  and "~x51 | ~x17"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   202
  and "~x51 | ~x45"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   203
  and "~x17 | ~x45"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   204
  and "~x19 | ~x52"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   205
  and "~x19 | ~x18"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   206
  and "~x19 | ~x46"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   207
  and "~x52 | ~x18"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   208
  and "~x52 | ~x46"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   209
  and "~x18 | ~x46"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   210
  and "~x53 | ~x19"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   211
  and "~x53 | ~x47"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   212
  and "~x19 | ~x47"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   213
  and "~x20 | ~x54"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   214
  and "~x20 | ~x48"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   215
  and "~x54 | ~x48"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   216
  and "~x21 | ~x55"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   217
  and "~x21 | ~x20"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   218
  and "~x21 | ~x49"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   219
  and "~x55 | ~x20"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   220
  and "~x55 | ~x49"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   221
  and "~x20 | ~x49"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   222
  and "~x22 | ~x56"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   223
  and "~x22 | ~x21"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   224
  and "~x22 | ~x50"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   225
  and "~x56 | ~x21"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   226
  and "~x56 | ~x50"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   227
  and "~x21 | ~x50"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   228
  and "~x23 | ~x57"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   229
  and "~x23 | ~x22"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   230
  and "~x23 | ~x51"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   231
  and "~x57 | ~x22"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   232
  and "~x57 | ~x51"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   233
  and "~x22 | ~x51"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   234
  and "~x24 | ~x58"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   235
  and "~x24 | ~x23"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   236
  and "~x24 | ~x52"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   237
  and "~x58 | ~x23"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   238
  and "~x58 | ~x52"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   239
  and "~x23 | ~x52"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   240
  and "~x59 | ~x24"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   241
  and "~x59 | ~x53"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   242
  and "~x24 | ~x53"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   243
  and "~x25 | ~x54"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   244
  and "~x26 | ~x25"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   245
  and "~x26 | ~x55"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   246
  and "~x25 | ~x55"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   247
  and "~x27 | ~x26"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   248
  and "~x27 | ~x56"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   249
  and "~x26 | ~x56"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   250
  and "~x28 | ~x27"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   251
  and "~x28 | ~x57"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   252
  and "~x27 | ~x57"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   253
  and "~x29 | ~x28"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   254
  and "~x29 | ~x58"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   255
  and "~x28 | ~x58"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   256
  shows False
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   257
  using assms
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   258
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_prop_10"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   259
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   260
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   261
lemma "\<forall>x::int. P x \<longrightarrow> (\<forall>y::int. P x \<or> P y)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   262
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_fol_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   263
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   264
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   265
lemma 
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   266
  assumes "(\<forall>x y. P x y = x)"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   267
  shows "(\<exists>y. P x y) = P x c"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   268
  using assms 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   269
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_fol_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   270
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   271
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   272
lemma 
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   273
  assumes "(\<forall>x y. P x y = x)"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   274
  and "(\<forall>x. \<exists>y. P x y) = (\<forall>x. P x c)"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   275
  shows "(EX y. P x y) = P x c"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   276
  using assms
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   277
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_fol_03"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   278
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   279
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   280
lemma
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   281
  assumes "if P x then \<not>(\<exists>y. P y) else (\<forall>y. \<not>P y)"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   282
  shows "P x \<longrightarrow> P y"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   283
  using assms
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   284
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_fol_04"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   285
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   286
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   287
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   288
section {* Arithmetic *}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   289
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   290
subsection {* Linear arithmetic over integers and reals *}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   291
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   292
lemma "(3::int) = 3"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   293
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   294
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   295
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   296
lemma "(3::real) = 3"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   297
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   298
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   299
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   300
lemma "(3 :: int) + 1 = 4"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   301
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_03"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   302
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   303
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   304
lemma "x + (y + z) = y + (z + (x::int))"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   305
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_04"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   306
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   307
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   308
lemma "max (3::int) 8 > 5"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   309
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_05"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   310
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   311
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   312
lemma "abs (x :: real) + abs y \<ge> abs (x + y)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   313
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_06"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   314
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   315
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   316
lemma "P ((2::int) < 3) = P True"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   317
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_07"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   318
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   319
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   320
lemma "x + 3 \<ge> 4 \<or> x < (1::int)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   321
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_08"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   322
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   323
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   324
lemma
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   325
  assumes "x \<ge> (3::int)" and "y = x + 4"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   326
  shows "y - x > 0" 
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   327
  using assms
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   328
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_09"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   329
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   330
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   331
lemma "let x = (2 :: int) in x + x \<noteq> 5"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   332
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_10"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   333
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   334
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   335
lemma
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   336
  fixes x :: real
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   337
  assumes "3 * x + 7 * a < 4" and "3 < 2 * x"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   338
  shows "a < 0"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   339
  using assms
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   340
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_11"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   341
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   342
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   343
lemma "(0 \<le> y + -1 * x \<or> \<not> 0 \<le> x \<or> 0 \<le> (x::int)) = (\<not> False)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   344
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_12"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   345
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   346
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   347
lemma "distinct [x < (3::int), 3 \<le> x]"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   348
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_13"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   349
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   350
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   351
lemma
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   352
  assumes "a > (0::int)"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   353
  shows "distinct [a, a * 2, a - a]"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   354
  using assms
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   355
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_14"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   356
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   357
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   358
lemma "
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   359
  (n < m & m < n') | (n < m & m = n') | (n < n' & n' < m) |
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   360
  (n = n' & n' < m) | (n = m & m < n') |
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   361
  (n' < m & m < n) | (n' < m & m = n) |
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   362
  (n' < n & n < m) | (n' = n & n < m) | (n' = m & m < n) |
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   363
  (m < n & n < n') | (m < n & n' = n) | (m < n' & n' < n) |
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   364
  (m = n & n < n') | (m = n' & n' < n) |
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   365
  (n' = m & m = (n::int))"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   366
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_15"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   367
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   368
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   369
text{* 
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   370
The following example was taken from HOL/ex/PresburgerEx.thy, where it says:
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   371
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   372
  This following theorem proves that all solutions to the
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   373
  recurrence relation $x_{i+2} = |x_{i+1}| - x_i$ are periodic with
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   374
  period 9.  The example was brought to our attention by John
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   375
  Harrison. It does does not require Presburger arithmetic but merely
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   376
  quantifier-free linear arithmetic and holds for the rationals as well.
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   377
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   378
  Warning: it takes (in 2006) over 4.2 minutes! 
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   379
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   380
There, it is proved by "arith". SMT is able to prove this within a fraction
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   381
of one second. With proof reconstruction, it takes about 13 seconds on a Core2
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   382
processor.
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   383
*}
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   384
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   385
lemma "\<lbrakk> x3 = abs x2 - x1; x4 = abs x3 - x2; x5 = abs x4 - x3;
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   386
         x6 = abs x5 - x4; x7 = abs x6 - x5; x8 = abs x7 - x6;
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   387
         x9 = abs x8 - x7; x10 = abs x9 - x8; x11 = abs x10 - x9 \<rbrakk>
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   388
 \<Longrightarrow> x1 = x10 & x2 = (x11::int)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   389
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_16"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   390
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   391
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   392
33446
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   393
lemma "let P = 2 * x + 1 > x + (x::real) in P \<or> False \<or> P"
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   394
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_17"]]
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   395
  by smt
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   396
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   397
lemma "x + (let y = x mod 2 in 2 * y + 1) \<ge> x + (1::int)"
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   398
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_18"]]
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   399
  by smt
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   400
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   401
lemma "x + (let y = x mod 2 in y + y) < x + (3::int)"
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   402
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_19"]]
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   403
  by smt
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   404
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   405
lemma 
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   406
  assumes "x \<noteq> (0::real)"
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   407
  shows "x + x \<noteq> (let P = (abs x > 1) in if P \<or> \<not>P then 4 else 2) * x"
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   408
  using assms
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   409
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_20"]]
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   410
  by smt
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   411
33748
dd5513734567 added arithmetic example using div and mod
boehmes
parents: 33472
diff changeset
   412
lemma                                                                         
dd5513734567 added arithmetic example using div and mod
boehmes
parents: 33472
diff changeset
   413
  assumes "(n + m) mod 2 = 0" and "n mod 4 = 3"                               
dd5513734567 added arithmetic example using div and mod
boehmes
parents: 33472
diff changeset
   414
  shows "n mod 2 = 1 & m mod 2 = (1::int)"      
dd5513734567 added arithmetic example using div and mod
boehmes
parents: 33472
diff changeset
   415
  using assms
dd5513734567 added arithmetic example using div and mod
boehmes
parents: 33472
diff changeset
   416
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_linarith_21"]]
dd5513734567 added arithmetic example using div and mod
boehmes
parents: 33472
diff changeset
   417
  by smt
dd5513734567 added arithmetic example using div and mod
boehmes
parents: 33472
diff changeset
   418
33446
153a27370a42 handle let expressions inside terms by unfolding (instead of raising an exception),
boehmes
parents: 33299
diff changeset
   419
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   420
subsection {* Linear arithmetic with quantifiers *}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   421
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   422
lemma "~ (\<exists>x::int. False)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   423
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   424
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   425
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   426
lemma "~ (\<exists>x::real. False)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   427
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   428
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   429
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   430
lemma "\<exists>x::int. 0 < x"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   431
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_03"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   432
  using [[z3_proofs=false]] (* no Z3 proof *)
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   433
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   434
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   435
lemma "\<exists>x::real. 0 < x"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   436
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_04"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   437
  using [[z3_proofs=false]] (* no Z3 proof *)
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   438
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   439
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   440
lemma "\<forall>x::int. \<exists>y. y > x"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   441
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_05"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   442
  using [[z3_proofs=false]] (* no Z3 proof *)
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   443
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   444
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   445
lemma "\<forall>x y::int. (x = 0 \<and> y = 1) \<longrightarrow> x \<noteq> y"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   446
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_06"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   447
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   448
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   449
lemma "\<exists>x::int. \<forall>y. x < y \<longrightarrow> y < 0 \<or> y >= 0"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   450
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_07"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   451
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   452
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   453
lemma "\<forall>x y::int. x < y \<longrightarrow> (2 * x + 1) < (2 * y)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   454
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_08"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   455
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   456
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   457
lemma "\<forall>x y::int. (2 * x + 1) \<noteq> (2 * y)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   458
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_09"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   459
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   460
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   461
lemma "\<forall>x y::int. x + y > 2 \<or> x + y = 2 \<or> x + y < 2"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   462
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_10"]]
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   463
  by smt
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   464
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   465
lemma "\<forall>x::int. if x > 0 then x + 1 > 0 else 1 > x"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   466
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_11"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   467
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   468
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   469
lemma "if (ALL x::int. x < 0 \<or> x > 0) then False else True"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   470
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_12"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   471
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   472
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   473
lemma "(if (ALL x::int. x < 0 \<or> x > 0) then -1 else 3) > (0::int)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   474
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_13"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   475
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   476
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   477
lemma "~ (\<exists>x y z::int. 4 * x + -6 * y = (1::int))"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   478
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_14"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   479
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   480
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   481
lemma "\<exists>x::int. \<forall>x y. 0 < x \<and> 0 < y \<longrightarrow> (0::int) < x + y"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   482
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_15"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   483
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   484
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   485
lemma "\<exists>u::int. \<forall>(x::int) y::real. 0 < x \<and> 0 < y \<longrightarrow> -1 < x"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   486
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_16"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   487
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   488
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   489
lemma "\<exists>x::int. (\<forall>y. y \<ge> x \<longrightarrow> y > 0) \<longrightarrow> x > 0"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   490
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_17"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   491
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   492
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   493
lemma "\<forall>x::int. trigger [pat x] (x < a \<longrightarrow> 2 * x < 2 * a)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   494
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_arith_quant_18"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   495
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   496
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   497
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   498
subsection {* Non-linear arithmetic over integers and reals *}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   499
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   500
lemma "a > (0::int) \<Longrightarrow> a*b > 0 \<Longrightarrow> b > 0"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   501
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nlarith_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   502
  using [[z3_proofs=false]]  -- {* Isabelle's arithmetic decision procedures
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   503
    are too weak to automatically prove @{thm zero_less_mult_pos}. *}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   504
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   505
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   506
lemma  "(a::int) * (x + 1 + y) = a * x + a * (y + 1)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   507
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nlarith_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   508
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   509
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   510
lemma "((x::real) * (1 + y) - x * (1 - y)) = (2 * x * y)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   511
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nlarith_03"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   512
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   513
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   514
lemma
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   515
  "(U::int) + (1 + p) * (b + e) + p * d =
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   516
   U + (2 * (1 + p) * (b + e) + (1 + p) * d + d * p) - (1 + p) * (b + d + e)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   517
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nlarith_04"]]
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   518
  by smt
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   519
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   520
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   521
subsection {* Linear arithmetic for natural numbers *}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   522
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   523
lemma "2 * (x::nat) ~= 1"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   524
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nat_arith_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   525
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   526
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   527
lemma "a < 3 \<Longrightarrow> (7::nat) > 2 * a"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   528
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nat_arith_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   529
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   530
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   531
lemma "let x = (1::nat) + y in x - y > 0 * x"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   532
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nat_arith_03"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   533
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   534
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   535
lemma
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   536
  "let x = (1::nat) + y in
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   537
   let P = (if x > 0 then True else False) in
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   538
   False \<or> P = (x - 1 = y) \<or> (\<not>P \<longrightarrow> False)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   539
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nat_arith_04"]]
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   540
  by smt
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   541
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   542
lemma "distinct [a + (1::nat), a * 2 + 3, a - a]"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   543
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nat_arith_05"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   544
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   545
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   546
lemma "int (nat \<bar>x::int\<bar>) = \<bar>x\<bar>"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   547
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nat_arith_06"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   548
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   549
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   550
definition prime_nat :: "nat \<Rightarrow> bool" where
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   551
  "prime_nat p = (1 < p \<and> (\<forall>m. m dvd p --> m = 1 \<or> m = p))"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   552
lemma "prime_nat (4*m + 1) \<Longrightarrow> m \<ge> (1::nat)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   553
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_nat_arith_07"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
   554
  by (smt prime_nat_def)
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   555
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   556
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   557
section {* Bitvectors *}
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   558
33472
e88f67d679c4 added documentation for local SMT solver setup and available SMT options,
boehmes
parents: 33465
diff changeset
   559
locale z3_bv_test
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   560
begin
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   561
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   562
text {*
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   563
The following examples only work for Z3, and only without proof reconstruction.
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   564
*}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   565
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   566
declare [[smt_solver=z3, z3_proofs=false]]
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   567
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   568
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   569
subsection {* Bitvector arithmetic *}
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   570
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   571
lemma "(27 :: 4 word) = -5" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   572
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   573
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   574
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   575
lemma "(27 :: 4 word) = 11"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   576
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   577
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   578
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   579
lemma "23 < (27::8 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   580
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_03"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   581
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   582
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   583
lemma "27 + 11 = (6::5 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   584
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_04"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   585
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   586
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   587
lemma "7 * 3 = (21::8 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   588
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_05"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   589
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   590
lemma "11 - 27 = (-16::8 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   591
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_06"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   592
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   593
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   594
lemma "- -11 = (11::5 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   595
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_07"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   596
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   597
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   598
lemma "-40 + 1 = (-39::7 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   599
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_08"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   600
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   601
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   602
lemma "a + 2 * b + c - b = (b + c) + (a :: 32 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   603
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_09"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   604
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   605
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   606
lemma "x = (5 :: 4 word) \<Longrightarrow> 4 * x = 4" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   607
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_arith_10"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   608
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   609
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   610
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   611
subsection {* Bit-level logic *}
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   612
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   613
lemma "0b110 AND 0b101 = (0b100 :: 32 word)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   614
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   615
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   616
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   617
lemma "0b110 OR 0b011 = (0b111 :: 8 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   618
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   619
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   620
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   621
lemma "0xF0 XOR 0xFF = (0x0F :: 8 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   622
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_03"]]
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   623
  by smt
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   624
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   625
lemma "NOT (0xF0 :: 16 word) = 0xFF0F" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   626
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_04"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   627
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   628
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   629
lemma "word_cat (27::4 word) (27::8 word) = (2843::12 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   630
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_05"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   631
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   632
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   633
lemma "word_cat (0b0011::4 word) (0b1111::6word) = (0b0011001111 :: 10 word)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   634
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_06"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   635
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   636
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   637
lemma "slice 1 (0b10110 :: 4 word) = (0b11 :: 2 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   638
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_07"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   639
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   640
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   641
lemma "ucast (0b1010 :: 4 word) = (0b1010 :: 10 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   642
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_08"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   643
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   644
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   645
lemma "scast (0b1010 :: 4 word) = (0b111010 :: 6 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   646
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_09"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   647
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   648
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   649
lemma "bv_lshr 0b10011 2 = (0b100::8 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   650
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_10"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   651
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   652
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   653
lemma "bv_ashr 0b10011 2 = (0b100::8 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   654
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_11"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   655
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   656
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   657
lemma "word_rotr 2 0b0110 = (0b1001::4 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   658
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_12"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   659
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   660
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   661
lemma "word_rotl 1 0b1110 = (0b1101::4 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   662
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_13"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   663
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   664
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   665
lemma "(x AND 0xff00) OR (x AND 0x00ff) = (x::16 word)" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   666
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_14"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   667
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   668
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   669
lemma "w < 256 \<Longrightarrow> (w :: 16 word) AND 0x00FF = w" 
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   670
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_bit_15"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   671
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   672
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   673
end
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   674
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   675
lemma
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   676
  assumes "bv2int 0 = 0"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   677
      and "bv2int 1 = 1"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   678
      and "bv2int 2 = 2"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   679
      and "bv2int 3 = 3"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   680
      and "\<forall>x::2 word. bv2int x > 0"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   681
  shows "\<forall>i::int. i < 0 \<longrightarrow> (\<forall>x::2 word. bv2int x > i)"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   682
  using assms 
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   683
  using [[smt_solver=z3]]
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   684
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   685
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   686
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   687
lemma "P (0 \<le> (a :: 4 word)) = P True"
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   688
  using [[smt_solver=z3, z3_proofs=false]]
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   689
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_bv_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   690
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   691
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   692
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   693
section {* Pairs *}
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   694
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   695
lemma "fst (x, y) = a \<Longrightarrow> x = a"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   696
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_pair_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   697
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   698
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   699
lemma "p1 = (x, y) \<and> p2 = (y, x) \<Longrightarrow> fst p1 = snd p2"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   700
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_pair_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   701
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   702
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   703
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   704
section {* Higher-order problems and recursion *}
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   705
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   706
lemma "i \<noteq> i1 \<and> i \<noteq> i2 \<Longrightarrow> (f (i1 := v1, i2 := v2)) i = f i"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   707
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_01"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   708
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   709
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   710
lemma "(f g x = (g x \<and> True)) \<or> (f g x = True) \<or> (g x = True)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   711
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_02"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   712
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   713
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   714
lemma "id 3 = 3 \<and> id True = True"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   715
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_03"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
   716
  by (smt id_def)
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   717
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   718
lemma "i \<noteq> i1 \<and> i \<noteq> i2 \<Longrightarrow> ((f (i1 := v1)) (i2 := v2)) i = f i"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   719
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_04"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   720
  by smt
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   721
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   722
lemma "map (\<lambda>i::nat. i + 1) [0, 1] = [1, 2]"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   723
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_05"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
   724
  by (smt map.simps)
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   725
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   726
lemma "(ALL x. P x) | ~ All P"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   727
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_06"]]
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   728
  by smt
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   729
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   730
fun dec_10 :: "nat \<Rightarrow> nat" where
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   731
  "dec_10 n = (if n < 10 then n else dec_10 (n - 10))"
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   732
lemma "dec_10 (4 * dec_10 4) = 6"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   733
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_07"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
   734
  by (smt dec_10.simps)
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   735
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   736
axiomatization
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   737
  eval_dioph :: "int list \<Rightarrow> nat list \<Rightarrow> int"
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   738
  where
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   739
  eval_dioph_mod:
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   740
  "eval_dioph ks xs mod int n = eval_dioph ks (map (\<lambda>x. x mod n) xs) mod int n"
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   741
  and
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   742
  eval_dioph_div_mult:
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   743
  "eval_dioph ks (map (\<lambda>x. x div n) xs) * int n +
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   744
   eval_dioph ks (map (\<lambda>x. x mod n) xs) = eval_dioph ks xs"
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   745
lemma
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   746
  "(eval_dioph ks xs = l) =
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   747
   (eval_dioph ks (map (\<lambda>x. x mod 2) xs) mod 2 = l mod 2 \<and>
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   748
    eval_dioph ks (map (\<lambda>x. x div 2) xs) =
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   749
      (l - eval_dioph ks (map (\<lambda>x. x mod 2) xs)) div 2)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   750
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_hol_08"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
   751
  by (smt eval_dioph_mod[where n=2] eval_dioph_div_mult[where n=2])
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   752
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   753
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   754
section {* Monomorphization examples *}
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   755
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   756
definition P :: "'a \<Rightarrow> bool" where "P x = True"
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   757
lemma poly_P: "P x \<and> (P [x] \<or> \<not>P[x])" by (simp add: P_def)
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   758
lemma "P (1::int)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   759
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_mono_01"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
   760
  by (smt poly_P)
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   761
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   762
consts g :: "'a \<Rightarrow> nat"
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   763
axioms
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   764
  g1: "g (Some x) = g [x]"
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   765
  g2: "g None = g []"
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   766
  g3: "g xs = length xs"
33010
39f73a59e855 added proof reconstructon for Z3,
boehmes
parents: 32622
diff changeset
   767
lemma "g (Some (3::int)) = g (Some True)"
33011
ab599f7f2639 corrected paths to certificates,
boehmes
parents: 33010
diff changeset
   768
  using [[smt_cert="$ISABELLE_SMT/Examples/cert/z3_mono_02"]]
33299
73af7831ba1e simplified method syntax of "smt",
boehmes
parents: 33011
diff changeset
   769
  by (smt g1 g2 g3 list.size)
32618
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   770
42865636d006 added new method "smt": an oracle-based connection to external SMT solvers
boehmes
parents:
diff changeset
   771
end