319
|
1 |
theory Command
|
|
2 |
imports Main
|
514
|
3 |
keywords "foobar" "foobar_trace" :: thy_decl and
|
|
4 |
"foobar_goal" "foobar_prove" :: thy_goal
|
319
|
5 |
begin
|
321
|
6 |
|
319
|
7 |
ML {*
|
|
8 |
let
|
449
|
9 |
val do_nothing = Scan.succeed (Local_Theory.background_theory I)
|
426
|
10 |
val kind = Keyword.thy_decl
|
319
|
11 |
in
|
514
|
12 |
Outer_Syntax.local_theory ("foobar", kind) "description of foobar" do_nothing
|
319
|
13 |
end
|
|
14 |
*}
|
|
15 |
|
|
16 |
ML {*
|
|
17 |
let
|
321
|
18 |
fun trace_prop str =
|
449
|
19 |
Local_Theory.background_theory (fn lthy => (tracing str; lthy))
|
426
|
20 |
val trace_prop_parser = Parse.prop >> trace_prop
|
|
21 |
val kind = Keyword.thy_decl
|
321
|
22 |
in
|
514
|
23 |
Outer_Syntax.local_theory ("foobar_trace", kind) "traces a proposition"
|
|
24 |
trace_prop_parser
|
321
|
25 |
end
|
|
26 |
*}
|
|
27 |
|
|
28 |
ML {*
|
|
29 |
let
|
|
30 |
fun prove_prop str lthy =
|
|
31 |
let
|
|
32 |
val prop = Syntax.read_prop lthy str
|
|
33 |
in
|
422
|
34 |
Proof.theorem NONE (K I) [[(prop,[])]] lthy
|
321
|
35 |
end;
|
426
|
36 |
val prove_prop_parser = Parse.prop >> prove_prop
|
|
37 |
val kind = Keyword.thy_goal
|
321
|
38 |
in
|
514
|
39 |
Outer_Syntax.local_theory_to_proof ("foobar_goal", kind) "proving a proposition"
|
|
40 |
prove_prop_parser
|
321
|
41 |
end
|
|
42 |
*}
|
|
43 |
|
|
44 |
ML {*
|
451
|
45 |
structure Result = Proof_Data(
|
|
46 |
type T = unit -> term
|
|
47 |
fun init thy () = error "Result")
|
|
48 |
|
|
49 |
val result_cookie = (Result.get, Result.put, "Result.put")
|
321
|
50 |
*}
|
451
|
51 |
|
324
|
52 |
ML{*
|
321
|
53 |
let
|
324
|
54 |
fun after_qed thm_name thms lthy =
|
394
|
55 |
Local_Theory.note (thm_name, (flat thms)) lthy |> snd
|
324
|
56 |
|
|
57 |
fun setup_proof (thm_name, (txt, pos)) lthy =
|
321
|
58 |
let
|
451
|
59 |
val trm = Code_Runtime.value lthy result_cookie ("", txt)
|
321
|
60 |
in
|
422
|
61 |
Proof.theorem NONE (after_qed thm_name) [[(trm,[])]] lthy
|
324
|
62 |
end
|
321
|
63 |
|
426
|
64 |
val parser = Parse_Spec.opt_thm_name ":" -- Parse.ML_source
|
324
|
65 |
|
321
|
66 |
in
|
514
|
67 |
Outer_Syntax.local_theory_to_proof ("foobar_prove", Keyword.thy_goal) "proving a proposition"
|
|
68 |
(parser >> setup_proof)
|
324
|
69 |
end*}
|
|
70 |
|
321
|
71 |
|
319
|
72 |
|
451
|
73 |
|
319
|
74 |
end
|