author | ballarin |
Fri, 05 Dec 2008 11:26:07 +0100 | |
changeset 28993 | 829e684b02ef |
parent 28902 | 2019bcc9d8bf |
child 29018 | 17538bdef546 |
permissions | -rw-r--r-- |
28873 | 1 |
(* Title: FOL/ex/NewLocaleSetup.thy |
2 |
Author: Clemens Ballarin, TU Muenchen |
|
3 |
||
4 |
Testing environment for locale expressions --- experimental. |
|
5 |
*) |
|
6 |
||
7 |
theory NewLocaleSetup |
|
8 |
imports FOL |
|
9 |
begin |
|
10 |
||
11 |
ML {* |
|
12 |
||
13 |
local |
|
14 |
||
15 |
structure P = OuterParse and K = OuterKeyword; |
|
16 |
val opt_bang = Scan.optional (P.$$$ "!" >> K true) false; |
|
17 |
||
18 |
val locale_val = |
|
19 |
Expression.parse_expression -- |
|
20 |
Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] || |
|
28887 | 21 |
Scan.repeat1 SpecParse.context_element >> pair ([], []); |
28873 | 22 |
|
23 |
in |
|
24 |
||
25 |
val _ = |
|
26 |
OuterSyntax.command "locale" "define named proof context" K.thy_decl |
|
28887 | 27 |
(P.name -- Scan.optional (P.$$$ "=" |-- P.!!! locale_val) (([], []), []) -- P.opt_begin |
28873 | 28 |
>> (fn ((name, (expr, elems)), begin) => |
29 |
(begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
|
28902
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28887
diff
changeset
|
30 |
(Expression.add_locale_cmd name name expr elems #-> TheoryTarget.begin))); |
28873 | 31 |
|
32 |
val _ = |
|
33 |
OuterSyntax.improper_command "print_locales" "print locales of this theory" K.diag |
|
34 |
(Scan.succeed (Toplevel.no_timing o (Toplevel.unknown_theory o |
|
35 |
Toplevel.keep (NewLocale.print_locales o Toplevel.theory_of)))); |
|
36 |
||
37 |
val _ = OuterSyntax.improper_command "print_locale" "print named locale in this theory" K.diag |
|
38 |
(opt_bang -- P.xname >> (Toplevel.no_timing oo (fn (show_facts, name) => |
|
39 |
Toplevel.unknown_theory o Toplevel.keep (fn state => |
|
40 |
NewLocale.print_locale (Toplevel.theory_of state) show_facts name)))); |
|
41 |
||
28993
829e684b02ef
Interpretation in theories including interaction with subclass relation.
ballarin
parents:
28902
diff
changeset
|
42 |
val _ = |
829e684b02ef
Interpretation in theories including interaction with subclass relation.
ballarin
parents:
28902
diff
changeset
|
43 |
OuterSyntax.command "interpretation" |
829e684b02ef
Interpretation in theories including interaction with subclass relation.
ballarin
parents:
28902
diff
changeset
|
44 |
"prove and register interpretation of locale expression in theory" K.thy_goal |
829e684b02ef
Interpretation in theories including interaction with subclass relation.
ballarin
parents:
28902
diff
changeset
|
45 |
(P.!!! Expression.parse_expression |
829e684b02ef
Interpretation in theories including interaction with subclass relation.
ballarin
parents:
28902
diff
changeset
|
46 |
>> (fn expr => Toplevel.print o |
829e684b02ef
Interpretation in theories including interaction with subclass relation.
ballarin
parents:
28902
diff
changeset
|
47 |
Toplevel.theory_to_proof (Expression.interpretation_cmd expr))); |
829e684b02ef
Interpretation in theories including interaction with subclass relation.
ballarin
parents:
28902
diff
changeset
|
48 |
|
28873 | 49 |
end |
50 |
||
51 |
*} |
|
52 |
||
53 |
end |