TITLE: Is this proof correct? (natural deduction)
QUESTION [6 upvotes]: I'm working through The Science of Programming by David Gries. This question is #18 in section 3.3.
Prove $((P \land \lnot Q) \to Q) \to (P \to Q)$
Using the natural deduction system here is my proof.

$(P \land \lnot Q) \to Q)$ (premise)
From $P$ infer $Q$ (subproof)

2.1 $P$ (premise)
2.2 From $\lnot Q$ infer $Q$ (subproof)
2.2.1 $\lnot Q$ (premise)
2.2.2 $P \land \lnot Q$ ($\land$-Introduction, 2.1, 2.2.1)
2.2.3 $Q$ ($\to$-E, 1, 2.2.2)

$P \to Q$ ($\to$-I, 2)

Is this correct? I feel like I'm really stretching in trying to prove $P\to Q$ especially with the subproof of $\lnot Q \to Q$.

REPLY [6 votes]: I would do it slightly differently, but as always people use somewhat different systems for natural deduction.

Begin


1) $(P \land \lnot Q) \rightarrow Q$ (ass.)


2) $P$ (ass.)


3) $\lnot Q$ (ass.)
4) $(P \land \lnot Q)$ introduction $\lnot$ from 2,3.
5) $Q$ (modus ponens from 1. and 4.)
6) $\bot$ from $5$ and $3$. 

7) $\lnot \lnot Q$ (from introduction $\lnot$ and 3, 6, we drop 3).
8) $Q$ (double negation rule).

9) $P \rightarrow Q$ (from 2,8 and introduction $\to$); we drop 2.

10) $((P \land \lnot Q) \to Q)\to (P \to Q)$ (intro $\to$ 1, 9) we drop 1.

Done.

REPLY [5 votes]: $\def\fitch#1#2{\begin{array}{|l}#1\\\hline#2\end{array}}$
Can you use the Law of Excluded Middle?
$$\fitch{}{\fitch{(P\land\lnot Q)\to Q}{\fitch{P}{\left.\raise{5ex}{Q\vee\lnot Q\\\fitch{Q}{Q}\\Q\to Q}\right\}&\text{add this}\\\fitch{\lnot Q}{P\wedge\lnot Q\\ Q}\\\lnot Q \to Q\\Q}\\P\to Q}\\((P\land\lnot Q)\to Q )\to(P\to Q)}$$
Else there is the double negation path.
$$\fitch{}{\fitch{(P\land\lnot Q)\to Q}{\fitch{P}{\fitch{\lnot Q}{P\wedge\lnot Q\\ Q\\\bot}\\\lnot\lnot Q \\Q }\\P\to Q}\\((P\land\lnot Q)\to Q )\to(P\to Q)}$$
If the falsum symbol is not accepted this can be modified to introduce negation via $X\to\neg Y, X\to Y\vdash \neg X$
$$\fitch{}{\fitch{(P\land\lnot Q)\to Q}{\fitch{P}{\fitch{\lnot Q}{\neg Q}\\\lnot Q\to\lnot Q\\\fitch{\lnot Q}{P\wedge\lnot Q\\ Q}\\\neg Q\to Q\\\lnot\lnot Q \\Q }\\P\to Q}\\((P\land\lnot Q)\to Q )\to(P\to Q)}$$
I'll leave the justifications to you.

REPLY [4 votes]: Your attempt of derivation is wrong because in your subproof 2 you can't have the hypothesis $\lnot Q$, you are just assuming that $(P \land \lnot Q) \to Q$.
I think $((P \land \lnot Q) \to Q) \to (P \to Q)$ is provable only in classical logic, not in weaker logics such as the intuitionistic one. For instance, you can use the Law of Excluded Middle (or some equivalent formula provable only in classical logic) in your derivation in natural deduction:
\begin{align}
\dfrac{\dfrac{\dfrac{Q \lor \lnot Q \qquad [Q]^1 \qquad \dfrac{[(P \land \lnot Q) \to Q]^3 \qquad \dfrac{[P]^2 \qquad [\lnot Q]^1}{P \land \lnot Q}\land_i}{Q}\to_e}{Q}\lor_e^1}{P\to Q}\to_i^2}{((P \land \lnot Q) \to Q) \to (P  \to Q)}\to_i^3
\end{align}
where the Law of Excluded Middle $Q \lor \lnot Q$ is provable in classical natural deduction as follows:
\begin{align}
\dfrac{\dfrac{[\lnot (Q \lor \lnot Q)]^2 \qquad \dfrac{\dfrac{\dfrac{[\lnot (Q \lor \lnot Q)]^2 \qquad \dfrac{[Q]^1}{Q \lor \lnot Q}\lor_{i_L}}{\bot}}{\lnot Q}\lnot_i^1}{Q \lor \lnot Q}\lor_{i_R}}{\bot}\lnot_e}{Q \lor \lnot Q}\text{raa}^2
\end{align}