I was working on two separate problems and came across a potential pattern involving Pascal's triangle. I would like to know if Pascal's triangle applies to either of these problems and if so, is there a formula I can use to come up with these patterns explicitly?
Potential Pattern 1:
Whenever I was counting the number of possible functions between set $A$ and set $B$, where $A=\{a,b,c\}$ and $B=\{0,1\}$
I noticed the following:
There is one function from $A$ to $B$ that sends zero elements to element $1$ in $B$. Three functions from $A$ to $B$ that only send one element in $A$ to element $1$ in $B$. Three functions from $A$ to $B$ that send two elements in $A$ to element $1$ in $B$. One function from $A$ to $B$ that sends three elements in $A$ to element $1$ in B.
Thus we have $1+3+3+1$ possible functions.
Potential Pattern 2:
I was looking at a set of $4$-elements and began generating the elements of its powerset and noticed it has $1$ zero element set, $4$ one element sets, $6$ two element sets, $4$ three element sets and $1$ four element set.
This follows the pattern of $1,4,6,4,1.$
For instance, how can I use a formula to calculate the following: given the power set of a 4-element set, how many three element sets does it have? Could I see an example of how to calculate this with a formula? The answer is 4, but I know that because I wrote all the subsets down and counted them by hand.
For problem nr1:
A function can be thought of as a subset of the so called Cartesian product between two sets. That is $$ f: A\to B, \ f(a)=b $$ can be thought of as a subset of $\{(a,b)\mid a\in A, b\in B\}$ so what you are actually counting here is the number of ways you can create these pairs with some particular restrictions say you would like everything to be mapped to only one specific member of the target domain, that is $B$.
For problem nr2:
You are counting "how many ways can I pick $0$ elements from a set having $n$ elements" this is usually expressed as a so called binomial coefficient $$ \binom{n}{0}=\frac{n!}{0!(n-0)!}=1 $$ for exaample.
How this is tied to the pascal triangle is as follows:
If you number the rows of the triangle starting from $0$ then the $k$th element in $n$th row is $$ \binom{n}{k}=\frac{n!}{k!(n-k)!}. $$
The name binomial coefficient comes from the fact that these numbers represent the coefficients in $$ (a+b)^n. $$ Let us look at an example:
$$ (a+b)^3=1\cdot a^3+3\cdot a^2b+3\cdot ab^2+1\cdot b^3 $$
How come? Well, we are actually counting the number of ways we can pick factors from the sums:
$$ (a+b)^3=(a+b)(a+b)(a+b) $$
so $a^3$ has coefficeint $1$ since there is only one way to pick $3$ "a"s. $a^2b$ has coefficient $3$ since we can pick $2$ "a"s and $1$ "b" in three different ways $$ (\underline{a}+b)(\underline{a}+b)(a+\underline{b}) $$ $$ (\underline{a}+b)(a+\underline{b})(\underline{a}+b) $$ and $$ (a+\underline{b})(\underline{a}+b)(\underline{a}+b). $$
I hope this clarified a bit :)