MAT2033 · 1. hafta · propositional logic, predicates and quantifiers

Önermeler mantığı, yüklemler ve niceleyiciler

Bağlaçlar, doğruluk tablosu, mantıksal denklik kanunları ve ∀/∃ ile çeviri ve olumsuzlama. Vizenin ilk sorusu neredeyse her zaman buradan gelir.

propositionconnectiveconditionalbiconditionalexclusive ortruth tabletautologycontradictioncontingencylogical equivalenceDe Morgan's lawsconverseinversecontrapositivepredicatedomain of discourseuniversal quantifierexistential quantifiercounterexample

Ayrık matematiğin dili mantıktır. Bu hafta öğrendiğin semboller dönem boyunca her ispatta, her küme sorusunda, her algoritmada karşına çıkacak. Vizede bu konudan gelen sorular mekaniktir: doğruluk tablosu kur, iki ifadenin denk olduğunu kanunlarla göster, İngilizce cümleyi sembole çevir, niceleyicili bir ifadeyi olumsuzla. Kurallar azdır ama tamamen oturmaları lazım.

Altın kurallar:

  1. p→qp \to q sadece pp doğru, qq yanlışken yanlıştır. Diğer üç satırın hepsi doğru.
  2. Tablo sırasını hiç değiştirme. 3 değişkende pp: TTTTFFFF, qq: TTFFTTFF, rr: TFTFTFTF.
  3. Her kanun adımında tek kanun kullan ve adını yaz. Hoca isim için puan verir.
  4. “Bütün” ok ister, “bazı” ve ister. ∀x (A→B)\forall x\,(A \to B), ∃x (A∧B)\exists x\,(A \land B).
  5. Olumsuzlarken niceleyici döner: ∀↔∃\forall \leftrightarrow \exists, sonra içerisi olumsuzlanır.

Önerme ve bağlaçlar

Önerme (proposition): ya doğru (T) ya yanlış (F) olan bildirme cümlesi. “7 asaldır” önermedir (doğru). "2+2=52 + 2 = 5" önermedir (yanlış). “Kapıyı kapat” ya da "x+1=3x + 1 = 3" önerme değildir: birincisi emir, ikincisinde xx belli olmadan doğru/yanlış söylenemez.

Önermeleri bağlaçlarla (connectives) birleştirirsin:

SembolAdıNe zaman doğru?
¬p\lnot pnegation (değil)pp yanlışken
p∧qp \land qconjunction (ve)ikisi de doğruyken
p∨qp \lor qdisjunction (veya, kapsayan)en az biri doğruyken
p⊕qp \oplus qexclusive or (ya … ya …)tam olarak biri doğruyken
p→qp \to qconditional (ise)p=T,q=Fp = T, q = F hariç her zaman
p↔qp \leftrightarrow qbiconditional (ancak ve ancak)ikisi aynı değerdeyken
ppqqp→qp \to qp↔qp \leftrightarrow qp⊕qp \oplus q
TTTTF
TFFFT
FTTFT
FFTTF

Koşullu önerme neden böyle?

p→qp \to q bir söz gibidir. Hoca “Ödevi teslim edersen 10 puan veririm” diyor. Hoca ancak tek durumda yalan söylemiş olur: ödevi teslim ettin (p=Tp = T) ve puanı alamadın (q=Fq = F). Teslim etmediysen (p=Fp = F) hoca ne yaparsa yapsın sözünü bozmuş sayılmaz, önerme doğru kalır. Buna “vacuously true” (boş yere doğru) denir.

TUZAK · pp yanlışsa p→qp \to q doğrudur. “Yanlış hipotezden her şey çıkar.” Tabloda p=Fp = F olan satırlar otomatik T. Bunu bilmek hesabı yarıya indirir.

Çeviri kalıpları

Sınavın sevdiği kalıplar; hepsi p→qp \to q ile ifade edilir:

İngilizceSembol
if pp, then qq / qq if pp / qq whenever ppp→qp \to q
pp only if qqp→qp \to q
pp is sufficient for qq / qq is necessary for ppp→qp \to q
qq unless pp¬p→q\lnot p \to q (yani p∨qp \lor q)
pp if and only if qq / pp iff qqp↔qp \leftrightarrow q

