Skip to content

An integer range is listed, and a family of sets has a union and an intersection - #1435

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
indexed-set-operations
Sep 21, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
indexed-set-operations

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Item 4 of the docket on #1409, second half: the constructions the chapter's exercises are written over — integer ranges, indexed unions and intersections, and the complement relative to a universe. Its rows are the tests.

ZZ /\ [1; 10] lists its members. An integer set cut by a numeric interval with at most 4096 members in it is the finite set of them (SetOperators.IntersectSpecialSetAndInterval, through the residue-class listing of #1424 with modulus 1): the book's [n] = {1, …, n} is ZZ+ /\ [1; n], [0; 2.5] /\ ZZ* is {0, 1, 2}, ZZ /\ (1; 2) is {}. The reals and the complex numbers cut by an interval are the interval; the rationals stay as written.

union(A_k, k in I) and intersection(A_k, k in I) are Entity.Set.IndexedUnionf and IndexedIntersectionf, binders like sum (name bound throughout, capture-avoiding substitution as a quantifier's), under an abstract IndexedSetOperation:

a listed index set folded to the binary operators: union({k, 2 k}, k in ZZ+ /\ [1; 10]) is {1, …, 10, 12, 14, 16, 18, 20} (Ex 3.6.1); A_k = {k-2, …, k+2} over {1, 2, 3} unites to {-1, …, 5} and meets in {1, 2, 3} (Ex 3.6.6)
any other an object whose membership goes through the quantifiers (#1421): x in union(A_n, n in I) is exists n in I : x in A_n. So the book's limit cases read at their members — 0 in intersection([0; 1/n), n in ZZ+) is True and 0.1 is not (§3.9.5 Try 8); 1 is in every [n] and 2 is not (Problem 3.11.20)

The families themselves stay written over an infinite index set (⋂ [0, 1/n) = {0} as a set equality needs a limit argument, not this PR's). complement(A, U) is U \ A — a complement is relative to a universe, there being no set of everything (Ex 3.5.11). Note that i is the imaginary unit, so an index is k or n; the parser says so when asked for i.

MathS.Sets.IndexedUnion/IndexedIntersection/Complement; union, intersection, complement are keywords now. Syntax.md, BREAKING-CHANGES.md (rows measured on a v2.5.0 build), PublicApi.txt regenerated, parser regenerated and post-processed. IndexedSetOperationTest, 25 rows. Full suite 12160 passed, 0 failed; benchmark gate PASSED (SimplifyHard 173,260,088 B, the same bytes as master after #1432).

What is left of item 4 is tuples and Cartesian products, which is #330's question (a pair as a value, a set of pairs) and waits for the v3 design (#1019); the docket moves to item 5, relations.

Part of #1409.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 2 commits September 21, 2026 03:06
…ntersection

Item 4 of the reference's docket (#1409), second half. ZZ /\ [1; 10] lists its members: an
integer set cut by a numeric interval with at most 4096 members in it is the finite set of
them -- the reference's [n] = {1, ..., n} is ZZ+ /\ [1; n], and its indexed unions run over
such ranges; the reals and the complex numbers cut by an interval are the interval, and the
rationals stay as written. union(A_k, k in I) and intersection(A_k, k in I), the ⋃ and ⋂
over a family, are Entity.Set.IndexedUnionf and IndexedIntersectionf: binders like sum,
with the capture-avoiding substitution a quantifier has, folded to the binary operators
over a listed index set, and over any other an object whose membership goes through the
quantifiers -- x in union(A_n, n in I) is exists n in I : x in A_n -- so that the
reference's limit cases read at their members: 0 in intersection([0; 1/n), n in ZZ+) is
True and 0.1 is not, 1 is in every [n] and 2 is not. complement(A, U) is U \ A, a
complement being relative to a universe.

The reference's rows are the tests (IndexedSetOperationTest): Ex 3.6.1, Ex 3.6.6 over two
index sets, Ex 3.5.11, Problem 3.11.20, §3.9.5 Try 8. An index is k or n where the book
writes i, which is the imaginary unit here.

#1409

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Happypig375

Copy link
Copy Markdown
Member

Do e.g. max / min also want its indexed variant separate from a function of two expressions? If breaking, note for v3

@Rafael-SOWNet

Copy link
Copy Markdown
Member Author

Today min and max overload on the shape of the second argument: min(a, b) is the smaller of two, min(f(t), t in S) the minimum over a set (Minimumf), decided by the second argument being an in statement with a name on its left — as argmax(f, t in S) is, and as union(A_k, k in I) is here. So the indexed variant is not separate for min/max, and it is a separate name for the set operations only because unite and intersect are infix keywords, and a unite( token would break A unite (B \/ C). Not breaking now: min(p, q in S) as "the smaller of two truth values" is nothing anyone writes, so the overload has no real ambiguity.

The v3 point is consistency of the indexed spelling across all of them — sum and product take (body, var, from, to), min/max/argmax/union/intersection take (body, var in S), and the prefix binders (forall, ) take var in S : body — one convention for every operation over an indexed family, with // as the Unicode input of the same. Noted on #1019.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants