逻辑方法探索离散数学:编程逻辑入门指南

5星 · 超过95%的资源 需积分: 9 25 下载量 138 浏览量 更新于2024-07-21 收藏 20.27MB PDF 举报
"A Logical Approach to Discrete Math" 是一本专为编程逻辑设计的计算机科学教材,它将逻辑方法应用于离散数学领域,帮助读者理解和掌握这一学科在编程中的实际应用。该书由 David Gries 和 Fred B. Schneider 联合撰写,主要关注的是形式方法在编程中的运用。 书中核心内容包括一套严谨的证明体系,例如,通过定义子集关系(Subset C)和避免在命题 P 或 Q 中出现自由变量 v 的前提下,展示了蕴含律({xIP}C{x[Q]}),这表明如果对于所有 x,有 P,则至少存在一个 x 使得 Q 成立。作者还介绍了符号规则和优先级,如表中的操作符 precedence,比如: 1. 文本替换([x:=e]),用于表达式中的文本直接替换; 2. 函数应用(.),用于表示函数的调用; 3. 前缀运算符,如 +, -, #, **, *, ±, mod, gcd, 和 unxo,这些运算符有各自的优先级; 4. 非关联性与关联性:二元运算符通常遵循左结合原则,但像**和•'这样的特定运算符则向右结合; 5. 斜线/用来表示否定,例如 b#c 等同于 -(b = -c),这是一种简化的书写方式; 6. 希腊字母及其对应的符号和转写,如 Alpha 对应于 a 和 a"。 作者还可能讨论了命题逻辑的其他概念,如命题(Propositions)、真值(Truth Values)、联接词(Conjunctions)、蕴含(Implications)、存在量词(Existential Quantifiers)和全称量词(Universal Quantifiers)。此外,书中可能包含了一系列定理、例题和练习,旨在帮助读者通过实践巩固对离散数学逻辑的理解,并将其转化为实际的编程技能。 整本书旨在提供一种系统且逻辑清晰的方法,帮助读者在处理离散数学问题时运用逻辑思维,这对于编写和理解复杂的算法、设计可靠的数据结构以及构建健壮的软件系统至关重要。通过这本书,读者可以掌握如何在计算机科学的上下文中正确地应用逻辑原理,提升编程的精确性和效率。

Write a program to simulate a process of translation from a logical address to physical address. Assumptions 1. Assume the file la.txt includes the sequence of generated addresses from CPU. 2. Use a part of memory as backing store that store data for a process. 3. The backing store size is 128 bytes 4. The size of process p is 128 bytes. 5. The contents of p is included in a file pdata.bin which is a binary file. 6. Use a part of memory as RAM. The size of physical memory is 256 bytes, from 0 to 255. All the physical memory is available, allocating starting from beginning in sequence. That is, allocate frame 0 first, then frame 1, then frame 2…. 7. The size of a frame is 32 bytes, i.e., 5 bits for the offset in a frame, total number of frames is 8. 8. At beginning, no page table is available for process p. Requirements Write a program to 1. Setup a simulating backing store in memory. Read the data from pdata.bin to this backing store. 2. Initialize a page table for process p, set the frame number to be -1 for each page, indicating that the page is not loaded into memory yet. 3. Read logical addresses one by one from la.txt. 4. For each logical address, a) if its page has been loaded into physical memory, simply find the frame number in the page table, then generate physical address, find and print out the physical address and data inside this address. b) if the page is used for the first time, i.e., in page table, its frame number is -1,then the page that contains this address should be loaded into a free frame in physical memory (RAM). Then update the page table by adding the frame number to the right index in the page table. Then repeat 4a). Refer to Figure 1 for the relationships and how physical memory, backing store, and CPU are simulated.写一个c文件

2023-05-26 上传