You are on page 1of 29

Discrete Mathematics (Ayrk Matematik)

Do.Dr.Banu DR e-mail: banu@ce.yildiz.edu.tr veya diri@yildiz.edu.tr


http://www.ce.yildiz.edu.tr/personal/banud

Kaynaklar Discrete Mathematics and Its Applications Kenneth H.Rosen, McGraw Hill

Konular
1. Logic and Proof * propositions (nermeler) * conditional propositions (artl nermeler) * logical equivalence (mantksal denklik) * quantifiers (nicelikler) * proof 2. The Language of Mathematics * sets (kmeler) * sequences and strings (diziler) * number systems * relations (ilikiler) * equivalence relations (eitlik bantlar) * matrices of relations * functions

3. Algorithms * different algorithms 4. Graph Theory * path and cycles * hamiltonian cycles * a shortest-path algorithm * isomorphisms of graph 5. Trees * terminology and characterizations of tree * spanning tree * binary tree * tree traversals * isomorphisms tree 6. Choromatic polinomial

7. Boolean Algebras and Combinatorial Circuit 8. Automata, Grammars and Language * finite-state automata (sonlu durum makineleri) * language and grammars * nondeterministic finite-state automata

Blm 1 Mantk ve spatlar (Logic and Proofs)

Mantk (Logic)
Mantk (Logic) = doru karm elde etme almasdr Mantn kullanm
Matematikte kullanm:
Teoremleri ispatlamak

Bilgisayar Bilimlerinde kullanm:


Programlarn kendilerinden beklenen sonucu retip retmediinin kontroldr

nermeler (Propositions)
Sonucu doru (true) veya yanl (false) olan ifadelere proposition (nerme) denir. rnekler:
Cneyt programcdr" bu bir nermedir Keke bilge kii olsaydm bu bir nerme deildir

Birletiriciler (Connectives)
nermeleri (propositions) gstermek iin p,q,r,s,t,... gibi deikenler kullanlr. En ok kullanlan birletiriciler:
Conjunction AND Inclusive disjunction OR Exclusive disjunction OR Negation Implication Double implication Sembol ^ Sembol v Sembol v Sembol ~ Sembol Sembol

AND (conjunction) doruluk tablosu


p ve q bir nerme ise, conjunction (p ^ q ) veya (p and q) olarak gsterilir Conjunction doruluk tablosu
p T T F F q T F T F p^q T F F F

Sadece p ve q nun her ikisinin de doru olduu durumda p ^ q dorudur

rnek
p = kaplan vahi bir hayvandr q = balina bir srngendir p ^ q = " kaplan vahi bir hayvandr and balina bir srngendir " p ^ q yanltr. Neden?

OR (disjunction) doruluk tablosu


p ve q bir nerme ise, disjunction (p v q ) veya (p or q) olarak gsterilir
Disjunction doruluk tablosu p T T F F q T F T F pvq T T T F

Sadece p ve q nun her ikisinin de yanl olduu durumda p q yanltr


rnek: p = Cneyt programcdr", q = Zeynep avukattr" p v q = " Cneyt programcdr or Zeynep avukattr "

Exclusive disjunction OR(XOR)


p ve q bir nerme ise, exclusive disjunction OR (xor) p q olarak gsterilir
Exclusive disjunction doruluk tablosu p T T F F q T F T F pvq F T T F

Sadece p doru ve q yanl ise, veya p yanl ve q doru ise p q dorudur


rnek: p = Cneyt programcdr, q = Zeynep avukattr p v q = Ne Cneyt programcdr ne de Zeynep avukattr"

Tersi (Negation)
p nin tersi: ~p veya p ile gsterilir
p T F ~p F T

p doru iken ~p yanltr p yanl iken ~p dorudur


rnek: p = Cneyt programcdr" ~p = Cneyt programc deildir"

Birden Fazla nermenin Birletirilmesi


p, q, r basit nermeler olsun Birletirilmi ifadeleri aadaki gibi gsterebiliriz
(pq)^r p(q^r) (~p)(~q) (pq)^(~r) ve dier durumlar

rnek: (pq)^r nin doruluk tablosu


p T T T T F F F F q T T F F T T F F r T F T F T F T F (p q) ^ r T F T F T F F F

artl nermeler ve Mantksal Denklik (Conditional Propositions and Logical Equivalence)


artl nerme (conditional proposition) If p then q eklinde gsterilir Sembol: p q
rnek:
p = " Cneyt programcdr" q = " Zeynep avukattr " p q = If Cneyt programcdr then Zeynep avukattr"

p q nun Doruluk Tablosu


p T T F F q T F T F pq T F T T

Sadece p ve q nun her ikiside doru veya pnin yanl olduu durumlarda p q nermesi dorudur

