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

离散数学问题集--问题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 都成立。

相关文章:

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

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

手游防DDoS攻击SDK接入

在手游中集成防DDoS攻击SDK是抵御流量型和应用层攻击的核心手段之一。以下从​​SDK选型、接入流程、防护策略优化​​三个维度提供完整指南,并附关键代码示例: ​​一、SDK选型与核心能力对比​​ ​​服务商​​​​优势​​​​劣势​​​​适用场景…...

Java—HTML:CSS选择器

今天我要介绍的知识点内容是Java HTML中的CSS选择器; CSS选择器用于定位HTML元素并为其添加样式。它允许我们控制网页的颜色、字体、布局和其他视觉元素。通过分离内容与样式。 下面我将介绍CSS中选择器的使用,并作举例说明; 选择器基本语…...

如何将/dev/ubuntu-vg/lv-data的空间扩展到/dev/ubuntu-vg/ubuntu-lv的空间上

要将 /dev/ubuntu-vg/lv-data 的空间扩展到 /dev/ubuntu-vg/ubuntu-lv 上,实际上是将 lv-data 的空间释放出来,并将其分配给 ubuntu-lv。以下是详细的步骤和操作说明: 已知信息 你有两个逻辑卷: /dev/ubuntu-vg/lv-data/dev/ubun…...

SSM阶段性总结

0 Pojo类 前端给后端:DTO 后端给前端:VO 数据库:PO/VO 业务处理逻辑:BO 统称pojo 1 代理模式 实现静态代理: 1定义接口2实现类3写一个静态代理类4这样在调用时就可以使用这个静态代理类来实现某些功能 实现动态代…...

Qt 5.14.2入门(一)写个Hello Qt!程序

目录 参考链接:一、新建项目二、直接运行三、修改代码增加窗口内容1、Qt 显示一个 QLabel 标签控件窗口2、添加按键 参考链接: Qt5教程(一):Hello World 程序 Qt 编程指南 一、新建项目 1、新建一个项目&#xff08…...

Jmeter分布式测试启动

代理客户端配置 打开jmeter.properties文件,取消注释并设置端口(如server_port1099), 并添加server.rmi.ssl.disabletrue禁用SSL加密。 (Linux系统)修改jmeter-server文件中的RMI_HOST_DEF为代理机实际IP。…...

redis itheima

