# HG changeset patch # User paulson # Date 1725011088 -3600 # Node ID f38e59e1c019ac3ba54e95a55341d2cff55a2680 # Parent bcecb69f72faaac2dc4dbea8b09eb19f3b90988d# Parent 07c51801c2ea35a55161a004e50a1eff7fb2140b merged diff -r 07c51801c2ea -r f38e59e1c019 src/Doc/Datatypes/Datatypes.thy --- a/src/Doc/Datatypes/Datatypes.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Doc/Datatypes/Datatypes.thy Fri Aug 30 10:44:48 2024 +0100 @@ -453,7 +453,7 @@ Incidentally, this is how the traditional syntax can be set up: \ - syntax "_list" :: "args \ 'a list" ("[(_)]") + syntax "_list" :: "list_args \ 'a list" ("[(_)]") text \\blankline\ diff -r 07c51801c2ea -r f38e59e1c019 src/Doc/Tutorial/Protocol/Message.thy --- a/src/Doc/Tutorial/Protocol/Message.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Doc/Tutorial/Protocol/Message.thy Fri Aug 30 10:44:48 2024 +0100 @@ -79,13 +79,16 @@ (*<*) text\Concrete syntax: messages appear as \\A,B,NA\\, etc...\ +nonterminal mtuple_args syntax - "_MTuple" :: "['a, args] \ 'a * 'b" ("(2\_,/ _\)") + "" :: "'a \ mtuple_args" ("_") + "_MTuple_args" :: "'a \ mtuple_args \ mtuple_args" ("_,/ _") + "_MTuple" :: "['a, mtuple_args] \ 'a * 'b" ("(2\_,/ _\)") syntax_consts - "_MTuple" == MPair + "_MTuple_args" "_MTuple" \ MPair translations - "\x, y, z\" == "\x, \y, z\\" - "\x, y\" == "CONST MPair x y" + "\x, y, z\" \ "\x, \y, z\\" + "\x, y\" \ "CONST MPair x y" definition keysFor :: "msg set \ key set" where diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Auth/Message.thy --- a/src/HOL/Auth/Message.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Auth/Message.thy Fri Aug 30 10:44:48 2024 +0100 @@ -49,10 +49,13 @@ text\Concrete syntax: messages appear as \\A,B,NA\\, etc...\ +nonterminal mtuple_args syntax - "_MTuple" :: "['a, args] \ 'a * 'b" ("(2\_,/ _\)") + "" :: "'a \ mtuple_args" ("_") + "_MTuple_args" :: "'a \ mtuple_args \ mtuple_args" ("_,/ _") + "_MTuple" :: "['a, mtuple_args] \ 'a * 'b" ("(2\_,/ _\)") syntax_consts - "_MTuple" \ MPair + "_MTuple_args" "_MTuple" \ MPair translations "\x, y, z\" \ "\x, \y, z\\" "\x, y\" \ "CONST MPair x y" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Codegenerator_Test/Code_Lazy_Test.thy --- a/src/HOL/Codegenerator_Test/Code_Lazy_Test.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Codegenerator_Test/Code_Lazy_Test.thy Fri Aug 30 10:44:48 2024 +0100 @@ -23,8 +23,13 @@ code_lazy_type llist no_notation lazy_llist ("_") -syntax "_llist" :: "args => 'a list" ("\<^bold>[(_)\<^bold>]") -syntax_consts "_llist" == lazy_llist +nonterminal llist_args +syntax + "" :: "'a \ llist_args" ("_") + "_llist_args" :: "'a \ llist_args \ llist_args" ("_,/ _") + "_llist" :: "llist_args => 'a list" ("\<^bold>[(_)\<^bold>]") +syntax_consts + "_llist_args" "_llist" == lazy_llist translations "\<^bold>[x, xs\<^bold>]" == "x\<^bold>#\<^bold>[xs\<^bold>]" "\<^bold>[x\<^bold>]" == "x\<^bold>#\<^bold>[\<^bold>]" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Computational_Algebra/Polynomial.thy --- a/src/HOL/Computational_Algebra/Polynomial.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Computational_Algebra/Polynomial.thy Fri Aug 30 10:44:48 2024 +0100 @@ -348,7 +348,13 @@ subsection \List-style syntax for polynomials\ -syntax "_poly" :: "args \ 'a poly" ("[:(_):]") +nonterminal poly_args +syntax + "" :: "'a \ poly_args" ("_") + "_poly_args" :: "'a \ poly_args \ poly_args" ("_,/ _") + "_poly" :: "poly_args \ 'a poly" ("[:(_):]") +syntax_consts + "_poly_args" "_poly" \ pCons translations "[:x, xs:]" \ "CONST pCons x [:xs:]" "[:x:]" \ "CONST pCons x 0" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/HOLCF/ConvexPD.thy --- a/src/HOL/HOLCF/ConvexPD.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/HOLCF/ConvexPD.thy Fri Aug 30 10:44:48 2024 +0100 @@ -178,12 +178,13 @@ (infixl "\\" 65) where "xs \\ ys == convex_plus\xs\ys" +nonterminal convex_pd_args syntax - "_convex_pd" :: "args \ logic" ("{_}\") - + "" :: "logic \ convex_pd_args" ("_") + "_convex_pd_args" :: "logic \ convex_pd_args \ convex_pd_args" ("_,/ _") + "_convex_pd" :: "convex_pd_args \ logic" ("{_}\") syntax_consts - "_convex_pd" == convex_add - + "_convex_pd_args" "_convex_pd" == convex_add translations "{x,xs}\" == "{x}\ \\ {xs}\" "{x}\" == "CONST convex_unit\x" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/HOLCF/IOA/Sequence.thy --- a/src/HOL/HOLCF/IOA/Sequence.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/HOLCF/IOA/Sequence.thy Fri Aug 30 10:44:48 2024 +0100 @@ -69,9 +69,12 @@ subsection \List enumeration\ +nonterminal llist_args syntax - "_totlist" :: "args \ 'a Seq" ("[(_)!]") - "_partlist" :: "args \ 'a Seq" ("[(_)?]") + "" :: "'a \ llist_args" ("_") + "_list_args" :: "'a \ llist_args \ llist_args" ("_,/ _") + "_totlist" :: "llist_args \ 'a Seq" ("[(_)!]") + "_partlist" :: "llist_args \ 'a Seq" ("[(_)?]") syntax_consts "_totlist" "_partlist" \ Consq translations diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/HOLCF/LowerPD.thy --- a/src/HOL/HOLCF/LowerPD.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/HOLCF/LowerPD.thy Fri Aug 30 10:44:48 2024 +0100 @@ -133,12 +133,13 @@ (infixl "\\" 65) where "xs \\ ys == lower_plus\xs\ys" +nonterminal lower_pd_args syntax - "_lower_pd" :: "args \ logic" ("{_}\") - + "" :: "logic \ lower_pd_args" ("_") + "_lower_pd_args" :: "logic \ lower_pd_args \ lower_pd_args" ("_,/ _") + "_lower_pd" :: "lower_pd_args \ logic" ("{_}\") syntax_consts - "_lower_pd" == lower_add - + "_lower_pd_args" "_lower_pd" == lower_add translations "{x,xs}\" == "{x}\ \\ {xs}\" "{x}\" == "CONST lower_unit\x" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/HOLCF/Sprod.thy --- a/src/HOL/HOLCF/Sprod.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/HOLCF/Sprod.thy Fri Aug 30 10:44:48 2024 +0100 @@ -40,8 +40,13 @@ definition ssplit :: "('a \ 'b \ 'c) \ ('a ** 'b) \ 'c" where "ssplit = (\ f p. seq\p\(f\(sfst\p)\(ssnd\p)))" -syntax "_stuple" :: "[logic, args] \ logic" ("(1'(:_,/ _:'))") -syntax_consts "_stuple" \ spair +nonterminal stuple_args +syntax + "" :: "logic \ stuple_args" ("_") + "_stuple_args" :: "logic \ stuple_args \ stuple_args" ("_,/ _") + "_stuple" :: "[logic, stuple_args] \ logic" ("(1'(:_,/ _:'))") +syntax_consts + "_stuple_args" "_stuple" \ spair translations "(:x, y, z:)" \ "(:x, (:y, z:):)" "(:x, y:)" \ "CONST spair\x\y" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/HOLCF/UpperPD.thy --- a/src/HOL/HOLCF/UpperPD.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/HOLCF/UpperPD.thy Fri Aug 30 10:44:48 2024 +0100 @@ -131,12 +131,13 @@ (infixl "\\" 65) where "xs \\ ys == upper_plus\xs\ys" +nonterminal upper_pd_args syntax - "_upper_pd" :: "args \ logic" ("{_}\") - + "" :: "logic \ upper_pd_args" ("_") + "_upper_pd_args" :: "logic \ upper_pd_args \ upper_pd_args" ("_,/ _") + "_upper_pd" :: "upper_pd_args \ logic" ("{_}\") syntax_consts - "_upper_pd" == upper_add - + "_upper_pd_args" "_upper_pd" == upper_add translations "{x,xs}\" == "{x}\ \\ {xs}\" "{x}\" == "CONST upper_unit\x" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Library/FSet.thy --- a/src/HOL/Library/FSet.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Library/FSet.thy Fri Aug 30 10:44:48 2024 +0100 @@ -164,12 +164,13 @@ lift_definition finsert :: "'a \ 'a fset \ 'a fset" is insert parametric Lifting_Set.insert_transfer by simp +nonterminal fset_args syntax - "_insert_fset" :: "args => 'a fset" ("{|(_)|}") - + "" :: "'a \ fset_args" ("_") + "_fset_args" :: "'a \ fset_args \ fset_args" ("_,/ _") + "_fset" :: "fset_args => 'a fset" ("{|(_)|}") syntax_consts - "_insert_fset" == finsert - + "_fset_args" "_fset" == finsert translations "{|x, xs|}" == "CONST finsert x {|xs|}" "{|x|}" == "CONST finsert x {||}" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Library/Monad_Syntax.thy --- a/src/HOL/Library/Monad_Syntax.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Library/Monad_Syntax.thy Fri Aug 30 10:44:48 2024 +0100 @@ -47,8 +47,7 @@ "_thenM" :: "['a, 'b] \ 'c" (infixl ">>" 54) syntax_consts - "_do_block" "_do_cons" \ bind_do and - "_do_bind" "_thenM" \ bind and + "_do_block" "_do_cons" "_do_bind" "_do_then" \ bind and "_do_let" \ Let translations diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Library/Multiset.thy Fri Aug 30 10:44:48 2024 +0100 @@ -91,10 +91,13 @@ "\a M b. if b = a then Suc (M b) else M b" by (rule add_mset_in_multiset) +nonterminal multiset_args syntax - "_multiset" :: "args \ 'a multiset" ("{#(_)#}") + "" :: "'a \ multiset_args" ("_") + "_multiset_args" :: "'a \ multiset_args \ multiset_args" ("_,/ _") + "_multiset" :: "multiset_args \ 'a multiset" ("{#(_)#}") syntax_consts - "_multiset" == add_mset + "_multiset_args" "_multiset" == add_mset translations "{#x, xs#}" == "CONST add_mset x {#xs#}" "{#x#}" == "CONST add_mset x {#}" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Library/Open_State_Syntax.thy --- a/src/HOL/Library/Open_State_Syntax.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Library/Open_State_Syntax.thy Fri Aug 30 10:44:48 2024 +0100 @@ -119,6 +119,8 @@ nonterminal sdo_binds and sdo_bind +definition "sdo_syntax = ()" + syntax "_sdo_block" :: "sdo_binds \ 'a" ("exec {//(2 _)//}" [12] 62) "_sdo_bind" :: "[pttrn, 'a] \ sdo_bind" ("(_ \/ _)" 13) @@ -130,6 +132,11 @@ syntax (ASCII) "_sdo_bind" :: "[pttrn, 'a] \ sdo_bind" ("(_ <-/ _)" 13) +syntax_consts + "_sdo_block" "_sdo_cons" == sdo_syntax and + "_sdo_bind" == scomp and + "_sdo_let" == Let + translations "_sdo_block (_sdo_cons (_sdo_bind p t) (_sdo_final e))" == "CONST scomp t (\p. e)" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/List.thy --- a/src/HOL/List.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/List.thy Fri Aug 30 10:44:48 2024 +0100 @@ -42,13 +42,16 @@ lemmas set_simps = list.set (* legacy *) + +text \List enumeration\ + +nonterminal list_args syntax - \ \list Enumeration\ - "_list" :: "args => 'a list" ("[(_)]") - + "" :: "'a \ list_args" ("_") + "_list_args" :: "'a \ list_args \ list_args" ("_,/ _") + "_list" :: "list_args => 'a list" ("[(_)]") syntax_consts - "_list" == Cons - + "_list_args" "_list" == Cons translations "[x, xs]" == "x#[xs]" "[x]" == "x#[]" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Metis_Examples/Message.thy --- a/src/HOL/Metis_Examples/Message.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Metis_Examples/Message.thy Fri Aug 30 10:44:48 2024 +0100 @@ -48,13 +48,16 @@ text\Concrete syntax: messages appear as \\A,B,NA\\, etc...\ +nonterminal mtuple_args syntax - "_MTuple" :: "['a, args] => 'a * 'b" ("(2\_,/ _\)") + "" :: "'a \ mtuple_args" ("_") + "_MTuple_args" :: "'a \ mtuple_args \ mtuple_args" ("_,/ _") + "_MTuple" :: "['a, mtuple_args] \ 'a * 'b" ("(2\_,/ _\)") syntax_consts - "_MTuple" == MPair + "_MTuple_args" "_MTuple" \ MPair translations - "\x, y, z\" == "\x, \y, z\\" - "\x, y\" == "CONST MPair x y" + "\x, y, z\" \ "\x, \y, z\\" + "\x, y\" \ "CONST MPair x y" definition HPair :: "[msg,msg] => msg" ("(4Hash[_] /_)" [0, 1000]) where diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Prolog/Test.thy --- a/src/HOL/Prolog/Test.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Prolog/Test.thy Fri Aug 30 10:44:48 2024 +0100 @@ -16,13 +16,18 @@ Nil :: "'a list" ("[]") Cons :: "'a => 'a list => 'a list" (infixr "#" 65) -syntax - (* list Enumeration *) - "_list" :: "args => 'a list" ("[(_)]") +text \List enumeration\ +nonterminal list_args +syntax + "" :: "'a \ list_args" ("_") + "_list_args" :: "'a \ list_args \ list_args" ("_,/ _") + "_list" :: "list_args => 'a list" ("[(_)]") +syntax_consts + "_list_args" "_list" == Cons translations - "[x, xs]" == "x#[xs]" - "[x]" == "x#[]" + "[x, xs]" == "x#[xs]" + "[x]" == "x#[]" typedecl person diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Quotient_Examples/Lift_FSet.thy --- a/src/HOL/Quotient_Examples/Lift_FSet.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Quotient_Examples/Lift_FSet.thy Fri Aug 30 10:44:48 2024 +0100 @@ -95,12 +95,13 @@ end +nonterminal fset_args syntax - "_insert_fset" :: "args => 'a fset" ("{|(_)|}") - + "" :: "'a \ fset_args" ("_") + "_fset_args" :: "'a \ fset_args \ fset_args" ("_,/ _") + "_fset" :: "fset_args => 'a fset" ("{|(_)|}") syntax_consts - "_insert_fset" == fcons - + "_fset_args" "_fset" == fcons translations "{|x, xs|}" == "CONST fcons x {|xs|}" "{|x|}" == "CONST fcons x {||}" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Quotient_Examples/Quotient_FSet.thy --- a/src/HOL/Quotient_Examples/Quotient_FSet.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Quotient_Examples/Quotient_FSet.thy Fri Aug 30 10:44:48 2024 +0100 @@ -288,12 +288,13 @@ "insert_fset :: 'a \ 'a fset \ 'a fset" is "Cons" by auto +nonterminal fset_args syntax - "_insert_fset" :: "args => 'a fset" ("{|(_)|}") - + "" :: "'a \ fset_args" ("_") + "_fset_args" :: "'a \ fset_args \ fset_args" ("_,/ _") + "_fset" :: "fset_args => 'a fset" ("{|(_)|}") syntax_consts - "_insert_fset" == insert_fset - + "_fset_args" "_fset" == insert_fset translations "{|x, xs|}" == "CONST insert_fset x {|xs|}" "{|x|}" == "CONST insert_fset x {||}" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/SET_Protocol/Message_SET.thy --- a/src/HOL/SET_Protocol/Message_SET.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/SET_Protocol/Message_SET.thy Fri Aug 30 10:44:48 2024 +0100 @@ -68,10 +68,13 @@ (*Concrete syntax: messages appear as \\A,B,NA\\, etc...*) +nonterminal mtuple_args syntax - "_MTuple" :: "['a, args] \ 'a * 'b" ("(2\_,/ _\)") + "" :: "'a \ mtuple_args" ("_") + "_MTuple_args" :: "'a \ mtuple_args \ mtuple_args" ("_,/ _") + "_MTuple" :: "['a, mtuple_args] \ 'a * 'b" ("(2\_,/ _\)") syntax_consts - "_MTuple" == MPair + "_MTuple_args" "_MTuple" \ MPair translations "\x, y, z\" == "\x, \y, z\\" "\x, y\" == "CONST MPair x y" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/Set.thy --- a/src/HOL/Set.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/Set.thy Fri Aug 30 10:44:48 2024 +0100 @@ -143,10 +143,13 @@ definition insert :: "'a \ 'a set \ 'a set" where insert_compr: "insert a B = {x. x = a \ x \ B}" +nonterminal finset_args syntax - "_Finset" :: "args \ 'a set" ("{(_)}") + "" :: "'a \ finset_args" ("_") + "_Finset_args" :: "'a \ finset_args \ finset_args" ("_,/ _") + "_Finset" :: "finset_args \ 'a set" ("{(_)}") syntax_consts - "_Finset" \ insert + "_Finset_args" "_Finset" \ insert translations "{x, xs}" \ "CONST insert x {xs}" "{x}" \ "CONST insert x {}" diff -r 07c51801c2ea -r f38e59e1c019 src/HOL/ex/Code_Lazy_Demo.thy --- a/src/HOL/ex/Code_Lazy_Demo.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/HOL/ex/Code_Lazy_Demo.thy Fri Aug 30 10:44:48 2024 +0100 @@ -39,8 +39,13 @@ = LNil ("\<^bold>\\<^bold>\") | LCons (lhd: 'a) (ltl: "'a llist") (infixr "###" 65) -syntax "_llist" :: "args => 'a list" ("\<^bold>\(_)\<^bold>\") -syntax_consts "_llist" == LCons +nonterminal llist_args +syntax + "" :: "'a \ llist_args" ("_") + "_llist_args" :: "'a \ llist_args \ llist_args" ("_,/ _") + "_llist" :: "llist_args => 'a list" ("\<^bold>\(_)\<^bold>\") +syntax_consts + "_llist_args" "_llist" == LCons translations "\<^bold>\x, xs\<^bold>\" == "x###\<^bold>\xs\<^bold>\" "\<^bold>\x\<^bold>\" == "x###\<^bold>\\<^bold>\" diff -r 07c51801c2ea -r f38e59e1c019 src/Pure/Build/build_manager.scala --- a/src/Pure/Build/build_manager.scala Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Pure/Build/build_manager.scala Fri Aug 30 10:44:48 2024 +0100 @@ -802,22 +802,27 @@ result_futures + (context.name -> result_future)) } - def running: List[String] = process_futures.keys.toList + def running: List[String] = process_futures.keys.toList.filterNot(cancelling_until.contains) + + private def maybe_result(name: String): Option[Process_Result] = + for (future <- result_futures.get(name) if future.is_finished) yield + future.join_result match { + case Exn.Res(result) => result + case Exn.Exn(exn) => Process_Result(Process_Result.RC.interrupt).error(exn.getMessage) + } private def do_terminate(name: String): Boolean = { - val is_late = cancelling_until(name) > Time.now() + val is_late = Time.now() > cancelling_until(name) if (is_late) process_futures(name).join.terminate() is_late } def update: (State, Map[String, Process_Result]) = { val finished0 = - for ((name, future) <- result_futures if future.is_finished) - yield name -> - (future.join_result match { - case Exn.Res(result) => result - case Exn.Exn(exn) => Process_Result(Process_Result.RC.interrupt).error(exn.getMessage) - }) + for { + (name, _) <- result_futures + result <- maybe_result(name) + } yield name -> result val (terminated, cancelling_until1) = cancelling_until @@ -826,7 +831,8 @@ val finished = finished0 ++ - terminated.map((name, _) => name -> Process_Result(Process_Result.RC.timeout)) + terminated.map((name, _) => + name -> maybe_result(name).getOrElse(Process_Result(Process_Result.RC.timeout))) val state1 = copy( @@ -850,9 +856,7 @@ if do_cancel(process_future) } yield name -> (Time.now() + cancel_timeout) - copy( - process_futures.filterNot((name, _) => cancelled.contains(name)), - cancelling_until = cancelling_until ++ cancelling_until1) + copy(cancelling_until = cancelling_until ++ cancelling_until1) } } } @@ -1021,7 +1025,20 @@ override def stopped(state: Runner.State): Boolean = progress.stopped && state.is_empty - def init: Runner.State = Runner.State.init(store.options) + def init: Runner.State = synchronized_database("init") { + for ((name, job) <- _state.running) { + echo("Cleaned up job " + job.uuid) + + val report = store.report(job.kind, job.id) + + _state = _state + .remove_running(job.name) + .add_finished(report.result(Some(job.uuid), job.user)) + } + + Runner.State.init(store.options) + } + def loop_body(state: Runner.State): Runner.State = { val state1 = if (progress.stopped) state @@ -1498,11 +1515,14 @@ html { background-color: white; }""")) } + override def close(): Unit = { + server.stop() + super.close() + } + def init: Unit = server.start() - def loop_body(u: Unit): Unit = { - if (progress.stopped) server.stop() - else synchronized_database("iterate") { cache.update() } - } + def loop_body(u: Unit): Unit = + if (!progress.stopped) synchronized_database("iterate") { cache.update() } } diff -r 07c51801c2ea -r f38e59e1c019 src/Pure/General/latex.ML --- a/src/Pure/General/latex.ML Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Pure/General/latex.ML Fri Aug 30 10:44:48 2024 +0100 @@ -251,7 +251,9 @@ else if s = Markup.keyword2N then keyword_markup else Markup.no_output; -val _ = Output.add_mode latexN latex_output (prefix Symbol.latex o cartouche); +fun latex_escape ss = Symbol.latex :: Symbol.open_ :: ss @ [Symbol.close]; + +val _ = Output.add_mode latexN latex_output latex_escape; val _ = Markup.add_mode latexN latex_markup; val _ = Pretty.add_mode latexN diff -r 07c51801c2ea -r f38e59e1c019 src/Pure/General/output.ML --- a/src/Pure/General/output.ML Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Pure/General/output.ML Fri Aug 30 10:44:48 2024 +0100 @@ -17,11 +17,11 @@ include BASIC_OUTPUT type output = string val default_output: string -> output * int - val default_escape: output -> string - val add_mode: string -> (string -> output * int) -> (output -> string) -> unit + val default_escape: output list -> string list + val add_mode: string -> (string -> output * int) -> (output list -> string list) -> unit val output_width: string -> output * int val output: string -> output - val escape: output -> string + val escape: output list -> string list val physical_stdout: output -> unit val physical_stderr: output -> unit val physical_writeln: output -> unit @@ -66,7 +66,7 @@ type output = string; (*raw system output*) fun default_output s = (s, size s); -fun default_escape (s: output) = s; +fun default_escape (ss: output list) = ss; local val default = {output = default_output, escape = default_escape}; diff -r 07c51801c2ea -r f38e59e1c019 src/Pure/General/pretty.ML --- a/src/Pure/General/pretty.ML Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Pure/General/pretty.ML Fri Aug 30 10:44:48 2024 +0100 @@ -65,11 +65,11 @@ val regularN: string val symbolicN: string val output_buffer: int option -> T -> Buffer.T - val output: int option -> T -> Output.output + val output: int option -> T -> Output.output list val string_of_margin: int -> T -> string val string_of: T -> string val writeln: T -> unit - val symbolic_output: T -> Output.output + val symbolic_output: T -> Output.output list val symbolic_string_of: T -> string val unformatted_string_of: T -> string val markup_chunks: Markup.T -> T list -> T @@ -359,15 +359,15 @@ then symbolic prt else formatted (the_default (! margin_default) margin) prt; -val output = Buffer.content oo output_buffer; -fun string_of_margin margin = Output.escape o output (SOME margin); -val string_of = Output.escape o output NONE; -val writeln = Output.writeln o string_of; +val output = Buffer.contents oo output_buffer; +fun string_of_margin margin = implode o Output.escape o output (SOME margin); +val string_of = implode o Output.escape o output NONE; +val writeln = Output.writelns o Output.escape o output NONE; -val symbolic_output = Buffer.content o symbolic; -val symbolic_string_of = Output.escape o symbolic_output; +val symbolic_output = Buffer.contents o symbolic; +val symbolic_string_of = implode o Output.escape o symbolic_output; -val unformatted_string_of = Output.escape o Buffer.content o unformatted; +val unformatted_string_of = implode o Output.escape o Buffer.contents o unformatted; (* chunks *) diff -r 07c51801c2ea -r f38e59e1c019 src/Pure/PIDE/markup.ML --- a/src/Pure/PIDE/markup.ML Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Pure/PIDE/markup.ML Fri Aug 30 10:44:48 2024 +0100 @@ -864,8 +864,8 @@ val enclose = output #-> Library.enclose; fun markup m = - let val (bg, en) = output m - in Library.enclose (Output.escape bg) (Output.escape en) end; + let val (bg, en) = output m |> apply2 (single #> Output.escape #> implode); + in Library.enclose bg en end; val markups = fold_rev markup; diff -r 07c51801c2ea -r f38e59e1c019 src/Pure/Syntax/syntax_phases.ML --- a/src/Pure/Syntax/syntax_phases.ML Fri Aug 30 10:16:48 2024 +0100 +++ b/src/Pure/Syntax/syntax_phases.ML Fri Aug 30 10:44:48 2024 +0100 @@ -766,7 +766,7 @@ if show_markup andalso not show_types then let val ((bg1, bg2), en) = typing_elem; - val bg = bg1 ^ Pretty.symbolic_output (pretty_typ_ast Markup.empty ty) ^ bg2; + val bg = implode (bg1 :: Pretty.symbolic_output (pretty_typ_ast Markup.empty ty) @ [bg2]); val info = {markup = (bg, en), consistent = false, indent = 0}; in SOME (Pretty.make_block info [pretty_ast Markup.empty t]) end else NONE @@ -775,7 +775,7 @@ if show_markup andalso not show_sorts then let val ((bg1, bg2), en) = sorting_elem; - val bg = bg1 ^ Pretty.symbolic_output (pretty_typ_ast Markup.empty s) ^ bg2; + val bg = implode (bg1 :: Pretty.symbolic_output (pretty_typ_ast Markup.empty s) @ [bg2]); val info = {markup = (bg, en), consistent = false, indent = 0}; in SOME (Pretty.make_block info [pretty_typ_ast Markup.empty ty]) end else NONE diff -r 07c51801c2ea -r f38e59e1c019 src/ZF/List.thy --- a/src/ZF/List.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/ZF/List.thy Fri Aug 30 10:44:48 2024 +0100 @@ -13,15 +13,18 @@ datatype "list(A)" = Nil | Cons ("a \ A", "l \ list(A)") +notation Nil (\[]\) +nonterminal list_args syntax - "_Nil" :: i (\[]\) - "_List" :: "is \ i" (\[(_)]\) -syntax_consts "_List" \ Cons + "" :: "i \ list_args" (\_\) + "_List_args" :: "[i, list_args] \ list_args" (\_,/ _\) + "_List" :: "list_args \ i" (\[(_)]\) +syntax_consts + "_List_args" "_List" \ Cons translations "[x, xs]" == "CONST Cons(x, [xs])" "[x]" == "CONST Cons(x, [])" - "[]" == "CONST Nil" consts length :: "i\i" diff -r 07c51801c2ea -r f38e59e1c019 src/ZF/ZF_Base.thy --- a/src/ZF/ZF_Base.thy Fri Aug 30 10:16:48 2024 +0100 +++ b/src/ZF/ZF_Base.thy Fri Aug 30 10:44:48 2024 +0100 @@ -129,13 +129,13 @@ definition succ :: "i \ i" where "succ(i) \ cons(i, i)" -nonterminal "is" +nonterminal "finset_args" syntax - "" :: "i \ is" (\_\) - "_Enum" :: "[i, is] \ is" (\_,/ _\) - "_Finset" :: "is \ i" (\{(_)}\) + "" :: "i \ finset_args" (\_\) + "_Finset_args" :: "[i, finset_args] \ finset_args" (\_,/ _\) + "_Finset" :: "finset_args \ i" (\{(_)}\) syntax_consts - "_Finset" == cons + "_Finset_args" "_Finset" == cons translations "{x, xs}" == "CONST cons(x, {xs})" "{x}" == "CONST cons(x, 0)" @@ -192,19 +192,26 @@ definition split :: "[[i, i] \ 'a, i] \ 'a::{}" \ \for pattern-matching\ where "split(c) \ \p. c(fst(p), snd(p))" +nonterminal "tuple_args" +syntax + "" :: "i \ tuple_args" (\_\) + "_Tuple_args" :: "[i, tuple_args] \ tuple_args" (\_,/ _\) + "_Tuple" :: "[i, tuple_args] \ i" (\\(_,/ _)\\) +syntax_consts + "_Tuple_args" "_Tuple" == Pair +translations + "\x, y, z\" == "\x, \y, z\\" + "\x, y\" == "CONST Pair(x, y)" + (* Patterns -- extends pre-defined type "pttrn" used in abstractions *) nonterminal patterns syntax "_pattern" :: "patterns \ pttrn" (\\_\\) "" :: "pttrn \ patterns" (\_\) "_patterns" :: "[pttrn, patterns] \ patterns" (\_,/_\) - "_Tuple" :: "[i, is] \ i" (\\(_,/ _)\\) syntax_consts - "_pattern" "_patterns" == split and - "_Tuple" == Pair + "_pattern" "_patterns" == split translations - "\x, y, z\" == "\x, \y, z\\" - "\x, y\" == "CONST Pair(x, y)" "\\x,y,zs\.b" == "CONST split(\x \y,zs\.b)" "\\x,y\.b" == "CONST split(\x y. b)" @@ -300,7 +307,7 @@ "_PROD" :: "[pttrn, i, i] \ i" (\(3PROD _:_./ _)\ 10) "_SUM" :: "[pttrn, i, i] \ i" (\(3SUM _:_./ _)\ 10) "_lam" :: "[pttrn, i, i] \ i" (\(3lam _:_./ _)\ 10) - "_Tuple" :: "[i, is] \ i" (\<(_,/ _)>\) + "_Tuple" :: "[i, tuple_args] \ i" (\<(_,/ _)>\) "_pattern" :: "patterns \ pttrn" (\<_>\)