Hipotez ve Sonu (Hypothesis and conclusion)


p q artl nermesinde p antecedent veya hypothesis q consequent or conclusion olarak adlandrlr. if p then q" mantksal olarak "p only if q ile ayndr

Gereklilik ve Yeterlilik (Necessary and Sufficient)


Gerekli art (necessary condition) sonu (conclusion) tarafndan ifade edilir Yeterli art (sufficient condition) hipotez (hypothesis) tarafndan ifade edilir
rnek: If Cneyt programcdr then Zeynep avukattr" Necessary condition: Zeynep avukattr Sufficient condition: Cneyt programcdr

Mantksal Denklik (Logical Equivalence)


Doruluk tablosundaki deerleri ayn olan iki nerme iin aralarnda mantksal denklik vardr denir
p T T F F q T F T F ~p q T F T T pq T F T T

rnek: ~p q nermesi p q ile logically equivalent dr. Yani aralarnda mantksal denklik vardr

10

Yer deitirme (Converse)


p qnun converse q p dir
p T T F F q T F T F pq T F T T qp T T F T

Bu iki nerme arasnda mantksal denklik mevcut deildir ( not logically equivalent)

Contrapositive (Devrik)
p q nermesinin contrapositive ~q ~p eklinde gsterilir
p T T F F q T F T F pq T F T T ~q ~p T F T T

Bu nermeler logically equivalentdr

11

ift Ynl nerme (Biconditional Proposition)


ift Ynl nerme (biconditional proposition) p if and only if q olarak tanmlanr p q sembol ile gsterilir p T T F F q T F T F pq T F F T (p q) ^ (q p) T F F T

p q, (p q)^(q p) nun logically equivalentdr

Totoloji-Tutarllk (Tautology)
Eer doruluk tablosunda nermelerin her bir durumu iin doru sonu (true) elde edilmi ise, birletirilmi nerme (compound proposition) bir tautology dir rnek: p p v q
p T T F F q T F T F ppvq T T T T

12

eliki (Contradiction)
Eer doruluk tablosunda nermelerin her bir durumu iin yanl sonu (false) elde edilmi ise, birletirilmi nerme (compound proposition) bir contradiction dr rnek: p ^ ~p
p T F p ^ (~p) F F

De Morgan Kanunu
Aadaki nerme iftleri birbirleri ile mantksal olarak denktir ~ (p q) (~p)^(~q) ~ (p ^ q) (~p) (~q)

13

Nicelikler (Quantifiers)
P(x), x deikeni ile ilikili bir propositional fonksiyon olsun
rnein, P(x): 2x ift tamsay

Dde ierisindeki her x deeri iin, P(x)i proposition yapan bir kme olsun
rnein: x, tamsaylar kmesinin bir elemandr

D, P(x)nin domain of discourseu olarak adlandrlr (ayrntl bilgi alan)

Ddeki her x deeri, P(x)i sonucu doru veya yanl olan bir proposition yapar
rnein: P(n): n2+2n tek saydr D kmesinin pozitif integer saylardan olusun if n tek say then n2+2n tek saydr if n ift say then n2+2n tek say deildir Bu snftakiler 18 yandan byktr D kmesi, snftaki renciler olsun rencilerin bazlar proposition doru, bazlar da yanl yapar

14

Her ve Baz (For every and for some)


Matematik ve Bilgisayar Bilimlerindeki ou ifadede for every ve for some kullanlr rnein:
For every triangle T, the sum of the angles of T is 180 degrees.

Evrensel/Genel Niteliyiciler (Universal Quantifier)


The universal quantification of P(x) is the proposition P(x) is true for all values of x in the universe of discourse.
P(x) nermesi, D kmesi ierisindeki her x deeri iin doru olmaldr. x P(x) veya for all x P(x) veya for every x P(x) eklinde yazlr

En az bir x deeri iin doru deilse, P(x) yanl olur


Every student in this class has studied calculus P(x) x has studied calculus

x P(x)

15

When all of the elements in the universe of discourse can be listed x1, x2,...,xn it follows that the universal quantification x P(x) is the same as the conjunction P(x1)P(x2) ... P(xn), since the conjunction is true if and only if P(x1), P(x2),...,P(xn) are all true.

Propositional fonksiyonun doruluu


x P(x) ifadesi
Dorudur. Eer P(x) doruysa for every x D Yanltr. Eer P(x) doru deilse for some x D

rnein: P(n) propositional bir fonksiyon ve P(n): n2 + 2n tek bir saydr. n D = {btn tam saylar} P(n) sadece n tek say olduunda dorudur. P(n) n ift say ise yanltr

16

For every real number x, x2 0

