CS 476 Programming Language Design William Mansky Dynamic
- Slides: 35
CS 476 – Programming Language Design William Mansky
Dynamic Semantics • What is the “meaning” of a program? • The values it computes, its intermediate states: operational semantics • The specification it fulfills, the pre- and postconditions it satisfies: axiomatic semantics • The mathematical function it implements, the program in another language it corresponds to: denotational semantics 1
Axiomatic Semantics • What is true about a program? What can we assert about it? r = 1; while(x > 0){ r = r * x; x = x – 1; } “r is x!” 2
Axiomatic Semantics • What is true about a program? What can we assert about it? “x is some number n” r = 1; while(x > 0){ r = r * x; x = x – 1; } “r is n!” 3
Axiomatic Semantics • What is true about a program? What can we assert about it? {x=n} r = 1; while(x > 0){ r = r * x; x = x – 1; } { r = n! } precondition postcondition 4
Floyd-Hoare Logic • 5
Floyd-Hoare Logic • 6
IMP: Syntax E : : = <#> | <ident> |E+E|E–E|E*E | <bool> | E and E | E or E | not E |E=E | if E then E else E C : : = <ident> : = E | C; C | skip | if E then C else C | while E do C 7
Floyd-Hoare Logic: Rules 8
Floyd-Hoare Logic: Rules “rule of consequence” 9
Floyd-Hoare Logic: Rules “rule of consequence” 10
Floyd-Hoare Logic: Rules “rule of consequence” 11
Floyd-Hoare Logic: Rules “rule of consequence” 12
Floyd-Hoare Logic: Control Flow Rules 13
Floyd-Hoare Logic: Control Flow Rules 14
Floyd-Hoare Logic: Control Flow Rules 15
Floyd-Hoare Logic: Control Flow Rules 16
Floyd-Hoare Logic: Control Flow Rules loop invariant • Note: this doesn’t guarantee that the loop will terminate! 17
Floyd-Hoare Logic: Example 18
Floyd-Hoare Logic: Example 19
Floyd-Hoare Logic: Example 20
Floyd-Hoare Logic: Example 21
Floyd-Hoare Logic: Example 22
Floyd-Hoare Logic: Example 23
Floyd-Hoare Logic: Example 24
Floyd-Hoare Logic: Example 25
Floyd-Hoare Logic: Annotating Code • 26
Floyd-Hoare Logic: Annotating Code • 27
Floyd-Hoare Logic: Annotating Code • 28
Floyd-Hoare Logic: Annotating Code • 29
Floyd-Hoare Logic: Annotating Code • { r * x! = n!} 30
Floyd-Hoare Logic: Annotating Code • 31
Floyd-Hoare Logic: Annotating Code • 32
Axiomatic and Operational Semantics • 33
Advantages of Axiomatic Semantics • Pre- and postcondition summarize the meaning of a program • Axiomatic semantics is a form of symbolic execution • A Hoare triple is also a concise specification for a program: we can write down the intended behavior, and then prove that the program has that behavior • Trivia: Sir Tony Hoare also invented quicksort, and was knighted for his service to computer science 34
- William mansky
- William mansky
- William mansky
- Greedy algorithm vs dynamic programming
- General method of dynamic programming
- Roman (500 b.c.– a.d. 476)
- Cs 476
- Rounding key words
- 476 a 1453
- Solange ferradura
- Symmetrical components in power system pdf
- Paminklas
- 476 a 1453
- That "rome fell in a.d. 476" means
- 12 tables of roman law
- 476 fighter group
- Bistogram cikajang
- 476 bus times
- Ece 476
- Power systems
- Dhol chantier
- Ie 476
- Ntp 476
- I.sz. 476
- Ece 476
- Ece 476
- Rome 509
- Ece 476
- Ece 476
- Ece 476
- Ece 476
- Ece 476
- What is hdl hardware description language
- Dynamic dynamic - bloom
- Tabulation in dynamic programming
- Matrix chain multiplication formula