author | Christian Urban <urbanc@in.tum.de> |
Mon, 18 Jun 2012 14:49:09 +0100 | |
changeset 520 | 615762b8d8cb |
parent 514 | 7e25716c3744 |
child 553 | c53d74b34123 |
permissions | -rw-r--r-- |
319
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory Command |
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports Main |
514
7e25716c3744
updated to outer syntax / parser changes
Christian Urban <urbanc@in.tum.de>
parents:
451
diff
changeset
|
3 |
keywords "foobar" "foobar_trace" :: thy_decl and |
7e25716c3744
updated to outer syntax / parser changes
Christian Urban <urbanc@in.tum.de>
parents:
451
diff
changeset
|
4 |
"foobar_goal" "foobar_prove" :: thy_goal |
319
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
begin |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
6 |
|
319
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
ML {* |
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
let |
449 | 9 |
val do_nothing = Scan.succeed (Local_Theory.background_theory I) |
426 | 10 |
val kind = Keyword.thy_decl |
319
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
in |
520
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
12 |
Outer_Syntax.local_theory @{command_spec "foobar"} |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
13 |
"description of foobar" |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
14 |
do_nothing |
319
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
end |
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
*} |
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
|
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
ML {* |
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
let |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
20 |
fun trace_prop str = |
449 | 21 |
Local_Theory.background_theory (fn lthy => (tracing str; lthy)) |
426 | 22 |
val trace_prop_parser = Parse.prop >> trace_prop |
23 |
val kind = Keyword.thy_decl |
|
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
24 |
in |
520
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
25 |
Outer_Syntax.local_theory @{command_spec "foobar_trace"} |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
26 |
"traces a proposition" |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
27 |
trace_prop_parser |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
28 |
end |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
29 |
*} |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
30 |
|
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
31 |
ML {* |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
32 |
let |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
33 |
fun prove_prop str lthy = |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
34 |
let |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
35 |
val prop = Syntax.read_prop lthy str |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
36 |
in |
422 | 37 |
Proof.theorem NONE (K I) [[(prop,[])]] lthy |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
38 |
end; |
426 | 39 |
val prove_prop_parser = Parse.prop >> prove_prop |
40 |
val kind = Keyword.thy_goal |
|
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
41 |
in |
520
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
42 |
Outer_Syntax.local_theory_to_proof @{command_spec "foobar_goal"} |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
43 |
"proving a proposition" |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
44 |
prove_prop_parser |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
45 |
end |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
46 |
*} |
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
47 |
|
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
48 |
ML {* |
451
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
49 |
structure Result = Proof_Data( |
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
50 |
type T = unit -> term |
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
51 |
fun init thy () = error "Result") |
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
52 |
|
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
53 |
val result_cookie = (Result.get, Result.put, "Result.put") |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
54 |
*} |
451
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
55 |
|
324
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
56 |
ML{* |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
57 |
let |
324
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
58 |
fun after_qed thm_name thms lthy = |
394 | 59 |
Local_Theory.note (thm_name, (flat thms)) lthy |> snd |
324
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
60 |
|
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
61 |
fun setup_proof (thm_name, (txt, pos)) lthy = |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
62 |
let |
451
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
63 |
val trm = Code_Runtime.value lthy result_cookie ("", txt) |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
64 |
in |
422 | 65 |
Proof.theorem NONE (after_qed thm_name) [[(trm,[])]] lthy |
324
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
66 |
end |
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
67 |
|
426 | 68 |
val parser = Parse_Spec.opt_thm_name ":" -- Parse.ML_source |
324
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
69 |
|
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
70 |
in |
520
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
71 |
Outer_Syntax.local_theory_to_proof @{command_spec "foobar_prove"} |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
72 |
"proving a proposition" |
615762b8d8cb
improved new_command section
Christian Urban <urbanc@in.tum.de>
parents:
514
diff
changeset
|
73 |
(parser >> setup_proof) |
324
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
74 |
end*} |
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
321
diff
changeset
|
75 |
|
321
e450fa467e3f
polished the commands section
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
76 |
|
319
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
|
451
fc074e669f9f
disabled foobar_prove; updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
78 |
|
319
6bce4acf7f2a
added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
end |