Files
math-notes/discrete-math/01-sets-basics.md

61 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Sets: Basics and Operations
**Source:** MIT 6.1200J Lecture 01
## What is a Set?
A **set** is a collection of objects.
### Properties
- **No duplicates:** {1, 2, 2, 3} = {1, 2, 3}
- **Order doesn't matter:** {1, 2, 3} = {3, 1, 2}
- **Can be infinite:** = {0, 1, 2, ...}
- **Can contain other sets:** B = {2, {3, 4}, ∅}
## Basic Notation
### Membership
- **∈** (element of): 6 ∈ A means "6 is in set A"
- **∉** (not element of): {1, 2} ∉ A
### Subset
- **⊆** (subset): S ⊆ T means all elements of S are also in T
- Example: {1, 2} ⊆ {0, 1, 2, 6}
## Common Sets
- **** (Natural numbers): {0, 1, 2, ...}
- **** (Integers): {..., -2, -1, 0, 1, 2, ...}
- **∅** or **{}** (Empty set): The set with no elements
## Set-Builder Notation
Used to define sets with predicates:
```
{n ∈ | isPrime(n)} = {2, 3, 5, 7, 11, ...}
```
Reads as: "The set of all n in such that isPrime(n) is true"
Can also use colon instead of vertical bar: `{n ∈ : isPrime(n)}`
## Set Operations
### Intersection (∩)
A ∩ B = {elements in both A and B}
### Union ()
A B = {elements in A or B (or both)}
### Difference (\ or )
A \ B = {elements in A that are not in B}
## Ordered Tuples
When **order matters**, use parentheses (not braces):
- **(6, 1, 2, 0) ≠ (2, 1, 6, 0)**
- Duplicates allowed: (1, 2, 2, 3) is valid
- Set operations (∩, , etc.) don't apply to tuples
## Related
- [[../logic-proofs/00-index|Logic & Proofs]]
- [[00-index|Discrete Math Index]]