diff --git a/docs/Computer Science/Programming Basis/GNU Make.md b/docs/Computer Science/Programming Basis/GNU Make.md new file mode 100644 index 0000000..1e02a5f --- /dev/null +++ b/docs/Computer Science/Programming Basis/GNU Make.md @@ -0,0 +1,58 @@ +# GNU Make + +!!! Abstract + GNU Make是一个用于自动化编译的工具,它可以根据文件的依赖关系自动执行编译任务。本文将介绍GNU Make的基本使用方法。 + + 为啥要学Make? + + 属于是为了这盘醋包了顿饺子,由于数据结构基础这门课的大作业或多或少需要用到多文件编译,我干脆就希望使用Make进行自动化编译,而且在系统课上接触了Makefile的编写,所以就有了这篇文章。 + +## Part 01 别急,先看看 gcc 编译! + +gcc的编译过程可以简要分为四个阶段:**预处理**、**编译**、**汇编**、**链接**。 + +gcc编译工具链是以gcc编译器为核心的一整套工具,主要包含以下三部分内容: + +- gcc-core:亦即gcc编译器,用于完成预处理过程和编译过程,将C代码转换成汇编代码; +- Binutils:包含了除了gcc编译器以外的一系列小工具,比如汇编器as、连接器ld、目标文件格式查看器readelf等; +- glibc:GNU C Library,是GNU组织为了GNU系统以及Linux系统编写的C语言标准库。 + +### 01.1 预处理/Pre-Processing + +预处理阶段的主要任务是处理源文件以`#`开头的预处理指令,比如`#include`、`#define`等。这里主要是将`#include`的一些**头文件**与**宏定义**进行展开,生成一个`.i`文件。 + +预处理过程输入的是C的源文件,输出的是一个中间/预加载文件,这个文件还是C代码。此阶段使用gcc参数`-E`,同时参数`-o`指定了最后输出文件的名字,下面的例子就将**`main.c`文件经过预处理生成`main.i`文件**: + +```shell +gcc -E main.c -o main.i +``` + +### 01.2 编译/Compiling + +编译过程使用gcc编译器将预处理后的`.i`文件通过编译转换为汇编语言,生成一个`.s`文件。这是gcc编译器完成的工作,在这部分过程之中,gcc编译器会检查各个源文件的语法,即使我们调用了一个没有定义的函数,也不会报错, + +编译过程输入的是一个中间/预加载文件,输出的是一个汇编文件,当然,直接以C文件作为输入进行编译也是可以的。此阶段使用gcc参数`-S`,具体例子如下: + +```shell +gcc -S main.i -o main.s +gcc -S main.c -o main.s +``` + +### 01.3 汇编/Assembling + +汇编阶段的主要任务是将汇编语言文件经过汇编,生成目标文件`.o`文件,每一个源文件都对应一个目标文件。即把汇编语言的代码转换成机器码,这是as汇编器完成的工作。 + +汇编过程输入的是汇编文件,输出`.o`后缀的目标文件,gcc的参数`-c`表示只编译源文件但不链接,当然,我们也可以直接输入C源文件,就直接包含了前面两个过程。 + +```shell +gcc -c main.s -o main.o +gcc -c main.c -o main.o +``` + +Linux下生成的`.o`目标文件、`.so`动态库文件以及下一小节链接阶段生成最终的可执行文件都是elf格式的, 可以使用 readelf 工具来查看它们的内容。 + +从 readelf 的工具输出的信息,可以了解到目标文件包含ELF头、程序头、节等内容,对于`.o`目标文件或`.so`库文件,编译器在链接阶段利用这些信息把多个文件组织起来,对于可执行文件,系统在运行时根据这些信息加载程序运行。 + +### 01.4 链接/Linking + +最后将每个源文件对应的`.o`文件链接起来,就生成了一个可执行程序文件,这是这是链接器ld完成的工作。 \ No newline at end of file diff --git a/docs/Computer Science/Algorithm/Discrete Mathematics.md b/docs/Math/Discrete Mathematics/01 Propositional Logic.md similarity index 94% rename from docs/Computer Science/Algorithm/Discrete Mathematics.md rename to docs/Math/Discrete Mathematics/01 Propositional Logic.md index 753f59f..7337723 100644 --- a/docs/Computer Science/Algorithm/Discrete Mathematics.md +++ b/docs/Math/Discrete Mathematics/01 Propositional Logic.md @@ -1,16 +1,6 @@ -# Discrete Mathematics +# Part 01 Propositional Logic -!!! Abstract - 这是我在2023-2024学年春夏学期修读《离散数学理论基础》的课程笔记,由于我实在不想将它安排在数学一类,加之其以`markdown`编写,所以就放在了这里。 - - 参考书籍: - - - 《Discrete Mathematics and Its Applications》 By Kenneth H. Rosen - - 《Concrete Mathmatics》 By Ronald L. Graham - -## Part 01 Propositional Logic - -### 1.1 Propositions +## 1.1 Propositions A **proposition** is a declarative sentence that is either true or false, but not both. We use letters to denote **propositional variables**, or sentential variables, i.e. variables that represent propositions. The **truth value** of a proposition is true, denoted by **T**, if it is a true proposition, and similiarly, the truth value of a proposition is false, denoted by **F**, if it is a false proposition.Propositions that cannot be expressed in terms of simpler propositions are called **atomic propositions**. @@ -33,7 +23,7 @@ The truth value of $p\leftrightarrow q$ is the same as the truth value of $(p\to **Precedence of Logical Operators**: From highest to lowest, the precedence of logical operators is $\neg$, $\land$, $\lor$, $\to$, and $\leftrightarrow$. -### 1.3 Logical Equivalence +## 1.3 Logical Equivalence Basic terminology and its concepts: @@ -129,11 +119,11 @@ A compound proposition is **satisfiable** if there is an assignment of truth val A compound proposition is unsatisfiable if and only if it is a contradiction or its negation is a tautology. -### 1.4 Applications of Propositional Logic +## 1.4 Applications of Propositional Logic A list of propositions is **consistent** if it is possible to assign truth values to the proposition variables so that each proposition is true. -### 1.5 Propositional Normal Forms +## 1.5 Propositional Normal Forms **Propositional formula/命题公式** is a compound proposition that is built up from atomic propositions using logical connectives with the following criteria: @@ -186,5 +176,5 @@ $$f = \neg g = \prod M(\{0,1,2,\cdots,2^{n-1}\}-\{j,k,\cdots,l\}).$$ The $M_i$ is a maxterm defined by $M_i=\neg m_i$. -### 1.6 Predicates and Quantifiers +## 1.6 Predicates and Quantifiers diff --git a/docs/Math/Discrete Mathematics/04 Graph Theory.md b/docs/Math/Discrete Mathematics/04 Graph Theory.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/Math/Discrete Mathematics/Discrete Mathematics.md b/docs/Math/Discrete Mathematics/Discrete Mathematics.md new file mode 100644 index 0000000..a513c6c --- /dev/null +++ b/docs/Math/Discrete Mathematics/Discrete Mathematics.md @@ -0,0 +1,16 @@ +# Discrete Mathematics + +!!! Abstract + 这是我在2023-2024学年春夏学期修读《离散数学理论基础》的课程笔记。 + + 离散数学的内容繁杂,包含逻辑、集合论、图论等内容。对于计算机专业的学生来说,这部分包含的内容更加宽泛,可以说是**“在数理基础课上讲不到的都在这了”**。 + + 参考书籍: + + - 《Discrete Mathematics and Its Applications》 By Kenneth H. Rosen + - 《Concrete Mathmatics》 By Ronald L. Graham + +## Table of Contents + +- [ ] [Propositional Logic](./01%20Propositional%20Logic.md) +- [ ] [Graph Theory](./04%20Graph%20Theory.md) \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index ffc8410..3b409eb 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -118,6 +118,7 @@ nav: - Programing Basis: - Computer Science/Programming Basis/index.md - Shell: Computer Science/Programming Basis/Shell.md + - GNU Make: Computer Science/Programming Basis/GNU Make.md - Linux: Computer Science/Programming Basis/Linux.md - Assembly: Computer Science/Programming Basis/Assembly.md - MIT Missing Semester: Computer Science/Programming Basis/MIT Missing Semester.md @@ -129,7 +130,6 @@ nav: - Java: Computer Science/Programming Language/Java.md - Algorithm: - Computer Science/Algorithm/index.md - - Discrete Mathematics: Computer Science/Algorithm/Discrete Mathematics.md - Algorithms and Data Structure: - Computer Science/Algorithm/Algorithms and Data Structure.md - Algorithm Analysis: Computer Science/Algorithm/01 Algorithm Analysis.md @@ -146,6 +146,10 @@ nav: - YAML: Computer Science/Web/YAML.md - Math: - Math/index.md + - Discrete Mathematics: + - Math/Discrete Mathematics/Discrete Mathematics.md + - Propositional Logic: Math/Discrete Mathematics/01 Propositional Logic.md + - Graph Theory: Math/Discrete Mathematics/04 Graph Theory.md # - Algebra: Math/Algebra.md # - Analysis: Math/Analysis.md # - Topology: Math/General Topology.md