Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Devise a rule of inference for verification of partial correctness of statements of the form

ifcondition1thenS1elseifcondition2thenS2elseSnwhereS1,S2,.......,Snareblocks

Short Answer

Expert verified

Thus(P¬(condition1)¬(conditon22)¬(conditionn1))SnqPif condition1thenS1if condition2thenS2..elseSnq.

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

Over 22 million students worldwide already upgrade their learning with Vaia!

01

Inference of the program segment rule.

Suppose that program S is divided into subprogramsS1 andS2 , denote byS=S1:S2

Assume the correctness ofS1 with respect to the initial statement p and the final statement q, the correctness ofS2 with respect to the initial statement p, and the final statement r.

A rule of inference called a compositional rule that can be stated as

pS1qqS2rpS1,S2r

02

Given

Given in the question,

ifcondition1thenS1elseifcondition2thenS2elseSnwhereS1,S2,.......,Snareblocks

03

Solution

We know here we solve our question, let P be the initial assertion.

Let q be the final assertion, if the condition is true thenS1will get executed.

So,

Pcondition1)S1q

If condition 2 is true and condition 1 is false.

ThenS2will be executed.

So, (P¬(condition1)(conditon2))S1q.

Similarly,

(P¬(condition)¬(condition)........(conditionn-1)){Sn}q

entire statement.

So,

(Pcondition1)S1q(P¬(condition1)(conditon2))S1q(P¬(condition1)¬(conditon2)¬(conditionn1))SnqPif condition1thenS1if condition2thenS2..elseSnq.

Hence,(P¬(condition1)¬(conditon2)¬(conditionn1))SnqPif condition1thenS1if condition2thenS2.elseSnq

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Study anywhere. Anytime. Across all devices.

Sign-up for free