“Only if” en çok karıştırılan kalıp. “Sınava girersin only if kimliğin varsa” = sınava girdiysen kimliğin kesin vardır: “girdin” →\to “kimliğin var”. Kimliğin olması girmeyi garanti etmez.

Converse, inverse, contrapositive

p→qp \to q için üç akraba:

  • converse: q→pq \to p
  • inverse: ¬p→¬q\lnot p \to \lnot q
  • contrapositive: ¬q→¬p\lnot q \to \lnot p

Sadece contrapositive orijinale denktir. Converse ile inverse de birbirine denktir ama orijinale değil. “Yağmur yağarsa zemin ıslanır” doğru. Converse “zemin ıslaksa yağmur yağmıştır” yanlış olabilir (biri su dökmüştür). Contrapositive “zemin kuruysa yağmur yağmamıştır” ise orijinalle aynı bilgiyi verir.

Doğruluk tablosu kurma

Şablon:

  1. Değişken say: nn değişken varsa 2n2^n satır.
  2. Sütunları standart sırayla doldur (yukarıdaki altın kural 2).
  3. İfadeyi içten dışa parçala, her parça için ara sütun aç.
  4. Son sütuna bak: hepsi T ise tautology, hepsi F ise contradiction, karışıksa contingency.

Örnek. (p∧¬r)→(q∨r)(p \land \lnot r) \to (q \lor r)

ppqqrr¬r\lnot rp∧¬rp \land \lnot rq∨rq \lor rsonuç
TTTFFTT
TTFTTTT
TFTFFTT
TFFTTFF
FTTFFTT
FTFTFTT
FFTFFTT
FFFTFFT

Son sütunda bir F var, geri kalanı T: contingency. Hızlı kontrol: ok sadece “sol T, sağ F” iken F olur. Sol tarafın T olduğu satırlar (p=T,r=Fp=T, r=F) sadece 2. ve 4. satır; bunlardan sağ tarafı F olan yalnız 4. satır.

Mantıksal denklik (logical equivalence)

AA ve BB her satırda aynı değeri alıyorsa denktir: A≡BA \equiv B. Başka bir deyişle A↔BA \leftrightarrow B bir tautology’dir. İki yolla gösterirsin: doğruluk tablosu ya da kanun zinciri.

KanunFormül
Conditionalp→q≡¬p∨qp \to q \equiv \lnot p \lor q
De Morgan¬(p∧q)≡¬p∨¬q\lnot(p \land q) \equiv \lnot p \lor \lnot q, ¬(p∨q)≡¬p∧¬q\lnot(p \lor q) \equiv \lnot p \land \lnot q
Double negation¬¬p≡p\lnot\lnot p \equiv p
Distributivep∧(q∨r)≡(p∧q)∨(p∧r)p \land (q \lor r) \equiv (p \land q) \lor (p \land r), p∨(q∧r)≡(p∨q)∧(p∨r)p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)
Negationp∨¬p≡Tp \lor \lnot p \equiv T, p∧¬p≡Fp \land \lnot p \equiv F
Identityp∧T≡pp \land T \equiv p, p∨F≡pp \lor F \equiv p
Dominationp∨T≡Tp \lor T \equiv T, p∧F≡Fp \land F \equiv F
Idempotentp∨p≡pp \lor p \equiv p, p∧p≡pp \land p \equiv p
Commutative, associativep∨q≡q∨pp \lor q \equiv q \lor p, (p∨q)∨r≡p∨(q∨r)(p \lor q) \lor r \equiv p \lor (q \lor r)
Absorptionp∨(p∧q)≡pp \lor (p \land q) \equiv p, p∧(p∨q)≡pp \land (p \lor q) \equiv p
Biconditionalp↔q≡(p→q)∧(q→p)p \leftrightarrow q \equiv (p \to q) \land (q \to p)

Zincir stratejisi: önce okları conditional kanunuyla ∨\lor‘a çevir, sonra parantez önündeki ¬\lnot‘leri De Morgan ile içeri it, ¬¬\lnot\lnot‘leri sil, en son dağılma ve sadeleştirme.

Örnek 1. Show that (p→q)∨(p→r)≡p→(q∨r)(p \to q) \lor (p \to r) \equiv p \to (q \lor r).

(p → q) ∨ (p → r)
≡ (¬p ∨ q) ∨ (¬p ∨ r)        conditional law (twice)
≡ (¬p ∨ ¬p) ∨ (q ∨ r)        commutative and associative laws
≡ ¬p ∨ (q ∨ r)               idempotent law
≡ p → (q ∨ r)                conditional law   ∎

Örnek 2. Show that ¬(p∨¬q)∨(¬p∧¬q)≡¬p\lnot(p \lor \lnot q) \lor (\lnot p \land \lnot q) \equiv \lnot p.

¬(p ∨ ¬q) ∨ (¬p ∧ ¬q)
≡ (¬p ∧ ¬¬q) ∨ (¬p ∧ ¬q)     De Morgan's law
≡ (¬p ∧ q) ∨ (¬p ∧ ¬q)       double negation law
≡ ¬p ∧ (q ∨ ¬q)              distributive law (ortak ¬p dışarı)
≡ ¬p ∧ T                     negation law
≡ ¬p                         identity law   ∎

İPUCU · Denk DEĞİL demek için tablo kurma. Tek bir satır bul, iki taraf farklı çıksın. “For p=F,q=Tp = F, q = T the left side is T and the right side is F” cümlesi tam puan.

Yüklemler ve niceleyiciler

"x>3x > 3" bir önerme değil, çünkü xx belli değil. Buna yüklem (predicate) denir: P(x)P(x). xx‘e değer verince önerme olur: P(5)P(5) doğru, P(1)P(1) yanlış. xx‘in alabileceği değerler kümesine domain (domain of discourse) denir. Domain verilmeden niceleyicili bir ifadenin doğruluğu belirlenemez.

İfadeAnlamıNe zaman doğru?Ne zaman yanlış?
∀x P(x)\forall x\, P(x)her xx için P(x)P(x)domain’deki her eleman sağlıyorsatek bir karşı örnek (counterexample) varsa
∃x P(x)\exists x\, P(x)en az bir xx için P(x)P(x)tek bir örnek varsahiçbir eleman sağlamıyorsa

Sonlu domain’de niceleyiciler büyük birer “ve”/“veya”dır. Domain {1,2,3}\{1, 2, 3\} ise ∀x P(x)≡P(1)∧P(2)∧P(3)\forall x\,P(x) \equiv P(1) \land P(2) \land P(3) ve ∃x P(x)≡P(1)∨P(2)∨P(3)\exists x\,P(x) \equiv P(1) \lor P(2) \lor P(3). Bu yüzden niceleyicinin olumsuzlanması De Morgan’ın ta kendisidir:

¬∀x P(x)≡∃x ¬P(x)¬∃x P(x)≡∀x ¬P(x)\lnot \forall x\, P(x) \equiv \exists x\, \lnot P(x) \qquad \lnot \exists x\, P(x) \equiv \forall x\, \lnot P(x)

“Herkes geçti” yanlışsa, “geçemeyen biri var” demektir. “Hiç kimse geçmedi” demek değildir.

Domain etkisi: ∃x (2x=1)\exists x\,(2x = 1) reel sayılarda doğru (x=12x = \tfrac12), tam sayılarda yanlış. Niceleyiciler ¬\lnot dışında bütün bağlaçlardan önce bağlanır: ∀x P(x)∧Q(x)\forall x\, P(x) \land Q(x), (∀x P(x))∧Q(x)(\forall x\, P(x)) \land Q(x) demektir.

Çeviri: ok mu, ve mi?

Domain bütün insanlar, A(x)A(x): ”xx bir sporcu”, S(x)S(x): ”xx öğrenci”.

