# Workshop Plan, Week 8 Plan The exercises

### Pages to are hidden for

"Workshop Plan, Week 8 Plan The exercises"

```					                Department of Computer Science and Software Engineering
433-295 Discrete Structures

Workshop Plan, Week 8
14 to 18 September 2009

Plan
The ﬁrst exercises relate to material in DvE Chapters 5 and 6. The last two relate to Assignment 2.

The exercises
42. (Based on DvE 5.50.) Relations are sets. To say that R(x, y) ∧ S(x, y) holds is the same as
saying that (x, y) is in the relation R and also in the relation S, that is, (x, y) ∈ R ∩ S.
Suppose R and S are reﬂexive relations on a set A. Then ∆A ⊆ R and ∆A ⊆ S, so ∆A ⊆ R ∩ S.
That is, R ∩ S is also reﬂexive. We say that intersection preserves reﬂexivity. It is easy to
see that union also preserves reﬂexivity. Similarly, if R is reﬂexive then so is R−1 , but the
complement A2 − R is clearly not. The table below lists these results. Complete the table,
indicating which operations on relations preserve symmetry and transitivity.

Property                            Reﬂexivity     Symmetry      Transitivity
preserved   under   ∩?                 yes
preserved   under   ∪?                 yes
preserved   under   inverse?           yes
preserved   under   complement?        no

Now assume that R and S are equivalence relations. From the table’s ﬁrst two rows, determine
whether R ∩ S necessarily is an equivalence relation, and whether R ∪ S is.

43. (DvE 6.40) Suppose h : X → X satisﬁes h ◦ h ◦ h = 1X . Show that h is a bijection. Also give
a simple example of a set X and a function h : X → X such that h ◦ h ◦ h = 1X , but h is not
the identity function (hint: think paper-scissors-rock).

44. (DvE 6.53) Let the function f : {0, 1, 2, 3, 4} → {5, 6} be {(0, 5), (1, 5), (2, 5), (3, 6), (4, 6)}. How
many right-inverses to f are there?

45. (Assignment 2 relevant.) Consider the propositional expression x ⇔ (y ∨ z). Its syntax tree is
shown below. We can think of this tree as a digital circuit with inputs x, y, and z, and two
gates, an “or” gate and an “iﬀ” gate. In this view, the circuit’s output is delivered through the
‘iﬀ’ gate (in this example). To assert the Boolean constraint x ⇔ (y ∨ z) is the same as saying
that we want the circuit’s output to be 1 (true). Tseitin translation introduces a fresh variable,
a node variable for each gate (the gates are internal nodes in the expression tree). We use the
variables t1 and t2 for this example, using t1 for the ‘iﬀ’ gate, as shown.

To satisfy the constraint x ⇔ (y ∨ z) now means satisfying t1 , together                      t1
with the two equivalences                                                                ⇔
t2
t1 ⇔ (x ⇔ t2 )                                       x               ∨
t2 ⇔ (y ∨ z)
y                 z
The ﬁrst equivalence can be written in CNF as
(¬t1 ∨ x ∨ ¬t2 ) ∧ (¬t1 ∨ ¬x ∨ t2 ) ∧ (t1 ∨ ¬x ∨ ¬t2 ) ∧ (t1 ∨ x ∨ t2 )           (1)
and the second can be written
(¬t2 ∨ y ∨ z) ∧ (t2 ∨ ¬y) ∧ (t2 ∨ ¬z)                              (2)
Altogether we want to satisfy all of these clauses, that is, the singleton clause t1 , together
with (1) and (2). These eight clauses are the result of the Tseitin translation, and they are
equi-satisﬁable with the original formula.
It is easy to see that the idea generalises to formulas of arbitrary size and structure. We just
need to ﬁnd appropriate translations to CNF, for the remaining connectives. Each is replaced
by a ﬁxed-size CNF formula. This means the size of the output is linear in the size of the
input formula—a good thing. The table below lists, for some connectives, the clauses and node
variable generated for a circuit with an output gate labeled with that connective. The task is
to add entries for the remaining two connectives, and the two Boolean constants.

Expression       nodevar     clauses
v (a variable)       v        ∅
{{¬t, ¬u}, {t, u}} ∪ C
¬ϕ          t (fresh)   where u = nodevar (ϕ)
and C = clauses(ϕ)
{{¬t, u, v}, {t, ¬u}, {t, ¬v}} ∪ C1 ∪ C2
ϕ∨ψ           t (fresh)   where u = nodevar (ϕ) and v = nodevar (ψ)
and C1 = clauses(ϕ) and C2 = clauses(ψ)
{{¬t, u, ¬v}, {¬t, ¬u, v}, {t, ¬u, ¬v}, {t, u, v}} ∪ C1 ∪ C2
ϕ⇔ψ           t (fresh)   where u = nodevar (ϕ) and v = nodevar (ψ)
and C1 = clauses(ϕ) and C2 = clauses(ψ)

46. (Assignment 2 relevant.) Consider the program below, on the left:

#WORDSIZE 4                  (([("x", BitwiseAnd (BitwiseAnd (Const "0xC") (Var "y"))
x = (0xC & y) & 3                                (Const "3")
{x == 0}                           )
]
,4
)
,Equal (Var "x") (Const "0")
)

written in the language used in our project. Note that the assertion is valid. For this input,
the parser produces the expression shown on the right.
(a) Give the binary strings corresponding to "0xC", "3", and "0". Is your toBinary from last
week able to generate these?
(b) Give an expression of type BoolExp which is a correct Boolean constraint (bit-blasting)
for the input program.
(c) Give an expression of type BoolExp which is a correct translation of the negation of
{x == 0}.
(d) Assuming that Tseitin translation can make use of “variables” from 16 and onwards, show
the clauses that it should generate for the expression
Or (Bvar "x" 3 0) (Or (Bvar "x" 3 1) (Or (Bvar "x" 3 2) (Bvar "x" 3 3)))

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 5 posted: 10/13/2009 language: English pages: 2