Главная » Просмотр файлов » 3. Verification of sequential and concurrent programs. Apt_ Olderog (3rd edition) (2010)

3. Verification of sequential and concurrent programs. Apt_ Olderog (3rd edition) (2010) (811405), страница 77

Файл №811405 3. Verification of sequential and concurrent programs. Apt_ Olderog (3rd edition) (2010) (3. Verification of sequential and concurrent programs. Apt_ Olderog (3rd edition) (2010).pdf) 77 страница3. Verification of sequential and concurrent programs. Apt_ Olderog (3rd edition) (2010) (811405) страница 772020-08-25СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 77)

. ., zn and they are not free inp or Bi , (12.18) implies by the soundness of the invariance rule A6|=tot {p ∧ INV ∧ Bi ∧ SCH i } UPDATE i {p ∧ INV ∧ Bi }.(12.19)Now by the soundness of the composition rule, (12.19) and (12.17) imply(12.16).⊓⊔Define the expression t′ by the following substitution performed on t:t′ ≡ t[zi := zi + n]i∈{1, . . . , n} .This substitution represents a shift by n in the values of zi .

It allows us toconsider t in the following claim only for values zi ≥ 0 whereas t′ takes careof all the values that are possible for zi due to the invariant INV of thescheduler FAIR, namely zi ≥ −n.44012 FairnessClaim 2 For i ∈ {1, . . . , n}|=tot {p ∧ Bi ∧ z̄ ≥ 0∧ ∃zi ≥ 0 : t[zj := if Bj then zj + 1 else zj fi]j6=i = α}Si(12.20){t < α}implies|=tot {p ∧ INV ∧ Bi ∧ SCH i ∧ t′ = α}UPDATE i ; Si{t′ < α}.(12.21)Proof of Claim 2. Fix i ∈ {1, .

. . , n}. Since the variables z1 , . . ., zn are notfree in p, Bi or Si , substituting for j ∈ {1, . . . , n} the expression zj + n for zjin the pre- and postcondition of (12.20) yields:|=tot {p ∧ Bi ∧ z̄ ≥ −n∧ ∃zi ≥ −n : t′ [zj := if Bj then zj + 1 else zj fi]j6=i = α}Si(12.22){t′ < α}.We use here the abbreviationz̄ ≥ −n ≡ z1 ≥ −n ∧ .

. . ∧ zn ≥ −nand the definition of t′ . This explains the change in the range of the existentialquantifier over the bound variable zi .Next, by the truth of the axioms for ordinary and random assignments 2and 37 and the soundness of the conditional rule 4 and the consequence rule 6we get|=tot {zi ≥ −n ∧ t′ = α}UPDATE i(12.23){∃zi ≥ −n : t′ [zj := if Bj then zj + 1 else zj fi]j6=i = α}.INV implies zi ≥ −n, so combining (12.19), established in the proof of Claim1, and (12.23) yields by the soundness of the conjunction rule A4 and of theconsequence rule|=tot {p ∧ INV ∧ Bi ∧ SCH i ∧ t′ = α}UPDATE i(12.24){p ∧ INV ∧ Bi∧ ∃zi ≥ −n : t′ [zj := if Bj then zj + 1 else zj fi]j6=i = α}.Since INV implies z̄ ≥ −n, the postcondition of (12.24) impliesp ∧ Bi ∧ z̄ ≥ −n∧ ∃zi ≥ −n : t′ [zj := if Bj then zj + 1 else zj fi]j6=i = α,12.7 Verification441the precondition of (12.22).

Thus, by the soundness of the consequence ruleand the composition rule, (12.24) and (12.22) imply (12.21).⊓⊔Claim 3p ∧ z̄ ≥ 0 → t ∈ W(12.25)p ∧ INV → t′ ∈ W.(12.26)impliesProof of Claim 3. By the definition of INV , the implicationp ∧ INV → p ∧ z̄ + n ≥ 0holds, with z̄ + n ≥ 0 abbreviating z1 + n ≥ 0 ∧ . . . ∧ zn + n ≥ 0. Also,substituting everywhere in (12.25) the expression zi + n for zi , i ∈ {1, .

. . , n},yields:p ∧ z̄ + n ≥ 0 → t[zi := zi + n]i∈{1, . . . , n} ∈ W.Thus, by the definition of t′ , (12.26) follows.⊓⊔We now return to the main proof. By Claims 1–3, the truth of the premises(1)–(3) of the fair repetition rule 39 implies the truth of the following (correctness) formulas (in the sense of total correctness):{p ∧ INV ∧ Bi ∧ SCH i } UPDATE i ; Si {p ∧ INV },{p ∧ INV ∧ Bi ∧ SCH i ∧ t = α} UPDATE i ; Si {t′ < α}, i ∈ {1, . . . , n},p ∧ INV → t′ ∈ W .Also {p} INIT {p ∧ INV } is true, since z1 , . .