TRUE

For every real number x, if x >1 then x+1>1 TRUE For every real number x, if x 0 then x+1>1 FALSE For every positive integer n, if n is even then n2+n+19 prime
FALSE

Varolusal Niteleyiciler (Existential Quantifier)


The existential quantification of P(x) is the proposition There exists an element x in the universe of discourse such that P(x) is true
P(x) nermesi, D kmesi ierisindeki en az bir x deeri iin doru olmaldr. x P(x) veya There is an x such that P(x) veya There is at least one x such that P(x) eklinde yazlr.

Btn x deerleri iin doru ise, P(x) yanl olur

17

When all of the elements in the universe of discourse can be listed x1, x2,...,xn the existential quantification x P(x) is the same as the disjunction P(x1)vP(x2)v ... vP(xn), since this disjunction is true if and only if at least one of P(x1), P(x2),...,P(xn) is true.

For some real number x, x/(x2+1) = 2/5

TRUE

For some positive integer n, if n is prime then n+1, n+2, n+3 and n+4 are not prime TRUE n=23

18

Translating Sentences into Logical Expressions


Express the statement Everyone has exactly one best friend as logical expression.
Let B(x,y) be the statement y is the best friend of x. To translate the sentence in the example, note that it says that for every person x there is another person y such that y is the best friend of x and that if z is a person other than y, then z is not the best friend of x. We can translate the sentence into

xyz (B ( x, y ) (( z y ) B ( x, z )))

Express the statement If somebody is female and is a parent, then this person is someones mother as logical expression.

Let F(x) be the statement x is female, let P(x) be the statement x is a parent, and let M(x,y) be the statement x is the mother of y. Since the statement in the example pertains to all people, we can write it symbolically as

x(( F ( x ) P ( x )) yM ( x, y ) )

19

Counterexample
Eer x D, P(x)i yanl yaparsa universal statement x P(x)de yanl olur x P(x) ifadesindeki, P(x) yanl yapan x deeri counterexample olarak adlandrlr
rnek: P(x) = her x deeri bir asal saydr", for every tamsay x. Fakat eer x = 4 (bir tamsay) bu x says asal say deildir. yleyse 4 deeri bir counterexample olup P(x)i yanl yapar

Lojik iin Genelletirilmi De Morgan Kanunu


~(x P(x)) x ~P(x) ~(x P(x)) x ~P(x)

20

Every student in the class has taken a course in calculus This statement is a universal quantification, namely, x P(x), Where P(x) is the statement x has taken a course in calculus. The negation of this statement is, It is not the case that every student in the class has taken a course in calculus. This is equivalent to, There is a student in the class who has not taken a course in calculus. And this is simply the existential quantification of the negation of the original propositional function, namely x ~P(x) This example illustrates the following equivalence: ~x P(x) x ~P(x)

Suppose we wish to negate an existential quantification. For instance, consider the proposition There is a student in this class who has taken a course in calculus. This is the existential quantification x Q(x), Where Q(x) is the statement x has taken a course in calculus. The nagation of this statement is the proposition It is not the case that there is a student in this class who has taken a course in calculus. This is equivalent to, Every student in this class has not taken calculus, which is just the universal quantification of the nagation of the original propositional function, x ~Q(x)

21

Negating Quantifiers Negation Equivalent Statement When is negation true? When false?

P(x) is false for every x

xP( x )

xP( x)
There is an x for which P(x) is false

There is an x for which P(x) true

P(x) is true for every x

xP( x)

xP( x )

karsama Kurallar (Rules of Inference)


Doruluu varsaylan ya da kantlanm nermeleri ieren bir kmeden yola karak bu kme dndaki bir nermenin doruluuna varma. karsama kurallarnn gsterilimi
p1 p2 ... pn

q p1 ^ p2 ^ ^ pn q

22

ekleme
P

Basitletirme p^q

modus ponens pq p

p q

pq q

modus tollens

rnek Ali piyangoyu kazanrsa araba alacak. Ali piyangoyu kazand. O halde, Ali araba alacak.

rnek Ali piyangoyu kazanrsa araba alacak. Ali araba almad. O halde, Ali piyangoyu kazanmad.

Sonucu Onaylama Yanlgs pq q

ncl Yadsma Yanlgs pq p

pq ^ p q bir totoloji deil: p = Y , q = D ise: (Y D) ^ D Y

(pq ) ^ q p bir totoloji deil: p = Y , q = D ise: (Y D) ^ D Y rnek Madonna A.B.D. bakanysa 35 yann stndedir. Madonna 35 yann stndedir. O halde, Madonna A.B.D. bakandr. rnek 2 + 3 = 8 ise 2 + 4 = 6 2+38 O halde, 2 + 4 6

