<<

1. PARTIALLY ORDERED SETS - SOLUTIONS

2. For two posets A and B:

(a) Show that if f : A → B is an , then f is one-to-one.

Solution: We need to show that

a 6= a0 ⇒ f (a) 6= f (a0).

Equivalently, we can show that

f (a) = f (a0) ⇒ a = a0.

Note that f (a) = f (a0) ⇒ f (a) ≤ f (a0) and f (a) = f (a0) ⇒ f (a0) ≤ f (a). Since f is an , this implies that a ≤ a0 and a0 ≤ a, which together imply that a = a0.

(b) Show that if f : A → B is an order , then there is an g: B → A.

Solution: Using the result from part (a), f is one-to-one and onto, so f −1 is a well-defined and is also one-to-one and onto. Let g = f −1. We can show that g is an order embed- ding, and hence an order isomorphism. To show that, note that since f is an order embedding,

f (a) ≤ f (a0) ⇐⇒ a ≤ a0,

which, letting b = f (a) and b0 = f (a0), implies that

b ≤ b0 ⇐⇒ g(b) ≤ g(b0).

Thus, g is an order embedding.

E. A. Lee, Concurrent Models of Computation 3 1. PARTIALLY ORDERED SETS - SOLUTIONS

3. Let ω = {0/,{0/},{0/,{0/}},···} be the von Neumann as defined on page ??. This problem explores the relationship between this and N.

(a) Let f : ω → N be defined by f (x) = |x|, ∀ x ∈ ω . That is, f (x) is the size of the set x. Show that f is a .

Solution: f is onto because the set ω contains at least one set with any size n ∈ N. f is one-to-one because ω contains no more than one set with any size n ∈ N. Since f is onto and one-to-one, it is a bijection.

(b) Let (ω,⊆) and (N,≤) be posets, where ⊆ is the usual order and ≤ is the usual numeric order. Show that these posets are order isomorphic.

Solution: The function f of part (a) is an order isomorphism because it is onto (shown in part (a)) and an order embedding. To show it is an order embedding, just note that for any x,x0 ∈ ω, if x ⊆ x0, then f (x) ≤ f (x0) (obviously, because f is just set size). Moreover, since f is a bijection, it has an inverse, and we can similarly show that the inverse is onto and an order embedding.

(c) The lifted version of the function f in part (a) is written fˆ. What is the value of fˆ({0/,{0/}})? What is the value of f ({0/,{0/}})? Note that on page ?? it is noted that when there is no ambigu- ity, fˆ may be written simply f . For this function, is there such ambiguity?

Solution: fˆ({0/,{0/}}) = {0,1}. f ({0/,{0/}}) = 2. Hence, in this case, there is definitely ambiguity, and the shorthand notation should not be used.

4 E. A. Lee, Concurrent Models of Computation 1. PARTIALLY ORDERED SETS - SOLUTIONS

4. Classify each of the following as a partial order , a relation, or neither. State whether it is a CPO.

(a) The set of words A∗ over a non-empty alphabet A with a relation v defined by

x v y ⇐⇒ ∃ z ∈ A∗ : x.z = y,

where x.z denotes concatenation.

Solution: This is an order relation. It has a least element, λ. It is not a CPO. The chain {a, aa, aaa, aaaa, ···}, for some a ∈ A, has no upper bound in the set.

(b) The set A = {seconds, grams, meters, pounds, yards} of units and a relation R defined by (a,a0) ∈ A if a can be converted to a0 by scaling by a unitless constant.

Solution: This is neither because it does not satisfy the antisymmetric property. It is not a CPO because it is not an order relation.

(c) The set D of all countable (including finite) of R, ordered by the subset order. Hint: It may be easier to use Definition ?? for a CPO, rather than Definition ??.

Solution: This is not a CPO. The following proof is due to Eleftherios Matsikoudis: The set D of all countable subsets of reals is a . It is non-empty, and for every two countable subsets of reals, there is an upper bound in D of the two subsets, namely their union. But D does not have an upper bound in D. The sets in D can contain any real , so the only upper bound of D with respect to subset inclusion is the set of all reals, which is uncountable and therefore not in D. Thus, D is not a CPO with respect to subset inclusion. The following proof, due to Ben Lickly, uses Definition ??. Any such proof appears to require the of choice or some equivalent statement. One statement equivalent to the axiom of choice is Zorn’s lemma, which states that a poset (A,≤) for which every chain has an upper bound has a maximal element. A maximal element is an a ∈ A where there is no a0 ∈ A such that a < a0. Lickly’s proof assumes that D is a CPO and then reaches a contradiction. If D is a CPO, then by Definition ??, every chain has an upper bound, so Zorn’s lemma applies. But D does not have a maximal element. Given any countable subset of the reals, one can always add one more to the set and the resulting set is still countable. So D has no maximal element, and hence D must not be a CPO.

(d) The set {1/n | n ∈ N} ∪ {0}, ordered by the natural numeric order (where 1/0 is interpreted as ∞).

Solution: This is a total order and a CPO. It clearly has a bottom element, and every chain has a LUB in the set.

(e) The set {1/n | n ∈ N}, ordered by the reverse numeric order (where again 1/0 is interpreted as ∞).

E. A. Lee, Concurrent Models of Computation 5 1. PARTIALLY ORDERED SETS - SOLUTIONS

Solution: This is a total order, but not a CPO because the set itself has no least upper bound in the set.

6 E. A. Lee, Concurrent Models of Computation 5 Synchronous-Reactive Models

Solutions

1. This exercise studies the use of absent events in SR.

(a) As a warmup, use Sequence and When to construct an SR model that generates a sequence of values true interspersed with absent. For example, produce the sequence

