当前位置: 首页 > news >正文

离散数学问题集--问题5.9

问题 5.9 综合了计算机组成原理、数字逻辑和离散数学中的关键概念,旨在帮助学生理解二进制算术运算的硬件实现、逻辑门与算术运算的关系,以及如何使用数学方法来验证数字系统的正确性。它强调了从规范到实现再到验证的完整过程。

问题5.9的思路

思想

  • 函数抽象: num ⁡ ( α n ) \operatorname{num}(\alpha_{n}) num(αn):将二进制字符串映射到非负整数
  • 递归: num ⁡ ( α n + 1 ) = a n + 1 2 n + 1 + num ⁡ ( α n ) \operatorname{num}(\alpha_{n + 1})=a_{n + 1}2^{n + 1}+\operatorname{num}(\alpha_{n}) num(αn+1)=an+12n+1+num(αn)
  • 用求和位和进位来表示两个二进制数的加法:

思路

  • 加法器的抽象规范–>加法器的电路实现–>数学方法验证实现是否符合规范

拓展问题

  1. 问题5.9都考察了哪些知识点?讲到了哪些重要的结论?
  2. 如何将问题5.9的结论推广到十进制?

Problem 5.9

For any binary string α \alpha α, let num ⁡ ( α ) \operatorname{num}(\alpha) num(α) be the nonnegative integer it represents in binary notation (possibly with leading zeroes). For example, num ⁡ ( 10 ) = 2 \operatorname{num}(10)=2 num(10)=2, and num ⁡ ( 0101 ) = 5 \operatorname{num}(0101)=5 num(0101)=5.

An n + 1 n + 1 n+1-bit adder adds two n + 1 n + 1 n+1-bit binary numbers. More precisely, an n + 1 n + 1 n+1-bit adder takes two length n + 1 n + 1 n+1 binary strings
α n : : = a n . . . a 1 a 0 , β n : : = b n . . . b 1 b 0 , \begin{align*} \alpha_{n}&::=a_{n}...a_{1}a_{0},\\ \beta_{n}&::=b_{n}...b_{1}b_{0}, \end{align*} αnβn::=an...a1a0,::=bn...b1b0,
and a binary digit C 0 C_{0} C0 as inputs, and produces a length- ( n + 1 ) (n + 1) (n+1) binary string
σ n : : = s n . . . s 1 s 0 , \sigma_{n}::=s_{n}...s_{1}s_{0}, σn::=sn...s1s0,
and a binary digit c n + 1 c_{n + 1} cn+1 as outputs, and satisfies the specification:
num ⁡ ( α n ) + num ⁡ ( β n ) + c 0 = 2 n + 1 c n + 1 + num ⁡ ( σ n ) . (5.9) \operatorname{num}(\alpha_{n})+\operatorname{num}(\beta_{n})+c_{0}=2^{n + 1}c_{n + 1}+\operatorname{num}(\sigma_{n}). \tag{5.9} num(αn)+num(βn)+c0=2n+1cn+1+num(σn).(5.9)
There is a straightforward way to implement an n + 1 n + 1 n+1-bit adder as a digital circuit: an n + 1 n + 1 n+1-bit ripple-carry circuit has 1 + 2 ( n + 1 ) 1 + 2(n + 1) 1+2(n+1) binary inputs
a n , . . . , a 1 , a 0 , b n , . . . , b 1 , b 0 , c 0 , a_{n},...,a_{1},a_{0},b_{n},...,b_{1},b_{0},c_{0}, an,...,a1,a0,bn,...,b1,b0,c0,
and n + 2 n + 2 n+2 binary outputs,
c n + 1 , s n , . . . , s 1 , s 0 . c_{n + 1},s_{n},...,s_{1},s_{0}. cn+1,sn,...,s1,s0.
As in Problem 3.6, the ripple-carry circuit is specified by the following formulas:
s i : : = a i ⊕ b i ⊕ c i c i + 1 : : = ( a i ∧ b i ) ∨ ( a i ∧ c i ) ∨ ( b i ∧ c i ) \begin{align*} s_{i}&::=a_{i}\oplus b_{i}\oplus c_{i} \tag{5.10}\\ c_{i + 1}&::=(a_{i} \land b_{i}) \lor (a_{i} \land c_{i}) \lor (b_{i} \land c_{i}) \tag{5.11} \end{align*} sici+1::=aibici::=(aibi)(aici)(bici)(5.10)(5.11)
for 0 ≤ i ≤ n 0\leq i\leq n 0in, where we follow the convention that 1 1 1 corresponds to T and 0 0 0 corresponds to F.

(a) Verify that definitions (5.10) and (5.11) imply that
a n + b n + c n = 2 c n + 1 + s n . (5.12) a_{n}+b_{n}+c_{n}=2c_{n + 1}+s_{n}. \tag{5.12} an+bn+cn=2cn+1+sn.(5.12)
for all n ∈ N n \in \mathbb{N} nN.

