3

I have created a code for a proof goal:

\centering{zz:\,$\{P,\,P \lif Q,\,Q \lif  R\}\,\sststile{AL}{}\,R$`

The output looks like this:

enter image description here

Now I'd like to define a custom command which gives a very general recipe for this kind of code. It should have the following form:

\zz{formulas before the turnstile |- formula after the turnstile}[first argument of sststile, optional]

So in my example, it should be:

\zz{P,P \lif Q, Q \lif R|- R}[AL]

The command should work with any number for formulas before the turnstile, seperate them with a comma and add the extra space between them. Also, if I write |= instead of |- it should produce the double turnstile \sdtstile. How could I do that? I'm looking forward to your answers!

Here is the code I used:

\documentclass[a4paper,ngerman, abstracton, leqno]{scrartcl} 
\usepackage{amsmath} 
\usepackage{amssymb} 
\usepackage{amsthm} 
\usepackage{turnstile}
\usepackage[LGRgreek]{mathastext} % removes italics from mathfont

\newcommand{\lif}{\rightarrow}

\begin{document} \centering{zz:,${P,,P \lif Q,,Q \lif R},\sststile{AL}{},R$} \end{document}

  • This would be much easier if you have two commands, \zz{before}{after}[what] for one type of turnstyle and \ZZ{before}{after}[what] for the other type. I imagine you can invent something with your syntax too, but it will need much more "TeXhacking" skills... – Rmano May 18 '21 at 08:47
  • BTW, \centering gets no arguments, it's a switch: https://tex.stackexchange.com/questions/23650/when-should-we-use-begincenter-instead-of-centering/23653 – Rmano May 18 '21 at 08:48

1 Answers1

1

First off, \centering does not work as you seem to think. I used \[...\] instead.

\documentclass{article}
\usepackage{amsmath}
\usepackage{turnstile}

\usepackage{lipsum} % just for mock text

\newcommand{\lif}{\rightarrow}

\ExplSyntaxOn

\NewDocumentCommand{\zz}{mO{}} { \vitus_zz_start:nn { #1 } { #2 } }

\cs_new_protected:Nn \vitus_zz_start:nn { \regex_match:nnTF { | - } { #1 } { \vitus_zz_do:nnnn { |- } { \sststile } { #1 } { #2 } } { \vitus_zz_do:nnnn { |= } { \sdtstile } { #1 } { #2 } } }

\cs_new_protected:Nn \vitus_zz_do:nnnn { [ \mathrm{zz{:};} \seq_set_split:Nnn \l_tmpa_seq { #1 } { #3 } \seq_item:Nn \l_tmpa_seq { 1 } #2{#4}{} \seq_item:Nn \l_tmpa_seq { 2 } ] }

\ExplSyntaxOff

\begin{document}

\lipsum[1][1-3] \zz{P,P \lif Q, Q \lif R |- R}[AL] \lipsum[2][1-3] \zz{P,P \lif Q, Q \lif R |- R} \lipsum[1][1-3] \zz{P,P \lif Q, Q \lif R |= R}[AL] \lipsum[2][1-3] \zz{P,P \lif Q, Q \lif R |= R} \lipsum[2][1-3]

\end{document}

The arguments are absorbed and the first (mandatory) one is analyzed to see whether it contains |-. If it does, \sststile is used, otherwise \sdtstile. Next the argument is split at either |- or |= according to the previous analysis and the line is formed.

enter image description here

egreg
  • 1,121,712