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