src/HOL/Library/Debug.thy
author haftmann
Sun, 22 Jul 2012 09:56:34 +0200
changeset 49442 571cb1df0768
child 53066 5e8a0b8bb070
permissions -rw-r--r--
library theories for debugging and parallel computing using code generation towards Isabelle/ML
haftmann@49442
     1
(* Author: Florian Haftmann, TU Muenchen *)
haftmann@49442
     2
haftmann@49442
     3
header {* Debugging facilities for code generated towards Isabelle/ML *}
haftmann@49442
     4
haftmann@49442
     5
theory Debug
haftmann@49442
     6
imports Main
haftmann@49442
     7
begin
haftmann@49442
     8
haftmann@49442
     9
definition trace :: "String.literal \<Rightarrow> unit" where
haftmann@49442
    10
  [simp]: "trace s = ()"
haftmann@49442
    11
haftmann@49442
    12
definition tracing :: "String.literal \<Rightarrow> 'a \<Rightarrow> 'a" where
haftmann@49442
    13
  [simp]: "tracing s = id"
haftmann@49442
    14
haftmann@49442
    15
lemma [code]:
haftmann@49442
    16
  "tracing s = (let u = trace s in id)"
haftmann@49442
    17
  by simp
haftmann@49442
    18
haftmann@49442
    19
definition flush :: "'a \<Rightarrow> unit" where
haftmann@49442
    20
  [simp]: "flush x = ()"
haftmann@49442
    21
haftmann@49442
    22
definition flushing :: "'a \<Rightarrow> 'b \<Rightarrow> 'b" where
haftmann@49442
    23
  [simp]: "flushing x = id"
haftmann@49442
    24
haftmann@49442
    25
lemma [code, code_unfold]:
haftmann@49442
    26
  "flushing x = (let u = flush x in id)"
haftmann@49442
    27
  by simp
haftmann@49442
    28
haftmann@49442
    29
definition timing :: "String.literal \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" where
haftmann@49442
    30
  [simp]: "timing s f x = f x"
haftmann@49442
    31
haftmann@49442
    32
code_const trace and flush and timing
haftmann@49442
    33
  (Eval "Output.tracing" and "Output.tracing/ (PolyML.makestring _)" and "Timing.timeap'_msg")
haftmann@49442
    34
haftmann@49442
    35
code_reserved Eval Output PolyML Timing
haftmann@49442
    36
haftmann@49442
    37
hide_const (open) trace tracing flush flushing timing
haftmann@49442
    38
haftmann@49442
    39
end
haftmann@49442
    40