texlive[64392] Master: luatruthtable (14sep22)

commits+karl at tug.org commits+karl at tug.org
Wed Sep 14 22:05:16 CEST 2022


Revision: 64392
          http://tug.org/svn/texlive?view=revision&revision=64392
Author:   karl
Date:     2022-09-14 22:05:16 +0200 (Wed, 14 Sep 2022)
Log Message:
-----------
luatruthtable (14sep22)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/lualatex/luatruthtable/
    trunk/Master/texmf-dist/doc/lualatex/luatruthtable/README.txt
    trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.bib
    trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.pdf
    trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.tex
    trunk/Master/texmf-dist/tex/lualatex/luatruthtable/
    trunk/Master/texmf-dist/tex/lualatex/luatruthtable/luatruthtable.sty
    trunk/Master/tlpkg/tlpsrc/luatruthtable.tlpsrc

Added: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luatruthtable/README.txt	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/luatruthtable/README.txt	2022-09-14 20:05:16 UTC (rev 64392)
@@ -0,0 +1,9 @@
+# Introduction
+The luatruthtable package is developed to generate Truth Tables of boolean values in LaTeX. It provides an easy way for generating truth tables in LaTeX . There is no need of special environment in the package for generation of Truth Tables. It is written in lua and tex file is to be compiled with LuaLatex engine.  The time required for operations is no issue while compiling with LuaLaTeX.  There is no need to install lua on users system as tex distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. It is useful for generation of Truth Tables in tex file itself. The package supports nesting of commands for multiple operations. It can be modified or extended by writing custom lua programs. 
+
+# License
+The luatruthtable package is released under the LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
+It is developed in lua.  Lua is certified open source software available. Its license is simple and liberal which is compatible with GPL.
+
+#Installation and Inclusion
+The installation of  luatruthtable package is similar to plain latex package where luatruthtable.sty file is in LaTeX directory of texmf tree. The package can be used by including the command  \usepackage{luatruthtable} in the preamble of latex document.The tex file is to be compiled using the LuaLaTeX engine.
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/README.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.bib
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.bib	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.bib	2022-09-14 20:05:16 UTC (rev 64392)
@@ -0,0 +1,20 @@
+
+
+
+ at online{online.latextruthtable,
+  title = {Macro for automating truth tables in LaTeX},
+  url = {https://tex.stackexchange.com/questions/505994},
+  note = {visited on 2022-02-22}
+}
+
+
+ at online{online.luacustomoperator,
+  title = {Lua Custom Operator},
+  url = {http://lua-users.org/wiki/CustomOperators},
+  note = {visited on 2022-02-22}
+}
+
+
+
+
+


Property changes on: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.bib
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.pdf	2022-09-14 20:04:24 UTC (rev 64391)
+++ trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.pdf	2022-09-14 20:05:16 UTC (rev 64392)

Property changes on: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.tex	2022-09-14 20:05:16 UTC (rev 64392)
@@ -0,0 +1,358 @@
+\documentclass{article}
+\usepackage{listings,color,parskip,booktabs,longtable,array,
+hyperref,multirow,multicol,luatruthtable, enumitem}
+\usepackage[top=1.1in, bottom=1.1in, left=1in, right=1in]{geometry}
+\hypersetup{colorlinks,urlcolor=blue}
+\lstset{frame=none,
+	language=[LaTeX]{TeX},
+  aboveskip=3mm,
+  belowskip=3mm,
+  showstringspaces=false,
+  columns=flexible,
+  basicstyle={\ttfamily},
+  numbers=none,
+  numberstyle=\tiny\color{gray},
+  stringstyle=\color{mauve},
+  breaklines=true,
+  breakatwhitespace=true,
+  tabsize=1
+}
+\usepackage[backend=bibtex]{biblatex}
+\addbibresource{luatruthtable}
+\begin{document}
+\title{luatruthtable Package}
+\author{Chetan Shirore and Dr. Ajit Kumar}
+\maketitle
+\section{luatruthtable Package}
+The \emph{luatruthtable} package is developed to generate Truth Tables of boolean values in LaTeX. It provides an easy way for generating truth tables in LaTeX . There is no need of special environment in the package for generation of Truth Tables. It is written in lua and tex file is to be compiled with LuaLatex engine.  The time required for operations is no issue while compiling with LuaLaTeX.  There is no need to install lua on users system as tex distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. It is useful for generation of Truth Tables in tex file itself. The package supports nesting of commands for multiple operations. It can be modified or extended by writing custom lua programs. 
+
+The progamming capabilities of Lua are effectively used in the development of pacakage. The other approaches of generating Truth Table in LaTeX get weired \cite{online.latextruthtable} and probably without using Lua it can't be done in an easier way in LaTeX.  The \emph{xkeyval} package is used in its development apart from the \emph{luacode*} package. 
+
+\section{License} The \emph{luatruthtable} package is released under the LaTeX Project Public License v1.3c or later. The complete license text is available at \url{http://www.latex-project.org/lppl.txt}.
+It is developed in lua.  Lua is certified open source software available. Its license is simple and liberal which is compatible with GPL.
+\section{Installation and Inclusion}
+The installation of  \emph{luatruthtable} package is similar to plain latex package where \texttt{.sty} file is in \LaTeX directory of texmf tree. The package can be used by including the command \texttt{\textbackslash usepackage\{luatruthtable\}} in the preamble of latex document.  The tex file is to be compiled using the LuaLaTeX engine.
+\section{Core Ideas used in the development of the package} The function \verb|toBinary(x,y)| is used to produce sequence of \emph{True} and \emph{False} values  of boolean variables. This function converts the decimal number \verb|x| to a binary number by adding \verb|y| number of leading zeroes. The result of this is stored in a table in Lua.  Here \verb|y| corresponds to number of boolean variables. As  \(2^y\) permutations of boolean variables are to be produced, the function \verb|toBinary(x,y)| runs inside a loop where  \verb|x|  takes values from \(1\) to \(y\). The splitting of variables and expressions is done using string methods available in Lua. The nested \emph{metamethods} in Lua are used to define several logical operators. The \emph{load} function in Lua is used to evaluate logical expressions. 
+\section{Command luaTruthTable in luatruthtable package}
+The \verb|\luaTruthTable| command is the main command in the \emph{luatruthtable} package which generates truth tables. It has the following syntax.
+\begin{lstlisting}
+\luaTruthTable[trtext,fltext]{list of boolean / logical variables}{list of  expressions}
+\end{lstlisting}
+The command has two mandatory arguments. \\
+i) \verb|list of boolean / logical variables| : The list of boolean or logical variables should be separated by comma.  \\
+ii) \verb|list of expressions| : The list of logical expressions that are to be evaluated should be separated by comma. \\
+The command has two optional arguments. \\
+i) \verb|trtext| : The \verb|trtext| is the display value for the boolean value \emph{True}. It has the default value \verb|$T$| in the package. It can be any string or number.  Assigning value \(0\) should be avoided to  \verb|trtext| variable.   \\
+ii) \verb|fltext| : The \verb|fltext| is the display value for the boolean value \emph{False}. It has the default value \verb|$F$| in the package. It can be any string or number.  Assigning value \(1\) should be avoided to  \verb|fltext| variable.  
+
+The \verb|\luaTruthTable| command should be used within in the environment \verb|\begin{tabular} ... \end{tabular}| or any other environment in LaTeX for Tables. The sequence of column heads should be same as sequence of \verb|list of boolean / logical variables| and \verb|list of expressions|. Without these correct inputs, the command \verb|\luaTruthTable| can't produce the expected output. 
+
+\section{Operations in luatruthtable package}
+\begin{enumerate}[label=\alph*)]
+\item \emph{not}: The value of \emph{ not p} is False when \(p\) is True and it is True when \(p\) is False. 
+\begin{center}
+\begin{tabular}{|c|c|}
+\hline
+\(p\) &  not \(p\) \\
+\hline
+\luaTruthTable{p}{lognot*p} \\
+\hline
+\end{tabular}
+\end{center}
+
+The command \verb|lognot*| is used in the package to generate truth table for  \emph{not} operation.
+\item \emph{and}: The value of \emph{p AND q} is True if and only if both \(p\) and \(q\) are True.
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) and \(q\) \\
+\hline
+\luaTruthTable{p,q}{p*logand*q} \\
+\hline
+\end{tabular}
+\end{center}
+The command \verb|*logand*| is used in the package to generate truth table for  \emph{and} operation .
+\item \emph{or}: The value of \emph{p or q} is False if and only if both \(p\) and \(q\) are False.
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) or \(q\) \\
+\hline
+\luaTruthTable{p,q}{p*logor*q} \\
+\hline
+\end{tabular}
+\end{center}
+The command \verb|*logor*| is used in the package to generate truth table for  \emph{or} operation.
+\item \emph{implies}: The value of \emph{p implies q} is False if and only if  \(p\) is True and \(q\) is False.
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) implies \(q\) \\
+\hline
+\luaTruthTable{p,q}{p*imp*q} \\
+\hline
+\end{tabular}
+\end{center}
+
+The command \verb|*imp*| is used in the package to generate truth table for  \emph{implies} operation.
+\item \emph{if and only if} : The value of \emph{p if and only if q} is True if and only if  both \(p\) and \(q\) have same truth values. 
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) iff \(q\) \\
+\hline
+\luaTruthTable{p,q}{p*iff*q} \\
+\hline
+\end{tabular}
+\end{center}
+
+The command \verb|*iff*| is used in the package to generate truth table for  \emph{if and only if} operation.
+\item \emph{NAND} : The value of \emph{p NAND q} is \(0\) if and only if both \(p\)  and \(q\) have value \(1\).
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) NAND \(q\) \\
+\hline
+\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*lognand*q} \\
+\hline
+\end{tabular}
+\end{center}
+
+The command \verb|*lognand*| is used in the package to generate truth table for  \emph{NAND} operation.
+\item \emph{XOR} : The value of \emph{p XOR q} is \(0\) if and only if  \(p\)  and \(q\) have same values.
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) XOR \(q\) \\
+\hline
+\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*logxor*q} \\
+\hline
+\end{tabular}
+\end{center}
+
+
+The command \verb|*logxor*| is used in the package to generate truth table for  \emph{XOR} operation.
+\item \emph{NOR}: The value of \emph{p NOR q} is \(1\) if and only if both \(p\)  and \(q\) have value \(0\).
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) NOR \(q\) \\
+\hline
+\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*lognor*q} \\
+\hline
+\end{tabular}
+\end{center}
+
+The command \verb|*lognor*| is used in the package to generate truth table for  \emph{NOR} operation.
+\item \emph{XNOR}: The value of \emph{p XNOR q} is \(1\) if and only if both \(p\)  and \(q\) have same values.
+\begin{center}
+\begin{tabular}{|cc|c|}
+\hline
+\(p\) & \(q\) & \(p\) XNOR \(q\) \\
+\hline
+\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*logxnor*q} \\
+\hline
+\end{tabular}
+\end{center}
+
+The command \verb|*logxnor*| is used in the package to generate truth table for  \emph{XNOR} operation.
+\end{enumerate}
+The following table summarises logical operators in the package.
+\begin{center}
+\begin{longtable}{llm{8cm}}
+\toprule
+\multicolumn{1}{c}{\textcolor{blue}{Operator}} & \multicolumn{1}{l}{\textcolor{blue}{Syntax}} & \multicolumn{1}{c}{\textcolor{blue}{Description}}  \\
+\toprule
+\begin{lstlisting}
+lognot*
+\end{lstlisting} &
+\begin{lstlisting}
+lognot*p
+\end{lstlisting} & Negates the boolean variable \(p\)\\
+\midrule
+\begin{lstlisting}
+*logand*
+\end{lstlisting} &
+\begin{lstlisting}
+p*logand*q
+\end{lstlisting} & Gives the truth of the expression \emph{p and q} for boolean variables \(p\) and \(q\).\\
+\midrule
+\begin{lstlisting}
+*logor*
+\end{lstlisting} &
+\begin{lstlisting}
+p*logor*q
+\end{lstlisting} & Gives the truth of the expression \emph{p or q} for boolean variables \(p\) and \(q\).\\
+\midrule
+\begin{lstlisting}
+*imp*
+\end{lstlisting} &
+\begin{lstlisting}
+p*imp*q
+\end{lstlisting} & Gives the truth of the expression \emph{if p then q} for boolean variables \(p\) and \(q\).\\
+\midrule
+\begin{lstlisting}
+*iff*
+\end{lstlisting} &
+\begin{lstlisting}
+p*iff*q
+\end{lstlisting} & Gives the truth of the expression \emph{p if and only if q} for boolean variables \(p\) and \(q\).\\
+\midrule
+\begin{lstlisting}
+*lognand*
+\end{lstlisting} &
+\begin{lstlisting}
+p*lognand*q
+\end{lstlisting} & Gives the truth of the expression \emph{ p NAND q} for boolean variables \(p\) and \(q\).\\
+\midrule
+\begin{lstlisting}
+*logxor*
+\end{lstlisting} &
+\begin{lstlisting}
+p*logxor*q
+\end{lstlisting} & Gives the truth of the expression \emph{ p XOR q} for boolean variables \(p\) and \(q\).\\
+\midrule
+\begin{lstlisting}
+*lognor*
+\end{lstlisting} &
+\begin{lstlisting}
+p*lognor*q
+\end{lstlisting} & Gives the truth of the expression \emph{ p NOR q} for boolean variables \(p\) and \(q\).\\
+\midrule
+\begin{lstlisting}
+*logxnor*
+\end{lstlisting} &
+\begin{lstlisting}
+p*logxnor*q
+\end{lstlisting} & Gives the truth of the expression \emph{ p XNOR q} for boolean variables \(p\) and \(q\).\\
+
+\bottomrule
+\end{longtable}
+\end{center}
+
+\section{Examples and Usage} The \emph{luatruthtable} package can accept finite number of variables. It supports finite number of variables that one would practically need. Few examples of usage are given here. 
+\begin{lstlisting}
+\begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
+\hline
+\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
+ & \(p \leftrightarrow q\) &  \( p\) nand \(q\) & \(p\)   xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
+\hline
+\luaTruthTable{p,q}{lognot*p,p*logand*q,  p*logor*q, p*imp*q, p*iff*q, 
+p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
+\hline
+\end{tabular}
+\end{lstlisting}
+With the packages \emph{luatruthtable},the above code outputs to 
+\ \\ \ \\
+\begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
+\hline
+\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
+ & \(p \leftrightarrow q\) &  \( p\) nand \(q\) & \(p\)   xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
+\hline
+\luaTruthTable{p,q}{lognot*p,p*logand*q,  p*logor*q, p*imp*q, p*iff*q, 
+p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
+\hline
+\end{tabular}
+\ \\ \\
+The following is the code generated by the command \verb|\luaTruthTable| in above code. 
+ \begin{lstlisting}
+$F$ & $T$ & $T$ & $F$ & $T$ & $T$ & $F$ & $T$ & $T$ & $F$ & $F$\\
+$T$ & $F$ & $F$ & $F$ & $T$ & $F$ & $F$ & $T$ & $T$ & $F$ & $F$\\
+$T$ & $T$ & $F$ & $T$ & $T$ & $T$ & $T$ & $F$ & $F$ & $F$ & $T$\\
+$F$ & $F$ & $T$ & $F$ & $F$ & $T$ & $T$ & $T$ & $F$ & $T$ & $T$
+ \end{lstlisting}
+  The following example illustrates the use use of \emph{trtext} and \emph{fltext}. Here \(0\) is assigned to \emph{trtext} and \(1\) is assigned to \emph{fltext}.
+ \begin{lstlisting}
+ \begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
+\hline
+\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
+ & \(p \leftrightarrow q\) &  \( p\) nand \(q\) & \(p\)   xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
+\hline
+\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{lognot*p,p*logand*q,  p*logor*q, p*imp*q, p*iff*q, 
+p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
+\hline
+\end{tabular}
+ \end{lstlisting} 
+ 
+ With the packages \emph{luatruthtable},the above code outputs to 
+\ \\ \ \\
+  \begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
+\hline
+\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
+ & \(p \leftrightarrow q\) &  \( p\) nand \(q\) & \(p\)   xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
+\hline
+\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{lognot*p,p*logand*q,  p*logor*q, p*imp*q, p*iff*q, 
+p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
+\hline
+\end{tabular}
+\ \\ \\
+The following is the code generated by the command \verb|\luaTruthTable| in above code. 
+\begin{lstlisting}
+$0$ & $1$ & $1$ & $0$ & $1$ & $1$ & $0$ & $1$ & $1$ & $0$ & $0$\\
+$1$ & $0$ & $0$ & $0$ & $1$ & $0$ & $0$ & $1$ & $1$ & $0$ & $0$\\
+$1$ & $1$ & $0$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $1$\\
+$0$ & $0$ & $1$ & $0$ & $0$ & $1$ & $1$ & $1$ & $0$ & $1$ & $1$
+\end{lstlisting}
+The following example involves three variables. 
+\begin{lstlisting}
+\begin{tabular}{|ccc|c|}
+\hline
+\(p\) & \(q\) & \(r\) &  \((p \land q)\) \rightarrow \(\neg r\) \\
+\hline
+\luaTruthTable{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
+\hline
+\end{tabular}
+\end{lstlisting}
+ With the packages \emph{luatruthtable},the above code outputs to 
+\ \\ \ \\
+\begin{tabular}{|ccc|c|}
+\hline
+\(p\) & \(q\) & \(r\) &  \((p \land q)\) \rightarrow \(\neg r\) \\
+\hline
+\luaTruthTable{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
+\hline
+\end{tabular}
+\ \\ \\
+Here \emph{lognot*r} should be enclosed in parenthesis in order to produce correct results in generated truth table.
+\ \\
+The following is the code generated by the command \verb|\luaTruthTable| in above code. 
+\begin{lstlisting}
+$F$ & $F$ & $T$ & $T$\\
+$F$ & $T$ & $F$ & $T$\\
+$F$ & $T$ & $T$ & $T$\\
+$T$ & $F$ & $F$ & $T$\\
+$T$ & $F$ & $T$ & $T$\\
+$T$ & $T$ & $F$ & $T$\\
+$T$ & $T$ & $T$ & $F$\\
+$F$ & $F$ & $F$ & $T$
+\end{lstlisting}
+With the use of optional arguments \verb|[trtext=True, fltext=False]| in the previous example, one gets the following output.
+\ \\ \  \\ \ \\
+\begin{tabular}{|ccc|c|}
+\hline
+\(p\) & \(q\) & \(r\) &  \((p \land q)\) \rightarrow \(\neg r\) \\
+\hline
+\luaTruthTable[trtext=True, fltext=False]{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
+\hline
+\end{tabular}
+\ \\ \\ 
+
+It is possible to input \emph{trtext} and \emph{trfalse} in mathematics environment. So with the use of optional arguments \verb|[trtext=$True$, fltext=$False$]| in the previous example, one gets the following output.
+\ \\ \  \\ \ \\
+\begin{tabular}{|ccc|c|}
+\hline
+\(p\) & \(q\) & \(r\) &  \((p \land q)\) \rightarrow \(\neg r\) \\
+\hline
+\luaTruthTable[trtext=$True$, fltext=$False$]{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
+\hline
+\end{tabular} 
+\ \\ \  \\ \ \\
+Since \emph{luacode*} package is used, the backslash is to be escaped while assigning values to \emph{trtext} and \emph{trfalse}.  For example \verb|[trtext=\\(True\\), fltext=\\(False\\)]|
+
+
+\section{Known Issues,Limitations and Scope of the package} The associativity and precedence of operator is not yet supported. The package can give appropriate results only when parentheses are used for each of the operation. It gives eraneous result when  parentheses are not used. This point is of utmost importance in using the package. These issues are there is no native way of defining custom operations in Lua \cite{online.luacustomoperator}. However some metamethods can be nested in a way to glimpse the operators. All operators defined in this package are instances of such nestings. The question may be raised that is there better way of accomplishing this in Lua. The answer to the point is that there are alternative ways of doing this. They may be better in some or other sense. For example, instead of defining \emph{*logand*} operator and using it in the fashion \emph{p*logand*q}, one could define function \emph{logand} that takes two arguments and use it in a way \emph{logand(p,q)}. But when it comes to embedding it in LaTeX, again one has to use more and more nested parentheses as number of statements and operations increase. This is the exact reason why such approach is not used in the development of package. Instead of using \emph{implies(logand(p,logor(q,r)),s)} it sounds more natural to use \emph{(p *logand* (q*logor*r) )*implies* s}. 
+
+Apart from these issues, there is no error handling mechanism used in the package. It relies on the error handling of Lua and TeX itself. The package currently supports 9 operations viz. \emph{not,and,nand,or, xor, implies, iff, nor, xnor}. The error handling and extending number of operations may be considered in future versions of the package. 
+
+\printbibliography
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/lualatex/luatruthtable/luatruthtable.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/luatruthtable/luatruthtable.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/luatruthtable/luatruthtable.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/luatruthtable/luatruthtable.sty	2022-09-14 20:05:16 UTC (rev 64392)
@@ -0,0 +1,286 @@
+% luaset package
+% version 1.0
+% Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
+%Authors: Chetan Shirore and Dr. Ajit Kumar
+
+\ProvidesPackage{luatruthtable}[1.0]
+\RequirePackage{xkeyval}
+\RequirePackage{amsmath}
+\RequirePackage{luacode}
+\begin{luacode*}
+local function toBinary(x,y)
+    y = y or math.max(1, select(2, math.frexp(x)))
+    local res = {}
+    for i = y, 1, -1 do
+        res[i] = math.fmod(x, 2)
+        x = math.floor((x - res[i]) / 2)
+    end
+    return res
+end
+
+local function _not(a)
+  if a ==0 then return 1
+    else return 0 end
+end
+
+local lognot = {}
+
+local not_mt= {
+  __mul = function(a,b)
+      return _not(b)
+
+  end
+}
+
+setmetatable(lognot, not_mt)
+_G.lognot = lognot
+
+local function _and(a, b)
+  if a == 1 and b == 1 then return 1
+    else return 0 end
+end
+
+local tmp1 = {}
+local logand = {}
+
+local and_mt= {
+  __mul = function(a,b)
+    if b==logand then
+      tmp1[1]=a
+      return tmp1
+    elseif a == tmp1 then
+      return _and(tmp1[1], b)
+    end
+  end
+}
+
+setmetatable(tmp1, and_mt)
+setmetatable(logand, and_mt)
+_G.logand = logand
+
+local function _or(a, b)
+  if a == 0 and b == 0 then return 0
+    else return 1 end
+end
+
+local tmp2 = {}
+local logor = {}
+
+local or_mt= {
+  __mul = function(a,b)
+    if b==logor then
+      tmp2[1]=a
+      return tmp2
+    elseif a == tmp2 then
+      return _or(tmp2[1], b)
+    end
+  end
+}
+
+setmetatable(tmp2, or_mt)
+setmetatable(logor, or_mt)
+_G.logor = logor
+
+local function _imp(a, b)
+  if a == 1 and b == 0 then return 0
+    else return 1 end
+end
+
+local tmp3 = {}
+local imp = {}
+
+local imp_mt= {
+  __mul = function(a,b)
+    if b==imp then
+      tmp3[1]=a
+      return tmp3
+    elseif a == tmp3 then
+      return _imp(tmp3[1], b)
+    end
+  end
+}
+
+setmetatable(tmp3, imp_mt)
+setmetatable(imp, imp_mt)
+_G.imp = imp
+
+local function _iff(a, b)
+  if a == b then return 1
+    else return 0 end
+end
+
+local tmp4 = {}
+local iff = {}
+
+local iff_mt= {
+  __mul = function(a,b)
+    if b==iff then
+      tmp4[1]=a
+      return tmp4
+    elseif a == tmp4 then
+      return _iff(tmp4[1], b)
+    end
+  end
+}
+
+setmetatable(tmp4, iff_mt)
+setmetatable(iff, iff_mt)
+_G.iff = iff
+
+local function _xor(a, b)
+  if a ~= b then return 1
+    else return 0 end
+end
+
+local tmp5 = {}
+local logxor = {}
+
+local xor_mt= {
+  __mul = function(a,b)
+    if b==logxor then
+      tmp5[1]=a
+      return tmp5
+    elseif a == tmp5 then
+      return _xor(tmp5[1], b)
+    end
+  end
+}
+
+setmetatable(tmp5, xor_mt)
+setmetatable(logxor, xor_mt)
+_G.logxor = logxor
+
+local function _nand(a, b)
+  if a ==1 and b == 1 then return 0
+    else return 1 end
+end
+
+local tmp6 = {}
+local lognand = {}
+
+local nand_mt= {
+  __mul = function(a,b)
+    if b==lognand then
+      tmp6[1]=a
+      return tmp6
+    elseif a == tmp6 then
+      return _nand(tmp6[1], b)
+    end
+  end
+}
+
+setmetatable(tmp6, nand_mt)
+setmetatable(lognand, nand_mt)
+_G.lognand = lognand
+
+local function _nor(a, b)
+  if a ==0 and b == 0 then return 1
+    else return 0 end
+end
+
+local tmp7 = {}
+local lognor = {}
+
+local nor_mt= {
+  __mul = function(a,b)
+    if b==lognor then
+      tmp7[1]=a
+      return tmp7
+    elseif a == tmp7 then
+      return _nor(tmp7[1], b)
+    end
+  end
+}
+
+setmetatable(tmp7, nor_mt)
+setmetatable(lognor, nor_mt)
+_G.lognor = lognor
+
+local function _xnor(a, b)
+  if a == b then return 1
+    else return 0 end
+end
+
+local tmp8 = {}
+local logxnor = {}
+
+local xnor_mt= {
+  __mul = function(a,b)
+    if b==logxnor then
+      tmp8[1]=a
+      return tmp8
+    elseif a == tmp8 then
+      return _xnor(tmp8[1], b)
+    end
+  end
+}
+
+setmetatable(tmp8, xnor_mt)
+setmetatable(logxnor, xnor_mt)
+_G.logxnor = logxnor
+
+function truthTable(str0,str,trtext,fltext)
+local eval=""
+local names={lognot=lognot,logand=logand,logor=logor, imp=imp, 
+  iff=iff, logxor=logxor,lognand=lognand,lognor=lognor, logxnor=logxnor}
+local vars={}
+local expr={}
+local countexp = 1
+local countvars =1
+local res=""
+local sep=" & "
+trtext = trtext or "$T$"
+fltext = fltext or "$F$"
+for variables in string.gmatch(str0, '([^,]+)') do
+  vars[countvars] = variables
+ countvars = countvars + 1
+end
+
+for subexp in string.gmatch(str, '([^,]+)') do
+    expr[countexp] = subexp
+    countexp = countexp + 1
+end
+
+local n =#vars
+for i =1,2^n do
+  itr = toBinary(i,n)
+
+  for j=1, #itr do
+    names[vars[j]] = itr[j]
+end
+
+    for k = 1, #expr do
+      res= res ..sep.. load("return " .. expr[k],nil,"t",names)()
+      end
+if i~=2^n then
+eval = eval .. table.concat(toBinary(i,n)," & ") .. res .."\\\\"
+else
+eval = eval .. table.concat(toBinary(i,n)," & ") .. res
+end
+ res=""
+end
+
+if trtext:gsub("%s+", "") =="0" or trtext:gsub("%s+", "") == "$0$"  
+or fltext:gsub("%s+", "") =="1" or fltext:gsub("%s+", "") == "$1$" 
+then
+eval=eval
+else
+eval=eval:gsub(0,fltext):gsub(1,trtext)
+end
+return eval
+end
+
+\end{luacode*}
+
+% ========= KEY DEFINITIONS =========
+\define at key{luatruthtable}{trtext}{\def\luatrtbl at trtext{#1}}
+\define at key{luatruthtable}{fltext}{\def\luatrtbl at fltext{#1}}
+
+% ========= KEY DEFAULTS =========
+\setkeys{luatruthtable}{trtext=$T$,fltext=$F$}%
+% ========= Defining Command =========
+\newcommand{\luaTruthTable}[3][]{%
+  \setkeys{luatruthtable}{#1}
+  \directlua{tex.sprint(truthTable(\luastringN{#2},\luastringN{#3},'\luatrtbl at trtext','\luatrtbl at fltext'))}} %
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/lualatex/luatruthtable/luatruthtable.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2022-09-14 20:04:24 UTC (rev 64391)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2022-09-14 20:05:16 UTC (rev 64392)
@@ -510,7 +510,7 @@
     luamesh luamplib luaotfload luapackageloader luaprogtable luapstricks
     luaquotes luarandom
     luasseq luatex85 luatexbase luatexja luatexko luatextra
-    luatodonotes luavlna luaxml
+    luatodonotes luatruthtable luavlna luaxml
     lutabulartools lwarp lxfonts ly1 lyluatex
   macrolist macros2e macroswap mafr magaz magicnum magra
     mahjong mailing mailmerge

Modified: trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2022-09-14 20:04:24 UTC (rev 64391)
+++ trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2022-09-14 20:05:16 UTC (rev 64392)
@@ -59,6 +59,7 @@
 depend luatexbase
 depend luatexko
 depend luatextra
+depend luatruthtable
 depend luavlna
 depend luaxml
 depend lutabulartools

Added: trunk/Master/tlpkg/tlpsrc/luatruthtable.tlpsrc
===================================================================


More information about the tex-live-commits mailing list.