src/Tools/Code/code_runtime.ML
changeset 56973 62da80041afd
parent 56969 7491932da574
child 57435 312660c1a70a
equal deleted inserted replaced
56972:f64730f667b9 56973:62da80041afd
    15     -> ((term -> term) -> 'a -> 'a) -> term -> string list -> 'a option
    15     -> ((term -> term) -> 'a -> 'a) -> term -> string list -> 'a option
    16   val dynamic_value_strict: 'a cookie -> Proof.context -> string option
    16   val dynamic_value_strict: 'a cookie -> Proof.context -> string option
    17     -> ((term -> term) -> 'a -> 'a) -> term -> string list -> 'a
    17     -> ((term -> term) -> 'a -> 'a) -> term -> string list -> 'a
    18   val dynamic_value_exn: 'a cookie -> Proof.context -> string option
    18   val dynamic_value_exn: 'a cookie -> Proof.context -> string option
    19     -> ((term -> term) -> 'a -> 'a) -> term -> string list -> 'a Exn.result
    19     -> ((term -> term) -> 'a -> 'a) -> term -> string list -> 'a Exn.result
    20   val static_value: 'a cookie -> Proof.context -> string option
    20   val static_value: 'a cookie -> { ctxt: Proof.context, target: string option,
    21     -> ((term -> term) -> 'a -> 'a) -> string list -> Proof.context -> term -> 'a option
    21     lift_postproc: (term -> term) -> 'a -> 'a, consts: string list }
    22   val static_value_strict: 'a cookie -> Proof.context -> string option
    22     -> Proof.context -> term -> 'a option
    23     -> ((term -> term) -> 'a -> 'a) -> string list -> Proof.context -> term -> 'a
    23   val static_value_strict: 'a cookie -> { ctxt: Proof.context, target: string option,
    24   val static_value_exn: 'a cookie -> Proof.context -> string option
    24     lift_postproc: (term -> term) -> 'a -> 'a, consts: string list }
    25     -> ((term -> term) -> 'a -> 'a) -> string list -> Proof.context -> term -> 'a Exn.result
    25     -> Proof.context -> term -> 'a
       
    26   val static_value_exn: 'a cookie -> { ctxt: Proof.context, target: string option,
       
    27     lift_postproc: (term -> term) -> 'a -> 'a, consts: string list }
       
    28     -> Proof.context -> term -> 'a Exn.result
    26   val dynamic_holds_conv: Proof.context -> conv
    29   val dynamic_holds_conv: Proof.context -> conv
    27   val static_holds_conv: Proof.context -> string list -> Proof.context -> conv
    30   val static_holds_conv: { ctxt: Proof.context, consts: string list } -> Proof.context -> conv
    28   val code_reflect: (string * string list option) list -> string list -> string
    31   val code_reflect: (string * string list option) list -> string list -> string
    29     -> string option -> theory -> theory
    32     -> string option -> theory -> theory
    30   datatype truth = Holds
    33   datatype truth = Holds
    31   val put_truth: (unit -> truth) -> Proof.context -> Proof.context
    34   val put_truth: (unit -> truth) -> Proof.context -> Proof.context
    32   val trace: bool Unsynchronized.ref
    35   val trace: bool Unsynchronized.ref
   120   Exn.release (dynamic_value_exn cookie ctxt some_target postproc t args);
   123   Exn.release (dynamic_value_exn cookie ctxt some_target postproc t args);
   121 
   124 
   122 fun dynamic_value cookie ctxt some_target postproc t args =
   125 fun dynamic_value cookie ctxt some_target postproc t args =
   123   partiality_as_none (dynamic_value_exn cookie ctxt some_target postproc t args);
   126   partiality_as_none (dynamic_value_exn cookie ctxt some_target postproc t args);
   124 
   127 
   125 fun static_evaluator cookie ctxt some_target program consts' =
   128 fun static_evaluator cookie ctxt some_target { program, deps } =
   126   let
   129   let
   127     val evaluator = obtain_evaluator ctxt some_target program (map Constant consts');
   130     val evaluator = obtain_evaluator ctxt some_target program (map Constant deps);
   128     val evaluation' = evaluation cookie ctxt evaluator;
   131     val evaluation' = evaluation cookie ctxt evaluator;
   129   in fn _ => fn _ => fn vs_ty_t => fn _ => evaluation' vs_ty_t [] end;
   132   in fn _ => fn _ => fn vs_ty_t => fn _ => evaluation' vs_ty_t [] end;
   130 
   133 
   131 fun static_value_exn cookie ctxt some_target postproc consts =
   134 fun static_value_exn cookie { ctxt, target, lift_postproc, consts } =
   132   let
   135   let
   133     val evaluator = Code_Thingol.static_value ctxt (Exn.map_result o postproc) consts
   136     val evaluator = Code_Thingol.static_value { ctxt = ctxt,
   134       (static_evaluator cookie ctxt some_target);
   137       lift_postproc = Exn.map_result o lift_postproc, consts = consts }
       
   138       (static_evaluator cookie ctxt target);
   135   in fn ctxt' => evaluator ctxt' o reject_vars ctxt' end;
   139   in fn ctxt' => evaluator ctxt' o reject_vars ctxt' end;
   136 
   140 
   137 fun static_value_strict cookie ctxt some_target postproc consts =
   141 fun static_value_strict cookie = Exn.release ooo static_value_exn cookie;
   138   Exn.release oo static_value_exn cookie ctxt some_target postproc consts;
   142 
   139 
   143 fun static_value cookie = partiality_as_none ooo static_value_exn cookie;
   140 fun static_value cookie thy some_target postproc consts =
       
   141   partiality_as_none oo static_value_exn cookie thy some_target postproc consts;
       
   142 
   144 
   143 
   145 
   144 (* evaluation for truth or nothing *)
   146 (* evaluation for truth or nothing *)
   145 
   147 
   146 structure Truth_Result = Proof_Data
   148 structure Truth_Result = Proof_Data
   183 fun dynamic_holds_conv ctxt = Code_Thingol.dynamic_conv ctxt
   185 fun dynamic_holds_conv ctxt = Code_Thingol.dynamic_conv ctxt
   184   (fn program => fn vs_t => fn deps =>
   186   (fn program => fn vs_t => fn deps =>
   185     check_holds_oracle ctxt (obtain_evaluator ctxt NONE program deps) vs_t)
   187     check_holds_oracle ctxt (obtain_evaluator ctxt NONE program deps) vs_t)
   186       o reject_vars ctxt;
   188       o reject_vars ctxt;
   187 
   189 
   188 fun static_holds_conv ctxt consts =
   190 fun static_holds_conv (ctxt_consts as { ctxt, ... }) =
   189   Code_Thingol.static_conv ctxt consts (fn program => fn consts' =>
   191   Code_Thingol.static_conv ctxt_consts (fn { program, deps } => fn ctxt' => fn vs_t =>
   190     let
   192     K (check_holds_oracle ctxt' (obtain_evaluator ctxt NONE program (map Constant deps)) vs_t o reject_vars ctxt'));
   191       val evaluator' = obtain_evaluator ctxt NONE program (map Constant consts')
       
   192     in
       
   193       fn ctxt' => fn vs_t => fn _ => check_holds_oracle ctxt' evaluator' vs_t o reject_vars ctxt'
       
   194     end);
       
   195 
       
   196 (* o reject_vars ctxt'*)
       
   197 
   193 
   198 end; (*local*)
   194 end; (*local*)
   199 
   195 
   200 
   196 
   201 (** instrumentalization **)
   197 (** instrumentalization **)