Discrete StructureUnit 110 min read
Logic, Propositions, Truth Tables & Boolean Algebra
Unit 1 of Discrete Structure introduces propositional logic, logical connectives, truth tables, tautologies, contradictions, logical equivalences, and Boolean algebra—foundations for designing algorithms, verifying proofs, and building digital circuits.
Propositional Logic: The Building Blocks
What is a Proposition?
A proposition is a declarative statement that is either true (T) or false (F), but not both. It must be unambiguous and verifiable.
| P | Q |
|---|---|
| T | F |
| F | T |
Key Points:
- Not all sentences are propositions. Questions, commands, and exclamations are not propositions.
- Example: "Nepal is a landlocked country." (True) vs. "The sky is green." (False)
Logical Connectives: Combining Propositions
Logical connectives combine propositions to form compound propositions. The five primary connectives are:
| Connective | Symbol | Name | Truth Table (P → Q) |
|---|---|---|---|
| Negation | ¬P | NOT P | P |
| T | |||
| F | |||
| Conjunction | P ∧ Q | AND | P |
| T | |||
| T | |||
| F | |||
| F | |||
| Disjunction | P ∨ Q | OR | P |
| T | |||
| T | |||
| F | |||
| F | |||
| Implication | P → Q | IF P THEN Q | P |
| T | |||
| T | |||
| F | |||
| F | |||
| Biconditional | P ↔ Q | IF AND ONLY IF | P |
| T | |||
| T | |||
| F | |||
| F |
A combined truth table for all five connectives (Image: WatchduckYou can name the author as 'T. Piesk', 'Tilman Pies, Public domain, via Wikimedia Commons)
Worked Example: Evaluating Compound Propositions
Problem: Evaluate the truth value of (¬P ∨ Q) → (P ∧ ¬Q) when P is true and Q is false.
Solution:
¬P=¬(T)=F¬P ∨ Q=F ∨ F=FP ∧ ¬Q=T ∧ T=T(¬P ∨ Q) → (P ∧ ¬Q)=F → T= T
Tautologies, Contradictions, and Contingencies
| Type | Definition | Example |
|---|---|---|
| Tautology | Always true, regardless of truth values of propositions. | P ∨ ¬P (Law of Excluded Middle) |
| Contradiction | Always false, regardless of truth values of propositions. | P ∧ ¬P (Contradiction) |
| Contingency | Truth value depends on the truth values of its propositions. | P → Q |
Logical Equivalences and Laws
Logical equivalences allow us to simplify or transform propositions without changing their truth value.
| Law | Equivalence | Example |
|---|---|---|
| Identity | P ∨ F ≡ P |
P ∨ F is always P |
P ∧ T ≡ P |
P ∧ T is always P |
|
| Double Negation | ¬(¬P) ≡ P |
Negating twice returns the original proposition. |
| Commutative | P ∨ Q ≡ Q ∨ P |
Order doesn’t matter in OR. |
P ∧ Q ≡ Q ∧ P |
Order doesn’t matter in AND. | |
| Associative | (P ∨ Q) ∨ R ≡ P ∨ (Q ∨ R) |
Grouping doesn’t matter in OR. |
(P ∧ Q) ∧ R ≡ P ∧ (Q ∧ R) |
Grouping doesn’t matter in AND. | |
| Distributive | P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R) |
AND distributes over OR. |
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R) |
OR distributes over AND. | |
| De Morgan’s | ¬(P ∨ Q) ≡ ¬P ∧ ¬Q |
Negation of OR is AND of negations. |
¬(P ∧ Q) ≡ ¬P ∨ ¬Q |
Negation of AND is OR of negations. | |
| Implication | P → Q ≡ ¬P ∨ Q |
Implication can be rewritten. |
| Biconditional | P ↔ Q ≡ (P → Q) ∧ (Q → P) |
Biconditional is two implications. |
Boolean Algebra: The Algebra of Logic
Boolean algebra is a branch of algebra where the values of the variables are the truth values true and false, and the operations are logical connectives.
Key Properties:
- Closure: The result of applying a logical connective to propositions is always a proposition.
- Identity:
P ∨ F ≡ PandP ∧ T ≡ P. - Commutativity:
P ∨ Q ≡ Q ∨ PandP ∧ Q ≡ Q ∧ P. - Associativity:
(P ∨ Q) ∨ R ≡ P ∨ (Q ∨ R)and(P ∧ Q) ∧ R ≡ P ∧ (Q ∧ R). - Distributivity:
P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)andP ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R). - Complement:
P ∨ ¬P ≡ TandP ∧ ¬P ≡ F.
Worked Example: Simplifying Boolean Expressions
Problem: Simplify the expression (P ∨ ¬Q) ∧ (P ∨ Q) ∧ (¬P ∨ Q).
Solution:
- Apply the distributive law to the first two terms:
(P ∨ ¬Q) ∧ (P ∨ Q) = P ∨ (¬Q ∧ Q) ¬Q ∧ Qis alwaysF(contradiction), so:P ∨ F ≡ P- Now the expression is
P ∧ (¬P ∨ Q). - Apply the distributive law again:
P ∧ (¬P ∨ Q) = (P ∧ ¬P) ∨ (P ∧ Q) P ∧ ¬Pis alwaysF, so:F ∨ (P ∧ Q) ≡ P ∧ Q
Final Simplified Expression: P ∧ Q
Truth Tables for Complex Propositions
Truth tables are used to determine the truth value of complex propositions for all possible truth values of their components.
Example: Construct a truth table for (P → Q) ∧ (¬P ∨ R).
| P | Q | R | P → Q | ¬P | ¬P ∨ R | (P → Q) ∧ (¬P ∨ R) |
|---|---|---|---|---|---|---|
| T | T | T | T | F | T | T |
| T | T | F | T | F | F | F |
| T | F | T | F | F | T | F |
| T | F | F | F | F | F | F |
| F | T | T | T | T | T | T |
| F | T | F | T | T | T | T |
| F | F | T | T | T | T | T |
| F | F | F | T | T | T | T |
In the Real World
- eSewa and Kathmandu Traffic Management:
- Propositional Logic in Traffic Light Control:
eSewa and the Kathmandu Metropolitan City use logic gates (based on propositional calculus) to control traffic lights. For example, a traffic light at a busy intersection might follow this logic:
IF (Sensor1 detects car AND Sensor2 detects car) THEN GreenLight1 = ON AND GreenLight2 = OFF- This ensures that only one direction gets the green light at a time, preventing collisions. The logic can be represented using implication (
→) and conjunction (∧).
- Propositional Logic in Traffic Light Control:
eSewa and the Kathmandu Metropolitan City use logic gates (based on propositional calculus) to control traffic lights. For example, a traffic light at a busy intersection might follow this logic:
Khalti and Online Payment Verification:
- Boolean Algebra in Transaction Processing:
When you make a payment via Khalti, the system checks multiple conditions to verify the transaction. For example:
(User_Authenticated ∧ Account_Balanced) → Transaction_Approved¬(Transaction_Approved) → Send_Alert_To_UserHere, logical AND (∧), implication (→), and negation (¬) are used to ensure secure and valid transactions.
- Boolean Algebra in Transaction Processing:
When you make a payment via Khalti, the system checks multiple conditions to verify the transaction. For example:
WhatsApp Group Messages and Filtering:
- Logical Connectives in Spam Detection:
WhatsApp uses propositional logic to filter out spam messages. For instance:
IF (Message_Contains_Keyword AND Sender_Not_Verified) THEN Mark_As_Spam- This can be broken down using logical AND (
∧) and implication (→). The system evaluates these conditions in real-time to protect users from unwanted messages.
- Logical Connectives in Spam Detection:
WhatsApp uses propositional logic to filter out spam messages. For instance:
Exam Tip
What to Expect in the Exam:
Definitions and Concepts:
- Be ready to define propositions, logical connectives, tautologies, contradictions, and logical equivalences.
- Example question: "Define a tautology and give an example."
Truth Tables:
- You will be asked to construct truth tables for given logical expressions.
- Example question: "Construct a truth table for
(P ∧ Q) → (¬P ∨ R)."
Logical Equivalences:
- Prove that two logical expressions are equivalent using laws of Boolean algebra.
- Example question: "Show that
P → Qis equivalent to¬P ∨ Q."
Simplification:
- Simplify complex logical expressions using Boolean algebra laws.
- Example question: "Simplify the expression
(P ∨ ¬Q) ∧ (P ∨ Q)."
Applications:
- Explain real-world applications of propositional logic, such as in traffic management systems, payment verification, or spam detection.
- Example question: "How is propositional logic used in online payment systems like Khalti?"
Tips for Success:
- Practice Constructing Truth Tables: This is a fundamental skill. Start with simple expressions and gradually move to more complex ones.
- Memorize Logical Equivalences: Laws like De Morgan’s, distributive laws, and implication equivalences are frequently tested.
- Understand the Real-World Applications: Connecting theoretical concepts to practical scenarios (like traffic lights or payment systems) can help you remember the material better and perform well in application-based questions.
- Work on Simplification Problems: These problems require a good grasp of Boolean algebra. Practice regularly to build confidence.
Based on the TU BCA syllabus for Discrete Structure (BCA151), unit 1.
Discussion
Loading…