C.A.R. Hoare??????? - PowerPoint PPT Presentation

About This Presentation
Title:

C.A.R. Hoare???????

Description:

Title: PowerPoint Presentation Last modified by: zhaojianhua Created Date: 1/1/1601 12:00:00 AM Document presentation format: (4:3) Other titles – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 16
Provided by: educ5480
Category:

less

Transcript and Presenter's Notes

Title: C.A.R. Hoare???????


1
????????
  • ???
  • ????????

2
??
  • C.A.R. Hoare???????
  • ?????????????
  • ?????
  • ??????????,???????????,??????????
  • ???????????????.

3
?????
  • Hoare???
  • P S Q
  • S ??
  • P(pre-condition,????)
  • Q (post-condition,????)
  • P?Q???????
  • ?????????????
  • ??S?????P???????,?S ????????,?????????Q?

4
???????
  • ????
  • ????ve
  • skip??
  • ????
  • ??SS
  • ??if p then S else S fi
  • ??while p do S

5
??????
  • Qe/v ve Q
  • ????ve????????? Qe/v,??ve?????????Q?
  • Qe/v?????Q??v????e???????
  • ??x110xx1x10

6
??skip??
  • skip????????
  • P skip P

7
pre,post??
  • ??????????,???????????,??????????
  • PgtP,P S Q
  • P S Q
  • P S Q,Q gt Q
  • P S Q

8
??????
  • ??????????????,?????????????????,?????????????????
    ?
  • P S1 Q, QS2R
  • P S1S2 R

9
if-then-else??
  • P?p S1 Q ,P??p S2 Q
  • P if p then S1 else S2 Q
  • if????????p??,???S1,????S2?
  • ??????
  • ????????P?p?????S1 ????Q?
  • ????????P??p,????S??????Q?
  • ????????P,???????P?p,????P??p??if????????????????

10
while??(?????)
  • P?p S P
  • Pwhile p do S f??P
  • P???while???????
  • ?while????????,?????????
  • ?while??????p??????
  • ??,?while???????,??????P??p?
  • ???????while???????

11
while??(?????)
  • ??????????f
  • f??????????,?
  • P?p ? fgt0
  • ???????f0,
  • ff0 S fltf0,
  • ????????
  • for(int i 0 ilt100 i)

12
??(1)
  • ?????????
  • y10
  • y2x1
  • while y2gtx2 do
  • y1y11
  • y2y2-x2
  • end
  • ???????
  • ?x1gt0, x2gt0???,?????y1?x1/x2??????,y2?x1/x2?????
    ?
  • Precondition x1gt0 ? x2gt0
  • Postconditionx1y1x2y2 ? y2gt0 ? y2ltx2

13
??(2)
  • ??????????
  • x1gt0 ? x2gt0
  • y10
  • x1gt0 ? x2gt0 ? y10
  • y2x1
  • x1y1x2y2 ? y2gt0
  • while y2gtx2 do
  • x1y1x2y2 ? y2gtx2
  • y1y11
  • x1y1x2y2-x2 ? y2gtx2
  • y2y2-x2
  • x1y1x2y2 ? y2gt0
  • end
  • x1y1x2y2 ? y2gt0 ? y2ltx2

14
??
  • ?????????GCD?????????
  • ??????????Floyd???????

15
Hoare Logic??????/??
  • ??1
  • true mm2 3 mm2 3
  • ???m22?,
  • ????,m2??3,mm2??????m3,?????3!
  • ??2
  • p q pp1 p q1
  • ?p?q????????,?????pq?????
Write a Comment
User Comments (0)
About PowerShow.com