One should endorse one's work and save it for later.
This is my endorsement:

van=Facebook.com/groups/learningalgebra;

Next I insert a kill(all) statement to clear all existing definitions.
This makes sure there are no surprises if a file is run twice.

kill(all)$

wxMaxima has a menu bar at the top of the screen.
If you click the Cell menu at the top of the screen it shows us how to evaluate expressions;

/Users/van/Desktop/VanLearningAlgebra-Sets01.png

Sets

We can define a set by using curly braces "{}" or by using the function set();
They work the same way.
Let's define a set A and a set B using this fact.

A: {1, 2, 3};

B: set(x, y, z);

Notice three things:
1) The colon ':' operator means we are creating a definition, much as in a dictionary.
2) All statements are terminated with either a semicolon ';' or a dollar sign '$'
   Maxima will echo a statement ending in ';', it is quiet with '$'.
3) If we type the name of a thing, like 'A', Maxima will tell us its current definition.
   Let's do this with A and B:

A;

B;

We can construct a set named C from a Maxima list named L.
Lists are defined by square braces:

L: [f, g, h, i];

C: setify(L);

Now that we have defined three sets, let's do three things with them.
1) Define a function f using ":=" operator.
2) Review a set definition by typing its name, A.
3) map the function f onto the set A 

Step 1: So pretend your the function f.
Your only job in life is to add 2 to whatever someone gives you as input
and report that as your output. So if someone gives you a 3, you give them a 5 back.

f(x):=x+2;

Step 2: Find out what the computer currently thinks the value of A is:

A;

Step 3: Apply the function f to every element of the set A

map(f, A);

Now we change the subject. We want to add a new element to the set A.
This is done using adjoin.
In the future we will say this as follows:
Add an element 0 to the set A and return the set using adjoin(element, set)

adjoin(0, A);

Note that if we want this to be the definition of A we must define it to be so with ':'

A;

A:adjoin(0, A);

A;

It is always a good idea to find functions that undo the effect of each other.
These are called 'inverses'.
The inverse of adjoin(element, set) is disjoin(element,set).
Remember if we want the effect to 'stick' we have to define it to be so with ':'

A;
A: disjoin(0,A)$
A;

We can count the number of elements in a set with the function cardinality(set) 

cardinality(A);

We can count the number of ways to partition (chop up) a set of n elements using the Bell number function, belln(n)
See https://en.wikipedia.org/wiki/Bell_number

belln(cardinality(A));

Note that the elements of a set must be unique, so {1,1,2,3} would not be a set.
Let's see how Maxima deals with this

{1,1,2,3};

We can combine two sets using the function cartesian_product(A,B)
The Cartesian product of sets A and B, just takes every element of A
and combines it with every element of B.

cartesian_product(A,B);

We can combine more than two sets this way also to produce all possible ordered combinations
of the sets {0,1}, {x,y}, and {f,g}

cartesian_product({0,1},{x,y},{f,g});

If two sets do not contain any comment elements we say they are disjoint.
We can test this using the predicate function disjointp(setA, setB).
Predicate functions in Maxima are functions that test for a condition and return true or false

A;
B;

disjointp(A, A);
disjointp(A, B);

We can find all the divisors of a number n using the function divisors(n)

If a number has no other divisors other than 1 and itself we say it is prime.
We might wonder if the number 101 is prime. Let's check it using the function

divisors(101);

So 101 is prime.

A perfect number is one whose divisors, besides itself,
that can be added up to give the original number.
See https://en.wikipedia.org/wiki/Perfect_number

We might wonder if the number 28 is perfect.

divisors(28);

We want all the divisors except the last which is the number itself so we use the function
which we learned above, disjoin(element, set)

d: disjoin(28, divisors(28));

To add the divisors up we convert them to a list

L: listify(d);

sum(L[i],i,1,length(L));

By combining these statements in a block, we can check if any number n is perfect
using the function perfectp(n)

perfectp(n):=block(
                   [L],
                    L:listify(disjoin(n,divisors(n))),
                   is(n = sum(L[i],i,1,length(L)))
                  )$

Let's test our predicate function on numbers we know to be perfect and not

perfectp(28);

perfectp(27);

perfectp(496);

perfectp(495);

It's interesting we can 'program' such a powerful function so simply in Maxima.

There are some more functions we should see.
Definition:
A predicate function that tests if x is an element of a set is elementp(element, set)

A;

elementp(2,A);

elementp(4,A);

Definition:
A predicate function that tests if the set (or list) is empty is emptyp(set)
The empty set is denoted here by {}

emptyp(A);

emptyp({});

Definition:
We can apply a function to every member of a set using the function every(function, set)
In this case we ask if every element in set A is an integer.

every(integerp, A);

Now for something completely different.
We can make one set out of a nested set using the function flatten(set of sets)

flatten({i,{j,{k,l}}});

The identity function evaluates to its argument for all inputs.
To determine if every member of a set is some value, you can use identity(thing)

identity(false);

identity(7);

Now we look at the classic set operations, intersection, union, negation and set_difference
These are also called And, Or, Not, and Diff
We can define the Maxima set operation in terms of these more common names
but we capitalize the first letter to avoid name conflicts with other Maxima functions.

We start with the function And(set,set) 

And(u,v) := intersection(u,v)$

And({2,3,4},{4,5,6});

Next is the function Or(set,set)

Or(u,v) := union(u,v)$

Or({2,3,4},{4,5,6});

We cannot compute the infinite space of elements not in the set,
so the function less satisfying is the function Not(set)

Not(u) := not(u);

Not({2,3,4});

Diff(u,v) := setdifference(u,v);

Diff({3,4,5},{4,5});

If we want to know how many partitions of a set with n elements has
we call the function num_partitions(n)

ABC:Or(A,Or(B,C));

n:cardinality(ABC);

num_partitions(n);

We can split a set by a predicate using partition_set(set, predicate_function)
This returns a list of two sets,
those for which the predicate is false and
those for which the predicate is true

partition_set(A, oddp);

We can compute all the ways the elements of the set can be arranged using
the function permutations(set)

permutations(A);

cardinality(permutations(A));

cardinality(permutations(Or(A,B)));

When we would like to know if two sets are identical
we use the predicate function setequalp(setA,setB)

A;
B;
setequalp(A,B);

setequalp(B,B);

If we want to know if some elements of a set satisfy a predicate we use
the function some(predicate_function, set)

A;

some(oddp, A);

some(evenp, A);

stirling1(2,3);

We can find subsets with the function subset(set, predicate_function)

ABC;
subset(ABC, integerp);