src/HOL/SMT_Examples/SMT_Examples.thy
author wenzelm
Sun, 06 Jan 2019 15:04:34 +0100
changeset 69605 a96320074298
parent 67972 959b0aed2ce5
permissions -rw-r--r--
isabelle update -u path_cartouches;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36899
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
     1
(*  Title:      HOL/SMT_Examples/SMT_Examples.thy
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
     2
    Author:     Sascha Boehme, TU Muenchen
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
     3
*)
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
     4
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
     5
section \<open>Examples for the SMT binding\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
     6
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
     7
theory SMT_Examples
36899
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
     8
imports Complex_Main
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
     9
begin
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    10
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 67972
diff changeset
    11
external_file \<open>SMT_Examples.certs\<close>
58367
8af1e68d7e1a renamed SMT certificate files, following 'SMT2' -> 'SMT' renaming
blanchet
parents: 58061
diff changeset
    12
declare [[smt_certificates = "SMT_Examples.certs"]]
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    13
declare [[smt_read_only_certificates = true]]
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    14
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    15
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
    16
section \<open>Propositional and first-order logic\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    17
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    18
lemma "True" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    19
lemma "p \<or> \<not>p" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    20
lemma "(p \<and> True) = p" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    21
lemma "(p \<or> q) \<and> \<not>p \<Longrightarrow> q" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    22
lemma "(a \<and> b) \<or> (c \<and> d) \<Longrightarrow> (a \<and> b) \<or> (c \<and> d)" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    23
lemma "(p1 \<and> p2) \<or> p3 \<longrightarrow> (p1 \<longrightarrow> (p3 \<and> p2) \<or> (p1 \<and> p3)) \<or> p1" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    24
lemma "P = P = P = P = P = P = P = P = P = P" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    25
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
    26
lemma
56079
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    27
  assumes "a \<or> b \<or> c \<or> d"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    28
      and "e \<or> f \<or> (a \<and> d)"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    29
      and "\<not> (a \<or> (c \<and> ~c)) \<or> b"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    30
      and "\<not> (b \<and> (x \<or> \<not> x)) \<or> c"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    31
      and "\<not> (d \<or> False) \<or> c"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    32
      and "\<not> (c \<or> (\<not> p \<and> (p \<or> (q \<and> \<not> q))))"
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    33
  shows False
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
    34
  using assms by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    35
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    36
axiomatization symm_f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    37
  symm_f: "symm_f x y = symm_f y x"
56109
1ba56358eba4 updated SMT example certificates
blanchet
parents: 56079
diff changeset
    38
66740
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
    39
lemma "a = a \<and> symm_f a b = symm_f b a"
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
    40
  by (smt symm_f)
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    41
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
    42
(*
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    43
Taken from ~~/src/HOL/ex/SAT_Examples.thy.
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    44
Translated from TPTP problem library: PUZ015-2.006.dimacs
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    45
*)
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
    46
lemma
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    47
  assumes "~x0"
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    48
  and "~x30"
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    49
  and "~x29"
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
    50
  and "~x59"
