Skip to content

In-class Assignment 4

In class assignment 4 (due next Tuesday 10:59 AM, right before class).

Program 1

def mult(A,B):
    # P = {A >= 0 and B >= 0}
    x = A
    y = B
    z = 0
    # L1
    while 
      # L2
      if !(x > 0):   # enter loop when x > 0  , exit when x <= 0
        break

      if x % 2 == 1:  #x is odd
          z = z + y 
      x = x // 2
      y = y * 2
      # L3

    # L4 : find abstract values of x,y,z
    return z

Apply the abstract interpretation shown in class for the above mult program for precondition A=odd and B=even.