Simplify lean link formatting.

finite-set-exercises
Joshua Potter 2023-08-09 07:39:41 -06:00
parent e8aa984b98
commit d89200fd9d
7 changed files with 7804 additions and 8426 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,8 @@
\hyperlabel{ref:construction-sequence} \hyperlabel{ref:construction-sequence}
A \textbf{construction sequence} is a finite sequence A \textbf{construction sequence} is a finite sequence
$\langle \epsilon_1, \ldots, \epsilon_n \rangle$ of expressions such that for $\langle \epsilon_1, \ldots, \epsilon_n \rangle$ of expressions such that
each $i \leq n$ we have at least one of for each $i \leq n$ we have at least one of
\begin{align*} \begin{align*}
& \epsilon_i \text{ is a sentence symbol} \\ & \epsilon_i \text{ is a sentence symbol} \\
& \epsilon_i = \mathcal{E}_\neg(\epsilon_j) \text{ for some } j < i \\ & \epsilon_i = \mathcal{E}_\neg(\epsilon_j) \text{ for some } j < i \\
@ -39,8 +39,9 @@ An \textbf{expression} is a finite sequence of symbols.
\hyperlabel{ref:well-formed-formula} \hyperlabel{ref:well-formed-formula}
An \nameref{ref:expression} that can be built up from the sentence symbols by An \nameref{ref:expression} that can be built up from the sentence symbols by
applying some finite number of times the \textbf{formula-building operations} applying some finite number of times the
(on expressions) defined by the equations: \textbf{formula-building operations} (on expressions) defined by the
equations:
\begin{align*} \begin{align*}
\mathcal{E}_{\neg}(\alpha) \mathcal{E}_{\neg}(\alpha)
& = (\neg \alpha) \\ & = (\neg \alpha) \\
@ -66,17 +67,13 @@ An \nameref{ref:expression} that can be built up from the sentence symbols by
\hyperlabel{sec:lemma-0a} \hyperlabel{sec:lemma-0a}
\begin{lemma}[0A] \begin{lemma}[0A]
Assume that $\langle x_1, \ldots, x_m \rangle = Assume that $\langle x_1, \ldots, x_m \rangle =
\langle y_1, \ldots, y_m, \ldots, y_{m+k} \rangle$. \langle y_1, \ldots, y_m, \ldots, y_{m+k} \rangle$.
Then $x_1 = \langle y_1, \ldots, y_{k+1} \rangle$. Then $x_1 = \langle y_1, \ldots, y_{k+1} \rangle$.
\end{lemma} \end{lemma}
\begin{proof} \begin{proof}
TODO TODO
\end{proof} \end{proof}
\chapter{Sentential Logic}% \chapter{Sentential Logic}%
@ -89,16 +86,13 @@ Then $x_1 = \langle y_1, \ldots, y_{k+1} \rangle$.
\hyperlabel{sub:induction-principle-1} \hyperlabel{sub:induction-principle-1}
\begin{theorem} \begin{theorem}
If $S$ is a set of wffs containing all the sentence symbols and closed under
If $S$ is a set of wffs containing all the sentence symbols and closed under all all five formula-building operations, then $S$ is the set of \textit{all}
five formula-building operations, then $S$ is the set of \textit{all} wffs. wffs.
\end{theorem} \end{theorem}
\begin{proof} \begin{proof}
TODO TODO
\end{proof} \end{proof}
\section{Exercises 1}% \section{Exercises 1}%
@ -113,9 +107,7 @@ The sentences shoudl be chosen so as to have an interesting structure, and the
translations should each contain 15 or more symbols. translations should each contain 15 or more symbols.
\begin{answer} \begin{answer}
TODO TODO
\end{answer} \end{answer}
\subsection{\sorry{Exercise 1.1.2}}% \subsection{\sorry{Exercise 1.1.2}}%
@ -124,11 +116,9 @@ The sentences shoudl be chosen so as to have an interesting structure, and the
Show that there are no wffs of length 2, 3, or 6, but that any other positive Show that there are no wffs of length 2, 3, or 6, but that any other positive
length is possible. length is possible.
\begin{answer} \begin{proof}
TODO TODO
\end{proof}
\end{answer}
\subsection{\sorry{Exercise 1.1.3}}% \subsection{\sorry{Exercise 1.1.3}}%
\hyperlabel{sub:exercise-1.1.3} \hyperlabel{sub:exercise-1.1.3}
@ -137,29 +127,26 @@ Let $\alpha$ be a wff; let $c$ be the number of places at which binary
connective symbols $(\land, \lor, \Rightarrow, \Leftrightarrow)$ occur in connective symbols $(\land, \lor, \Rightarrow, \Leftrightarrow)$ occur in
$\alpha$; let $s$ be the number of places at which sentence symbols occur in $\alpha$; let $s$ be the number of places at which sentence symbols occur in
$\alpha$. $\alpha$.
(For exmaple, if $\alpha$ is $(A \Rightarrow (\neg A))$ then $c = 1$ and $s = 2$.) (For example, if $\alpha$ is $(A \Rightarrow (\neg A))$ then $c = 1$ and
$s = 2$.)
Show by using the induction principle that $s = c + 1$. Show by using the induction principle that $s = c + 1$.
\begin{answer} \begin{proof}
TODO TODO
\end{proof}
\end{answer}
\subsection{\sorry{Exercise 1.1.4}}% \subsection{\sorry{Exercise 1.1.4}}%
\hyperlabel{sub:exercise-1.1.4} \hyperlabel{sub:exercise-1.1.4}
Assume we have a construction sequence ending in $\phi$, where $\phi$ does not Assume we have a construction sequence ending in $\phi$, where $\phi$ does not
contain the symbol $A_4$. contain the symbol $A_4$.
Suppose we delete all the expressions in the construction sequence that contain Suppose we delete all the expressions in the construction sequence that
$A_4$. contain $A_4$.
Show that the result is still a legal construction sequence. Show that the result is still a legal construction sequence.
\begin{answer} \begin{proof}
TODO TODO
\end{proof}
\end{answer}
\subsection{\sorry{Exercise 1.1.5}}% \subsection{\sorry{Exercise 1.1.5}}%
\hyperlabel{sub:exercise-1.1.5} \hyperlabel{sub:exercise-1.1.5}
@ -173,11 +160,9 @@ Suppose that $\alpha$ is a wff not containing the negation symbol $\neg$.
\textit{Suggestion}: Apply induction to show that the length is of the form \textit{Suggestion}: Apply induction to show that the length is of the form
$4k + 1$ and the number of sentence symbols is $k + 1$. $4k + 1$ and the number of sentence symbols is $k + 1$.
\begin{answer} \begin{proof}
TODO TODO
\end{proof}
\end{answer}
\subsection{\sorry{Exercise 1.1.6}}% \subsection{\sorry{Exercise 1.1.6}}%
\hyperlabel{sub:exercise-1.1.6} \hyperlabel{sub:exercise-1.1.6}
@ -189,10 +174,8 @@ Suppose that $\alpha$ is a wff not containing the negation symbol $\neg$.
\item Show that more than a quarter of the symbols are sentence symbols. \item Show that more than a quarter of the symbols are sentence symbols.
\end{enumerate} \end{enumerate}
\begin{answer} \begin{proof}
TODO TODO
\end{proof}
\end{answer}
\end{document} \end{document}

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,153 @@ theorem commutative_law_ii (A B : Set α)
exact and_comm exact and_comm
_ = B ∩ A := rfl _ = B ∩ A := rfl
/-! #### Associative Laws
For any sets `A`, `B`, and `C`,
```
A (B C) = (A B) C
A ∩ (B ∩ C) = (A ∩ B) ∩ C
```
-/
#check Set.union_assoc
theorem associative_law_i (A B C : Set α)
: A (B C) = (A B) C := calc A (B C)
_ = { x | x ∈ A x ∈ B C } := rfl
_ = { x | x ∈ A (x ∈ B x ∈ C) } := rfl
_ = { x | (x ∈ A x ∈ B) x ∈ C } := by
ext _
simp only [Set.mem_setOf_eq]
rw [← or_assoc]
_ = { x | x ∈ A B x ∈ C } := rfl
_ = (A B) C := rfl
#check Set.inter_assoc
theorem associative_law_ii (A B C : Set α)
: A ∩ (B ∩ C) = (A ∩ B) ∩ C := calc A ∩ (B ∩ C)
_ = { x | x ∈ A ∧ (x ∈ B ∩ C) } := rfl
_ = { x | x ∈ A ∧ (x ∈ B ∧ x ∈ C) } := rfl
_ = { x | (x ∈ A ∧ x ∈ B) ∧ x ∈ C } := by
ext _
simp only [Set.mem_setOf_eq]
rw [← and_assoc]
_ = { x | x ∈ A ∩ B ∧ x ∈ C } := rfl
_ = (A ∩ B) ∩ C := rfl
/-! #### Distributive Laws
For any sets `A`, `B`, and `C`,
```
A ∩ (B C) = (A ∩ B) (A ∩ C)
A (B ∩ C) = (A B) ∩ (A C)
```
-/
#check Set.inter_distrib_left
theorem distributive_law_i (A B C : Set α)
: A ∩ (B C) = (A ∩ B) (A ∩ C) := calc A ∩ (B C)
_ = { x | x ∈ A ∧ x ∈ B C } := rfl
_ = { x | x ∈ A ∧ (x ∈ B x ∈ C) } := rfl
_ = { x | (x ∈ A ∧ x ∈ B) (x ∈ A ∧ x ∈ C) } := by
ext _
exact and_or_left
_ = { x | x ∈ A ∩ B x ∈ A ∩ C } := rfl
_ = (A ∩ B) (A ∩ C) := rfl
#check Set.union_distrib_left
theorem distributive_law_ii (A B C : Set α)
: A (B ∩ C) = (A B) ∩ (A C) := calc A (B ∩ C)
_ = { x | x ∈ A x ∈ B ∩ C } := rfl
_ = { x | x ∈ A (x ∈ B ∧ x ∈ C) } := rfl
_ = { x | (x ∈ A x ∈ B) ∧ (x ∈ A x ∈ C) } := by
ext _
exact or_and_left
_ = { x | x ∈ A B ∧ x ∈ A C } := rfl
_ = (A B) ∩ (A C) := rfl
/-! #### De Morgan's Laws
For any sets `A`, `B`, and `C`,
```
C - (A B) = (C - A) ∩ (C - B)
C - (A ∩ B) = (C - A) (C - B)
```
-/
#check Set.diff_inter_diff
theorem de_morgans_law_i (A B C : Set α)
: C \ (A B) = (C \ A) ∩ (C \ B) := calc C \ (A B)
_ = { x | x ∈ C ∧ x ∉ A B } := rfl
_ = { x | x ∈ C ∧ ¬(x ∈ A x ∈ B) } := rfl
_ = { x | x ∈ C ∧ (x ∉ A ∧ x ∉ B) } := by
ext _
simp only [Set.mem_setOf_eq]
rw [not_or_de_morgan]
_ = { x | (x ∈ C ∧ x ∉ A) ∧ (x ∈ C ∧ x ∉ B) } := by
ext _
exact and_and_left
_ = { x | x ∈ C \ A ∧ x ∈ C \ B } := rfl
_ = (C \ A) ∩ (C \ B) := rfl
#check Set.diff_inter
theorem de_morgans_law_ii (A B C : Set α)
: C \ (A ∩ B) = (C \ A) (C \ B) := calc C \ (A ∩ B)
_ = { x | x ∈ C ∧ x ∉ A ∩ B } := rfl
_ = { x | x ∈ C ∧ ¬(x ∈ A ∧ x ∈ B) } := rfl
_ = { x | x ∈ C ∧ (x ∉ A x ∉ B) } := by
ext _
simp only [Set.mem_setOf_eq]
rw [not_and_de_morgan]
_ = { x | (x ∈ C ∧ x ∉ A) (x ∈ C ∧ x ∉ B) } := by
ext _
exact and_or_left
_ = { x | x ∈ C \ A x ∈ C \ B } := rfl
_ = (C \ A) (C \ B) := rfl
/-! #### Identities Involving ∅
For any set `A`,
```
A ∅ = A
A ∩ ∅ = ∅
A ∩ (C - A) = ∅
```
-/
#check Set.union_empty
theorem emptyset_identity_i (A : Set α)
: A ∅ = A := calc A
_ = { x | x ∈ A x ∈ ∅ } := rfl
_ = { x | x ∈ A False } := rfl
_ = { x | x ∈ A } := by simp
_ = A := rfl
#check Set.inter_empty
theorem emptyset_identity_ii (A : Set α)
: A ∩ ∅ = ∅ := calc A ∩ ∅
_ = { x | x ∈ A ∧ x ∈ ∅ } := rfl
_ = { x | x ∈ A ∧ False } := rfl
_ = { x | False } := by simp
_ = ∅ := rfl
#check Set.inter_diff_self
theorem emptyset_identity_iii (A C : Set α)
: A ∩ (C \ A) = ∅ := calc A ∩ (C \ A)
_ = { x | x ∈ A ∧ x ∈ C \ A } := rfl
_ = { x | x ∈ A ∧ (x ∈ C ∧ x ∉ A) } := rfl
_ = { x | x ∈ C ∧ False } := by simp
_ = { x | False } := by simp
_ = ∅ := rfl
/-- #### Exercise 2.1 /-- #### Exercise 2.1
Assume that `A` is the set of integers divisible by `4`. Similarly assume that Assume that `A` is the set of integers divisible by `4`. Similarly assume that

