Textbook
The difference $A\setminus B$ contains the elements of $A$ that do not belong to $B$:
$$A\setminus B=\{x\mid x\in A\land x\notin B\}.$$
Both conditions are required. An element absent from $A$ cannot enter the result, even if it is also absent from $B$. Therefore $A\setminus B\subseteq A$.
Argument order matters: generally $A\setminus B\ne B\setminus A$. The definition gives the boundary cases $A\setminus\varnothing=A$, $\varnothing\setminus B=\varnothing$, and $A\setminus A=\varnothing$.
The result shares no elements with $B$. Moreover, $A\setminus B=\varnothing$ exactly when $A\subseteq B$: an empty difference means that no element of $A$ lies outside $B$.
Membership in $A$ is checked before the exclusion condition involving $B$. If the first answer is negative, no later check can admit that object. When $A$ and $B$ have no common elements, their difference equals $A$: nothing can be removed. Adding to $B$ an object absent from $A$ also leaves the result unchanged. Here $B$ supplies a prohibition, never a source of new candidates.
Related concepts: Set membership.
In plain language
Difference resembles a shopping list after items already at home have been crossed out. The home inventory removes entries without adding new ones. Reversing the order gives a different list: things at home that were absent from the shopping list. An ordinary set records presence rather than apple counts; the refrigerator declines responsibility for that accounting.
Example
For the illustrative sets $A=\{1,2,3\}$ and $B=\{3,4\}$, the difference is computed in both directions.
Set difference
Initial set A
Only elements of A can enter A minus B.
Step 1 of 3: Initial set A
Read all steps
Initial set A
Only elements of A can enter A minus B.
- A
- 1current2current3current
- B
- 34
Exclusion of elements in B
Three is removed. Four is not added: it was never in A.
- A
- 1included2included3excluded
- A minus B
- 1included2included
Reversed direction
Now B is the starting set. The shared 3 is removed, leaving 4.
- B
- 3excluded4included
- B minus A
- 4included
First, three is removed from $A$ because it occurs in $B$. Four is not a candidate for that operation because it was never in $A$. After reversing direction, four survives, while one and two cannot arrive from the second list. Two conditions govern every result element: was it in the left argument, and is it absent from the right? Reversing the arguments changes both questions together.