Skip to content

Sets and Logical Operations

標準~35 min8 terms12 past questions

Goals of this unit

  • Read the union, intersection, and complement of sets as regions of a Venn diagram.
  • Build a truth table and identify the operation or logical expression it shows.
  • Tell apart the outputs of AND and OR on rows where only one input is 1, and of OR and XOR on the row where both inputs are 1.
Terms at a glance (8)
TermIn one lineTypeHow to tell it apart
集合A collection of things whose membership is clearly decidedConceptElement, subset, union, intersection, complement
ベン図Diagram that draws sets as circles and shows relations by overlapDiagramRead each region by inside or outside a circle
真理値表Table listing every input combination with its outputTablen inputs give 2 to the power n rows
論理演算Umbrella term for operations on the two values true (1) and false (0)Umbrella termThe result is also 0 or 1
ANDLogical product: 1 only when all inputs are 1Binary operationA single 0 gives 0
ORLogical sum: 1 if any input is 1Binary operation0 only when all inputs are 0
NOTNegation that swaps 0 and 1 of a single inputUnary operationTakes only one input
XORExclusive OR: 1 only when the two inputs differBinary operationBoth 1 gives 0

Terms

A set (集合) is a collection of things for which it is clearly decided whether each one meets a given condition.

OperationSymbolElements collected
UnionA∪BElements in at least one of A and B
Intersection (common part)A∩BElements in both A and B
ComplementA with a bar over it, etc.Elements of the whole that are not in A

Each individual member of a set is an element, and when every element of set X is also in set Y, X is a subset of Y. From two sets you can form the union, which gathers the elements in either one, and the intersection, which gathers only the elements in both. The elements of the whole that are not in a given set form its complement.

AnalogyLike a club roster: whether your name is on it decides whether you are in. A group such as "tall people," with a vague standard, is not a set.

How to rememberRemember ∪ as the shape of U, the first letter of Union, and ∩ as that shape turned upside down.

Exam points

  • ExamFor any two sets (集合), every element of the intersection (積集合) is in each original set, and every element of an original set is in the union (和集合). Inclusion runs in the order "intersection ⊆ original set ⊆ union."

2 past questions on this term 集合

ベン図Venn Diagram

Open in glossary ベン図

A Venn diagram (ベン図) draws sets as circles and shows how they relate through the circles' overlap and position.

Region (two circles)Circle ACircle BSet represented
A-only partInsideOutsideElements in A but not in B
OverlapInsideInsideIntersection (A∩B)
B-only partOutsideInsideElements in B but not in A
Part outside every circleOutsideOutsideComplement of the union (A∪B)

The outer rectangle stands for the whole under consideration; inside a circle is that set, and outside is its complement. Two circles split the whole into 4 regions and three circles into 8, and each region is fixed uniquely by which circles it lies inside and which it lies outside. Turning a shaded region into words or an expression lets you check by eye how the conditions are put together.

AnalogyLike circling the areas of two towns on a map and treating the houses where the circles overlap as belonging to both towns.

How to rememberIt is named after the British logician John Venn, so the name is a person's, not a description.

Exam points

  • ExamTo turn a shaded region into a logical expression (論理式), check for each region whether it is inside or outside each circle, then combine the conditions, using the condition itself for inside and its negation (否定) for outside.

2 past questions on this term ベン図

真理値表Truth Table

Open in glossary 真理値表

A truth table (真理値表) lists every combination the inputs can take, one per row, together with each output.

  1. Write every input combination
  2. Build the column inside the brackets
  3. Apply the outer operation
  4. Read the output column

The last column is the output, and the rows where it is 1 show what the expression does.

4 / 4

True is usually written as 1 and false as 0, and with n inputs the table has 2 to the power n rows. Because the table spells out an operation's behavior completely, two expressions that produce the same table behave the same way.

AnalogyFor a light with two switches, a list made by trying every on/off pattern and noting whether the bulb lights.

How to rememberA "truth value" is the value true or false, and the table is named for listing those values.

Exam points

  • ExamWhich operation a table shows is decided by the input combinations on the rows whose output is 1. If the output is 1 only on the row where all inputs are 1, it is the logical product (論理積).
  • ExamFor an expression with a negation (否定) outside the brackets, build the column for the result inside the brackets, then swap its 0s and 1s to get the table.

2 past questions on this term 真理値表

論理演算Logical Operation

Open in glossary 論理演算

A logical operation (論理演算) is any operation that takes only the two values true (1) and false (0) as input and returns 1 or 0 by a fixed rule.

