1 / 2

Dijkstra 의 mini-language

Dijkstra 의 mini-language. 〈 문장 〉 → abort | skip | x 1 , x 2 , …, x n := E 1 , E 2 , … , E n | 〈 문장 〉 ; 〈 문장 〉 | if B 1 → SL 1 | B 2 → SL 2 | … | B n → SL n fi | do B 1 → SL 1 | B 2 → SL 2 | … | B n → SL n od . 동시 배정 (concurrent assignment) x , y := y , x

Télécharger la présentation

Dijkstra 의 mini-language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dijkstra의 mini-language • 〈문장〉 → abort | skip | x1, x2, …, xn:= E1,E2, …,En | 〈문장〉 ; 〈문장〉 | if B1→SL1| B2→ SL2| … |Bn→ SLnfi | doB1→ SL1| B2 → SL2| … |Bn → SLnod. • 동시배정(concurrent assignment) • x,y:=y,x • x = old(y) ∧ y = old(x) • x:=y; y:=x • x = old(y) ∧ y = old(y) ⇔x:= y;skip. • y:=x; x:=y • y = old(x) ∧ x= old(x)⇔ y:= x;skip. • 비결정적(nondeterministic)으로가드(guard)를선택한다. • True인 가드(Bk또는 Bm)가둘이상이면 그 중 아무나(nondeterministic) 선택한다. • ifx ≥ y→m := x|x≤ y→m:= yfi (m = x ∨ m = y) ∧ (m≥ x) ∧ (m≥ y). • if-fi 구조에서 true인가드가 하나도 없으면abort이다. • iffi⇔ abort. ifx ≥ ythen m := xelse m := y fi ifx> ythen m := xelse m := y fi 한국과학기술원 전산학과 최광무

  2. Loop invariance와 terminating 조건 • do-od 구조는true인 가드가 없으면 loop이 끝난다. • do-od ⇔ skip. • 간단한 do-od프로그램. q1, q2, q3, q4:=Q1, Q2, Q3,Q4; doq1> q2 →q1, q2:= q2, q1 | q2> q3 → q2, q3 := q3, q2 | q3> q4 → q3, q4 := q4, q3 od • do-od프로그램이 끝나고나면, • ¬(q1> q2) ∧ ¬(q2> q3) ∧ ¬(q3> q4) • (q1 ≤ q2) ∧ (q2 ≤ q3) ∧ (q3 ≤ q4) • q1 ≤ q2 ≤ q3≤ q4. • s := 0; for i:=1 to 100 do s := s + i od • Loop invariance condition • Loop 시작직전 • Initialize • Loop 탈출 test 할때 • Update • Loop을 나와서도 만족한다. • Aftertermination • Loop termination condition • Loop을 한 번 돌 때 마다 반드시감소(단조감소; monotonically decreasing)하는 양 함수 for (init; test; update) for (s=0, i=1; i<=100; i++) s += i; Loop invariance s = 1 + 2 + … + (i-1) 초기상황 s = 1 + … (1-1) = 0 최종상황 ((s = 1 + 2 + … + (i-1)) ∧ (i = 101)) = (s = 1 + 2 + … + 100). Update s = 1 + 2 + … + i∧ i++ = s = 1 + 2 + … + (i-1) Loop termination f(i) = 101 – i. 한국과학기술원 전산학과 최광무

More Related