src/Tools/Compute_Oracle/compute.ML
author nipkow
Fri, 07 Sep 2007 17:56:03 +0200
changeset 24553 9b19da7b2b08
parent 24137 8d7896398147
child 24584 01e83ffa6c54
permissions -rw-r--r--
added lemma
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
     1
(*  Title:      Pure/Tools/compute.ML
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     3
    Author:     Steven Obua
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     4
*)
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     5
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     6
signature COMPUTE = sig
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     7
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     8
    type computer
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
     9
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    10
    datatype machine = BARRAS | BARRAS_COMPILED | HASKELL | SML
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    11
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    12
    exception Make of string
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    13
    val make : machine -> theory -> thm list -> computer
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    14
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    15
    exception Compute of string
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    16
    val compute : computer -> (int -> string) -> cterm -> term
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    17
    val theory_of : computer -> theory
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    18
    val hyps_of : computer -> term list
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    19
    val shyps_of : computer -> sort list
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    20
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    21
    val rewrite_param : computer -> (int -> string) -> cterm -> thm
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    22
    val rewrite : computer -> cterm -> thm
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    23
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    24
    val discard : computer -> unit
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    25
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    26
    val setup : theory -> theory
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    27
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    28
end
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    29
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    30
structure Compute :> COMPUTE = struct
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    31
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    32
datatype machine = BARRAS | BARRAS_COMPILED | HASKELL | SML	 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    33
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    34
(* Terms are mapped to integer codes *)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    35
structure Encode :> 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    36
sig
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    37
    type encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    38
    val empty : encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    39
    val insert : term -> encoding -> int * encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    40
    val lookup_code : term -> encoding -> int option
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    41
    val lookup_term : int -> encoding -> term option					
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    42
    val remove_code : int -> encoding -> encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    43
    val remove_term : term -> encoding -> encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    44
    val fold : ((term * int) -> 'a -> 'a) -> encoding -> 'a -> 'a    
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    45
end 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    46
= 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    47
struct
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    48
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    49
type encoding = int * (int Termtab.table) * (term Inttab.table)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    50
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    51
val empty = (0, Termtab.empty, Inttab.empty)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    52
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    53
fun insert t (e as (count, term2int, int2term)) = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    54
    (case Termtab.lookup term2int t of
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    55
	 NONE => (count, (count+1, Termtab.update_new (t, count) term2int, Inttab.update_new (count, t) int2term))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    56
       | SOME code => (code, e))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    57
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    58
fun lookup_code t (_, term2int, _) = Termtab.lookup term2int t
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    59
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    60
fun lookup_term c (_, _, int2term) = Inttab.lookup int2term c
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    61
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    62
fun remove_code c (e as (count, term2int, int2term)) = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    63
    (case lookup_term c e of NONE => e | SOME t => (count, Termtab.delete t term2int, Inttab.delete c int2term))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    64
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    65
fun remove_term t (e as (count, term2int, int2term)) = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    66
    (case lookup_code t e of NONE => e | SOME c => (count, Termtab.delete t term2int, Inttab.delete c int2term))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    67
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    68
fun fold f (_, term2int, _) = Termtab.fold f term2int 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    69
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    70
end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    71
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    72
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    73
exception Make of string;
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    74
exception Compute of string;
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    75
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    76
local
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    77
    fun make_constant t ty encoding = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    78
	let 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    79
	    val (code, encoding) = Encode.insert t encoding 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    80
	in 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    81
	    (encoding, AbstractMachine.Const code)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    82
	end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    83
