Question: 2 . Specifications ( 1 0 p , Questions 7 9 ) Recall that we often want to translate specifications written in English into predicate

2. Specifications (10p, Questions 79) Recall that we often want to translate specifications written in English into predicate logic. For example, we may translate B[1..n]
contains duplicates into i, j in 1... n : i 6= j B[i]= B[j]. Now consider the specification:
Given a non-increasing array B[1..n], and a value v, return 0 if v does not occur
in B[1..n], but otherwise return the index of one of the occurrences.
Example: if B[1..6] is 123456
211713131110 then if v =11 then 5 must be returned;
if v =12 then 0 must be returned; if v =13 then either 3 or 4 must be returned.
For that specification, you must express in predicate logic
7.(3p) the precondition, that is, what is assumed about B[1..n] and v.
and next the postcondition, that is, what is required about r where r is the value returned.
We can write the postcondition as (r 6=0\Phi 1)(r =0\Phi 2).
8.(3p) What should \Phi 1 be?
9.(4p) What should \Phi 2 be?
Whenever B occurs in your specification it must be as part

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!