56079
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    51
  and "x1 \<or> x31 \<or> x0"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    52
  and "x2 \<or> x32 \<or> x1"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    53
  and "x3 \<or> x33 \<or> x2"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    54
  and "x4 \<or> x34 \<or> x3"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    55
  and "x35 \<or> x4"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    56
  and "x5 \<or> x36 \<or> x30"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    57
  and "x6 \<or> x37 \<or> x5 \<or> x31"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    58
  and "x7 \<or> x38 \<or> x6 \<or> x32"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    59
  and "x8 \<or> x39 \<or> x7 \<or> x33"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    60
  and "x9 \<or> x40 \<or> x8 \<or> x34"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    61
  and "x41 \<or> x9 \<or> x35"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    62
  and "x10 \<or> x42 \<or> x36"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    63
  and "x11 \<or> x43 \<or> x10 \<or> x37"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    64
  and "x12 \<or> x44 \<or> x11 \<or> x38"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    65
  and "x13 \<or> x45 \<or> x12 \<or> x39"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    66
  and "x14 \<or> x46 \<or> x13 \<or> x40"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    67
  and "x47 \<or> x14 \<or> x41"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    68
  and "x15 \<or> x48 \<or> x42"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    69
  and "x16 \<or> x49 \<or> x15 \<or> x43"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    70
  and "x17 \<or> x50 \<or> x16 \<or> x44"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    71
  and "x18 \<or> x51 \<or> x17 \<or> x45"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    72
  and "x19 \<or> x52 \<or> x18 \<or> x46"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    73
  and "x53 \<or> x19 \<or> x47"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    74
  and "x20 \<or> x54 \<or> x48"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    75
  and "x21 \<or> x55 \<or> x20 \<or> x49"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    76
  and "x22 \<or> x56 \<or> x21 \<or> x50"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    77
  and "x23 \<or> x57 \<or> x22 \<or> x51"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    78
  and "x24 \<or> x58 \<or> x23 \<or> x52"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    79
  and "x59 \<or> x24 \<or> x53"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    80
  and "x25 \<or> x54"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    81
  and "x26 \<or> x25 \<or> x55"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    82
  and "x27 \<or> x26 \<or> x56"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    83
  and "x28 \<or> x27 \<or> x57"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    84
  and "x29 \<or> x28 \<or> x58"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    85
  and "~x1 \<or> ~x31"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    86
  and "~x1 \<or> ~x0"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    87
  and "~x31 \<or> ~x0"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    88
  and "~x2 \<or> ~x32"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    89
  and "~x2 \<or> ~x1"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    90
  and "~x32 \<or> ~x1"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    91
  and "~x3 \<or> ~x33"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    92
  and "~x3 \<or> ~x2"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    93
  and "~x33 \<or> ~x2"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    94
  and "~x4 \<or> ~x34"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    95
  and "~x4 \<or> ~x3"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    96
  and "~x34 \<or> ~x3"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    97
  and "~x35 \<or> ~x4"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    98
  and "~x5 \<or> ~x36"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
    99
  and "~x5 \<or> ~x30"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   100
  and "~x36 \<or> ~x30"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   101
  and "~x6 \<or> ~x37"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   102
  and "~x6 \<or> ~x5"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   103
  and "~x6 \<or> ~x31"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   104
  and "~x37 \<or> ~x5"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   105
  and "~x37 \<or> ~x31"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   106
  and "~x5 \<or> ~x31"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   107
  and "~x7 \<or> ~x38"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   108
  and "~x7 \<or> ~x6"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   109
  and "~x7 \<or> ~x32"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   110
  and "~x38 \<or> ~x6"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   111
  and "~x38 \<or> ~x32"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   112
  and "~x6 \<or> ~x32"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   113
  and "~x8 \<or> ~x39"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   114
  and "~x8 \<or> ~x7"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   115
  and "~x8 \<or> ~x33"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   116
  and "~x39 \<or> ~x7"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   117
  and "~x39 \<or> ~x33"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   118
  and "~x7 \<or> ~x33"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   119
  and "~x9 \<or> ~x40"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   120
  and "~x9 \<or> ~x8"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   121
  and "~x9 \<or> ~x34"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   122
  and "~x40 \<or> ~x8"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   123
  and "~x40 \<or> ~x34"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   124
  and "~x8 \<or> ~x34"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   125
  and "~x41 \<or> ~x9"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   126
  and "~x41 \<or> ~x35"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   127
  and "~x9 \<or> ~x35"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   128
  and "~x10 \<or> ~x42"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   129
  and "~x10 \<or> ~x36"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   130
  and "~x42 \<or> ~x36"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   131
  and "~x11 \<or> ~x43"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   132
  and "~x11 \<or> ~x10"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   133
  and "~x11 \<or> ~x37"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   134
  and "~x43 \<or> ~x10"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   135
  and "~x43 \<or> ~x37"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   136
  and "~x10 \<or> ~x37"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   137
  and "~x12 \<or> ~x44"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   138
  and "~x12 \<or> ~x11"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   139
  and "~x12 \<or> ~x38"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   140
  and "~x44 \<or> ~x11"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   141
  and "~x44 \<or> ~x38"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   142
  and "~x11 \<or> ~x38"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   143
  and "~x13 \<or> ~x45"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   144
  and "~x13 \<or> ~x12"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   145
  and "~x13 \<or> ~x39"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   146
  and "~x45 \<or> ~x12"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   147
  and "~x45 \<or> ~x39"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   148
  and "~x12 \<or> ~x39"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   149
  and "~x14 \<or> ~x46"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   150
  and "~x14 \<or> ~x13"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   151
  and "~x14 \<or> ~x40"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   152
  and "~x46 \<or> ~x13"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   153
  and "~x46 \<or> ~x40"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   154
  and "~x13 \<or> ~x40"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   155
  and "~x47 \<or> ~x14"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   156
  and "~x47 \<or> ~x41"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   157
  and "~x14 \<or> ~x41"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   158
  and "~x15 \<or> ~x48"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   159
  and "~x15 \<or> ~x42"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   160
  and "~x48 \<or> ~x42"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   161
  and "~x16 \<or> ~x49"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   162
  and "~x16 \<or> ~x15"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   163
  and "~x16 \<or> ~x43"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   164
  and "~x49 \<or> ~x15"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   165
  and "~x49 \<or> ~x43"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   166
  and "~x15 \<or> ~x43"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   167
  and "~x17 \<or> ~x50"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   168
  and "~x17 \<or> ~x16"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   169
  and "~x17 \<or> ~x44"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   170
  and "~x50 \<or> ~x16"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   171
  and "~x50 \<or> ~x44"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   172
  and "~x16 \<or> ~x44"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   173
  and "~x18 \<or> ~x51"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   174
  and "~x18 \<or> ~x17"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   175
  and "~x18 \<or> ~x45"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   176
  and "~x51 \<or> ~x17"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   177
  and "~x51 \<or> ~x45"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   178
  and "~x17 \<or> ~x45"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   179
  and "~x19 \<or> ~x52"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   180
  and "~x19 \<or> ~x18"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   181
  and "~x19 \<or> ~x46"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   182
  and "~x52 \<or> ~x18"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   183
  and "~x52 \<or> ~x46"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   184
  and "~x18 \<or> ~x46"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   185
  and "~x53 \<or> ~x19"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   186
  and "~x53 \<or> ~x47"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   187
  and "~x19 \<or> ~x47"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   188
  and "~x20 \<or> ~x54"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   189
  and "~x20 \<or> ~x48"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   190
  and "~x54 \<or> ~x48"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   191
  and "~x21 \<or> ~x55"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   192
  and "~x21 \<or> ~x20"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   193
  and "~x21 \<or> ~x49"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   194
  and "~x55 \<or> ~x20"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   195
  and "~x55 \<or> ~x49"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   196
  and "~x20 \<or> ~x49"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   197
  and "~x22 \<or> ~x56"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   198
  and "~x22 \<or> ~x21"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   199
  and "~x22 \<or> ~x50"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   200
  and "~x56 \<or> ~x21"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   201
  and "~x56 \<or> ~x50"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   202
  and "~x21 \<or> ~x50"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   203
  and "~x23 \<or> ~x57"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   204
  and "~x23 \<or> ~x22"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   205
  and "~x23 \<or> ~x51"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   206
  and "~x57 \<or> ~x22"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   207
  and "~x57 \<or> ~x51"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   208
  and "~x22 \<or> ~x51"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   209
  and "~x24 \<or> ~x58"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   210
  and "~x24 \<or> ~x23"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   211
  and "~x24 \<or> ~x52"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   212
  and "~x58 \<or> ~x23"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   213
  and "~x58 \<or> ~x52"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   214
  and "~x23 \<or> ~x52"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   215
  and "~x59 \<or> ~x24"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   216
  and "~x59 \<or> ~x53"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   217
  and "~x24 \<or> ~x53"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   218
  and "~x25 \<or> ~x54"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   219
  and "~x26 \<or> ~x25"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   220
  and "~x26 \<or> ~x55"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   221
  and "~x25 \<or> ~x55"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   222
  and "~x27 \<or> ~x26"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   223
  and "~x27 \<or> ~x56"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   224
  and "~x26 \<or> ~x56"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   225
  and "~x28 \<or> ~x27"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   226
  and "~x28 \<or> ~x57"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   227
  and "~x27 \<or> ~x57"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   228
  and "~x29 \<or> ~x28"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   229
  and "~x29 \<or> ~x58"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   230
  and "~x28 \<or> ~x58"
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   231
  shows False
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   232
  using assms by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   233
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   234
lemma "\<forall>x::int. P x \<longrightarrow> (\<forall>y::int. P x \<or> P y)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   235
  by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   236
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
   237
