0% found this document useful (0 votes)
65 views3 pages

Homework 02

This document contains the instructions for homework 2 of a computer science course. It includes 5 problems related to formal logic and string theory. Problem 1 asks students to prove that a string is "good" based on inductive rules and characterize the property of all good strings. Problem 2 asks students to prove that logical implication distributes over conjunction and vice versa. Problem 3 asks students to prove the validity of logical formulas. Problem 4 asks students to write logical formulas representing properties of strings like being even, a substring, or a power of 2. Problem 5 (bonus) asks students to prove that repeated applications of a tree modification rule can turn any rooted tree into a single vertex tree.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views3 pages

Homework 02

This document contains the instructions for homework 2 of a computer science course. It includes 5 problems related to formal logic and string theory. Problem 1 asks students to prove that a string is "good" based on inductive rules and characterize the property of all good strings. Problem 2 asks students to prove that logical implication distributes over conjunction and vice versa. Problem 3 asks students to prove the validity of logical formulas. Problem 4 asks students to write logical formulas representing properties of strings like being even, a substring, or a power of 2. Problem 5 (bonus) asks students to prove that repeated applications of a tree modification rule can turn any rooted tree into a single vertex tree.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Carnegie Mellon University in Qatar, Computer Science Problem Sets

15-251: Great Theoretical Ideas in Computer Science January 17


Spring 2022/Christos A. Kapoutsis 22.01.17 17:07:46

Homework 02
due: January 23

Problem 1. Consider the following inductively defined set of “good” strings of a’s and b’s:
• Seed: The empty string  is good.
• Rule 1: If s is good, then a s b is good.
• Rule 2: If s is good, then b s a is good.
• Rule 3: If s1 , s2 are good, then s1 s2 is good.

(a) Prove that abaababbba is good.

(b) Give a characterization of the good strings: i.e., a property P such that a string s is good if
and only if s has property P .
(Your characterization should be non-trivial; e.g., P cannot be “all good strings”.)

(c) Prove that every good string satisfies your P . (Soundness.)

(d) Prove that every string that satisfies your P is good. (Completeness.)

(e) Prove that abababbba is not good.

Problem 2. (a) Prove that → distributes over ∧, i.e., that the following formula is a tautology:
 
p → (q ∧ r) ↔ (p → q) ∧ (p → r) .

(b) Prove that part (a) is not true if we swap → with ∧, namely the formula
 
p ∧ (q → r) ↔ (p ∧ q) → (p ∧ r) .

is not a tautology, and thus ∧ does not distribute over →.


Problem Sets: Homework 02 2

Problem 3. For each of the following formulas, prove that the formula is valid or give an inter-
pretation to show that it is not valid.

 
(a) ∀u P (u) → R(u) → ∀uP (u) → ∀uR(u) .
 
(b) ∀uP (u) → ∀uR(u) → ∀u P (u) → R(u) .

Problem 4. Consider a first-order logic with the following symbols:


• relational : just equality ( · = · );
• functional : cat( · , · );
• constant: 0, 1, and e.
For this logic, consider the interpretation where
• the universe is the set of all finite binary strings;
• = maps to the relation which it true iff its two arguments are identical;
• cat maps to the function which returns the concatenation xy of its arguments x and y.
• 0 maps to the the single-symbol string 0;
• 1 maps to the the single-symbol string 1; and
• e maps to the the empty string .
We can use this logic to write formulas which represent complex properties of strings. For example,
consider the formula
isOdd(x) := (∃y)(x=cat(y, 1))
represents the property that “the binary number represented by the string x is odd”.
In each part below, write a formula which represents the given relation. If you wish, you may use
a relation that you have already defined in a previous part.

(a) isEven(x), for “the binary number represented by x is even”.

(b) isSubstring(x, y), for “x is a substring of y”.

(c) isPowerOf2(x), for “the binary number represented by x is a power of 2”.

(d) isEqual(x, y), for “the binary numbers represented by x and y are equal”.

Problem 5 (BONUS). Let T be any rooted tree. Let v by any node of T . The subtree of T rooted
at v is the set of all nodes x for which every path from the root of T to x goes through v. To attach
to v another rooted tree T 0 is simply to draw an edge from v to the root of T 0 . (Note that a rooted
tree need not be binary —each node may have any number of children.)
Now consider the following rule for modifying a rooted tree T :
Problem Sets: Homework 02 3

1. Pick any leaf u and remove it from T .


2. If the parent v of u was the root of T , then do nothing.
3. Otherwise, take 251 copies of the subtree rooted at v (after the removal of u), and attach
them to the parent of v.
Prove that, for every rooted tree T , repeated applications of this rule can eventually turn T into
the single-vertex tree which consists of only the root.

You might also like