如何使每个对齐部分都有自己独立的编号?

如何使每个对齐部分都有自己独立的编号?

如何才能使行号不延续到下alignat一部分?

代码如下:

\subsubsection*{Answer}
\begin{alignat}{2}
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    \forall x (P(x) \to Q(x)) &\text{ by } (\in) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    (P(x) \to Q(x)) &\text{ by } (\forall -, 1) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    \forall x P(x)  &\text{ by } (\in) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    \forall x P(x)  &\text{ by } (\forall -, 3) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash Q(u) &\text{ by } (\forall +, 2, 4) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    (\forall x P(x)) \to (\forall y Q(y)) &\text{ by } (\forall +, 5) \\
    \forall x (P(x) \to Q(x)) &\vdash (\forall x P(x)) \to (\forall y Q(y))
\end{alignat}
\subsection*{Example 4}
Prove
\[
    \exists x (P(x) \lor Q(x)) \vdash
    (\exists xP(x)) \lor (\exists xQ(x))
.\] 
\subsubsection*{Answer}

\begin{alignat}{2}
    P(u) &\vdash \exists P(u) \text{ by } (\in) \\
    Q(u) &\vdash \exists Q(u) \text{ by } (\in) \\
    P(u) &\vdash \exists xP(x) \text{ by } (\exists +, 1) \\
    P(u) &\vdash \exists xP(x) \text{ by } (\exists +, 0) \\
    Q(u) &\vdash \exists xQ(x) \\
    P(u) &\vdash (\exists x P(x)) \lor (\exists  x Q(x)) \\
    Q(u) &\vdash (\exists x P(x)) \lor (\exists  x Q(x)) \\
    (P(u) \lor Q(u)) &\vdash
    (\exists xP(x)) \lor (\exists xQ(x)) \text { by } (\forall -, \\
    \exists x (P(x) \lor Q(x)) &\vdash
    (\exists xP(x)) \lor (\exists xQ(x)) \text { by } (\exists -,
\end{alignat}
\end{document}

它产生: 在此处输入图片描述 在此处输入图片描述

但我想要的是每个“答案”部分不是从上一个“答案”部分继续,\begin{alignat}和之间的任何内容end{alignat}都应从 #1 开始。

我怎样才能实现这个目标?

答案1

我不会让equation柜台超载。

\documentclass{article}
\usepackage[leqno]{amsmath}

\newcounter{derivation}

\newenvironment{derivation}
 {%
  \setcounter{derivation}{\value{equation}}%
  \setcounter{equation}{0}%
  %\renewcommand{\theHequation}{derivation@\arabic{equation}}% for hyperref
  \alignat{2}%
 }
 {%
  \endalignat
  \setcounter{equation}{\value{derivation}}%
 }

\begin{document}

\subsubsection*{Answer}
\begin{derivation}
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    \forall x (P(x) \to Q(x)) &\text{ by } (\in) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    (P(x) \to Q(x)) &\text{ by } (\forall -, 1) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    \forall x P(x)  &\text{ by } (\in) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    \forall x P(x)  &\text{ by } (\forall -, 3) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash Q(u) &\text{ by } (\forall +, 2, 4) \\
    \forall x (P(x) \to Q(x)), \forall xP(x) &\vdash
    (\forall x P(x)) \to (\forall y Q(y)) &\text{ by } (\forall +, 5) \\
    \forall x (P(x) \to Q(x)) &\vdash (\forall x P(x)) \to (\forall y Q(y))
\end{derivation}
\subsection*{Example 4}
Prove
\[
    \exists x (P(x) \lor Q(x)) \vdash
    (\exists xP(x)) \lor (\exists xQ(x))
.\] 
\subsubsection*{Answer}

\begin{derivation}
    P(u) &\vdash \exists P(u) &\text{ by } (\in) \\
    Q(u) &\vdash \exists Q(u) &\text{ by } (\in) \\
    P(u) &\vdash \exists xP(x) &\text{ by } (\exists +, 1) \\
    P(u) &\vdash \exists xP(x) &\text{ by } (\exists +, 0) \\
    Q(u) &\vdash \exists xQ(x) \\
    P(u) &\vdash (\exists x P(x)) \lor (\exists  x Q(x)) \\
    Q(u) &\vdash (\exists x P(x)) \lor (\exists  x Q(x)) \\
    (P(u) \lor Q(u)) &\vdash
    (\exists xP(x)) \lor (\exists xQ(x)) &\text { by } (\forall -, \\
    \exists x (P(x) \lor Q(x)) &\vdash
    (\exists xP(x)) \lor (\exists xQ(x)) &\text { by } (\exists -,
\end{derivation}
\end{document}

在此处输入图片描述

相关内容