From 6d44c638512eb736c41551c5887b4475a14935bf Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Thu, 15 Sep 2022 03:15:34 +0000
Subject: CTAN sync 202209150315

---
 .../contrib/stex/source/stex/stex-symbols.dtx      | 209 ++++++++++++++++++---
 1 file changed, 186 insertions(+), 23 deletions(-)

(limited to 'macros/latex/contrib/stex/source/stex/stex-symbols.dtx')

diff --git a/macros/latex/contrib/stex/source/stex/stex-symbols.dtx b/macros/latex/contrib/stex/source/stex/stex-symbols.dtx
index ba9fa5f097..e5e7982abc 100644
--- a/macros/latex/contrib/stex/source/stex/stex-symbols.dtx
+++ b/macros/latex/contrib/stex/source/stex/stex-symbols.dtx
@@ -10,7 +10,7 @@
 % TODO update copyright  
 %
 %<*driver>
-\def\bibfolder#1{../../lib/bib/#1}
+\def\libfolder#1{../../lib/#1}
 \input{../../doc/stex-docheader}
 
 \begin{document}
@@ -60,9 +60,6 @@
 %         passed on to \mmt for semantic services.
 %     \item |def|: An (ideally semantic) term, representing a \emph{definiens}. Not used by \sTeX, but
 %         passed on to \mmt for semantic services.
-%     \item |local|: A boolean (by default false). If set, this declaration
-%         will not be added to the module content, i.e. importing
-%         the current module will not make this declaration available.
 %     \item |args|: Specifies the ``signature'' of the semantic macro.
 %       Can be either an integer $0 \leq n \leq 9$, or a (more precise)
 %       sequence of the following characters:
@@ -92,7 +89,6 @@
 %     \item |name| (string),
 %     \item |module| (string),
 %     \item |notations| (sequence of strings; initially empty),
-%     \item |local| (boolean),
 %     \item |type| (token list),
 %     \item |args| (string of |i|s, |a|s and |b|s),
 %     \item |arity| (integer string),
@@ -204,15 +200,14 @@
 %    \begin{macrocode}
 \keys_define:nn { stex / symdecl } {
   name        .str_set_x:N  = \l_stex_symdecl_name_str ,
-  local       .bool_set:N   = \l_stex_symdecl_local_bool ,
   args        .str_set_x:N  = \l_stex_symdecl_args_str ,
   type        .tl_set:N     = \l_stex_symdecl_type_tl ,
   deprecate   .str_set_x:N  = \l_stex_symdecl_deprecate_str ,
   align       .str_set:N    = \l_stex_symdecl_align_str , % TODO(?)
   gfc         .str_set:N    = \l_stex_symdecl_gfc_str , % TODO(?)
-  specializes .str_set:N    = \l_stex_symdecl_specializes_str , % TODO(?)
   def         .tl_set:N     = \l_stex_symdecl_definiens_tl ,
   reorder     .str_set_x:N  = \l_stex_symdecl_reorder_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
   assoc       .choices:nn   = 
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}
@@ -229,6 +224,7 @@
   \bool_set_false:N \l_stex_symdecl_local_bool
   \tl_clear:N \l_stex_symdecl_type_tl
   \tl_clear:N \l_stex_symdecl_definiens_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
   
   \keys_set:nn { stex / symdecl } { #1 }
 }
@@ -324,6 +320,7 @@
       }{##1}
     }
   }
