src/HOL/SMT2.thy
author blanchet
Tue Jun 03 16:02:42 2014 +0200 (2014-06-03)
changeset 57169 6abda9b6b9c1
parent 57165 7b1bf424ec5f
child 57209 7ffa0f7e2775
permissions -rw-r--r--
tune
blanchet@56078
     1
(*  Title:      HOL/SMT2.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@56078
     7
theory SMT2
blanchet@56078
     8
imports Record
blanchet@56078
     9
keywords "smt2_status" :: diag
blanchet@56078
    10
begin
blanchet@56078
    11
blanchet@56090
    12
ML_file "Tools/SMT2/smt2_util.ML"
blanchet@56078
    13
ML_file "Tools/SMT2/smt2_failure.ML"
blanchet@56078
    14
ML_file "Tools/SMT2/smt2_config.ML"
blanchet@56078
    15
blanchet@56078
    16
blanchet@56078
    17
subsection {* Triggers for quantifier instantiation *}
blanchet@56078
    18
blanchet@56078
    19
text {*
blanchet@56078
    20
Some SMT solvers support patterns as a quantifier instantiation
blanchet@56078
    21
heuristics.  Patterns may either be positive terms (tagged by "pat")
blanchet@56078
    22
triggering quantifier instantiations -- when the solver finds a
blanchet@56078
    23
term matching a positive pattern, it instantiates the corresponding
blanchet@56078
    24
quantifier accordingly -- or negative terms (tagged by "nopat")
blanchet@56078
    25
inhibiting quantifier instantiations.  A list of patterns
blanchet@56078
    26
of the same kind is called a multipattern, and all patterns in a
blanchet@56078
    27
multipattern are considered conjunctively for quantifier instantiation.
blanchet@56078
    28
A list of multipatterns is called a trigger, and their multipatterns
blanchet@56078
    29
act disjunctively during quantifier instantiation.  Each multipattern
blanchet@56078
    30
should mention at least all quantified variables of the preceding
blanchet@56078
    31
quantifier block.
blanchet@56078
    32
*}
blanchet@56078
    33
blanchet@56078
    34
typedecl pattern
blanchet@56078
    35
blanchet@56078
    36
consts
blanchet@56078
    37
  pat :: "'a \<Rightarrow> pattern"
blanchet@56078
    38
  nopat :: "'a \<Rightarrow> pattern"
blanchet@56078
    39
blanchet@56078
    40
definition trigger :: "pattern list list \<Rightarrow> bool \<Rightarrow> bool" where "trigger _ P = P"
blanchet@56078
    41
blanchet@56078
    42
blanchet@56078
    43
subsection {* Higher-order encoding *}
blanchet@56078
    44
blanchet@56078
    45
text {*
blanchet@56078
    46
Application is made explicit for constants occurring with varying
blanchet@56078
    47
numbers of arguments.  This is achieved by the introduction of the
blanchet@56078
    48
following constant.
blanchet@56078
    49
*}
blanchet@56078
    50
blanchet@56078
    51
definition fun_app :: "'a \<Rightarrow> 'a" where "fun_app f = f"
blanchet@56078
    52
blanchet@56078
    53
text {*
blanchet@56078
    54
Some solvers support a theory of arrays which can be used to encode
blanchet@56078
    55
higher-order functions.  The following set of lemmas specifies the
blanchet@56078
    56
properties of such (extensional) arrays.
blanchet@56078
    57
*}
blanchet@56078
    58
blanchet@56078
    59
lemmas array_rules = ext fun_upd_apply fun_upd_same fun_upd_other  fun_upd_upd fun_app_def
blanchet@56078
    60
blanchet@56078
    61
blanchet@56103
    62
subsection {* Normalization *}
blanchet@56103
    63
blanchet@56103
    64
lemma case_bool_if[abs_def]: "case_bool x y P = (if P then x else y)"
blanchet@56103
    65
  by simp
blanchet@56103
    66
blanchet@56107
    67
lemma nat_int': "\<forall>n. nat (int n) = n" by simp
blanchet@56103
    68
lemma int_nat_nneg: "\<forall>i. i \<ge> 0 \<longrightarrow> int (nat i) = i" by simp
blanchet@56103
    69
lemma int_nat_neg: "\<forall>i. i < 0 \<longrightarrow> int (nat i) = 0" by simp
blanchet@56103
    70
blanchet@56103
    71
lemma nat_zero_as_int: "0 = nat 0" by (rule transfer_nat_int_numerals(1))
blanchet@56103
    72
lemma nat_one_as_int: "1 = nat 1" by (rule transfer_nat_int_numerals(2))
blanchet@56103
    73
lemma nat_numeral_as_int: "numeral = (\<lambda>i. nat (numeral i))" by simp
blanchet@56103
    74
lemma nat_less_as_int: "op < = (\<lambda>a b. int a < int b)" by simp
blanchet@56103
    75
lemma nat_leq_as_int: "op \<le> = (\<lambda>a b. int a <= int b)" by simp
blanchet@56103
    76
lemma Suc_as_int: "Suc = (\<lambda>a. nat (int a + 1))" by (rule ext) simp
blanchet@56103
    77
lemma nat_plus_as_int: "op + = (\<lambda>a b. nat (int a + int b))" by (rule ext)+ simp
blanchet@56103
    78
lemma nat_minus_as_int: "op - = (\<lambda>a b. nat (int a - int b))" by (rule ext)+ simp
blanchet@56103
    79
lemma nat_times_as_int: "op * = (\<lambda>a b. nat (int a * int b))" by (simp add: nat_mult_distrib)
blanchet@56103
    80
lemma nat_div_as_int: "op div = (\<lambda>a b. nat (int a div int b))" by (simp add: nat_div_distrib)
blanchet@56103
    81
lemma nat_mod_as_int: "op mod = (\<lambda>a b. nat (int a mod int b))" by (simp add: nat_mod_distrib)
blanchet@56103
    82
blanchet@56103
    83
lemma int_Suc: "int (Suc n) = int n + 1" by simp
blanchet@56103
    84
lemma int_plus: "int (n + m) = int n + int m" by (rule of_nat_add)
blanchet@56103
    85
lemma int_minus: "int (n - m) = int (nat (int n - int m))" by auto
blanchet@56103
    86
blanchet@56103
    87
lemmas Ex1_def_raw = Ex1_def[abs_def]
blanchet@56103
    88
lemmas Ball_def_raw = Ball_def[abs_def]
blanchet@56103
    89
lemmas Bex_def_raw = Bex_def[abs_def]
blanchet@56103
    90
lemmas abs_if_raw = abs_if[abs_def]
blanchet@56103
    91
lemmas min_def_raw = min_def[abs_def]
blanchet@56103
    92
lemmas max_def_raw = max_def[abs_def]
blanchet@56103
    93
blanchet@56103
    94
blanchet@56078
    95
subsection {* Integer division and modulo for Z3 *}
blanchet@56078
    96
blanchet@56102
    97
text {*
blanchet@56102
    98
The following Z3-inspired definitions are overspecified for the case where @{text "l = 0"}. This
blanchet@56102
    99
Schönheitsfehler is corrected in the @{text div_as_z3div} and @{text mod_as_z3mod} theorems.
blanchet@56102
   100
*}
blanchet@56102
   101
blanchet@56078
   102
definition z3div :: "int \<Rightarrow> int \<Rightarrow> int" where
blanchet@56102
   103
  "z3div k l = (if l \<ge> 0 then k div l else - (k div - l))"
blanchet@56078
   104
blanchet@56078
   105
definition z3mod :: "int \<Rightarrow> int \<Rightarrow> int" where
blanchet@56102
   106
  "z3mod k l = k mod (if l \<ge> 0 then l else - l)"
blanchet@56078
   107
blanchet@56101
   108
lemma div_as_z3div:
blanchet@56102
   109
  "\<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
   110
  by (simp add: z3div_def)
blanchet@56101
   111
blanchet@56101
   112
lemma mod_as_z3mod:
blanchet@56102
   113
  "\<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
   114
  by (simp add: z3mod_def)
blanchet@56101
   115
blanchet@56078
   116
blanchet@56078
   117
subsection {* Setup *}
blanchet@56078
   118
blanchet@56078
   119
ML_file "Tools/SMT2/smt2_builtin.ML"
blanchet@56078
   120
ML_file "Tools/SMT2/smt2_datatypes.ML"
blanchet@56078
   121
ML_file "Tools/SMT2/smt2_normalize.ML"
blanchet@56078
   122
ML_file "Tools/SMT2/smt2_translate.ML"
blanchet@56078
   123
ML_file "Tools/SMT2/smtlib2.ML"
blanchet@56078
   124
ML_file "Tools/SMT2/smtlib2_interface.ML"
blanchet@56083
   125
ML_file "Tools/SMT2/z3_new_proof.ML"
blanchet@57159
   126
ML_file "Tools/SMT2/z3_new_isar.ML"
blanchet@56083
   127
ML_file "Tools/SMT2/smt2_solver.ML"
blanchet@56078
   128
ML_file "Tools/SMT2/z3_new_interface.ML"
blanchet@56090
   129
ML_file "Tools/SMT2/z3_new_replay_util.ML"
blanchet@56090
   130
ML_file "Tools/SMT2/z3_new_replay_literals.ML"
blanchet@56090
   131
ML_file "Tools/SMT2/z3_new_replay_rules.ML"
blanchet@56090
   132
ML_file "Tools/SMT2/z3_new_replay_methods.ML"
blanchet@56090
   133
ML_file "Tools/SMT2/z3_new_replay.ML"
blanchet@56090
   134
ML_file "Tools/SMT2/smt2_systems.ML"
blanchet@56078
   135
blanchet@56078
   136
method_setup smt2 = {*
blanchet@56078
   137
  Scan.optional Attrib.thms [] >>
blanchet@56078
   138
    (fn thms => fn ctxt =>
blanchet@56078
   139
      METHOD (fn facts => HEADGOAL (SMT2_Solver.smt2_tac ctxt (thms @ facts))))
blanchet@56078
   140
*} "apply an SMT solver to the current goal (based on SMT-LIB 2)"
blanchet@56078
   141
blanchet@56078
   142
blanchet@56078
   143
subsection {* Configuration *}
blanchet@56078
   144
blanchet@56078
   145
text {*
blanchet@56078
   146
The current configuration can be printed by the command
blanchet@56078
   147
@{text smt2_status}, which shows the values of most options.
blanchet@56078
   148
*}
blanchet@56078
   149
blanchet@56078
   150
blanchet@56078
   151
blanchet@56078
   152
subsection {* General configuration options *}
blanchet@56078
   153
blanchet@56078
   154
text {*
blanchet@56078
   155
The option @{text smt2_solver} can be used to change the target SMT
blanchet@56078
   156
solver.  The possible values can be obtained from the @{text smt2_status}
blanchet@56078
   157
command.
blanchet@56078
   158
blanchet@56078
   159
Due to licensing restrictions, Yices and Z3 are not installed/enabled
blanchet@56078
   160
by default.  Z3 is free for non-commercial applications and can be enabled
blanchet@56078
   161
by setting Isabelle system option @{text z3_non_commercial} to @{text yes}.
blanchet@56078
   162
*}
blanchet@56078
   163
blanchet@56078
   164
declare [[ smt2_solver = z3_new ]]
blanchet@56078
   165
blanchet@56078
   166
text {*
blanchet@56078
   167
Since SMT solvers are potentially non-terminating, there is a timeout
blanchet@56078
   168
(given in seconds) to restrict their runtime.  A value greater than
blanchet@56078
   169
120 (seconds) is in most cases not advisable.
blanchet@56078
   170
*}
blanchet@56078
   171
blanchet@56078
   172
declare [[ smt2_timeout = 20 ]]
blanchet@56078
   173
blanchet@56078
   174
text {*
blanchet@56078
   175
SMT solvers apply randomized heuristics.  In case a problem is not
blanchet@56078
   176
solvable by an SMT solver, changing the following option might help.
blanchet@56078
   177
*}
blanchet@56078
   178
blanchet@56078
   179
declare [[ smt2_random_seed = 1 ]]
blanchet@56078
   180
blanchet@56078
   181
text {*
blanchet@56078
   182
In general, the binding to SMT solvers runs as an oracle, i.e, the SMT
blanchet@56078
   183
solvers are fully trusted without additional checks.  The following
blanchet@56078
   184
option can cause the SMT solver to run in proof-producing mode, giving
blanchet@56078
   185
a checkable certificate.  This is currently only implemented for Z3.
blanchet@56078
   186
*}
blanchet@56078
   187
blanchet@56078
   188
declare [[ smt2_oracle = false ]]
blanchet@56078
   189
blanchet@56078
   190
text {*
blanchet@56078
   191
Each SMT solver provides several commandline options to tweak its
blanchet@56078
   192
behaviour.  They can be passed to the solver by setting the following
blanchet@56078
   193
options.
blanchet@56078
   194
*}
blanchet@56078
   195
blanchet@56078
   196
(* declare [[ cvc3_options = "" ]] TODO *)
blanchet@56078
   197
(* declare [[ yices_options = "" ]] TODO *)
blanchet@56078
   198
(* declare [[ z3_options = "" ]] TODO *)
blanchet@56078
   199
blanchet@56078
   200
text {*
blanchet@56078
   201
The SMT method provides an inference mechanism to detect simple triggers
blanchet@56078
   202
in quantified formulas, which might increase the number of problems
blanchet@56078
   203
solvable by SMT solvers (note: triggers guide quantifier instantiations
blanchet@56078
   204
in the SMT solver).  To turn it on, set the following option.
blanchet@56078
   205
*}
blanchet@56078
   206
blanchet@56078
   207
declare [[ smt2_infer_triggers = false ]]
blanchet@56078
   208
blanchet@56078
   209
text {*
blanchet@56078
   210
Enable the following option to use built-in support for div/mod, datatypes,
blanchet@56078
   211
and records in Z3.  Currently, this is implemented only in oracle mode.
blanchet@56078
   212
*}
blanchet@56078
   213
blanchet@56078
   214
declare [[ z3_new_extensions = false ]]
blanchet@56078
   215
blanchet@56078
   216
text {*
blanchet@56078
   217
The SMT method monomorphizes the given facts, that is, it tries to
blanchet@56078
   218
instantiate all schematic type variables with fixed types occurring
blanchet@56078
   219
in the problem.  This is a (possibly nonterminating) fixed-point
blanchet@56078
   220
construction whose cycles are limited by the following option.
blanchet@56078
   221
*}
blanchet@56078
   222
blanchet@56078
   223
declare [[ monomorph_max_rounds = 5 ]]
blanchet@56078
   224
blanchet@56078
   225
text {*
blanchet@56078
   226
In addition, the number of generated monomorphic instances is limited
blanchet@56078
   227
by the following option.
blanchet@56078
   228
*}
blanchet@56078
   229
blanchet@56078
   230
declare [[ monomorph_max_new_instances = 500 ]]
blanchet@56078
   231
blanchet@56078
   232
blanchet@56078
   233
blanchet@56078
   234
subsection {* Certificates *}
blanchet@56078
   235
blanchet@56078
   236
text {*
blanchet@56078
   237
By setting the option @{text smt2_certificates} to the name of a file,
blanchet@56078
   238
all following applications of an SMT solver a cached in that file.
blanchet@56078
   239
Any further application of the same SMT solver (using the very same
blanchet@56078
   240
configuration) re-uses the cached certificate instead of invoking the
blanchet@56078
   241
solver.  An empty string disables caching certificates.
blanchet@56078
   242
blanchet@56078
   243
The filename should be given as an explicit path.  It is good
blanchet@56078
   244
practice to use the name of the current theory (with ending
blanchet@56078
   245
@{text ".certs"} instead of @{text ".thy"}) as the certificates file.
blanchet@56078
   246
Certificate files should be used at most once in a certain theory context,
blanchet@56078
   247
to avoid race conditions with other concurrent accesses.
blanchet@56078
   248
*}
blanchet@56078
   249
blanchet@56078
   250
declare [[ smt2_certificates = "" ]]
blanchet@56078
   251
blanchet@56078
   252
text {*
blanchet@56078
   253
The option @{text smt2_read_only_certificates} controls whether only
blanchet@56078
   254
stored certificates are should be used or invocation of an SMT solver
blanchet@56078
   255
is allowed.  When set to @{text true}, no SMT solver will ever be
blanchet@56078
   256
invoked and only the existing certificates found in the configured
blanchet@56078
   257
cache are used;  when set to @{text false} and there is no cached
blanchet@56078
   258
certificate for some proposition, then the configured SMT solver is
blanchet@56078
   259
invoked.
blanchet@56078
   260
*}
blanchet@56078
   261
blanchet@56078
   262
declare [[ smt2_read_only_certificates = false ]]
blanchet@56078
   263
blanchet@56078
   264
blanchet@56078
   265
blanchet@56078
   266
subsection {* Tracing *}
blanchet@56078
   267
blanchet@56078
   268
text {*
blanchet@56078
   269
The SMT method, when applied, traces important information.  To
blanchet@56078
   270
make it entirely silent, set the following option to @{text false}.
blanchet@56078
   271
*}
blanchet@56078
   272
blanchet@56078
   273
declare [[ smt2_verbose = true ]]
blanchet@56078
   274
blanchet@56078
   275
text {*
blanchet@56078
   276
For tracing the generated problem file given to the SMT solver as
blanchet@56078
   277
well as the returned result of the solver, the option
blanchet@56078
   278
@{text smt2_trace} should be set to @{text true}.
blanchet@56078
   279
*}
blanchet@56078
   280
blanchet@56078
   281
declare [[ smt2_trace = false ]]
blanchet@56078
   282
blanchet@56078
   283
blanchet@56078
   284
subsection {* Schematic rules for Z3 proof reconstruction *}
blanchet@56078
   285
blanchet@56078
   286
text {*
blanchet@56078
   287
Several prof rules of Z3 are not very well documented.  There are two
blanchet@56078
   288
lemma groups which can turn failing Z3 proof reconstruction attempts
blanchet@56078
   289
into succeeding ones: the facts in @{text z3_rule} are tried prior to
blanchet@56078
   290
any implemented reconstruction procedure for all uncertain Z3 proof
blanchet@56078
   291
rules;  the facts in @{text z3_simp} are only fed to invocations of
blanchet@56078
   292
the simplifier when reconstructing theory-specific proof steps.
blanchet@56078
   293
*}
blanchet@56078
   294
blanchet@56078
   295
lemmas [z3_new_rule] =
blanchet@56078
   296
  refl eq_commute conj_commute disj_commute simp_thms nnf_simps
blanchet@56078
   297
  ring_distribs field_simps times_divide_eq_right times_divide_eq_left
blanchet@56078
   298
  if_True if_False not_not
blanchet@56078
   299
blanchet@56078
   300
lemma [z3_new_rule]:
blanchet@57169
   301
  "(P \<and> Q) = (\<not> (\<not> P \<or> \<not> Q))"
blanchet@57169
   302
  "(P \<and> Q) = (\<not> (\<not> Q \<or> \<not> P))"
blanchet@57169
   303
  "(\<not> P \<and> Q) = (\<not> (P \<or> \<not> Q))"
blanchet@57169
   304
  "(\<not> P \<and> Q) = (\<not> (\<not> Q \<or> P))"
blanchet@57169
   305
  "(P \<and> \<not> Q) = (\<not> (\<not> P \<or> Q))"
blanchet@57169
   306
  "(P \<and> \<not> Q) = (\<not> (Q \<or> \<not> P))"
blanchet@57169
   307
  "(\<not> P \<and> \<not> Q) = (\<not> (P \<or> Q))"
blanchet@57169
   308
  "(\<not> P \<and> \<not> Q) = (\<not> (Q \<or> P))"
blanchet@56078
   309
  by auto
blanchet@56078
   310
blanchet@56078
   311
lemma [z3_new_rule]:
blanchet@57169
   312
  "(P \<longrightarrow> Q) = (Q \<or> \<not> P)"
blanchet@57169
   313
  "(\<not> P \<longrightarrow> Q) = (P \<or> Q)"
blanchet@57169
   314
  "(\<not> P \<longrightarrow> Q) = (Q \<or> P)"
blanchet@56078
   315
  "(True \<longrightarrow> P) = P"
blanchet@56078
   316
  "(P \<longrightarrow> True) = True"
blanchet@56078
   317
  "(False \<longrightarrow> P) = True"
blanchet@56078
   318
  "(P \<longrightarrow> P) = True"
blanchet@56078
   319
  by auto
blanchet@56078
   320
blanchet@56078
   321
lemma [z3_new_rule]:
blanchet@57169
   322
  "((P = Q) \<longrightarrow> R) = (R | (Q = (\<not> P)))"
blanchet@56078
   323
  by auto
blanchet@56078
   324
blanchet@56078
   325
lemma [z3_new_rule]:
blanchet@57169
   326
  "(\<not> True) = False"
blanchet@57169
   327
  "(\<not> False) = True"
blanchet@56078
   328
  "(x = x) = True"
blanchet@56078
   329
  "(P = True) = P"
blanchet@56078
   330
  "(True = P) = P"
blanchet@57169
   331
  "(P = False) = (\<not> P)"
blanchet@57169
   332
  "(False = P) = (\<not> P)"
blanchet@57169
   333
  "((\<not> P) = P) = False"
blanchet@57169
   334
  "(P = (\<not> P)) = False"
blanchet@57169
   335
  "((\<not> P) = (\<not> Q)) = (P = Q)"
blanchet@57169
   336
  "\<not> (P = (\<not> Q)) = (P = Q)"
blanchet@57169
   337
  "\<not> ((\<not> P) = Q) = (P = Q)"
blanchet@57169
   338
  "(P \<noteq> Q) = (Q = (\<not> P))"
blanchet@57169
   339
  "(P = Q) = ((\<not> P \<or> Q) \<and> (P \<or> \<not> Q))"
blanchet@57169
   340
  "(P \<noteq> Q) = ((\<not> P \<or> \<not> Q) \<and> (P \<or> Q))"
blanchet@56078
   341
  by auto
blanchet@56078
   342
blanchet@56078
   343
lemma [z3_new_rule]:
blanchet@57169
   344
  "(if P then P else \<not> P) = True"
blanchet@57169
   345
  "(if \<not> P then \<not> P else P) = True"
blanchet@56078
   346
  "(if P then True else False) = P"
blanchet@57169
   347
  "(if P then False else True) = (\<not> P)"
blanchet@57169
   348
  "(if P then Q else True) = ((\<not> P) \<or> Q)"
blanchet@57169
   349
  "(if P then Q else True) = (Q \<or> (\<not> P))"
blanchet@57169
   350
  "(if P then Q else \<not> Q) = (P = Q)"
blanchet@57169
   351
  "(if P then Q else \<not> Q) = (Q = P)"
blanchet@57169
   352
  "(if P then \<not> Q else Q) = (P = (\<not> Q))"
blanchet@57169
   353
  "(if P then \<not> Q else Q) = ((\<not> Q) = P)"
blanchet@57169
   354
  "(if \<not> P then x else y) = (if P then y else x)"
blanchet@57169
   355
  "(if P then (if Q then x else y) else x) = (if P \<and> (\<not> Q) then y else x)"
blanchet@57169
   356
  "(if P then (if Q then x else y) else x) = (if (\<not> Q) \<and> P then y else x)"
blanchet@56078
   357
  "(if P then (if Q then x else y) else y) = (if P \<and> Q then x else y)"
blanchet@56078
   358
  "(if P then (if Q then x else y) else y) = (if Q \<and> P then x else y)"
blanchet@56078
   359
  "(if P then x else if P then y else z) = (if P then x else z)"
blanchet@56078
   360
  "(if P then x else if Q then x else y) = (if P \<or> Q then x else y)"
blanchet@56078
   361
  "(if P then x else if Q then x else y) = (if Q \<or> P then x else y)"
blanchet@56078
   362
  "(if P then x = y else x = z) = (x = (if P then y else z))"
blanchet@56078
   363
  "(if P then x = y else y = z) = (y = (if P then x else z))"
blanchet@56078
   364
  "(if P then x = y else z = y) = (y = (if P then x else z))"
blanchet@56078
   365
  by auto
blanchet@56078
   366
blanchet@56078
   367
lemma [z3_new_rule]:
blanchet@56078
   368
  "0 + (x::int) = x"
blanchet@56078
   369
  "x + 0 = x"
blanchet@56078
   370
  "x + x = 2 * x"
blanchet@56078
   371
  "0 * x = 0"
blanchet@56078
   372
  "1 * x = x"
blanchet@56078
   373
  "x + y = y + x"
blanchet@56078
   374
  by auto
blanchet@56078
   375
blanchet@56078
   376
lemma [z3_new_rule]:  (* for def-axiom *)
blanchet@56078
   377
  "P = Q \<or> P \<or> Q"
blanchet@57169
   378
  "P = Q \<or> \<not> P \<or> \<not> Q"
blanchet@57169
   379
  "(\<not> P) = Q \<or> \<not> P \<or> Q"
blanchet@57169
   380
  "(\<not> P) = Q \<or> P \<or> \<not> Q"
blanchet@57169
   381
  "P = (\<not> Q) \<or> \<not> P \<or> Q"
blanchet@57169
   382
  "P = (\<not> Q) \<or> P \<or> \<not> Q"
blanchet@57169
   383
  "P \<noteq> Q \<or> P \<or> \<not> Q"
blanchet@57169
   384
  "P \<noteq> Q \<or> \<not> P \<or> Q"
blanchet@57169
   385
  "P \<noteq> (\<not> Q) \<or> P \<or> Q"
blanchet@57169
   386
  "(\<not> P) \<noteq> Q \<or> P \<or> Q"
blanchet@57169
   387
  "P \<or> Q \<or> P \<noteq> (\<not> Q)"
blanchet@57169
   388
  "P \<or> Q \<or> (\<not> P) \<noteq> Q"
blanchet@57169
   389
  "P \<or> \<not> Q \<or> P \<noteq> Q"
blanchet@57169
   390
  "\<not> P \<or> Q \<or> P \<noteq> Q"
blanchet@56078
   391
  "P \<or> y = (if P then x else y)"
blanchet@56078
   392
  "P \<or> (if P then x else y) = y"
blanchet@57169
   393
  "\<not> P \<or> x = (if P then x else y)"
blanchet@57169
   394
  "\<not> P \<or> (if P then x else y) = x"
blanchet@57169
   395
  "P \<or> R \<or> \<not> (if P then Q else R)"
blanchet@57169
   396
  "\<not> P \<or> Q \<or> \<not> (if P then Q else R)"
blanchet@57169
   397
  "\<not> (if P then Q else R) \<or> \<not> P \<or> Q"
blanchet@57169
   398
  "\<not> (if P then Q else R) \<or> P \<or> R"
blanchet@57169
   399
  "(if P then Q else R) \<or> \<not> P \<or> \<not> Q"
blanchet@57169
   400
  "(if P then Q else R) \<or> P \<or> \<not> R"
blanchet@57169
   401
  "(if P then \<not> Q else R) \<or> \<not> P \<or> Q"
blanchet@57169
   402
  "(if P then Q else \<not> R) \<or> P \<or> R"
blanchet@56078
   403
  by auto
blanchet@56078
   404
blanchet@56078
   405
hide_type (open) pattern
blanchet@56078
   406
hide_const fun_app z3div z3mod
blanchet@57165
   407
hide_const (open) trigger pat nopat
blanchet@56078
   408
blanchet@56078
   409
end