Abstraction 南京地铁一号线 南京地二号线 南索地铁一号线南延线 十神电宝过 克间于四一计国H许-美 Formal Semantics of Prog.Lang. 09/07/2018
Abstraction Formal Semantics of Prog. Lang. 09/07/2018
Formal Semantics To assign mathematical meanings to language contructs programs A scientific way to study PL and programming -"developing general abstractions" -"considers software behavior in a rigorous and general way" ·More than testing Formal Semantics of Prog.Lang. 09/07/2018
Formal Semantics • To assign mathematical meanings to language contructs & programs • A scientific way to study PL and programming – “developing general abstractions” – “considers software behavior in a rigorous and general way” • More than testing Formal Semantics of Prog. Lang. 09/07/2018
factorial(n c=n; result 1; while (c>1){ result result c; C=c-1; return result; } Is it correct? What do we mean by correctness? Formal Semantics of Prog.Lang 09/07/2018
Formal Semantics of Prog. Lang. 09/07/2018 factorial( n ) { c = n; result = 1; while (c>1) { result = result * c; c = c-1; } return result; } Is it correct? What do we mean by correctness?
factorial(n This isn't right.It's not even wrong. (Wolfgang Pauli) izquotes.com What do we mean by correctness? Formal Semantics of Prog.Lang 09/07/2018
Formal Semantics of Prog. Lang. 09/07/2018 factorial( n ) { c = n; result = 1; while (c>1) { result = result * c; c = c-1; } return result; } Is it correct? What do we mean by correctness?
{n20} factorial(n { c =n; result 1; result n!/c!} while (c>1) resultresult c; C=c-1; } {result=n/c!c=1} return result; } result n! Formal Semantics of Prog.Lang. 09/07/2018
factorial( n ) { c = n; result = 1; while (c>1) { result = result * c; c = c-1; } return result; } Formal Semantics of Prog. Lang. 09/07/2018 { result = n!/c!} { result = n!/c! c=1} { n 0 } { result = n! }