+
   \bool_if:NTF \l_tmpa_bool {
     % possibly numeric
     \str_if_empty:NTF \l_stex_symdecl_args_str {
@@ -351,6 +348,19 @@
     \prop_put:Nnx \l_tmpa_prop { defined }{ true }
   }
 
+  % argnames
+
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} {
+    \clist_if_empty:NTF \l_stex_symdecl_argnames_clist {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+    }{
+      \clist_pop:NN \l_stex_symdecl_argnames_clist \l_tmpa_tl
+      \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl}
+    }
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
   % semantic macro
 
   \bool_if:NT \l_stex_symdecl_make_macro_bool {
@@ -396,7 +406,7 @@
     _prop 
   } {
     \bool_if:NTF \l_stex_symdecl_local_bool \stex_do_up_to_module:x \stex_execute_in_module:x {
-      \_@@_restore_symbol:nnnnnnn
+      \_@@_restore_symbol:nnnnnnnn
         {\l_stex_symdecl_name_str}
         { \prop_item:Nn \l_tmpa_prop {args} }
         { \prop_item:Nn \l_tmpa_prop {arity} }
@@ -404,10 +414,11 @@
         { \prop_item:Nn \l_tmpa_prop {defined} }
         {\bool_if:NT \l_stex_symdecl_make_macro_bool {#1} }
         {\l_stex_current_module_str}
+        { \prop_item:Nn \l_tmpa_prop {argnames} }
     }
   }
 }
-\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnn {
+\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnnn {
   \prop_clear:N \l_tmpa_prop
   \prop_put:Nnn \l_tmpa_prop { module } { #7 }
   \prop_put:Nnn \l_tmpa_prop { name } { #1}
@@ -415,6 +426,7 @@
   \prop_put:Nnn \l_tmpa_prop { arity } { #3 }
   \prop_put:Nnn \l_tmpa_prop { assocs } { #4 }
   \prop_put:Nnn \l_tmpa_prop { defined } { #5 }
+  \prop_put:Nnn \l_tmpa_prop { argnames } { #8 }
   \tl_if_empty:nF{#6}{
     \tl_set:cx{#6}{\stex_invoke_symbol:n{\detokenize{#7 ? #1}}}
   }
@@ -435,6 +447,7 @@
 \cs_new_protected:Nn \_stex_textsymdecl_args:n {
   \str_clear:N \l_@@_name_str
   \tl_clear:N \l_@@_type_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
   \keys_set:nn { stex / textsymdecl } { #1 }
 }
 
@@ -450,12 +463,12 @@
   \stex_execute_in_module:n{
     \cs_set_nopar:cpn{#1name}{
       \ifvmode\hbox_unpack:N\c_empty_box\fi
-      \hbox{#3}\xspace
+      \ifmmode\hbox{#3}\else#3\fi\xspace
     }
     \cs_set_nopar:cpn{#1}{
       \ifmmode\csname#1-sym\expandafter\endcsname\else
       \ifvmode\hbox_unpack:N\c_empty_box\fi
-      \symref{#1-sym}{\hbox{#3}}\expandafter\xspace
+      \symref{#1-sym}{#3}\expandafter\xspace
       \fi
     }
   }
@@ -594,12 +607,13 @@
 %    \begin{macrocode}
 \keys_define:nn { stex / notation } {
 %  lang    .tl_set_x:N  = \l_@@_lang_str ,
-  variant .tl_set_x:N  = \l_@@_variant_str ,
-  prec    .str_set_x:N = \l_@@_prec_str ,
-  op      .tl_set:N    = \l_@@_op_tl ,
-  primary .bool_set:N  = \l_@@_primary_bool ,
-  primary .default:n   = {true} ,
-  unknown .code:n      = \str_set:Nx 
+  variant .tl_set_x:N   = \l_@@_variant_str ,
+  prec    .str_set_x:N  = \l_@@_prec_str ,
+  op      .tl_set:N     = \l_@@_op_tl ,
+  primary .bool_set:N   = \l_@@_primary_bool ,
+  primary .default:n    = {true} ,
+  hints    .str_set_x:N = \l_@@_hints_str,
+  unknown .code:n       = \str_set:Nx 
       \l_@@_variant_str \l_keys_key_str
 }
 
@@ -607,6 +621,7 @@
 %  \str_clear:N \l_@@_lang_str
   \str_clear:N \l_@@_variant_str
   \str_clear:N \l_@@_prec_str
+  \str_clear:N \l_@@_hints_str
   \tl_clear:N \l_@@_op_tl
   \bool_set_false:N \l_@@_primary_bool
   
@@ -677,7 +692,7 @@
           \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn 
             \l_tmpa_seq {\tl_to_str:n{x} } { \l_tmpa_str }
           \seq_map_inline:Nn \l_tmpa_seq {
-            \seq_put_right:Nn \l_tmpb_seq { ##1 }
+            \seq_put_right:Nn \l_@@_precedences_seq { ##1 }
           }
         }
       }{
@@ -824,11 +839,12 @@
 
   \seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpa_str
   \tl_put_right:Nx \l_stex_notation_dummyargs_tl { {
-    \STEXInternalTermMathAssocArgiiii
-      { #1\int_use:N \l_@@_currarg_int }
+    \STEXInternalTermMathAssocArgiiiii
+      { \int_use:N \l_@@_currarg_int }
       { \l_tmpa_str }
       { ####\int_use:N \l_@@_currarg_int }
       { \l_tmpa_cs {####1} {####2} }
+      {#1}
   } }
   \_@@_arguments:
 }
@@ -1036,7 +1052,6 @@
 %    \begin{macrocode}
 \keys_define:nn { stex / symdef } {
   name    .str_set_x:N = \l_stex_symdecl_name_str ,
-  local   .bool_set:N  = \l_stex_symdecl_local_bool ,
   args    .str_set_x:N = \l_stex_symdecl_args_str ,
   type    .tl_set:N    = \l_stex_symdecl_type_tl ,
   def     .tl_set:N    = \l_stex_symdecl_definiens_tl ,
@@ -1045,6 +1060,7 @@
  % lang    .str_set_x:N = \l_@@_lang_str ,
   variant .str_set_x:N = \l_@@_variant_str ,
   prec    .str_set_x:N = \l_@@_prec_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
   assoc   .choices:nn  = 
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}},
@@ -1060,6 +1076,7 @@
   \bool_set_false:N \l_stex_symdecl_local_bool
   \tl_clear:N \l_stex_symdecl_type_tl
   \tl_clear:N \l_stex_symdecl_definiens_tl
+  \clist_clear:N \l_stex_symdecl_argnames_clist
  % \str_clear:N \l_@@_lang_str
   \str_clear:N \l_@@_variant_str
   \str_clear:N \l_@@_prec_str
@@ -1086,6 +1103,70 @@
     { \l_@@_prec_str}
 }
 \stex_deactivate_macro:Nn \symdef {module~environments}
+
+\keys_define:nn { stex / mmtdef } {
+  name    .str_set_x:N = \l_stex_symdecl_name_str ,
+  args    .str_set_x:N = \l_stex_symdecl_args_str ,
+  reorder .str_set_x:N = \l_stex_symdecl_reorder_str ,
+  op      .tl_set:N    = \l_@@_op_tl ,
+ % lang    .str_set_x:N = \l_@@_lang_str ,
+  variant .str_set_x:N = \l_@@_variant_str ,
+  prec    .str_set_x:N = \l_@@_prec_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
+  assoc   .choices:nn  = 
+      {bin,binl,binr,pre,conj,pwconj}
+      {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}},
+  unknown .code:n      = \str_set:Nx 
+      \l_@@_variant_str \l_keys_key_str
+}
+\cs_new_protected:Nn \_stex_mmtdef_args:n {
+  \str_clear:N \l_stex_symdecl_name_str
+  \str_clear:N \l_stex_symdecl_args_str
+  \str_clear:N \l_stex_symdecl_assoctype_str
+  \str_clear:N \l_stex_symdecl_reorder_str
+  \bool_set_false:N \l_stex_symdecl_local_bool
+  \clist_clear:N \l_stex_symdecl_argnames_clist
+ % \str_clear:N \l_@@_lang_str
+  \str_clear:N \l_@@_variant_str
+  \str_clear:N \l_@@_prec_str
+  \tl_clear:N \l_@@_op_tl
+  
+  \keys_set:nn { stex / mmtdef } { #1 }
+}
+
+\NewDocumentCommand \mmtdef {m O{} }{
+  \_stex_mmtdef_args:n{ #2 }
+  \bool_set_true:N \l_stex_symdecl_make_macro_bool
+  \str_if_empty:NT \l_stex_symdecl_name_str {
+    \str_set:Nx \l_stex_symdecl_name_str { #1 }
+  }
+  %\tl_set:Nx \l_stex_symdecl_definiens_tl {
+  %  \stex_annotate:nnn{ OMID }{
+  %    \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+  %  }{}
+  %}
+  \stex_symdecl_do:n { #1 }
+  \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_current_module_str ? \l_stex_symdecl_name_str
+    }{},
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+    }{}
+  }
+  \tl_set:Nn \l_stex_notation_after_do_tl {
+    \_@@_final:
+    \stex_smsmode_do:\ignorespacesandpars
+  }
+  \str_set:Nx \l_stex_get_symbol_uri_str {
+    \l_stex_current_module_str ? \l_stex_symdecl_name_str
+  }
+  \exp_args:Nx \stex_notation_do:nnnnn
+    { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } }
+    { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } }
+    { \l_@@_variant_str }
+    { \l_@@_prec_str}
+}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1102,6 +1183,7 @@
   op      .tl_set:N     = \l_@@_op_tl ,
   prec    .str_set_x:N  = \l_@@_prec_str ,
   reorder .str_set_x:N  = \l_@@_reorder_str ,
+  argnames    .clist_set:N  = \l_@@_argnames_clist ,
   assoc   .choices:nn   = 
       {bin,binl,binr,pre,conj,pwconj}
       {\str_set:Nx \l_@@_assoctype_str {\l_keys_choice_tl}},
@@ -1120,6 +1202,7 @@
   \tl_clear:N \l_@@_type_tl
   \tl_clear:N \l_@@_def_tl
   \tl_clear:N \l_@@_op_tl
+  \clist_clear:N \l_@@_argnames_clist
 
   \keys_set:nn { stex / vardef } { #1 }
 }
@@ -1176,7 +1259,21 @@
   \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int }
   \tl_set:cx { #1 }{ \stex_invoke_variable:n { \l_@@_name_str } }
 
-  \prop_set_eq:cN { l_stex_variable_\l_@@_name_str _prop} \l_tmpa_prop
+  % argnames
+
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} {
+    \clist_if_empty:NTF \l_@@_argnames_clist {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+    }{
+      \clist_pop:NN \l_@@_argnames_clist \l_tmpa_tl
+      \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl}
+    }
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
+
+  \prop_set_eq:cN { l_stex_symdecl_var://\l_@@_name_str _prop} \l_tmpa_prop
 
   \tl_if_empty:NF \l_@@_op_tl {
     \cs_set:cpx {
@@ -1352,6 +1449,17 @@
 
   \cs_generate_from_arg_count:cNnn {stex_varseq_\l_@@_name_str _cs}
     \cs_set:Npn  {\int_use:N \l_@@_args_int} { #5 }
+
+  % argnames
+
+  \clist_clear:N \l_tmpa_clist
+  \int_step_inline:nn {\l_@@_args_int} {
+      \clist_put_right:Nn \l_tmpa_clist {##1}
+  }
+  \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,}
+
+
+
   
   \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l_@@_name_str _cs}}
   \int_step_inline:nn \l_@@_args_int {
@@ -1399,6 +1507,8 @@
     \expandafter\meaning\csname stex_varseq_\l_@@_name_str _cs\endcsname\\~\\
     \prop_to_keyval:N \l_tmpa_prop
   }
+  \prop_set_eq:cN {l_stex_symdecl_varseq://\l_@@_name_str _prop}\l_tmpa_prop
+  
   \stex_if_do_html:T{\stex_annotate_invisible:nnn{varseq}{\l_@@_name_str}{
     \tl_if_empty:NF \l_@@_type_tl {
       \stex_annotate:nnn {type}{}{$\l_@@_type_tl$}
@@ -1428,10 +1538,63 @@
 
   }}
 
-  \prop_set_eq:cN {stex_varseq_\l_@@_name_str _prop}\l_tmpa_prop
   \ignorespacesandpars
 }
 
+
+\keys_define:nn { stex / mmtdecl } {
+  name        .str_set_x:N  = \l_stex_symdecl_name_str ,
+  args        .str_set_x:N  = \l_stex_symdecl_args_str ,
+  deprecate   .str_set_x:N  = \l_stex_symdecl_deprecate_str ,
+  reorder     .str_set_x:N  = \l_stex_symdecl_reorder_str ,
+  argnames    .clist_set:N  = \l_stex_symdecl_argnames_clist ,
+  assoc       .choices:nn   = 
+      {bin,binl,binr,pre,conj,pwconj}
+      {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}
+}
+
+\cs_new_protected:Nn \_stex_mmtdecl_args:n {
+  \str_clear:N \l_stex_symdecl_name_str
+  \str_clear:N \l_stex_symdecl_args_str
+  \str_clear:N \l_stex_symdecl_deprecate_str
+  \str_clear:N \l_stex_symdecl_reorder_str
+  \str_clear:N \l_stex_symdecl_assoctype_str
+  \bool_set_false:N \l_stex_symdecl_local_bool
+  \clist_clear:N \l_stex_symdecl_argnames_clist
+  
+  \keys_set:nn { stex / symdecl } { #1 }
+}
+
+\NewDocumentCommand \mmtdecl { s m O{}} {
+  \_stex_mmtdecl_args:n{#3}
+  \IfBooleanTF #1 {
+    \bool_set_false:N \l_stex_symdecl_make_macro_bool
+  } {
+    \bool_set_true:N \l_stex_symdecl_make_macro_bool
+  }
+  \str_if_empty:NT \l_stex_symdecl_name_str {
+    \str_set:Nx \l_stex_symdecl_name_str { #1 }
+  }
+  %\tl_set:Nx \l_stex_symdecl_definiens_tl {
+  %  \stex_annotate:nnn{ OMID }{
+  %    \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+  %  }{}
+  %}
+  \stex_symdecl_do:n{#2}
+  \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_current_module_str ? \l_stex_symdecl_name_str
+    }{},
+    \stex_annotate:nnn{ OMID }{
+      \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str 
+    }{}
+  }
+  \stex_smsmode_do:
+}
+
+\stex_deactivate_macro:Nn \mmtdecl {mmtinterface~environments}
+\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments}
+
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-- 
cgit v1.2.3