23

ayrc kyas pq p

varsayml kyas pq qr

rnek

q rnek

pr

Alinin czdan cebinde veya masasnda. Alinin czdan cebinde deil. O halde, Alinin czdan masasnda. yapc ikilem pq rs pr

396|35244 66|35244 66|35244 3|35244 O halde, 396|35244 3|35244 ykc ikilem pq rs q s

qs

p r

Akl Yrtme rnei rnek pr rs t s t u u p

Akl Yrtme rnei rnek (p q) (r ^ s) rt t p

pr rs ps t s s t st pt t u tu pu u p

(1, 2, VK) (4, degisme) (5, ise) (3, 6, VK) (8, ise) (7, 9, VK) (10, 11, MT)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11)

rt t r r s (r ^ s) (p q) (r ^ s) (p q) p^q p

(1) (2) (1, 2, MT) (3) (3, ekleme) (4) (4, DM) (5) (6) (6, 5, MT) (7) (7, DM) (8) (8, basitlestirme)

24

spatlar (Proofs)

Bir matematik sistemi Tanmlanmam terimler (Undefined terms) Tanmlar (Definitions) Aksiyomlar (Axioms)

Tanmlanmam Terimler (Undefined Terms)


Tanmlanmam terimler bir matematik sisteminin temel tan oluturur. Bu terimler bir matematiksel sistemin balang kavramlar olarak da kabul edilebilir.
rnek: Euclidean geometride tanmlanmam terimler Nokta (Point) Doru (Line)

25

Tanmlar (Definitions)
Tanm (definition), yeni bir kavram yaratmak amacyla nceden kabul edilmi kavramlar ve tanmlanmam terimlerden bir proposition oluturmaktr
rnek: Euclidean geometrideki tanmlar: Eer iki genin karlkl kenarlar ve alar birbirinin ayn ise bu iki gen e gendir ki ann toplam 180 derece ise bu alara birbirini tamamlayan alar denir

Aksiyomlar (Axioms)
Aksiyom (axiom), matematiksel bir sistem ierisinde ispat yapmakszn doru kabul edilen propositiondr Matematikteki aksiyomlara rnek:
rnek: Euclidean geometrideki aksiyomlar
ki nokta verilmi olsun. Bu noktalardan geen bir doru her zaman mevcuttur. Bir doru ve doru zerinde yer almayan bir nokta mevcut olsun. Bu noktadan geen dorularn bir tanesi verilen doruya mutlaka paraleldir.

26

Teoremler (Theorems)

Teorem, nceden ispatlanm teoremleri, aksiyomlar, tanmlamalar kullanarak ve p nin doru olduunu farzederek doruluu nerilebilen p q formundaki propositiona denir

Lemma(yardmc teorem/n sav) ve Corollary (bir nermenin doru sonucu) Lemma, byk bir teoremi ispatlamak iin kullanlan kk bir teoremdir Corollary, bir baka teoremin mantksal sonucu ile dier bir teoremin ispatlamasdr
Euclidean geometriden rnek : Eer bir genin, kenar eit ise alarda eittir."

27

spat eitleri
spat (proof), Teoremin doruluunu belirlemek iin propositionlar kullanan bir seri ilemden oluan mantksal karmdr Dorudan ispat (Direct proof): p q
q nermesinin doruluunu elde etmek amacyla ispatlanm teoremleri, aksiyomlar ve p nermesinin doruluunu kabul ederek zme ulamadr

Dolayl ispat (Indirect proof): (~q)(~p) p q nermesinin elikisinden zme ulamaktr

Matemaiksel sonu karma (Mathematical induction)


n A S(n) formundaki ifadenin ispatna bakalm * N, pozitif tamsaylar veya doal saylardan oluan bir kme * A, Nnin bir alt kmesi * S(n) propositional bir fonksiyon

28

Her pozitif tamsaynn, S(n) nermesini doru veya yanl yaptn farzedelim
1. S(1) doru olduunu teyit et 2. n keyfi seilmi pozitif bir tamsay olsun i pozitif bir tamsay olup, i < n olarak belirle 3. S(i) nin doruluundan yola karak S(i+1)in doru olduunu gster S(i) S(i+1) 4. Sonu olarak, tm pozitif tamsaylar iin S(n) dorudur

Matematiksel sonu karm: terminoloji


Temel adm (basis step): S(1) in doruluunun gsterilmesi Tmevarmsal adm (Inductive step): S(i)nin doru farzedilmesi spat S(i) S(i+1) if S(i) is true, for all i<n+1, then S(n+1) is true Sonu (Conclusion): Btn pozitif tamsaylar iin S(n)nin doruluu

29

You might also like