3

When writing a proof, I often need to include a claim, for which I've defined a separate environment. In my current set up, claims are numbered successively, with the numbering resetting within every proof. This is achieved by the following code in my preamble:

\newcounter{proofcount} 
\newtheorem{claim}{Claim}
\makeatletter
\@addtoreset{claim}{proofcount}
\makeatother


\AtBeginEnvironment{proof}{\stepcounter{proofcount}}
\theoremstyle{remark}

\makeatletter
\newtheorem*{cproof/}{Proof of claim \rev@cproofmark}

\newenvironment{cproof}[1][\@nil]
  {\def\@tmp{#1}%
   \ifx\@tmp\@nnil
       \def\rev@cproofmark{\theclaim}%
    \else
       \let\rev@cproofmark\@tmp
    \fi
   \renewcommand{\qedsymbol}{$\dashv$}%
   \pushQED{\qed}\begin{cproof/}}
  {\popQED\end{cproof/}}

\makeatother

Now, if there is only one proof in my claim, the above renders said claim as "Claim 1", which looks (to me) strange; I'd rather it just say "Claim". Of course, I could achieve this by having a separate environment for unnumbered claims, and use that when my proof only requires a single claim, but I was wondering if there's a way of automating the process? That is, have a single claim environment such that, within each proof, if there's only one claim, the claim is not numbered, and if there's more than one, they're numbered Claim 1, Claim 2, etc.

To clarify, if I write something like:

\begin{proof}
Proof starts.
\begin{claim}
This is a claim.
\end{claim}
\begin{cproof}
This is the proof the claim.
\end{cproof}
Main proof continues.
\end{proof}

\begin{proof}
Proof starts.
\begin{claim}
This is a claim.
\end{claim}
Proof continues.
\begin{cproof}
This is the proof the claim.
\end{cproof}
Main proof continues.
\begin{claim}
This is a claim.
\end{claim}
\begin{cproof}
This is the proof the claim.
\end{cproof}
Main proof continues.
\end{proof}

I get:

enter image description here

I would like "Claim 1" in the first proof to appear as "Claim". I can achieve this by having a different environment for unnumbered claims in my preamble, but I was wondering if there's a way of automating this and only using one environment.

2
  • 1
    Please, provide a MWE. Your question is not clear, at least not to me. Are there multiple proofs inside the same claim? Or each claim has one proof and you just care about suppressing the numbering if there's just one claim?
    – nickie
    Aug 10, 2022 at 9:41
  • @nickie My apologies, I thought it was clear. There can be multiple claims inside the same proof, or just one claim. If there is only one claim, I'd like it to not be numbered. I've added a MWE, please let me know if there's anything else I can add to further clarify the question.
    – Reveillark
    Aug 10, 2022 at 14:26

1 Answer 1

1

As the number of claims in a proof will only be known when the proof environment is closed, and this may happen many pages after the point where the first claim is defined, suppressing the numbering of single claims is not so easy. The following solution stores the number of claims in each proof to the .aux file. You may need to rerun LaTeX to get the numbering right (as the warning will say).

\documentclass[11pt]{article}
\usepackage{etoolbox}
\usepackage{amsthm}
\usepackage{xspace}

\newcounter{proofcount}
\newtheorem{claimn}{Claim}
\newtheorem*{claimx}{Claim}
\makeatletter
\@addtoreset{claimn}{proofcount}
\makeatother

\makeatletter
\newif\if@claim@numbered
\newif\if@claim@rerun
\AtBeginEnvironment{proof}{%
  \stepcounter{proofcount}%
  \global\@claim@numberedtrue%
  \ifcsdef{proof\theproofcount}{%
    \ifnum\csuse{proof\theproofcount}=1\global\@claim@numberedfalse\fi%
  }{}%
}
\AtEndEnvironment{proof}{%
  \ifcsdef{proof\theproofcount}{%
    \ifnum\csuse{proof\theproofcount}=\theclaimn\else
    \global\@claim@reruntrue%
    \fi%
  }{\global\@claim@reruntrue}%
  \immediate\write\@auxout{%
    \string\csgdef{proof\theproofcount}{\theclaimn}}%
}
\newenvironment{claim}{%
  \if@claim@numbered\claimn\else\stepcounter{claimn}\claimx\fi%
}{%
  \if@claim@numbered\endclaimn\else\endclaimx\fi%
}
\AtEndDocument{%
  \if@claim@rerun
  \@latex@warning@no@line{Claim numbering may have changed.
    Rerun to get it right}%
  \fi
}
\makeatother
\theoremstyle{remark}

\makeatletter
\newtheorem*{cproof/}{Proof of claim\xspace\rev@cproofmark}

\newenvironment{cproof}[1][\@nil]
  {\def\@tmp{#1}%
   \ifx\@tmp\@nnil
     \if@claim@numbered
     \def\rev@cproofmark{\theclaimn}%
     \else
     \def\rev@cproofmark{}%
     \fi%
   \else
     \let\rev@cproofmark\@tmp
   \fi
   \renewcommand{\qedsymbol}{$\dashv$}%
   \pushQED{\qed}\begin{cproof/}}
  {\popQED\end{cproof/}}

\makeatother
\parindent 0pt

\begin{document}

\begin{proof}
The first proof starts, it only has one claim.
\begin{claim}
This is the single claim.
\end{claim}
\begin{cproof}
This is the proof of the single claim.
\end{cproof}
Main proof continues.
\end{proof}

\begin{proof}
The second proof starts, it has more claims.
\begin{claim}
This is the first claim.
\end{claim}
Proof continues.
\begin{cproof}
This is the proof of the first claim.
\end{cproof}
Main proof continues.
\begin{claim}
This is the second claim.
\end{claim}
\begin{cproof}
This is the proof of the second claim.
\end{cproof}
Main proof continues.
\end{proof}

\end{document}

The result is this: result

1
  • This had solved my problem, but I'm now randomly getting a "Label `' multiply defined" warning in the output. Alas, I suppose I'll go back to numbering things by hand :(
    – Reveillark
    Sep 10, 2022 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .