01 Logic

Updated 4 Oct 2026

  • Logic is ”the study of reasoning”

Propositions

  • A proposition (ประพจน์) is a declarative sentence that is either TRUE or FALSE, but no both.
    • ประโยคบอกเล่าหรือประโยคปฏิเสธที่ เป็นจริงหรือเป็นเท็จอย่างใดอย่างหนึ่ง เท่านั้น!!

Compound Propositions

  • We can build composite propositions from simpler propositions by using 5 connectives:
    • and (∧\land), or (∨\lor), not (¬\neg), implies (→\rightarrow), if and only if (⟷\longleftrightarrow)

Truth Tables

  • The truth values of compound propositions can be described by truth tables
p¬pTFFT \begin{array}{|c|c|} \hline p & \neg p \\ \hline T & F \\ F & T \\ \hline \end{array} pqp∧qTTTTFFFTFFFF\begin{array}{|c|c|c|} \hline p & q & p \land q \\ \hline T & T & T \\ T & F & F \\ F & T & F \\ F & F & F \\ \hline \end{array} pqp∨qTTTTFTFTTFFF\begin{array}{|c|c|c|} \hline p & q & p \lor q \\ \hline T & T & T \\ T & F & T \\ F & T & T \\ F & F & F \\ \hline \end{array}

Conditional Proposition

  • pp เป็น Condition part, hypothesis, antecedent, premise
  • qq เป็น Conclusion, consequence
pqp→qTTTTFFFTTFFT\begin{array}{|c|c|c|} \hline p & q & p \rightarrow q \\ \hline T & T & T \\ T & F & F \\ F & T & T \\ F & F & T \\ \hline \end{array}
  • p→qp\rightarrow q can also be read as:
    • “If pp, then qq”
    • “qq when pp”
    • “A sufficient condition for qq is pp”
    • “A necessary condition for pp is qq”

Biconditional Proposition

pqp↔qTTTTFFFTFFFT\begin{array}{|c|c|c|} \hline p & q & p \leftrightarrow q \\ \hline T & T & T \\ T & F & F \\ F & T & F \\ F & F & T \\ \hline \end{array}
  • Input เหมือนกันเป็น TRUE ต่างกันเป็น FALSE ตรงข้ามกับ XOR Gate นะ!!! ระวังจำสับสน
  • p↔qp \leftrightarrow q can also be read as:
    • “pp is a necessary and sufficient condition for qq”
    • and sometimes written as “pp iff qq”

Logical Equivalence

  • ประพจน์ pp สมมูลกับ qq เมื่อ pp และ qq มีค่าความจริงเหมือนกันทุกกรณี (ดูใน Truth Table) เขียนแทนด้วย “p ≡≡ q”
    • Logically equivalent = Same in every possible combination
pqrp∨(q∧r)(p∨q)∧(p∨r)Equivalent?TTTTTTTTFTTTTFTTTTTFFTTTFTTTTTFTFFFTFFTFFTFFFFFT\begin{array}{|c|c|c|c|c|c|} \hline p & q & r & p \lor (q \land r) & (p \lor q) \land (p \lor r) & \text{Equivalent?} \\ \hline T & T & T & T & T & T \\ T & T & F & T & T & T \\ T & F & T & T & T & T \\ T & F & F & T & T & T \\ F & T & T & T & T & T \\ F & T & F & F & F & T \\ F & F & T & F & F & T \\ F & F & F & F & F & T \\ \hline \end{array}
  • ปัญหาอยู่ตรงที่ว่า จะรู้ว่า Logcally equivalent กันเนี่ย ถ้ามีทั้งหมด 10 symbols ไม่ต้องเขียน Truth Table 210=1,0242^{10}=1,024 แถวเลยหรอ?!!!
    • เพราะว่า The size of the truth table grows “exponentially” as the number of symbols increases.

Basic Logical Equivalences (สมมูลที่สำคัญ ๆ)

Biconditional Law

p↔q≡(p→q)∧(q→p)p \leftrightarrow q \equiv (p \rightarrow q) \land (q \rightarrow p)

Implication Law

p→q≡¬p∨qp \rightarrow q \equiv \neg p \lor q

Contrapositive Law

p→q≡¬q→¬pp \rightarrow q \equiv \neg q \rightarrow \neg p

De Morgan’s Law

¬(p∧q)≡¬p∨¬q\neg (p \land q) \equiv \neg p \lor \neg q ¬(p∨q)≡¬p∧¬q\neg (p \lor q) \equiv \neg p \land \neg q

Associative Laws (The Grouping is Not Important)

  • เครื่องหมาย ใน เหมือนกับ นอก!
p∨(q∨r)≡(p∨q)∨rp \lor (q \lor r) \equiv (p \lor q) \lor r p∧(q∧r)≡(p∧q)∧rp \land (q \land r) \equiv (p \land q) \land r

Distributive Law

  • Check Link อีกทีว่าถูกต้องมั้ย
  • เครื่องหมาย ใน ต่างกับ นอก!
p∨(q∧r)≡(p∨q)∧(p∨r)p \lor (q \land r) \equiv (p \lor q) \land (p \lor r) p∧(q∨r)≡(p∧q)∨(p∧r)p \land (q \lor r) \equiv (p \land q) \lor (p \land r)

Quantifications (ตัวบ่งปริมาณ)

Universal Quantification (∀\forall)

  • ∀x\forall x, P(x)P(x) is true, if P(x)P(x) is true for every xx in DD → to show, examine all objects
  • ∀x\forall x, P(x)P(x) is false, if P(x)P(x) is false for at least one xx in DD → to show, give one counterexample

Existential Quantification (∃\exists)

  • ∃x\exists x, P(x)P(x) is true, if P(x)P(x) is true for at least one xx in DD → to show, give one example
  • ∃x\exists x, P(x)P(x) is false, if P(x)P(x) is false for every xx in DD → to show, examine all objects

Generalized De Morgan’s Law

¬(∀x,P(x))\neg(\forall x, P(x)) and ∃x,¬P(x)\exists x, \neg P(x) have the same truth values.

¬(∃x,P(x))\neg(\exists x, P(x)) and ∀x,¬P(x)\forall x, \neg P(x) have the same truth values.

  • ง่าย ๆ ก็คือกระจาย ¬\neg เข้าไปใน quantified statement นั่นเอง

Nested Quantifiers

  • ง่าย ๆ ก็คือการมีประพจน์ มากกว่า 1 ตัว = 2 ตัว นั่นแหละ
∃x∃y[P(x,y)]\exists x\exists y[{P(x,y)}]==TRUE== เมื่อมี (x, y) อย่างน้อยหนึ่งคู่ที่ทำให้เงื่อนไขเป็นจริง
∃x∀y[P(x,y)]\exists x\forall y[{P(x,y)}]==TRUE== เมื่อ x หนึ่งตัวที่เมื่อนำไปจับคู่กับ y ทุกตัวแล้วเป็นจริงFalse → Diffcult ให้ใช้ De Morgan’s Law
∀x∃y[P(x,y)]\forall x\exists y[{P(x,y)}]==TRUE== เมื่อนำ x ทุกตัวไปจับคู่กับ y บางตัวแล้วเป็นจริง
∀x∀y[P(x,y)]\forall x\forall y{[P(x,y)]}==FALSE== ทันทีเมื่อพบข้อแย้งอย่างน้อยหนึ่งคู่ที่แทนแล้วไม่จริง