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