離散數學問題集--問題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+1?2n+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?...a1?a0?,::=bn?...b1?b0?,?
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?...s1?s0?,
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*} si?ci+1??::=ai?bi?ci?::=(ai?bi?)(ai?ci?)(bi?ci?)?(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?=an?bn?cn? 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?=(an?bn?)(bn?cn?)(cn?an?)
  • 右邊 = 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[(an?bn?)(bn?cn?)(cn?an?)]+an?bn?cn?

下面使用真值表來驗證。

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?=an?bn?cn? a n ∧ b n a_{n}\land b_{n} an?bn? b n ∧ c n b_{n}\land c_{n} bn?cn? c n ∧ a n c_{n}\land a_{n} cn?an? 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?=(an?bn?)(bn?cn?)(cn?an?) 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+1?2n+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+1?2n+1+num(αn?)+bn+1?2n+1+num(βn?)+c0?=(an+1?2n+1+bn+1?2n+1)+(num(αn?)+num(βn?)+c0?)=2n+1(2cn+2?+sn+1??cn+1?)+(2n+1cn+1?+num(σn?))=2n+2cn+2?+2n+1sn+1??2n+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 都成立。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/76140.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/76140.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/76140.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

OpenLayers:海量圖形渲染之矢量切片

最近由于在工作中涉及到了海量圖形渲染的問題,因此我開始研究相關的解決方案。在咨詢了許多朋友之后發現矢量切片似乎是行業內最常用的一種解決方案,于是我便開始研究它該如何使用。 一、什么是矢量切片 矢量切片按照我的理解就是用柵格切片的方式把矢…

神經網絡入門—自定義網絡

網絡模型 定義一個兩層網絡 import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F# 定義神經網絡模型 class Net(nn.Module):def __init__(self, init_x0.0):super().__init__()self.fc1 nn.Linear(1, 10)self.fc2 nn.Linear(…

無人機裝調與測試

文章目錄 前言一、無人機基本常識/預備知識(一)無人機飛行原理無人機硬件組成/各組件作用1.飛控2.GPS3.接收機4.電流計5.電調6.電機7.電池8.螺旋槳9.UBEC(穩壓模塊) (二)飛控硬件簡介(三&#x…

2024年-全國大學生數學建模競賽(CUMCM)試題速瀏、分類及淺析

2024年-全國大學生數學建模競賽(CUMCM)試題速瀏、分類及淺析 全國大學生數學建模競賽(China Undergraduate Mathematical Contest in Modeling)是國家教委高教司和中國工業與應用數學學會共同主辦的面向全國大學生的群眾性科技活動,目的在于激…

Linux入門指南:從零開始探索開源世界

🚀 前言 大家好!今天我們來聊一聊Linux這個神奇的操作系統~ 🤖 很多小伙伴可能覺得Linux是程序員專屬,其實它早已滲透到我們生活的各個角落!本文將帶你了解Linux的誕生故事、發行版選擇攻略、應用領域,還有…

記錄vscode連接不上wsl子系統下ubuntu18.04問題解決方法

記錄vscode連接不上wsl子系統下ubuntu18.04問題解決方法 報錯內容嘗試第一次解決方法嘗試第二次解決方法注意事項參考連接 報錯內容 Unable to download server on client side: Error: Request downloadRequest failed unexpectedly without providing any details… Will tr…

Cursor+MCP學習記錄

參考視頻 Cursor MCP 王炸!徹底顛覆我的Cursor工作流,效率直接起飛_嗶哩嗶哩_bilibili 感覺這個博主講的還不錯 所使用到的網址 Smithery - Model Context Protocol Registry Introduction - Model Context Protocol 學習過程 Smithery - Model …

testflight上架ipa包-只有ipa包的情況下如何修改簽名信息為蘋果開發者賬戶對應的信息-ipa蘋果包如何手動改簽或者第三方工具改簽-優雅草卓伊凡

testflight上架ipa包-只有ipa包的情況下如何修改簽名信息為蘋果開發者賬戶對應的信息-ipa蘋果包如何手動改簽或者第三方工具改簽-優雅草卓伊凡 直接修改蘋果IPA包的簽名和打包信息并不是一個推薦的常規做法,因為這可能違反蘋果的開發者條款,并且可能導致…

深入解析Java內存與緩存:從原理到實踐優化

一、Java內存管理:JVM的核心機制 1. JVM內存模型全景圖 ┌───────────────────────────────┐ │ JVM Memory │ ├─────────────┬─────────────────┤ │ Thread │ 共享…

紫光展銳5G SoC T8300:影像升級,「定格」美好世界

影像能力已成為當今衡量智能手機性能的重要標尺之一。隨著消費者對手機攝影需求日益提升,手機廠商紛紛在影像硬件和算法上展開激烈競爭,力求為用戶帶來更加出色的拍攝體驗。 紫光展銳專為全球主流用戶打造的暢享影音和游戲體驗的5G SoC——T8300&#x…

【Java設計模式】第6章 抽象工廠模式講解

6. 抽象工廠模式 6.1 抽象工廠講解 定義:提供一個接口創建一系列相關或依賴對象,無需指定具體類。核心概念: 產品等級結構:同一類型的不同產品(如Java視頻、Python視頻)。產品族:同一工廠生產的多個產品(如Java視頻 + Java手記)。適用場景: 需要創建多個相關聯的產品…

Dify教程01-Dify是什么、應用場景、如何安裝

Dify教程01-Dify是什么、應用場景、如何安裝 大家好,我是星哥,上篇文章講了Coze、Dify、FastGPT、MaxKB 對比,今天就來學習如何搭建Dify。 Dify是什么 **Dify 是一款開源的大語言模型(LLM) 應用開發平臺。**它融合了后端即服務&#xff08…

Java后端開發-面試總結(集結版)

第一個問題,在 Java 集合框架中,ArrayList和LinkedList有什么區別?在實際應用場景中,應該如何選擇使用它們? ArrayList 基于數組,LinkedList 基于雙向鏈表。 在查詢方面 ArrayList 效率高,添加…

nslookup、dig、traceroute、ping 這些工具在解析域名時是否查詢 DNS 服務器 或 本地 hosts 文件 的詳細對比

host配置解析 127.0.0.1 example.comdig 測試,查詢 DNS 服務器 nslookup測試,查詢 DNS 服務器 traceroute測試,先讀取本地 hosts 文件,再查詢 DNS 服務器 ping測試,先讀取本地 hosts 文件,再查詢 DNS 服務…

文件上傳、讀取與包含漏洞解析及防御實戰

一、漏洞概述 文件上傳、讀取和包含漏洞是Web安全中常見的高危風險點,攻擊者可通過此類漏洞執行惡意代碼、竊取敏感數據或直接控制服務器。其核心成因在于開發者未對用戶輸入內容進行充分驗證或過濾,導致攻擊者能夠繞過安全機制,上傳或執行…

STM32 的編程方式總結

🧱 按照“是否可獨立工作”來分: 庫/方式是否可獨立使用是否依賴其他庫說明寄存器裸寫? 是? 無完全自主控制,無庫依賴標準庫(StdPeriph)? 是? 只依賴 CMSIS自成體系(F1專屬),只…

Flutter命令行打包打不出ipa報錯

Flutter打包ipa報錯解決方案 在Flutter開發中,打包iOS應用時可能會遇到以下錯誤: error: exportArchive: The data couldn’t be read because it isn’ in the correct format. 或者 Encountered error while creating the IPA: error: exportArchive…

SQL Server常見問題的分類解析(一)

以下是SQL Server常見問題的分類解析,涵蓋安裝配置、性能優化、備份恢復、高可用性等核心場景,結合微軟官方文檔和社區實踐整理而成(編號對應搜索結果來源): 一、安裝與配置問題 安裝失敗:.NET Framework缺失解決方案:手動安裝所需版本.NET Framework,以管理員身份運行…

Spring Boot 3.x 下 Spring Security 的執行流程、核心類和原理詳解,結合用戶描述的關鍵點展開說明,并以表格總結

以下是 Spring Boot 3.x 下 Spring Security 的執行流程、核心類和原理詳解,結合用戶描述的關鍵點展開說明,并以表格總結: 1. Spring Security 核心原理 Spring Security 通過 Filter 鏈 實現安全控制,其核心流程如下&#xff1a…

Vue:路由切換表格塌陷

目錄 一、 出現場景二、 解決方案 一、 出現場景 當路由切換時&#xff0c;表格操作欄會出現行錯亂、塌陷的問題 二、 解決方案 在組件重新被激活的時候刷新表格 <el-table ref"table"></el-table>activated(){this.$nextTick(() > {this.$refs[t…