., zn do not appear in p. Thesoundness of the composition rule and the repetitive command III rule 38implies the truth ofVn{p} INIT ; do ⊓⊔ni=1 Bi ∧ SCH i → UPDATE i ; Si od {p ∧ i=1 ¬Bi },that is, the truth of{p} Tfair (S) {p ∧Vni=1¬Bi },all in the sense of total correctness. This concludes the proof of Theorem 12.4.⊓⊔Corollary 12.2. (Soundness of FN) The proof system FN is sound forfair total correctness of one-level nondeterministic programs.44212 Fairness12.8 Case Study: Zero SearchIn this section we study a nondeterministic solution to our introductory problem of zero search.

Recall from Section 1.1 that given a function f from integers to integers the problem is to write a program that finds a zero of fprovided such a zero exists.Here we consider the nondeterministic programZERO-N ≡ f ound := false; x := 0; y := 1;do ¬f ound → x := x + 1;f ound := f (x) = 0⊓⊔ ¬f ound → y := y − 1;f ound := f (y) = 0od.ZERO-N searches for a zero of f with the help of two subprograms: oneis searching for this zero by incrementing its test values (x := x + 1) and theother one by decrementing them (y := y − 1). The idea is that ZERO-N findsthe desired zero by activating these subprograms in a nondeterministic, butfair order.Summarizing, we wish to prove|=fair {∃u : f (u) = 0} S {f (x) = 0 ∨ f (y) = 0}.The correctness proof takes place in the new proof system FN and is dividedinto three steps.Step 1 We first show that ZERO-N works correctly if f has a positive zerou:|=fair {f (u) = 0 ∧ u > 0} ZERO-N {f (x) = 0 ∨ f (y) = 0}.A proof outline for fair total correctness has the following structure:{f (u) = 0 ∧ u > 0}f ound := false;x := 0;y := 1;{f (u) = 0 ∧ u > 0 ∧ ¬f ound ∧ x = 0 ∧ y = 1}{inv : p}{bd : t}do ¬f ound → {p ∧ ¬f ound}x := x + 1;f ound := f (x) = 0{p}⊓⊔ ¬f ound → {p ∧ ¬f ound}y := y − 1;f ound := f (y) = 0(12.27)12.8 Case Study: Zero Search443{p}od{p ∧ f ound}{f (x) = 0 ∨ f (y) = 0}.It remains to find a loop invariant p and a bound function t that will completethis outline.Since the variable u is left unchanged by the program ZERO-N, certainlyf (u) = 0 ∧ u > 0is an invariant.

But for the completion of the proof outline we need a strongerinvariant relating u to the program variables x and f ound. We take as anoverall invariantp ≡f (u) = 0 ∧ u > 0 ∧ x ≤ u∧ if f ound then f (x) = 0 ∨ f (y) = 0 else x < u fi.Notice that the implicationsf (u) = 0 ∧ u > 0 ∧ ¬f ound ∧ x = 0 ∧ y = 1 → pandp ∧ f ound → f (x) = 0 ∨ f (y) = 0are obviously true and thus confirm the proof outline as given outside the doloop.To check the proof outline inside the loop, we need an appropriate boundfunction.

We observe the following hierarchy of changes:• by the assumption of fairness, executing the second loop component bringsus closer to a switch to the first loop component,• executing the first loop component brings us closer to the desired zero uby incrementing the test value x by 1.Hence, we take as partial order the setP = Z × Z,ordered lexicographically by <lex and well-founded on the subsetW = N × N,and as bound functiont ≡ (u − x, z1 ).In t the scheduling variable z1 counts the number of executions of the secondloop component before the next switch to the first one, and u−x, the distancebetween the current test value x and the zero u, counts the remaining numberof executions of the first loop component.44412 FairnessWe now show that our choices of p and t complete the overall proof outlineas given inside the do loop.