View File

@ -19,7 +19,7 @@ namespace Enderton.Set.Chapter_3
If `x ∈ C` and `y ∈ C`, then `⟨x, y⟩ ∈ 𝒫 𝒫 C`. If `x ∈ C` and `y ∈ C`, then `⟨x, y⟩ ∈ 𝒫 𝒫 C`.
-/ -/
theorem theorem_3b {C : Set α} (hx : x ∈ C) (hy : y ∈ C) theorem lemma_3b {C : Set α} (hx : x ∈ C) (hy : y ∈ C)
: OrderedPair x y ∈ 𝒫 𝒫 C := by : OrderedPair x y ∈ 𝒫 𝒫 C := by
have hxs : {x} ⊆ C := Set.singleton_subset_iff.mpr hx have hxs : {x} ⊆ C := Set.singleton_subset_iff.mpr hx
have hxys : {x, y} ⊆ C := Set.mem_mem_imp_pair_subset hx hy have hxys : {x, y} ⊆ C := Set.mem_mem_imp_pair_subset hx hy

View File

@ -22,11 +22,11 @@ Let $(a_i)_{i \geq 0}$ be an arithmetic sequence with common difference $d$.
\sum_{i=0}^n a_i = \frac{(n + 1)(a_0 + a_n)}{2}. \sum_{i=0}^n a_i = \frac{(n + 1)(a_0 + a_n)}{2}.
\end{equation} \end{equation}
\begin{proof}
\code{Common/Real/Sequence/Arithmetic} \code{Common/Real/Sequence/Arithmetic}
{Real.Arithmetic.sum\_recursive\_closed} {Real.Arithmetic.sum\_recursive\_closed}
\begin{proof}
Let $(a_i)_{i \geq 0}$ be an arithmetic sequence with common difference $d$. Let $(a_i)_{i \geq 0}$ be an arithmetic sequence with common difference $d$.
By definition, for all $k \in \mathbb{N}$, By definition, for all $k \in \mathbb{N}$,
\begin{equation} \begin{equation}
@ -82,11 +82,11 @@ Let $(a_i)_{i \geq 0}$ be a geometric sequence with common ratio $r \neq 1$.
\sum_{i=0}^n a_i = \frac{a_0(1 - r^{n+1})}{1 - r}. \sum_{i=0}^n a_i = \frac{a_0(1 - r^{n+1})}{1 - r}.
\end{equation} \end{equation}
\begin{proof}
\code{Common/Real/Sequence/Geometric} \code{Common/Real/Sequence/Geometric}
{Real.Geometric.sum\_recursive\_closed} {Real.Geometric.sum\_recursive\_closed}
\begin{proof}
Let $(a_i)_{i \geq 0}$ be a geometric sequence with common ratio $r \neq 1$. Let $(a_i)_{i \geq 0}$ be a geometric sequence with common ratio $r \neq 1$.
By definition, for all $k \in \mathbb{N}$, By definition, for all $k \in \mathbb{N}$,
\begin{equation} \begin{equation}