缓存问题 核心是如何避免大量请求到达数据库 缓存穿透 既不存在于 redis,也不存在于 mysql 的key,被重复请求 public Result queryById(Long id) {String key CACHE_SHOP_KEYid;// 1. redis & mysqlString shopJson stringRedisTemplate.opsFo…...

mysql 执行计划中eq_ref是什么意思?

在 MySQL 的执行计划中,eq_ref 是一种连接类型(type),表示查询优化器在使用**主键(PRIMARY KEY)或唯一索引(UNIQUE INDEX)**进行等值匹配()时,对表…...

QT 调用动态链接库

引入QT提供的动态加载库的类 #include <QLibrary>定义函数指针类型 typedef void (*GetResFunction)(uint8_t*, uint8_t*, int);定义函数指针的主要目的是为了解析和调用动态链接库中的函数。如果你不定义函数指针&#xff0c;就无法直接调用动态链接库中的函数 加载动…...

100天精通Python(爬虫篇)——第122天:基于selenium接管已启动的浏览器(反反爬策略)

文章目录 1、问题描述2、问题推测3、解决方法3.1 selenium自动启动浏览器3.2 selenium接管已启动的浏览器3.3 区别总结 4、代码实战4.1 手动方法&#xff08;手动打开浏览器输入账号密码&#xff09;4.2 自动方法&#xff08;.bat文件启动的浏览器&#xff09; 1、问题描述 使用…...

MPP 架构解析:原理、核心优势与对比指南

一、引言&#xff1a;大数据时代的数据处理挑战 全球数据量正以指数级增长。据 Statista 统计&#xff0c;2010 年全球数据量仅 2ZB&#xff0c;2025 年预计达 175ZB。企业面临的核心挑战已从“如何存储数据”转向“如何快速分析数据”。传统架构在处理海量数据时暴露明显瓶颈…...

GitHub 趋势日报 (2025年04月06日)

GitHub 趋势日报 (2025年04月06日) 本日报由 TrendForge 系统生成 https://trendforge.devlive.org/ &#x1f4c8; 今日整体趋势 Top 10 排名项目名称项目描述今日获星语言1microsoft/markitdownPython tool for converting files and office documents to Markdown.⭐ 548Py…...

Python设计模式-工厂模式

一、模式定义与核心思想 工厂模式&#xff08;Factory Pattern&#xff09;属于创建型设计模式&#xff0c;其核心思想是通过一个"工厂类"来创建对象&#xff0c;而不是直接调用类的构造函数。这种模式将对象的实例化过程封装起来&#xff0c;使系统在实例化对象时能…...

SAP-ABAP:SAP的Open SQL和Native SQL详细对比

在SAP ABAP开发中,Open SQL和Native SQL是两种操作数据库的方式,它们的核心区别在于可移植性、功能范围及底层实现机制。以下是详细对比: 1. Open SQL:深入解析 1.1 核心特性 数据库抽象层 Open SQL 由 SAP 内核的 Database Interface (DBI) 转换为目标数据库的 SQL(如 …...

蓝桥杯 拼数(字符串大小比较)

题目描述 设有 n 个正整数 a1​…an​&#xff0c;将它们联接成一排&#xff0c;相邻数字首尾相接&#xff0c;组成一个最大的整数。 输入格式 第一行有一个整数&#xff0c;表示数字个数 n。 第二行有 n 个整数&#xff0c;表示给出的 n 个整数 ai​。 输出格式 一个正整…...

Server-Sent Events一种允许服务器向客户端发送实时更新的 Web API

Server-Sent Events&#xff08;SSE&#xff09;是一种允许服务器向客户端发送实时更新的 Web API。它基于 HTTP 协议&#xff0c;提供了一种单向的、服务器到客户端的通信机制&#xff0c;客户端可以通过监听服务器发送的事件来接收实时数据。下面从原理、使用场景、代码示例等…...

彻底解决VS2008编译错误:fatal error C1083 无法打开包括文件“stdint.h“

彻底解决VS2008编译错误&#xff1a;fatal error C1083 无法打开包括文件"stdint.h" 一、错误现象与本质原因 当在Visual Studio 2008中编译包含C99标准整数类型&#xff08;如int8_t、uint32_t&#xff09;的代码时&#xff0c;常出现以下编译错误&#xff1a; f…...

react从零开始的基础课

全文约5万字。 1.hello,.. // App.jsx import { useState } from react import reactLogo from ./assets/react.svg import viteLogo from /vite.svg import ./App.cssfunction App() {const [count, setCount] useState(0)return (<><Greeting name"world&qu…...

算法题型讲解

一.双指针 主要分为俩种类型&#xff1a; 1.左右指针&#xff1a;双指针指向开头&#xff0c;以一定标准移动或交换&#xff0c;对区域进行划分&#xff0c;或找到特殊点的位置 &#xff08;如&#xff1a;快慢指针判断有无环&#xff0c;移动零&#xff09; 2.对撞指针&am…...

操作主机的管理

1.在AD林范围内&#xff0c;有哪几个操作主机角色 架构主机&#xff08;Schema Master&#xff09; 功能&#xff1a;负责整个AD林中所有对象和属性的定义&#xff0c;是唯一可以更新目录架构的DC。架构更新会从架构主机复制到目录林中的所有其他域控制器。 作用范围&#xf…...

Redis和数据库一致性问题

操作模拟 1、先更新数据库还是先更新缓存&#xff1f; 1.1先更新缓存&#xff0c;再更新数据库 按并发的角度来说&#xff0c;有两个线程A、B&#xff0c;操作同一个数据&#xff0c;线程A先更新缓存为1&#xff0c;在线程A更新数据库之前&#xff0c;这时候线程B进来&#…...

第R8周:RNN实现阿尔茨海默病诊断(pytorch)

>- **&#x1f368; 本文为[&#x1f517;365天深度学习训练营]中的学习记录博客** >- **&#x1f356; 原作者&#xff1a;[K同学啊]** 本人往期文章可查阅&#xff1a; 深度学习总结 一、准备工作 &#x1f3e1; 我的环境&#xff1a; 语言环境&#xff1a;Python3.1…...

《穿透表象,洞察分布式软总线“无形”之奥秘》

分布式系统已成为众多领域的关键支撑技术&#xff0c;而分布式软总线作为实现设备高效互联的核心技术&#xff0c;正逐渐走入大众视野。它常被描述为一条“无形”的总线&#xff0c;这一独特属性不仅是理解其技术内涵的关键&#xff0c;更是把握其在未来智能世界中重要作用的切…...

C++基础精讲-02

文章目录 1.C/C申请、释放堆空间的方式对比1.1C语言申请、释放堆空间1.2C申请、释放堆空间1.2.1 new表达式申请数组空间 1.3回收空间时的注意事项1.4malloc/free 和 new/delete 的区别 2.引用2.1 引用的概念2.2 引用的本质2.3 引用与指针的联系与区别2.4 引用的使用场景2.4.1 引…...

【网络安全】Linux 命令大全

未经许可,不得转载。 文章目录 前言正文文件管理文档编辑文件传输磁盘管理磁盘维护网络通讯系统管理系统设置备份压缩设备管理其它命令前言 在网络安全工作中,熟练掌握 Linux 系统中的常用命令对于日常运维、日志分析和安全排查等任务至关重要。 以下是常用命令的整理汇总,…...

双相机结合halcon的条码检测

以下是针对提供的C#代码的详细注释和解释&#xff0c;结合Halcon库的功能和代码结构进行说明&#xff1a; --- ### **代码整体结构** 该代码是一个基于Halcon库的条码扫描类GeneralBarcodeScan&#xff0c;支持单台或双台相机的条码检测&#xff0c;并通过回调接口返回结果。…...

C++学习之ORACLE①

目录 1.ORACLE数据库简介 2..ORACLE数据库安装 3..ORACLE体系结构 4..ORACLE基本概念 5..ORACLE基本元素 6..ORACLE数据库启动和关闭 7.SQLPLUS登录ORACLE数据库相关操作 8.SQLPLUS的基本操作 9.oracle中上课使用的方案 10.SQL语言分类 11.SQL中的select语句语法和注…...

setInterval问题以及前端如何实现精确的倒计时

一、为什么setInterval不能实现 原因有两&#xff1a;1、js是单线程&#xff0c;基于事件循环执行其他任务&#xff08;这里建议读者可以多去了解一下浏览器线程与事件循环相关知识&#xff09; 2、setinterval是每隔delay时间&#xff0c;把逻辑放到任务队列中&#xff0c;而…...

企业级开发SpringBoost玩转Elasticsearch

案例 Spring Boot 提供了 spring-data-elasticsearch 模块&#xff0c;可以方便地集成 Elasticsearch。 下面我们将详细讲解如何在 Spring Boot 中使用 Elasticsearch 8&#xff0c;并提供示例代码。 1. 添加依赖: 首先&#xff0c;需要在 pom.xml 文件中添加 spring-data-e…...