src/HOL/SMT.thy
author blanchet
Mon Sep 29 14:32:30 2014 +0200 (2014-09-29)
changeset 58481 62bc7c79212b
parent 58441 c1b489999de9
child 58598 d9892c88cb56
permissions -rw-r--r--
made 'moura' tactic more powerful
blanchet@58061
     1
(*  Title:      HOL/SMT.thy
blanchet@56078
     2
    Author:     Sascha Boehme, TU Muenchen
blanchet@56078
     3
*)
blanchet@56078
     4
blanchet@56078
     5
header {* Bindings to Satisfiability Modulo Theories (SMT) solvers based on SMT-LIB 2 *}
blanchet@56078
     6
blanchet@58061
     7
theory SMT
blanchet@57230
     8
imports Divides
blanchet@58061
     9
keywords "smt_status" :: diag
blanchet@56078
    10
begin
blanchet@56078
    11
blanchet@58481
    12
subsection {* A skolemization tactic and proof method *}
blanchet@58481
    13
blanchet@58481
    14
lemma choices:
blanchet@58481
    15
  "\<And>Q. \<forall>x. \<exists>y ya. Q x y ya \<Longrightarrow> \<exists>f fa. \<forall>x. Q x (f x) (fa x)"
blanchet@58481
    16
  "\<And>Q. \<forall>x. \<exists>y ya yb. Q x y ya yb \<Longrightarrow> \<exists>f fa fb. \<forall>x. Q x (f x) (fa x) (fb x)"
blanchet@58481
    17
  "\<And>Q. \<forall>x. \<exists>y ya yb yc. Q x y ya yb yc \<Longrightarrow> \<exists>f fa fb fc. \<forall>x. Q x (f x) (fa x) (fb x) (fc x)"
blanchet@58481
    18
  by metis+
blanchet@58481
    19
blanchet@58481
    20
lemma bchoices:
blanchet@58481
    21
  "\<And>Q. \<forall>x \<in> S. \<exists>y ya. Q x y ya \<Longrightarrow> \<exists>f fa. \<forall>x \<in> S. Q x (f x) (fa x)"
blanchet@58481
    22
  "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb. Q x y ya yb \<Longrightarrow> \<exists>f fa fb. \<forall>x \<in> S. Q x (f x) (fa x) (fb x)"
blanchet@58481
    23
  "\<And>Q. \<forall>x \<in> S. \<exists>y ya yb yc. Q x y ya yb yc \<Longrightarrow> \<exists>f fa fb fc. \<forall>x \<in> S. Q x (f x) (fa x) (fb x) (fc x)"
blanchet@58481
    24
  by metis+
blanchet@58481
    25
blanchet@58481
    26
ML {*
blanchet@58481
    27
fun moura_tac ctxt =
blanchet@58481
    28
  Atomize_Elim.atomize_elim_tac ctxt THEN'
blanchet@58481
    29
  SELECT_GOAL (Clasimp.auto_tac (ctxt addSIs @{thms choice choices bchoice bchoices}) THEN
blanchet@58481
    30
    ALLGOALS (blast_tac ctxt));
blanchet@58481
    31
*}
blanchet@58481
    32
blanchet@58481
    33
