Sets and Sequences as Mathematical Models
A sequence records positions and repeated elements. A set preserves membership while discarding both position and multiplicity.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Compare two records
The sequences \((A,B,A)\) and \((B,A)\) give the same underlying set. Only the former records a second occurrence of A. A frequency map retains multiplicity while still losing which occurrence came first.
Pick the model from the query
Asking which rooms are reserved can work with a set. Asking which room was reserved first needs ordering. See ordered and unordered equality for choosing an assertion that matches each interpretation.[1]
Start with a pair that has the same set and different data
Suppose two routes visit stops A, B, A and B, A respectively. Both have visited-set \(\{A,B\}\). The first route contains an extra visit and a different first stop. A sequence preserves both facts, and a bag preserves just the extra visit. See collection equality.
Model A,B,A B,A
Set {A,B} {A,B}
Bag A×2,B A,B
Sequence A,B,A B,A
Choose operations after choosing the model
Intersection can answer which stops two routes share. Testing consecutive transfers instead needs ordered positions. When a transformation discards structure, use a sample where the discarded structure changes the downstream answer.