|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
% (find-LATEX "2026-set-comprehensions.tex")
% (defun c () (interactive) (find-LATEXsh "lualatex -record 2026-set-comprehensions.tex" :end))
% (defun C () (interactive) (find-LATEXsh "lualatex 2026-set-comprehensions.tex" "Success!!!"))
% (defun D () (interactive) (find-pdf-page "~/LATEX/2026-set-comprehensions.pdf"))
% (defun d () (interactive) (find-pdftools-page "~/LATEX/2026-set-comprehensions.pdf"))
% (defun e () (interactive) (find-LATEX "2026-set-comprehensions.tex"))
% (defun o () (interactive) (find-LATEX "2025bad-foundations.tex"))
% (defun u () (interactive) (find-latex-upload-links "2026-set-comprehensions"))
% (defun v () (interactive) (find-2a '(e) '(d)))
% (defun d0 () (interactive) (find-ebuffer "2026-set-comprehensions.pdf"))
% (defun cv () (interactive) (C) (ee-kill-this-buffer) (v) (g))
% (defun oe () (interactive) (find-2a '(o) '(e)))
% (code-eec-LATEX "2026-set-comprehensions")
% (find-pdf-page "~/LATEX/2026-set-comprehensions.pdf")
% (find-sh0 "cp -v ~/LATEX/2026-set-comprehensions.pdf /tmp/")
% (find-sh0 "cp -v ~/LATEX/2026-set-comprehensions.pdf /tmp/pen/")
% (find-xournalpp "/tmp/2026-set-comprehensions.pdf")
% file:///home/edrx/LATEX/2026-set-comprehensions.pdf
% file:///tmp/2026-set-comprehensions.pdf
% file:///tmp/pen/2026-set-comprehensions.pdf
% http://anggtwu.net/LATEX/2026-set-comprehensions.pdf
% (find-LATEX "2019.mk")
% (find-Deps1-links "Caepro5 Piecewise2 Maxima2")
% (find-Deps1-cps "Caepro5 Piecewise2 Maxima2")
% (find-Deps1-cps "Caepro5 Piecewise2 Maxima2 Verbatim3")
% (find-Deps1-anggs "Caepro5 Piecewise2 Maxima2")
% (find-MM-aula-links "2026-set-comprehensions" "2" "2026setcompr" "nsc")
% «.geometry» (to "geometry")
% «.edrx26a» (to "edrx26a")
% «.biber» (to "biber")
% «.edrx26b» (to "edrx26b")
% «.edrx26c» (to "edrx26c")
%
% «.defs» (to "defs")
% «.footer» (to "footer")
% «.defs-comprehensions» (to "defs-comprehensions")
% «.title» (to "title")
% «.introduction» (to "introduction")
% «.exercises» (to "exercises")
% «.answers» (to "answers")
% «.maxima» (to "maxima")
% «.haskell» (to "haskell")
% «.lua» (to "lua")
% «.hypotheses» (to "hypotheses")
% «.venn-diagrams» (to "venn-diagrams")
% «.propositions» (to "propositions")
% «.references» (to "references")
% «.write-dnt-file» (to "write-dnt-file")
% «.make-with-bib» (to "make-with-bib")
%newpage %-- defs
\documentclass[oneside,12pt]{article}
\usepackage[colorlinks,citecolor=DarkRed,urlcolor=DarkRed]{hyperref} % (find-es "tex" "hyperref")
\usepackage[x11names,svgnames]{xcolor} % (find-es "tex" "xcolor")
\usepackage{colorweb} % (find-es "tex" "colorweb")
\usepackage{indentfirst} % (find-es "tex" "indentfirst")
%\usepackage{tikz}
%
% (find-LATEX "dednat7-test1.tex")
%\usepackage{proof} % For derivation trees ("%:" lines)
%\input diagxy % For 2D diagrams ("%D" lines)
%\xyoption{curve} % For the ".curve=" feature in 2D diagrams
%
% «geometry» (to ".geometry")
% (find-es "tex" "geometry")
\usepackage[a4paper%, landscape,
%top=1.5cm, bottom=.25cm, left=1cm, right=1cm, includefoot
]{geometry}
%
% «edrx26a» (to ".edrx26a")
\usepackage{edrx26a} % (find-LATEX "edrx26a.sty")
%
% «biber» (to ".biber")
\usepackage[backend=biber,
style=alphabetic]{biblatex} % (find-es "tex" "biber")
\addbibresource{catsem-ab.bib} % (find-LATEX "catsem-ab.bib")
\addbibresource{education.bib} % (find-LATEX "education.bib")
%
\begin{document}
% «edrx26b» (to ".edrx26b")
\input edrx26b.tex % (find-LATEX "edrx26b.tex")
% «edrx26c» (to ".edrx26c")
% (find-LATEX "edrx26c.tex")
%L processsubfile "edrx26c.tex" -- runs the "%L"s
\input edrx26c % loads the defs
% «defs» (to ".defs")
% (find-LATEX "edrx21defs.tex" "colors")
% (find-LATEX "edrx21.sty")
% «footer» (to ".footer")
% (find-LATEX "edrxheadfoot.tex")
\def\drafturl{http://anggtwu.net/LATEX/2025-2-C2.pdf}
\def\drafturl{http://anggtwu.net/2025.2-C2.html}
\def\draftfooter{\tiny \href{\drafturl}{\jobname{}} \ColorBrown{\shorttoday{} \hours}}
% (find-LATEX "2024-1-C2-carro.tex" "defs-caepro")
% (find-LATEX "2024-1-C2-carro.tex" "defs-pict2e")
% «2026-defs» (to ".2026-defs")
% (find-LATEX "2026-defs.tex")
%%L processsubfile "2026-defs.tex" -- runs the "%L"s
%\input 2026-defs % loads the defs
%L require "Numerozinhos1" -- (find-angg "LUA/Numerozinhos1.lua")
\pu
% «defs-comprehensions» (to ".defs-comprehensions")
% (find-processsubfile-links "2026defs-comprehensions")
% (find-LATEX "2026defs-comprehensions.tex")
%L processsubfile "2026defs-comprehensions.tex" -- runs the "%L"s
\input 2026defs-comprehensions % loads the defs
\pu
\def\comprehensionbox#1{\ensuremath{\sm{#1}}}
\def\comprehensionbox#1{\ensuremath{\mat{#1}}}
\def\comprehensionbox#1{\ensuremath{\fbox{\sm{#1}}}}
\def\comprehensionbox#1{\fbox{\ensuremath{\mat{#1}}}}
\def\comprehensionbox#1{\fbox{\ensuremath{\sm{#1}}}}
\def\comprehensionbox#1{\vbtbgbox{\ensuremath{\mat{#1}}}}
\def\V{\mathbf{V}}
\def\F{\mathbf{F}}
\def\Stop{\omit\vrule\phantom{$\scriptstyle($}\hss}
\def\Stop{\omit|\hss}
\def\HLine{\hline\\[0pt]}
\def\HLine{\hline}
% (bafa "defs-comprehensions")
% For: (find-angg "LUA/Comprehensions1.lua" "Comprehension-tests")
% ;-- title
% _____ _ _ _
% |_ _(_) |_| | ___ _ __ __ _ __ _ ___
% | | | | __| |/ _ \ | '_ \ / _` |/ _` |/ _ \
% | | | | |_| | __/ | |_) | (_| | (_| | __/
% |_| |_|\__|_|\___| | .__/ \__,_|\__, |\___|
% |_| |___/
%
% «title» (to ".title")
% (2026setcomprp 1 "title")
% (2026setcompra "title")
\title{Notes on Set Comprehensions}
\author{%
Eduardo Ochs%
%{\large Eduardo Ochs}%
\thanks{eduardoochs@gmail.com}\\
%{\small UFF, Rio das Ostras, RJ, Brasil}\\
}
\maketitle
% ;-- comprehensions-links
% «comprehensions-links» (to ".comprehensions-links")
% (bafp 12 "comprehensions-links")
% (bafa "comprehensions-links")
% (mpgp 8 "comprehension")
% (mpga "comprehension")
% \picturedots(0,0)(3,4){ 1,4 2,4 1,3 }
% ;-- comprehensions
% «comprehensions» (to ".comprehensions")
% (bafp 12 "comprehensions")
% (bafa "comprehensions")
WARNING: this is an attempt to join in a single PDF file many of my
notes on set comprehensions, including some that were written in
Portuguese, and that I need to translate to English... but this is
currently a mess!
\msk
URL of the current/latest version:
\par
% https://anggtwu.net/LATEX/2026-set-comprehensions.pdf
\url{https://anggtwu.net/LATEX/2026-set-comprehensions.pdf}
\msk
These notes are mentioned here:
% (bafp 6 "set-comprehensions")
% (bafa "set-comprehensions")
% (bafa "set-comprehensions" "OchsNSC2026")
\par
% https://anggtwu.net/LATEX/2026bad-foundations.pdf#page=6
\url{https://anggtwu.net/LATEX/2026bad-foundations.pdf\#page=6}
% ;-- introduction
% «introduction» (to ".introduction")
% (2026setcomprp 1 "introduction")
% (2026setcompra "introduction")
\section{Introduction}
\def\und#1#2{\underbrace{#1}_{#2}}
\def\und#1#2{\underbrace{#1}_{\text{#2}}}
\def\und#1#2{\underbrace{\mathstrut#1}_{\mathstrut\text{#2}}}
\def\ug#1{\und{#1}{gen}}
\def\uf#1{\und{#1}{filt}}
\def\ue#1{\und{#1}{expr}}
\standout{TODO:} expand this one-page explanation:
% (bafp 5 "set-comprehensions")
% (bafa "set-comprehensions")
% (bafa "set-comprehensions" "OchsNSC2026")
\par
% https://anggtwu.net/LATEX/2026bad-foundations.pdf#page=5
\url{https://anggtwu.net/LATEX/2026bad-foundations.pdf\#page=5}
\msk
My favorite way of presenting variables to students with bad
foundations is by starting from a certain set of exercises on set
comprehensions in the next section, in which all variables are bound
and vary over small finite sets, and all the resulting sets are easy
to draw; this lets us avoid most of the difficulties in
\cite[p.6]{EllermeijerHeck} -- ``The meaning of variable is variable
in mathematics'' -- in a first moment; we start by ``variables that
vary'', and then we build the other possible meanings for variables on
top of that.
I started using that approach in \cite{MPG}, that was in Portuguese
and for freshmen students, and reused it in \cite{PH1} and other
papers. This appendix contains the exercises from \cite{MPG} with a
better introduction, and then a discussion of the rationale.
\msk
These two kinds of set comprehensions are written similarly but they
correspond to different programs:
%
%V for a=2,4 do
%V print(10*a)
%V end
%L
%L defvbt "compr 10*a"
\pu
%
%V for a=2,4 do
%V if a^2<10 then
%V print(a)
%V end
%V end
%L
%L defvbt "compr a^2<10"
\pu
%
$$\begin{array}{rclll}
\setofst {10a} {a∈\{2,3,4\}} &=& \{20,30,40\} && \myvcenter{\vbt{compr 10*a}} \\
\setofst {a∈\{2,3,4\}} {a^2<10} &=& \{2,3\} && \myvcenter{\vbt{compr a^2<10}} \\
\end{array}
$$
One way to unify them is to create a third notation, that uses a
\qco{;} instead of a \qco{|}, and in which all expressions at the left
of the \qco{;} are either ``generators'' or ``filters'', and after the
\qco{;} we have a ``result expression''. Generators, filters, and
result expressions correspond to the \qco{for}s, \qco{if}s, and
\qco{print}s in the Lua programs above, and if we annotate the parts
with underbraces to indicate the generators, the filters, and result
expressions, we get this:
%
$$\begin{array}{rcl}
\setofst {\ue{10a}} {\ug{a∈\{2,3,4\}}}
&=& \setofsc {\ug{a∈\{2,3,4\}}} {\ue{10a}} \\
\setofst {\ug{a∈\{2,3,4\}}} {\uf{a^2<10}}
&=& \setofsc {\ug{a∈\{2,3,4\}}, \uf{a^2<10}} {\ue{a}} \\
\end{array}
$$
\unitlength=4pt
\def\closeddot{\circle*{0.6}}
We can calculate the result of a set comprehension by using a tree.
For example, in this case,
%
$$\setofsc {\ug{x∈\{1,\ldots,5\}},\ug{y∈\{x,\ldots,6-x\}}} {\ue{(x,y)}}
\;=\; \picturedots(0,0)(6,6){ 1,1 1,2 1,3 1,4 1,5 2,2 2,3 2,4 3,3 }
$$
%
we can draw -- or, rather, typeset -- that tree in several ways. Here
are two ways, that follow the same conventions but have different
columns:
%
$$\comprehensionbox{
x & y & (x,y) \\\HLine
1 & 1 & (1,1) \\
& 2 & (1,2) \\
& 3 & (1,3) \\
& 4 & (1,4) \\
& 5 & (1,5) \\
2 & 2 & (2,2) \\
& 3 & (2,3) \\
& 4 & (2,4) \\
3 & 3 & (3,3) \\
4 & \Stop \\
5 & \Stop \\
}
%
\qquad
%
\comprehensionbox{
x & 6-x & \{x,\ldots,6-x\} & y & (x,y) \\\HLine
1 & 5 & \{1,2,3,4,5\} & 1 & (1,1) \\
& & & 2 & (1,2) \\
& & & 3 & (1,3) \\
& & & 4 & (1,4) \\
& & & 5 & (1,5) \\
2 & 4 & \{2,3,4\} & 2 & (2,2) \\
& & & 3 & (2,3) \\
& & & 4 & (2,4) \\
3 & 3 & \{3\} & 3 & (3,3) \\
4 & 2 & \{\} & \Stop \\
5 & 1 & \{\} & \Stop \\
}
$$
Most students feel that the second tree/table is much easier to
follow, but that they wouldn't be able to draw it fully by
themselves... it is obvious how the columns of the first tree were
chosen, but it in the second one it is not -- {\sl hint: because this
needs the idea of subexpressions}...
Most students find the the second table easier to follow than the
first one, but the columns in the first table were chosen in an
obvious way, and it is not so easy to explain how we chose the columns
of the second table. This is a nice example of how explanations can be
expanded and contracted.
% ;-- exercises
% «exercises» (to ".exercises")
% (2026setcomprp 3 "exercises")
% (2026setcompra "exercises")
\section{Exercises}
Source:
\par
% (mpgp 10 "comprehension-ex123")
% (mpga "comprehension-ex123")
% https://anggtwu.net/LATEX/material-para-GA.pdf#page=10
\url{https://anggtwu.net/LATEX/material-para-GA.pdf\#page=10}
\msk
SC1) Draw these sets:
$\begin{array}{rcl}
A & := & \{(1,4), (2,4), (1,3)\} \\
B & := & \{(1,3), (1,4), (2,4)\} \\
C & := & \{(1,3), (1,4), (2,4), (2,4)\} \\
D & := & \{(1,3), (1,4), (2,3), (2,4)\} \\
E & := & \{(0,3), (1,2), (2,1), (3,0)\} \\
\end{array}
$
\msk
SC2) Draw these sets:
$\begin{array}{rcl}
A & := & \{x∈\{1,2\}; (x,3-x)\} \\
B & := & \{x∈\{1,2,3\}; (x,3-x)\} \\
C & := & \{x∈\{0,1,2,3\}; (x,3-x)\} \\
D & := & \{x∈\{0,0.5,1, \ldots, 3\}; (x,3-x)\} \\
E & := & \{x∈\{1,2,3\}, y∈\{3,4\}; (x,y)\} \\
F & := & \{x∈\{3,4\}, y∈\{1,2,3\}; (x,y)\} \\
G & := & \{x∈\{3,4\}, y∈\{1,2,3\}; (y,x)\} \\
H & := & \{x∈\{3,4\}, y∈\{1,2,3\}; (x,2)\} \\
I & := & \{x∈\{1,2,3\}, y∈\{3,4\}, x+y<6; (x,y)\} \\
J & := & \{x∈\{1,2,3\}, y∈\{3,4\}, x+y>4; (x,y)\} \\
K & := & \{x∈\{1,2,3,4\}, y∈\{1,2,3,4\}; (x,y)\} \\
L & := & \{x,y∈\{0,1,2,3,4\}; (x,y)\} \\
M & := & \{x,y∈\{0,1,2,3,4\}, y=3; (x,y)\} \\
N & := & \{x,y∈\{0,1,2,3,4\}, x=2; (x,y)\} \\
O & := & \{x,y∈\{0,1,2,3,4\}, x+y=3; (x,y)\} \\
P & := & \{x,y∈\{0,1,2,3,4\}, y=x; (x,y)\} \\
Q & := & \{x,y∈\{0,1,2,3,4\}, y=x+1; (x,y)\} \\
R & := & \{x,y∈\{0,1,2,3,4\}, y=2x; (x,y)\} \\
S & := & \{x,y∈\{0,1,2,3,4\}, y=2x+1; (x,y)\} \\
\end{array}
$
\msk
SC3) Draw these sets:
$\begin{array}{rcl}
A & := & \setofst{(x,0)}{x∈\{0,1,2,3\}} \\
B & := & \setofst{(x,x/2)}{x∈\{0,1,2,3\}} \\
C & := & \setofst{(x,x)}{x∈\{0,1,2,3\}} \\
D & := & \setofst{(x,2x)}{x∈\{0,1,2,3\}} \\
E & := & \setofst{(x,1)}{x∈\{0,1,2,3\}} \\
F & := & \setofst{(x,1+x/2)}{x∈\{0,1,2,3\}} \\
G & := & \setofst{(x,1+x)}{x∈\{0,1,2,3\}} \\
H & := & \setofst{(x,1+2x)}{x∈\{0,1,2,3\}} \\
I & := & \setofst{(x,2)}{x∈\{0,1,2,3\}} \\
J & := & \setofst{(x,2+x/2)}{x∈\{0,1,2,3\}} \\
K & := & \setofst{(x,2+x)}{x∈\{0,1,2,3\}} \\
L & := & \setofst{(x,2+2x)}{x∈\{0,1,2,3\}} \\
M & := & \setofst{(x,2)}{x∈\{0,1,2,3\}} \\
N & := & \setofst{(x,2-x/2)}{x∈\{0,1,2,3\}} \\
O & := & \setofst{(x,2-x)}{x∈\{0,1,2,3\}} \\
P & := & \setofst{(x,2-2x)}{x∈\{0,1,2,3\}} \\
\end{array}
$
\bsk
Now we can define the cartesian product.
These definitions are standard:
$$\begin{array}{rcl}
A×B &:=& \{a∈A,b∈B;(a,b)\} \\
A^2 &:=& A×A \\
\end{array}
$$
So, for example:
%
$$\begin{array}{rcl}
\{1,2\}×\{3,4\} &=& \{(1,3),(1,4),(2,3),(2,4)\} \\
\{3,4\}^2 &=& \{3,4\}×\{3,4\} \\
&=& \{(3,3),(3,4),(4,3),(4,4)\} \\
\end{array}
$$
SC4) Let:
%
$$\begin{array}{rcl}
A &=& \{1,2,4\} \\
B &=& \{2,3\} \\
C &=& \{2,3,4\} \\
\end{array}
$$
Draw these sets:
\begin{tabular}{lll}
a) $A×A$ & d) $B×A$ & g) $C×A$ \\
b) $A×B$ & e) $B×B$ & h) $C×B$ \\
c) $A×C$ & f) $B×C$ & i) $C×C$ \\
\end{tabular}
\msk
SC5) Draw these sets:
$\begin{array}{rcl}
A &:=& \{x,y∈\{0,1,2,3\};(x,y)\} \\
B &:=& \{x,y∈\{0,1,2,3\}, y=2; (x,y)\} \\
C &:=& \{x,y∈\{0,1,2,3\}, x=1; (x,y)\} \\
D &:=& \{x,y∈\{0,1,2,3\}, y=x; (x,y)\} \\
E &:=& \{x,y∈\{0,1,2,3,4\}, y=2x; (x,y)\} \\
F &:=& \{(x,y)∈\{0,1,2,3,4\}^2, y=2x; (x,y)\} \\
G &:=& \{(x,y)∈\{0,1,2,3,4\}^2, y=x; (x,y)\} \\
H &:=& \{(x,y)∈\{0,1,2,3,4\}^2, y=x/2; (x,y)\} \\
I &:=& \{(x,y)∈\{0,1,2,3,4\}^2, y=x/2+1; (x,y)\} \\
J &:=& \setofst {(x,y)∈\{0,1,2,3,4\}^2} {y=2x} \\
K &:=& \setofst {(x,y)∈\{0,1,2,3,4\}^2} {y=x} \\
L &:=& \setofst {(x,y)∈\{0,1,2,3,4\}^2} {y=x/2} \\
M &:=& \setofst {(x,y)∈\{0,1,2,3,4\}^2} {y=x/2+1} \\
N &:=& \setofst {(x,y)∈\{1,2,3\}^2} {0x+0y=0} \\
O &:=& \setofst {(x,y)∈\{1,2,3\}^2} {0x+0y=2} \\
P &:=& \setofst {(x,y)∈\{1,2,3\}^2} {x≥y} \\
\end{array}
$
\msk
SC6) Draw these sets:
$\begin{array}{rcl}
J' &:=& \setofst {(x,y)∈\R^2} {y=2x} \\
K' &:=& \setofst {(x,y)∈\R^2} {y=x} \\
L' &:=& \setofst {(x,y)∈\R^2} {y=x/2} \\
M' &:=& \setofst {(x,y)∈\R^2} {y=x/2+1} \\
N' &:=& \setofst {(x,y)∈\R^2} {0x+0y=0} \\
O' &:=& \setofst {(x,y)∈\R^2} {0x+0y=2} \\
P' &:=& \setofst {(x,y)∈\R^2} {x≥y} \\
\end{array}
$
% ;-- answers
% «answers» (to ".answers")
% (2026setcomprp 5 "answers")
% (2026setcompra "answers")
\section{Answers}
Source:
\par
% (mpgp 12 "comprehension-gab")
% (mpga "comprehension-gab")
% https://anggtwu.net/LATEX/material-para-GA.pdf#page=12
\url{https://anggtwu.net/LATEX/material-para-GA.pdf\#page=12}
\msk
SC1)
$
A = B = C = \picturedots(0,0)(3,4){ 1,4 2,4 1,3 }
\quad
D = \picturedots(0,0)(3,4){ 1,4 2,4 1,3 2,3 }
\quad
E = \picturedots(0,0)(4,4){ 0,3 1,2 2,1 3,0 }
$
\bsk
SC2)
$ A = \picturedots(0,0)(4,4){ 1,2 2,1 }
\quad B = \picturedots(0,0)(4,4){ 1,2 2,1 3,0 }
\quad C = \picturedots(0,0)(4,4){ 0,3 1,2 2,1 3,0 }
\quad D = \picturedots(0,0)(4,4){ 0,3 .5,2.5 1,2 1.5,1.5 2,1 2.5,.5 3,0 }
$
\msk
$
\quad E = \picturedots(0,0)(4,4){ 1,3 2,3 3,3 1,4 2,4 3,4 }
\quad F = \picturedots(0,0)(4,4){ 3,1 4,1 3,2 4,2 3,3 4,3 }
\quad G = \picturedots(0,0)(4,4){ 1,3 2,3 3,3 1,4 2,4 3,4 }
\quad H = \picturedots(0,0)(4,4){ 3,2 4,2 }
\quad I = \picturedots(0,0)(4,4){ 1,3 2,3 1,4 }
\quad J = \picturedots(0,0)(4,4){ 2,3 3,3 1,4 2,4 3,4 }
$
\msk
$
\quad K = \picturedots(0,0)(4,4){ 1,4 2,4 3,4 4,4
1,3 2,3 3,3 4,3
1,2 2,2 3,2 4,2
1,1 2,1 3,1 4,1 }
\quad L = \picturedots(0,0)(4,4){ 0,4 1,4 2,4 3,4 4,4
0,3 1,3 2,3 3,3 4,3
0,2 1,2 2,2 3,2 4,2
0,1 1,1 2,1 3,1 4,1
0,0 1,0 2,0 3,0 4,0 }
\quad M = \picturedots(0,0)(4,4){ 0,3 1,3 2,3 3,3 4,3 }
\quad N = \picturedots(0,0)(4,4){ 2,0 2,1 2,2 2,3 2,4 }
\quad O = \picturedots(0,0)(4,4){ 0,3 1,2 2,1 3,0 }
\quad P = \picturedots(0,0)(4,4){ 0,0 1,1 2,2 3,3 4,4 }
$
\msk
$
\quad Q = \picturedots(0,0)(4,4){ 0,1 1,2 2,3 3,4 }
\quad R = \picturedots(0,0)(4,4){ 0,0 1,2 2,4 }
\quad S = \picturedots(0,0)(4,4){ 0,1 1,3 }
$
\bsk
SC3)
$ A = \picturedots(0,0)(4,4){ 0,0 1,0 2,0 3,0 }
\quad B = \picturedots(0,0)(4,4){ 0,0 1,.5 2,1 3,1.5 }
\quad C = \picturedots(0,0)(4,4){ 0,0 1,1 2,2 3,3 }
\quad D = \picturedots(0,0)(4,7){ 0,0 1,2 2,4 3,6 }
$
$
\quad E = \picturedots(0,0)(4,4){ 0,1 1,1 2,1 3,1 }
\quad F = \picturedots(0,0)(4,4){ 0,1 1,1.5 2,2 3,2.5 }
\quad G = \picturedots(0,0)(4,4){ 0,1 1,2 2,3 3,4 }
\quad H = \picturedots(0,0)(4,7){ 0,1 1,3 2,5 3,7 }
$
$
\quad I = \picturedots(0,0)(4,4){ 0,2 1,2 2,2 3,2 }
\quad J = \picturedots(0,0)(4,4){ 0,2 1,2.5 2,3 3,3.5 }
\quad K = \picturedots(0,0)(4,4){ 0,2 1,3 2,4 3,5 }
\quad L = \picturedots(0,0)(4,8){ 0,2 1,4 2,6 3,8 }
$
$
\quad M = \picturedots(0,0)(4,4){ 0,2 1,2 2,2 3,2 }
\quad N = \picturedots(0,0)(4,4){ 0,2 1,1.5 2,1 3,.5 }
\quad O = \picturedots(0,-1)(4,4){ 0,2 1,1 2,0 3,-1 }
\quad P = \picturedots(0,-5)(4,3){ 0,2 1,0 2,-2 3,-4 }
$
\bsk
SC4)
$ A×A = \picturedots(0,0)(4,4){ 1,1 2,1 4,1 1,2 2,2 4,2 1,4 2,4 4,4 }
\quad B×A = \picturedots(0,0)(4,4){ 2,1 3,1 2,2 3,2 2,4 3,4 }
\quad C×A = \picturedots(0,0)(4,4){ 2,1 3,1 4,1 2,2 3,2 4,2 2,4 3,4 4,4 }
$
\msk
$
\quad A×B = \picturedots(0,0)(4,4){ 1,2 2,2 4,2 1,3 2,3 4,3 }
\quad B×B = \picturedots(0,0)(4,4){ 2,2 3,2 2,3 3,3 }
\quad C×B = \picturedots(0,0)(4,4){ 2,2 3,2 4,2 2,3 3,3 4,3 }
$
\msk
$
\quad A×C = \picturedots(0,0)(4,4){ 1,2 2,2 4,2 1,3 2,3 4,3 1,4 2,4 4,4 }
\quad B×C = \picturedots(0,0)(4,4){ 2,2 3,2 2,3 3,3 2,4 3,4 }
\quad C×C = \picturedots(0,0)(4,4){ 2,2 3,2 4,2 2,3 3,3 4,3 2,4 3,4 4,4 }
$
\bsk
SC5)
$ A = \picturedots(0,0)(4,4){ 0,3 1,3 2,3 3,3
0,2 1,2 2,2 3,2
0,1 1,1 2,1 3,1
0,0 1,0 2,0 3,0 }
\quad B = \picturedots(0,0)(4,4){ 0,2 1,2 2,2 3,2 }
\quad C = \picturedots(0,0)(4,4){ 1,0 1,1 1,2 1,3 }
\quad D = \picturedots(0,0)(4,4){ 0,0 1,1 2,2 3,3 }
\quad E = \picturedots(0,0)(4,4){ 0,0 1,2 2,4 }
$
\msk
$
\quad F = \picturedots(0,0)(4,4){ 0,0 1,2 2,4 }
\quad G = \picturedots(0,0)(4,4){ 0,0 1,1 2,2 3,3 4,4 }
\quad H = \picturedots(0,0)(4,4){ 0,0 2,1 4,2 }
\quad I = \picturedots(0,0)(4,4){ 0,1 2,2 4,3 }
$
\msk
$
\quad J = \picturedots(0,0)(4,4){ 0,0 1,2 2,4 }
\quad K = \picturedots(0,0)(4,4){ 0,0 1,1 2,2 3,3 4,4 }
\quad L = \picturedots(0,0)(4,4){ 0,0 2,1 4,2 }
\quad M = \picturedots(0,0)(4,4){ 0,1 2,2 4,3 }
$
\msk
$
\quad N = \picturedots(0,0)(4,4){ 1,3 2,3 3,3
1,2 2,2 3,2
1,1 2,1 3,1 }
\quad O = \picturedots(0,0)(4,4){ }
\quad P = \picturedots(0,0)(4,4){ 3,3
2,2 3,2
1,1 2,1 3,1 }
$
% ;-- maxima
% «maxima» (to ".maxima")
\section{Maxima}
TODO: explaind the DSL in:
\par
% (find-TH "eev-maxima" "set-comprehensions")
% (find-myqdraw "myqdraw3.mac" "set-comprehensions")
% https://anggtwu.net/eev-maxima.html#set-comprehensions
\par\url{https://anggtwu.net/eev-maxima.html\#set-comprehensions}
% http://anggtwu.net/myqdraw/myqdraw3.mac.html#set-comprehensions
\par\url{http://anggtwu.net/myqdraw/myqdraw3.mac.html\#set-comprehensions}
% ;-- haskell
% «haskell» (to ".haskell")
\section{Haskell}
TODO: explain this syntax, including the guards:
% (find-es "haskell" "comprehension")
% (find-angg "HASKELL/Comprehensions1.hs")
% http://anggtwu.net/e/haskell.e.html#comprehension
\par\url{http://anggtwu.net/e/haskell.e.html\#comprehension}
% http://anggtwu.net/HASKELL/Comprehensions1.hs.html
\par\url{http://anggtwu.net/HASKELL/Comprehensions1.hs.html}
% ;-- lua
% «lua» (to ".lua")
\section{Lua}
TODO: explaind the DSL in:
% (find-angg "LUA/Comprehensions2.lua")
% http://anggtwu.net/LUA/Comprehensions2.lua.html
\par\url{http://anggtwu.net/LUA/Comprehensions2.lua.html}
% ;-- hypotheses
% «hypotheses» (to ".hypotheses")
\section{Making and testing hypotheses}
TODO: translate the collaborative game from:
% (wld2026p 14 "set-comprehensions-3")
% (wld2026a "set-comprehensions-3")
% (wld2026a "set-comprehensions-3" "jogo\ncolaborativo")
% http://anggtwu.net/LATEX/2026logica-para-pessoas.pdf#page=14
\par\url{http://anggtwu.net/LATEX/2026logica-para-pessoas.pdf\#page=14}
% (c2m242srp 19 "um-jogo")
% (c2m242sra "um-jogo")
% http://anggtwu.net/LATEX/2024-2-C2-somas-de-riemann.pdf#page=19
\par\url{http://anggtwu.net/LATEX/2024-2-C2-somas-de-riemann.pdf\#page=19}
% ;-- venn-diagrams
% «venn-diagrams» (to ".venn-diagrams")
\section{Venn Diagrams}
% (find-books "__analysis/__analysis.el" "van-hiele" "120" "It is easy to see that `set' has no intuitive\ncontents by consulting the textbooks that introduce sets")
This is from \cite[p.120]{VanHiele}:
\begin{quote}
In this guided learning process, leading from intuition to first
abstraction, the concept of `set' is of no use. `Set' is the
terminal point of an abstraction: It is the loosest link
facilitating ``counting.'' It is easy to see that `set' has no
intuitive contents by consulting the textbooks that introduce sets.
Some speak of ""ele- ments with a common property.'' Indeed, the
only real common property is that they all are elements of the same
set. Other textbooks start with a set of stamps or a set of
boulders. This also creates confusion, for `collecting'' does not
play a part in a mathematical set. The identity of the elements of
such sets is often problematic, as well. A concept is likely to be
element of a set if it is defined in such a way that it can be
recognized. This condition is necessary and sufficient. But sets
used as examples in textbooks almost always have elements that are
very difficult to recognize.
\end{quote}
% (find-books "__discrete/__discrete.el" "epp" "350" "copy the diagram and shade the region corresponding to the")
TODO: show how to translate between the Venn diagram in
\cite[p.350, exercise 17]{Epp} and the world with 12 villages from:
% (find-TH "math-b" "ebl2019-mesa")
% (find-LATEX "2019ebl-mesa-slides.tex")
% (emsp 25 "propositions")
% (emsa "propositions")
% https://anggtwu.net/LATEX/2019ebl-mesa-slides.pdf#page=25
\par\url{https://anggtwu.net/LATEX/2019ebl-mesa-slides.pdf\#page=25}
% ;-- propositions
% «propositions» (to ".propositions")
\section{Propositions}
\def\villagesW{\picturedots(0,0)(5,4){ 1,3 2,3 3,3 4,3 1,2 2,2 3,2 4,2 1,1 2,1 3,1 4,1 }}
\def\villagesP{\picturedots(0,0)(5,4){ 1,3 2,3 3,3 1,2 2,2 3,2 }}
\def\villagesQ{\picturedots(0,0)(5,4){ 2,3 3,3 4,3 2,2 3,2 4,2 }}
\def\villagesR{\picturedots(0,0)(5,4){ 2,2 3,2 2,1 3,1 }}
Here ``adults'' would prefer the terminology of Kripke frames, but
students prefer a terminology inspired by videogames. Imagine that we
are in a world that has these twelve villages,
%
$$W \;=\; \picturedots(0,0)(5,4){
1,3 2,3 3,3 4,3
1,2 2,2 3,2 4,2
1,1 2,1 3,1 4,1
}
$$
And these are the villages in which we can find `p'riests,
`q'artographers, and leathe`r'smiths:
%
$$P \;=\; \villagesP
\quad
Q \;=\; \villagesQ
\quad
R \;=\; \villagesR
$$
It's easy to visualize the villages that have both priests and
cartographers -- it is $P∩Q$:
%
$$P∩Q \;=\; \picturedots(0,0)(5,4){
2,3 3,3
2,2 3,2
}
$$
Until this point we were talking about sets that were easy to draw,
and everything was very concrete. Now note that each village has
coordinates. Saying simply `$x=4$' is confusing, but if we translate
that to the set of villages in which $x=4$ things become much easier
to visualize:
%
$$\setofst{(x,y)∈W}{x=4} \;\;=\;\; \picturedots(0,0)(5,4){
4,3
4,2
4,1 }
$$
Note that we have:
%
$$\begin{array}{rclcl}
P &=& \setofst{(x,y)∈W}{x≤3 ∧ y≥2} &=& \villagesP \\
Q &=& \setofst{(x,y)∈W}{x≥2 ∧ y≥2} &=& \villagesQ \\
R &=& \setofst{(x,y)∈W}{2≤x≤3 ∧ y≤2} &=& \villagesR \\
\end{array}
$$
So, in a sense, $P$ ``is'' $x≤3 ∧ y≥2$. How do the books handle this?
This is a good opportunity to show that 1) some books explain their
abuses of language, 2) other books are simply sloppy, 3)
disambiguation and understanding abuses of language are usually tasks
left to the reader, 4) sometimes we need to invent new notations
ourselves to formalize abuses and sloppiness, 5) some things can be
formalized {\sl sort of} easily if we use dependent variables, 6)
[but] I am not aware of any book that explains the rules for dependent
variables really well, 7) we can look at computer languages to see how
they implement ideas that the books leave underspecified,
\newpage
% ;-- comprehensions-links
% «comprehensions-links» (to ".comprehensions-links")
% (bafp 12 "comprehensions-links")
% (bafa "comprehensions-links")
% (mpgp 8 "comprehension")
% (mpga "comprehension")
% \picturedots(0,0)(3,4){ 1,4 2,4 1,3 }
% ;-- comprehensions
% «comprehensions» (to ".comprehensions")
% (bafp 12 "comprehensions")
% (bafa "comprehensions")
% ;-- solving-equations
% «solving-equations» (to ".solving-equations")
% (bafp 14 "solving-equations")
% (bafa "solving-equations")
\subsection{Solving equations}
TODO: discard?
\msk
% From: (find-angg "MAXIMA/2025-baf-strang.mac")
%
%M (%i1) eq1 : 1*x + 2*y = 3;
%M (%o1) 2\,y+x=3
%M (%i2) eq2 : 4*x + 5*y = 6;
%M (%o2) 5\,y+4\,x=6
%M (%i3) eq3 : 4*eq1;
%M (%o3) 4\,\left(2\,y+x\right)=12
%M (%i4) eq4 : expand(4*eq1);
%M (%o4) 8\,y+4\,x=12
%M (%i5) eq5 : eq2 - eq4;
%M (%o5) -\left(3\,y\right)=-6
%M (%i6) eq6 : eq5 / -3;
%M (%o6) y=2
%M (%i7) eq7 : subst(eq6, eq1);
%M (%o7) x+4=3
%M (%i8) eq8 : eq7 - 4;
%M (%o8) x=-1
%L
%L maximahead:sa("strang by hand", "")
\pu
%M (%i1) eq1 : 1*x + 2*y = 3;
%M (%o1) 2\,y+x=3
%M (%i2) eq2 : 4*x + 5*y = 6;
%M (%o2) 5\,y+4\,x=6
%M (%i3) solve([eq1,eq2],[x,y]);
%M (%o3) \left[ \left[ x=-1 , y=2 \right] \right]
%M (%i4)
%L
%L maximahead:sa("strang by solve", "")
\pu
Now we can discuss what means ``solving a set of equations'' --
remember that students with bad foundations don't understand that
well; see \cite[p.6]{Hewitt1}. Strang starts his book \cite{Strang4}
with the equations \co{eq1} and \co{eq2} below, and he derives
consequences from them until he reaches $x=-1$, $y=2$; these are two
translations of his argument to Maxima:
%
$$\def\maximavbox#1{\vtop{#1}}
\def\hboxthreewidth{6cm}
\scalebox{0.7}{
\ga{strang by hand}
\hspace*{-6cm}
\ga{strang by solve}
}
$$
\def\eqnp{\eqnpfull}
%V eq1: x + y = 3;
%V eq2: x - y = 1;
%V eq3: eq2+y;
%V eq4: subst(eq3,eq1);
%V eq5: eq4-1;
%V eq6: eq5/2;
%V eq7: subst(eq6,eq1);
%V eq8: eq7-1;
%L
%L defvbt "strang simpler"
\pu
%V eq1: x + y = 3;
%V eq2: x + y = 4;
%L
%L defvbt "strang no solution"
\pu
%V eq1: x + y = 4;
%V eq2: 2x + 2y = 8;
%L
%L defvbt "strang whole line"
\pu
We can't spend too much class time on exercises for the students with
the worst foundations, but we need to have a lot of material prepared
for them. Here is an exercise that I find very nice. Now our world has
the set of villages in the left below, and the second column shows how
to solve in Maxima a problem that is simpler than the `$x+2y=3,
4x+5y=6$' from Strang -- but it shows only the commands, not the log
with the input and output lines. The exercise is: a) write the log by
hand; b) complete the third column, that is translation of the
calculations to how we usually write them in Maths;
%
$$W \;=\; \picturedots(0,0)(5,5){
1,4 2,4 3,4 4,4
1,3 2,3 3,3 4,3
1,2 2,2 3,2 4,2
1,1 2,1 3,1 4,1
}
\qquad
\myvcenter{\vbt{strang simpler}}
\qquad
\begin{array}{rcl}
x+y &\eqnp{1} & 3 \\
x-y &\eqnp{2} & 1 \\
\ldots & \eqnp{3} & \ldots \\
\ldots & \eqnp{4} & \ldots \\
\ldots & \ldots & \ldots \\
\end{array}
$$
%
c) draw the set of worlds that obeys each one of the equations
\co{eq1} to \qco{eq8}, using a complete notation, like this:
%
$$\setofst{(x,y)∈W}{x+y=3}
\;=\; \picturedots(0,0)(5,5){
1,2
2,1
}
$$
%
d), e) do something similar for the two systems of equations below --
they're harder to understand, so read the next pages of Strang's book:
%
$$\mat{\vbt{strang no solution}\\
\text{(no solution)}\\
}
\qquad
\mat{\vbt{strang whole line}\\
\text{(whole line)}\\
}
$$
\newpage
% ;-- functions-of-xy
% «functions-of-xy» (to ".functions-of-xy")
% (bafp 18 "functions-of-xy")
% (bafa "functions-of-xy")
\subsection{Functions of $(x,y)$}
TODO: discard?
\msk
Up to this point we only saw one way to draw sets like this one:
%
$$\setofst{(x,y)∈W}{x+y≤4}$$
%
We calculated the result of the comprehension as a set of pairs, and
we drew these pairs. There are other ways, of course -- and one of
these ways is: for each $(x,y)∈W$ we check if $x+y≤4$ is true there or
not, and if that is true we draw a `$•$'; if not, we draw nothing.
We can adapt that way to functions of $x$ and $y$ whose results are
not truth values. For example, if we draw the result of $x+y$ centered
on each point $(x,y)∈W$ we get this,
%
% Based on: (c3m251nfp 23 "piramide")
% (c3m251nfa "piramide")
%
%L PictBounds.setbounds(v(0,0), v(5,5))
%L fxy_x = Numerozinhos.from(1, 1, [[
%L 1 2 3 4
%L 1 2 3 4
%L 1 2 3 4
%L 1 2 3 4 ]])
%L fxy_y = Numerozinhos.from(1, 1, [[
%L 4 4 4 4
%L 3 3 3 3
%L 2 2 2 2
%L 1 1 1 1 ]])
%L fxy_xy = Numerozinhos.from(1, 1, [[
%L 5 6 7 8
%L 4 5 6 7
%L 3 4 5 6
%L 2 3 4 5 ]])
%L fxy_4 = Numerozinhos.from(1, 1, [[
%L 4 4 4 4
%L 4 4 4 4
%L 4 4 4 4
%L 4 4 4 4 ]])
%L fxy_bool = Numerozinhos.from(1, 1, [[
%L F F F F
%L T F F F
%L T T F F
%L T T T F ]])
%L fxy_x :topict():sa("x on W"):output()
%L fxy_y :topict():sa("y on W"):output()
%L fxy_xy :topict():sa("x+y on W"):output()
%L fxy_4 :topict():sa("4 on W"):output()
%L fxy_bool:topict():sa("bool on W"):output()
\pu
$$\ga{x+y on W}
$$
%
and this gives us a way to visualize (some) subexpressions, and how
they are combined:
%
$$\def\und#1#2{\underbrace{#1}_{\ga{#2 on W}}}
\sa{x _}{\und{x}{x}}
\sa{y _}{\und{y}{y}}
\sa{4 _}{\und{4}{4}}
\sa{x+y _}{\und{\ga{x _}+\ga{y _}}{x+y}}
\sa{x+y<=4 _}{\und{\ga{x+y _}≤\ga{4 _}}{bool}}
\setofst{(x,y)∈W}{\ga{x+y<=4 _}}
$$
%newpage %-- footer
%newpage %-- writetoc
% ;-- references
% «references» (to ".references")
\printbibliography
% «write-dnt-file» (to ".write-dnt-file")
% (find-angg "LUA/Output1.lua" "write_dnt_file")
% (find-fline "~/LATEX/" "2026-set-comprehensions.dnt")
% (find-fline "~/LATEX/2026-set-comprehensions.dnt")
%L write_dnt_file ("2026-set-comprehensions.dnt")
\pu
\GenericWarning{Success:}{Success!!!} % Used by `M-x cv'
\end{document}
% «make-with-bib» (to ".make-with-bib")
% (misa "make-arxiv")
% (find-build-for-arxiv-links "2026-set-comprehensions")
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd ~/LATEX/
which biber
# biber --version
make -f 2019.mk STEM=2026-set-comprehensions veryclean
lualatex 2026-set-comprehensions.tex
biber 2026-set-comprehensions
lualatex 2026-set-comprehensions.tex
pdflatex 2026-set-comprehensions.tex
% (find-pdfpages2-links "~/LATEX/" "2026-set-comprehensions")
% Local Variables:
% coding: utf-8-unix
% outline-regexp: "% ;--"
% ee-tla: "nsc"
% ee-tla: "2026setcompr"
% End: