= Propositional and predictive logic

= Proofs
Argument that something is true, foolproof, objective, argument.
== Direct proof
Want to prove $p->q$
Assume p, then through several steps of reasoning, conclude q.

*Eks:*

If $n$ is odd, then $n²$ is odd

Def: An integer n is #underline[even] if $exists k in ZZ, s.t., n=2k$

n is odd if $exists in ZZ #text("such that") n=2k+1$

Assume n is odd. then $exists k in ZZ #text("such that") n=2k+1$

So

$ 
n²=(2k+1)²=4k²+4k+1\ \
=2(2k²+2k)+1
$
Since $k in ZZ$, then $2k²+2k in ZZ$, so $n²$ is odd.


== Proof by contraposition
Prove $p->q$ by proving $not p-> not q$

For an integer n, if n² is odd, then n is odd.

Suppose n² is odd, then $exists k in ZZ #text("such that") n²=2k+1$

So $n=plus.minus sqrt(2k+1)$

We prove that if n is even, then n² is even.

Suppose n is even, then $exists in ZZ #text("such that") n=2k$

So $n²=(2k²)=4k²=2(2k²)$

Since $2k²$ is an integer, n² is even.

== Proof by contradiction
Want to prove _p_ by assuming it's not true (assume $not p$) and then reach a contradiction.

By contradiction we are going to conclude something we know is false. 

Showing: $not p->p$

*Eks:*
$sqrt(2)$ is irrational

A real number r is #underline[rational] if $exists a,b in ZZ$ #underline[with] $b eq.not 0 space #text("such that") space r=a/b$

Assume $sqrt(2)$ is rational. Then $exists a, b in ZZ, b eq.not 0 space #text("such that") space sqrt(2)=a/b$. You can assume that a and b have no common factors.

Then:
$
2=(a²)/(b²) \
2b²=a²
$
So a² is even, therefore a is even, then:
$ exists k in ZZ, a=2k $
$ 
2b²=(2k²)=4k²=> \
b²=2k²
$
So b² is even and therefore b is even.

Now that we've shown that a and b have a common factor (they have a common factor, 2, because both are even).

So now we have shown that $sqrt(2)$ can't be a rational number because there then is a contradiction.

= Sets
Def: A #underline[set] is an unordered collection of objects called #underline[elements]/#underline[members] of the set. We a set contains its elements.

$a in A$ - a is an element of A

$ a in.not A$ - a is NOT an element of A

It's also called the naive set theory, which leads to some paradoxes (Russell's Paradox, exercise 50 in 2.1 in book).

A way to describe a set, is to list all its elements. Eks: $A= {1,2,3,4}, B = {a,b,c,d}, C={"Apple",7,"Mike","Tivoli"}$

You can also do: ${x|"x has property P"}$

Ex: 
$ O&={x|x" is an odd integer"} \
&={x in ZZ|x "is odd"}
$

A set can have sets as elements. A set does not contain it's subelements if it contains sets. ${NN, ZZ, QQ, RR}$ does e.q. not contain the number 2. It contains sets that contain the number 2, but it itself does not.

== Important sets
$NN={0,1,2,3,4,...}$ - Set of natural numbers (some argue 0 is not in the natural numbers, some argue it is).

$ZZ={...,-2,-1,0,1,2,...}$ - Set of Integers. Can say $ZZ⁺$ or $ZZ_(>=0)$ for integers greater than 0.

$QQ = {a/b|a,b in ZZ, b eq.not 0}$ - Set of rational numbers

$RR$ - Real numbers (all numbers)

$CC$ - Complex numbers

== When two sets are equal
Def: Two sets A and B are equal if and only if they contain exactly the same elements.

$A=B$ if and only if $forall x{x in A <-> x in B}$

Order and amount of appearances doesn't matter in sets, so $ {1,3,5}={5,3,1}={1,3,3,5,5,5} $

If you have a set of variables, and some of them are equal, their value still only appears once.

== Empty set
This is the set with no elements. Notation $emptyset$

== Singleton set
Set with one element

== Subset
Def: A is a #underline[subset] of B, and B is a #underline[superset] of A, if and only if, every element of A is an element of B. Denoted $A subset.eq B$ or $B supset.eq A$.

You should say "A is a subset of B"

To show $A subset.eq B$: show that $"if" x in A ", then" x in B$. Show that every element in A is in B

To show $A subset.eq.not B$: find $"some" x in A "such that" x in B$. Find an element in A that is not in B.

*Theorem:* For any set S, $emptyset subset.eq S$ and $S subset.eq S$

$forall x(x in nothing -> x in S)$ is true ($x in nothing$ will always be false, so that means the implication is always true).

== Size of set (cardinality)
Def: Let S be the set. If there are exactly n distinct elements in S where $n in NN$, then we say that S is a finite set, with cardinality (size) n. $|S|=n$.

$ 
A&={x in ZZ⁺|"x is odd and" x <=10} \
|A|&=5\
|nothing|&=0
$
A set is infinite if it's not finite ($NN, RR, ZZ, QQ$ are for example all infinite).

== Powerset
Def: Let S be a set, the #underline[powerset] of S, denoted $cal(P)(S)$, is the set of all subsets of S

$cal(P)({0,1,2,3})={nothing,{0},{1},{2},{3},{0,1},{0,2}{1,2},{0,1,2,3}}$

$|S|=n , |cal(P)(S)|=2^n$
$cal(P)(nothing)={nothing}$

== Cartesian products

Def: The (ordered) n-tuple $(a_1,a_2,...,a_n)$ is the ordered collection that has $a_i$ as its i'th element.

$(a_1,a_2,...,a_n)=(b_1,b_2,...,b_n) "if and only if" a_i=b_i forall i=1,2,...,n$ (n-tuples are equal if and only if their elements are the same and in the same order)

2-tuples are called ordered pairs

$(a,b) != (b,a)$ (unless $a=b$)

*Def:* Let A and B be sets. The cartesian product of A and B, denoted $A times B$, is the set of all ordered pairs (a,b) where $a in A$ and $b in B$

$A times B={(a,b)|a in A and b in B}$

Ex: $A={1,2}, B={a,b,c}$

$ A times B={(1,a), (1,b), (1,c), (2,a), (2,b), (2,c)} $

$A times B != B times A$ (unless $A=B$ or $A=nothing or B=nothing$)

=== Cartesian product of many sets
Def: The Cartesian product of $A_1,A_2,...,A_n$, denoted by $A_1 times A_2 times ... times A_n$ is the set of n-tuples ($a_i,a_2,...,a_n$) such that $a_i in A_i "for all" i=1,2,...,n$


*NOTE:* $A times (B times C) !=(A times B)times C !=A times B times C$

First one would be $((a,b),c)$, second one would be $(a,(b,c))$, third would be $(a,b,c)$.

$A²=A times A,space A³=A times A times A$, etc.

== Relations
A subset R of $A times B$ is called a relation from A to B.

A relation from A to itself is called a relation on A.

*Example*

$A={0,1,2,3}$

$ 
R&={(a,b)|a,b in A and a <=b} \
&={(0,0),(0,1),(0,2),(0,3),(1,1),(1,2),(1,3),(2,2),(2,3),(3,3)}
$