MIT计算机科学中的数学学习笔记(一): state machine

Proof

define: m|a => exist a Integer number k, make m equals to k * a
Invariant: P(n) = “if (x, y) is the state after n transitions, then m|x, m|y”

problem

we have two jugs, the one only can fill with 3 gals water, another one can only fill with 5 gals water. We need a jug fill with 4 gals water.

State machine

(a=3,b=3)
define state pairs(x,y)
x=#a, y=#b
start states: (0,0)

Transitions

emyting:
(x,y) to (0,y)
(x,y) to (x,0)
filling:
(x,y) to (a,y)
(x,y) to (x,b)
pouring:
(x,y) to (0, x+y) when x+y<=b
(x,y) to (x - (b-y), b) when x+y>=b
(x,y) to (x+y,0) when x+y<=a
(x,y) to (a,y-(a-y)) when x+y>=a

How to proof

Base case: (0,0), m|0 => p(0) is true
Inductive step: assume P(n) is true, to proof P(n+1) is true.
if P(n+1) is true : m|y-(a-x),m|x-(b-y),m|(x+y),m|x,m|y,m|a,m|b,m|0 need be true
Because p(n)=> m|a, m|b,m|x, m|y,m|0 so P(n+1) is true,
Proof ends.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值