CümleDoğruYanlış (neden)
All athletes are students.∀x (A(x)→S(x))\forall x\,(A(x) \to S(x))∀x (A(x)∧S(x))\forall x\,(A(x) \land S(x)): “herkes sporcu ve öğrenci” der
Some athletes are students.∃x (A(x)∧S(x))\exists x\,(A(x) \land S(x))∃x (A(x)→S(x))\exists x\,(A(x) \to S(x)): sporcu olmayan biri yüzünden otomatik doğru olur
No athlete is a student.∀x (A(x)→¬S(x))\forall x\,(A(x) \to \lnot S(x))
Not all athletes are students.∃x (A(x)∧¬S(x))\exists x\,(A(x) \land \lnot S(x))

İkinci satırdaki tuzağın sebebi koşullu önermenin boş doğruluğu: domain’de sporcu olmayan tek bir kişi A(x)→S(x)A(x) \to S(x)‘i doğru yapar, cümle hiçbir şey söylememiş olur.

Çözümlü örnek: olumsuzlama

“Every student who studies passes.” S(x)S(x): studies, P(x)P(x): passes.

∀x (S(x) → P(x))                    orijinal
¬∀x (S(x) → P(x))                   olumsuzla
≡ ∃x ¬(S(x) → P(x))                 niceleyici döner
≡ ∃x (S(x) ∧ ¬P(x))                 ¬(a → b) ≡ a ∧ ¬b

İngilizcesi: “There is a student who studies but does not pass.” Olumsuzlamayı “Not every student who studies passes” diye bırakma; soru genelde “no negation in front of a quantifier” ister.

Sık yapılan hatalar

Yanlış düşünceDoğrusu
pp yanlışsa p→qp \to q yanlıştırDoğrudur. Ok sadece T→FT \to F iken yanlış
”pp only if qq” = q→pq \to pp→qp \to q
”qq unless pp” = p→qp \to q¬p→q\lnot p \to q
Converse orijinale denktirSadece contrapositive denktir
¬(p∧q)≡¬p∧¬q\lnot(p \land q) \equiv \lnot p \land \lnot q¬p∨¬q\lnot p \lor \lnot q; ∧\land ile ∨\lor yer değiştirir
¬∀x P(x)≡∀x ¬P(x)\lnot \forall x\,P(x) \equiv \forall x\,\lnot P(x)∃x ¬P(x)\exists x\,\lnot P(x); niceleyici de döner
“Some A are B” = ∃x (A→B)\exists x\,(A \to B)∃x (A∧B)\exists x\,(A \land B)
“All A are B” = ∀x (A∧B)\forall x\,(A \land B)∀x (A→B)\forall x\,(A \to B)
Birkaç örnek denedim, ∀\forall doğru∀\forall örnekle ispatlanmaz; ama tek karşı örnek onu yıkar
Domain’e bakmadan cevap vermekAynı ifade R\mathbb{R}‘de doğru, Z\mathbb{Z}‘de yanlış olabilir

Kendini test et

Sınavdaki gibi İngilizce sorular. Önce kâğıt kalemle çöz, sonra cevabı aç.

Soru 1kolay

Let pp be true, qq be false and rr be true. Find the truth value of (p∨q)→(¬r∧q)(p \lor q) \to (\lnot r \land q).

Cevabı göster
False

Sol taraf: p∨q=T∨F=Tp \lor q = T \lor F = T. Sağ taraf: ¬r∧q=F∧F=F\lnot r \land q = F \land F = F. Ok sadece T→FT \to F iken yanlış: T→F=FT \to F = F.

Soru 2kolay

Let gg: "you can use the gym", ss: "you are a student", tt: "you are staff". Write in symbols: "You can use the gym only if you are a student or staff."

Cevabı göster
g→(s∨t)g \to (s \lor t)

"p only if q" kalıbı p→qp \to q demektir: spor salonunu kullanıyorsan kesin öğrenci ya da personelsin. Sonuç kısmı s∨ts \lor t. Ters yön ((s∨t)→g(s \lor t) \to g) yazmak klasik hata.

Soru 3kolay

Write the converse and the contrapositive of: "If nn is divisible by 6, then nn is even." Which of the two is always equivalent to the original?

Cevabı göster
Converse: if n is even, then n is divisible by 6. Contrapositive: if n is not even, then n is not divisible by 6. The contrapositive.

