Chapterبەش 1 · Lectureوانە 1.2
Union, Intersection, Difference and Complementیەکگرتن، یەکتربڕین، جیاوازیی کۆمەڵە و تەواوکەر
How to build new sets from old ones: the universal set and Venn diagrams, union, intersection, disjoint sets, difference and complement, with worked examples and their use in databases, search filters and Python.
چۆن نوێ لە کۆن دروست دەکرێت: و ، ، ، ، و ، لەگەڵ نموونەی شیکراوە و بەکارهێنانیان لە ، گەڕان و Pythonـدا.
What you will learnچی فێر دەبیت
- Draw and read a Venn diagram with a universal set.
- Find the union, intersection, difference and complement of given sets.
- Decide whether two sets are disjoint and explain why .
- Recognise set operations in SQL, Python and search filters.
- بە بکێشیت و بیخوێنیتەوە.
- ، ، و چەند دراو بدۆزیتەوە.
- بڕیار بدەیت دوو جیاکراوەن یان نا و ڕوونی بکەیتەوە بۆچی .
- لە SQL، Python و گەڕاندا بناسیتەوە.
Combining setsتێکەڵکردنی کۆمەڵەکان
In the previous lesson you learned to read and write one set. Real questions usually involve two sets. Imagine a class in Erbil. A is the set of students in the Python club and B is the set of students in the football team. The teacher may ask:
لە وانەی پێشوودا فێر بوویت چۆن یەک بخوێنیتەوە و بنووسیت. پرسیارە ڕاستەقینەکان زۆرجار دوو لەخۆ دەگرن. پۆلێک لە هەولێر وێنا بکە. A ئەو قوتابییانەیە کە لە یانەی Pythonـدان و B قوتابییانی تیمی تۆپی پێیە. مامۆستا لەوانەیە بپرسێت:
- Who is in at least one of them? → the union
- Who is in both? → the intersection
- Who is in the Python club but not in the team? → the difference
- Who is in neither? → the complement of the union
- کێ لانیکەم لە یەکێکیاندایە؟ ←
- کێ لە هەردووکیاندایە؟ ←
- کێ لە یانەی Pythonـدایە بەڵام نەک لە تیمەکە؟ ←
- کێ لە هیچیاندا نییە؟ ←
Each question builds a new set from A and B. This lesson gives each operation its symbol, its rule and a picture.
هەر پرسیارێک نوێ لە A و B دروست دەکات. ئەم وانەیە هێما، یاسا و وێنەی هەر دەدات.
The universal set and Venn diagramsکۆمەڵەی گشتی و هێڵکارییەکانی ڤێن
The U of all the objects we are talking about in a problem. Every other set in the problem is a of U.
ئەو (U) کە هەموو ئەو شتانە لەخۆ دەگرێت کە لە پرسیارێکدا باسیان دەکەین. هەموو کۆمەڵەکانی تری پرسیارەکە Uـن.
Before we combine sets, we fix the universal set U: everything we are talking about in this problem. In the class example, U is all the students of the class. Every other set is a subset of U.
پێش تێکەڵکردنی ، (U) دیاری دەکەین: هەموو ئەو شتانەی لەم پرسیارەدا باسیان دەکەین. لە نموونەی پۆلەکەدا، U هەموو قوتابییانی پۆلەکەیە. هەموو تر Uـن.
In a Venn diagram, U is a rectangle and every set is a circle inside it. Two overlapping circles cut the rectangle into four regions. All examples of this lesson use , and .
لە ، U لاکێشەیەکە و هەر بازنەیەکە لە ناویدا. دوو بازنە کە بەشێکیان بەسەر یەکدا کەوتووە، لاکێشەکە دەکەنە چوار ناوچە. هەموو نموونەکانی ئەم وانەیە ، و بەکار دەهێنن.
What the universal set is: the set of everything we are talking about in a problem, with simple examples.
چییە: ئەو کە هەموو ئەو شتانەی تێدایە کە لە پرسیارێکدا باسیان دەکەین، بە نموونەی سادە.
Short (3:39) definition of the universal set with examples.
پێناسەیەکی کورت (3:39) بۆ ، لەگەڵ نموونە.
Union: یەکگرتن:
The of all elements that are in A, in B or in both: .
کۆمەڵەی ، کە هەموو ئەو ئەندامانە لەخۆ دەگرێت کە لە A یان لە B یان لە هەردووکیاندا هەن: .
x is in the union when it is in A, in B, or in both. The mathematical “or” always includes “both”.
x لە کاتێک لە A، لە B یان لە هەردووکیاندا بێت. «یان»ـی بیرکاری هەمیشە «هەردووکیان»یش دەگرێتەوە.
Example: . Put everything from both sets together and write each element once: 2 and 3 are in both sets but appear only once in the answer.
نموونە: . هەموو شتێکی هەردوو کۆ بکەرەوە و هەر تەنها یەک جار بنووسە: 2 و 3 لە هەردوو بەڵام تەنها یەک جار لە وەڵامەکەدا دەردەکەون.
Intersection: یەکتربڕین:
The of the elements that are in both A and B: .
کۆمەڵەی ، کە تەنها ئەو ئەندامانە لەخۆ دەگرێت کە هەم لە A و هەم لە Bـدا هەن: .
x is in the intersection only when it is in A and in B at the same time: the elements the two sets share.
x تەنها کاتێک لە کە لە هەمان کاتدا لە A و لە B بێت: ئەو دوو هاوبەشن تێیدا.
Example: . Walk through A and keep only the elements that also appear in B.
نموونە: . بە Aدا بڕۆ و تەنها ئەوانە بهێڵەوە کە لە Bـیشدا هەن.
How to find the intersection of two sets, the elements they share, and shade it in a Venn diagram.
چۆن دوو دەدۆزیتەوە، واتە ئەو لە هەردووکیاندا هەن، پاشان چۆن لە ڕەنگی دەکەیت.
Plays 0:00-5:12, the intersection part with Venn diagrams; the union part follows after 5:12.
لە 0:00 تا 5:12 پەخش دەبێت: بەشی لەگەڵ ؛ بەشی دوای 5:12 دێت.
Disjoint setsکۆمەڵە جیاکراوەکان
Two sets are disjoint when they have no element in common, that is when .
دوو کۆمەڵە جیاکراوەن کاتێک هیچ ئەندامێکی هاوبەشیان نییە، واتە کاتێک .
Two sets are disjoint if they have no element in common, that is . In a Venn diagram their circles do not overlap. Example: the odd numbers and the even numbers are disjoint.
دوو جیاکراوەن ئەگەر هیچ هاوبەشیان نەبێت، واتە . لە بازنەکانیان بەسەر یەکدا ناکەون. نموونە: ژمارە تاکەکانی و ژمارە جووتەکانی .
Difference: جیاوازیی کۆمەڵە:
The (also ) of the elements that are in A but not in B.
کۆمەڵەی (یان )، کە ئەو ئەندامانە لەخۆ دەگرێت کە لە Aـدا هەن بەڵام لە Bـدا نین.
Start with A and remove everything that is also in B. Many books write for the same set.
لە Aـەوە دەست پێبکە و هەموو ئەو شتانە لابە کە لە Bـیشدا هەن. زۆر کتێب هەمان بە دەنووسن.
The course example: and , so : remove a and b from A.
نموونەی کۆرسەکە: و ، بۆیە : a و b لە A لابە.
With our sets: , but . The order matters: , just as .
بە خۆمان: ، بەڵام . ڕیزبەندی گرنگە: ، هەر وەک چۆن .
Complement: تەواوکەر:
The of everything in the U that is not in A: .
کۆمەڵەی ، کە هەموو ئەو شتانەی (U) لەخۆ دەگرێت کە لە Aـدا نین: .
The complement is everything in the universal set that is not in A. It is also written or .
هەموو ئەو شتانەی کە لە Aـدا نین. بە یان ـیش دەنووسرێت.
With and : . Another example: if U is the digits and A is the prime digits , then .
بە و : . نموونەیەکی تر: ئەگەر U تاکژمارەکانی بێت و A ژمارە سەرەتاییەکانی بێت، ئەوا .
All the operations at a glanceهەموو کارەکانی کۆمەڵە بە یەک نیگا
Watch the shaded region change while the rule under it changes. Every operation is a choice of regions of the same picture.
سەیری ناوچە ڕەنگکراوەکە بکە کاتێک لەگەڵ یاساکەی خوارەوەیدا دەگۆڕێت. هەر تەنها هەڵبژاردنی چەند ناوچەیەکی هەمان وێنەیە.