method_setup moura = {*
blanchet@58481
    34
 Scan.succeed (SIMPLE_METHOD' o moura_tac)
blanchet@58481
    35
*} "solve skolemization goals, especially those arising from Z3 proofs"
blanchet@58481
    36
blanchet@58481
    37
hide_fact (open) choices bchoices
blanchet@58481
    38
blanchet@58481
    39
blanchet@56078
    40
subsection {* Triggers for quantifier instantiation *}
blanchet@56078
    41
blanchet@56078
    42
text {*
blanchet@56078
    43
Some SMT solvers support patterns as a quantifier instantiation
blanchet@57696
    44
heuristics. Patterns may either be positive terms (tagged by "pat")
blanchet@56078
    45
triggering quantifier instantiations -- when the solver finds a
blanchet@56078
    46
term matching a positive pattern, it instantiates the corresponding
blanchet@56078
    47
quantifier accordingly -- or negative terms (tagged by "nopat")
blanchet@57696
    48
inhibiting quantifier instantiations. A list of patterns
blanchet@56078
    49
of the same kind is called a multipattern, and all patterns in a
blanchet@56078
    50
multipattern are considered conjunctively for quantifier instantiation.
blanchet@56078
    51
A list of multipatterns is called a trigger, and their multipatterns
blanchet@57696
    52
act disjunctively during quantifier instantiation. Each multipattern
blanchet@56078
    53
should mention at least all quantified variables of the preceding
blanchet@56078
    54
quantifier block.
blanchet@56078
    55
*}
blanchet@56078
    56
blanchet@57230
    57
typedecl 'a symb_list
blanchet@57230
    58
blanchet@57230
    59
consts
blanchet@57230
    60
  Symb_Nil :: "'a symb_list"
blanchet@57230
    61
  Symb_Cons :: "'a \<Rightarrow> 'a symb_list \<Rightarrow> 'a symb_list"
blanchet@57230
    62
blanchet@56078
    63
typedecl pattern
blanchet@56078
    64
blanchet@56078
    65
consts
blanchet@56078
    66
  pat :: "'a \<Rightarrow> pattern"
blanchet@56078
    67
  nopat :: "'a \<Rightarrow> pattern"
blanchet@56078
    68
blanchet@57230
    69
definition trigger :: "pattern symb_list symb_list \<Rightarrow> bool \<Rightarrow> bool" where
blanchet@57230
    70
  "trigger _ P = P"
blanchet@56078
    71
blanchet@56078
    72
blanchet@56078
    73
subsection {* Higher-order encoding *}
blanchet@56078
    74
blanchet@56078
    75
text {*
blanchet@56078
    76
Application is made explicit for constants occurring with varying
blanchet@57696
    77
numbers of arguments. This is achieved by the introduction of the
blanchet@56078
    78
following constant.
blanchet@56078
    79
*}
blanchet@56078
    80
blanchet@56078
    81
definition fun_app :: "'a \<Rightarrow> 'a" where "fun_app f = f"
blanchet@56078
    82
blanchet@56078
    83
text {*
blanchet@56078
    84
Some solvers support a theory of arrays which can be used to encode
blanchet@57696
    85
higher-order functions. The following set of lemmas specifies the
blanchet@56078
    86
properties of such (extensional) arrays.
blanchet@56078
    87
*}
blanchet@56078
    88
blanchet@56078
    89
lemmas array_rules = ext fun_upd_apply fun_upd_same fun_upd_other  fun_upd_upd fun_app_def
blanchet@56078
    90
blanchet@56078
    91
blanchet@56103
    92
subsection {* Normalization *}
blanchet@56103
    93
blanchet@56103
    94
lemma case_bool_if[abs_def]: "case_bool x y P = (if P then x else y)"
blanchet@56103
    95
  by simp
blanchet@56103
    96
blanchet@56103
    97
lemmas Ex1_def_raw = Ex1_def[abs_def]
blanchet@56103
    98
lemmas Ball_def_raw = Ball_def[abs_def]
blanchet@56103
    99
lemmas Bex_def_raw = Bex_def[abs_def]
blanchet@56103
   100
lemmas abs_if_raw = abs_if[abs_def]
blanchet@56103
   101
lemmas min_def_raw = min_def[abs_def]
blanchet@56103
   102
lemmas max_def_raw = max_def[abs_def]
blanchet@56103
   103
blanchet@56103
   104
blanchet@56078
   105
subsection {* Integer division and modulo for Z3 *}
blanchet@56078
   106
blanchet@56102
   107
text {*
blanchet@56102
   108
The following Z3-inspired definitions are overspecified for the case where @{text "l = 0"}. This
blanchet@56102
   109
Schönheitsfehler is corrected in the @{text div_as_z3div} and @{text mod_as_z3mod} theorems.
blanchet@56102
   110
*}
blanchet@56102
   111
blanchet@56078
   112
definition z3div :: "int \<Rightarrow> int \<Rightarrow> int" where
blanchet@56102
   113
  "z3div k l = (if l \<ge> 0 then k div l else - (k div - l))"
blanchet@56078
   114
blanchet@56078
   115
definition z3mod :: "int \<Rightarrow> int \<Rightarrow> int" where
blanchet@56102
   116
  "z3mod k l = k mod (if l \<ge> 0 then l else - l)"
blanchet@56078
   117
blanchet@56101
   118
lemma div_as_z3div:
blanchet@56102
   119
  "\<forall>k l. k div l = (if l = 0 then 0 else if l > 0 then z3div k l else z3div (- k) (- l))"
blanchet@56101
   120
  by (simp add: z3div_def)
blanchet@56101
   121
blanchet@56101
   122
lemma mod_as_z3mod:
blanchet@56102
   123
  "\<forall>k l. k mod l = (if l = 0 then k else if l > 0 then z3mod k l else - z3mod (- k) (- l))"
blanchet@56101
   124
  by (simp add: z3mod_def)
blanchet@56101
   125
blanchet@56078
   126
blanchet@56078
   127
subsection {* Setup *}
blanchet@56078
   128
blanchet@58061
   129
ML_file "Tools/SMT/smt_util.ML"
blanchet@58061
   130
ML_file "Tools/SMT/smt_failure.ML"
blanchet@58061
   131
ML_file "Tools/SMT/smt_config.ML"
blanchet@58061
   132
ML_file "Tools/SMT/smt_builtin.ML"
blanchet@58061
   133
ML_file "Tools/SMT/smt_datatypes.ML"
blanchet@58061
   134
ML_file "Tools/SMT/smt_normalize.ML"
blanchet@58061
   135
ML_file "Tools/SMT/smt_translate.ML"
blanchet@58061
   136
ML_file "Tools/SMT/smtlib.ML"
blanchet@58061
   137
ML_file "Tools/SMT/smtlib_interface.ML"
blanchet@58061
   138
ML_file "Tools/SMT/smtlib_proof.ML"
blanchet@58061
   139
ML_file "Tools/SMT/smtlib_isar.ML"
blanchet@58061
   140
ML_file "Tools/SMT/z3_proof.ML"
blanchet@58061
   141
ML_file "Tools/SMT/z3_isar.ML"
blanchet@58061
   142
ML_file "Tools/SMT/smt_solver.ML"
blanchet@58360
   143
ML_file "Tools/SMT/cvc4_interface.ML"
blanchet@58360
   144
ML_file "Tools/SMT/verit_proof.ML"
blanchet@58360
   145
ML_file "Tools/SMT/verit_isar.ML"
blanchet@58360
   146
ML_file "Tools/SMT/verit_proof_parse.ML"
blanchet@58061
   147
ML_file "Tools/SMT/z3_interface.ML"
blanchet@58061
   148
ML_file "Tools/SMT/z3_replay_util.ML"
blanchet@58061
   149
ML_file "Tools/SMT/z3_replay_literals.ML"
blanchet@58061
   150
ML_file "Tools/SMT/z3_replay_rules.ML"
blanchet@58061
   151
ML_file "Tools/SMT/z3_replay_methods.ML"
blanchet@58061
   152
ML_file "Tools/SMT/z3_replay.ML"
blanchet@58061
   153
ML_file "Tools/SMT/smt_systems.ML"
blanchet@56078
   154
blanchet@58061
   155
method_setup smt = {*
blanchet@56078
   156
  Scan.optional Attrib.thms [] >>
blanchet@56078
   157
    (fn thms => fn ctxt =>
blanchet@58061
   158
      METHOD (fn facts => HEADGOAL (SMT_Solver.smt_tac ctxt (thms @ facts))))
blanchet@58072
   159
*} "apply an SMT solver to the current goal"
blanchet@56078
   160
blanchet@56078
   161
blanchet@56078
   162
subsection {* Configuration *}
blanchet@56078
   163
blanchet@56078
   164
text {*
blanchet@56078
   165
The current configuration can be printed by the command
blanchet@58061
   166
@{text smt_status}, which shows the values of most options.
blanchet@56078
   167
*}
blanchet@56078
   168
blanchet@56078
   169
blanchet@56078
   170
subsection {* General configuration options *}
blanchet@56078
   171
blanchet@56078
   172
text {*
blanchet@58061
   173
The option @{text smt_solver} can be used to change the target SMT
blanchet@58061
   174
solver. The possible values can be obtained from the @{text smt_status}
blanchet@56078
   175
command.
blanchet@56078
   176
blanchet@57696
   177
Due to licensing restrictions, Z3 is not enabled by default. Z3 is free
blanchet@57237
   178
for non-commercial applications and can be enabled by setting Isabelle
blanchet@57237
   179
system option @{text z3_non_commercial} to @{text yes}.
blanchet@56078
   180
*}
blanchet@56078
   181
blanchet@58061
   182
declare [[smt_solver = z3]]
blanchet@56078
   183
blanchet@56078
   184
text {*
blanchet@57696
   185
Since SMT solvers are potentially nonterminating, there is a timeout
blanchet@57696
   186
(given in seconds) to restrict their runtime.
blanchet@56078
   187
*}
blanchet@56078
   188
blanchet@58061
   189
declare [[smt_timeout = 20]]
blanchet@56078
   190
blanchet@56078
   191
text {*
blanchet@57696
   192
SMT solvers apply randomized heuristics. In case a problem is not
blanchet@56078
   193
solvable by an SMT solver, changing the following option might help.
blanchet@56078
   194
*}
blanchet@56078
   195
blanchet@58061
   196
declare [[smt_random_seed = 1]]
blanchet@56078
   197
blanchet@56078
   198
text {*
blanchet@56078
   199
In general, the binding to SMT solvers runs as an oracle, i.e, the SMT
blanchet@57696
   200
solvers are fully trusted without additional checks. The following
blanchet@56078
   201
option can cause the SMT solver to run in proof-producing mode, giving
blanchet@57696
   202
a checkable certificate. This is currently only implemented for Z3.
blanchet@56078
   203
*}
blanchet@56078
   204
blanchet@58061
   205
declare [[smt_oracle = false]]
blanchet@56078
   206
blanchet@56078
   207
text {*
blanchet@56078
   208
Each SMT solver provides several commandline options to tweak its
blanchet@57696
   209
behaviour. They can be passed to the solver by setting the following
blanchet@56078
   210
options.
blanchet@56078
   211
*}
blanchet@56078
   212
blanchet@58061
   213
declare [[cvc3_options = ""]]
blanchet@58441
   214
declare [[cvc4_options = "--full-saturate-quant --quant-cf"]]
blanchet@58061
   215
declare [[veriT_options = ""]]
blanchet@58061
   216
declare [[z3_options = ""]]
blanchet@56078
   217
blanchet@56078
   218
text {*
blanchet@56078
   219
The SMT method provides an inference mechanism to detect simple triggers
blanchet@56078
   220
in quantified formulas, which might increase the number of problems
blanchet@56078
   221
solvable by SMT solvers (note: triggers guide quantifier instantiations
blanchet@57696
   222
in the SMT solver). To turn it on, set the following option.
blanchet@56078
   223
*}
blanchet@56078
   224
blanchet@58061
   225
declare [[smt_infer_triggers = false]]
blanchet@56078
   226
blanchet@56078
   227
text {*
blanchet@58360
   228
Enable the following option to use built-in support for datatypes,
blanchet@58360
   229
codatatypes, and records in CVC4. Currently, this is implemented only
blanchet@58360
   230
in oracle mode.
blanchet@58360
   231
*}
blanchet@58360
   232
blanchet@58360
   233
declare [[cvc4_extensions = false]]
blanchet@58360
   234
blanchet@58360
   235
text {*
blanchet@56078
   236
Enable the following option to use built-in support for div/mod, datatypes,
blanchet@57696
   237
and records in Z3. Currently, this is implemented only in oracle mode.
blanchet@56078
   238
*}
blanchet@56078
   239
blanchet@58061
   240
declare [[z3_extensions = false]]
blanchet@56078
   241
blanchet@56078
   242
blanchet@56078
   243
subsection {* Certificates *}
blanchet@56078
   244
blanchet@56078
   245
text {*
blanchet@58061
   246
By setting the option @{text smt_certificates} to the name of a file,
blanchet@56078
   247
all following applications of an SMT solver a cached in that file.
blanchet@56078
   248
Any further application of the same SMT solver (using the very same
blanchet@56078
   249
configuration) re-uses the cached certificate instead of invoking the
blanchet@57696
   250
solver. An empty string disables caching certificates.
blanchet@56078
   251
blanchet@57696
   252
The filename should be given as an explicit path. It is good
blanchet@56078
   253
practice to use the name of the current theory (with ending
blanchet@56078
   254
@{text ".certs"} instead of @{text ".thy"}) as the certificates file.
blanchet@56078
   255
Certificate files should be used at most once in a certain theory context,
blanchet@56078
   256
to avoid race conditions with other concurrent accesses.
blanchet@56078
   257
*}
blanchet@56078
   258
blanchet@58061
   259
declare [[smt_certificates = ""]]
blanchet@56078
   260
blanchet@56078
   261
text {*
blanchet@58061
   262
The option @{text smt_read_only_certificates} controls whether only
blanchet@56078
   263
stored certificates are should be used or invocation of an SMT solver
blanchet@57696
   264
is allowed. When set to @{text true}, no SMT solver will ever be
blanchet@56078
   265
invoked and only the existing certificates found in the configured
blanchet@56078
   266
cache are used;  when set to @{text false} and there is no cached
blanchet@56078
   267
certificate for some proposition, then the configured SMT solver is
blanchet@56078
   268
invoked.
blanchet@56078
   269
*}
blanchet@56078
   270
blanchet@58061
   271
declare [[smt_read_only_certificates = false]]
blanchet@56078
   272
blanchet@56078
   273
blanchet@56078
   274
subsection {* Tracing *}
blanchet@56078
   275
blanchet@56078
   276
text {*
blanchet@57696
   277
The SMT method, when applied, traces important information. To
blanchet@56078
   278
make it entirely silent, set the following option to @{text false}.
blanchet@56078
   279
*}
blanchet@56078
   280
blanchet@58061
   281
declare [[smt_verbose = true]]
blanchet@56078
   282
blanchet@56078
   283
text {*
blanchet@56078
   284
For tracing the generated problem file given to the SMT solver as
blanchet@56078
   285
well as the returned result of the solver, the option
blanchet@58061
   286
@{text smt_trace} should be set to @{text true}.
blanchet@56078
   287
*}
blanchet@56078
   288
blanchet@58061
   289
declare [[smt_trace = false]]
blanchet@56078
   290
blanchet@56078
   291
blanchet@56078
   292
subsection {* Schematic rules for Z3 proof reconstruction *}
blanchet@56078
   293
blanchet@56078
   294
text {*
blanchet@57696
   295
Several prof rules of Z3 are not very well documented. There are two
blanchet@56078
   296
lemma groups which can turn failing Z3 proof reconstruction attempts
blanchet@56078
   297
into succeeding ones: the facts in @{text z3_rule} are tried prior to
blanchet@56078
   298
any implemented reconstruction procedure for all uncertain Z3 proof
blanchet@56078
   299
rules;  the facts in @{text z3_simp} are only fed to invocations of
blanchet@56078
   300
the simplifier when reconstructing theory-specific proof steps.
blanchet@56078
   301
*}
blanchet@56078
   302
blanchet@58061
   303
lemmas [z3_rule] =
blanchet@56078
   304
  refl eq_commute conj_commute disj_commute simp_thms nnf_simps
blanchet@56078
   305
  ring_distribs field_simps times_divide_eq_right times_divide_eq_left
blanchet@56078
   306
  if_True if_False not_not
blanchet@56078
   307
blanchet@58061
   308
lemma [z3_rule]:
blanchet@57169
   309
  "(P \<and> Q) = (\<not> (\<not> P \<or> \<not> Q))"
blanchet@57169
   310
  "(P \<and> Q) = (\<not> (\<not> Q \<or> \<not> P))"
blanchet@57169
   311
  "(\<not> P \<and> Q) = (\<not> (P \<or> \<not> Q))"
blanchet@57169
   312
  "(\<not> P \<and> Q) = (\<not> (\<not> Q \<or> P))"
blanchet@57169
   313
  "(P \<and> \<not> Q) = (\<not> (\<not> P \<or> Q))"
blanchet@57169
   314
  "(P \<and> \<not> Q) = (\<not> (Q \<or> \<not> P))"
blanchet@57169
   315
  "(\<not> P \<and> \<not> Q) = (\<not> (P \<or> Q))"
blanchet@57169
   316
  "(\<not> P \<and> \<not> Q) = (\<not> (Q \<or> P))"
blanchet@56078
   317
  by auto
blanchet@56078
   318
blanchet@58061
   319
lemma [z3_rule]:
blanchet@57169
   320
  "(P \<longrightarrow> Q) = (Q \<or> \<not> P)"
blanchet@57169
   321
  "(\<not> P \<longrightarrow> Q) = (P \<or> Q)"
blanchet@57169
   322
  "(\<not> P \<longrightarrow> Q) = (Q \<or> P)"
blanchet@56078
   323
  "(True \<longrightarrow> P) = P"
blanchet@56078
   324
  "(P \<longrightarrow> True) = True"
blanchet@56078
   325
  "(False \<longrightarrow> P) = True"
blanchet@56078
   326
  "(P \<longrightarrow> P) = True"
blanchet@56078
   327
  by auto
blanchet@56078
   328
blanchet@58061
   329
lemma [z3_rule]:
blanchet@57169
   330
  "((P = Q) \<longrightarrow> R) = (R | (Q = (\<not> P)))"
blanchet@56078
   331
  by auto
blanchet@56078
   332
blanchet@58061
   333
lemma [z3_rule]:
blanchet@57169
   334
  "(\<not> True) = False"
blanchet@57169
   335
  "(\<not> False) = True"
blanchet@56078
   336
  "(x = x) = True"
blanchet@56078
   337
  "(P = True) = P"
blanchet@56078
   338
  "(True = P) = P"
blanchet@57169
   339
  "(P = False) = (\<not> P)"
blanchet@57169
   340
  "(False = P) = (\<not> P)"
blanchet@57169
   341
  "((\<not> P) = P) = False"
blanchet@57169
   342
  "(P = (\<not> P)) = False"
blanchet@57169
   343
  "((\<not> P) = (\<not> Q)) = (P = Q)"
blanchet@57169
   344
  "\<not> (P = (\<not> Q)) = (P = Q)"
blanchet@57169
   345
  "\<not> ((\<not> P) = Q) = (P = Q)"
blanchet@57169
   346
  "(P \<noteq> Q) = (Q = (\<not> P))"
blanchet@57169
   347
  "(P = Q) = ((\<not> P \<or> Q) \<and> (P \<or> \<not> Q))"
blanchet@57169
   348
  "(P \<noteq> Q) = ((\<not> P \<or> \<not> Q) \<and> (P \<or> Q))"
blanchet@56078
   349
  by auto
blanchet@56078
   350
blanchet@58061
   351
lemma [z3_rule]:
blanchet@57169
   352
  "(if P then P else \<not> P) = True"
blanchet@57169
   353
  "(if \<not> P then \<not> P else P) = True"
blanchet@56078
   354
  "(if P then True else False) = P"
blanchet@57169
   355
  "(if P then False else True) = (\<not> P)"
blanchet@57169
   356
  "(if P then Q else True) = ((\<not> P) \<or> Q)"
blanchet@57169
   357
  "(if P then Q else True) = (Q \<or> (\<not> P))"
blanchet@57169
   358
  "(if P then Q else \<not> Q) = (P = Q)"
blanchet@57169
   359
  "(if P then Q else \<not> Q) = (Q = P)"
blanchet@57169
   360
  "(if P then \<not> Q else Q) = (P = (\<not> Q))"
blanchet@57169
   361
  "(if P then \<not> Q else Q) = ((\<not> Q) = P)"
blanchet@57169
   362
  "(if \<not> P then x else y) = (if P then y else x)"
blanchet@57169
   363
  "(if P then (if Q then x else y) else x) = (if P \<and> (\<not> Q) then y else x)"
blanchet@57169
   364
  "(if P then (if Q then x else y) else x) = (if (\<not> Q) \<and> P then y else x)"
blanchet@56078
   365
  "(if P then (if Q then x else y) else y) = (if P \<and> Q then x else y)"
blanchet@56078
   366
  "(if P then (if Q then x else y) else y) = (if Q \<and> P then x else y)"
blanchet@56078
   367
  "(if P then x else if P then y else z) = (if P then x else z)"
blanchet@56078
   368
  "(if P then x else if Q then x else y) = (if P \<or> Q then x else y)"
blanchet@56078
   369
  "(if P then x else if Q then x else y) = (if Q \<or> P then x else y)"
blanchet@56078
   370
  "(if P then x = y else x = z) = (x = (if P then y else z))"
blanchet@56078
   371
  "(if P then x = y else y = z) = (y = (if P then x else z))"
blanchet@56078
   372
  "(if P then x = y else z = y) = (y = (if P then x else z))"
blanchet@56078
   373
  by auto
blanchet@56078
   374
blanchet@58061
   375
lemma [z3_rule]:
blanchet@56078
   376
  "0 + (x::int) = x"
blanchet@56078
   377
  "x + 0 = x"
blanchet@56078
   378
  "x + x = 2 * x"
blanchet@56078
   379
  "0 * x = 0"
blanchet@56078
   380
  "1 * x = x"
blanchet@56078
   381
  "x + y = y + x"
blanchet@57230
   382
  by (auto simp add: mult_2)
blanchet@56078
   383
blanchet@58061
   384
lemma [z3_rule]:  (* for def-axiom *)
blanchet@56078
   385
  "P = Q \<or> P \<or> Q"
blanchet@57169
   386
  "P = Q \<or> \<not> P \<or> \<not> Q"
blanchet@57169
   387
  "(\<not> P) = Q \<or> \<not> P \<or> Q"
blanchet@57169
   388
  "(\<not> P) = Q \<or> P \<or> \<not> Q"
blanchet@57169
   389
  "P = (\<not> Q) \<or> \<not> P \<or> Q"
blanchet@57169
   390
  "P = (\<not> Q) \<or> P \<or> \<not> Q"
blanchet@57169
   391
  "P \<noteq> Q \<or> P \<or> \<not> Q"
blanchet@57169
   392
  "P \<noteq> Q \<or> \<not> P \<or> Q"
blanchet@57169
   393
  "P \<noteq> (\<not> Q) \<or> P \<or> Q"
blanchet@57169
   394
  "(\<not> P) \<noteq> Q \<or> P \<or> Q"
blanchet@57169
   395
  "P \<or> Q \<or> P \<noteq> (\<not> Q)"
blanchet@57169
   396
  "P \<or> Q \<or> (\<not> P) \<noteq> Q"
blanchet@57169
   397
  "P \<or> \<not> Q \<or> P \<noteq> Q"
blanchet@57169
   398
  "\<not> P \<or> Q \<or> P \<noteq> Q"
blanchet@56078
   399
  "P \<or> y = (if P then x else y)"
blanchet@56078
   400
  "P \<or> (if P then x else y) = y"
blanchet@57169
   401
  "\<not> P \<or> x = (if P then x else y)"
blanchet@57169
   402
  "\<not> P \<or> (if P then x else y) = x"
blanchet@57169
   403
  "P \<or> R \<or> \<not> (if P then Q else R)"
blanchet@57169
   404
  "\<not> P \<or> Q \<or> \<not> (if P then Q else R)"
blanchet@57169
   405
  "\<not> (if P then Q else R) \<or> \<not> P \<or> Q"
blanchet@57169
   406
  "\<not> (if P then Q else R) \<or> P \<or> R"
blanchet@57169
   407
  "(if P then Q else R) \<or> \<not> P \<or> \<not> Q"
blanchet@57169
   408
  "(if P then Q else R) \<or> P \<or> \<not> R"
blanchet@57169
   409
  "(if P then \<not> Q else R) \<or> \<not> P \<or> Q"
blanchet@57169
   410
  "(if P then Q else \<not> R) \<or> P \<or> R"
blanchet@56078
   411
  by auto
blanchet@56078
   412
blanchet@57230
   413
hide_type (open) symb_list pattern
blanchet@57230
   414
hide_const (open) Symb_Nil Symb_Cons trigger pat nopat fun_app z3div z3mod
blanchet@56078
   415
blanchet@56078
   416
end