(true, absent, absent, true, absent, true, true, true, absent) .

Make sure your model adequately displays the output. In particular, absent should be visible in the display.1

Solution: The following model will do the job:

where the InstanceOfTickDisplay is the composite actor shown below, created to format the output:

1Note that you could use TrueGate to implement this more simply, but part of the goal of this exercise is to fully understand When.

17 5. SYNCHRONOUS-REACTIVE MODELS - SOLUTIONS

The output is: Tick 0 : true Tick 1 : Tick 2 : Tick 3 : true Tick 4 : Tick 5 : true Tick 6 : true Tick 7 : true Tick 8 :

(b) Use Default, When, and Const to create a composite actor IsAbsent that given any input se- quence, produces an output true at every tick when the input is absent, and otherwise produces the output absent.2

Solution: The following model will do the job:

(c) Create a composite actor that can recognize the difference between single and double mouse clicks. Your actor should have an input port named click, and two output ports, singleClick and doubleClick. When a true input at click is followed by N absents, your actor should produce output true on singleClick, where N is a parameter of your actor. If instead a second true input occurs within N ticks of the first, then your actor should output a true on doubleClick. How does your model behave if given three values true within N ticks on input port click?

Solution: The following model will do the job:

2Again, a simpler implementation is available using IsPresent, but the goal of this exercise is to fully under Default.

18 Ptolemaeus, System Design, Modeling, and Simulation: Solutions 5. SYNCHRONOUS-REACTIVE MODELS - SOLUTIONS

(d) Extra credit: Redo (a)-(c) by writing a custom a Java actor for each of the three functions above. How does this design compare with the design implemented using primitive SR actors? Is it more or less understandable? Complex?

http://Ptolemy.org/systems 19 2 Synchronous Systems

Solutions

1. Suppose A = {⊥} ∪ N is a flat CPO with ⊥ at the bottom and each element of N immediately above ⊥. Each element of N is incomparable with all other elements of N. Consider a function f : A2 → A given by, for all a1,a2 ∈ A,

 a a  ⊥ if 1 = 2 = ⊥ f (a1,a2) = a1 if a1 ∈ N  a2 + 1 otherwise

(a) Is this function strict?

Solution: The function is not strict. Even without knowing anything about the second argu- ment, if it knows the first, it may be able to assert the output.

(b) Suppose this function is used in the following SR model:

where d = 1 is produced on every tick by the left actor. Find all possible outputs of f . Is there a least fixed point?

Solution: The output of f can be any n ∈ N. These are all incomparable, so there is no least fixed point.

(c) Show that this function is not monotonic.

9 2. SYNCHRONOUS SYSTEMS - SOLUTIONS

Solution: Counterexample: (⊥,1) ≤ (1,1) but f (⊥,1) = 2 is incomparable with f (1,1) = 1.

10 E. A. Lee, Concurrent Models of Computation 2. SYNCHRONOUS SYSTEMS - SOLUTIONS

2. Suppose D is a set of data values and A = {⊥,absent}∪D is a flat CPO with ⊥ at the bottom. Consider 2 a function g: A → A given by, for all a1,a2 ∈ A,

 absent a a absent  if 1 = 2 = g(a1,a2) = d if a1 ∈ D or a2 ∈ D  ⊥ otherwise

for some d ∈ D.

(a) Is this function strict?

Solution: The function is not strict. It can assert a known output if one input is known to be in D.

(b) Is this monotonic? continuous?

Solution: The function is monotonic, as can be verified by exhaustive search. Since all chains in the CPO are finite, every is continuous, so the function is also continuous.

(c) Is this function sequential?

Solution: The function is not sequential. In particular, note that g(⊥,⊥) = ⊥. If it were sequential, then then would need to be true that either g((d1),⊥) = ⊥ or g(⊥,(d2)) = ⊥. That is, it would need to be true that the function was blocked on one of the two inputs. But neither of these is true for d1,d2 ∈ D.

(d) Suppose this function is used in the following SR model:

where d ∈ D is produced on every tick by the left actor. What is the output of g on each tick? What if d is replaced with absent in the source actor on the left? Assume the constructive semantics.

Solution: The output is d. If d is replaced by absent, then the output is ⊥.

E. A. Lee, Concurrent Models of Computation 11 2. SYNCHRONOUS SYSTEMS - SOLUTIONS

3. The following questions relate to the following circuit diagram, which should be interpreted under synchronous semantics:

(a) Is this circuit sequential or combinational? Explain.

Solution: It is sequential, because with input (x,y) = (1,0), the output depends on previous inputs.

(b) For input (x,y) = (0,1), is the circuit constructive? Explain.

Solution: YES. Start with (w,z) = (⊥,⊥). Evaluate either gate, and either w or z become known. Then evaluate the other gate, and the other becomes known. The end result is (w,z) = (0,1).

(c) For input (x,y) = (1,0), is the circuit constructive? Explain.

Solution: NO. Start with (w,z) = (⊥,⊥). Evaluate either gate, and we remain at (w,z) = (⊥,⊥), which is therefore the least fixed point.

(d) Perform symbolic execution, and find the characteristic functions for nodes w and z as a function of x and y. (e) Use your result from part (d) to show whether the circuit is constructive. Solution: The circuit is constructive if for all x,y,

0 1 fw(x,y) + fw(x,y) = 1 0 1 fz (x,y) + fz (x,y) = 1

Using the solutions from part (d), this becomes

x¯+ y · x = 1 x¯· y¯+ y = 1.

If (x,y) = (1,0), then these become

0 + 0 · 1 = 1 0 · 1 + 0 = 1,

both of which are false. Therefore, the circuit is not constructive.

12 E. A. Lee, Concurrent Models of Computation