pp: "6 divides n", qq: "n is even". Converse q→pq \to p (yön değişir), contrapositive ¬q→¬p\lnot q \to \lnot p (yön değişir ve ikisi de olumsuzlanır). Sadece contrapositive orijinale denktir. Converse burada yanlış bile: n=4n = 4 çift ama 6'ya bölünmez.

Soru 4orta

Construct the truth table of (p→q)→(q→p)(p \to q) \to (q \to p). Is it a tautology, a contradiction or a contingency?

Cevabı göster
Contingency (false only when p = F, q = T)

Satırlar TT, TF, FT, FF. p→qp \to q: T, F, T, T. q→pq \to p: T, T, F, T. Dış ok: T→T=TT\to T = T, F→T=TF \to T = T, T→F=FT \to F = F, T→T=TT \to T = T. Son sütun TTFT: hem T hem F var, yani contingency.

Soru 5orta

In how many rows of its truth table is (p⊕q)∧(q∨r)(p \oplus q) \land (q \lor r) true?

Cevabı göster
3

8 satır. p⊕qp \oplus q sadece pp ile qq farklıyken T: TF* ve FT* satırları (4 satır). Bunlardan q∨rq \lor r de T olanlar: TFT (r=Tr=T), FTT, FTF (q=Tq=T). TFF satırında q∨r=Fq \lor r = F. Toplam 3 satır.

Soru 6orta

Using the laws of logic (name each law), show that ¬(p→q)→p\lnot(p \to q) \to p is a tautology.

Cevabı göster
It is equivalent to T, so it is a tautology.

¬(p→q)→p≡¬¬(p→q)∨p\lnot(p\to q) \to p \equiv \lnot\lnot(p \to q) \lor p (conditional law)≡(p→q)∨p\equiv (p \to q) \lor p (double negation)≡(¬p∨q)∨p\equiv (\lnot p \lor q) \lor p (conditional law)≡(p∨¬p)∨q\equiv (p \lor \lnot p) \lor q (commutative + associative)≡T∨q\equiv T \lor q (negation law)≡T\equiv T (domination law). Her adımda tek kanun, adıyla.

Soru 7zor

Are p→(q→r)p \to (q \to r) and (p→q)→r(p \to q) \to r logically equivalent? Justify.

Cevabı göster
No. For p = F, q = F, r = F the first is T and the second is F.

Denk değil demek için tek satır yeter. p=Fp = F alınca p→(q→r)p \to (q \to r) otomatik T. Öbür tarafta p→q=Tp \to q = T olur; r=Fr = F seçersek (p→q)→r=T→F=F(p\to q) \to r = T \to F = F. Farklı değer, denk değiller. (Doğrulama: farklı çıkan satırlar FTF ve FFF.)

Soru 8kolay

Let Q(x)Q(x) be "x2−5x+6=0x^2 - 5x + 6 = 0", the domain being all integers. Find the truth values of ∃x Q(x)\exists x\, Q(x) and ∀x Q(x)\forall x\, Q(x).

Cevabı göster
∃x Q(x) is true, ∀x Q(x) is false

x2−5x+6=(x−2)(x−3)x^2 - 5x + 6 = (x-2)(x-3). x=2x = 2 sağlar, o yüzden ∃x Q(x)\exists x\,Q(x) doğru (tek örnek yeter). ∀\forall için tek karşı örnek yeter: x=0x = 0 için 6≠06 \ne 0, yanlış.

Soru 9orta

The domain is {1,2,3,4}\{1, 2, 3, 4\}. Determine the truth values of (a) ∀x (x is odd→x2<10)\forall x\,(x \text{ is odd} \to x^2 < 10) and (b) ∃x (x is even∧x2>15)\exists x\,(x \text{ is even} \land x^2 > 15).

Cevabı göster
(a) true, (b) true

(a) Tek olanlara bakmak yeter (çift olanlarda ok otomatik T): 12=1<101^2 = 1 < 10, 32=9<103^2 = 9 < 10. Hepsi tutuyor, doğru.
(b) Çift olan ve karesi 15'ten büyük biri lazım: x=4x = 4, 16>1516 > 15. Doğru.

Soru 10orta

