SWE 637 Homework 6 Solution
Fall 2006
Logic Coverage: Due 10/31, beginning of class


My job as an engineer is not to invent new mathematics, but to find new ways to use old mathematics.
- Dave Parnas

Answer the following questions. Bring hardcopies of your answers to class, hand written or printouts. All homeworks are due before class on the due date. Please remember that the GMU Honor Code is in effect: You may discuss the assignment with each other, the professor, or the GTA, but each homework should be done individually.

  1. Logic Coverage. (20 pts)
    Use the following program fragment to answer the questions below:
       if ((a && b) || (a && c)
          f();
       
    It yields the predicate:
             p = (a ∧ b) ∨ (a ∧ c)
    1. Identify the clauses in this predicate.
      • a (two occurrences)
      • b
      • c
    2. Write the complete truth table for all clauses. Label your rows starting from 1, where row number 1 is all TRUE and the last row is all FALSE. (Hint: It may look like there are 24 = 16 rows, but in fact there are fewer).
      There is no need to list rows that contain different values for the same variable.
        (a b) (a c) p
      1.T T t TT
      2.T T t FT
      3.T F t TT
      4.T F t FF
      5.F T f TF
      6.F T f FF
      7.F F f TF
      8.F F f FF
    3. Cross out the rows in your table that are infeasible because of the repeated occurrence of b.
      If 16 rows had been listed (24), 8 would need to be crossed out, leaving the 8 above. No rows need to be crossed out of this table.
    4. Compute and simplify pa, pb, and pc.
      pa = pa=true ⊕ pa=false
          = ((t ∧ b) ∨ (t ∧ c)) ⊕ ((f ∧ b) ∨ (f ∧ c))
          = (b ∨ c) ⊕ (f ∨ f)
          = (b ∨ c)
      pb = pb=true ⊕ pb=false
          = ((a ∧ t) ∨ (a ∧ c)) ⊕ ((a ∧ f) ∨ (a ∧ c))
          = (a ∨ (a ∧ c)) ⊕ (f ∨ (a ∧ c))
          = a ⊕ (a ∧ c)
          = a ∧ ¬ c
      pc = pc=true ⊕ pc=false
          = ((a ∧ b) ∨ (a ∧ t)) ⊕ ((a ∧ b) ∨ (a ∧ f))
          = ((a ∧ b) ∨ a) ⊕ ((a ∧ b) ∨ f)
          = a ⊕ (a ∧ b)
          = a ∧ ¬ b
    5. Identify all pairs of rows from your table that satisfy CACC for each variable.
      • for clause a:
           a is true and b or c is true : rows 1, 2 and 3
           a is false and b or c is true : rows 5, 6 and 7
           (1, 5) or (1, 6) or (1, 7) or (2, 5) or (2, 6) or (2, 7) or (3, 5) or (3, 6) or (3, 7)
      • for clause b:
           b is true and a ∧ ¬ c is t : row 2
           b is false and a ∧ ¬ c is t : row 4
           (2, 4)
      • for clause c:
           c is true and a ∧ ¬ b is t : row 3
           c is false and a ∧ ¬ b is t : row 4
           (3, 4)

      Thus, any of the following collections of rows from the table can satisfy CACC:

      • 1, 2, 3, 4, 5
      • 1, 2, 3, 4, 6
      • 1, 2, 3, 4, 7
      • 2, 3, 4, 5
      • 2, 3, 4, 6
      • 2, 3, 4, 7
    6. Identify all pairs of rows from your table that satisfy RACC for each variable. (note: The homework did not ask for RACC, but the first draft did.)
      • for clause a: (1, 5) or (2, 6) or (3, 7)
      • for clause b: (2, 4)
      • for clause c: (3, 4)

      Thus, any of the following collections of rows from the table can satisfy RACC:

      • 1, 2, 3, 4, 5
      • 1, 2, 3, 4, 6
      • 1, 2, 3, 4, 7
    1. Is this program fragment functionally equivalent to the first?
      yes
    2. List the truth assignments that will satisfy edge coverage on the second program fragment. If it does not matter whether one of the values is true or false in a test, use '*' for "don't care".
        a b c
      1.tt*-- '*' means don't care
      2.t f t 
      3.t f f 
      4.f * * 
    3. Which of your CACC tests for the first predicate satisfy edge coverage on the second program fragment?
      All of them do.
    4. Which, if any, of your CACC tests for the first predicate do not satisfy edge coverage on the second program fragment?
      All of them satisfy edge coverage.