Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Q What is Eddys Current Loss?

Answered: 1 week ago