View File

@ -44,61 +44,47 @@
\label{#1}% \label{#1}%
\hypertarget{#1}{}} \hypertarget{#1}{}}
% Denote whether we are working with a standard/Mathlib statement (lean) or a % Denote if working with a predefined statement/theorem or a custom one.
% custom one (code).
\newcommand\@leanlink[4]{% \newcommand\@leanlink[4]{%
\textcolor{blue}{\raisebox{-4.5pt}{% \textcolor{BlueViolet}{\raisebox{-4.5pt}{%
\tikz{\draw (0, 0) node[yscale=-1,xscale=1] {\faFont};}}}% \tikz{\draw (0, 0) node[yscale=-1,xscale=1] {\faFont};}}{-\;}}%
{-\;}\href{#1/#2.html\##3}{#4}} \href{#1/#2.html\##3}{\color{BlueViolet}{#4}}}
\newcommand\@codelink[4]{% \newcommand\@codelink[4]{%
\textcolor{blue}{\raisebox{-4.5pt}{% \textcolor{MidnightBlue}{\raisebox{-4.5pt}{%
\tikz{\draw (0, 0) node[] {\faCodeBranch};}}}% \tikz{\draw (0, 0) node[xshift=8pt] {\faCodeBranch};}}{-\;}}%
{-\;}\href{#1/#2.html\##3}{#4}} \href{#1/#2.html\##3}{\color{MidnightBlue}{#4}}}
% Reference to an anchor of Lean documentation. % Reference to an anchor of generated Lean documentation.
\newcommand\leanref[3]{% \newcommand\leanref[3]{%
\@leanlink{#1}{#2}{#3}{#3}\vspace{10pt}}
\WithSuffix\newcommand\leanref*[3]{%
\@leanlink{#1}{#2}{#3}{#3}} \@leanlink{#1}{#2}{#3}{#3}}
\newcommand\coderef[3]{% \newcommand\coderef[3]{%
\@codelink{#1}{#2}{#3}{#3}\vspace{10pt}}
\WithSuffix\newcommand\coderef*[3]{%
\@codelink{#1}{#2}{#3}{#3}} \@codelink{#1}{#2}{#3}{#3}}
% Variants that allows customizing display text.
\newcommand\leanpref[4]{% \newcommand\leanpref[4]{%
\@leanlink{#1}{#2}{#3}{#4}\vspace{10pt}}
\WithSuffix\newcommand\leanpref*[4]{%
\@leanlink{#1}{#2}{#3}{#4}} \@leanlink{#1}{#2}{#3}{#4}}
\newcommand\codepref[4]{% \newcommand\codepref[4]{%
\@codelink{#1}{#2}{#3}{#4}\vspace{10pt}}
\WithSuffix\newcommand\codepref*[4]{%
\@codelink{#1}{#2}{#3}{#4}} \@codelink{#1}{#2}{#3}{#4}}
% Macro to build all Lean related commands relative to a specified directory. % Macro to build all Lean related commands relative to a specified directory.
\newcommand\makeleancommands[1]{% \newcommand\makeleancommands[1]{%
\newcommand\lean[2]{% \newcommand\lean[2]{%
\leanref{#1}{##1}{##2}} \noindent\leanref{#1}{##1}{##2}}
\WithSuffix\newcommand\lean*[2]{% \WithSuffix\newcommand\lean*[2]{%
\leanref*{#1}{##1}{##2}} \vspace{6pt}\noindent\leanref{#1}{##1}{##2}}
\newcommand\code[2]{% \newcommand\code[2]{%
\coderef{#1}{##1}{##2}} \noindent\coderef{#1}{##1}{##2}}
\WithSuffix\newcommand\code*[2]{% \WithSuffix\newcommand\code*[2]{%
\coderef*{#1}{##1}{##2}} \vspace{6pt}\noindent\coderef{#1}{##1}{##2}}
\newcommand\leanp[3]{% \newcommand\leanp[3]{%
\leanpref{#1}{##1}{##2}{##3}} \noindent\leanpref{#1}{##1}{##2}{##3}}
\WithSuffix\newcommand\leanp*[3]{% \WithSuffix\newcommand\leanp*[3]{%
\leanpref*{#1}{##1}{##2}{##3}} \vspace{6pt}\noindent\leanpref{#1}{##1}{##2}{##3}}
\newcommand\codep[3]{% \newcommand\codep[3]{%
\codepref{#1}{##1}{##2}{##3}} \noindent\codepref{#1}{##1}{##2}{##3}}
\WithSuffix\newcommand\codep*[3]{% \WithSuffix\newcommand\codep*[3]{%
\codepref*{#1}{##1}{##2}{##3}} \vspace{6pt}\noindent\codepref{#1}{##1}{##2}{##3}}
} }
% ======================================== % ========================================
@ -124,11 +110,7 @@
\newcommand\@statement[1]{% \newcommand\@statement[1]{%
\linedivider*\paragraph{\normalfont\normalsize\textit{#1.}}} \linedivider*\paragraph{\normalfont\normalsize\textit{#1.}}}
\newcommand{\statementpadding}{\ \vspace{8pt}}
\newenvironment{answer}{\@statement{Answer}}{\hfill$\square$} \newenvironment{answer}{\@statement{Answer}}{\hfill$\square$}
\newenvironment{axiom}{\@statement{Axiom}}{\hfill$\square$}
\newenvironment{definition}{\@statement{Definition}}{\hfill$\square$}
\renewenvironment{proof}{\@statement{Proof}}{\hfill$\square$} \renewenvironment{proof}{\@statement{Proof}}{\hfill$\square$}
\newtheorem{corollaryinner}{Corollary} \newtheorem{corollaryinner}{Corollary}