lemma
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   238
  assumes "(\<forall>x y. P x y = x)"
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   239
  shows "(\<exists>y. P x y) = P x c"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   240
  using assms by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   241
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
   242
lemma
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   243
  assumes "(\<forall>x y. P x y = x)"
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   244
  and "(\<forall>x. \<exists>y. P x y) = (\<forall>x. P x c)"
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
   245
  shows "(\<exists>y. P x y) = P x c"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   246
  using assms by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   247
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   248
lemma
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   249
  assumes "if P x then \<not>(\<exists>y. P y) else (\<forall>y. \<not>P y)"
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   250
  shows "P x \<longrightarrow> P y"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   251
  using assms by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   252
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   253
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   254
section \<open>Arithmetic\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   255
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   256
subsection \<open>Linear arithmetic over integers and reals\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   257
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   258
lemma "(3::int) = 3" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   259
lemma "(3::real) = 3" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   260
lemma "(3 :: int) + 1 = 4" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   261
lemma "x + (y + z) = y + (z + (x::int))" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   262
lemma "max (3::int) 8 > 5" by smt
61945
1135b8de26c3 more symbols;
wenzelm
parents: 59964
diff changeset
   263
lemma "\<bar>x :: real\<bar> + \<bar>y\<bar> \<ge> \<bar>x + y\<bar>" by smt
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   264
lemma "P ((2::int) < 3) = P True" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   265
lemma "x + 3 \<ge> 4 \<or> x < (1::int)" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   266
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   267
lemma
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   268
  assumes "x \<ge> (3::int)" and "y = x + 4"
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
   269
  shows "y - x > 0"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   270
  using assms by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   271
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   272
lemma "let x = (2 :: int) in x + x \<noteq> 5" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   273
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   274
lemma
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   275
  fixes x :: real
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   276
  assumes "3 * x + 7 * a < 4" and "3 < 2 * x"
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   277
  shows "a < 0"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   278
  using assms by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   279
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   280
lemma "(0 \<le> y + -1 * x \<or> \<not> 0 \<le> x \<or> 0 \<le> (x::int)) = (\<not> False)" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   281
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   282
lemma "
56079
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   283
  (n < m \<and> m < n') \<or> (n < m \<and> m = n') \<or> (n < n' \<and> n' < m) \<or>
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   284
  (n = n' \<and> n' < m) \<or> (n = m \<and> m < n') \<or>
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   285
  (n' < m \<and> m < n) \<or> (n' < m \<and> m = n) \<or>
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   286
  (n' < n \<and> n < m) \<or> (n' = n \<and> n < m) \<or> (n' = m \<and> m < n) \<or>
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   287
  (m < n \<and> n < n') \<or> (m < n \<and> n' = n) \<or> (m < n' \<and> n' < n) \<or>
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   288
  (m = n \<and> n < n') \<or> (m = n' \<and> n' < n) \<or>
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   289
  (n' = m \<and> m = (n::int))"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   290
  by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   291
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   292
text\<open>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   293
The following example was taken from HOL/ex/PresburgerEx.thy, where it says:
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   294
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   295
  This following theorem proves that all solutions to the
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   296
  recurrence relation $x_{i+2} = |x_{i+1}| - x_i$ are periodic with
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   297
  period 9.  The example was brought to our attention by John
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   298
  Harrison. It does does not require Presburger arithmetic but merely
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   299
  quantifier-free linear arithmetic and holds for the rationals as well.
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   300
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
   301
  Warning: it takes (in 2006) over 4.2 minutes!
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   302
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   303
There, it is proved by "arith". SMT is able to prove this within a fraction
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   304
of one second. With proof reconstruction, it takes about 13 seconds on a Core2
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   305
processor.
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   306
\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   307
61945
1135b8de26c3 more symbols;
wenzelm
parents: 59964
diff changeset
   308
lemma "\<lbrakk> x3 = \<bar>x2\<bar> - x1; x4 = \<bar>x3\<bar> - x2; x5 = \<bar>x4\<bar> - x3;
1135b8de26c3 more symbols;
wenzelm
parents: 59964
diff changeset
   309
         x6 = \<bar>x5\<bar> - x4; x7 = \<bar>x6\<bar> - x5; x8 = \<bar>x7\<bar> - x6;
1135b8de26c3 more symbols;
wenzelm
parents: 59964
diff changeset
   310
         x9 = \<bar>x8\<bar> - x7; x10 = \<bar>x9\<bar> - x8; x11 = \<bar>x10\<bar> - x9 \<rbrakk>
56079
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   311
 \<Longrightarrow> x1 = x10 \<and> x2 = (x11::int)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   312
  by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   313
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   314
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   315
lemma "let P = 2 * x + 1 > x + (x::real) in P \<or> False \<or> P" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   316
48069
e9b2782c4f99 restricted Z3 by default to a fragment where proof reconstruction should not fail (for better integration with Sledgehammer) -- the full set of supported Z3 features can still be used by enabling the configuration option "z3_with_extensions"
boehmes
parents: 47155
diff changeset
   317
lemma "x + (let y = x mod 2 in 2 * y + 1) \<ge> x + (1::int)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   318
  using [[z3_extensions]] by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   319
48069
e9b2782c4f99 restricted Z3 by default to a fragment where proof reconstruction should not fail (for better integration with Sledgehammer) -- the full set of supported Z3 features can still be used by enabling the configuration option "z3_with_extensions"
boehmes
parents: 47155
diff changeset
   320
lemma "x + (let y = x mod 2 in y + y) < x + (3::int)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   321
  using [[z3_extensions]] by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   322
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   323
lemma
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   324
  assumes "x \<noteq> (0::real)"
61945
1135b8de26c3 more symbols;
wenzelm
parents: 59964
diff changeset
   325
  shows "x + x \<noteq> (let P = (\<bar>x\<bar> > 1) in if P \<or> \<not> P then 4 else 2) * x"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   326
  using assms [[z3_extensions]] by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   327
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   328
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   329
subsection \<open>Linear arithmetic with quantifiers\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   330
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   331
lemma "~ (\<exists>x::int. False)" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   332
lemma "~ (\<exists>x::real. False)" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   333
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   334
lemma "\<exists>x::int. 0 < x" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   335
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   336
lemma "\<exists>x::real. 0 < x"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   337
  using [[smt_oracle=true]] (* no Z3 proof *)
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   338
  by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   339
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   340
lemma "\<forall>x::int. \<exists>y. y > x" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   341
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   342
lemma "\<forall>x y::int. (x = 0 \<and> y = 1) \<longrightarrow> x \<noteq> y" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   343
lemma "\<exists>x::int. \<forall>y. x < y \<longrightarrow> y < 0 \<or> y >= 0" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   344
lemma "\<forall>x y::int. x < y \<longrightarrow> (2 * x + 1) < (2 * y)" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   345
lemma "\<forall>x y::int. (2 * x + 1) \<noteq> (2 * y)" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   346
lemma "\<forall>x y::int. x + y > 2 \<or> x + y = 2 \<or> x + y < 2" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   347
lemma "\<forall>x::int. if x > 0 then x + 1 > 0 else 1 > x" by smt
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
   348
lemma "if (\<forall>x::int. x < 0 \<or> x > 0) then False else True" by smt
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
   349
lemma "(if (\<forall>x::int. x < 0 \<or> x > 0) then -1 else 3) > (0::int)" by smt
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   350
lemma "~ (\<exists>x y z::int. 4 * x + -6 * y = (1::int))" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   351
lemma "\<exists>x::int. \<forall>x y. 0 < x \<and> 0 < y \<longrightarrow> (0::int) < x + y" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   352
lemma "\<exists>u::int. \<forall>(x::int) y::real. 0 < x \<and> 0 < y \<longrightarrow> -1 < x" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   353
lemma "\<exists>x::int. (\<forall>y. y \<ge> x \<longrightarrow> y > 0) \<longrightarrow> x > 0" by smt
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   354
lemma "\<forall>(a::int) b::int. 0 < b \<or> b < 1" by smt
42318
0fd33b6b22cf corrected order of steps in Z3 proof reconstruction for elimination of unused quantified variables: first try to eliminate unused variables, then skip over used variables
boehmes
parents: 41786
diff changeset
   355
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   356
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   357
subsection \<open>Non-linear arithmetic over integers and reals\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   358
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   359
lemma "a > (0::int) \<Longrightarrow> a*b > 0 \<Longrightarrow> b > 0"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   360
  using [[smt_oracle, z3_extensions]]
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   361
  by smt
36899
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
   362
41282
a4d1b5eef12e updated SMT certificates
boehmes
parents: 41132
diff changeset
   363
lemma  "(a::int) * (x + 1 + y) = a * x + a * (y + 1)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   364
  using [[z3_extensions]]
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   365
  by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   366
41282
a4d1b5eef12e updated SMT certificates
boehmes
parents: 41132
diff changeset
   367
lemma "((x::real) * (1 + y) - x * (1 - y)) = (2 * x * y)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   368
  using [[z3_extensions]]
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   369
  by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   370
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   371
lemma
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   372
  "(U::int) + (1 + p) * (b + e) + p * d =
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   373
   U + (2 * (1 + p) * (b + e) + (1 + p) * d + d * p) - (1 + p) * (b + d + e)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   374
  using [[z3_extensions]] by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   375
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   376
lemma [z3_rule]:
43893
f3e75541cb78 allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
boehmes
parents: 42321
diff changeset
   377
  fixes x :: "int"
f3e75541cb78 allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
boehmes
parents: 42321
diff changeset
   378
  assumes "x * y \<le> 0" and "\<not> y \<le> 0" and "\<not> x \<le> 0"
f3e75541cb78 allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
boehmes
parents: 42321
diff changeset
   379
  shows False
f3e75541cb78 allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
boehmes
parents: 42321
diff changeset
   380
  using assms by (metis mult_le_0_iff)
f3e75541cb78 allow rules with premises to be declared as z3_rule (to circumvent incompleteness of Z3 proof reconstruction)
boehmes
parents: 42321
diff changeset
   381
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   382
67226
ec32cdaab97b isabelle update_cartouches -c -t;
wenzelm
parents: 66758
diff changeset
   383
subsection \<open>Linear arithmetic for natural numbers\<close>
66298
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   384
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   385
declare [[smt_nat_as_int]]
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   386
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   387
lemma "2 * (x::nat) \<noteq> 1" by smt
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   388
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   389
lemma "a < 3 \<Longrightarrow> (7::nat) > 2 * a" by smt
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   390
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   391
lemma "let x = (1::nat) + y in x - y > 0 * x" by smt
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   392
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   393
lemma
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   394
  "let x = (1::nat) + y in
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   395
   let P = (if x > 0 then True else False) in
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   396
   False \<or> P = (x - 1 = y) \<or> (\<not>P \<longrightarrow> False)"
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   397
  by smt
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   398
67972
959b0aed2ce5 avoid adding unnecessary quantified lemmas when embedding natural number terms into integer terms: quantified lemmas can cause Z3 to produce complex proofs that are hard to replay in Isabelle
boehmes
parents: 67613
diff changeset
   399
lemma "int (nat \<bar>x::int\<bar>) = \<bar>x\<bar>" by (smt int_nat_eq)
66298
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   400
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   401
definition prime_nat :: "nat \<Rightarrow> bool" where
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   402
  "prime_nat p = (1 < p \<and> (\<forall>m. m dvd p --> m = 1 \<or> m = p))"
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   403
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   404
lemma "prime_nat (4*m + 1) \<Longrightarrow> m \<ge> (1::nat)" by (smt prime_nat_def)
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   405
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   406
declare [[smt_nat_as_int = false]]
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   407
5ff9fe3fee66 introduced option for nat-as-int in SMT
blanchet
parents: 63167
diff changeset
   408
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   409
section \<open>Pairs\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   410
41132
42384824b732 updated SMT certificates
boehmes
parents: 40681
diff changeset
   411
lemma "fst (x, y) = a \<Longrightarrow> x = a"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   412
  using fst_conv by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   413
41132
42384824b732 updated SMT certificates
boehmes
parents: 40681
diff changeset
   414
lemma "p1 = (x, y) \<and> p2 = (y, x) \<Longrightarrow> fst p1 = snd p2"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   415
  using fst_conv snd_conv by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   416
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   417
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   418
section \<open>Higher-order problems and recursion\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   419
41132
42384824b732 updated SMT certificates
boehmes
parents: 40681
diff changeset
   420
lemma "i \<noteq> i1 \<and> i \<noteq> i2 \<Longrightarrow> (f (i1 := v1, i2 := v2)) i = f i"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   421
  using fun_upd_same fun_upd_apply by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   422
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   423
lemma "(f g (x::'a::type) = (g x \<and> True)) \<or> (f g x = True) \<or> (g x = True)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   424
  by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   425
56109
1ba56358eba4 updated SMT example certificates
blanchet
parents: 56079
diff changeset
   426
lemma "id x = x \<and> id True = True"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   427
  by (smt id_def)
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   428
41132
42384824b732 updated SMT certificates
boehmes
parents: 40681
diff changeset
   429
lemma "i \<noteq> i1 \<and> i \<noteq> i2 \<Longrightarrow> ((f (i1 := v1)) (i2 := v2)) i = f i"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   430
  using fun_upd_same fun_upd_apply by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   431
41786
a5899d0ce1a1 added test cases with quantifier occurring in first-order term positions
boehmes
parents: 41601
diff changeset
   432
lemma
a5899d0ce1a1 added test cases with quantifier occurring in first-order term positions
boehmes
parents: 41601
diff changeset
   433
  "f (\<exists>x. g x) \<Longrightarrow> True"
a5899d0ce1a1 added test cases with quantifier occurring in first-order term positions
boehmes
parents: 41601
diff changeset
   434
  "f (\<forall>x. g x) \<Longrightarrow> True"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   435
  by smt+
36899
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
   436
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   437
lemma True using let_rsp by smt
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67226
diff changeset
   438
lemma "le = (\<le>) \<Longrightarrow> le (3::int) 42" by smt
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   439
lemma "map (\<lambda>i::int. i + 1) [0, 1] = [1, 2]" by (smt list.map)
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
   440
lemma "(\<forall>x. P x) \<or> \<not> All P" by smt
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   441
57696
fb71c6f100f8 do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
blanchet
parents: 57232
diff changeset
   442
fun dec_10 :: "int \<Rightarrow> int" where
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   443
  "dec_10 n = (if n < 10 then n else dec_10 (n - 10))"
56109
1ba56358eba4 updated SMT example certificates
blanchet
parents: 56079
diff changeset
   444
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   445
lemma "dec_10 (4 * dec_10 4) = 6" by (smt dec_10.simps)
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   446
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   447
axiomatization
57696
fb71c6f100f8 do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
blanchet
parents: 57232
diff changeset
   448
  eval_dioph :: "int list \<Rightarrow> int list \<Rightarrow> int"
56109
1ba56358eba4 updated SMT example certificates
blanchet
parents: 56079
diff changeset
   449
where
57696
fb71c6f100f8 do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
blanchet
parents: 57232
diff changeset
   450
  eval_dioph_mod: "eval_dioph ks xs mod n = eval_dioph ks (map (\<lambda>x. x mod n) xs) mod n"
56109
1ba56358eba4 updated SMT example certificates
blanchet
parents: 56079
diff changeset
   451
and
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   452
  eval_dioph_div_mult:
57696
fb71c6f100f8 do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
blanchet
parents: 57232
diff changeset
   453
  "eval_dioph ks (map (\<lambda>x. x div n) xs) * n +
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   454
   eval_dioph ks (map (\<lambda>x. x mod n) xs) = eval_dioph ks xs"
56109
1ba56358eba4 updated SMT example certificates
blanchet
parents: 56079
diff changeset
   455
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   456
lemma
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   457
  "(eval_dioph ks xs = l) =
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   458
   (eval_dioph ks (map (\<lambda>x. x mod 2) xs) mod 2 = l mod 2 \<and>
57696
fb71c6f100f8 do not embed 'nat' into 'int's in 'smt2' method -- this is highly inefficient and decreases the Sledgehammer success rate significantly
blanchet
parents: 57232
diff changeset
   459
    eval_dioph ks (map (\<lambda>x. x div 2) xs) = (l - eval_dioph ks (map (\<lambda>x. x mod 2) xs)) div 2)"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   460
  using [[smt_oracle = true]] (*FIXME*)
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   461
  using [[z3_extensions]]
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   462
  by (smt eval_dioph_mod[where n=2] eval_dioph_div_mult[where n=2])
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   463
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   464
45393
13ab80eafd71 try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
boehmes
parents: 43893
diff changeset
   465
context complete_lattice
13ab80eafd71 try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
boehmes
parents: 43893
diff changeset
   466
begin
13ab80eafd71 try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
boehmes
parents: 43893
diff changeset
   467
46084
dd7fb9e651ad regenerate SMT example certificates, to reflect "set" type constructor
blanchet
parents: 45972
diff changeset
   468
lemma
56079
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   469
  assumes "Sup {a | i::bool. True} \<le> Sup {b | i::bool. True}"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   470
  and "Sup {b | i::bool. True} \<le> Sup {a | i::bool. True}"
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   471
  shows "Sup {a | i::bool. True} \<le> Sup {a | i::bool. True}"
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   472
  using assms by (smt order_trans)
45393
13ab80eafd71 try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
boehmes
parents: 43893
diff changeset
   473
13ab80eafd71 try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
boehmes
parents: 43893
diff changeset
   474
end
13ab80eafd71 try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
boehmes
parents: 43893
diff changeset
   475
13ab80eafd71 try different alternatives in discharging extra assumptions when schematic theorems obtained from lambda-lifting can be instantiated in different ways
boehmes
parents: 43893
diff changeset
   476
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   477
section \<open>Monomorphization examples\<close>
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   478
66740
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
   479
definition Pred :: "'a \<Rightarrow> bool" where
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
   480
  "Pred x = True"
56079
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   481
66740
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
   482
lemma poly_Pred: "Pred x \<and> (Pred [x] \<or> \<not> Pred [x])"
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
   483
  by (simp add: Pred_def)
56109
1ba56358eba4 updated SMT example certificates
blanchet
parents: 56079
diff changeset
   484
66740
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
   485
lemma "Pred (1::int)"
ece9435ca78e updated SMT certificates and added one test
blanchet
parents: 66298
diff changeset
   486
  by (smt poly_Pred)
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   487
36899
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
   488
axiomatization g :: "'a \<Rightarrow> nat"
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
   489
axiomatization where
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
   490
  g1: "g (Some x) = g [x]" and
bcd6fce5bf06 layered SMT setup, adapted SMT clients, added further tests, made Z3 proof abstraction configurable
boehmes
parents: 36898
diff changeset
   491
  g2: "g None = g []" and
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   492
  g3: "g xs = length xs"
56079
175ac95720d4 use 'smt2' in SMT examples as much as currently possible
blanchet
parents: 55465
diff changeset
   493
58061
3d060f43accb renamed new SMT module from 'SMT2' to 'SMT'
blanchet
parents: 57994
diff changeset
   494
lemma "g (Some (3::int)) = g (Some True)" by (smt g1 g2 g3 list.size)
36898
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   495
8e55aa1306c5 integrated SMT into the HOL image
boehmes
parents:
diff changeset
   496
end