\input /home/pasky/school/fastex/lib.tex

\subchapter{Princip inkluze a exkluze (PIE)}{

%% \n -> prunik, \u -> sjednoceni



\example{

	$$ |A_{1} \cup{} A_{2}| = |A_{1}| + |A_{2}| - |A_{1} \cap{} A_{2}| $$
	$$ |A_{1} \cup{} A_{2} \cup{} A_{3}| = |A_{1}| + |A_{2}| + |A_{3}|
	                          - |A_{1} \cap{} A_{2}|
	                          - |A_{1} \cap{} A_{3}|
	                          - |A_{2} \cap{} A_{3}|
	                          + |A_{1} \cap{} A_{2} \cap{} A_{3}| $$

}

\theorem{}{PIE}{
	Jsou-li $A_{1},A_{2},\ldots{},A_{n}$ kone�n� mno�iny:

	$$ |\setjoin{i=1}{n}{A_{i}}|
	       = \sum_{k=1}^{n}{\undernote{(-1)^{k+1}}{\textnote{parita}}
	                        \cdot \sum_{I \in{} \cn{\{1,..,n\}}{k}}{
	                               |\setcommon{i \in{} I}{}{A_{i}}|}
	                         } $$

	(Ve vno�en� sum� s��t�me p�es v�echny $k$-prvkov� podmno�iny mno�iny $1..n$.)


\proof{
	Nech� $x$ je libovoln� prvek z $A_{1} \cup{} A_{2} \cup{} \cdots{} \cup{} A_{n}$.
	Pro $n=1$, $n=2$ viz diagramy mno�in, nakreslit si, kam kter� prvek p�isp�v�:
	$+1 -1 +1 \cdots{}$
	
	Kolikr�t je po��t�n $x$ vlevo, kolikr�t vpravo?
	Vlevo jednou --- trivi�ln�.

\scpart{Vpravo}{
	
	 Nech� $j$ ozna�uje po�et mno�in $A_{i}$, do kter�ch pat�� $x$.

\example{
	  $$x \in{} A_{1}, \ldots{}, A_{j}$$
	  $$x \notin{} A_{j+1}, \ldots{}, A_{n}$$
}

	Pak plat�:
	 $$ \#x = \cn{j}{1} - \cn{j}{2} + \cn{j}{3} - \cdots{} + (-1)^{j-1} \cn{j}{j} $$
	  $$ = \sum_{i=1}^{j}{(-1)^{i-1} \cn{j}{i}} + 1 - 1 $$


	Obrac�me znam�nko a paritu:

	$$ = 1 - \sum_{i=0}^{j}{(-1)^i \cn{j}{i}} $$
	$$ = 1 - (-1 + 1)^j $$
	$$ = 1 $$
	\qed


}

}


\example{

	$$ |X| = \{1, \ldots, n\},\ |Y| = \{1, \ldots, l\},\ n \ge{} l $$

	Kolik existuje zobrazen� z $X$ {\bf{}na} $Y$?

	V�ech zobrazen� z $X$ do $Y$ je $l^n$.
	Nechceme po��tat ta, ve kter�ch se na n�jak� prvek $Y$ nezobrazuje ��dn� prvek z $X$:
	$$\existss{y \in{} Y}:\ \forall{x \in{} X},\ f(x) \ne y.$$

	Pro v�echna $i = 1,\ldots,l$ plat�:

		$$ A_{i} = \{j\colon X \to{} Y\ |\ \forall{x \in{} X},\ f(x) \ne i \} = \{ j\colon X \to{} Y-\{i\} \} $$
		$$ |A_{i}| = (l-1)^n $$

	Pro $i_{1} \not = i_{2}$:

		$$ A_{i_{1}} \cap{} A_{i_{2}} = \{ f\colon X \to{} Y-\{i_{1}, i_{2}\} \} $$
		$$ |A_{i_{1}} \cap{} A_{i_{2}}| = (l-2)^n $$

	Pro $\displaystyle{\{ i_{1}, \ldots, i_{k} \} \in{} \cn{\{1, \ldots, l\}}{k}}$:

		$$ A_{i_{1}} \cap{} \cdots \cap{} A_{i_{k}} = \{ f\colon X \to{} Y-\{i_{1},\ldots,i_{k}\} \} $$
		$$ \{A_{i_{1}} \cap{} \cdots \cap{} A_{i_{k}}\} = (l-k)^n $$

	Po�et zobrazen� z $X$ na $Y$ je:

		$$ l^n - |\setjoin{i=1}{l}{A_{i}}| = $$
		        $$ = l^n - \Bigg(\cn{l}{1}(l-1)^n - \cn{l}{2}(l-2)^n + \cn{l}{3}(l-3)^n - \cdots + $$
		        $$  + (-1)^{l-2}\cn{l}{l-1}(l-(l-1)^n) + (-1)^{l-1}\cn{l}{l}(l-l)^n\Bigg) = $$
		        $$ = \sum_{k=0}^{l-1}{(-1)^k\cn{l}{k}(l-k)^n} $$

}

}

}

\bend