证明:对任意的 n ∈ N n\in\mathbb{N} nN

  • 左边 = a n + b n + c n \text{左边}=a_n+b_n+c_n 左边=an+bn+cn
  • 可用 1 1 1 位的行波进位加法器来实现。它的输入为 a n a_n an b n b_n bn c n c_n cn,输出为 c n + 1 c_{n+1} cn+1 s n s_n sn
  • 根据 (5.10) 和 (5.11) 有, s n = a n ⊕ b n ⊕ c n s_{n}=a_{n}\oplus b_{n}\oplus c_{n} sn=anbncn c n + 1 = ( a n ∧ b n ) ∨ ( b n ∧ c n ) ∨ ( c n ∧ a n ) c_{n+1}=(a_{n}\land b_{n})\lor(b_{n}\land c_{n})\lor(c_{n}\land a_{n}) cn+1=(anbn)(bncn)(cnan)
  • 右边 = 2 c n + 1 + s n = 2 [ ( a n ∧ b n ) ∨ ( b n ∧ c n ) ∨ ( c n ∧ a n ) ] + a n ⊕ b n ⊕ c n \text{右边}=2c_{n+1}+s_n=2[(a_{n}\land b_{n})\lor(b_{n}\land c_{n})\lor(c_{n}\land a_{n})]+a_{n}\oplus b_{n}\oplus c_{n} 右边=2cn+1+sn=2[(anbn)(bncn)(cnan)]+anbncn

下面使用真值表来验证。

a n a_{n} an b n b_{n} bn c n c_{n} cn a n + b n + c n a_{n} + b_{n} + c_{n} an+bn+cn s n = a n ⊕ b n ⊕ c n s_{n}=a_{n}\oplus b_{n}\oplus c_{n} sn=anbncn a n ∧ b n a_{n}\land b_{n} anbn b n ∧ c n b_{n}\land c_{n} bncn c n ∧ a n c_{n}\land a_{n} cnan c n + 1 = ( a n ∧ b n ) ∨ ( b n ∧ c n ) ∨ ( c n ∧ a n ) c_{n+1} = (a_{n} \land b_{n}) \lor (b_{n}\land c_{n})\lor (c_{n}\land a_{n}) cn+1=(anbn)(bncn)(cnan) 2 c n + 1 + s n 2c_{n+1} + s_{n} 2cn+1+sn
0000000000
1001100001
0101100001
0011100001
1102010012
1012000112
0112001012
1113111113

(b) Prove by induction on n n n that an n + 1 n + 1 n+1-bit ripple-carry circuit really is an n + 1 n + 1 n+1-bit adder, that is, its outputs satisfy (5.9).

Hint: You may assume that, by definition of binary representation of integers,
num ⁡ ( α n + 1 ) = a n + 1 2 n + 1 + num ⁡ ( α n ) . (5.13) \operatorname{num}(\alpha_{n + 1})=a_{n + 1}2^{n + 1}+\operatorname{num}(\alpha_{n}). \tag{5.13} num(αn+1)=an+12n+1+num(αn).(5.13)

证明:使用强归纳法。

归纳假设 P ( n ) P(n) P(n) 为公式 (5.9)。

基础情形: n = 0 n=0 n=0

  • 左边 = num ⁡ ( α 0 ) + num ⁡ ( β 0 ) + c 0 \text{左边}=\operatorname{num}(\alpha_{0})+\operatorname{num}(\beta_{0})+c_{0} 左边=num(α0)+num(β0)+c0
  • 右边 = 2 c 1 + num ⁡ ( σ 0 ) \text{右边}=2c_1+\operatorname{num}(\sigma_{0}) 右边=2c1+num(σ0)
  • 根据 n + 1 n+1 n+1位加法器的规范可知: α 0 = a 0 \alpha_0=a_0 α0=a0 β 0 = b 0 \beta_0=b_0 β0=b0 σ 0 = s 0 \sigma_0=s_0 σ0=s0。因为只有 1 1 1 位,所以 num ⁡ ( α 0 ) = a 0 \operatorname{num}(\alpha_{0})=a_0 num(α0)=a0 num ⁡ ( β 0 ) = b 0 \operatorname{num}(\beta_{0})=b_0 num(β0)=b0 num ⁡ ( σ 0 ) = s 0 \operatorname{num}(\sigma_{0})=s_0 num(σ0)=s0
  • 左边 = num ⁡ ( α 0 ) + num ⁡ ( β 0 ) + c 0 = a 0 + b 0 + c 0 \text{左边}=\operatorname{num}(\alpha_{0})+\operatorname{num}(\beta_{0})+c_{0}=a_0+b_0+c_0 左边=num(α0)+num(β0)+c0=a0+b0+c0
  • 右边 = 2 c 1 + num ⁡ ( σ 0 ) = 2 c 1 + s 0 \text{右边}=2c_1+\operatorname{num}(\sigma_{0})=2c_1+s_0 右边=2c1+num(σ0)=2c1+s0
  • 根据公式(5.12)可知, 左边 = 右边 \text{左边}=\text{右边} 左边=右边

