412 Scan.optional (Parse.$$$ "=" |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
412 Scan.optional (Parse.$$$ "=" |-- Parse.!!! locale_val) (([], []), []) -- Parse.opt_begin |
413 >> (fn ((name, (expr, elems)), begin) => |
413 >> (fn ((name, (expr, elems)), begin) => |
414 (begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
414 (begin ? Toplevel.print) o Toplevel.begin_local_theory begin |
415 (Expression.add_locale_cmd name Binding.empty expr elems #> snd))); |
415 (Expression.add_locale_cmd name Binding.empty expr elems #> snd))); |
416 |
416 |
|
417 fun parse_interpretation_arguments mandatory = |
|
418 Parse.!!! (Parse_Spec.locale_expression mandatory) -- |
|
419 Scan.optional |
|
420 (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) []; |
|
421 |
417 val _ = |
422 val _ = |
418 Outer_Syntax.command "sublocale" |
423 Outer_Syntax.command "sublocale" |
419 "prove sublocale relation between a locale and a locale expression" Keyword.thy_goal |
424 "prove sublocale relation between a locale and a locale expression" Keyword.thy_goal |
420 (Parse.xname --| (Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") -- |
425 (Parse.xname --| (Parse.$$$ "\\<subseteq>" || Parse.$$$ "<") -- |
421 Parse.!!! (Parse_Spec.locale_expression false) |
426 parse_interpretation_arguments false |
422 >> (fn (loc, expr) => |
427 >> (fn (loc, (expr, equations)) => |
423 Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd loc expr))); |
428 Toplevel.print o Toplevel.theory_to_proof (Expression.sublocale_cmd loc expr equations))); |
424 |
429 |
425 val _ = |
430 val _ = |
426 Outer_Syntax.command "interpretation" |
431 Outer_Syntax.command "interpretation" |
427 "prove interpretation of locale expression in theory" Keyword.thy_goal |
432 "prove interpretation of locale expression in theory" Keyword.thy_goal |
428 (Parse.!!! (Parse_Spec.locale_expression true) -- |
433 (parse_interpretation_arguments true |
429 Scan.optional (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) [] |
|
430 >> (fn (expr, equations) => Toplevel.print o |
434 >> (fn (expr, equations) => Toplevel.print o |
431 Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
435 Toplevel.theory_to_proof (Expression.interpretation_cmd expr equations))); |
432 |
436 |
433 val _ = |
437 val _ = |
434 Outer_Syntax.command "interpret" |
438 Outer_Syntax.command "interpret" |
435 "prove interpretation of locale expression in proof context" |
439 "prove interpretation of locale expression in proof context" |
436 (Keyword.tag_proof Keyword.prf_goal) |
440 (Keyword.tag_proof Keyword.prf_goal) |
437 (Parse.!!! (Parse_Spec.locale_expression true) -- |
441 (parse_interpretation_arguments true |
438 Scan.optional (Parse.where_ |-- Parse.and_list1 (Parse_Spec.opt_thm_name ":" -- Parse.prop)) [] |
|
439 >> (fn (expr, equations) => Toplevel.print o |
442 >> (fn (expr, equations) => Toplevel.print o |
440 Toplevel.proof' (Expression.interpret_cmd expr equations))); |
443 Toplevel.proof' (Expression.interpret_cmd expr equations))); |
441 |
444 |
442 |
445 |
443 (* classes *) |
446 (* classes *) |