关于debugging的思考 a什么是debug? The process of repeatedly executing an algorithm,or running a program,with the intention of finding and eliminating errors is called debugging ■为什么我们可以依赖debug来排除错误? 口程序运行的“再现”==》错误的“再现
关于debugging的思考 ◼ 什么是debug? ❑ The process of repeatedly executing an algorithm, or running a program, with the intention of finding and eliminating errors is called debugging ◼ 为什么我们可以依赖debug来排除错误? ❑ 程序运行的“再现”==》错误的“再现
Test和Debugging的局限性 Most algorithmic problems have infinite sets of legal inputs, and hence infinitely many candidate test sets,each of which has the potential of exposing a new error. Dijkstra: Program testing can be used to show the presence of bugs, but never to show their absence! 我们能够用形式系统“理解”Dijkstral的话吗?
Test和Debugging 的局限性 Dijkstra: Program testing can be used to show the presence of bugs, but never to show their absence! 我们能够用形式系统“理解”Dijkstra的话吗? Most algorithmic problems have infinite sets of legal inputs, and hence infinitely many candidate test sets, each of which has the potential of exposing a new error
Test和debug的局限性 s Debug必须以测试出的错误的可再现为前提 口只有封闭环境、确定运行,才能“再现”错误 ·开放式环境中运行的程序,debug异常困难 口分布式系统、网络平台等 ■ 确定输入,但运行时刻数据非“独占” 口非确定环境下运行的程序 ■本质上输入数据无法保证确定性 ·必须随机的算法 口程序执行存在非确定性
Test和debug的局限性 ◼ Debug 必须以测试出的错误的可再现为前提 ❑ 只有封闭环境、确定运行,才能“再现”错误 ◼ 开放式环境中运行的程序,debug异常困难 ❑ 分布式系统、网络平台等 ◼ 确定输入,但运行时刻数据非“独占” ❑ 非确定环境下运行的程序 ◼ 本质上输入数据无法保证确定性 ◼ 必须随机的算法 ❑ 程序执行存在非确定性
Infinite computation Infinite computation为什么有时也会被称为infinite loop? "以下两个例子都会形成一个infinite computation,区别在哪? while(1)do {... for(int i=0;i==9;++)1...;i++;... ■如何规避“死循环”? 口算法级 循环出口必达 ▣不合适的出口标准;循环体内使用控制变量;.. 口编程级 ■细心;循环控制中,少用“高级”的语言设施;
Infinite computation ◼ Infinite computation为什么有时也会被称为infinite loop? ◼ 以下两个例子都会形成一个infinite computation,区别在哪? ❑ while(1) do {…} ❑ for(int i=0;i==9;i++) {…;i++;…} ◼ 如何规避“死循环”? ❑ 算法级 ◼ 循环出口必达 ❑ 不合适的出口标准;循环体内使用控制变量;…… ❑ 编程级 ◼ 细心;循环控制中,少用“高级” 的语言设施;……
程序和算法正确性保障: 自动验证: some sort 当我们完成了某个算法 puts a descrip 的正确性证明,我们 ithm A that is pro外 test的,debug的是什 eed A solves 么? "人工证明:一 Can we ourselves prove our algorithms to be correct?Is there any way in which we can use formal, mathematical techniques to realize this objective?
程序和算法正确性保障: ◼ 自动验证: ❑ some sort of super-algorithm that would accept as inputs a description of an algorithmic problem P and an algorithm A that is proposed as a solution, and would determine if indeed A solves P. ◼ 人工证明: ❑ Can we ourselves prove our algorithms to be correct? Is there any way in which we can use formal, mathematical techniques to realize this objective? 当我们完成了某个算法 的正确性证明,我们 test的,debug的是什 么?