in
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
    84
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    85
fun remove_types encoding t =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    86
    case t of 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    87
	Var (_, ty) => make_constant t ty encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    88
      | Free (_, ty) => make_constant t ty encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    89
      | Const (_, ty) => make_constant t ty encoding
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    90
      | Abs (_, ty, t') => 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    91
	let val (encoding, t'') = remove_types encoding t' in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    92
	    (encoding, AbstractMachine.Abs t'')
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    93
	end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    94
      | a $ b => 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    95
	let
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    96
	    val (encoding, a) = remove_types encoding a
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    97
	    val (encoding, b) = remove_types encoding b
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    98
	in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
    99
	    (encoding, AbstractMachine.App (a,b))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   100
	end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   101
      | Bound b => (encoding, AbstractMachine.Var b)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   102
end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   103
    
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   104
local
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   105
    fun type_of (Free (_, ty)) = ty
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   106
      | type_of (Const (_, ty)) = ty
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   107
      | type_of (Var (_, ty)) = ty
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   108
      | type_of _ = sys_error "infer_types: type_of error"
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   109
in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   110
fun infer_types naming encoding =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   111
    let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   112
        fun infer_types _ bounds _ (AbstractMachine.Var v) = (Bound v, List.nth (bounds, v))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   113
	  | infer_types _ bounds _ (AbstractMachine.Const code) = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   114
	    let
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   115
		val c = the (Encode.lookup_term code encoding)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   116
	    in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   117
		(c, type_of c)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   118
	    end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   119
	  | infer_types level bounds _ (AbstractMachine.App (a, b)) = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   120
	    let
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   121
		val (a, aty) = infer_types level bounds NONE a
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   122
		val (adom, arange) =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   123
                    case aty of
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   124
                        Type ("fun", [dom, range]) => (dom, range)
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   125
                      | _ => sys_error "infer_types: function type expected"
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   126
                val (b, bty) = infer_types level bounds (SOME adom) b
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   127
	    in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   128
		(a $ b, arange)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   129
	    end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   130
          | infer_types level bounds (SOME (ty as Type ("fun", [dom, range]))) (AbstractMachine.Abs m) =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   131
            let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   132
                val (m, _) = infer_types (level+1) (dom::bounds) (SOME range) m
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   133
            in
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   134
                (Abs (naming level, dom, m), ty)
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   135
            end
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   136
          | infer_types _ _ NONE (AbstractMachine.Abs m) = sys_error "infer_types: cannot infer type of abstraction"
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   137
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   138
        fun infer ty term =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   139
            let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   140
                val (term', _) = infer_types 0 [] (SOME ty) term
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   141
            in
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   142
                term'
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   143
            end
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   144
    in
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   145
        infer
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   146
    end
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   147
end
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   148
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   149
datatype prog = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   150
	 ProgBarras of AM_Interpreter.program 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   151
       | ProgBarrasC of AM_Compiler.program
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   152
       | ProgHaskell of AM_GHC.program
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   153
       | ProgSML of AM_SML.program
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   154
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   155
structure Sorttab = TableFun(type key = sort val ord = Term.sort_ord)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   156
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   157
datatype computer = Computer of theory_ref * Encode.encoding * term list * unit Sorttab.table * prog
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   158
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   159
datatype cthm = ComputeThm of term list * sort list * term
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   160
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   161
fun thm2cthm th = 
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   162
    let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   163
	val {hyps, prop, tpairs, shyps, ...} = Thm.rep_thm th
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   164
	val _ = if not (null tpairs) then raise Make "theorems may not contain tpairs" else ()
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   165
    in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   166
	ComputeThm (hyps, shyps, prop)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   167
    end
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   168
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   169
fun make machine thy raw_ths =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   170
    let
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   171
	fun transfer (x:thm) = Thm.transfer thy x
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   172
	val ths = map (thm2cthm o Thm.strip_shyps o transfer) raw_ths
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   173
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   174
        fun thm2rule (encoding, hyptable, shyptable) th =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   175
            let
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   176
		val (ComputeThm (hyps, shyps, prop)) = th
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   177
		val hyptable = fold (fn h => Termtab.update (h, ())) hyps hyptable
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   178
		val shyptable = fold (fn sh => Sorttab.update (sh, ())) shyps shyptable
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   179
		val (prems, prop) = (Logic.strip_imp_prems prop, Logic.strip_imp_concl prop)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   180
                val (a, b) = Logic.dest_equals prop
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   181
                  handle TERM _ => raise (Make "theorems must be meta-level equations (with optional guards)")
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   182
		val a = Envir.eta_contract a
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   183
		val b = Envir.eta_contract b
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   184
		val prems = map Envir.eta_contract prems
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   185
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   186
                val (encoding, left) = remove_types encoding a     
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   187
		val (encoding, right) = remove_types encoding b  
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   188
                fun remove_types_of_guard encoding g = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   189
		    (let
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   190
			 val (t1, t2) = Logic.dest_equals g 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   191
			 val (encoding, t1) = remove_types encoding t1
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   192
			 val (encoding, t2) = remove_types encoding t2
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   193
		     in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   194
			 (encoding, AbstractMachine.Guard (t1, t2))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   195
		     end handle TERM _ => raise (Make "guards must be meta-level equations"))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   196
                val (encoding, prems) = fold_rev (fn p => fn (encoding, ps) => let val (e, p) = remove_types_of_guard encoding p in (e, p::ps) end) prems (encoding, [])
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   197
                
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   198
                fun make_pattern encoding n vars (var as AbstractMachine.Abs _) =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   199
		    raise (Make "no lambda abstractions allowed in pattern")
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   200
		  | make_pattern encoding n vars (var as AbstractMachine.Var _) =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   201
		    raise (Make "no bound variables allowed in pattern")
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   202
		  | make_pattern encoding n vars (AbstractMachine.Const code) =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   203
		    (case the (Encode.lookup_term code encoding) of
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   204
			 Var _ => ((n+1, Inttab.update_new (code, n) vars, AbstractMachine.PVar)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   205
				   handle Inttab.DUP _ => raise (Make "no duplicate variable in pattern allowed"))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   206
		       | _ => (n, vars, AbstractMachine.PConst (code, [])))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   207
                  | make_pattern encoding n vars (AbstractMachine.App (a, b)) =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   208
                    let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   209
                        val (n, vars, pa) = make_pattern encoding n vars a
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   210
                        val (n, vars, pb) = make_pattern encoding n vars b
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   211
                    in
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   212
                        case pa of
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   213
                            AbstractMachine.PVar =>
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   214
                              raise (Make "patterns may not start with a variable")
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   215
                          | AbstractMachine.PConst (c, args) =>
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   216
                              (n, vars, AbstractMachine.PConst (c, args@[pb]))
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   217
                    end
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   218
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   219
                (* Principally, a check should be made here to see if the (meta-) hyps contain any of the variables of the rule.
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   220
                   As it is, all variables of the rule are schematic, and there are no schematic variables in meta-hyps, therefore
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   221
                   this check can be left out. *)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   222
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   223
                val (vcount, vars, pattern) = make_pattern encoding 0 Inttab.empty left
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   224
                val _ = (case pattern of
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   225
                             AbstractMachine.PVar =>
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   226
                             raise (Make "patterns may not start with a variable")
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   227
                         (*  | AbstractMachine.PConst (_, []) => 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   228
			     (print th; raise (Make "no parameter rewrite found"))*)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   229
			   | _ => ())
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   230
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   231
                (* finally, provide a function for renaming the
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   232
                   pattern bound variables on the right hand side *)
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   233
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   234
                fun rename level vars (var as AbstractMachine.Var _) = var
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   235
		  | rename level vars (c as AbstractMachine.Const code) =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   236
		    (case Inttab.lookup vars code of 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   237
			 NONE => c 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   238
		       | SOME n => AbstractMachine.Var (vcount-n-1+level))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   239
                  | rename level vars (AbstractMachine.App (a, b)) =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   240
                    AbstractMachine.App (rename level vars a, rename level vars b)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   241
                  | rename level vars (AbstractMachine.Abs m) =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   242
                    AbstractMachine.Abs (rename (level+1) vars m)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   243
		    
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   244
		fun rename_guard (AbstractMachine.Guard (a,b)) = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   245
		    AbstractMachine.Guard (rename 0 vars a, rename 0 vars b)
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   246
            in
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   247
                ((encoding, hyptable, shyptable), (map rename_guard prems, pattern, rename 0 vars right))
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   248
            end
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   249
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   250
        val ((encoding, hyptable, shyptable), rules) =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   251
          fold_rev (fn th => fn (encoding_hyptable, rules) =>
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   252
            let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   253
              val (encoding_hyptable, rule) = thm2rule encoding_hyptable th
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   254
            in (encoding_hyptable, rule::rules) end)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   255
          ths ((Encode.empty, Termtab.empty, Sorttab.empty), [])
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   256
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   257
        val prog = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   258
	    case machine of 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   259
		BARRAS => ProgBarras (AM_Interpreter.compile rules)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   260
	      | BARRAS_COMPILED => ProgBarrasC (AM_Compiler.compile rules)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   261
	      | HASKELL => ProgHaskell (AM_GHC.compile rules)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   262
	      | SML => ProgSML (AM_SML.compile rules)
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   263
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   264
(*	val _ = print (Encode.fold (fn x => fn s => x::s) encoding [])*)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   265
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   266
        fun has_witness s = not (null (Sign.witness_sorts thy [] [s]))
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   267
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   268
	val shyptable = fold Sorttab.delete (filter has_witness (Sorttab.keys (shyptable))) shyptable
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   269
24137
8d7896398147 replaced Theory.self_ref by Theory.check_thy, which now produces a checked ref;
wenzelm
parents: 23663
diff changeset
   270
    in Computer (Theory.check_thy thy, encoding, Termtab.keys hyptable, shyptable, prog) end
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   271
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   272
(*fun timeit f =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   273
    let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   274
	val t1 = Time.toMicroseconds (Time.now ())
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   275
	val x = f ()
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   276
	val t2 = Time.toMicroseconds (Time.now ())
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   277
	val _ = writeln ("### time = "^(Real.toString ((Real.fromLargeInt t2 - Real.fromLargeInt t1)/(1000000.0)))^"s")
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   278
    in
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   279
	x
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   280
    end*)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   281
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   282
fun report s f = f () (*writeln s; timeit f*)
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   283
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   284
fun compute (Computer (rthy, encoding, hyps, shyptable, prog)) naming ct =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   285
    let
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   286
	fun run (ProgBarras p) = AM_Interpreter.run p
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   287
	  | run (ProgBarrasC p) = AM_Compiler.run p
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   288
	  | run (ProgHaskell p) = AM_GHC.run p
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   289
	  | run (ProgSML p) = AM_SML.run p	    
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   290
        val {t=t, T=ty, thy=ctthy, ...} = rep_cterm ct
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   291
        val thy = Theory.merge (Theory.deref rthy, ctthy)
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   292
        val (encoding, t) = report "remove_types" (fn () => remove_types encoding t)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   293
        val t = report "run" (fn () => run prog t)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   294
        val t = report "infer_types" (fn () => infer_types naming encoding ty t)
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   295
    in
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   296
        t
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   297
    end
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   298
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   299
fun discard (Computer (rthy, encoding, hyps, shyptable, prog)) = 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   300
    (case prog of
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   301
	 ProgBarras p => AM_Interpreter.discard p
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   302
       | ProgBarrasC p => AM_Compiler.discard p
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   303
       | ProgHaskell p => AM_GHC.discard p
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   304
       | ProgSML p => AM_SML.discard p)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   305
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   306
fun theory_of (Computer (rthy, _, _,_,_)) = Theory.deref rthy
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   307
fun hyps_of (Computer (_, _, hyps, _, _)) = hyps
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   308
fun shyps_of (Computer (_, _, _, shyptable, _)) = Sorttab.keys (shyptable)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   309
fun shyptab_of (Computer (_, _, _, shyptable, _)) = shyptable
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   310
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   311
fun default_naming i = "v_" ^ Int.toString i
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   312
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   313
exception Param of computer * (int -> string) * cterm;
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   314
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   315
fun rewrite_param r n ct =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   316
    let 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   317
	val thy = theory_of_cterm ct 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   318
	val th = timeit (fn () => invoke_oracle_i thy "Compute_Oracle.compute" (thy, Param (r, n, ct)))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   319
	val hyps = map (fn h => assume (cterm_of thy h)) (hyps_of r)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   320
    in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   321
	fold (fn h => fn p => implies_elim p h) hyps th 
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   322
    end
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   323
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   324
(*fun rewrite_param r n ct =
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   325
    let	
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   326
	val hyps = hyps_of r
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   327
	val shyps = shyps_of r
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   328
	val thy = theory_of_cterm ct
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   329
	val _ = Theory.assert_super (theory_of r) thy
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   330
	val t' = timeit (fn () => compute r n ct)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   331
	val eq = Logic.mk_equals (term_of ct, t')
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   332
    in
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   333
	Thm.unchecked_oracle thy "Compute.compute" (eq, hyps, shyps)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   334
    end*)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   335
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   336
fun rewrite r ct = rewrite_param r default_naming ct
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   337
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   338
(* theory setup *)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   339
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   340
fun compute_oracle (thy, Param (r, naming, ct)) =
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   341
    let
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   342
        val _ = Theory.assert_super (theory_of r) thy
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   343
        val t' = compute r naming ct
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   344
	val eq = Logic.mk_equals (term_of ct, t')
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   345
	val hyps = hyps_of r
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   346
	val shyptab = shyptab_of r
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   347
	fun delete s shyptab = Sorttab.delete s shyptab handle Sorttab.UNDEF _ => shyptab
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   348
	fun delete_term t shyptab = fold delete (Sorts.insert_term t []) shyptab
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   349
	val shyps = if Sorttab.is_empty shyptab then [] else Sorttab.keys (fold delete_term (eq::hyps) shyptab)
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   350
	val _ = if not (null shyps) then raise Compute ("dangling sort hypotheses: "^(makestring shyps)) else ()
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   351
    in
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   352
        fold_rev (fn hyp => fn p => Logic.mk_implies (hyp, p)) hyps eq
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   353
    end
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   354
  | compute_oracle _ = raise Match
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   355
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   356
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   357
val setup = (fn thy => (writeln "install oracle"; Theory.add_oracle ("compute", compute_oracle) thy))
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   358
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   359
(*val _ = Context.add_setup (Theory.add_oracle ("compute", compute_oracle))*)
23174
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   360
3913451b0418 moved Compute_Oracle from Pure/Tools to Tools;
wenzelm
parents:
diff changeset
   361
end
23663
84b5c89b8b49 new version of computing oracle
obua
parents: 23174
diff changeset
   362