归纳步骤:

  • 假设 P ( k ) P(k) P(k) 对所有 k ≤ n k\leq n kn 都成立。
  • k = n + 1 k=n+1 k=n+1 时, 左边 = num ⁡ ( α n + 1 ) + num ⁡ ( β n + 1 ) + c 0 \text{左边}=\operatorname{num}(\alpha_{n+1})+\operatorname{num}(\beta_{n+1})+c_{0} 左边=num(αn+1)+num(βn+1)+c0
  • 根据公式(5.13)有:
    左边 = a n + 1 2 n + 1 + num ⁡ ( α n ) + b n + 1 2 n + 1 + num ⁡ ( β n ) + c 0 = ( a n + 1 2 n + 1 + b n + 1 2 n + 1 ) + ( num ⁡ ( α n ) + num ⁡ ( β n ) + c 0 ) = 2 n + 1 ( 2 c n + 2 + s n + 1 − c n + 1 ) + ( 2 n + 1 c n + 1 + num ⁡ ( σ n ) ) = 2 n + 2 c n + 2 + 2 n + 1 s n + 1 − 2 n + 1 c n + 1 + 2 n + 1 c n + 1 + s n = 2 n + 2 c n + 2 + ( 2 n + 1 s n + 1 + num ⁡ ( σ n ) ) = 2 n + 2 c n + 2 + num ⁡ ( σ n + 1 ) = 右边 . \begin{align*} \text{左边}&=a_{n+1}2^{n+1}+\operatorname{num}(\alpha_{n})+b_{n+1}2^{n+1}+\operatorname{num}(\beta_{n})+c_0\\ &=(a_{n+1}2^{n+1}+b_{n+1}2^{n+1})+(\operatorname{num}(\alpha_{n})+\operatorname{num}(\beta_{n})+c_0)\\ &=2^{n+1}(2c_{n+2}+s_{n+1}-c_{n+1})+(2^{n+1}c_{n+1}+\operatorname{num}(\sigma_{n}))\\ &=2^{n+2}c_{n+2}+2^{n+1}s_{n+1}-2^{n+1}c_{n+1}+2^{n+1}c_{n+1}+s_n\\ &=2^{n+2}c_{n+2}+(2^{n+1}s_{n+1}+\operatorname{num}(\sigma_{n}))\\ &=2^{n+2}c_{n+2}+\operatorname{num}(\sigma_{n+1})\\ &=\text{右边}. \end{align*} 左边=an+12n+1+num(αn)+bn+12n+1+num(βn)+c0=(an+12n+1+bn+12n+1)+(num(αn)+num(βn)+c0)=2n+1(2cn+2+sn+1cn+1)+(2n+1cn+1+num(σn))=2n+2cn+2+2n+1sn+12n+1cn+1+2n+1cn+1+sn=2n+2cn+2+(2n+1sn+1+num(σn))=2n+2cn+2+num(σn+1)=右边.

综上所述, P ( n ) P(n) P(n) 对任意的 n ∈ N n\in\mathbb{N} nN 都成立。

相关文章:

  • 【UnityEditor扩展】如何在 Unity 中创建棱柱体(用作VR安全区检测),同时在编辑器插件中实现与撤销/恢复功能
  • flink Shuffle的总结
  • [ctfshow web入门] web19
  • 第四讲:类与对象(下)
  • 如何在React中集成 PDF.js?构建支持打印下载的PDF阅读器详解
  • mapbox基础,加载栅格图片到地图
  • QMT实盘代码案例教学:etf全球配置策略
  • 深入理解Java性能调优与JVM底层机制
  • 柯尼卡美能达CA-410-CA-VP427 P427
  • 从 “单打独斗” 到 “生态共赢” 跨境货源池的协同增长逻辑
  • 摄像头模块对焦方式的类型
  • Java基础 4.7
  • 基于Python的二手房数据挖掘与可视化深度分析
  • STM32单片机入门学习——第22节: [7-2] AD单通道AD多通道
  • AutoAgent: 香港大学开源的AI智能体框架
  • ARM-IIC
  • #简易线程池...实现原理
  • 从零开始的图论讲解(1)——图的概念,图的存储,图的遍历与图的拓扑排序
  • ubuntu 20.04 编译和运行A-LOAM
  • std::async 和 std::thread 的主要区别
  • 自己建网站模板/优化关键词是什么意思
  • jsp做网站的流程/长沙网站排名推广
  • 泰安网站建设推广/在线识别图片来源
  • 网站开发php制作/正规网络公司关键词排名优化
  • 学生党建网站建设/天津seo网络
  • ag bbin 网站开发/软件开发公司排名