7100-程序推理-week2

本文介绍了程序状态、霍尔三元组的概念,详细阐述了最强后条件和最弱前条件在程序正确性证明中的应用,并探讨了同时赋值、变量引入和条件控制流的推理规则。通过实例解析,帮助读者掌握如何系统地推理和验证简单顺序程序。
摘要由CSDN通过智能技术生成
  • Learning how to (systematically) reason about simple, sequential programs.
  • Learning how to prove that a method is correct.

一,Program State

        The state at a program point is a valuation of the variables in scope at that program point.
        // 状态就是在某个点时,在范围内的变量的值

二,Floyd Logic

        {P} S {Q} #霍尔三元组
                
P--precondition // requires
                S--program
                Q--postcondition
// ensures
        当 P 满足,执行 S 后,Q 就会被满足(holds)

三,Strongest Postconditions and Weakest Preconditions

        Forward Reasoning --> Strongest Postconditions
        Backward reasoning --> Weakest Preconditions

//Weaker predicates describe fewer constraints on the state (only relevant variables constrained).

//Backwards reasoning generally leads to smaller predicates and hence simpler reasoning.
// 因为简单所以weakest

四,Method Correctness

        The method is correct when its precondition implies the calculated weakest precondition.
                (
P == > WP) // Pstronger,范围更小

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值