CookBook/Recipes/ExternalSolver.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 05 Feb 2009 22:44:11 +0000
changeset 100 dd8eebae11ec
parent 94 531e453c9d67
child 102 5e309df58557
permissions -rw-r--r--
polished
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
     1
theory ExternalSolver
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
     2
imports "../Base"
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
     3
uses ("external_solver.ML")
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
     4
begin
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
     5
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
     6
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
     7
section {* Executing an External Application *}
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
     8
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
     9
text {*
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    10
  {\bf Problem:}
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    11
  You want to use an external application.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    12
  \smallskip
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    13
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    14
  {\bf Solution:} The function @{ML system_out} might be the right thing for
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    15
  you.
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    16
  \smallskip
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    17
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    18
  This function executes an external command as if printed in a shell. It
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    19
  returns the output of the program and its return value.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    20
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    21
  For example, consider running an ordinary shell commands:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    22
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    23
  @{ML_response [display,gray] 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    24
    "system_out \"echo Hello world!\"" "(\"Hello world!\\n\", 0)"}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    25
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    26
  Note that it works also fine with timeouts (see Recipe~\ref{rec:timeout}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    27
  on Page~\pageref{rec:timeout}), i.e. external applications are killed
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    28
  properly. For example, the following expression takes only approximately
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    29
  one second:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    30
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    31
  @{ML_response [display,gray] 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    32
    "TimeLimit.timeLimit (Time.fromSeconds 1) system_out \"sleep 30\"
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    33
     handle TimeLimit.TimeOut => (\"timeout\", ~1)" "(\"timeout\", ~1)"}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    34
*}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    35
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    36
text {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    37
  The function @{ML system_out} can also be used for more reasonable
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    38
  applications, e.g. coupling external solvers with Isabelle. In that case,
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    39
  one has to make sure that Isabelle can find the particular executable.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    40
  One way to ensure this is by adding a Bash-like variable binding into
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    41
  one of Isabelle's settings file (prefer the user settings file usually to
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    42
  be found at @{text "$HOME/.isabelle/etc/settings"}).
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    43
  
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    44
  For example, assume you want to use the application @{text foo} which
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    45
  is here supposed to be located at @{text "/usr/local/bin/"}.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    46
  The following line has to be added to one of Isabelle's settings file:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    47
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    48
  @{text "FOO=/usr/local/bin/foo"}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    49
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    50
  In Isabelle, this application may now be executed by
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    51
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    52
  @{ML_response_fake [display,gray] "system_out \"$FOO\"" "\<dots>"}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    53
*}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    54
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    55
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    56
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    57
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    58
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    59
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    60
section {* Writing an Oracle\label{rec:external} *} 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    61
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    62
text {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    63
  {\bf Problem:}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    64
  You want to use a fast, new decision procedure not based one Isabelle's
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    65
  tactics, and you do not care whether it is sound.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    66
  \smallskip
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    67
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    68
  {\bf Solution:} Isabelle provides the oracle mechanisms to bypass the
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    69
  inference kernel. Note that theorems proven by an oracle carry a special
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    70
  mark to inform the user of their potential incorrectness.
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    71
  \smallskip
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    72
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    73
  \begin{readmore}
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    74
  A short introduction to oracles can be found in [isar-ref: no suitable label
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    75
  for section 3.11]. A simple example, which we will slightly extend here,
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    76
  is given in @{ML_file "FOL/ex/IffOracle"}. The raw interface for adding
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    77
  oracles is @{ML add_oracle in Thm} in @{ML_file "Pure/thm"}.
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    78
  \end{readmore}
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    79
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    80
  For our explanation here, we restrict ourselves to decide propositional
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    81
  formulae which consist only of equivalences between propositional variables,
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    82
  i.e. we want to decide whether @{term "P = (Q = P) = Q"} is a tautology.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    83
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    84
  Assume, that we have a decision procedure for such formulae, implemented
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    85
  in ML. Since we do not care how it works, we will use it here as an
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    86
  ``external solver'':
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    87
*}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    88
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    89
use "external_solver.ML"
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
    90
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    91
text {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    92
  We do, however, know that the solver provides a function
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    93
  @{ML IffSolver.decide}.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    94
  It takes a string representation of a formula and returns either
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    95
  @{ML true} if the formula is a tautology or
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    96
  @{ML false} otherwise. The input syntax is specified as follows:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    97
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    98
  formula $::=$ atom $\mid$ \verb|(| formula \verb|<=>| formula \verb|)|
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
    99
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   100
  and all token are separated by at least one space.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   101
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   102
  (FIXME: is there a better way for describing the syntax?)
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   103
 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   104
  We will proceed in the following way. We start by translating a HOL formula
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   105
  into the string representation expected by the solver. The solver's result
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   106
  is then used to build an oracle, which we will subsequently use as a core
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   107
  for an Isar method to be able to apply the oracle in proving theorems.
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   108
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   109
  Let us start with the translation function from Isabelle propositions into
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   110
  the solver's string representation. To increase efficiency while building
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   111
  the string, we use functions from the @{text Buffer} module.
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   112
  *}
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   113
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   114
ML {*fun translate t =
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   115
  let
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   116
    fun trans t =
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   117
      (case t of
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   118
        @{term "op = :: bool \<Rightarrow> bool \<Rightarrow> bool"} $ t $ u =>
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   119
          Buffer.add " (" #>
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   120
          trans t #>
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   121
          Buffer.add "<=>" #> 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   122
          trans u #>
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   123
          Buffer.add ") "
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   124
      | Free (n, @{typ bool}) =>
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   125
         Buffer.add " " #> 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   126
         Buffer.add n #>
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   127
         Buffer.add " "
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   128
      | _ => error "inacceptable term")
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   129
  in Buffer.content (trans t Buffer.empty) end
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   130
*}
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   131
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   132
text {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   133
  Here is the string representation of the term @{term "p = (q = p)"}:
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   134
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   135
  @{ML_response 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   136
    "translate @{term \"p = (q = p)\"}" 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   137
    "\" ( p <=> ( q <=> p ) ) \""}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   138
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   139
  Let us check, what the solver returns when given a tautology:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   140
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   141
  @{ML_response 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   142
    "IffSolver.decide (translate @{term \"p = (q = p) = q\"})"
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   143
    "true"}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   144
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   145
  And here is what it returns for a formula which is not valid:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   146
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   147
  @{ML_response 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   148
    "IffSolver.decide (translate @{term \"p = (q = p)\"})" 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   149
    "false"}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   150
*}
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   151
79
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   152
text {* 
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   153
  Now, we combine these functions into an oracle. In general, an oracle may
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   154
  be given any input, but it has to return a certified proposition (a
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   155
  special term which is type-checked), out of which Isabelle's inference
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   156
  kernel ``magically'' makes a theorem.
79
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   157
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   158
  Here, we take the proposition to be show as input. Note that we have
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   159
  to first extract the term which is then passed to the translation and
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   160
  decision procedure. If the solver finds this term to be valid, we return
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   161
  the given proposition unchanged to be turned then into a theorem:
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   162
*}
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   163
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   164
oracle iff_oracle = {* fn ct =>
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   165
  if IffSolver.decide (translate (HOLogic.dest_Trueprop (Thm.term_of ct)))
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   166
  then ct
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   167
  else error "Proof failed."*}
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   168
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   169
text {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   170
  Here is what we get when applying the oracle:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   171
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   172
  @{ML_response_fake "iff_oracle @{cprop \"p = (p::bool)\"}" "p = p"}
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   173
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   174
  (FIXME: is there a better way to present the theorem?)
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   175
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   176
  To be able to use our oracle for Isar proofs, we wrap it into a tactic:
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   177
*}
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   178
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   179
ML{*val iff_oracle_tac =
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   180
  CSUBGOAL (fn (goal, i) => 
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   181
    (case try iff_oracle goal of
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   182
      NONE => no_tac
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   183
    | SOME thm => rtac thm i))*}
