-
Notifications
You must be signed in to change notification settings - Fork 80
/
util.lean
51 lines (41 loc) · 1.94 KB
/
util.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import init.meta.format
universes u
/-- This function has a native implementation that tracks time. -/
def timeit {α : Type u} (s : string) (f : thunk α) : α :=
f ()
/-- This function has a native implementation that displays the given string in the regular output stream. -/
def trace {α : Type u} (s : string) (f : thunk α) : α :=
f ()
meta def trace_val {α : Type u} [has_to_format α] (f : α) : α :=
trace (to_fmt f).to_string f
/-- This function has a native implementation that shows the VM call stack. -/
def trace_call_stack {α : Type u} (f : thunk α) : α :=
f ()
/-- This function has a native implementation that displays in the given position all trace messages used in f.
The arguments line and col are filled by the elaborator. -/
def scope_trace {α : Type u} {line col: nat} (f : thunk α) : α :=
f ()
/--
This function has a native implementation where
the thunk is interrupted if it takes more than 'max' "heartbeats" to compute it.
The heartbeat is approx. the maximum number of memory allocations (in thousands) performed by 'f ()'.
This is a deterministic way of interrupting long running tasks. -/
meta def try_for {α : Type u} (max : nat) (f : thunk α) : option α :=
some (f ())
/--
This function has a native implementation where
the thunk is interrupted if it takes more than `max` milliseconds to compute it.
This is useful due to the variance in the number of heartbeats used by tactics. -/
meta def try_for_time {α : Type u} (max : ℕ) (f : thunk α) : option α :=
some (f ())
/-- Throws an exception when it is evaluated. -/
meta constant undefined_core {α : Sort u} (message : string) : α
meta def undefined {α : Sort u} : α := undefined_core "undefined"
meta def unchecked_cast {α : Sort u} {β : Sort u} : α → β :=
cast undefined