| Operation | Symbolهێما | x belongs to it when …x تێیدایە کاتێک … | Our exampleنموونەکەمان |
|---|---|---|---|
| Union | or (or both) یان (یان هەردووکیان) | ||
| Intersection | and و | ||
| Difference | and و | ||
| Difference | and و | ||
| Complement | and و |
A worked exampleنموونەیەکی شیکراوە
Let , let E be the even numbers in U and T the multiples of 3 in U. Work out every operation.
با بێت، E ژمارە جووتەکانی U بێت و T ئەو ژمارانەی U بێت کە دابەشی 3 دەبن. هەموو ئەنجام بدە.
- Write the sets in roster formکۆمەڵەکان بە شێوەی لیستکردنی کۆمەڵە بنووسە
First list the elements, so that every later step is just looking.
سەرەتا بنووسە، بۆ ئەوەی هەموو هەنگاوەکانی دواتر تەنها سەیرکردن بن.
- Union and intersectionیەکگرتن و یەکتربڕین
Put everything together for the union; keep only what is shared for the intersection.
بۆ هەموو شتێک کۆ بکەرەوە؛ بۆ تەنها هاوبەشەکان بهێڵەوە.
- The two differencesدوو جیاوازیی کۆمەڵەکە
Remove the shared element 6 from each set.
هاوبەشەکەی 6 لە هەر لابە.
- Complementsتەواوکەرەکان
Take everything in U that is missing from the set.
هەموو ئەوەی لە Uـدایە و لە نییە وەربگرە.
is the set of numbers that are neither even nor a multiple of 3.
ئەو ژمارانەن کە نە جووتن نە دابەشی 3 دەبن.
Set operations in computingکارەکانی کۆمەڵە لە کۆمپیوتەردا
Three of these operations appear wherever a computer searches or compares data. The complement is missing: to list “everything that is not in A”, a computer would first need the universal set U.
سێ لەم لە هەر شوێنێکدا دەردەکەون کە کۆمپیوتەر بەدوای دەگەڕێت یان بەراوردی دەکات. لێرەدا نییە: بۆ ڕیزکردنی «هەموو ئەوەی لە Aـدا نییە»، کۆمپیوتەر سەرەتا پێویستی بە (U) دەبوو.
| Ideaبیرۆکە | Mathsبیرکاری | SQL | Python |
|---|---|---|---|
| in A or in Bلە A یان لە B | UNION | a | b | |
| in A and in Bلە A و لە B | INTERSECT | a & b | |
| in A but not in Bلە A بەڵام نەک لە B | EXCEPT | a - b |
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | Why it is wrongبۆچی هەڵەیە | Do this insteadلە جیاتی ئەوە |
|---|---|---|
| Mixing up and تێکەڵکردنی و | is “or” (more elements), is “and” (fewer elements) واتە «یان» ( زیاتر)، واتە «و» ( کەمتر) | Think of as an open cup that collects everything, and of as a narrow cap that keeps only what is shared وەک پەرداخێکی کراوە بزانە کە هەموو شتێک کۆ دەکاتەوە، وەک سەرپۆشێکی تەسک کە تەنها هاوبەشەکان دەهێڵێتەوە |
| Writing shared elements twice: نووسینی دوو جار: | A set has no repeats دووبارەی تێدا نییە | |
| Thinking بیرکردنەوە لەوەی | The first set is the one you keep from یەکەم ئەوەیە کە لێی دەهێڵیتەوە | but بەڵام |
| A complement without saying what U is بەبێ دیاریکردنی U | depends on U پشت بە U دەبەستێت | Always write U firstهەمیشە سەرەتا U بنووسە |
| Calling two different sets “disjoint”پێوتنی «جیاکراوە» بە هەر دوو جیاواز | Disjoint means no shared elementجیاکراوە واتە هیچ هاوبەش نییە | Check بپشکنە |
| Forgetting elements that are in A but not in B when finding لەبیرچوونی ئەو لە Aـدان و لە Bـدا نین کاتێک دەدۆزیتەوە | is everything outside B, inside A or not هەموو شتێکە لە دەرەوەی B، لە ناو A بێت یان نا | Go through U element by element U یەک یەک بپشکنە |
Exercisesڕاهێنانەکان
Let , and . Find , , , , , and . What do you notice about the last two?
با ، و بن. ، ، ، ، ، و بدۆزەرەوە. سەبارەت بە دوو دانەی کۆتایی چی دەبینیت؟
Show answerوەڵامەکە پیشان بدە
The last two are equal: “not in (C or D)” is the same as “not in C and not in D”. This rule, , is one of De Morgan's laws; you will meet it again in logic and Boolean algebra.
دوو دانەی کۆتایی یەکسانن: «نە لە (C یان D)» هەمان «نە لە C و نە لە D»ـیە. ئەم یاسایە، ، یەکێکە لە ؛ لە لۆجیک و دووبارە دەیبینیتەوە.
, and . Which pairs are disjoint?
، و . کام جووتانە جیاکراوەن؟
Show answerوەڵامەکە پیشان بدە
and , so X, Y and Y, Z are disjoint. , so X and Z are not.
و ، بۆیە X و Y، هەروەها Y و Z جیاکراوەن. ، بۆیە X و Z جیاکراوە نین.
A class has 40 students. 25 are in the Python club, 18 are in the football team and 9 are in both. How many are in at least one of them? How many are in neither? How many are only in the Python club, and how many only in the team?
پۆلێک 40 قوتابیی هەیە. 25 لە یانەی Pythonـدان، 18 لە تیمی تۆپی پێدان و 9 لە هەردووکیاندان. چەند قوتابی لانیکەم لە یەکێکیاندان؟ چەند لە هیچیاندا نین؟ چەند تەنها لە یانەی Pythonـدان و چەند تەنها لە تیمەکەدان؟
Hintئاماژە
Start with the overlap, then fill the other regions.
لە بەشە هاوبەشەکەوە دەست پێبکە، پاشان ناوچەکانی تر پڕ بکەرەوە.
Show answerوەڵامەکە پیشان بدە
Draw the Venn diagram: 9 in the overlap, 16 in P only, 9 in F only, 6 outside. Check: .
بکێشە: 9 لە بەشە هاوبەشەکە، 16 تەنها لە P، 9 تەنها لە F و 6 لە دەرەوە. پشکنین: .
With and a student wrote: “” and “”. Correct both lines.
بە و خوێندکارێک نووسیویەتی: «» و «». هەردوو دێڕەکە ڕاست بکەرەوە.
Show answerوەڵامەکە پیشان بدە
Line 1: a set lists each element once, so . Line 2: and are different sets. The set is “in exactly one of the two sets”, which is (called the symmetric difference; Python writes it a ^ b).
دێڕی یەکەم: هەر تەنها یەک جار دەنووسێت، بۆیە . دێڕی دووەم: و دوو جیاوازن. واتە «تەنها لە یەکێک لە دوو »، کە دەکاتە (پێی دەوترێت symmetric difference؛ Python بە a ^ b دەینووسێت).
Summary and reviewپوختە و پێداچوونەوە
- Fix the universal set U first. A Venn diagram draws U as a rectangle and each set as a circle.
- Union : in A or in B (or both). Intersection : in A and in B.
- A and B are disjoint when .
- Difference : in A but not in B; the order matters. Complement : everything in U outside A.
- and .
- سەرەتا (U) دیاری بکە. U وەک لاکێشە و هەر وەک بازنە دەکێشێت.
- : لە A یان لە B (یان هەردووکیان). : لە A و لە B.
- A و B جیاکراوەن کاتێک .
- : لە A بەڵام نەک لە B؛ ڕیزبەندی گرنگە. : هەموو ئەوەی لە Uـدایە و لە دەرەوەی Aـیە.
- و .
Why does the complement need a universal set?بۆچی تەواوکەر پێویستی بە کۆمەڵەی گشتی هەیە؟
Because “everything not in A” must mean “everything in U not in A”; without U we do not know what “everything” is.
چونکە «هەموو ئەوەی لە Aـدا نییە» دەبێت واتای «هەموو ئەوەی لە Uـدایە و لە Aـدا نییە» بێت؛ بەبێ U نازانین «هەموو» چییە.
Is the mathematical “or” in the union exclusive?ئایا «یان»ـی بیرکاری لە یەکگرتندا یەکێکیان بە تەنهایە؟
No. “ or ” is also true when x is in both.
نەخێر. « یان » ڕاستە تەنانەت کاتێک x لە هەردووکیاندایە.
How do you find quickly?چۆن بە خێرایی دەدۆزیتەوە؟
Write A, then cross out every element that also appears in B.
A بنووسە، پاشان هەموو ئەو بسڕەوە کە لە Bـیشدا هەن.
What do disjoint sets look like in a Venn diagram?کۆمەڵە جیاکراوەکان لە هێڵکاریی ڤێندا چۆن دەردەکەون؟
Two circles that do not overlap.
دوو بازنە کە بەسەر یەکدا ناکەون.
Videoڤیدیۆ
Watch a videoسەیری ڤیدیۆیەک بکە
A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.
How to find the union, intersection and complement of sets step by step, from easy examples to combined operations.
هەنگاو بە هەنگاو چۆن ، و دەدۆزیتەوە، لە نموونەی ئاسانەوە تا چەند پێکەوە.
Chapters: 0:00 set operations, 2:01 complement and union, 5:58 combined operations, 11:24 a harder example.
بەشەکان: 0:00 ، 2:01 و ، 5:58 چەند پێکەوە، 11:24 نموونەیەکی قورستر.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Sets of Numbers: From Natural to Complexکۆمەڵەکانی ژمارە: لە ژمارە سروشتییەکانەوە تا ژمارە ئاوێتەکان
Related lecturesوانە پەیوەندیدارەکان
- Sets of Numbers: From Natural to Complexکۆمەڵەکانی ژمارە: لە ژمارە سروشتییەکانەوە تا ژمارە ئاوێتەکان
- Relational Algebra and Relational Calculusجەبری پەیوەندیدار و ژمێرکاریی پەیوەندیدار
- The Python You Need for the AI Labsئەو Pythonـەی بۆ تاقیگەکانی ژیریی دەستکرد پێویستە
- Tuples, Sets and Dictionariesتاپڵەکان، کۆمەڵەکان و فەرهەنگەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.