79
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   184
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   185
text {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   186
  and create a new method solely based on this tactic:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   187
*}
79
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   188
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   189
method_setup iff_oracle = {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   190
   Method.no_args (Method.SIMPLE_METHOD' iff_oracle_tac)
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   191
*} "Oracle-based decision procedure for chains of equivalences"
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   192
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   193
text {*
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   194
  (FIXME: what does @{ML "Method.SIMPLE_METHOD'"} do? ... what do you mean?)
79
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   195
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   196
  Finally, we can test our oracle to prove some theorems:
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   197
*}
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   198
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   199
lemma "p = (p::bool)"
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   200
   by iff_oracle
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   201
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   202
lemma "p = (q = p) = q"
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   203
   by iff_oracle
79
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   204
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   205
a53c7810e38b some tuning
Christian Urban <urbanc@in.tum.de>
parents: 61
diff changeset
   206
text {*
94
531e453c9d67 rewrote recipes describing external solvers
boehmes
parents: 83
diff changeset
   207
(FIXME: say something about what the proof of the oracle is ... what do you mean?)
83
0fb5f91d5109 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 81
diff changeset
   208
*} 
0fb5f91d5109 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 81
diff changeset
   209
0fb5f91d5109 fixed typos
Christian Urban <urbanc@in.tum.de>
parents: 81
diff changeset
   210
61
64c9540f2f84 Added four recipes.
boehmes
parents:
diff changeset
   211
end