逐步主鏈
S01 · definition
操作前
s,\ E
操作後
E=(V,I,N,\Gamma),\quad \Gamma=\varnothing
條件:\text{Lean not run (G2)}
規則:def_intro · 依賴:G1, G2
葉節點依據:def_intro + mko_lean_formal_statement_def
先把環境寫成四元組並命名。MKO 假設 a1 說版本、imports、已宣告名稱與 local context 都屬於陳述身分,所以任何關於 s 的判斷都必須附上 E。G2 記錄:這個四元組只在紙上固定,沒有呼叫任何工具鏈。
S02 · definition
操作前
s
操作後
\mathsf{Parse}(s)\ ;\ \mathsf{Elab}(s)=S\ ;\ \Gamma\vdash S:\mathrm{Prop}\ ;\ \Gamma\vdash p:S\ ;\ \mathsf{Kernel}(p,S)條件:無
規則:lean_stages · 依賴:S01, G3
葉節點依據:lean_stages + def_intro
為五個狀態命名:s 被解析;s elaboration 成核心項 S;S 的型別是 Prop;存在證明項 p:S;p 通過 kernel check。後面的狀態以前面的狀態為前提,但前面的狀態都不蘊含後面的狀態。MKO 的誤解正是把這幾個狀態合成一件事。本稿開始時五個狀態都是「未執行」。
S03 · implies
操作前
s=\texttt{∀ (a b : Nat), a ≤ b → a < b + 1}操作後
\forall a:\mathrm{Nat},\ \forall b:\mathrm{Nat},\ \bigl((a\le b)\to(a<(b+1))\bigr)條件:\text{notation and precedence of E as cited}
規則:lean_core_notation · 依賴:S02, G3
葉節點依據:lean_core_notation
依引用的記號與優先序慣例手工讀出結構:(a b : Nat) 是兩個巢狀的全稱約束;∀ 延伸到字串結尾;+ 比 < 結合得緊,所以 a < b + 1 是 a<(b+1);≤ 與 < 比 → 結合得緊,所以 → 的兩邊是 a≤b 與 a<b+1。讀出的意思:對所有自然數 a、b,若 a≤b 則 a<b+1。這是按慣例的人工閱讀,不是執行解析器的結果(G2)。
S04 · implies
操作前
\forall a\,b:\mathrm{Nat},\ a\le b\to a<b+1操作後
S=\forall a\,b:\mathrm{Nat},\ \mathrm{LE.le}\,a\,b\to\mathrm{LT.lt}\,a\,(\mathrm{HAdd.hAdd}\,b\,(\mathrm{OfNat.ofNat}\,1))條件:\mathsf{Elab}(s)\ \text{succeeds (not run)}
規則:lean_core_notation · 依賴:S03
葉節點依據:lean_core_notation + lean_stages
說明 elaboration 若成功必須產生什麼:把每個記號換成其常數,並補上隱式型別參數 Nat 與 instance 參數(LE Nat、LT Nat、HAdd Nat Nat Nat、OfNat Nat 1);顯示的項省略了這些隱式參數。這是對 elaboration 任務的描述;它是否成功、instance 的確切名稱,本稿都沒有檢查。
S05 · theorem_application
操作前
S
操作後
\Gamma\vdash S:\mathrm{Prop}\quad(\text{conditional on}\ \mathsf{Elab}(s)=S)條件:\mathsf{Elab}(s)=S
規則:prop_formation · 依賴:S04
葉節點依據:prop_formation + lean_core_notation
以 S04 的形狀為前提,用型別形成規則逐層推得 S 的型別是 Prop:先是兩個原子命題(S05.1),再是蘊含(S05.2),最後是兩層全稱(S05.3)。這是手工型別分析,不是型別檢查器的輸出。
S06 · implies
操作前
\mathsf{Elab}(s)=S\ \wedge\ \Gamma\vdash S:\mathrm{Prop}操作後
s\ \text{expresses a formal statement in}\ E條件:\mathsf{Elab}(s)=S\ \text{(not run)}
規則:mko_lean_formal_statement_def · 依賴:S05, S02
葉節點依據:mko_lean_formal_statement_def + lean_stages
套用 MKO 定義作為條件式:若 s 在 E 中 elaboration 為 S 且 Γ⊢S:Prop,則 s 在 E 中表達一個形式陳述。前件的型別部分已在 S05 以 elaboration 成功為前提手工得到;elaboration 本身沒有執行(G2)。因此記錄的狀態是:「預期在 E 中表達形式陳述;缺 elaboration receipt」。
S07 · definition
操作前
\Gamma\vdash p:S
操作後
p=\lambda (a\,b:\mathrm{Nat})\,(h:a\le b).\ q,\quad a,b:\mathrm{Nat},\ h:a\le b\ \vdash\ q:a<b+1條件:無
規則:curry_howard · 依賴:S04
葉節點依據:curry_howard
依命題即型別,S 的證明項是一個函數:接收任意 a、b : Nat 與假設 a≤b 的證明 h,回傳 a<b+1 的證明 q。約束變數 a、b 是資料,h 是假設;證明責任是:對任意 a、b 與 h,造出 a<b+1 的證明。這正是 S09 非正式證明的形狀。
S08 · implies
操作前
\forall a\,b,\ a\le b\to a<b+1
操作後
(a,b)=(3,3):\ 3\le 3\to 3<4;\quad (a,b)=(5,2):\ 5\le 2\to 5<3
條件:無
規則:forall_elim · 依賴:S03
葉節點依據:forall_elim + numeric_evaluation
用兩個實例看清陳述的意思。a=b=3 時假設 3≤3 成立,結論 3<4 也成立。a=5、b=2 時假設 5≤2 不成立,陳述對這一對不要求結論 5<3(在古典讀法中這個蘊含空真)。假設限定了陳述對哪些數對宣稱結論。
S09 · theorem_application
操作前
\forall a,b\in\mathbb{N},\ a\le b\Rightarrow a<b+1操作後
\text{true in}\ \mathbb{N}\ \text{(informal proof)}條件:無
規則:L_main · 依賴:S03
葉節點依據:order_basics + forall_intro + imp_intro
套用引理 L_main(在 S09.1、S09.2 證明):在標準自然數中,陳述的數學內容成立。這是數學上的非正式證明,對應 S07 中 q 的構造計畫。
S10 · implies
操作前
\text{informal proof of the content of}\ S操作後
\mathsf{Parse},\ \mathsf{Elab},\ \mathsf{Kernel}:\ \text{not run};\ p:\ \text{not constructed}條件:無
規則:mko_lean_formal_statement_def · 依賴:S06, S07, S09
葉節點依據:mko_lean_formal_statement_def + lean_stages + mko_proposition_def
整理狀態。S09 證明了陳述的數學內容在標準 ℕ 中為真,並給出 S07 中 q 的構造計畫;但它不是 Lean 證明項,也沒有任何東西經過 kernel check。因此狀態表為:解析未執行;elaboration 未執行;Prop 型別只有手工分析(S05,以 elaboration 成功為前提);證明項未建立;kernel check 未執行。依 MKO,形式陳述與其已檢查證明項是分離狀態,本稿只推進了前者的概念分析。
S11 · implies
操作前
s'=\texttt{∀ (a : Nat), a - 1 < a}操作後
\Gamma\vdash S':\mathrm{Prop}\quad(\text{conditional on}\ \mathsf{Elab}(s'))條件:\mathsf{Elab}(s')\ \text{succeeds (not run)}
規則:prop_formation · 依賴:G4, S05
葉節點依據:prop_formation + lean_core_notation
對 s′ 重做 S05 的型別分析:a−1 是 HSub Nat Nat Nat 的值,型別 Nat;LT.lt (a−1) a : Prop;對 a : Nat 全稱量化仍是 Prop。所以若 s′ 能 elaboration,它同樣表達一個形式陳述。
S12 · implies
操作前
\forall a:\mathrm{Nat},\ a-1<a操作後
a=0:\ 0-1=0,\ \neg(0<0)\ \Rightarrow\ \neg\forall a,\ a-1<a
條件:\text{truncated subtraction on Nat}
規則:quantifier_negation · 依賴:S11
葉節點依據:nat_trunc_sub + quantifier_negation + order_basics
在 Nat 的截斷減法下,a=0 給出 0−1=0(S12.1),而 0<0 不成立(S12.2)。存在反例,依量詞否定,S′ 的內容在標準讀法下為假。S′ 是 Prop(S11)但不是真命題:是命題不表示已證明為真(mko_proposition_def)。
S13 · implies
操作前
s''=\texttt{∀ (a : Int), a - 1 < a}操作後
\forall a\in\mathbb{Z},\ a-1<a\ \text{(true)};\quad S''\ne S'條件:\text{ring subtraction on Int}
規則:order_basics · 依賴:G4, S12
葉節點依據:order_basics + nat_trunc_sub
在 Int 上減法是通常的環減法。對任意整數 a,−1<0,兩邊加 a 得 a−1<a,所以 S″ 的內容為真。s′ 與 s″ 只差一個型別名稱,但約束變數型別不同、減法不同,因此是不同的核心項,而且真假不同。型別與環境都是陳述身分的一部分(MKO 假設 a1)。
S14 · implies
操作前
t_0=\texttt{a ≤ b → a < b + 1}操作後
\text{meaning of}\ t_0\ \text{depends on}\ \Gamma\ \text{and elaborator options}條件:無
規則:mko_lean_formal_statement_def · 依賴:S01, S03
葉節點依據:mko_lean_formal_statement_def + lean_stages
去掉約束後的文字 t0。若 local context 是 Γ′=(a b : Nat),t0 會被讀成關於這兩個區域變數的陳述;在 E 的空 Γ 中,a、b 不是已宣告名稱,elaboration 可能失敗,也可能依 elaborator 選項(例如自動隱式約束)以不同方式處理,本稿不預測是哪一種。所以 receipt 必須記錄 Γ 與選項;同一段文字在不同 context 中不是同一個陳述。
局部子步與引理
S05.1 · implies
操作前
\Gamma_1=(a:\mathrm{Nat},\ b:\mathrm{Nat})操作後
\Gamma_1\vdash b+1:\mathrm{Nat},\ \Gamma_1\vdash a\le b:\mathrm{Prop},\ \Gamma_1\vdash a<b+1:\mathrm{Prop}條件:無
規則:lean_core_notation · 依賴:S04
葉節點依據:lean_core_notation
在加入兩個約束變數後的 context Γ1 中:HAdd Nat Nat Nat 的輸出型別是 Nat,所以 b+1 : Nat;LE.le 與 LT.lt 的型別是 Nat → Nat → Prop,套用到兩個 Nat 就得到 Prop。
S05.2 · implies
操作前
\Gamma_1\vdash a\le b:\mathrm{Prop},\ \Gamma_1\vdash a<b+1:\mathrm{Prop}操作後
\Gamma_1\vdash (a\le b\to a<b+1):\mathrm{Prop}條件:無
規則:prop_formation · 依賴:S05.1
葉節點依據:prop_formation
依規則 (i):兩個 Prop 之間的蘊含仍是 Prop。
S05.3 · implies
操作前
\Gamma_1\vdash (a\le b\to a<b+1):\mathrm{Prop}操作後
\Gamma\vdash \forall a:\mathrm{Nat},\ \forall b:\mathrm{Nat},\ (a\le b\to a<b+1):\mathrm{Prop}條件:\mathrm{Nat}:\mathrm{Type}=\mathrm{Sort}\ 1
規則:prop_formation · 依賴:S05.2
葉節點依據:prop_formation
依規則 (ii) 兩次:先在 context (a:Nat) 中約束 b,得到 ∀b:Nat, (a≤b → a<b+1) : Prop;再在空 context Γ 中約束 a。因為 Nat : Type,而 Prop 是非直謂的,對任何型別量化一個 Prop 仍得 Prop。三個子步合起來給出 S05 的結論。
S09.1 · implies
操作前
0<1
操作後
b<b+1
條件:b\in\mathbb{N}
規則:order_basics · 依賴:order_basics
葉節點依據:order_basics
由 0<1,兩邊同加 b(次序對加法保持),得 b<b+1。把 ℕ 視為 ℝ 的子集,使用同一個次序。
S09.2 · implies
操作前
a\le b,\ b<b+1
操作後
a<b+1
條件:a\le b
規則:case_analysis · 依賴:S09.1, order_basics
葉節點依據:case_analysis + order_basics + eq_replace + imp_intro + forall_intro
a≤b 表示 a<b 或 a=b。若 a<b,與 b<b+1 依傳遞得 a<b+1;若 a=b,把 b 換成 a 代入 b<b+1 直接得 a<b+1。兩種情況都得結論;a、b 是任意的,釋放假設並全稱推廣,L_main 得證。
S12.1 · implies
操作前
0-1\ \text{in Nat}操作後
0-1=0
條件:0\le 1
規則:nat_trunc_sub · 依賴:nat_trunc_sub
葉節點依據:nat_trunc_sub
因為 0≤1,截斷減法給出 0−1=0,而不是 −1;−1 不是自然數。
S12.2 · equivalent
操作前
0-1<0
操作後
0<0,\ \text{which is false}條件:無
規則:eq_replace · 依賴:S12.1, order_basics
葉節點依據:eq_replace + order_basics
以 0−1=0 代換,0−1<0 等價於 0<0;依三分律 0=0 時 0<0 不成立。