Let M(x)M(x): "xx misses practice" and B(x)B(x): "xx is benched", the domain being the players of a team. Express "Every player who misses practice is benched" in logic, then write its negation with no negation sign in front of a quantifier, and say it in English.

Cevabı göster
∀x (M(x) → B(x)); negation: ∃x (M(x) ∧ ¬B(x)), "Some player misses practice but is not benched."

"Every ... who ..." kalıbı ∀\forall ve ok ister: ∀x (M(x)→B(x))\forall x\,(M(x) \to B(x)). Olumsuzlama: ¬∀x (… )≡∃x ¬(M(x)→B(x))\lnot\forall x\,(\dots) \equiv \exists x\,\lnot(M(x)\to B(x)), sonra ¬(a→b)≡a∧¬b\lnot(a \to b) \equiv a \land \lnot b. Sonuç ∃x (M(x)∧¬B(x))\exists x\,(M(x) \land \lnot B(x)).

Soru 11zor

Let S(x)S(x): "xx is a student" and L(x)L(x): "xx is lazy", the domain being all people. Express "No student is lazy" in two equivalent ways, one using ∀\forall and one using ∃\exists.

Cevabı göster
∀x (S(x) → ¬L(x)) and ¬∃x (S(x) ∧ L(x))

"Hiçbir öğrenci tembel değil" = "tembel bir öğrenci yok": ¬∃x (S(x)∧L(x))\lnot\exists x\,(S(x) \land L(x)). Olumsuzlamayı içeri itince ∀x ¬(S(x)∧L(x))≡∀x (¬S(x)∨¬L(x))≡∀x (S(x)→¬L(x))\forall x\,\lnot(S(x)\land L(x)) \equiv \forall x\,(\lnot S(x) \lor \lnot L(x)) \equiv \forall x\,(S(x) \to \lnot L(x)). İkisi aynı şeyi söyler.

Soru 12zor

Determine the truth value of ∀x (x2≥x)\forall x\,(x^2 \ge x) when the domain is (a) all real numbers, (b) all integers.

Cevabı göster
(a) false, (b) true

(a) Karşı örnek x=12x = \tfrac12: 14≥12\tfrac14 \ge \tfrac12 yanlış. Tek örnek ∀\forall'ı yıkar.
(b) x2−x=x(x−1)x^2 - x = x(x-1). Tam sayılarda x≤0x \le 0 ise iki çarpan da ≤0\le 0, x≥1x \ge 1 ise ikisi de ≥0\ge 0; çarpım hep ≥0\ge 0. Doğru. Aynı cümle, farklı domain, farklı cevap.

Doğrulama: Bütün doğruluk tabloları, denklikler ve niceleyici doğruluk değerleri node ile kaba kuvvetle (bütün satırlar / sonlu tanım kümesi ve -1000..1000 taraması) kontrol edildi (verify/MAT2033/01.mjs).

Deftere not kartı

p→q sadece T→F iken F. p↔q aynıysa T. p⊕q farklıysa T. p→q ≡ ¬p∨q ¬(p→q) ≡ p∧¬q p↔q ≡ (p→q)∧(q→p) De Morgan: ¬(p∧q) ≡ ¬p∨¬q ¬(p∨q) ≡ ¬p∧¬q "p only if q" = p→q "q if p" = p→q "q unless p" = ¬p→q "p sufficient for q" = p→q "q necessary for p" = p→q converse q→p, inverse ¬p→¬q, contrapositive ¬q→¬p (sadece bu denk) n değişken → 2^n satır; p: TTTTFFFF, q: TTFFTTFF, r: TFTFTFTF hepsi T tautology, hepsi F contradiction, karışık contingency Denk değil göstermek: farklı çıkan TEK satır yeter ∀: bir karşı örnek yanlış yapar. ∃: bir örnek doğru yapar. ¬∀x P(x) ≡ ∃x ¬P(x) ¬∃x P(x) ≡ ∀x ¬P(x) "All A are B" = ∀x (A(x)→B(x)) "Some A are B" = ∃x (A(x)∧B(x)) Domain değişirse cevap değişir: ∃x(2x=1) R'de T, Z'de F