本文内容大多抄录自结城浩《数学女孩 3:哥德尔不完备定理》,带有少量的我的见解。
这本书中有若干个错误……我也给他修正了……
本文承认排中律。
本文纯理性愉悦,请勿认真对待。
我们将创造一个形式系统 P P P ,并证明它是不完备的。
诶?不完备是什么意思?意思是存在一个语句 A A A 使得在其中不存在 A A A 或 ¬ A \neg A ¬ A 的证明。
形式系统 P P P 的定义
我们这里是在定义一个另类的数学系统(这个表述很不准确!),因此请将你的脑子丢掉。
常量
常量 I 0 0 0 是常量
常量 II f \texttt{f} f 是常量
常量 III ¬ \neg ¬ 是常量
常量 IV ∨ \lor ∨ 是常量
常量 V ∀ \forall ∀ 是常量
常量 VI ( \texttt{(} ( 是常量
常量 VII ) \texttt{)} ) 是常量
变量
第 1 1 1 型变量:x 1 , y 1 , z 1 , ⋯ x_1,y_1,z_1,\cdots x 1 , y 1 , z 1 , ⋯ 是用于数的变量,将其称为第 1 1 1 型变量
第 2 2 2 型变量:x 2 , y 2 , z 2 , ⋯ x_2,y_2,z_2,\cdots x 2 , y 2 , z 2 , ⋯ 是用于数的集合变量,将其称为第 2 2 2 型变量
第 3 3 3 型变量:x 3 , y 3 , z 3 , ⋯ x_3,y_3,z_3,\cdots x 3 , y 3 , z 3 , ⋯ 是用于数的集合的集合变量,将其称为第 3 3 3 型变量
以此类推。
数项和符号
这里我们用类似于皮亚诺公理的方法来表示数。
用数项 0 0 0 表示 0 0 0
用数项 f0 \texttt{f0} f0 表示 1 1 1
用数项 ff0 \texttt{ff0} ff0 表示 2 2 2
⋯ ⋯ \cdots\cdots ⋯⋯
我们把 0,f0,ff0, ⋯ \texttt{0,f0,ff0,}\cdots 0,f0,ff0, ⋯ 称为数项。
符号
我们将 0,f0,ff0 , ⋯ \texttt{0,f0,ff0},\cdots 0,f0,ff0 , ⋯ 或 x,fx,ffx, ⋯ \texttt{x,fx,ffx,}\cdots x,fx,ffx, ⋯ 称为第 1 1 1 型符号,此处设 x x x 是第 1 1 1 型变量。
我们将第 2 2 2 型变量称为第 2 2 2 型符号。
我们将第 3 3 3 型变量称为第 3 3 3 型符号。
以此类推第 n ( n ≥ 4 ) n(n \geq 4) n ( n ≥ 4 ) 型符号的定义。
基本逻辑公式
我们把 a(b) \texttt{a(b)} a(b) 这种形式的符号序列称为基本逻辑公式。这里设 a \texttt{a} a 是第 n + 1 n+1 n + 1 型符号,b \texttt{b} b 是第 n n n 型符号。例如 x 2 ( 0 ) x_2\texttt{(}0\texttt{)} x 2 ( 0 ) 、y 2 (ff x 1 ) y_2\texttt{(ff}x_1\texttt{)} y 2 (ff x 1 ) 、z 114 (ffff x 113 ) z_{114}\texttt{(ffff}x_{113}\texttt{)} z 114 (ffff x 113 ) ,他们都是基本逻辑公式。
感性理解一下,就是集合和元素的关系。这也是为什么我们在定义变量的时候强调了它们是【用于数的变量】【用于数的集合变量】【用于数的集合的集合变量】。
逻辑公式
逻辑公式 I 基本逻辑公式是逻辑公式
逻辑公式 II 若 a \texttt{a} a 是逻辑公式,则 ¬ (a) \neg\texttt{(a)} ¬ (a) 也是逻辑公式
逻辑公式 III 若 a \texttt{a} a 和 b \texttt{b} b 都是逻辑公式,则 (a) ∨ (b) \texttt{(a)}\lor\texttt{(b)} (a) ∨ (b) 也是逻辑公式。
逻辑公式 IV 若 a \texttt{a} a 是逻辑公式且 x x x 为变量,则 ∀ x (a) \forall x\texttt{(a)} ∀ x (a) 也是逻辑公式。
逻辑公式 V 只有满足上述条件的才是逻辑公式
省略形式
省略形式 I 将 (a) → (b) \texttt{(a)} \to \texttt{(b)} (a) → (b) 定义为 ( ¬ (a)) ∨ (b) \texttt{(}\neg\texttt{(a))}\lor\texttt{(b)} ( ¬ (a)) ∨ (b)
省略形式 II 将 (a) ∧ (b) \texttt{(a)}\land\texttt{(b)} (a) ∧ (b) 定义为 ¬ (( ¬ (a)) ∨ ( ¬ (b))) \neg\texttt{((}\neg\texttt{(a))}\lor\texttt{(}\neg\texttt{(b)))} ¬ (( ¬ (a)) ∨ ( ¬ (b)))
省略形式 III 将 (a) ⇆ (b) \texttt{(a)}\leftrightarrows\texttt{(b)} (a) ⇆ (b) 定义为 ((a) → (b)) ∧ ((b) → (a)) \texttt{((a)}\to\texttt{(b))}\land\texttt{((b)}\to\texttt{(a))} ((a) → (b)) ∧ ((b) → (a))
省略形式 IV 将 ∃ x (a) \exist x\texttt{(a)} ∃ x (a) 定义为 ¬ ( ∀ x (a))) \neg\texttt{(}\forall x\texttt{(a)))} ¬ ( ∀ x (a)))
括号的省略 为了看起来方便,后面我们会省略冗长的括号
公理
首先是皮亚诺公理。
公理 I-I ¬ (f x 1 = 0) \neg\texttt{(f}x_1=\texttt{0)} ¬ (f x 1 = 0)
公理 I-II (f x 1 = f y 1 ) → ( x 1 = y 1 ) \texttt{(f}x_1=\texttt{f}y_1\texttt)\to\texttt(x_1=y_1\texttt) (f x 1 = f y 1 ) → ( x 1 = y 1 )
公理 I-III x 2 (0) ∧ ∀ x 1 ( x 2 ( x 1 ) → x 2 (f x 1 )) → ∀ x 1 ( x 2 ( x 1 )) x_2\texttt{(0)}\land\forall x_1\texttt(x_2\texttt(x_1\texttt)\to x_2\texttt{(f}x_1\texttt{))}\to\forall x_1\texttt(x_2\texttt(x_1\texttt{))} x 2 (0) ∧ ∀ x 1 ( x 2 ( x 1 ) → x 2 (f x 1 )) → ∀ x 1 ( x 2 ( x 1 ))
诶?= = = 是什么?
等于 x 1 = y 1 ⟺ def ∀ u ( u ( x 1 ) → u ( y 1 )) x_1=y_1\overset{\text{def}}{\Longleftrightarrow}\forall u\texttt(u\texttt(x_1\texttt)\to u\texttt(y_1\texttt{))} x 1 = y 1 ⟺ def ∀ u ( u ( x 1 ) → u ( y 1 ))
诶?⟺ def \overset{\text{def}}{\Longleftrightarrow} ⟺ def 是什么?这是将左边的式子定义为 右边的式子的意思。
其次是命题逻辑的公理。
公理 II-I p ∨ p → p p\lor p\to p p ∨ p → p
公理 II-II p → p ∨ q p\to p\lor q p → p ∨ q
公理 II-III p ∨ q → q ∨ p p\lor q\to q\lor p p ∨ q → q ∨ p
公理 II-IV ( p → q ) → ( r ∨ p → r ∨ q ) \texttt(p\to q\texttt)\to\texttt(r\lor p\to r\lor q\texttt) ( p → q ) → ( r ∨ p → r ∨ q )
我也不知道怎么描述这四条公理(大笑)
再次是谓词逻辑的公理。
公理 III-I ∀ v ( a ) → subst( a , v , c ) \forall v\texttt{(}a\texttt{)}\to\texttt{subst(}a,v,c\texttt{)} ∀ v ( a ) → subst( a , v , c )
诶?subst \texttt{subst} subst 是什么?
subst( a , v , c ) \texttt{subst(}a,v,c\texttt{)} subst( a , v , c ) 表示将 a a a 中所有自由的 v v v 用 c c c 代换后得到的逻辑公式。这里假设 c c c 和 v v v 是同一型的符号,在 a a a 里,v v v 只要是自由的,c c c 中就没有受约束的变量。
关于自由的 与受约束的 可以理解为变量 与有一定限制条件的变量 ,在后续我们还会对这一概念做更详细的解释,此处先按下不表。
这里举一这个函数的例子,subst( ¬ ( x 2 ( x 1 )) , x 1 , f0) \texttt{subst(}\neg\texttt(x_2\texttt(x_1\texttt{))},x_1,\texttt{f0}\texttt) subst( ¬ ( x 2 ( x 1 )) , x 1 , f0 ) 即为 ¬ ( x 2 (f0)) \neg\texttt(x_2\texttt{(f0}\texttt{))} ¬ ( x 2 (f0 )) 。
公理 III-II ∀ ( b ∨ a ) → b ∨ ∀ v ( a ) \forall\texttt(b\lor a\texttt)\to b\lor \forall v\texttt(a\texttt) ∀ ( b ∨ a ) → b ∨ ∀ v ( a )
这里假设 v v v 是任意变量,b b b 中不出现自由的 v v v 。
然后是集合的内涵公理。
公理 IV ∃ u ( ∀ v ( u ( v ) ⇆ a )) \exist u\texttt(\forall v\texttt(u\texttt(v\texttt)\leftrightarrows a\texttt)\texttt) ∃ u ( ∀ v ( u ( v ) ⇆ a ) )
这里假设:
u u u 是第 n + 1 n+1 n + 1 型变量,v v v 是第 n n n 型变量
a a a 中不出现自由的 v v v
聪明的同学,可以发现这其实是集合的内涵定义……可以理解为”逻辑公式 a a a 决了集合 u u u ”。
最后是集合的外延公理。
公理 V ∀ x 1 ( x 2 ( x 1 ) ⇆ y 2 ( x 1 )) → ( x 2 = y 2 ) \forall x_1\texttt( x_2\texttt( x_1 \texttt) \leftrightarrows y_2\texttt( x_1 \texttt) \texttt) \to \texttt(x_2=y_2\texttt) ∀ x 1 ( x 2 ( x 1 ) ⇆ y 2 ( x 1 ) ) → ( x 2 = y 2 )
我们将这个逻辑公式进行”形式提升“后的逻辑公式也定为公理,也就是说下面一串逻辑公式都是公理。
∀ x 1 ( x 3 ( x 1 ) ⇆ y 3 ( x 1 )) → ( x 3 = y 3 ) \forall x_1\texttt( x_3\texttt( x_1 \texttt) \leftrightarrows y_3\texttt( x_1 \texttt) \texttt) \to \texttt(x_3=y_3\texttt) ∀ x 1 ( x 3 ( x 1 ) ⇆ y 3 ( x 1 ) ) → ( x 3 = y 3 )
∀ x 1 ( x 4 ( x 1 ) ⇆ y 4 ( x 1 )) → ( x 4 = y 4 ) \forall x_1\texttt( x_4\texttt( x_1 \texttt) \leftrightarrows y_4\texttt( x_1 \texttt) \texttt) \to \texttt(x_4=y_4\texttt) ∀ x 1 ( x 4 ( x 1 ) ⇆ y 4 ( x 1 ) ) → ( x 4 = y 4 )
⋯ ⋯ \cdots\cdots ⋯⋯
可以理解为“集合中的元素表述了集合”。
推理规则
推理规则-I 根据 a a a 和 a → b a\to b a → b 得到 b b b
推理规则-II 根据 a a a 得到 ∀ v ( a ) \forall v\texttt(a\texttt) ∀ v ( a ) ,这里的 v v v 是任意变量,可以理解为【既然任意情况下可以导出 a a a ,那么加上 ∀ v \forall v ∀ v 也能导出 a a a 】。
哥德尔数
终于,我们要开始研究这个形式系统了!
请注意,我们已回归到普通的数学世界,所以请让你的脑子回来吧。
所谓哥德尔数,就是构建一种符号序列到正整数的映射(但是每个正整数只对应一个符号序列)。
通过这种方法,我们可以将抽象的逻辑符号转换为更方便研究的数字,但我也不知道这样做的动机是什么,可能是因为人们对于数字有更长久更深刻的研究吧!
下文数字均为自然数。
基本符号的哥德尔数
我们将不大于 13 13 13 的奇数分配给常量。
常量 哥德尔数 0 0 0 1 1 1 f \texttt f f 3 3 3 ¬ \neg ¬ 5 5 5 ∨ \lor ∨ 7 7 7 ∀ \forall ∀ 9 9 9 ( \texttt( ( 11 11 11 ) \texttt) ) 13 13 13
我们将大于 13 13 13 的质数分配给第 1 1 1 型变量。
变量 哥德尔数 x 1 x_1 x 1 17 17 17 y 1 y_1 y 1 19 19 19 z 1 z_1 z 1 23 23 23 ⋯ \cdots ⋯ ⋯ \cdots ⋯
我们将大于 13 13 13 的质数的平方分配给第 2 2 2 型变量。
变量 哥德尔数 x 2 x_2 x 2 17 2 17^2 1 7 2 y 2 y_2 y 2 19 2 19^2 1 9 2 z 2 z_2 z 2 23 2 23^2 2 3 2 ⋯ \cdots ⋯ ⋯ \cdots ⋯
我们将大于 13 13 13 的质数的立方分配给第 3 3 3 型变量。
变量 哥德尔数 x 3 x_3 x 3 17 3 17^3 1 7 3 y 3 y_3 y 3 19 3 19^3 1 9 3 z 3 z_3 z 3 23 3 23^3 2 3 3 ⋯ \cdots ⋯ ⋯ \cdots ⋯
以及类推第 n ( n ≥ 4 ) n(n\geq 4) n ( n ≥ 4 ) 型变量的哥德尔数。
序列的哥德尔数
我们思考形如 n 1 , n 2 , ⋯ , n m n_1,n_2,\cdots,n_m n 1 , n 2 , ⋯ , n m 的哥德尔数序列,定义其哥德尔数为:
∏ i = 1 m prime i n i \prod_{i=1}^{m}\text{prime}_i^{n_i} i = 1 ∏ m prime i n i
其中 prime i \text{prime}_i prime i 为从小到大排列第 i i i 个质数。
举个例子!如表示 2 2 2 的数项 ff0 \texttt{ff0} ff0 ,其对应的哥德尔数序列为 3 , 3 , 1 3,3,1 3 , 3 , 1 ,那么它的哥德尔数就是 2 3 × 3 3 × 5 1 = 1080 2^3 \times 3^3 \times 5^1=1080 2 3 × 3 3 × 5 1 = 1080 。
符号序列的序列的哥德尔数也类似。
可以发现一些哥德尔数的性质。
如果哥德尔数是偶数就表示序列,反之就不表示序列
如果哥德尔数质因数分解中 2 2 2 的个数是奇数就表示符号序列,如果是偶数就是符号序列的序列
想到用唯一分解定理来保证哥德尔数对应序列的唯一,哥德尔也真是个天才呢
原始递归性
原始递归定义
举个例子 factorial ( n ) \texttt{factorial}(n) factorial ( n ) ,可以将其定义为:
{ factorial ( 0 ) = 1 factorial ( n + 1 ) = ( n + 1 ) × factorial ( n ) \begin{cases}
\texttt{factorial}(0)=1 \\
\texttt{factorial}(n+1)=(n+1)\times\texttt{factorial}(n)
\end{cases} { factorial ( 0 ) = 1 factorial ( n + 1 ) = ( n + 1 ) × factorial ( n )
事实上计算这个式子还需要用到乘法和加法,所以我们稍微深入一下。
如下定义函数 F F F 时,我们称函数 F F F 是由函数 G G G 和 H H H 经原始递归定义 的:
{ F ( 0 , x ) = G ( x ) F ( n + 1 , x ) = H ( n , x , F ( n , x ) ) \begin{cases}
F(0,x)=G(x) \\
F(n+1,x)=H(n,x,F(n,x))
\end{cases} { F ( 0 , x ) = G ( x ) F ( n + 1 , x ) = H ( n , x , F ( n , x ))
但是实际应用场景中我们的函数可能不止两个变量,因为用下列形式,由函数 G G G 和 H H H 定义的函数 F F F 也是经原始递归定义 的:
{ F ( 0 , x ⃗ ) = G ( x ⃗ ) F ( n + 1 , x ⃗ ) = H ( n , x ⃗ , F ( n , x ⃗ ) ) \begin{cases}
F(0,\vec x)=G(\vec x) \\
F(n+1,\vec x)=H(n,\vec x,F(n,\vec x))
\end{cases} { F ( 0 , x ) = G ( x ) F ( n + 1 , x ) = H ( n , x , F ( n , x ))
其中 x ⃗ \vec x x 是 x 1 , x 2 , ⋯ , x N − 1 x_1,x_2,\cdots,x_{N-1} x 1 , x 2 , ⋯ , x N − 1 的省略形式。
原始递归函数
在定义了【经原始递归定义】这个概念后,我们来定义一下原始递归函数:
常量函数是原始递归函数
求后继数的函数是原始递归函数
由两个原始递归函数经原始递归定义的函数是原始递归函数
往原始递归函数的变量里面带入原始递归函数后得到的函数是原始递归函数
像 F ( x ⃗ ) = x k F(\vec x)=x_k F ( x ) = x k 这样的【提取变量值】的投影函数是原始递归函数
只有符合上述条件的是原始递归函数
接下来我们来定义原始递归谓词。
存在满足 R ( n , x ⃗ ) ⟺ F ( n , x ⃗ ) = 0 R(n,\vec x) \iff F(n,\vec x)=0 R ( n , x ) ⟺ F ( n , x ) = 0 的原始递归函数 F ( n , x ⃗ ) F(n,\vec x) F ( n , x ) 的谓词 R ( n , x ⃗ ) R(n,\vec x) R ( n , x ) 叫做原始递归谓词。
意思大概是 R ( n , x ⃗ ) R(n,\vec x) R ( n , x ) 在对于 F ( n , x ⃗ ) = 0 F(n,\vec x)=0 F ( n , x ) = 0 做出判定。
原始递归函数的定理
原始递归函数有如下定理:
往原始递归函数(谓词)的变量里带入原始递归函数后,所得结果也是原始递归函数(谓词)
若 R R R 和 S S S 是原始递归谓词,则 ¬ R \neg R ¬ R ,R ∧ S R\land S R ∧ S ,R ∨ S R \lor S R ∨ S 也是原始递归谓词。
若 F F F 和 G G G 是原始递归函数,则 F = G F=G F = G 是原始递归谓词
若 M M M 是原始递归函数,R R R 是原始递归谓词,则 S S S 是原始递归谓词
S ( x ⃗ , y ⃗ ) ⟺ ∀ n [ n ≤ M ( x ⃗ ) ⇒ R ( n , y ⃗ ) ] S(\vec x,\vec y)\iff \forall n\left[n \leq M(\vec x)\Rightarrow R(n,\vec y)\right] S ( x , y ) ⟺ ∀ n [ n ≤ M ( x ) ⇒ R ( n , y ) ]
这里谓词 S S S 的含义是【对于所有小于等于 M ( x ⃗ ) M(\vec x) M ( x ) 的 n n n 都有 R ( n , y ⃗ ) R(n,\vec y) R ( n , y ) 】
此处 x ⃗ , y ⃗ \vec x,\vec y x , y 分别表示有限个变量序列。
若 M M M 是原始递归函数,R R R 是原始递归谓词,则 T T T 是原始递归谓词
T ( x ⃗ , y ⃗ ) ⟺ ∃ n [ n ≤ M ( x ⃗ ) ∧ R ( n , y ⃗ ) ] T(\vec x,\vec y)\iff \exist n\left[n \leq M(\vec x)\land R(n,\vec y)\right] T ( x , y ) ⟺ ∃ n [ n ≤ M ( x ) ∧ R ( n , y ) ]
这里谓词 T T T 的含义是【存在小于等于 M ( x ⃗ ) M(\vec x) M ( x ) 的 n n n 有 R ( n , y ⃗ ) R(n,\vec y) R ( n , y ) 】
此处 x ⃗ , y ⃗ \vec x,\vec y x , y 分别表示有限个变量序列。
若 M M M 是原始递归函数,R R R 是原始递归谓词,则 F F F 是原始递归函数
F ( x ⃗ , y ⃗ ) = min n [ n ≤ M ( x ⃗ ) ∧ R ( n , y ⃗ ) ] F(\vec x,\vec y)= \min n\left[n \leq M(\vec x)\land R(n,\vec y)\right] F ( x , y ) = min n [ n ≤ M ( x ) ∧ R ( n , y ) ]
这个函数用来求最小的 n ≤ M ( x ⃗ ) n \leq M(\vec x) n ≤ M ( x ) 满足 R ( n , y ⃗ ) R(n,\vec y) R ( n , y )
此处若合法的 n n n 不存在,函数值被定义为 0 0 0 。
表现定理
书中没有提到其证明,我在这里也偷偷略过了!
若 R R R 是包含两个变量的原始递归谓词,则对于任意数 m , n m,n m , n ,都存在包含两个变量的逻辑公式 r r r ,使得以下关系成立:
R ( n , m ) ⇒ R(n,m) \Rightarrow R ( n , m ) ⇒ 存在 r ⟨ m ‾ , n ‾ ⟩ r\langle \overline{m},\overline{n}\rangle r ⟨ m , n ⟩ 的形式证明。
¬ R ( n , m ) ⇒ \neg R(n,m)\Rightarrow ¬ R ( n , m ) ⇒ 存在 not( r ⟨ m ‾ , n ‾ ⟩ ) \texttt{not(}r\langle \overline{m},\overline{n}\rangle\texttt) not( r ⟨ m , n ⟩ ) 的形式证明。
这里 r ⟨ m ‾ , n ‾ ⟩ r\langle \overline{m},\overline{n}\rangle r ⟨ m , n ⟩ 的意思是把 r r r 中的变量替换为数项 m ‾ , n ‾ \overline m,\overline n m , n 。
通往证明的漫漫长路
从现在开始,我们要构造谓词【 p p p 是 x x x 的形式证明】,准备好吧!
首先说明几个定义……
∀ x ≤ M [ ⋯ ] ⟺ def ∀ x [ x ≤ M ⇒ ⋯ ] \forall x \leq M [\cdots]\overset{\text{def}}{\Longleftrightarrow} \forall x[x \leq M \Rightarrow \cdots] ∀ x ≤ M [ ⋯ ] ⟺ def ∀ x [ x ≤ M ⇒ ⋯ ]
∃ x ≤ M [ ⋯ ] ⟺ def ∃ x [ x ≤ M ⇒ ⋯ ] \exist x \leq M [\cdots]\overset{\text{def}}{\Longleftrightarrow} \exist x[x \leq M \Rightarrow \cdots] ∃ x ≤ M [ ⋯ ] ⟺ def ∃ x [ x ≤ M ⇒ ⋯ ]
min x ≤ M [ ⋯ ] = def min x [ x ≤ M ⇒ ⋯ ] \min x \leq M [\cdots]\overset{\text{def}}{=} \min x[x \leq M \Rightarrow \cdots] min x ≤ M [ ⋯ ] = def min x [ x ≤ M ⇒ ⋯ ]
∃ \exist ∃ 或 ∀ \forall ∀ 后有多个变量的,是嵌套 ∃ \exist ∃ 或 ∀ \forall ∀ 的缩略形式
我们用形如 ( \boxed{(} ( 的方式来指代这个字符的哥德尔数。
具体的:
0 ⟺ def 1 \boxed{0} \overset{\text{def}}{\Longleftrightarrow} 1 0 ⟺ def 1
f ⟺ def 3 \boxed{\texttt{f}} \overset{\text{def}}{\Longleftrightarrow} 3 f ⟺ def 3
¬ ⟺ def 5 \boxed{\neg} \overset{\text{def}}{\Longleftrightarrow} 5 ¬ ⟺ def 5
∨ ⟺ def 7 \boxed{\lor} \overset{\text{def}}{\Longleftrightarrow} 7 ∨ ⟺ def 7
∀ ⟺ def 9 \boxed{\forall} \overset{\text{def}}{\Longleftrightarrow} 9 ∀ ⟺ def 9
( ⟺ def 11 \boxed{(} \overset{\text{def}}{\Longleftrightarrow} 11 ( ⟺ def 11
) ⟺ def 13 \boxed{)} \overset{\text{def}}{\Longleftrightarrow} 13 ) ⟺ def 13
数论
先列出一些基础的数论方面的函数,用来简化后续式子。
CanDivide ( x , d ) \texttt{CanDivide}(x,d) CanDivide ( x , d ) 是谓词【 x x x 能被 d d d 整除】。
CanDivide ( x , d ) ⟺ def ∃ n ≤ x [ x = d × n ] \texttt{CanDivide}(x,d)\overset{\text{def}}{\Longleftrightarrow}\exist n\leq x[x=d \times n] CanDivide ( x , d ) ⟺ def ∃ n ≤ x [ x = d × n ]
你可能觉得 n ≤ x n \leq x n ≤ x 是无用的,但是这其实是用来保证 Candivide \texttt{Candivide} Candivide 是一个原始递归谓词的
IsPrime ( x ) \texttt{IsPrime}(x) IsPrime ( x ) 是谓词【 x x x 是质数】。
IsPrime ( x ) ⟺ def x > 1 ∧ ( ∃ d ≤ x [ d ≠ 1 ∧ d ≠ x ∧ CanDivide ( x , d ) ] ) \texttt{IsPrime}(x)\overset{\text{def}}{\Longleftrightarrow}x>1\land (\exist d\leq x[d \neq 1 \land d \neq x \land \texttt{CanDivide}(x,d)]) IsPrime ( x ) ⟺ def x > 1 ∧ ( ∃ d ≤ x [ d = 1 ∧ d = x ∧ CanDivide ( x , d )])
大于 1 1 1 的不存在非平凡因子的数是质数
CanDivideByPrime ( x , p ) \texttt{CanDivideByPrime}(x,p) CanDivideByPrime ( x , p ) 是谓词【 x x x 能被 p p p 整除且 p p p 为质数】,可以说是缩写了一下。
CanDivideByPrime ( x , p ) ⟺ def CanDivide ( x , p ) ∧ IsPrime ( p ) \texttt{CanDivideByPrime}(x,p)\overset{\text{def}}{\Longleftrightarrow}\texttt{CanDivide}(x,p) \land \texttt{IsPrime}(p) CanDivideByPrime ( x , p ) ⟺ def CanDivide ( x , p ) ∧ IsPrime ( p )
prime ( n , x ) \texttt{prime}(n,x) prime ( n , x ) 是求【 x x x 的第 n n n 个质因数(从小到大)】的函数,第 0 0 0 个质因数被定义为 0 0 0 。
{ prime ( n , 0 ) ⟺ def 0 prime ( n + 1 , x ) ⟺ def min p ≤ x [ prime ( n , x ) < p ∧ CanDivideByPrime(x,p) ] \begin{cases}
\texttt{prime}(n,0)\overset{\text{def}}{\Longleftrightarrow}0 \\
\texttt{prime}(n+1,x)\overset{\text{def}}{\Longleftrightarrow}\min p \leq x[\texttt{prime}(n,x)<p \land \texttt{CanDivideByPrime(x,p)}]
\end{cases} ⎩ ⎨ ⎧ prime ( n , 0 ) ⟺ def 0 prime ( n + 1 , x ) ⟺ def min p ≤ x [ prime ( n , x ) < p ∧ CanDivideByPrime(x,p) ]
大于第 n n n 个质因数的最小质因数就是第 n + 1 n+1 n + 1 个质因数
factorial ( n ) \texttt{factorial}(n) factorial ( n ) 是求【 n n n 的阶乘】的函数。
{ factorial ( 0 ) ⟺ def 1 factorial ( n + 1 ) ⟺ def ( n + 1 ) × factorial ( n ) \begin{cases}
\texttt{factorial}(0)\overset{\text{def}}{\Longleftrightarrow} 1 \\
\texttt{factorial}(n+1)\overset{\text{def}}{\Longleftrightarrow} (n+1) \times \texttt{factorial}(n)
\end{cases} ⎩ ⎨ ⎧ factorial ( 0 ) ⟺ def 1 factorial ( n + 1 ) ⟺ def ( n + 1 ) × factorial ( n )
p n p_n p n 是求【第 n n n 个质数(从小到大)】的函数,第 0 0 0 个质数被定义为 0 0 0 。
{ p 0 ⟺ def 0 p n + 1 ⟺ def min p ≤ M 1 ( n ) [ p n < p ∧ IsPrime ( p ) ] \begin{cases}
p_0 \overset{\text{def}}{\Longleftrightarrow} 0 \\
p_{n+1} \overset{\text{def}}{\Longleftrightarrow} \min p \leq M_1(n)[p_n < p \land \texttt{IsPrime}(p)]
\end{cases} ⎩ ⎨ ⎧ p 0 ⟺ def 0 p n + 1 ⟺ def min p ≤ M 1 ( n ) [ p n < p ∧ IsPrime ( p )]
此处 M 1 ( n ) ⟺ def factorial ( p n ) + 1 M_1(n)\overset{\text{def}}{\Longleftrightarrow}\texttt{factorial}(p_n)+1 M 1 ( n ) ⟺ def factorial ( p n ) + 1 ,也是为了规定一个上限保证函数是原始递归函数。
为什么这里的 M 1 ( n ) M_1(n) M 1 ( n ) 要取这个值?由于 M 1 ( n ) ≡ 1 ( m o d p i ) M_1(n) \equiv 1 \pmod{p_i} M 1 ( n ) ≡ 1 ( mod p i ) 对于 1 ≤ i ≤ n 1 \leq i \leq n 1 ≤ i ≤ n 都成立,所以要么存在一个小于 M 1 ( n ) M_1(n) M 1 ( n ) 的质数,要么它本身就是下一个质数。 这样就保证了能在 1 ∼ M 1 ( x ) 1 \sim M_1(x) 1 ∼ M 1 ( x ) 之间找到一个质数。
CanDivideByPower ( x , n , k ) \texttt{CanDivideByPower}(x,n,k) CanDivideByPower ( x , n , k ) 是谓词【 x x x 能被 x x x 的第 n n n 的质因子的 k k k 次方整除】。
CanDivideByPower(x,n,k) ⟺ def CanDivide ( x , prime ( n , x ) k ) \texttt{CanDivideByPower(x,n,k)} \overset{\text{def}}{\Longleftrightarrow} \texttt{CanDivide}(x,\texttt{prime}(n,x)^k) CanDivideByPower(x,n,k) ⟺ def CanDivide ( x , prime ( n , x ) k )
序列
从这里开始,我们开始刻画形式系统 P P P 中的序列!
x [ n ] x[n] x [ n ] 是求【序列 x x x 的第 n n n 个元素】的函数。
x n ⟺ def min k ≤ x [ CanDivideByPower ( x , n , k ) ∧ ¬ CanDivideByPower ( x , n , k + 1 ) ] x_n\overset{\text{def}}{\Longleftrightarrow}\min k \leq x [\texttt{CanDivideByPower}(x,n,k) \land \neg \texttt{CanDivideByPower}(x,n,k+1)] x n ⟺ def min k ≤ x [ CanDivideByPower ( x , n , k ) ∧ ¬ CanDivideByPower ( x , n , k + 1 )]
可以回忆一下序列的哥德尔数,序列的第 n n n 个元素就是其在 p n p_n p n 这个质因子上的幂次
len ( x ) \texttt{len}(x) len ( x ) 是求【序列 x x x 的长度】的函数。
len ( x ) ⟺ def min k ≤ x [ prime(k,x)>0 ∧ prime ( k + 1 , x ) = 0 ] \texttt{len}(x)\overset{\text{def}}{\Longleftrightarrow}\min k \leq x[\texttt{prime(k,x)>0} \land \texttt{prime}(k+1,x)=0] len ( x ) ⟺ def min k ≤ x [ prime(k,x)>0 ∧ prime ( k + 1 , x ) = 0 ]
x ∗ y x * y x ∗ y 是求【连接序列 x x x 和序列 y y y 的序列】的函数。
x ∗ y ⟺ def min z ≤ M 2 ( x , y ) [ ∀ m ≤ len ( x ) [ 1 ≤ m ⇒ z [ m ] = x [ m ] ] ∧ ∀ n ≤ len ( y ) [ 1 ≤ n ⇒ z [ len ( x ) + n ] = y [ n ] ] ] x * y \overset{\text{def}}{\Longleftrightarrow}\min z \leq M_2(x,y) [\forall m \leq \texttt{len}(x)[1 \leq m \Rightarrow z[m]=x[m]]\land \forall n \leq \texttt{len}(y)[1 \leq n \Rightarrow z[\texttt{len}(x)+n]=y[n]]] x ∗ y ⟺ def min z ≤ M 2 ( x , y ) [ ∀ m ≤ len ( x ) [ 1 ≤ m ⇒ z [ m ] = x [ m ]] ∧ ∀ n ≤ len ( y ) [ 1 ≤ n ⇒ z [ len ( x ) + n ] = y [ n ]]]
此处 M 2 ( n ) ⟺ def ( p len ( x ) + len ( y ) ) x + y M_2(n)\overset{\text{def}}{\Longleftrightarrow}(p_{\texttt{len}(x)+\texttt{len}(y)})^{x+y} M 2 ( n ) ⟺ def ( p len ( x ) + len ( y ) ) x + y 。
这个函数的意思是,最小的 z z z 满足 1 ∼ len ( x ) 1 \sim \texttt{len}(x) 1 ∼ len ( x ) 和 x x x 对齐,len ( x ) + 1 ∼ len ( y ) \texttt{len}(x)+1 \sim \texttt{len}(y) len ( x ) + 1 ∼ len ( y ) 和 y y y 对齐
⟨ x ⟩ \langle x \rangle ⟨ x ⟩ 是求【仅由 x x x 构成的序列】的函数,这里假设 x > 0 x>0 x > 0 。
⟨ x ⟩ ⟺ def 2 x \langle x \rangle \overset{\text{def}}{\Longleftrightarrow} 2^x ⟨ x ⟩ ⟺ def 2 x
paren ( x ) \texttt{paren}(x) paren ( x ) 是求【把 x x x 放到括号里面的序列】的函数。
paren ( x ) ⟺ def ⟨ ( ⟩ ∗ x ∗ ⟨ ) ⟩ \texttt{paren}(x)\overset{\text{def}}{\Longleftrightarrow}\langle\boxed{(}\rangle * x* \langle\boxed{)}\rangle paren ( x ) ⟺ def ⟨ ( ⟩ ∗ x ∗ ⟨ ) ⟩
变量、符号与逻辑公式
IsVarBase ( p ) \texttt{IsVarBase}(p) IsVarBase ( p ) 是谓词【 p p p 是第 1 1 1 型变量】。
IsVarBase ( p ) ⟺ def p > ) ∧ IsPrime ( p ) \texttt{IsVarBase}(p) \overset{\text{def}}{\Longleftrightarrow} p>\boxed{)}\land\texttt{IsPrime}(p) IsVarBase ( p ) ⟺ def p > ) ∧ IsPrime ( p )
我们曾经提到过:将大于 13 13 13 的质数分配给第 1 1 1 型变量
IsVarType ( x , n ) \texttt{IsVarType}(x,n) IsVarType ( x , n ) 是谓词【 x x x 是第 n n n 型变量】。
IsVarType ( x , n ) ⟺ def n ≥ 1 ∧ ∃ p ≤ x [ IsVarBase ( p ) ∧ x = p n ] \texttt{IsVarType}(x,n) \overset{\text{def}}{\Longleftrightarrow} n \geq 1 \land \exist p \leq x[\texttt{IsVarBase}(p) \land x=p^n] IsVarType ( x , n ) ⟺ def n ≥ 1 ∧ ∃ p ≤ x [ IsVarBase ( p ) ∧ x = p n ]
IsVar ( x ) \texttt{IsVar}(x) IsVar ( x ) 是谓词【 x x x 是变量】。
IsVar ( x ) ⟺ def ∃ n ≤ x [ IsVarType ( x , n ) ] \texttt{IsVar}(x) \overset{\text{def}}{\Longleftrightarrow} \exist n \leq x [\texttt{IsVarType}(x,n)] IsVar ( x ) ⟺ def ∃ n ≤ x [ IsVarType ( x , n )]
not ( x ) \texttt{not}(x) not ( x ) 是求【 ¬ ( x ) \neg(x) ¬ ( x ) 】的函数。
not ( x ) ⟺ def ⟨ ¬ ⟩ ∗ paren ( x ) \texttt{not}(x)\overset{\text{def}}{\Longleftrightarrow} \langle \boxed{\neg}\rangle * \texttt{paren}(x) not ( x ) ⟺ def ⟨ ¬ ⟩ ∗ paren ( x )
or ( x , y ) \texttt{or}(x,y) or ( x , y ) 是求【 ( x ) ∨ ( y ) (x)\lor(y) ( x ) ∨ ( y ) 】的函数。
or ( x , y ) ⟺ def paren ( x ) ∗ ⟨ ∨ ⟩ ∗ paren ( y ) \texttt{or}(x,y)\overset{\text{def}}{\Longleftrightarrow}\texttt{paren}(x)*\langle\boxed{\lor}\rangle*\texttt{paren}(y) or ( x , y ) ⟺ def paren ( x ) ∗ ⟨ ∨ ⟩ ∗ paren ( y )
forall ( x , a ) \texttt{forall}(x,a) forall ( x , a ) 是求【 ∀ x ( a ) \forall x(a) ∀ x ( a ) 】的函数。
forall ( x , a ) ⟺ def ⟨ ∀ ⟩ ∗ ⟨ x ⟩ ∗ paren ( a ) \texttt{forall}(x,a)\overset{\text{def}}{\Longleftrightarrow}\langle\boxed{\forall}\rangle*\langle x \rangle * \texttt{paren}(a) forall ( x , a ) ⟺ def ⟨ ∀ ⟩ ∗ ⟨ x ⟩ ∗ paren ( a )
后续使用 forall ( x , a ) \texttt{forall}(x,a) forall ( x , a ) 的时候,要记得检查 x x x 是不是变量
succ ( n , x ) \texttt{succ}(n,x) succ ( n , x ) 是求【 x x x 的第 n n n 个后继数】的函数。
{ succ ( 0 , x ) ⟺ def x succ ( n + 1 , x ) ⟺ def ⟨ f ⟩ ∗ succ ( n , x ) \begin{cases}
\texttt{succ}(0,x)\overset{\text{def}}{\Longleftrightarrow}x \\
\texttt{succ}(n+1,x)\overset{\text{def}}{\Longleftrightarrow}\langle\boxed{\texttt{f}}\rangle * \texttt{succ}(n,x)
\end{cases} ⎩ ⎨ ⎧ succ ( 0 , x ) ⟺ def x succ ( n + 1 , x ) ⟺ def ⟨ f ⟩ ∗ succ ( n , x )
n ‾ \overline{n} n 是求【 n n n 的数项】的函数。
n ‾ ⟺ def succ ( n , ⟨ 0 ⟩ ) \overline{n}\overset{\text{def}}{\Longleftrightarrow} \texttt{succ}(n,\langle\boxed{0}\rangle) n ⟺ def succ ( n , ⟨ 0 ⟩)
IsNumberType ( n ) \texttt{IsNumberType}(n) IsNumberType ( n ) 是谓词【 x x x 是第 1 1 1 型符号】。
IsNumberType ( n ) ⟺ def ∃ m , n ≤ x [ ( m = 0 ∧ IsVarType ( m , 1 ) ) ∧ x = succ ( n , ⟨ m ⟩ ) ] \texttt{IsNumberType}(n)\overset{\text{def}}{\Longleftrightarrow}\exist m,n \leq x[(m=\boxed{0}\land\texttt{IsVarType}(m,1))\land x=\texttt{succ}(n,\langle m \rangle)] IsNumberType ( n ) ⟺ def ∃ m , n ≤ x [( m = 0 ∧ IsVarType ( m , 1 )) ∧ x = succ ( n , ⟨ m ⟩)]
IsNthType ( x , n ) \texttt{IsNthType}(x,n) IsNthType ( x , n ) 是谓词【 x x x 是第 n n n 型符号】。
IsNthType ( x , n ) ⟺ def ( n = 1 ∧ IsNumberType ( x ) ) ∨ ( n > 1 ∧ ∃ v ≤ x [ IsVarType ( v , n ) ∧ x = ⟨ v ⟩ ] ) \texttt{IsNthType}(x,n)\overset{\text{def}}{\Longleftrightarrow} (n=1 \land \texttt{IsNumberType}(x)) \lor (n>1 \land \exist v\leq x [\texttt{IsVarType}(v,n) \land x=\langle v \rangle]) IsNthType ( x , n ) ⟺ def ( n = 1 ∧ IsNumberType ( x )) ∨ ( n > 1 ∧ ∃ v ≤ x [ IsVarType ( v , n ) ∧ x = ⟨ v ⟩])
IsElementForm ( x ) \texttt{IsElementForm}(x) IsElementForm ( x ) 是谓词【 x x x 是基本逻辑公式】。
大家肯定已经忘了基本逻辑公式的定义了吧!
来回顾一下:我们把 a(b) \texttt{a(b)} a(b) 这种形式的符号序列称为基本逻辑公式。这里设 a \texttt{a} a 是第 n + 1 n+1 n + 1 型符号,b \texttt{b} b 是第 n n n 型符号。
IsElementForm ( x ) ⟺ def ∃ a , b , n ≤ x [ IsNthType ( a , n + 1 ) ∧ IsNthType ( b , n ) ∧ x = a ∗ paren ( b ) ] \texttt{IsElementForm}(x)\overset{\text{def}}{\Longleftrightarrow} \exist a,b,n \leq x [\texttt{IsNthType}(a,n+1) \land \texttt{IsNthType}(b,n) \land x=a*\texttt{paren}(b)] IsElementForm ( x ) ⟺ def ∃ a , b , n ≤ x [ IsNthType ( a , n + 1 ) ∧ IsNthType ( b , n ) ∧ x = a ∗ paren ( b )]
IsOp ( x , a , b ) \texttt{IsOp}(x,a,b) IsOp ( x , a , b ) 是谓词【 x x x 是 ¬ ( a ) \neg(a) ¬ ( a ) 或 ( a ) ∨ ( b ) (a)\lor(b) ( a ) ∨ ( b ) 或 ∀ v ( a ) \forall v(a) ∀ v ( a ) 】。
IsOp ( x , a , b ) ⟺ def x = not ( a ) ∨ x = or ( a , b ) ∨ ∃ v ≤ x [ IsVar ( v ) ∧ x = forall ( v , a ) ] \texttt{IsOp}(x,a,b)\overset{\text{def}}{\Longleftrightarrow} x=\texttt{not}(a)\lor x=\texttt{or}(a,b) \lor \exist v \leq x [\texttt{IsVar}(v) \land x=\texttt{forall}(v,a)] IsOp ( x , a , b ) ⟺ def x = not ( a ) ∨ x = or ( a , b ) ∨ ∃ v ≤ x [ IsVar ( v ) ∧ x = forall ( v , a )]
IsFormSeq ( x ) \texttt{IsFormSeq}(x) IsFormSeq ( x ) 是谓词【 x x x 是根据基本逻辑公式构建的逻辑公式的序列】。
IsFormSeq ( x ) ⟺ def len ( x ) > 0 ∧ ∀ n ≤ len ( x ) [ n > 0 ⇒ IsElementForm ( x [ n ] ) ∨ ∃ p , q < n [ p , q > 0 ∧ IsOp ( x [ n ] , p [ n ] , q [ n ] ) ] ] \texttt{IsFormSeq}(x)\overset{\text{def}}{\Longleftrightarrow} \texttt{len}(x)>0 \land \forall n \leq \texttt{len}(x)[n>0\Rightarrow \texttt{IsElementForm}(x[n]) \lor \exist p,q<n[p,q>0\land \texttt{IsOp}(x[n],p[n],q[n])]] IsFormSeq ( x ) ⟺ def len ( x ) > 0 ∧ ∀ n ≤ len ( x ) [ n > 0 ⇒ IsElementForm ( x [ n ]) ∨ ∃ p , q < n [ p , q > 0 ∧ IsOp ( x [ n ] , p [ n ] , q [ n ])]]
重新来看看逻辑公式的定义理解一下……
逻辑公式 I 基本逻辑公式是逻辑公式
逻辑公式 II 若 a \texttt{a} a 是逻辑公式,则 ¬ (a) \neg\texttt{(a)} ¬ (a) 也是逻辑公式
逻辑公式 III 若 a \texttt{a} a 和 b \texttt{b} b 都是逻辑公式,则 (a) ∨ (b) \texttt{(a)}\lor\texttt{(b)} (a) ∨ (b) 也是逻辑公式。
逻辑公式 IV 若 a \texttt{a} a 是逻辑公式且 x x x 为变量,则 ∀ x (a) \forall x\texttt{(a)} ∀ x (a) 也是逻辑公式。
逻辑公式 V 只有满足上述条件的才是逻辑公式
IsEndedWith ( n , x ) \texttt{IsEndedWith}(n,x) IsEndedWith ( n , x ) 是谓词【 n n n 的最后一个元素是 x x x 】。
IsEndedWith ( n , x ) ⟺ def n [ len ( n ) ] = x \texttt{IsEndedWith}(n,x)\overset{\text{def}}{\Longleftrightarrow} n[\texttt{len}(n)]=x IsEndedWith ( n , x ) ⟺ def n [ len ( n )] = x
IsForm ( x ) \texttt{IsForm}(x) IsForm ( x ) 是谓词【 x x x 是逻辑公式】,这里我们定义其为【存在一个根据基本逻辑公式构建的逻辑公式的序列使得最后一个元素是 x x x 】。
IsForm ( x ) ⟺ def ∃ n ≤ M 3 ( n ) [ IsFormSeq ( n ) ∧ IsEndedWith ( n , x ) ] \texttt{IsForm}(x)\overset{\text{def}}{\Longleftrightarrow} \exist n \leq M_3(n)[\texttt{IsFormSeq}(n) \land \texttt{IsEndedWith}(n,x)] IsForm ( x ) ⟺ def ∃ n ≤ M 3 ( n ) [ IsFormSeq ( n ) ∧ IsEndedWith ( n , x )]
此处 M 3 ( n ) ⟺ def ( p len ( x ) 2 ) x × len ( x ) 2 M_3(n)\overset{\text{def}}{\Longleftrightarrow}(p_{\texttt{len}(x)^2})^{x \times \texttt{len}(x)^2} M 3 ( n ) ⟺ def ( p len ( x ) 2 ) x × len ( x ) 2 。
限制、替换与形式提升
开始操纵公式了呢……
IsBoundAt ( v , n , x ) \texttt{IsBoundAt}(v,n,x) IsBoundAt ( v , n , x ) 是谓词【变量 v v v 在 x x x 的第 n n n 个位置受到了约束】。
IsBoundAt ( v , n , x ) ⟺ def IsVar ( v ) ∧ IsForm ( x ) ∧ ∃ a , b , c ≤ x [ x = a ∗ forall ( v , b ) ∗ c ∧ IsForm ( b ) ∧ len ( a ) + 1 ≤ n ≤ len ( a ) + len ( forall ( v , b ) ) ] \texttt{IsBoundAt}(v,n,x)\overset{\text{def}}{\Longleftrightarrow} \texttt{IsVar}(v) \land \texttt{IsForm}(x) \land \exist a,b,c \leq x[x=a*\texttt{forall}(v,b)*c\land\texttt{IsForm}(b)\land\texttt{len}(a)+1\leq n \leq \texttt{len}(a)+\texttt{len}(\texttt{forall}(v,b))] IsBoundAt ( v , n , x ) ⟺ def IsVar ( v ) ∧ IsForm ( x ) ∧ ∃ a , b , c ≤ x [ x = a ∗ forall ( v , b ) ∗ c ∧ IsForm ( b ) ∧ len ( a ) + 1 ≤ n ≤ len ( a ) + len ( forall ( v , b ))]
这里可以理解为 C++ 中的 scope,具体的看完公式你就理解了
IsFreeAt ( v , n , x ) \texttt{IsFreeAt}(v,n,x) IsFreeAt ( v , n , x ) 是谓词【变量 v v v 在 x x x 的第 n n n 个位置没有受到约束】。
IsFreeAt ( v , n , x ) ⟺ def IsVar ( v ) ∧ IsForm ( x ) ∧ v = x [ n ] ∧ n ≤ len ( x ) ∧ ¬ IsBoundAt ( v , n , x ) \texttt{IsFreeAt}(v,n,x) \overset{\text{def}}{\Longleftrightarrow}\texttt{IsVar}(v) \land \texttt{IsForm}(x) \land v=x[n] \land n \leq \texttt{len}(x) \land \neg \texttt{IsBoundAt}(v,n,x) IsFreeAt ( v , n , x ) ⟺ def IsVar ( v ) ∧ IsForm ( x ) ∧ v = x [ n ] ∧ n ≤ len ( x ) ∧ ¬ IsBoundAt ( v , n , x )
这里仍然需要检查传入的变量是否合法
IsFree ( v , x ) \texttt{IsFree}(v,x) IsFree ( v , x ) 是谓词【 v v v 是 x x x 的自由变量】。
IsFree ( v , x ) ⟺ def ∃ n ≤ len ( x ) [ IsFreeAt ( v , n , x ) ] \texttt{IsFree}(v,x)\overset{\text{def}}{\Longleftrightarrow} \exist n \leq \texttt{len}(x)[\texttt{IsFreeAt}(v,n,x)] IsFree ( v , x ) ⟺ def ∃ n ≤ len ( x ) [ IsFreeAt ( v , n , x )]
substAtWith ( x , n , c ) \texttt{substAtWith}(x,n,c) substAtWith ( x , n , c ) 是求【用 c c c 代换 x x x 的第 n n n 个元素后的结果】的函数。
substAtWith ( x , n , c ) ⟺ def min z ≤ M 2 ( x , c ) [ ∃ a , b ≤ x [ n = len ( a ) + 1 ∧ x = a ∗ ⟨ x [ n ] ⟩ ∗ b ∧ z = a ∗ c ∗ b ] ] \texttt{substAtWith}(x,n,c)\overset{\text{def}}{\Longleftrightarrow}\min z \leq M_2(x,c)[\exist a,b \leq x[n=\texttt{len}(a)+1 \land x=a*\langle x[n] \rangle * b \land z=a*c*b]] substAtWith ( x , n , c ) ⟺ def min z ≤ M 2 ( x , c ) [ ∃ a , b ≤ x [ n = len ( a ) + 1 ∧ x = a ∗ ⟨ x [ n ]⟩ ∗ b ∧ z = a ∗ c ∗ b ]]
freepos ( k , v , x ) \texttt{freepos}(k,v,x) freepos ( k , v , x ) 是求【 x x x 的第 k + 1 k+1 k + 1 个自由的 v v v 的位置】的函数,值得注意的是这里的第 k + 1 k+1 k + 1 个是从后往前数的第 k + 1 k+1 k + 1 个,具体缘由我们等会儿再讲。特殊的,如果 v v v 在这个位置不自由时函数返回 0 0 0 。
freepos ( 0 , v , x ) ⟺ def min n ≤ len ( x ) [ IsFreeAt ( v , n , x ) ∧ ¬ ( ∃ p ≤ len ( x ) [ n < p ∧ IsFreeAt ( v , p , x ) ] ) ] freepos ( k + 1 , v , x ) ⟺ def min n < freepos ( k , v , x ) [ IsFreeAt ( v , n , x ) ∧ ¬ [ ∃ p < freepos ( k , v , x ) [ n < p ∧ IsFreeAt ( v , p , x ) ] ] ] \texttt{freepos}(0,v,x)\overset{\text{def}}{\Longleftrightarrow} \min n \leq \texttt{len}(x)[\texttt{IsFreeAt}(v,n,x) \land \neg (\exist p \leq \texttt{len}(x)[n<p \land \texttt{IsFreeAt}(v,p,x)])] \\
\texttt{freepos}(k+1,v,x)\overset{\text{def}}{\Longleftrightarrow} \min n < \texttt{freepos}(k,v,x)[\texttt{IsFreeAt}(v,n,x) \land \neg[\exist p<\texttt{freepos}(k,v,x)[n<p \land \texttt{IsFreeAt}(v,p,x)]]] freepos ( 0 , v , x ) ⟺ def min n ≤ len ( x ) [ IsFreeAt ( v , n , x ) ∧ ¬ ( ∃ p ≤ len ( x ) [ n < p ∧ IsFreeAt ( v , p , x )])] freepos ( k + 1 , v , x ) ⟺ def min n < freepos ( k , v , x ) [ IsFreeAt ( v , n , x ) ∧ ¬ [ ∃ p < freepos ( k , v , x ) [ n < p ∧ IsFreeAt ( v , p , x )]]]
最小的自由位置满足其与上一个自由位置之间无自由位置
freenum ( v , x ) \texttt{freenum}(v,x) freenum ( v , x ) 是求【 x x x 中有多少个自由的 v v v 的位置】的函数。
freenum ( v , x ) ⟺ def min n ≤ len ( x ) [ freepos ( n , v , x ) = 0 ] \texttt{freenum}(v,x)\overset{\text{def}}{\Longleftrightarrow}\min n \leq \texttt{len}(x)[\texttt{freepos}(n,v,x)=0] freenum ( v , x ) ⟺ def min n ≤ len ( x ) [ freepos ( n , v , x ) = 0 ]
substSome ( k , x , v , c ) \texttt{substSome}(k,x,v,c) substSome ( k , x , v , c ) 是求【把 x x x 中的 k k k 个自由的 v v v 用 c c c 代换后的结果】的函数。
{ substSome ( 0 , x , v , c ) ⟺ def x substSome ( k + 1 , x , v , c ) ⟺ def substAtWith ( substSome ( k , x , v , c ) , freepos ( k , v , x ) , c ) \begin{cases}
\texttt{substSome}(0,x,v,c)\overset{\text{def}}{\Longleftrightarrow}x \\
\texttt{substSome}(k+1,x,v,c)\overset{\text{def}}{\Longleftrightarrow} \texttt{substAtWith}(\texttt{substSome}(k,x,v,c),\texttt{freepos}(k,v,x),c)
\end{cases} ⎩ ⎨ ⎧ substSome ( 0 , x , v , c ) ⟺ def x substSome ( k + 1 , x , v , c ) ⟺ def substAtWith ( substSome ( k , x , v , c ) , freepos ( k , v , x ) , c )
这就是为什么 freepos 是倒着数的原因,因为我们的递归需要有一个确定的退出口来保证这是一个原始递归函数
subst ( a , v , c ) \texttt{subst}(a,v,c) subst ( a , v , c ) 是求【把所有 a a a 中自由的 v v v 用 c c c 代换后的结果】的函数。
subst ( a , v , c ) ⟺ def substSome ( freenum ( v , a ) , a , v , c ) \texttt{subst}(a,v,c)\overset{\text{def}}{\Longleftrightarrow}\texttt{substSome}(\texttt{freenum}(v,a),a,v,c) subst ( a , v , c ) ⟺ def substSome ( freenum ( v , a ) , a , v , c )
implies ( a , b ) \texttt{implies}(a,b) implies ( a , b ) 是求【 ( a ) → ( b ) (a)\to(b) ( a ) → ( b ) 】的函数。
implies ( a , b ) ⟺ def or ( not ( a ) , b ) \texttt{implies}(a,b)\overset{\text{def}}{\Longleftrightarrow}\texttt{or}(\texttt{not}(a),b) implies ( a , b ) ⟺ def or ( not ( a ) , b )
and ( a , b ) \texttt{and}(a,b) and ( a , b ) 是求【 ( a ) ∧ ( b ) (a)\land(b) ( a ) ∧ ( b ) 】的函数。
and ( a , b ) ⟺ def not ( or ( not ( a ) , not ( b ) ) ) \texttt{and}(a,b)\overset{\text{def}}{\Longleftrightarrow}\texttt{not}(\texttt{or}(\texttt{not}(a),\texttt{not}(b))) and ( a , b ) ⟺ def not ( or ( not ( a ) , not ( b )))
equiv ( a , b ) \texttt{equiv}(a,b) equiv ( a , b ) 是求【 ( a ) ⇆ ( b ) (a)\leftrightarrows(b) ( a ) ⇆ ( b ) 】的函数。
equiv ( a , b ) ⟺ def and ( implies ( a , b ) , implies ( b , a ) ) \texttt{equiv}(a,b)\overset{\text{def}}{\Longleftrightarrow}\texttt{and}(\texttt{implies}(a,b),\texttt{implies}(b,a)) equiv ( a , b ) ⟺ def and ( implies ( a , b ) , implies ( b , a ))
exists ( x , a ) \texttt{exists}(x,a) exists ( x , a ) 是求【 ∃ x ( a ) \exists x(a) ∃ x ( a ) 】的函数。
exists ( x , a ) ⟺ def not ( forall ( x , not ( a ) ) ) \texttt{exists}(x,a)\overset{\text{def}}{\Longleftrightarrow}\texttt{not}(\texttt{forall}(x,\texttt{not}(a))) exists ( x , a ) ⟺ def not ( forall ( x , not ( a )))
typelift ( n , x ) \texttt{typelift}(n,x) typelift ( n , x ) 是求【把 x x x 形式提升 n n n 后的结果】的函数。
typelift ( n , x ) ⟺ def min y ≤ x ( x n ) [ ∀ k ≤ len ( x ) [ ( ¬ IsVar ( x [ k ] ) ∧ y [ k ] = x [ k ] ) ] ∨ ( IsVar ( x [ k ] ) ∧ y [ k ] = x [ k ] × prime ( 1 , x [ k ] ) n ) ] \texttt{typelift}(n,x)\overset{\text{def}}{\Longleftrightarrow}\min y \leq x^{(x^n)} [\forall k \leq \texttt{len}(x)[(\neg\texttt{IsVar}(x[k])\land y[k]=x[k])]\lor(\texttt{IsVar}(x[k])\land y[k]=x[k] \times \texttt{prime}(1,x[k])^n)] typelift ( n , x ) ⟺ def min y ≤ x ( x n ) [ ∀ k ≤ len ( x ) [( ¬ IsVar ( x [ k ]) ∧ y [ k ] = x [ k ])] ∨ ( IsVar ( x [ k ]) ∧ y [ k ] = x [ k ] × prime ( 1 , x [ k ] ) n )]
只对于变量提升
公式、定理与形式证明
我们向证明冲锋。
IsAxiomI ( x ) \texttt{IsAxiomI}(x) IsAxiomI ( x ) 是谓词【 x x x 是根据公理 I-I/II/III 得到的逻辑公式】,由于这三个公理十分冗长,此处将其哥德尔数简写为 α 1 , α 2 , α 3 \alpha_1,\alpha_2,\alpha_3 α 1 , α 2 , α 3 。
IsAxiomI ( x ) ⟺ def x = α 1 ∨ x = α 2 ∨ x = α 3 \texttt{IsAxiomI}(x)\overset{\text{def}}{\Longleftrightarrow} x=\alpha_1 \lor x=\alpha_2 \lor x=\alpha_3 IsAxiomI ( x ) ⟺ def x = α 1 ∨ x = α 2 ∨ x = α 3
复习一下!
公理 I-I ¬ (f x 1 = 0) \neg\texttt{(f}x_1=\texttt{0)} ¬ (f x 1 = 0)
公理 I-II (f x 1 = f y 1 ) → ( x 1 = y 1 ) \texttt{(f}x_1=\texttt{f}y_1\texttt)\to\texttt(x_1=y_1\texttt) (f x 1 = f y 1 ) → ( x 1 = y 1 )
公理 I-III x 2 (0) ∧ ∀ x 1 ( x 2 ( x 1 ) → x 2 (f x 1 )) → ∀ x 1 ( x 2 ( x 1 )) x_2\texttt{(0)}\land\forall x_1\texttt(x_2\texttt(x_1\texttt)\to x_2\texttt{(f}x_1\texttt{))}\to\forall x_1\texttt(x_2\texttt(x_1\texttt{))} x 2 (0) ∧ ∀ x 1 ( x 2 ( x 1 ) → x 2 (f x 1 )) → ∀ x 1 ( x 2 ( x 1 ))
IsSchemaII ( n , x ) \texttt{IsSchemaII}(n,x) IsSchemaII ( n , x ) 是谓词【 x x x 是根据公理 II-n 得到的逻辑公式】。
IsSchemaII ( 1 , x ) ⟺ def ∃ p ≤ x [ IsForm ( p ) ∧ x = implies ( or ( p , p ) , p ) ] IsSchemaII ( 2 , x ) ⟺ def ∃ p , q ≤ x [ IsForm ( p ) ∧ IsForm ( q ) ∧ x = implies ( p , or ( p , q ) ) ] IsSchemaII ( 3 , x ) ⟺ def ∃ p , q ≤ x [ IsForm ( p ) ∧ IsForm ( q ) ∧ x = implies ( or ( p , q ) , or ( q , p ) ) ] IsSchemaII ( 4 , x ) ⟺ def ∃ p , q , r ≤ x [ IsForm ( p ) ∧ IsForm ( q ) ∧ IsForm ( r ) ∧ x = implies ( implies ( p , q ) , implies ( or ( r , p ) , or ( r , q ) ) ) ] \texttt{IsSchemaII}(1,x)\overset{\text{def}}{\Longleftrightarrow} \exist p \leq x [\texttt{IsForm}(p)\land x=\texttt{implies}(\texttt{or}(p,p),p)] \\
\texttt{IsSchemaII}(2,x)\overset{\text{def}}{\Longleftrightarrow} \exist p,q \leq x [\texttt{IsForm}(p) \land \texttt{IsForm}(q) \land x=\texttt{implies}(p,\texttt{or}(p,q))] \\
\texttt{IsSchemaII}(3,x)\overset{\text{def}}{\Longleftrightarrow} \exist p,q \leq x [\texttt{IsForm}(p) \land \texttt{IsForm}(q) \land x=\texttt{implies}(\texttt{or}(p,q),\texttt{or}(q,p))] \\
\texttt{IsSchemaII}(4,x)\overset{\text{def}}{\Longleftrightarrow} \exist p,q,r \leq x [\texttt{IsForm}(p) \land \texttt{IsForm}(q) \land \texttt{IsForm}(r) \land x=\texttt{implies}(\texttt{implies}(p,q),\texttt{implies}(\texttt{or}(r,p),\texttt{or}(r,q)))] \\ IsSchemaII ( 1 , x ) ⟺ def ∃ p ≤ x [ IsForm ( p ) ∧ x = implies ( or ( p , p ) , p )] IsSchemaII ( 2 , x ) ⟺ def ∃ p , q ≤ x [ IsForm ( p ) ∧ IsForm ( q ) ∧ x = implies ( p , or ( p , q ))] IsSchemaII ( 3 , x ) ⟺ def ∃ p , q ≤ x [ IsForm ( p ) ∧ IsForm ( q ) ∧ x = implies ( or ( p , q ) , or ( q , p ))] IsSchemaII ( 4 , x ) ⟺ def ∃ p , q , r ≤ x [ IsForm ( p ) ∧ IsForm ( q ) ∧ IsForm ( r ) ∧ x = implies ( implies ( p , q ) , implies ( or ( r , p ) , or ( r , q )))]
其次是命题逻辑的公理。
公理 II-I p ∨ p → p p\lor p\to p p ∨ p → p
公理 II-II p → p ∨ q p\to p\lor q p → p ∨ q
公理 II-III p ∨ q → q ∨ p p\lor q\to q\lor p p ∨ q → q ∨ p
公理 II-IV ( p → q ) → ( r ∨ p → r ∨ q ) \texttt(p\to q\texttt)\to\texttt(r\lor p\to r\lor q\texttt) ( p → q ) → ( r ∨ p → r ∨ q )
IsAxiomII ( x ) \texttt{IsAxiomII}(x) IsAxiomII ( x ) 是谓词【 x x x 是根据公理 II 得到的逻辑公式】。
IsAxiomII ( x ) ⟺ def IsSchemaII ( 1 , x ) ∨ IsSchemaII ( 2 , x ) ∨ IsSchemaII ( 3 , x ) ∨ IsSchemaII ( 4 , x ) \texttt{IsAxiomII}(x)\overset{\text{def}}{\Longleftrightarrow}\texttt{IsSchemaII}(1,x)\lor\texttt{IsSchemaII}(2,x)\lor\texttt{IsSchemaII}(3,x)\lor\texttt{IsSchemaII}(4,x) IsAxiomII ( x ) ⟺ def IsSchemaII ( 1 , x ) ∨ IsSchemaII ( 2 , x ) ∨ IsSchemaII ( 3 , x ) ∨ IsSchemaII ( 4 , x )
IsNotBoundIn ( z , y , v ) \texttt{IsNotBoundIn}(z,y,v) IsNotBoundIn ( z , y , v ) 是谓词【在 y y y 中 v v v 是自由的范围内,z z z 中 没有受约束的变量】。(注:这个中字是我加的,否则可能读起来不太像中文?)
IsNotBoundIn ( z , y , v ) ⟺ def ¬ ( ∃ n ≤ len ( y ) [ ∃ m ≤ len ( z ) [ ∃ w ≤ z [ w = z [ m ] ∧ IsBoundAt ( w , n , t ) ∧ IsFree ( v , n , y ) ] ] ] ) \texttt{IsNotBoundIn}(z,y,v)\overset{\text{def}}{\Longleftrightarrow}\neg(\exist n \leq \texttt{len}(y)[\exist m \leq \texttt{len}(z)[\exist w \leq z[w=z[m] \land \texttt{IsBoundAt}(w,n,t) \land \texttt{IsFree}(v,n,y)]]]) IsNotBoundIn ( z , y , v ) ⟺ def ¬ ( ∃ n ≤ len ( y ) [ ∃ m ≤ len ( z ) [ ∃ w ≤ z [ w = z [ m ] ∧ IsBoundAt ( w , n , t ) ∧ IsFree ( v , n , y )]]])
不存在一个位置 n n n 使存在一个 m m m 使得 z [ m ] z[m] z [ m ] 在这个位置受约束而 v v v 是自由的!
IsSchemaIII ( 1 , x ) \texttt{IsSchemaIII}(1,x) IsSchemaIII ( 1 , x ) 是谓词【 x x x 是根据公理 III-I 得到的逻辑公式】。
IsSchemaIII ( 1 , x ) ⟺ def ∃ v , y , z , n ≤ x [ IsVarType ( v , n ) ∧ IsNthType ( z , n ) ∧ IsForm ( y ) ∧ IsNotBoundIn ( z , y , v ) ∧ x = implies ( forall ( v , y ) , subst ( y , v , z ) ) ] \texttt{IsSchemaIII}(1,x)\overset{\text{def}}{\Longleftrightarrow}\exist v,y,z,n \leq x[\texttt{IsVarType}(v,n) \land \texttt{IsNthType}(z,n) \land \texttt{IsForm}(y) \land \texttt{IsNotBoundIn}(z,y,v) \land x=\texttt{implies}(\texttt{forall}(v,y),\texttt{subst}(y,v,z))] IsSchemaIII ( 1 , x ) ⟺ def ∃ v , y , z , n ≤ x [ IsVarType ( v , n ) ∧ IsNthType ( z , n ) ∧ IsForm ( y ) ∧ IsNotBoundIn ( z , y , v ) ∧ x = implies ( forall ( v , y ) , subst ( y , v , z ))]
公理 III-I ∀ v ( a ) → subst( a , v , c ) \forall v\texttt{(}a\texttt{)}\to\texttt{subst(}a,v,c\texttt{)} ∀ v ( a ) → subst( a , v , c )
IsSchemaIII ( 2 , x ) \texttt{IsSchemaIII}(2,x) IsSchemaIII ( 2 , x ) 是谓词【 x x x 是根据公理 III-II 得到的逻辑公式】。
IsSchemaIII ( 2 , x ) ⟺ def ∃ v , q , p ≤ x [ IsVar ( v ) ∧ IsForm ( ) ∧ ¬ IsFree ( v , p ) ∧ IsForm ( q ) ∧ x = implies ( forall ( v , or ( p , q ) ) , or ( p , forall ( v , q ) ) ) ] \texttt{IsSchemaIII}(2,x)\overset{\text{def}}{\Longleftrightarrow}\exist v,q,p \leq x[\texttt{IsVar}(v) \land \texttt{IsForm}() \land \neg \texttt{IsFree}(v,p) \land \texttt{IsForm}(q) \land x=\texttt{implies}(\texttt{forall}(v,\texttt{or}(p,q)),\texttt{or}(p,\texttt{forall}(v,q)))] IsSchemaIII ( 2 , x ) ⟺ def ∃ v , q , p ≤ x [ IsVar ( v ) ∧ IsForm ( ) ∧ ¬ IsFree ( v , p ) ∧ IsForm ( q ) ∧ x = implies ( forall ( v , or ( p , q )) , or ( p , forall ( v , q )))]
公理 III-II ∀ ( b ∨ a ) → b ∨ ∀ v ( a ) \forall\texttt(b\lor a\texttt)\to b\lor \forall v\texttt(a\texttt) ∀ ( b ∨ a ) → b ∨ ∀ v ( a )
这里假设 v v v 是任意变量,b b b 中不出现自由的 v v v 。
IsAxiomIII ( x ) \texttt{IsAxiomIII}(x) IsAxiomIII ( x ) 是谓词【 x x x 是根据公理 III】得到的逻辑公式。
IsAxiomIII ( x ) ⟺ def IsSchemaIII ( 1 , x ) ∨ IsSchemaIII ( 2 , x ) \texttt{IsAxiomIII}(x)\overset{\text{def}}{\Longleftrightarrow}\texttt{IsSchemaIII}(1,x) \lor \texttt{IsSchemaIII}(2,x) IsAxiomIII ( x ) ⟺ def IsSchemaIII ( 1 , x ) ∨ IsSchemaIII ( 2 , x )
IsAxiomIV ( x ) \texttt{IsAxiomIV}(x) IsAxiomIV ( x ) 是谓词【 x x x 是根据公理 IV 得到的逻辑公式】。
IsAxiomIV ( x ) ⟺ def ∃ u , v , y , n ≤ x [ IsVarType ( u , n + 1 ) ∧ IsVarType ( u , n ) ∧ ¬ IsFree ( u , y ) ∧ IsForm ( y ) ∧ x = exists ( u , forall ( v , equiv ( ⟨ u ⟩ ∗ paren ( ⟨ v ⟩ ) , y ) ) ) ] \texttt{IsAxiomIV}(x)\overset{\text{def}}{\Longleftrightarrow} \exist u,v,y,n \leq x [\texttt{IsVarType}(u,n+1) \land \texttt{IsVarType}(u,n) \land \neg \texttt{IsFree}(u,y) \land \texttt{IsForm}(y) \land x=\texttt{exists}(u,\texttt{forall}(v,\texttt{equiv}(\langle u \rangle * \texttt{paren}(\langle v \rangle),y)))] IsAxiomIV ( x ) ⟺ def ∃ u , v , y , n ≤ x [ IsVarType ( u , n + 1 ) ∧ IsVarType ( u , n ) ∧ ¬ IsFree ( u , y ) ∧ IsForm ( y ) ∧ x = exists ( u , forall ( v , equiv (⟨ u ⟩ ∗ paren (⟨ v ⟩) , y )))]
公理 IV ∃ u ( ∀ v ( u ( v ) ⇆ a )) \exist u\texttt(\forall v\texttt(u\texttt(v\texttt)\leftrightarrows a\texttt)\texttt) ∃ u ( ∀ v ( u ( v ) ⇆ a ) )
这里假设:
u u u 是第 n + 1 n+1 n + 1 型变量,v v v 是第 n n n 型变量
a a a 中不出现自由的 v v v
IsAxiomV ( x ) \texttt{IsAxiomV}(x) IsAxiomV ( x ) 是谓词【 x x x 是根据公理 V 得到的逻辑公式】,公理 V 对应的哥德尔数是 α 4 \alpha_4 α 4 。
IsAxiomV ( x ) ⟺ def ∃ n ≤ x [ x = typelift ( n , α 4 ) ] \texttt{IsAxiomV}(x)\overset{\text{def}}{\Longleftrightarrow}\exist n \leq x [x=\texttt{typelift}(n,\alpha_4)] IsAxiomV ( x ) ⟺ def ∃ n ≤ x [ x = typelift ( n , α 4 )]
IsAxiom ( x ) \texttt{IsAxiom}(x) IsAxiom ( x ) 是谓词【 x x x 是公理】。
IsAxiom ( x ) ⟺ def IsAxiomI ( x ) ∨ IsAxiomII ( x ) ∨ IsAxiomIII ( x ) ∨ IsAxiomIV ( x ) ∨ IsAxiomV ( x ) \texttt{IsAxiom}(x)\overset{\text{def}}{\Longleftrightarrow}\texttt{IsAxiomI}(x) \lor \texttt{IsAxiomII}(x) \lor \texttt{IsAxiomIII}(x) \lor \texttt{IsAxiomIV}(x) \lor \texttt{IsAxiomV}(x) IsAxiom ( x ) ⟺ def IsAxiomI ( x ) ∨ IsAxiomII ( x ) ∨ IsAxiomIII ( x ) ∨ IsAxiomIV ( x ) ∨ IsAxiomV ( x )
IsConseq ( x , a , b ) \texttt{IsConseq}(x,a,b) IsConseq ( x , a , b ) 是谓词【 x x x 是 a a a 和 b b b 的直接推论】。
IsConseq ( x , a , b ) ⟺ def a = implies ( b , x ) ∨ ∃ v ≤ x [ IsVar ( v ) ∧ x = forall ( v , a ) ] \texttt{IsConseq}(x,a,b)\overset{\text{def}}{\Longleftrightarrow}a=\texttt{implies}(b,x) \lor \exist v \leq x [\texttt{IsVar}(v) \land x=\texttt{forall}(v,a)] IsConseq ( x , a , b ) ⟺ def a = implies ( b , x ) ∨ ∃ v ≤ x [ IsVar ( v ) ∧ x = forall ( v , a )]
IsProof ( x ) \texttt{IsProof}(x) IsProof ( x ) 是谓词【 x x x 是形式证明】。
IsProof ( x ) ⟺ def len ( x ) > 0 ∧ ∀ n ≤ len ( x ) [ n > 0 ⇒ IsAxiomAt ( x , n ) ∨ ConseqAt ( x , n ) ] \texttt{IsProof}(x)\overset{\text{def}}{\Longleftrightarrow}\texttt{len}(x)>0 \land \forall n \leq \texttt{len}(x)[n>0\Rightarrow \texttt{IsAxiomAt}(x,n) \lor \texttt{ConseqAt}(x,n)] IsProof ( x ) ⟺ def len ( x ) > 0 ∧ ∀ n ≤ len ( x ) [ n > 0 ⇒ IsAxiomAt ( x , n ) ∨ ConseqAt ( x , n )]
其中,IsAxiomAt ( x , n ) ⟺ def IsAxiom ( x [ n ] ) \texttt{IsAxiomAt}(x,n) \overset{\text{def}}{\Longleftrightarrow} \texttt{IsAxiom}(x[n]) IsAxiomAt ( x , n ) ⟺ def IsAxiom ( x [ n ]) ,ConseqAt ( x , n ) ⟺ def ∃ p , q < n [ p , q > 0 ⇒ IsConseq ( x [ n ] , x [ p ] , x [ q ] ) ] \texttt{ConseqAt}(x,n)\overset{\text{def}}{\Longleftrightarrow} \exist p,q<n [p,q>0 \Rightarrow \texttt{IsConseq}(x[n],x[p],x[q])] ConseqAt ( x , n ) ⟺ def ∃ p , q < n [ p , q > 0 ⇒ IsConseq ( x [ n ] , x [ p ] , x [ q ])] 。
Proves ( p , x ) \texttt{Proves}(p,x) Proves ( p , x ) 是谓词【 p p p 是 x x x 的形式证明】。
Proves ( p , x ) ⟺ def IsProof ( p ) ∧ IsEndedWith ( p , x ) \texttt{Proves}(p,x) \overset{\text{def}}{\Longleftrightarrow} \texttt{IsProof}(p) \land \texttt{IsEndedWith}(p,x) Proves ( p , x ) ⟺ def IsProof ( p ) ∧ IsEndedWith ( p , x )
IsProvable ( x ) \texttt{IsProvable}(x) IsProvable ( x ) 是谓词【存在 x x x 的形式证明】。
IsProvable ( x ) ⟺ def ∃ p [ Proves ( p , x ) ] \texttt{IsProvable}(x) \overset{\text{def}}{\Longleftrightarrow} \exist p [\texttt{Proves}(p,x)] IsProvable ( x ) ⟺ def ∃ p [ Proves ( p , x )]
至此,总计五十八个函数的定义,带我们走到了这一步,我们终于定义了 x x x 存在形式证明的谓词,但是仍然有一个小小的缺憾,它不是一个原始递归函数,此前的五十七个函数均为原始递归函数。
写下这句话的时间是二零二六年的三月二十三日,距离我写下这篇文章的第一个子,已经过了七十二天,接下来还有一小部分的论证,我们便可以触及到这个伟大的定理了。
证明
接下来会多次用到表现定理,因此我将其重新摘抄于此,方便读者观看。
若 R R R 是包含两个变量的原始递归谓词,则对于任意数 m , n m,n m , n ,都存在包含两个变量的逻辑公式 r r r ,使得以下关系成立:
下称表现定理 I:R ( n , m ) ⇒ R(n,m) \Rightarrow R ( n , m ) ⇒ 存在 r ⟨ m ‾ , n ‾ ⟩ r\langle \overline{m},\overline{n}\rangle r ⟨ m , n ⟩ 的形式证明。
下称表现定理 II:¬ R ( n , m ) ⇒ \neg R(n,m)\Rightarrow ¬ R ( n , m ) ⇒ 存在 not( r ⟨ m ‾ , n ‾ ⟩ ) \texttt{not(}r\langle \overline{m},\overline{n}\rangle\texttt) not( r ⟨ m , n ⟩ ) 的形式证明。
这里 r ⟨ m ‾ , n ‾ ⟩ r\langle \overline{m},\overline{n}\rangle r ⟨ m , n ⟩ 的意思是把 r r r 中的变量替换为数项 m ‾ , n ‾ \overline m,\overline n m , n 。
由于这个证明的难度较高,所以我会以与书中相同的方式来引导读者观看整个证明。
我们定义双变量谓词 Q Q Q :
Q ( x , y ) ⟺ def ¬ Proves ( x , subst ( y , y 1 , y ‾ ) ) Q(x,y)\overset{\text{def}}{\Longleftrightarrow} \neg \texttt{Proves}(x,\texttt{subst}(y,\boxed{y_1},\overline{y})) Q ( x , y ) ⟺ def ¬ Proves ( x , subst ( y , y 1 , y ))
值得一提的是,x 1 ⟺ def 17 \boxed{x_1}\overset{\text{def}}{\Longleftrightarrow}17 x 1 ⟺ def 17 ,y 1 ⟺ def 19 \boxed{y_1}\overset{\text{def}}{\Longleftrightarrow}19 y 1 ⟺ def 19 。
我们运用表现定理 II 可以得到对于任意数 m . n m.n m . n ,存在双变量逻辑公式 q ⟨ m ‾ , n ‾ ⟩ q\langle \overline m,\overline n \rangle q ⟨ m , n ⟩ ,满足:
¬ Q ( m , n ) ⇒ 存在 not ( q ⟨ m ‾ , n ‾ ⟩ ) 的形式证明 \neg Q(m,n) \Rightarrow \text{存在}\texttt{not}(q\langle \overline m,\overline n \rangle)\text{的形式证明} ¬ Q ( m , n ) ⇒ 存在 not ( q ⟨ m , n ⟩) 的形式证明
此处将 q ⟨ m ‾ , n ‾ ⟩ q\langle \overline m,\overline n \rangle q ⟨ m , n ⟩ 定义为 subst ( subst ( q , x 1 , m ‾ ) , y 1 , n ‾ ) \texttt{subst}(\texttt{subst}(q,\boxed{x_1},\overline m),\boxed{y_1},\overline n) subst ( subst ( q , x 1 , m ) , y 1 , n ) 。
A0:¬ Q ( m , n ) ⇒ IsProvable ( not ( q ⟨ m ‾ , n ‾ ⟩ ) ) \neg Q(m,n) \Rightarrow \texttt{IsProvable}(\texttt{not}(q\langle \overline m,\overline n \rangle)) ¬ Q ( m , n ) ⇒ IsProvable ( not ( q ⟨ m , n ⟩))
由 Q Q Q 的定义可得:
A1:Proves ( m , n ⟨ n ‾ ⟩ ) ⇒ IsProvable ( not ( q ⟨ m ‾ , n ‾ ⟩ ) ) \texttt{Proves}(m,n \langle \overline n\rangle) \Rightarrow \texttt{IsProvable}(\texttt{not}(q\langle \overline m,\overline n \rangle)) Proves ( m , n ⟨ n ⟩) ⇒ IsProvable ( not ( q ⟨ m , n ⟩))
其中 n ⟨ n ‾ ⟩ n \langle \overline n \rangle n ⟨ n ⟩ 定义为 subst ( n , y 1 , n ‾ ) \texttt{subst}(n,\boxed{y_1},\overline{n}) subst ( n , y 1 , n ) 。
运用表现定理 I 可以得到:
B0:Q ( m , n ) ⇒ IsProvable ( q ⟨ m ‾ , n ‾ ⟩ ) Q(m,n) \Rightarrow \texttt{IsProvable}(q\langle \overline m,\overline n \rangle) Q ( m , n ) ⇒ IsProvable ( q ⟨ m , n ⟩)
由 Q Q Q 的定义可得:
B1:¬ Proves ( m , n ⟨ n ‾ ⟩ ) ) ⇒ IsProvable ( q ⟨ m ‾ , n ‾ ⟩ ) \neg \texttt{Proves}(m,n \langle \overline n\rangle)) \Rightarrow \texttt{IsProvable}(q\langle \overline m,\overline n \rangle) ¬ Proves ( m , n ⟨ n ⟩)) ⇒ IsProvable ( q ⟨ m , n ⟩)
我们定义 p p p :
p = def forall ( x 1 , q ⟨ x 1 , y 1 ⟩ ) p\overset{\text{def}}{=}\texttt{forall}(\boxed{x_1},q \langle \boxed{x_1},\boxed{y_1} \rangle) p = def forall ( x 1 , q ⟨ x 1 , y 1 ⟩)
我们将这个 p p p 记作 p ⟨ y 1 ⟩ p \langle \boxed{y_1} \rangle p ⟨ y 1 ⟩ ,有:
C1:p ⟨ y 1 ⟩ = forall ( x 1 , q ⟨ x 1 , y 1 ⟩ ) p \langle \boxed{y_1} \rangle=\texttt{forall}(\boxed{x_1},q \langle \boxed{x_1},\boxed{y_1} \rangle) p ⟨ y 1 ⟩ = forall ( x 1 , q ⟨ x 1 , y 1 ⟩)
用 p ‾ \overline p p 代换 y 1 \boxed{y_1} y 1 ,有:
C2:p ⟨ p ‾ ⟩ = forall ( x 1 , q ⟨ x 1 , p ‾ ⟩ ) p \langle \overline p \rangle=\texttt{forall}(\boxed{x_1},q \langle \boxed{x_1},\overline p \rangle) p ⟨ p ⟩ = forall ( x 1 , q ⟨ x 1 , p ⟩)
这里设 p ⟨ p ‾ ⟩ p \langle \overline p \rangle p ⟨ p ⟩ 为 subst ( p , y 1 , p ‾ ) \texttt{subst}(p,\boxed{y_1},\overline p) subst ( p , y 1 , p ) 。
我们定义 r r r 。
C3:r ⟨ x 1 ⟩ = def q ⟨ x 1 , p ‾ ⟩ r \langle \boxed{x_1} \rangle \overset{\text{def}}{=} q \langle \boxed{x_1},\overline p \rangle r ⟨ x 1 ⟩ = def q ⟨ x 1 , p ⟩
用 m ‾ \overline m m 代换 x 1 x_1 x 1 ,有:
C4:r ⟨ m ‾ ⟩ = def q ⟨ m ‾ , p ‾ ⟩ r \langle \overline m \rangle \overset{\text{def}}{=} q \langle \overline m,\overline p \rangle r ⟨ m ⟩ = def q ⟨ m , p ⟩
我们重新拾起 A1。
A1:Proves ( m , n ⟨ n ‾ ⟩ ) ⇒ IsProvable ( not ( q ⟨ m ‾ , n ‾ ⟩ ) ) \texttt{Proves}(m,n \langle \overline n\rangle) \Rightarrow \texttt{IsProvable}(\texttt{not}(q\langle \overline m,\overline n \rangle)) Proves ( m , n ⟨ n ⟩) ⇒ IsProvable ( not ( q ⟨ m , n ⟩))
用 p p p 代换 n n n ,有:
A2:Proves ( m , p ⟨ p ‾ ⟩ ) ⇒ IsProvable ( not ( q ⟨ m ‾ , p ‾ ⟩ ) ) \texttt{Proves}(m,p \langle \overline p\rangle) \Rightarrow \texttt{IsProvable}(\texttt{not}(q\langle \overline m,\overline p \rangle)) Proves ( m , p ⟨ p ⟩) ⇒ IsProvable ( not ( q ⟨ m , p ⟩))
由 A2 与 C2 有:
A3:Proves ( m , forall ( x 1 , q ⟨ x 1 , p ‾ ⟩ ) ) ⇒ IsProvable ( not ( q ⟨ m ‾ , p ‾ ⟩ ) ) \texttt{Proves}(m,\texttt{forall}(\boxed{x_1},q \langle \boxed{x_1},\overline p \rangle)) \Rightarrow \texttt{IsProvable}(\texttt{not}(q\langle \overline m,\overline p \rangle)) Proves ( m , forall ( x 1 , q ⟨ x 1 , p ⟩)) ⇒ IsProvable ( not ( q ⟨ m , p ⟩))
由 A3 与 C3 有:
A4:Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩ ) ) ⇒ IsProvable ( not ( q ⟨ m ‾ , p ‾ ⟩ ) ) \texttt{Proves}(m,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) \Rightarrow \texttt{IsProvable}(\texttt{not}(q\langle \overline m,\overline p \rangle)) Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩)) ⇒ IsProvable ( not ( q ⟨ m , p ⟩))
由 A4 与 C4 有:
A5:Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩ ) ) ⇒ IsProvable ( not ( r ⟨ m ‾ ⟩ ) ) \texttt{Proves}(m,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) \Rightarrow \texttt{IsProvable}(\texttt{not}(r \langle \overline m \rangle)) Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩)) ⇒ IsProvable ( not ( r ⟨ m ⟩))
我们重新拾起 B1。
B1:¬ Proves ( m , n ⟨ n ‾ ⟩ ) ) ⇒ IsProvable ( q ⟨ m ‾ , n ‾ ⟩ ) \neg \texttt{Proves}(m,n \langle \overline n\rangle)) \Rightarrow \texttt{IsProvable}(q\langle \overline m,\overline n \rangle) ¬ Proves ( m , n ⟨ n ⟩)) ⇒ IsProvable ( q ⟨ m , n ⟩)
用 p p p 代换 n n n :
B2:¬ Proves ( m , p ⟨ p ‾ ⟩ ) ) ⇒ IsProvable ( q ⟨ m ‾ , p ‾ ⟩ ) \neg \texttt{Proves}(m,p\langle \overline p\rangle)) \Rightarrow \texttt{IsProvable}(q\langle \overline m,\overline p \rangle) ¬ Proves ( m , p ⟨ p ⟩)) ⇒ IsProvable ( q ⟨ m , p ⟩)
由 B2 和 C2 有:
B3:¬ Proves ( m , forall ( x 1 , q ⟨ x 1 , p ‾ ⟩ ) ) ⇒ IsProvable ( q ⟨ m ‾ , p ‾ ⟩ ) \neg \texttt{Proves}(m,\texttt{forall}(\boxed{x_1},q \langle \boxed{x_1},\overline p \rangle)) \Rightarrow \texttt{IsProvable}(q\langle \overline m,\overline p \rangle) ¬ Proves ( m , forall ( x 1 , q ⟨ x 1 , p ⟩)) ⇒ IsProvable ( q ⟨ m , p ⟩)
由 B3 和 C3 有:
B4:¬ Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩ ) ) ⇒ IsProvable ( q ⟨ m ‾ , p ‾ ⟩ ) \neg \texttt{Proves}(m,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) \Rightarrow \texttt{IsProvable}(q\langle \overline m,\overline p \rangle) ¬ Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩)) ⇒ IsProvable ( q ⟨ m , p ⟩)
由 B4 和 C4 有:
B5:¬ Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩ ) ) ⇒ IsProvable ( r ⟨ m ‾ ⟩ ) \neg \texttt{Proves}(m,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) \Rightarrow \texttt{IsProvable}(r \langle \overline m \rangle) ¬ Proves ( m , forall ( x 1 , r ⟨ x 1 ⟩)) ⇒ IsProvable ( r ⟨ m ⟩)
我们定义 g g g 。
g = def forall ( x 1 , r ⟨ x 1 ⟩ ) g\overset{\text{def}}{=}\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle) g = def forall ( x 1 , r ⟨ x 1 ⟩)
接下来我们将证明 ¬ IsProvable ( forall ( x 1 , r ⟨ x 1 ⟩ ) ) \neg \texttt{IsProvable}(\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) ¬ IsProvable ( forall ( x 1 , r ⟨ x 1 ⟩)) 与 ¬ IsProvable ( not ( forall ( x 1 , r ⟨ x 1 ⟩ ) ) ) \neg \texttt{IsProvable}(\texttt{not}(\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle))) ¬ IsProvable ( not ( forall ( x 1 , r ⟨ x 1 ⟩))) 。
先做一个假设。
相容的意思是不存在一个命题 S S S 使得 S S S 与 ¬ S \neg S ¬ S 都存在形式证明。
我们想要证明 ¬ IsProvable ( g ) \neg \texttt{IsProvable}(g) ¬ IsProvable ( g ) ,使用反证法,假设 D1 成立。
D1:IsProvable ( forall ( x 1 , r ⟨ x 1 ⟩ ) ) \texttt{IsProvable}(\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) IsProvable ( forall ( x 1 , r ⟨ x 1 ⟩))
假设其形式证明为 s s s ,则有:
D2:Proves ( s , forall ( x 1 , r ⟨ x 1 ⟩ ) ) \texttt{Proves}(s,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) Proves ( s , forall ( x 1 , r ⟨ x 1 ⟩))
用 s s s 代换 A5 中的 m m m ,有:
D3:Proves ( s , forall ( x 1 , r ⟨ x 1 ⟩ ) ) ⇒ IsProvable ( not ( r ⟨ s ‾ ⟩ ) ) \texttt{Proves}(s,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) \Rightarrow \texttt{IsProvable}(\texttt{not}(r \langle \overline s \rangle)) Proves ( s , forall ( x 1 , r ⟨ x 1 ⟩)) ⇒ IsProvable ( not ( r ⟨ s ⟩))
由 D2 和 D3 有:
D4:IsProvable ( not ( r ⟨ s ‾ ⟩ ) ) \texttt{IsProvable}(\texttt{not}(r \langle \overline s \rangle)) IsProvable ( not ( r ⟨ s ⟩))
由 D1 可知,forall ( x 1 , r ⟨ x 1 ⟩ ) \texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle) forall ( x 1 , r ⟨ x 1 ⟩) 是一个定理,根据公理 III-I,有:
D5:IsProvable ( r ⟨ s ‾ ⟩ ) \texttt{IsProvable}(r \langle \overline s \rangle) IsProvable ( r ⟨ s ⟩)
D4 与 D5 可以推出这个形式系统是矛盾的,与 D0 相悖,因此假设 D1 不成立,有:
D6:¬ IsProvable ( forall ( x 1 , r ⟨ x 1 ⟩ ) ) \neg \texttt{IsProvable}(\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) ¬ IsProvable ( forall ( x 1 , r ⟨ x 1 ⟩))
先做一个假设。
E0:形式系统 P P P 是 ω \omega ω 相容的。
先来解释一些概念!ω \omega ω 矛盾的意思是对于单变量逻辑公式 f ⟨ x 1 ⟩ f \langle \boxed{x_1} \rangle f ⟨ x 1 ⟩ 而言,下面两个条件有能成立。
f ( 0 ‾ ) , f ( 1 ‾ ) , ⋯ f(\overline 0),f(\overline 1),\cdots f ( 0 ) , f ( 1 ) , ⋯ 都存在形式证明。
not ( forall ( x 1 , f ⟨ x 1 ⟩ ) ) \texttt{not}(\texttt{forall}(\boxed{x_1},f \langle \boxed{x_1} \rangle)) not ( forall ( x 1 , f ⟨ x 1 ⟩)) 存在形式证明。
ω \omega ω 相容就是不存在 ω \omega ω 矛盾。
根据 D6,我们有 E1 对于任意 t t t 成立。
E1:¬ Proves ( t , forall ( x 1 , r ⟨ x 1 ⟩ ) ) \neg \texttt{Proves}(t,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) ¬ Proves ( t , forall ( x 1 , r ⟨ x 1 ⟩))
根据 B5,我们有 E2 对于任意 t t t 成立。
E2:¬ Proves ( t , forall ( x 1 , r ⟨ x 1 ⟩ ) ) ⇒ IsProvable ( r ⟨ t ‾ ⟩ ) \neg \texttt{Proves}(t,\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle)) \Rightarrow \texttt{IsProvable}(r \langle \overline t \rangle) ¬ Proves ( t , forall ( x 1 , r ⟨ x 1 ⟩)) ⇒ IsProvable ( r ⟨ t ⟩)
由 E1 和 E2 可得 E3 对于任意 t t t 成立。
E3:IsProvable ( r ⟨ t ‾ ⟩ ) \texttt{IsProvable}(r \langle \overline t \rangle) IsProvable ( r ⟨ t ⟩)
运用反证法,假设 E4 成立。
E4:IsProvable ( not ( forall ( x 1 , r ⟨ x 1 ⟩ ) ) ) \texttt{IsProvable}(\texttt{not}(\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle))) IsProvable ( not ( forall ( x 1 , r ⟨ x 1 ⟩)))
根据 E3 与 E4 可得形式系统 P P P 存在 ω \omega ω 矛盾,与 E0 相悖,因此假设 E4 不成立,有:
E5:¬ IsProvable ( not ( forall ( x 1 , r ⟨ x 1 ⟩ ) ) ) \neg \texttt{IsProvable}(\texttt{not}(\texttt{forall}(\boxed{x_1},r \langle \boxed{x_1} \rangle))) ¬ IsProvable ( not ( forall ( x 1 , r ⟨ x 1 ⟩)))
根据 D6 和 E5,我们可以得到:
以上便是第一不完备定理的证明了,请读者休息休息吧!
第一不完备定理所表述的是,任何 ω \omega ω 相容的形式系统,只要蕴涵皮亚诺算术公理,就可以在其中构造在体系中既不能证明也不能否证的命题。
这里有些奇怪的是我在网上搜到的表述全都是,任何相容的形式系统,只要蕴涵皮亚诺算术公理,就可以在其中构造在体系中既不能证明也不能否证的命题,但是我们在 E0 中使用到了形式系统是 ω \omega ω 相容的,但是这篇文章本来就是理性愉悦,所以也无所谓了!
2026.3.31 添加注:ω \omega ω 相容其实是一个挺普遍的条件,如果一个形式系统存在 ω \omega ω 矛盾,那么它就会有某种程度上的矛盾(即会出现有点违背逻辑的结果),因此第一完备性定理并不是什么只针对很特殊的形式系统的结论!