ABA AND BA OR BA XOR B
00000
01011
10011
11110

Typical operations include AND and OR, along with negation, which takes just one input. Expressions combining operations are evaluated from the innermost brackets outward and are used in search conditions and in bit-by-bit processing inside computers. The intersection, union, and complement of sets correspond to the logical product, logical sum, and negation, respectively.

AnalogyLike a clerk who answers only "yes" or "no" and, from the one or more answers received, returns a single "yes" or "no" by a fixed procedure.

How to rememberIt is also called a Boolean operation, after George Boole, the mathematician who systematized two-valued calculation.

Exam points

  • ExamIn a condition, group the acceptable alternatives for one field with OR inside brackets, then join that group to another field's condition with AND. This narrows the results while keeping every alternative.

1 past questions on this term 論理演算

AND (logical product, 論理積) is an operation whose output is 1 only when all inputs are 1.

A single 0 among the inputs makes the output 0, and in set terms it corresponds to the intersection, which gathers the elements in both sets. It is used to narrow results by joining conditions with "and," and to pick out only certain bits of data.

AnalogyA safe door that opens only when both keys are turned.

How to rememberIt is sometimes written ∧ or "·" (the multiplication dot), and its results match multiplying 0s and 1s.

Exam points

  • ExamIn a bitwise AND, positions where the other operand's bit is 0 become 0, and positions where it is 1 keep the original data's value.
  • ExamIf an AND output is joined with a further input by another AND, the final output is 1 only when every input is 1.

2 past questions on this term AND

OR (logical sum, 論理和) is an operation whose output is 1 if any one input is 1.

The output is 0 only when every input is 0, and in set terms it corresponds to the union, which gathers the elements in either set. It joins conditions with "or" to widen the range of targets.

AnalogyA home arrival chime that rings whether you come in through the front door or the back door.

How to rememberIt is sometimes written ∨ or "+", and the only difference from ordinary addition is that 1 + 1 is also treated as 1.

Exam points

  • ExamThe count matching two conditions joined by OR is the sum of each condition's count minus the count that meets both.

1 past questions on this term OR

AND vs. OR

AspectANDOR
Key differenceWhen the output is 1All inputs are 1One or more inputs are 1
Set counterpartIntersection (common part)Union
Everyday wordandor

NOT (negation, 否定) is an operation that swaps 0 and 1 for a single input.

It is a unary operation that takes a single input, unlike operations that combine two inputs. In set terms it corresponds to the elements not in a set, that is, the complement, and in a Venn diagram it is the region outside a circle.

AnalogyA button that switches between on and off each time you press it.

How to rememberApplying NOT twice in a row gives back the original value (the negation of a negation is an affirmation).

Exam points

  • ExamA NOT outside the brackets inverts the whole result inside them, so negating an OR result gives 1 only on the row where all inputs are 0.

2 past questions on this term NOT

XOR (exclusive OR, 排他的論理和) is an operation whose output is 1 only when the two inputs differ.

Whether both inputs are 0 or both are 1, matching values give an output of 0. Applying XOR twice with the same value restores the original, and XOR is also used for purposes such as error detection.

AnalogyThe wiring of a stair light with one switch at the top and one at the bottom. Flipping either switch toggles the light on or off.

How to remember"Exclusive" means shutting the other out: it accepts "only one" and excludes the case where both hold.

Exam points

  • ExamXOR is 1 when at least one input is 1 and not both are, so it can also be written as an expression combining the other basic operations.
  • ExamIn a bitwise XOR, positions where the other operand's bit is 1 flip between 0 and 1, and positions where it is 0 keep the original data's value.
  • Mix-upWhen both inputs are 1, OR outputs 1 and XOR outputs 0, and this one row is the only difference.

2 past questions on this term XOR

OR vs. XOR

AspectORXOR
Key differenceBoth inputs are 110
Only one input is 111
Shaded area in a Venn diagramAll of both circlesBoth circles minus the overlap

Key points

  • An intersection is contained in each original set, and each original set is contained in the union.
  • Each region of a Venn diagram is fixed by which circles it lies inside or outside, and outside is expressed with negation.
  • A truth table with n inputs has 2 to the power n rows, and the rows where the output is 1 identify the operation.
  • In bitwise operations, AND clears the positions that are 0 in the other operand, and XOR flips the positions that are 1.

Check questions

5 past questions from this unit

Start the check questions

All past questions in this topic