To this end, we have to prove in system FN thepremises (1′ )–(3′ ) of the fair repetition rule 39′ .We begin with premise (1′ ). For the first loop component we have thefollowing proof outline:{p ∧ ¬f ound}{f (u) = 0 ∧ u > 0 ∧ x < u}x := x + 1{f (u) = 0 ∧ u > 0 ∧ x ≤ u}{f (u) = 0 ∧ u > 0 ∧ x ≤ u∧ if f (x) = 0 then f (x) = 0 else x < u fi}f ound := f (x) = 0{f (u) = 0 ∧ u > 0 ∧ x ≤ u∧ if f ound then f (x) = 0 else x < u fi}{p}.Clearly, all implications expressed by successive assertions in this proof outline are true.

The assignments are dealt with by backward substitution of theassignment axiom.This is also the case for the proof outline of the second loop component:{p ∧ ¬f ound}{f (u) = 0 ∧ u > 0 ∧ x < u}y := y + 1{f (u) = 0 ∧ u > 0 ∧ x < u}{f (u) = 0 ∧ u > 0 ∧ x < u ∧ f (y) = 0 → f (y) = 0}f ound := f (y) = 0{f (u) = 0 ∧ u > 0 ∧ x < u ∧ f ound → f (y) = 0}{f (u) = 0 ∧ u > 0 ∧ x ≤ u∧ if f ound then f (y) = 0 else x < u fi}{p}.We now turn to premise (2′ ) of rule 39′ . For the first loop component wehave the proof outline:{¬f ound ∧ f (u) = 0 ∧ u > 0 ∧ x < u∧ z1 ≥ 0 ∧ z2 ≥ 0 ∧ ∃z1 ≥ 0 : (u − x, z1 ) = α}{∃z1 ≥ 0 : (u − x, z1 ) = α}{(u − x − 1, z1 ) <lex α}x := x + 1;{(u − x, z1 ) <lex α}f ound := f (x) = 0{(u − x, z1 ) <lex α}{t <lex α}.Thus the bound function t drops below α because the program variable x isincremented in the direction of the zero u.12.8 Case Study: Zero Search445For the second loop component we have the proof outline:{¬f ound ∧ f (u) = 0 ∧ u > 0 ∧ x < u∧ z1 ≥ 0 ∧ z2 ≥ 0 ∧ (u − x, z1 + 1) = α}{(u − x, z1 + 1) = α}{(u − x, z1 ) <lex α}y := y − 1;f ound := f (y) = 0{(u − x, z1 ) <lex α}{t <lex α}.Notice that we can prove that the bound function t drops here below α onlywith the help of the scheduling variable z1 ; the assignments to the programvariables y and f ound do not affect t at all.Finally, premise (3′ ) of rule 39′ follows from the implicationsp ∧ z̄ ≥ 0 → x ≤ u ∧ z1 ≥ 0andx ≤ u ∧ z1 ≥ 0 → t ∈ W.This completes the proof of (12.27).Step 2 Next we assume that f has a zero u ≤ 0.

The claim now is|=fair {f (u) = 0 ∧ u ≤ 0} ZERO-N {f (x) = 0 ∨ f (y) = 0}.(12.28)Its proof is entirely symmetric to that of Step 1: instead of the first loopcomponent now the second one is responsible for finding the zero.In fact, as loop invariant we takep≡f (u) = 0 ∧ u ≤ 0 ∧ u ≤ y∧ if f ound then f (x) = 0 ∨ f (y) = 0 else u < y fiand as bound functiont ≡ (y − u, z2 ).The well-founded structure is as before:W = N × N.Step 3 We combine the results (12.27) and (12.28) of Step 1 and Step 2.Using the disjunction rule A3 and the rule of consequence, we obtain|=fair {f (u) = 0} ZERO-N {f (x) = 0 ∨ f (y) = 0}.A final application of the ∃-introduction rule A5 yields|=fair {∃u : f (u) = 0} ZERO-N {f (x) = 0 ∨ f (y) = 0},44612 Fairnessthe desired result about ZERO-N.12.9 Case Study: Asynchronous Fixed PointComputationIn this section we verify a nondeterministic program for computing fixedpoints.

Характеристики

Список файлов книги

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6374
Авторов
на СтудИзбе
309
Средний доход
с одного платного файла
Обучение Подробнее