@@ -8,7 +8,7 @@ Feedback.with_traces : (string * int) list -> ('a -> 'b) -> 'a -> 'b
88
99Invoke a function with specified levels for traces.
1010
11- The ` with_traces ` function is used to set values for a collection of
11+ The ` with_traces ` function is used to set values of a collection of
1212tracing variables for the duration of one top-level function call.
1313
1414In a state where trace variables designated by ` nm_1,...,nm_k ` have
@@ -30,67 +30,28 @@ if the function invocation fails.
3030
3131### Example
3232
33- In the following we make a recursive definition, temporarily setting
34- some traces so that aspects of the internal workings of the definition
35- mechanism are printed out. First we find the present values of the
36- trace variables:
37-
33+ First we define a convenience function.
3834``` hol4
39- > map current_trace
40- ["Definition.TC extraction",
41- "Definition.termination candidates"];
42- val it = [0, 0]: int list (* default values *)
35+ > fun pr_thm th = (print_thm th; print "\n");
36+ val pr_thm = fn: thm -> unit
4337```
44- Now we make the definition while locally setting the trace values:
45- ``` hol4
46- > with_traces [("Definition.TC extraction", 3),
47- ("Definition.termination candidates",2)]
48- Define
49- `fact n = if n = 0 then 1 else n * fact (n-1)`;
50-
51- # # # #
52- ------------------------
53- TC extraction on clause:
54-
55- fact n = if n = 0 then 1 else n * RESTRICT fact R n (n − 1)
56-
57- Extracting from:
58-
59- n = 0
60-
61- push_context:
62- n = 0
6338
64- Extracting from:
39+ Now we examine a theorem with and without traces set to local values.
6540
66- 1
67-
68- push_context:
69- n ≠ 0
70-
71- Extracting from:
72-
73- n * RESTRICT fact R n (n − 1)
74-
75- TC Capture:
76- [n ≠ 0, n ≠ 0 ⇒ R (n − 1) n] ⊢ RESTRICT fact R n (n − 1) = fact (n − 1)
41+ ``` hol4
42+ > map current_trace ["assumptions", "types"] ;
43+ val it = [0, 0]: int list
7744
78- Termination conditions: 1
79- Candidate termination relations generated: 2
80- Termination proof successful with candidate 1:
81- inv_image $< (λx. x)
45+ > pr_thm EQ_SYM_EQ;
46+ ⊢ ∀x y. x = y ⇔ y = x
47+ val it = (): unit
8248
83- Equations stored under "fact_def".
84- Induction stored under "fact_ind".
85- val it = ⊢ ∀n. fact n = if n = 0 then 1 else n * fact (n − 1): thm
86- ```
49+ > with_traces [("assumptions",1), ("types",1)] pr_thm EQ_SYM_EQ;
50+ [] ⊢ ∀(x :α) (y :α). x = y ⇔ y = x
51+ val it = (): unit
8752
88- And the trace values have been restored:
89- ``` hol4
90- > map current_trace
91- ["Definition.TC extraction",
92- "Definition.termination candidates"]
93- val it = [0, 0]: int list (* back to default values *)
53+ > map current_trace ["assumptions", "types"] ;
54+ val it = [0, 0]: int list
9455```
9556
9657### See also
0 commit comments