Application
About 2164 wordsAbout 7 min
2025-08-02
Question 1: Truth Tables, DNF, and CNF
Scenario: A server has three critical services: Apache, BIND, and Cron. For the system to be considered "stable," at least two of these services must be running.
Let's represent the state of the services with propositions A, B, and C, where True means the service is running. We can construct a truth table to define the "stable" function.
A | B | C | System Stable? | DNF Clause (if True) | CNF Clause (from False rows) |
---|---|---|---|---|---|
F | F | F | F | (A∨B∨C) | |
F | F | T | F | (A∨B∨¬C) | |
F | T | F | F | (A∨¬B∨C) | |
F | T | T | T | (¬A∧B∧C) | |
T | F | F | F | (¬A∨B∨C) | |
T | F | T | T | (A∧¬B∧C) | |
T | T | F | T | (A∧B∧¬C) | |
T | T | T | T | (A∧B∧C) |
Deriving the DNF (Disjunctive Normal Form)
The DNF is the disjunction (OR) of the minterms for each row where the function's output is True.
- DNF Result: (¬A∧B∧C)∨(A∧¬B∧C)∨(A∧B∧¬C)∨(A∧B∧C)
This DNF expression is true if exactly two services are running or if all three are running.
Deriving the CNF (Conjunctive Normal Form)
The CNF is the conjunction (AND) of maxterms derived from the rows where the function's output is False. For each 'False' row, we create a disjunction (OR) of the negated literals and apply De Morgan's laws.
- Row 1 (FFF): The condition is (¬A∧¬B∧¬C). Negating this gives (A∨B∨C).
- Row 2 (FFT): The condition is (¬A∧¬B∧C). Negating this gives (A∨B∨¬C).
- Row 3 (FTF): The condition is (¬A∧B∧¬C). Negating this gives (A∨¬B∨C).
- Row 5 (TFF): The condition is (A∧¬B∧¬C). Negating this gives (¬A∨B∨C).
- CNF Result: (A∨B∨C)∧(A∨B∨¬C)∧(A∨¬B∨C)∧(¬A∨B∨C)
This CNF expression logically states that we cannot have zero services running or only one service running.
Question 2: Properties of Formal Languages
Claim: All words in the language EVEN-EVEN have an even length.
Defining the EVEN-EVEN Language
The EVEN-EVEN language consists of strings over the alphabet {a,b} where the number of 'a's is even (0, 2, 4, ...) and the number of 'b's is also even (0, 2, 4, ...).
- Let ∣w∣a be the count of 'a's in a string w.
- Let ∣w∣b be the count of 'b's in a string w.
For a string w to be in EVEN-EVEN, ∣w∣a must be even and ∣w∣b must be even.
Examples: aa
, bb
, aabb
, aaaabb
, bbbb
, and the empty string ϵ.
Mathematical Proof
The total length of any string w is ∣w∣=∣w∣a+∣w∣b.
- Since ∣w∣a is an even number, it can be written as 2k for some non-negative integer k.
- Since ∣w∣b is an even number, it can be written as 2m for some non-negative integer m.
Now, substitute these into the formula for the total length:
∣w∣=(2k)+(2m)∣w∣=2(k+m)
Since k and m are integers, their sum (k+m) is also an integer. The expression 2(k+m) is, by definition, an even number.
Therefore, every word in the EVEN-EVEN language must have an even length.
Question 3: Proof of a Language Superset
Let EQUAL be the language of strings over {a,b} that contain an equal number of a’s and b’s. Let ~ODD-ODD be the complement of the ODD-ODD language (i.e., strings that do not have both an odd number of a's and an odd number of b's).
Prove that EQUAL ⊆ ~ODD-ODD.
Proof
To prove this, we must show that any arbitrary string w∈EQUAL must also be in O˜DD-ODD.
Let w be an arbitrary string in the language EQUAL.
By the definition of EQUAL, the number of 'a's in w is equal to the number of 'b's in w. Let's call this number k.
- ∣w∣a=k
- ∣w∣b=k
The definition of ~ODD-ODD means a string is in this language if ∣w∣a is even OR ∣w∣b is even.
We analyze two cases for the value of k:
- Case 1: k is an even number. If k is even, then ∣w∣a=k is even and ∣w∣b=k is also even. Since ∣w∣a is even, the condition for w to be in ~ODD-ODD is satisfied.
- Case 2: k is an odd number. If k is odd, then ∣w∣a=k is odd and ∣w∣b=k is also odd. This means w has an odd number of 'a's and an odd number of 'b's. This is the exact definition of a string in the ODD-ODD language.
Let's re-examine our premise. The proof seems to fail in Case 2. Let's reconsider the properties. The length of any string in EQUAL is ∣w∣=∣w∣a+∣w∣b=k+k=2k. This means every string in EQUAL has an even length.
Let's restart the proof with this insight.
- Let w∈EQUAL. Then ∣w∣a=∣w∣b=k.
- To be in ODD-ODD, ∣w∣a must be odd and ∣w∣b must be odd.
- If ∣w∣a and ∣w∣b were both odd, then k would be an odd number.
- However, if k is odd, ∣w∣a is odd and ∣w∣b is odd. This fits the definition of ODD-ODD. Example:
ab
. ∣w∣a=1,∣w∣b=1. This is in EQUAL and also in ODD-ODD. - This means
ab
is NOT in ~ODD-ODD.
Therefore, the statement EQUAL ⊆ ~ODD-ODD is FALSE. The string ab
is a counterexample, as it is in EQUAL but not in ~ODD-ODD.
(This demonstrates the importance of verifying claims and finding counterexamples).
Let's prove a different, correct statement: If a palindrome has an even length, it is in ~ODD-ODD.
- Let w be a palindrome with even length ∣w∣=2k.
- We can write w=uuR for some string u of length k.
- The number of 'a's in w is ∣w∣a=∣u∣a+∣uR∣a=2∣u∣a. This is an even number.
- Since ∣w∣a is even, w cannot have an odd number of 'a's AND an odd number of 'b's.
- Therefore, w∈O˜DD-ODD.
Question 4: Proof by Truth Table
Prove the logical equivalence of De Morgan's Law: ¬(P∨Q)≡(¬P∧¬Q)
P | Q | P∨Q | ¬(P∨Q) | ¬P | ¬Q | ¬P∧¬Q |
---|---|---|---|---|---|---|
T | T | T | F | F | F | F |
T | F | T | F | F | T | F |
F | T | T | F | T | F | F |
F | F | F | T | T | T | T |
Since the columns for ¬(P∨Q) and (¬P∧¬Q) are identical for all possible truth values of P and Q, the two expressions are logically equivalent.
Question 5: Proof by Derivation
Using the distributive law A∨(B∧C)≡(A∨B)∧(A∨C), prove the absorption law: P∨(P∧Q)≡P.
You may also use the following axioms:
- Identity Law: P∨False≡P
- Complementation Law: P∧¬P≡False
- Domination Law: P∨True≡True
- Tautology: A≡A∧True
Start with the Left-Hand Side (LHS):P∨(P∧Q)
Apply the distributive law: A∨(B∧C)≡(A∨B)∧(A∨C). Here, A=P, B=P, and C=Q. P∨(P∧Q)≡(P∨P)∧(P∨Q)
Apply the Idempotent Law (P∨P≡P): ≡P∧(P∨Q)
(This proves the other absorption law, P∧(P∨Q)≡P. Let's try another way to prove the original statement).
Let's try a different approach starting from the LHS.
Start with the LHS:P∨(P∧Q)
Use the Tautology axiom to write P as P∧True: ≡(P∧True)∨(P∧Q)
Apply the distributive law (A∧B)∨(A∧C)≡A∧(B∨C) in reverse. Here, A=P, B=True, C=Q. ≡P∧(True∨Q)
Apply the Domination Law (True∨Q≡True): ≡P∧True
Apply the Identity Law (P∧True≡P): ≡P
We have shown that P∨(P∧Q)≡P.
Question 6: Translating English to CNF
A team of three students, Alice, Bob, and Carol, are working on a project. Let the propositions A, B, and C mean that the respective student completed their part of the work.
Write a proposition in Conjunctive Normal Form (CNF) for each statement.
- At least one student completed their work.
- (A∨B∨C)
- Carol and Alice did not both complete their work.
- (¬C∨¬A)
- Exactly one student completed their work.
- This means "at least one" AND "at most one".
- At least one: (A∨B∨C)
- At most one (no two worked): (¬A∨¬B)∧(¬A∨¬C)∧(¬B∨¬C)
- Result: (A∨B∨C)∧(¬A∨¬B)∧(¬A∨¬C)∧(¬B∨¬C)
- At most two students completed their work.
- This is the same as saying "it's not the case that all three completed their work": ¬(A∧B∧C)
- Result: (¬A∨¬B∨¬C)
- If Bob completed his work, then Alice also completed her work.
- B⟹A
- Result: (¬B∨A)
Question 7: Predicate Logic Translation
Using the function capital(c)
(the capital of country c
), the predicate isNorthOf(p1, p2)
(place p1
is north of place p2
), and the constants malaysia
and thailand
, translate the following sentences into Predicate Logic. The universe of discourse is "all places and countries".
- The capital of Malaysia is north of the capital of Thailand.
isNorthOf(capital(malaysia), capital(thailand))
- There is a country whose capital is north of Kuala Lumpur.
- Let
kualaLumpur
be a constant representing the city. - ∃x isNorthOf(capital(x),kualaLumpur)
- Let
- Every place is north of some other place.
- ∀x ∃y (isNorthOf(x,y)∧x=y)
- Every city that is north of Bangkok is also north of Singapore.
- Let
bangkok
andsingapore
be constants. - ∀x isNorthOf(x,bangkok)⟹isNorthOf(x,singapore)
- Let
Question 8: Language Properties in Predicate Logic
Suppose you have access to the function ∣x∣ (length of string x), relations like =
and ∈
, and a language L over the alphabet {a,b}.
Write a logical statement that is True if and only if L contains the empty string ϵ.
- The statement is simply that the empty string is an element of the set L.
- ϵ∈L
- Alternatively, using a quantifier: ∃x (x∈L∧∣x∣=0)
Write a logical statement that is True if and only if L contains a finite number of strings of length 5.
- This means there exists some number k that is an upper bound on the count of strings of length 5 in L. This is more complex than defining if the entire language is finite. A simpler interpretation is to state there isn't an infinite number of such strings. We can't easily express "the count of" in basic predicate logic.
- A better approach for this level might be: Write a statement that is True if and only if L contains at least one string of every possible length.
- ∀n∃x(x∈L∧∣x∣=n)
Changelog
2b7ff
-web-deploy(Auto): Update base URL for web-pages branchon
Copyright
Copyright Ownership:WARREN Y.F. LONG
License under:Attribution-NonCommercial-NoDerivatives 4.0 International (CC-BY-NC-ND-4.0)