Lîm Tsú-thuàn [dan-0001]
Lîm Tsú-thuàn [dan-0001]
This blog majorly writes about computer science and mathematics, also is my personal public notes. Feel free to point out any good reference of topic you view on the site, I will add them into reference if proper.
1. Blog Posts [posts]
1. Blog Posts [posts]
Lean 中 Subtype
如何與底下的型別轉換 [lean-0003]
- December 12, 2024
- Lîm Tsú-thuàn
Lean 中 Subtype
如何與底下的型別轉換 [lean-0003]
- December 12, 2024
- Lîm Tsú-thuàn
這是從 zulip 上詢問到的做法,假設在 context 中已經有 ... ↑x ... = ...
這樣的 Prop
,並且目標就是 ... x ... = ...
,那麼使用下列的 tactic 即可
rw [← Subtype.val_inj]; norm_cast
Example. [#666]
- December 12, 2024
- Lîm Tsú-thuàn
Example. [#666]
- December 12, 2024
- Lîm Tsú-thuàn
Helper. Imports (expand to view) [#667]
- December 12, 2024
- Lîm Tsú-thuàn
Helper. Imports (expand to view) [#667]
- December 12, 2024
- Lîm Tsú-thuàn
import Mathlib.Data.Real.Basic import Mathlib.Analysis.SpecialFunctions.Pow.Real
比如我遇到的 proof context 是
c : ℝ x y : ℝ>0 ⊢ (x * y) ^ c = x ^ c * y ^ c
其中 ℝ>0
定義是
def VReal := { r : Real // 0 < r } deriving One, CommMonoid notation "ℝ>0" => VReal
先用
have K := Real.mul_rpow (le_of_lt x.property) (le_of_lt y.property) (z := c)
放置
K : (↑x * ↑y) ^ c = ↑x ^ c * ↑y ^ c
之後用
rw [← Subtype.val_inj]; norm_cast
就搞定了。
Sage 使用:微分方程式 [sage-0002]
- December 2, 2024
- Lîm Tsú-thuàn
- https://doc.sagemath.org/html/en/tutorial/tour_algebra.html
Sage 使用:微分方程式 [sage-0002]
- December 2, 2024
- Lîm Tsú-thuàn
- https://doc.sagemath.org/html/en/tutorial/tour_algebra.html
變數依然是使用 var
函數 t = var('t')
,不過要建立依賴 t
的函數變數就需要寫
x = function('x')(t)
方程式寫成 DE = diff(x, t) + x - 1
\(= \frac {d x}{d t} + x - 1\)。解方程式要用 desolve
函數,desolve(DE, [x,t])
\(= e^{-t} (C + e^t)\)
Sage 使用:微積分 [sage-0001]
- November 22, 2024
- Lîm Tsú-thuàn
Sage 使用:微積分 [sage-0001]
- November 22, 2024
- Lîm Tsú-thuàn
首先,用 var
建立變數
x = var('x')
接著就可以按照常見的方式定義函數,比如
f = x^3
微分 (diff
函數) [#300]
- November 22, 2024
- Lîm Tsú-thuàn
微分 (diff
函數) [#300]
- November 22, 2024
- Lîm Tsú-thuàn
在 sage 中要使用 diff(f, x)
來計算微分,比如這裡 diff(f, x)
\(= 3x^2\)。當然常見的數學定義也都可以使用,例如
-
diff(e^x,x)
\(= e^x\) -
diff(sin(x),x)
\(= cos x\) -
diff(cos(x),x)
\(= -sin x\)
Warning. [#301]
- November 22, 2024
- Lîm Tsú-thuàn
Warning. [#301]
- November 22, 2024
- Lîm Tsú-thuàn
有個需要注意的小細節是 f(x) = x^3
不等於 f = x^3
,兩者的調用方式並不相同
- 第一個要用
f(1)
- 第二個要用
f(x=1)
同理,diff(f, x)
的結果也受到 f
的定義方式影響
積分 (integral
函數) [#302]
- November 22, 2024
- Lîm Tsú-thuàn
積分 (integral
函數) [#302]
- November 22, 2024
- Lîm Tsú-thuàn
-
integral(f, x)
會計算不定積分 \(\int f\ dx\) -
integral(f, x, a, b)
則會計算定積分 \(\int _a^b f\ dx\)。注意參數缺失會導致錯誤
例如 integral(x^3,x)
\(= \frac {1}{4} x^4\)
Jacobian [#303]
- November 22, 2024
- Lîm Tsú-thuàn
Jacobian [#303]
- November 22, 2024
- Lîm Tsú-thuàn
多變數函數還可以求 Jacobian
f = (x*cos((1-z^2)*θ) - y*sin((1-z^2)*θ), x*sin((1-z^2)*θ) + y*cos((1-z^2)*θ), z) jacobian(f, (x,y,z))\[\begin {bmatrix} \cos ((1 - z^2)θ) & -\sin ((1 - z^2)θ) & 2yzθ \cdot \cos ((1 - z^2) θ) + 2xzθ \cdot \sin ((1 - z^2)θ) \\ \sin ((1 - z^2)θ) & \cos ((1 - z^2)θ) & -2xzθ \cdot \cos ((1 - z^2) θ) + 2yzθ \cdot \sin ((1 - z^2)θ) \\ 0 & 0 & 1 \end {bmatrix}\]
用 effect handler 實作 parser combinator [cs-001N]
- September 23, 2024
- Lîm Tsú-thuàn
用 effect handler 實作 parser combinator [cs-001N]
- September 23, 2024
- Lîm Tsú-thuàn
這些程式碼都是使用 OCaml 實現,並使用了 algeff 與 asai 程式庫
解析器需要完成的任務就是根據規則把一系列 tokens 變成文法樹,並且回報為何解析失敗,一般大學作業等級的編譯器都會讓學生直接使用解析器生成器,如 menhir 這種工具。然而實際上開發真實語言的解析器時,往往會遇到需要錯誤恢復並繼續解析,最後再回報多個錯誤的要求,這時候生成器往往給出很差的結果,甚至乾脆就是做不到的。
然而,手工編寫的解析器通常可維護性相當差劣。一種折衷的方案是所謂的解析器組合子,我過去也曾經介紹過如何利用組合子抽象掉重複的解析規則。但這種方案有個問題,就是回溯必須手動使用 try
組合子來在失敗時恢復狀態,但實務上這創造了相當難以理解的各種 try
安插,當我意識到這是因為 API 需要是兩階段的問題時,我就發現其實 effect handler 正是解決這個問題的好方法。
我本來是直接使用 Effect.Deep
的,但後來發現這種情境直接用 algeff 就足夠了,因此改採這個方案。實際程式碼如下
module Tokens = struct type t = Lexer.token Asai.Range.located list end module TokenState = Algaeff.State.Make (Tokens)
首先,我假設了 Lexer.token
這個型別存在,並且使用者會輸入一個標記過位置的 token list
。接著建立一個狀態模組,這個模組的只有三個用法:
let next_token () = match TokenState.get () with | [ eof ] -> eof | tok :: buf -> TokenState.set buf; tok | [] -> raise Impossible let shift pos = TokenState.set pos let current_position () = TokenState.get ()
這段程式巧妙的使用了 OCaml 的不可變 list 的特性,也就是持頭就可以保證資料不被回收
並且提供啟動函數
let run (init : Lexer.token Asai.Range.located list) (f : unit -> 'a) : 'a = TokenState.run ~init @@ fun () -> f ()
輔助函數. Asai 的例外捕捉 [#257]
- September 23, 2024
- Lîm Tsú-thuàn
輔助函數. Asai 的例外捕捉 [#257]
- September 23, 2024
- Lîm Tsú-thuàn
let catch_parse_error (p : unit -> 'a) : 'a option = let pos = current_position () in Reporter.try_with ~fatal:(fun d -> match d.message with | Parse_error -> shift pos; None | _ -> Reporter.fatal_diagnostic d) (fun () -> Some (p ()))
其中 Parse_error
跟 Reporter
都是使用者自訂的錯誤回報模組內容,如何定義可以參考 asai 的文件。這段輔助函數之所以出現只是為了讓讀者知道這個函數的存在,這個函數只捕捉解析失敗,讓其他錯誤繼續往上走。
常見的組合子 [cs-001O]
- September 23, 2024
- Lîm Tsú-thuàn
常見的組合子 [cs-001O]
- September 23, 2024
- Lîm Tsú-thuàn
直接消耗一個符合預測的 token consume
[#237]
- September 23, 2024
- Lîm Tsú-thuàn
直接消耗一個符合預測的 token consume
[#237]
- September 23, 2024
- Lîm Tsú-thuàn
let consume (predict : Lexer.token) : unit = let tok = next_token () in if tok.value == predict then () else # raise ...
重複解析到失敗為止 many
[#238]
- September 23, 2024
- Lîm Tsú-thuàn
重複解析到失敗為止 many
[#238]
- September 23, 2024
- Lîm Tsú-thuàn
let rec many (p : unit -> 'a) () : 'a list = let x = catch_parse_error p in match x with | None -> [] | Some x -> x :: many p ()
若失敗就解析第二個規則 [#239]
- September 23, 2024
- Lîm Tsú-thuàn
若失敗就解析第二個規則 [#239]
- September 23, 2024
- Lîm Tsú-thuàn
let ( <|> ) (p1 : unit -> 'a) (p2 : unit -> 'a) () : 'a = match catch_parse_error p1 with | None -> p2 () | Some x -> x
此外也有更複雜的錯誤恢復機制
如果最上層的定義解析失敗就紀錄失敗訊息並跳到下一個 start token 繼續解析 [#258]
- September 23, 2024
- Lîm Tsú-thuàn
如果最上層的定義解析失敗就紀錄失敗訊息並跳到下一個 start token 繼續解析 [#258]
- September 23, 2024
- Lîm Tsú-thuàn
let rec program () = let x = catch_parse_error top in match x with | Some x -> x :: program () | None -> let pos = next_start_token () in shift pos; program ()
Elaboration zoo 中的合一演算法與隱式參數 [cs-001K]
- September 22, 2024
- Lîm Tsú-thuàn
Elaboration zoo 中的合一演算法與隱式參數 [cs-001K]
- September 22, 2024
- Lîm Tsú-thuàn
程式語言為了讓使用者省略不必要的輸入,必須為使用者推導內容,這種需求催生了合一這種類型的演算法。比如很多程式語言允許泛型,比如下面的 OCaml 程式碼
let id (x : 'a) : 'a = x
Elaboration zoo 這個教學專案,它的程式碼要解決的,是一類更複雜的程式語言,叫做 dependent type 的系統中的合一問題,這類系統最重要的特性,就是類型也只是一種值,值也因此可以出現在類型中,但這就比較不是本篇的重點,有興趣的讀者可以閱讀 The Little Typer 來入門。在解釋完它的合一之後,我會介紹它隱式參數的解決方案
合一演算法的過程 [cs-001L]
- September 22, 2024
- Lîm Tsú-thuàn
合一演算法的過程 [cs-001L]
- September 22, 2024
- Lîm Tsú-thuàn
假設有程式碼
let id {A : U} (x : A) : A := x let id2 {B : U} (x : B) : B := id _ x
這裡 id _ x
中的底線就是表示「省略的引數」,被稱為 hole,我們並沒有明確的給它 B
。在展開這個 hole 時,我們用 meta variable ?0
替換它。但 meta variable 必須考慮 contextual variables 的 rigid form,因此進行套用得到 ?0 B x
這引發問題
什麼是 contextual variables?為什麼 contextual variables 是 B 與 x? [#668]
- September 22, 2024
- Lîm Tsú-thuàn
什麼是 contextual variables?為什麼 contextual variables 是 B 與 x? [#668]
- September 22, 2024
- Lîm Tsú-thuàn
答案是,這些是 ?0 能看到且實際內容未知的變數,只能用 rigid form 替代
什麼是 rigid form? [#669]
- September 22, 2024
- Lîm Tsú-thuàn
什麼是 rigid form? [#669]
- September 22, 2024
- Lîm Tsú-thuàn
rigid form 是 dependent type 中即使是 open term 也必須先進行計算而被迫在實作中出現的一種值;由於 meta variable 而被迫出現的值則叫做 flex form
現在我們手上有的 term 是 id (?0 B x) x
,現在執行 id (?0 B x)
,我們得到型別為
的 term
\[ \lambda x. x \]注意到 \((x\ :\ (?0\ B\ \textcolor {red}{x}))\) 中兩個 \(x\) 來源不同,不可混用,我用顏色表示它們的 scope 其實不同這件事
現在進入到把這個 term 套用到 x 上的環節了,因此觸發 \(x\ :\ B\) 是否是 \(?0\ B\ x\) 的 term 的合一計算,我們概念上紀錄成
\[ ?0\ B\ x \stackrel {?}{=} B \]現在合一演算法必須找出合適的 \(?0\) 來滿足等式。我們知道 \(?0\) 應該是某種 lambda
\[ \lambda 1. \lambda 2. \fbox {?} \],顯然 \(\fbox {?} = 1\) 就會給出我們想要的答案,但這部分要怎麼做到?elaboration zoo 的演算法分成三個階段
Invert [#670]
- September 22, 2024
- Lîm Tsú-thuàn
Invert [#670]
- September 22, 2024
- Lîm Tsú-thuàn
這裡的重點是,既然 \(?0\) 已經套用了 \(B\) 與 \(x\),因此就創立關聯它所創立的 lambda 變數到其 contextual variables 的 map
1 -> B 2 -> x
現在右手邊的 term 只需要看自己的每個 rigid form 有沒有被指向,只要這個 map 裡面查找到有變數是指向 rigid form 自己即反過來創立 rigid form 指向新名字的 map
Rename [#671]
- September 22, 2024
- Lîm Tsú-thuàn
Rename [#671]
- September 22, 2024
- Lîm Tsú-thuàn
因為我們右手邊的 term 是一個 rigid form \(B\),因此 map 是
B -> 1
用第二個 map 去改寫右手邊 term \(B\) 的內容,這樣我們就得到 \(\fbox {?} = 1\)
Lambda 化 [#672]
- September 22, 2024
- Lîm Tsú-thuàn
Lambda 化 [#672]
- September 22, 2024
- Lîm Tsú-thuàn
最後進行 abstraction,就得到了
\[ \lambda 1. \lambda 2. 1 \]
隱式參數的方法 [cs-001M]
- September 22, 2024
- Lîm Tsú-thuàn
隱式參數的方法 [cs-001M]
- September 22, 2024
- Lîm Tsú-thuàn
在最開始的程式碼
let id {A : U} (x : A) : A := x let id2 {B : U} (x : B) : B := id _ x
裡面,其實 {}
中的綁定叫做隱式參數,這表示我們其實也可以用 id x
來調用該函數。但這時候要怎麼知道需要補一個 hole 進去呢?elaboration zoo 作者提出的簡易方案就是區分 implicit \(\Pi \) type 與 implicit application,如此一來,當一個 implicit \(\Pi \) type 被 explicit apply 的時候,我們就知道要安插 hole 了
以 id x
而言,如果要明確的用 implicit 調用它,就必須寫成 id {B} x
,在語法就進行明確的區分。
這時候跳回去看「contextual variables 是 \(?0\) 能看到且實際內容未知的變數」就更能了解其理由了,因為已經能明確知道其內容的變數,如
let x = t
x
就是指向 t
的情況,若右手 term 是 x
,其實也會是 t
去進行 unify。若右手 term 已經是 rigid form 又可參照,就更不需要成為 contextual variables,因為其 solution 就是把右手 term 原封不動放入,在反轉 map 的時候,只要記得這個 rigid 是非 contextual,就可以為它寫一個 identity mapping。
Racket 中的有界續延如何實作 effect system 的功能? [cs-001I]
- August 27, 2024
- Lîm Tsú-thuàn
Racket 中的有界續延如何實作 effect system 的功能? [cs-001I]
- August 27, 2024
- Lîm Tsú-thuàn
討論如何用 racket 中的 continuation 實作 effect system 的概念
一個 effect system 大概做了什麼,我們從 effekt 語言的案例開始理解
- 一個簽名
effect yield(v : Int) : Bool
- 一個 handler
try { ... } with yield { n => ...; resume(n < 10) }
- 在
try
區塊中調用的函數f
可以用do yield(k)
來調用 handler - 當
f
執行到do yield(k)
,就會跳轉到with yield
中繼續進行,並且n = k
- 當程式執行到
resume
就會跳回去f
之後的do yield(k)
的續延繼續執行
事實上,exception 系統也可以實現成,沒有調用 resume 的 effect handler,讀者或許也已經想出數種使用方法了吧?這正是 effect system 的魅力。racket 擁有比 effect handler 更複雜的機制(continuation with marks),不過 effect handler 機制有保障使用者不容易出錯的好處,因此在 racket 中模擬一套 effect system 就有它的意義,並且是有趣的挑戰。
call/prompt
[racket-0005]
- August 27, 2024
call/prompt
[racket-0005]
- August 27, 2024
call/prompt
的主要功能,就如其名稱,是為被呼叫的函數提示一個標記,這個標記在 abort/cc
會被使用。完整的 call/prompt
調用是
(call/prompt f tag handler args ...)
f
是被調用的函數,中間的 tag
是標記,handler
是處理標記的函數,剩下的都是 f
的參數。讀者可以想像成
(with-handler [tag handler] (f args ...))
abort/cc
[racket-0006]
- August 27, 2024
abort/cc
[racket-0006]
- August 27, 2024
abort/cc
的調用是
(abort/cc tag vs ...)
tag
當然就是先前 prompt 寫進去的 tag
,而 vs ...
會用來呼叫 handler
(handler vs ...)
Continuation prompt tag 的產生方式 [racket-0008]
- August 27, 2024
Continuation prompt tag 的產生方式 [racket-0008]
- August 27, 2024
調用 (make-continuation-prompt-tag)
產出,這個函數還可以接受一個 symbol 產生可讀的識別碼,並且每次調用這個函數,產生的 tag 都算是不同的 tag,勿必要儲存好這個實體。
要想實現 exception 目前的程式已經完全充分了,只要寫下
(define (f params ...) (abort/cc tag "cannot read file ...")) (call/prompt f tag (λ (err) (printf "got err ~a~n" err)) args ...)
即可。事實上 racket 自身的的 exception 也是這樣實作的,要考慮的問題是,前面我們看過 resume
可以跳回去被呼叫的函數!這是如何做到的?
call/cc
[racket-0007]
- August 27, 2024
call/cc
[racket-0007]
- August 27, 2024
call/cc
這個函數是 call with current continuation 的意思,比如說在下面的程式碼中
(* 2 1)
1
的 continuation 就是把 1
挖掉留下的 (* 2 hole)
,故下列程式碼
(* 2 (call/cc (λ (k) (k 1))))
的結果是 2
。讀者可以想像 k = λ (hole) (* 2 hole)
,這在實作上不太正確,但對理解很有幫助。
一般來說,racket 的函數會簡單的寫成
(define (f params ...) stmt1 ... stmtn)
如果我在其中安放一個 call/cc
會發生什麼事呢?
(define (f params ...) ... (call/cc (λ (k) ...)) stmtk ...)
答案是 k = λ () (begin stmtk ... stmtn)
。由於 racket 自動把
stmt1 ... stmtn
包裝成 (begin stmt1 ... stmtn)
,而
(begin stmt1 stmt2 ...)
中 stmt1
的 continuation 是 (begin stmt2 ...)
,以此類推就很容易理解 k
等於什麼了。
我們正是需要使用 call/cc
來做出 resume 的效果。
實現 resume [#281]
- August 27, 2024
- Lîm Tsú-thuàn
實現 resume [#281]
- August 27, 2024
- Lîm Tsú-thuàn
在 f
中我們寫下
(define (f params ...) (call/cc (λ (k) (abort/cc tag k ...))))
在 call/prompt
的 handler 中新增一個 resume
參數,這樣就完成了。讀者可以填補下面的程式中的空白來檢驗結果,也充當練習
(define (f params ...) (call/cc (λ (k) (abort/cc tag k ...))) ...) (call/prompt f tag (λ (resume ...) ... ; 跳回 f 繼續 (resume)) args ...)
到這裡我們已經有了運行的基礎,要改善有幾個方向可以參考
- 用 macro 包裝語法
- 放到 typed/racket 中加上 effect 類型檢查確保使用者沒有漏掉 handler
- 支持 finally handler,保證任何退出行為都會被這個 handler 攔截(考慮 racket 的函數
dynamic-wind
)
我們下次見。
Interact with webmention.io [webmention-0003]
- August 10, 2024
- Lîm Tsú-thuàn
Interact with webmention.io [webmention-0003]
- August 10, 2024
- Lîm Tsú-thuàn
As I told in integrate forster site with existed webmentions tools, I will explain how to interact with API of webmention.io. Basically, you send a HTTP GET to the link below
https://webmention.io/api/mentions.jf2?domain=<your domain>&token=<your token>
You can get token at setting page, the result you will get will be like below
{ "type": "feed", "name": "Webmentions", "children": [ ... ] }
each children is
{ "type": "entry", "author": { "type": "card", "name": ..., "photo": ..., "url": ... }, "url": <source>, "published": null, "wm-received": ..., "wm-id": ..., "wm-source": ..., "wm-target": <target>, "wm-protocol": "webmention", "like-of": <target>, "wm-property": "like-of", "wm-private": false }
so you can parse this JSON and produce mention HTML for each target, and if you don't want to pull the whole feed, you can set since
as below
https://webmention.io/api/mentions.jf2?domain=<your domain>&token=<your token>&since=<time>
time format 2017-06-01T10:00:00-0700
. Of course, if you would not like to manage these mentions by hand, you can also consider my project webmention_db, which maintains mentions data for you at local.
Integrate forster site with existed webmentions tools [webmention-0002]
- July 31, 2024
- Lîm Tsú-thuàn
Integrate forster site with existed webmentions tools [webmention-0002]
- July 31, 2024
- Lîm Tsú-thuàn
Discuss how to make webmentions worked for forester.
This is a following post of the concept of webmention and forester, show how can you integrate a forester site with existed webmentions tools. To provide webmentions, the document must have a <link>
to provide webmention endopint, you don't have endpoint at this moment, that's why we need webmention.io
Get endopint via webmention.io (receiver service) [#282]
- July 31, 2024
- Lîm Tsú-thuàn
Get endopint via webmention.io (receiver service) [#282]
- July 31, 2024
- Lîm Tsú-thuàn
Go to webmention.io, there is a Web Sign-In form, put your <domain>
into it. Then it would load email via indie auth (you must provide the following content in index.html
for it)
<head> <link rel="me" href="mailto:your-mail">your-mail</a> <link rel="me" href="your-mastodon">Mastodon</a> <!-- you still haven't have endopint, just remind you once get one, back to here to insert it --> <link rel="webmention" href="<endpoint>" /> </head>
then send you a verify mail, after you login and click sites tab you will see a picture like
Click Get Setup Code, then you will see link like below
https://webmention.io/<domain>/webmention
that's the <endpoint>
for your site. We need to put it into tree.xsl
<head> …… <link rel="webmention" href="<endpoint>" /> …… </head>
If you want to send POST request to webmention.io manually, then here we already complete, but if you want to combine social media, we need to do more.
Bridgy [#283]
- July 31, 2024
- Lîm Tsú-thuàn
Bridgy [#283]
- July 31, 2024
- Lîm Tsú-thuàn
bridgy is a complex service, it plays several roles, but use it is relatively easy. At home page, you should see
I only use mastodon as example, you click the mastodon button, then get
click Cross-post to a Mastodon account..., unless your site is also a fediverse instance and know what to do. Then it would list your accounts (connected to bridgy) at Click to open an account you're currently logged into, go for one then you would see a form Enter post URL:, that's the place to give it your post link, but no rush, we need to prepare something.
- First, we cannot use
https://domain/xxx.xml
(I open an issue for this) - second, we haven't prepare proper document.
Microformat [#284]
- July 31, 2024
- Lîm Tsú-thuàn
Microformat [#284]
- July 31, 2024
- Lîm Tsú-thuàn
To make a https://domain/xxx.html
be a proper document, we must provide microformat, so you will need to macro
\def\hentry[descrption]{ \<html:div>[class]{h-entry}[hidden]{true}{ \<html:p>[class]{e-content}{ \descrption } } }
and invoke \hentry{describe the tree}
in every tree that you want to provide webmentions.
Now, your tree has proper content, the final step is using xsltproc
xsltproc default.xsl xxx.xml > xxx.html
to provide html version for post, then cross post html link on bridgy.
If all correct, you will be able to see the Dashboard of webmention.io has a list of reactions, which is made by people click like, repost, or reply your toot on mastodon. You might wondering do I missing something here? Yes, we want webmentions because we want to show reactions on our site, we will interact with webmention.io's APIs to collect mentions data, so that we can show them, that will be the next post.
The concept of webmention and forester [webmention-0001]
- July 30, 2024
- Lîm Tsú-thuàn
The concept of webmention and forester [webmention-0001]
- July 30, 2024
- Lîm Tsú-thuàn
Discuss how can we implement a webmention receiver for forester.
Each post in forester will be a xml (let's use my site as the example https://dannypsnl.me/xxx.xml
), post should provide the following content in <head></head>
<link href="https://dannypsnl.me/webmention-endpoint" rel="webmention" />
Sender view [#285]
- July 30, 2024
- Lîm Tsú-thuàn
Sender view [#285]
- July 30, 2024
- Lîm Tsú-thuàn
According to webmention spec, if someone tries to notify my site that there is a link mentions my post, then she has to do the following:
-
curl -I https://dannypsnl.me/xxx.xml
to get my webmention endpoint in thehead
- post the data, where
<link>
is the link refers to my postPOST /webmention-endpoint HTTP/1.1 Host: dannypsnl.me Content-Type: application/x-www-form-urlencoded source=<link> target=https://dannypsnl.me/xxx.xml
Receiver view [#286]
- July 30, 2024
- Lîm Tsú-thuàn
Receiver view [#286]
- July 30, 2024
- Lîm Tsú-thuàn
Therefore, a receiver is a POST
handler. According to spec, we can
- return http code
201
withLocation
in header pointing to the status URL - return http code
202
and asynchronously perform the verification - return http code
200
and synchronously perform the verification (not recommended), by section 3.2.2Webmention verification should be handled asynchronously to prevent DoS (Denial of Service) attacks.
Verification [#287]
- July 30, 2024
- Lîm Tsú-thuàn
Verification [#287]
- July 30, 2024
- Lîm Tsú-thuàn
- The receiver must check that
source
andtarget
are valid URLs [URL] and are of schemes that are supported by the receiver. (Most commonly this means checking that thesource
andtarget
schemes are http or https). - The receiver must reject the request if the
source
URL is the same as thetarget
URL. - The receiver should check that
target
is a valid resource for which it can accept Webmentions. This check should happen synchronously to reject invalid Webmentions before more in-depth verification begins. What a "valid resource" means is up to the receiver. For example, some receivers may accept Webmentions for multiple domains, others may accept Webmentions for only the same domain the endpoint is on.
If the receiver is going to use the Webmention in some way, (displaying it as a comment on a post, incrementing a like counter, notifying the author of a post), then it must perform an HTTP GET request on source
, following any HTTP redirects (and should limit the number of redirects it follows) to confirm that it actually mentions the target. The receiver should include an HTTP Accept header indicating its preference of content types that are acceptable.
Error response [#288]
- July 30, 2024
- Lîm Tsú-thuàn
Error response [#288]
- July 30, 2024
- Lîm Tsú-thuàn
If the Webmention was not successful because of something the sender did, it must return a 400 Bad Request status code and may include a description of the error in the response body.
However, hosting a receiver can be annoying, so the next post I will introduce how to build on the top of some existed tools.
用 docker compose 建立 hot reload 的 forest 筆記 [forester-000D]
- July 13, 2024
- Lîm Tsú-thuàn
用 docker compose 建立 hot reload 的 forest 筆記 [forester-000D]
- July 13, 2024
- Lîm Tsú-thuàn
建立 docker image [#261]
- July 13, 2024
- Lîm Tsú-thuàn
建立 docker image [#261]
- July 13, 2024
- Lîm Tsú-thuàn
Dockerfile 的內容
FROM ubuntu:oracular RUN apt-get update RUN apt install -y opam RUN apt install -y build-essential RUN opam init -y RUN git clone https://git.sr.ht/~jonsterling/ocaml-forester RUN cd ocaml-forester; opam pin -y . RUN apt install -y curl RUN curl https://sh.rustup.rs -sSf | \ sh -s -- --default-toolchain stable -y ENV PATH=/root/.cargo/bin:$PATH ENV PATH=/root/.opam/default/bin:$PATH RUN cargo install forest-server CMD [ "forest", "watch", "1313", "--", "build --dev dev.toml" ]
大致上就是下載 opam
、forest-server
等必要工具,然後指定指令監看檔案變化進行 reload。用 docker build . -t forest:latest
產出 image。
Configure docker compose [#262]
- July 13, 2024
- Lîm Tsú-thuàn
Configure docker compose [#262]
- July 13, 2024
- Lîm Tsú-thuàn
services: forest: image: "forest:latest" working_dir: "<hostpath/to/your-forest>" ports: - "1313:1313" labels: - "traefik.enable=true" - "traefik.http.routers.whoami.rule=Host(`forest.localhost`)" - "traefik.http.routers.whoami.entrypoints=web" volumes: - "./:<hostpath/to/your-forest>" traefik: image: "traefik:v2.10" container_name: "traefik" command: - "--api.insecure=true" - "--providers.docker=true" - "--providers.docker.exposedbydefault=false" - "--entrypoints.web.address=:80" ports: - "80:80" # Web UI - "8080:8080" volumes: - "/var/run/docker.sock:/var/run/docker.sock:ro"
<hostpath/to/your-forest>
這部分不能省略,因為這樣每篇 tree 中的 edit 按鈕才會是正確的 host 路徑。執行 docker compose up -d
啟動 containers。
最後你可以在 forest.localhost:1313
存取到 forest,之後就只需要修改跟新增 tree 即可。
避免寫死 host 路徑 [#263]
- July 13, 2024
- Lîm Tsú-thuàn
避免寫死 host 路徑 [#263]
- July 13, 2024
- Lîm Tsú-thuàn
如果真的不想寫死的話可以像我一樣用 YAML.jl 這一類的工具直接寫個小腳本搞定
using YAML forest_dir = pwd() data = YAML.load_file("blog.yml") data["services"]["blog"]["working_dir"] = forest_dir data["services"]["blog"]["volumes"] = ["./:$(forest_dir)"] YAML.write_file("docker-compose.yml", data)
無外部空間下如何考慮幾何空間的測量? [math-00C4]
- July 1, 2024
- Lîm Tsú-thuàn
無外部空間下如何考慮幾何空間的測量? [math-00C4]
- July 1, 2024
- Lîm Tsú-thuàn
自 g0v 貼文 改寫
metric 就是在測量長度。不過在歐式空間裡面討論嵌入其中的曲面時,曲面有外部空間切向量,也就是歐式空間的向量可以使用。如果曲面沒有外空間,就需要自己做一個出來,這就引出了 Riemann metric 的想法:對可微分流形 \(M\) 的每一點 \(p\) 考慮抽象的切空間 \(T_pM\)(不考慮 \(T_pM\) 到底是什麼),重點是隨點附上內積函數 \(g : T_pM \times T_pM \to R\),因為是模仿內積所以有 bilinearity, positive-definiteness, symmetry 等性質
現在考慮曲線 \(y : [0, 1] \to M\),在每一點度量 \(T_pM\) 向量並積分(加起來)即是曲線長度。又隨著區間 \(t : [0, 1]\) 改變,會有對應變化的 \(p\) 點,因此模仿並定義
\[ \text {length}(y) = \int _0^1 \sqrt {g( \frac {d y}{d t} , \frac {d y}{d t} )} dt \]\(\sqrt {g( \frac {d y}{d t} , \frac {d y}{d t} )}\) 是 norm 的定義,積分因為是跟著 \(t\) 變化,因此依賴 \(y\) 的參數 \(t\) 來定義。如此一來就可以問下一個問題:根據 g 是從 a 到 b 的最短曲線是誰,這就是曲面上的直線的概念(然而,全域與局部最短線,是不一樣的問題,考慮整體將會複雜許多)。
一個失敗的類型論 inductive types 定義方案 [tt-001O]
- April 28, 2024
- Lîm Tsú-thuàn
一個失敗的類型論 inductive types 定義方案 [tt-001O]
- April 28, 2024
- Lîm Tsú-thuàn
從上次提到之後,我到現在都會斷斷續續的思考這個問題。現在我認為 type pattern matching 在 dependent type 中是一個失敗的想法。或許這個方案只是太過複雜而非不能達成,但我認為目前缺點已經超過這套系統能帶來的好處。下面我會討論一些精簡的推導與相應的結果
- 在最早想到這個方案時,由於發現要避免多態性被打破,所以在一般 universe
U
之外要有一個特殊的 universe,之後會稱其為U-
。 - 因為每個
A : U-
身為型別與身為值不一樣,這需要一個區分用法的方式,可以考慮極化計算性作為解法,所以到這裡我還沒有停步。
然而,有一個特殊的規則是變數不能是 U-
,免得出現 stuck value 出現在 U-
的計算之中,但這在 type pattern match 的變數 case 中會出現,這裡是我開始認為這套系統沒機會的地方。關於這種情況,我有兩個想法
- 第一種是規定一種特殊的
U- or U
的選擇,讓型別定義可以用U
表示變數的情況,但這又讓型別 universe 更複雜了,我認為這個方向沒什麼機會。 - 第二種是放鬆只能在 inductive types 定義中使用
U-
的限制,因為這類 inductive types 必然不能被多態函數使用,因此放鬆使用位置之後就能寫出定義時是多態,而使用時必然是單態的新型態函數。這個方向還需要再限制不讓x : U-
是隱式參數,這樣就不可能有 stuck value 出現。
此外我沒有想到有什麼錯誤,但這複雜化了實際使用,所以到這裡我就暫時告一段落。
用 agda 玩翻杯子遊戲 [agda-0003]
- March 31, 2024
- Lîm Tsú-thuàn
- agda-0003.html
用 agda 玩翻杯子遊戲 [agda-0003]
- March 31, 2024
- Lîm Tsú-thuàn
- agda-0003.html
翻杯子遊戲是一個很有名的派對遊戲與典型的奇偶問題。遊戲從 3 個向下的杯子與 2 個向上的杯子開始,每次可以選兩個不同的杯子,被選中的杯子方向會翻轉,問是否有辦法反覆這個動作,得到五個向上的杯子。
Exercise. [#678]
- March 31, 2024
- Lîm Tsú-thuàn
Exercise. [#678]
- March 31, 2024
- Lîm Tsú-thuàn
在開始閱讀之前,你可以自己先想想看問題的方案。若有辦法達成,提出需要執行什麼步驟;若不可能達成,提出為何無法達成。
正如標題說的,我們想用 agda 來玩這個遊戲,所以需要知道怎麼用這個程式語言。
Tool. Agda 的開發工具 [agda-0005]
- April 1, 2024
- Lîm Tsú-thuàn
Tool. Agda 的開發工具 [agda-0005]
- April 1, 2024
- Lîm Tsú-thuàn
我使用的編輯器工具是 agda mode on VS Code,也可以用 emacs 之類的。常用操作有
-
ctrl+c
,ctrl+l
會編譯檢查檔案,假設程式中有?
,會被替換成所謂的 hole{! !}
,其實就是待寫的程式 -
ctrl+c
,ctrl+,
可以窺看 hole 的目標類型,與當前 context 有哪些 term 可用 -
ctrl+c
,ctrl+r
會把 hole 中你打的程式碼往前提取,當然前提是類型是正確的 -
ctrl+c
,ctrl+m
會把 hole 中你打的程式碼直接當成結果,一樣類型要是正確的 - 一般來說一個 agda 定義如下
hello : A → B hello a = {! !}
ctrl+c, ctrl+c 會問你要把哪個變數用構造子分開,回答a
,假設有a1
與a2
兩個構造子,程式就會變成hello : A → B hello a1 = {! !} hello a2 = {! !}
Remark. [#677]
- April 1, 2024
- Lîm Tsú-thuàn
Remark. [#677]
- April 1, 2024
- Lîm Tsú-thuàn
使用 Linux 的使用者可以更改預設的 copy/cut 指令以免衝突。
Collary. 本篇出現的符號輸入 [#679]
- March 31, 2024
- Lîm Tsú-thuàn
Collary. 本篇出現的符號輸入 [#679]
- March 31, 2024
- Lîm Tsú-thuàn
\bN |
ℕ |
---|---|
\bP |
ℙ |
\:: Vector 類型的串接符號 |
∷ |
\_1 表示下標 1 |
₁ |
\^1 表示上標 1 |
¹ |
\^- 表示上標負號 |
⁻ |
\equiv |
≡ |
\nequiv |
≢ |
\< |
≡⟨⟩ 中的 ⟨ |
\> |
≡⟨⟩ 中的 ⟩ |
\r 函數類型的分隔符 |
→ |
\Gl 匿名函數的開頭 |
λ |
建立模型 [#680]
- March 31, 2024
- Lîm Tsú-thuàn
建立模型 [#680]
- March 31, 2024
- Lîm Tsú-thuàn
由於每次要找兩個杯子做翻轉,而且杯子只有上跟下的分別,因此我們可以考慮用 Data.Parity
來表示杯子的狀態,其中 _⁻¹
表示可以翻轉杯子,所以引用
open import Data.Parity.Base open import Data.Parity.Properties
接著,五個杯子可以用 vector 表示,所以引入模組並定義
open import Data.Nat open import Data.Vec open import Data.Vec.Properties _Cups : ℕ → Set n Cups = Vec Parity n
現在,我們可以寫下初始狀態與目標狀態
open Parity initS : 5 Cups initS = 0ℙ ∷ 0ℙ ∷ 1ℙ ∷ 1ℙ ∷ 0ℙ ∷ [] target : 5 Cups target = 1ℙ ∷ 1ℙ ∷ 1ℙ ∷ 1ℙ ∷ 1ℙ ∷ []
猜想與結論 [#681]
- March 31, 2024
- Lîm Tsú-thuàn
猜想與結論 [#681]
- March 31, 2024
- Lîm Tsú-thuàn
為了證明從 initS
到 target
是不可能的
- 需要考慮根據「找兩個杯子翻轉實際上有可能達成的所有結果」。
- 此外,如
0ℙ ∷ 0ℙ ∷ 1ℙ ∷ 1ℙ ∷ 0ℙ
與0ℙ ∷ 0ℙ ∷ 1ℙ ∷ 0ℙ ∷ 1ℙ
之間的差異於我們無關緊要。
由於可能的杯子狀態只有 0ℙ
跟 1ℙ
,所以可能的選擇有
-
(0ℙ, 0ℙ)
到(1ℙ, 1ℙ)
-
(0ℙ, 1ℙ)
到(1ℙ, 0ℙ)
-
(1ℙ, 0ℙ)
到(0ℙ, 1ℙ)
-
(1ℙ, 1ℙ)
到(0ℙ, 0ℙ)
中間兩個是 identical 的轉換,由於我們上面討論的第二點,他們不會對狀態造成改變;第一個會把原封不動變成翻轉兩次,最後一個把翻轉兩次變成不動。所以綜合而論就是,若把 n Cups
中的 Parity
全部直接加起來,就能夠分辨狀態是否有可能互換,據此定義 χ
函數。
χ : ∀ {n} → n Cups → Parity χ [] = 0ℙ χ (x ∷ cups) = χ cups + x
因此只論遊戲目的,下面的兩個事實就已經證明答案是不可能達成,因為兩者的奇偶性不同,然而我們唯一能做的動作不會改變奇偶性。
lemma₁ : χ initS ≡ 0ℙ lemma₁ = refl lemma₂ : χ target ≡ 1ℙ lemma₂ = refl
推廣結果 [#682]
- March 31, 2024
- Lîm Tsú-thuàn
推廣結果 [#682]
- March 31, 2024
- Lîm Tsú-thuàn
但我們還想要知道廣泛的來說,如何將事實表現成定理,並且應用到任意 n Cups
上,因此有
theorem : ∀ {n} → (i j : Fin n) → (a : n Cups) ------------------------------------------------ → χ ((a [ i ]%= _⁻¹) [ j ]%= _⁻¹) ≡ χ a theorem i j a = begin χ (updateAt (updateAt a i _⁻¹) j _⁻¹) ≡⟨ lemma j (a [ i ]%= _⁻¹) ⟩ χ (updateAt a i _⁻¹)⁻¹ ≡⟨ ⁻¹-selfInverse (sym (lemma i a)) ⟩ χ a ∎ where open ≡-Reasoning open Lemma
其意義是,對任意有限多個杯子進行兩次翻轉,奇偶性不變。這個定理比實際遊戲進行的行為更廣泛一些,i ≢ j
才是對應現實中的翻杯子行為,因為選擇是先進行的,而翻轉是同時做。但因為對同一杯子翻轉兩次也不會改變奇偶狀態,所以 i ≡ j
也行。其中
-
a [ i ]%= _⁻¹
表示對a
的位置i
套用翻轉函數。 -
x ≡ y
表示要證明x
等於y
。 -
begin
到∎
用來寫出等式替換的過程,程式a ≡⟨ lemma ⟩ b
的意義是,根據lemma
可知a ≡ b
。這些程式要通過引用open import Relation.Binary.PropositionalEquality
並使用open ≡-Reasoning
來存取。 - 這裡出現的
Fin n
需要引用open import Data.Fin
由於跟Data.Nat
有名稱衝突,需要用using
跟renaming
控制引用的符號。
Exercise. [#683]
- March 31, 2024
- Lîm Tsú-thuàn
Exercise. [#683]
- March 31, 2024
- Lîm Tsú-thuàn
上面的 open Lemma
是一個內部模組,下面留空讓你自行證明
module Lemma where lemma : ∀ {n} → (i : Fin n) → (a : n Cups) ---------------------------------------------------------- → χ (a [ i ]%= _⁻¹) ≡ χ a ⁻¹ lemma i a = {! !}
Conclusion. [#684]
- March 31, 2024
- Lîm Tsú-thuàn
Conclusion. [#684]
- March 31, 2024
- Lîm Tsú-thuàn
結論當然還可以再推廣,例如不再是翻兩個而是三個杯子呢?假使奇偶相同,只做某動作就一定能得到某狀態嗎?或是假使動作能改變奇偶性,是否就一定能達成某狀態呢?把玩想像構物的有趣之處,歡迎自行體驗。
使用 TLA+ 的第一步 [tlaplus-0002]
- March 27, 2024
- Lîm Tsú-thuàn
使用 TLA+ 的第一步 [tlaplus-0002]
- March 27, 2024
- Lîm Tsú-thuàn
由於很多 TLA+ 入門教學似乎都沒有談到實務上要從哪裡開始使用 TLA+,所以這裡我想介紹實際上要怎麼做。一個 TLA+ 的檔案以 .tla
為副檔名,其中由 --- MODULE name ---
開頭,由 ===
結尾,例如
---- MODULE plustwo ---- =====
在其中可以引用模組,寫成 EXTENDS xxx, yyy, ...
---- MODULE plustwo ---- EXTENDS Integers =====
使用 PlusCal 語言 [#278]
- March 27, 2024
- Lîm Tsú-thuàn
使用 PlusCal 語言 [#278]
- March 27, 2024
- Lîm Tsú-thuàn
比起直接寫出 Spec
等不變式,先寫 PlusCal language 的程式再使用用它生成的 Spec
不變量會更簡單也更實用。因為 TLA+ 會嘗試生成所有可能的狀態,有可能出現所謂的 unbound model,就結果而言對它進行檢查永遠不會完成。用 PlusCal 語言寫的程式相對容易發現這種錯誤。
---- MODULE plustwo ---- EXTENDS Integers CONSTANT Limit (* --algorithm plustwo variables x = 0; begin while x < Limit do x := x + 2; end while; end algorithm; *) \* BEGIN TRANSLATION (chksum(pcal) = "3f62e9ff" /\ chksum(tla) = "239a9ecd") \* END TRANSLATION =====
由 PlusCal 產出的不變量會被包在 BEGIN TRANSLATION
到 END TRANSLATION
裡面,可以發現它還會檢查 checksum。由於這個區塊內的程式會被機器生成的內容覆蓋,要記得千萬不要把自己寫的不變量放在這裡面。
上面的 CONSTANT Limit
可以在 model 的設定檔 .cfg
中指定,這是為了避免把常數寫死在 TLA+ 主程式中,好在檢查前可以進行修改。
增加自己的不變量 [#279]
- March 27, 2024
- Lîm Tsú-thuàn
增加自己的不變量 [#279]
- March 27, 2024
- Lîm Tsú-thuàn
在有了這些程式之後,可以開始增加自己的不變量
Even(x) == x % 2 = 0 IsInc == x >= 0 Inv == IsInc /\ Even(x) THEOREM Terminated == Spec => Termination
-
IsInc
要求x
總是大於初始值0
-
Even(x)
要求我們寫的程式只會產生偶數 -
Inv
把所有我們想證明的不變量組合在一起,/\
表示邏輯的「a 且 b」語句。我想很容易猜到\/
表示邏輯的「a 或 b」語句
THEOREM
部分宣告 Spec
蘊含 Termination
不變量,這兩者都是 PlusCal 產生的,所以不用太在意細節,這裡的意義是證明程式確實會終止。
Conclusion. [#280]
- March 27, 2024
- Lîm Tsú-thuàn
Conclusion. [#280]
- March 27, 2024
- Lîm Tsú-thuàn
這裡介紹了 TLA+ 如何運作,TLA+ 對現實程式的幫助會體現在編寫非同步的程式時,TLA+ 擅長對只有有限狀態、可以使用經典邏輯推導的程式進行檢查,主要可以發現死鎖與違反不變式等錯誤。對 TLA+ 所使用的數學方面的學習可以參考 Lamport 本人寫的 A Science of Concurrent Programs。
滿足 \(\text {null }T = \text {range }T\) 的矩陣 \(T : \R ^4 \to \R ^4\) [linear-000C]
- March 24, 2024
- Lîm Tsú-thuàn
滿足 \(\text {null }T = \text {range }T\) 的矩陣 \(T : \R ^4 \to \R ^4\) [linear-000C]
- March 24, 2024
- Lîm Tsú-thuàn
在我最早的想法中,根據 \(\text {range }T = \text {null }T\),可以看出 \(T(Tv) = 0\) 對所有 \(v \in \R ^4\) 成立。因此,可以假設
\[ T = \begin {bmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} \end {bmatrix} \]計算 \(TT\) 可以得
\[ T^2 = \begin {bmatrix} {a_{11}}^2 + a_{12}a_{21} + a_{13}a_{31} + a_{14}a_{41} & a_{11}a_{12} + a_{12}a_{22} + a_{13}a_{32} + a_{14}a_{42} & a_{11}a_{13} + a_{12}a_{23} + a_{13}a_{33} + a_{14}a_{43} & a_{11}a_{14} + a_{12}a_{24} + a_{13}a_{34} + a_{14}a_{44} \\ a_{11}a_{21} + a_{21}a_{22} + a_{23}a_{31} + a_{24}a_{41} & a_{12}a_{21} + {a_{22}}^2 + a_{23}a_{32} + a_{24}a_{42} & a_{13}a_{21} + a_{22}a_{23} + a_{23}a_{33} + a_{24}a_{43} & a14a_{21} + a_{22}a_{24} + a_{23}a_{34} + a_{24}a_{44} \\ a_{11}a_{31} + a_{21}a_{32} + a_{31}a_{33} + a_{34}a_{41} & a_{12}a_{31} + a_{22}a_{32} + a_{32}a_{33} + a_{34}a_{42} & a_{13}a_{31} + a_{23}a_{32} + {a_{33}}^2 + a_{34}a_{43} & a14a_{31} + a_{24}a_{32} + a_{33}a_{34} + a_{34}a_{44} \\ a_{11}a_{41} + a_{21}a_{42} + a_{31}a_{43} + a_{41}a_{44} & a_{12}a_{41} + a_{22}a_{42} + a_{32}a_{43} + a_{42}a_{44} & a_{13}a_{41} + a_{23}a_{42} + a_{33}a_{43} + a_{43}a_{44} & a14a_{41} + a_{24}a_{42} + a_{34}a_{43} + {a_{44}}^2 \\ \end {bmatrix} \]因此這裡就有了 16 個方程式。可以知道
\[ a_{i1} = \frac {-(a_{i2}a_{2j} + a_{i3}a_{3j} + a_{i4}a_{4j})} {a_{1j}} \]令 \(a_{1j} = 1\),得
\[ 1 = a_{11} = \frac {-(a_{i2}a_{2j} + a_{i3}a_{3j} + a_{i4}a_{4j})} {a_{11}} = -(a_{i2}a_{2j} + a_{i3}a_{3j} + a_{i4}a_{4j}) \]接著指定 \(a_{21} = 1, a_{31} = -1, a_{41} = -1\),得
\[ T = \begin {bmatrix} 1 & 1 & 1 & 1 \\ 1 & a_{22} & a_{23} & a_{24} \\ -1 & a_{32} & a_{33} & a_{34} \\ -1 & a_{42} & a_{43} & a_{44} \end {bmatrix} \]接著依次指定值滿足方程式,如
- \(1+a_{22}-a_{23}-a_{24} = 0\)
- \(-1+a_{32}-a_{33}-a_{34} = 0\)
- \(-1+a_{42}-a_{43}-a_{44} = 0\)
就可以湊出
\[ T = \begin {bmatrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ -1 & -1 & -1 & -1 \\ -1 & 1 & -1 & 1 \end {bmatrix} \]不過這個辦法適合求出具體的矩陣,卻很難用來證明任意次數的空間有或無這種線性變換的存在。有效率的方法是使用 rank-nullity,在限制下可以知道 \(\text {rank}\;T = 2 = \text {nullity}\;T\) 因此只對 \(2\) 個維度造成影響的矩陣都可以。同理可以推論奇數有限維度皆不滿足,故 \(\R ^5 \to \R ^5\) 滿足這個性質的矩陣不存在。
Component model 的基本案例 [software-0012]
- March 7, 2024
- Lîm Tsú-thuàn
Component model 的基本案例 [software-0012]
- March 7, 2024
- Lîm Tsú-thuàn
最基本的範例如下
(component (core module $M (func (export "dup") (param i64) (result i64) local.get 0 local.get 0 i64.add) ) (core instance $m (instantiate $M)) (func $run (param "a" s64) (result s64) (canon lift (core func $m "dup")) ) (export "mdup" (func $run)) )
這段程式碼以 .wat 的 component 擴展格式寫成,其意義是
- 宣告一個 core module,也就是原始的 wasm 格式,其中導出一個函數
dup
- 接著實例化 (instantiate) 這個 module,這裡可以發現 component model 的主要用途正是讓實例化可以被編程,成為其他高階工具的輸出內容,這裡的地位類似 linker script
- 接著,一個 instance 的函數就可以被 component 的函數包裝,只要用
canon lift
提升即可。不過要注意的是,如果函數帶有需要記憶體操作的簽名,例如有字串參數,就需要提供 memory 與 realloc 等參數,好讓 runtime 知道如何進行資料在不同 component 之間編碼傳遞 - 最後導出包裝函數,命名為
mdup
,外部的使用者就可以調用了
Example. Functor category 中的 monomorphism 不一定由 monomorphism 組成 [math-007Z]
- February 1, 2024
- Lîm Tsú-thuàn
Example. Functor category 中的 monomorphism 不一定由 monomorphism 組成 [math-007Z]
- February 1, 2024
- Lîm Tsú-thuàn
考慮 \(A\) 範疇是 \(0 \to 1\) 與 \(B\) 範疇,其中 \(fg=fh=k\) 但注意 \(f\) 不是 mono,因為這沒有蘊含 \(g=h\)
因此 functor category \([A,B]\) 是 \(B\) 的 arrow category。現在我們可以指出 natural transformation \((1_B, f) : (B,B)\to (B,C)\) 是 \([A,B]\) 中的 monomorphism,但其 component \(f\) 並不是 mono。要檢查 \((1_B,f)\) 是 mono 可以列出所有可以串在前面的 arrows,在這裡有四個。
對應的結果是 (左到右,上到下)
- \((fg,g) = (k,g)\)
- \((fh,h) = (k,h)\)
- \((f,g)\)
- \((f,h)\)
確實滿足 mono 的特性,\((1_B,f) \circ a = (1_B,f) \circ b\) 蘊含 \(a = b\)。
用 Catlab.jl 製作 wiring 圖 [software-000X]
- January 27, 2024
- Lîm Tsú-thuàn
用 Catlab.jl 製作 wiring 圖 [software-000X]
- January 27, 2024
- Lîm Tsú-thuàn
引用的程式庫
using Catlab.WiringDiagrams, Catlab.Graphics import Convex, SCS using Catlab.Theories
產生 wiring 圖的程式
A = Ob(FreeBiproductCategory, :A) g = (mcopy(A) ⊗ id(A)) ⋅ (id(A) ⊗ mmerge(A)) to_composejl(g)
g
是 monoidal category 的 morphism,to_composejl
會把它畫成 wiring diagram;也可以用 to_tikz
或是 to_graphviz
來畫。
要是想匯出到 latex 檔案中使用,可以參考下面的程式產生 tikz 程式。
import Catlab.Graphics: TikZ to_tikz(g) |> TikZ.pprint
什麼是編譯器? [cs-000Z]
- January 2, 2024
- Lîm Tsú-thuàn
什麼是編譯器? [cs-000Z]
- January 2, 2024
- Lîm Tsú-thuàn
要回答這個問題,就要先知道什麼是程式語言,然後我們才能在這個基礎上解釋編譯器的目的與定義。
程式語言是什麼? [cs-0010]
- January 2, 2024
- Lîm Tsú-thuàn
程式語言是什麼? [cs-0010]
- January 2, 2024
- Lîm Tsú-thuàn
一個程式語言必然是有語法,是有限語法規則構成的一種形式系統,與用作推理基礎的邏輯系統不同的是
- 一般不介意規則上的重複,同一個計算與多個規則對應非常的常見。例如迴圈與遞迴具有完全一樣的能力 (對應 PCF 的 \(\mu \)),但 racket 語言兩者皆有提供。
- 通常刻意追求可計算性 (也就是不一致),不過程式語言也可以不具備可計算性。
不具備計算規則的程式語言 [cs-0016]
- January 2, 2024
- Lîm Tsú-thuàn
不具備計算規則的程式語言 [cs-0016]
- January 2, 2024
- Lîm Tsú-thuàn
例如 XML 或是 JSON 等純標記語言就是刻意不設計對應的計算系統的。
有計算規則的程式語言 [cs-001A]
- January 2, 2024
- Lîm Tsú-thuàn
有計算規則的程式語言 [cs-001A]
- January 2, 2024
- Lîm Tsú-thuàn
以有計算規則為前提,則一個程式語言一般會有操作語意與指稱語意兩種描述方式。定位上,操作語意通常是實作程式語言時會參考的一組演繹規則,寫成相繼式,如
\[ \frac { \Gamma \vdash A \Downarrow u, B \Downarrow v }{ \Gamma \vdash A + B \Downarrow u + v } \]指稱語意是找出一組數學物件,並證明自己完全抽象了操作語意 (也就是滿足充分性定理),用來推理程式語言的行為的一個模型。細節在遞迴的表示一文中有描述,數學記號 \(\mathcal {C}\llbracket e \rrbracket \) 就是在描述一個接受語法,回傳相應的數學物件的指稱語意函數。另外可以進一步參考 Gunter 的書。
此外,有一些具有計算規則,但不要求要有通用計算性的語言,這一類語言通常被稱為宣告式。
宣告式的程式語言 [cs-0017]
- January 2, 2024
- Lîm Tsú-thuàn
宣告式的程式語言 [cs-0017]
- January 2, 2024
- Lîm Tsú-thuàn
HTML、css 在瀏覽器底下具有計算意義,用來產生對應的畫面。還有 Prolog 與 SQL 等語言,一般都只是宣告所謂的 query,並讓一些特定的求解系統自己計算答案。這層意義下 computer algebra system 或是 z3 這種 logic solver 都算是程式語言。
所以語法規則這部分的形式系統對程式語言來說必須存在,但描述計算的形式系統對則不是必要的,研究具有計算規則的程式語言對應的。
編譯器的角色 [cs-0011]
- January 2, 2024
- Lîm Tsú-thuàn
編譯器的角色 [cs-0011]
- January 2, 2024
- Lîm Tsú-thuàn
所以,編譯器其實只在語法規則與計算規則都有規範的程式語言上有意義,編譯器的意義是把目前程式語言的語法重新寫成目標語言的語法,所以讀者很可能聽過重寫系統這個說法。
硬體實現的計算系統 [cs-0012]
- January 2, 2024
- Lîm Tsú-thuàn
硬體實現的計算系統 [cs-0012]
- January 2, 2024
- Lîm Tsú-thuàn
電腦事實上是一種計算系統的物理案例,我們用電路把某種通用計算系統實現出來,用電訊號表示計算系統的計算結果。CPU 讀取指令進行相應電訊號發射,並將結果儲存在特定位置,這基本上就是現代電腦的運作機制。
組合語言與組譯器 assembly [cs-0013]
- January 2, 2024
- Lîm Tsú-thuàn
組合語言與組譯器 assembly [cs-0013]
- January 2, 2024
- Lîm Tsú-thuàn
但指令需要編碼才能被 CPU 讀取,因此會有一系列的數字與對應的指令,組合語言則是為了讓人類可以閱讀這些指令而設計的編碼,組譯器因此基本上只要直接把指令文字變成一連串數字即可!因此,可以看出組合語言確實是一種程式語言,而組譯器是最簡單的把語法變成數字語法的重寫系統,對應的計算系統則是電腦硬體執行的那個計算系統。
當然這省略了組譯器的模組化功能部分,不過這部分對理解組譯器的定位沒有什麼幫助。這部分是由被稱為 linker 的程式進行,把不同的物件檔連結起來,比較好的參考書籍有《Linker and Loader》
當然這時候有人會質疑,為什麼不要直接用數字指令,或是任意一種底層的可計算結構編寫計算就好呢?事實上,這種觀點等於在說他認為不需要有任何新的程式語言的發明,因為程式語言存在最主要的理由之一就是要賦予計算規則「好用的」語法規則,讓不同的開發者可以有效的用來溝通。現在,可以總結編譯器為,把程式語言重寫成另一種程式語言的系統!所以下面我們就有計算規則的這類程式語言,討論編譯器必須滿足哪些要求,與實現上的概覽。
Requirement. 不能改變計算語意 [cs-0014]
- January 2, 2024
- Lîm Tsú-thuàn
Requirement. 不能改變計算語意 [cs-0014]
- January 2, 2024
- Lîm Tsú-thuàn
也就是說如果一個語法 \(M\) 在當前的計算規則下應該得出 \(v\),那麼編譯之後得到的目標語法 \(M'\) 在目標計算系統裡面也應該算出 \(v\)。很不幸的是這件事通常沒這麼簡單,因為程式語言擁有的一些高級抽象很可能在組合語言這類語言裡面不存在,像 Bool
這種值在組合語言裡面常常就只是 \(0\) 與非 \(0\)。這導致我們本來就需要對這類抽象進行編碼,當涉及到連續記憶體配置時 (像是字串與陣列等),這件事就更難做對了。不過總之語意被改變一般被認為是一種編譯器的錯誤。
除了不改變語意,編譯器還需要達成一些額外的目標,其中一項就是根據資料盡可能的最佳化在目標計算系統上的執行速度、或是減少空間消耗等,不過第二項就我所知幾乎都是開發者的工作。
常見的最佳化策略 [cs-0015]
- January 2, 2024
- Lîm Tsú-thuàn
常見的最佳化策略 [cs-0015]
- January 2, 2024
- Lîm Tsú-thuàn
- 常數傳播與共通子運算式:這是一種簡單的靜態分析,主要想法就是通過代數約束找出已經計算過的資料,並盡量減少重複利用已經有的運算結果。
- 指令選擇:有些計算可以用不同指令組合達成,但某些計算組合比其他更快。
- 暫存器 (register) 分配:由於 CPU 操作 register 比讀取記憶體更快速,所以盡量把變數放在 register 可以減少執行時間。
- 表達式樹平衡:如果一個表達式的樹主要構成是二元計算指令,這時把樹調整成更平衡的形式再配置指令會加速,因為可以減少資料依賴、使用更多的 register。
- 迴圈常數倍展開:由於快取的關係,一次進行 4 或是 8 個計算會比再次載入執行更快。
- 多面體編譯:把資料相依性記錄成 lattice,幫沒有資料衝突的計算安排用不同的 CPU core 執行,跟迴圈與共通運算式的想法其實是類似的。
找出程式的錯誤 [cs-0018]
- January 2, 2024
- Lîm Tsú-thuàn
找出程式的錯誤 [cs-0018]
- January 2, 2024
- Lîm Tsú-thuàn
讀者現在應該了解編譯器的存在目的與一點點形式化的背景,可以進一步學習指稱語意或是最佳化策略來了解程式語言的各種面向,此外,可計算程式語言一般還需要能與環境互動,這部分本身就有相當的複雜性,或許未來能夠再寫一篇文章介紹。
方便的 CLI 軟體 [software-000R]
- December 28, 2023
- Lîm Tsú-thuàn
方便的 CLI 軟體 [software-000R]
- December 28, 2023
- Lîm Tsú-thuàn
Zoxide [software-000N]
- December 15, 2023
- Lîm Tsú-thuàn
- https://github.com/ajeetdsouza/zoxide
Zoxide [software-000N]
- December 15, 2023
- Lîm Tsú-thuàn
- https://github.com/ajeetdsouza/zoxide
Remark. [#299]
- December 15, 2023
- Lîm Tsú-thuàn
Remark. [#299]
- December 15, 2023
- Lîm Tsú-thuàn
zoxide 這個軟體讓我們用簡短的縮寫跳轉到曾經去過的目錄
This is a smarter cd
command. When I do z xxx
, it would bring me to the most frequently used directory with "xxx" in the name. More you use it, it would get more accurated.
Atuin [software-000Q]
- December 15, 2023
- Lîm Tsú-thuàn
- https://atuin.sh
Atuin [software-000Q]
- December 15, 2023
- Lîm Tsú-thuàn
- https://atuin.sh
atuin 紀錄 CLI history,互動操作更方便而且可以跨電腦同步指令
atuin
gives better interactive interface to do command history search, once you found a target, use
-
<tab>
to back to shell and edit the command; and -
<enter>
to execute the command directly.
There is a post teach you to use self hosted sync server.
Sd [software-000T]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/chmln/sd
Sd [software-000T]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/chmln/sd
sd
替換sed
指令
Intuitive find & replace CLI (sed alternative).
Ast-grep [software-000V]
- December 31, 2023
- Lîm Tsú-thuàn
- https://ast-grep.github.io/
- https://github.com/ast-grep/ast-grep
Ast-grep [software-000V]
- December 31, 2023
- Lîm Tsú-thuàn
- https://ast-grep.github.io/
- https://github.com/ast-grep/ast-grep
sg
指令用語法而不是文字搜尋,對程式碼進行搜尋的效果會更好
A CLI tool for code structural search, lint and rewriting.
Croc [software-000P]
- December 15, 2023
- https://github.com/schollz/croc
Croc [software-000P]
- December 15, 2023
- https://github.com/schollz/croc
The tool send files from one computer to another securely.
croc 可以處理像是 keys 遷移這類問題
Migrate gpg keys to new machine [software-000O]
- December 15, 2023
- Lîm Tsú-thuàn
Migrate gpg keys to new machine [software-000O]
- December 15, 2023
- Lîm Tsú-thuàn
gpg -a --export > publickeys.asc gpg -a --export-secret-keys > privatekeys.asc gpg --export-ownertrust > trust.txt
Then use tools e.g. croc to transfer files. Apply below commands in new machine
gpg --import publickeys.asc gpg --import privatekeys.asc gpg -K gpg -k gpg --import-ownertrust trust.txt
Now your gpg is migrated.
為什麼需要 domain theory?遞迴的數學表示 [math-003Z]
- December 9, 2023
- Lîm Tsú-thuàn
為什麼需要 domain theory?遞迴的數學表示 [math-003Z]
- December 9, 2023
- Lîm Tsú-thuàn
一般的 OCaml 函數可以寫成
let f x y z = ...
一個直覺的想法是:每個型別都解釋成一個可數集合,該型別的 term 解釋成這個集合的元素。但有些函數會用到自己本身,例如整數階乘函數
let rec fac n = if n = 0 then 1 else n * fac(n-1)
它的值是什麼呢?答案是
\[ \mu (x : int \to int). \lambda (n : int). \begin {aligned} \begin {cases} 1 &\quad &(n = 0) \\ n \times x(n-1) &\quad &(n \ne 0) \end {cases} \end {aligned} \]\(\mu \) 中的 \(x\) 就是 fac
自己,把原始 OCaml 程式中的 fac
換成 \(x\) 即可。問題是集合論沒有辦法充分解釋這個運算,具體來說,集合解釋不滿足 PCF 的 Adequacy theorem。
Theorem. Adequacy (充分性定理) [math-0044]
- December 9, 2023
- Lîm Tsú-thuàn
Theorem. Adequacy (充分性定理) [math-0044]
- December 9, 2023
- Lîm Tsú-thuàn
If \(M\) is closed term of ground type and \(\mathcal {C}\llbracket M \rrbracket = \mathcal {C}\llbracket V \rrbracket \) for a value \(V\), then \(M \Downarrow V\).
對一個形式系統來說,一個 model 需要證明自己能充分的表現系統的特徵,所以才需要證明這個定理。
一般來說,只考慮構造與操作規則的話,可以記成下面這樣
Definition. Rules of \(\mu \) [math-0040]
- December 9, 2023
- Lîm Tsú-thuàn
Definition. Rules of \(\mu \) [math-0040]
- December 9, 2023
- Lîm Tsú-thuàn
Typing [#264]
- December 9, 2023
- Lîm Tsú-thuàn
Typing [#264]
- December 9, 2023
- Lîm Tsú-thuàn
Operational (Big step) [#265]
- December 9, 2023
- Lîm Tsú-thuàn
Operational (Big step) [#265]
- December 9, 2023
- Lîm Tsú-thuàn
但我們想要知道在數學上可以用什麼物件表示運算子 \(\mu \),也就是指稱語意 (denotational semantic),我先定義一個這個目標需要達成的等式。
基本的約束 [math-0041]
- December 9, 2023
- Lîm Tsú-thuàn
基本的約束 [math-0041]
- December 9, 2023
- Lîm Tsú-thuàn
解釋 (interpretation)
\[\llbracket \Gamma \triangleright \mu (x:t). M : t \rrbracket \rho \]必須是一個能滿足下面等式的 \(\llbracket t \rrbracket \) 元素 \(d\)
\[d = \llbracket \Gamma , x:t \triangleright M : t \rrbracket (\rho [x \mapsto d])\]註:\(\rho \) 在後面講到語意解釋時會定義
問題是我們怎麼知道存在這麼一個元素呢?由於不動點定理,使得我們有動機把 \(\llbracket t \rrbracket \) 解釋成 cpo,把計算解釋成 monotone function 再套用不動點定理。從而得到一個合理的定義:least fixed point 即是 \(\mu \) 的表示物件。
Definition. \(\mathcal {C}\llbracket e \rrbracket \) 的解釋 [math-0043]
- December 9, 2023
- Lîm Tsú-thuàn
Definition. \(\mathcal {C}\llbracket e \rrbracket \) 的解釋 [math-0043]
- December 9, 2023
- Lîm Tsú-thuàn
Notation. [#619]
- December 9, 2023
- Lîm Tsú-thuàn
Notation. [#619]
- December 9, 2023
- Lîm Tsú-thuàn
這裡採用 \(x \mapsto v\) 表示數學中的函數,\(x\) 是輸入 \(v\) 是輸出;但 \(\rho [x \mapsto d]\) 則是指 \(\rho \) 中的 \(x\) 被替換成 \(d\)
在開始之前我們需要大概了解 \(\mathcal {C}\llbracket x \rrbracket \) 這個解釋的定義。
- 當 \(t\) 是型別,則 \(\mathcal {C}\llbracket t \rrbracket \) 是一個 cpo
- 當 \(s, t\) 是型別,則 \(\mathcal {C}\llbracket s \to t \rrbracket \) 是一個連續函數,domain 是 \(\mathcal {C}\llbracket s \rrbracket \) 而 codomain 是 \(\mathcal {C}\llbracket t \rrbracket \)
- \(\rho \) 是一個 \(\Gamma \)-環境,幫每個 \(\Gamma \) 中的變數 \(x\) 定義一個 \(\rho (x) \in \mathcal {C}\llbracket \Gamma (x) \rrbracket \),\(\Gamma (x)\) 是一個型別
- \(\mathcal {C}\llbracket \Gamma \triangleright M : t \rrbracket \rho \in \mathcal {C}\llbracket t \rrbracket \),要解釋成三種情形
- \(\mathcal {C}\llbracket \Gamma \triangleright x : t \rrbracket \rho = \rho (x)\)
需要 \(\rho \) 函數的部分,當我們在程式語言中寫下
let f : T = M
時,就在 \(\rho \) 這個部分函數中加入了 \(f = M\) 的定義,注意到 \(\rho \) 是部分函數,因為也可能被問到未綁定的變數 \(z\),這時候 \(\rho (z) = \bot \) - \( \mathcal {C}\llbracket \Gamma \triangleright \lambda (x : s). M : s \to t \rrbracket \rho = (d \mapsto \mathcal {C}\llbracket \Gamma , x : s \triangleright M : t \rrbracket (\rho [x \mapsto d])) \)
把程式函數包裝成數學函數
- \( \mathcal {C}\llbracket \Gamma \triangleright M(N) : t \rrbracket \rho = (\mathcal {C}\llbracket \Gamma \triangleright M : s \to t \rrbracket \rho )(\mathcal {C}\llbracket \Gamma \triangleright N : s \rrbracket \rho ) \)
直接利用作為解釋的數學函數進行調用
- \(\mathcal {C}\llbracket \Gamma \triangleright x : t \rrbracket \rho = \rho (x)\)
Definition. \(\mu \) 的解釋結果 [math-0042]
- December 9, 2023
- Lîm Tsú-thuàn
Definition. \(\mu \) 的解釋結果 [math-0042]
- December 9, 2023
- Lîm Tsú-thuàn
\(\mu \) 本身的公式倒沒有很複雜
\[ \mathcal {C}\llbracket \Gamma \triangleright \mu (x:t). M : t \rrbracket \rho = \text {fix}(f) \]其中數學函數 \(f\) 是
\[ d \mapsto \mathcal {C}\llbracket \Gamma , x : t \triangleright M : t \rrbracket \rho [x \mapsto d] \]但我們怎麼確認 \(\text {fix}(f)\) 的存在?我們已經知道 \(\mathcal {C}\llbracket t \rrbracket \) 是 cpo。根據不動點定理我們知道只要再證明 \(f\) 是連續函數即可;接著根據下面的定理我們可以知道這能夠套用到任意來自 ground type 的 functional 上
Proposition. (cpo)-continuous function space is a cpo [math-0047]
- December 10, 2023
Proposition. (cpo)-continuous function space is a cpo [math-0047]
- December 10, 2023
If \(D\) and \(E\) are cpo, then the continuous function space
\[ [D \to E] = \{ f : D \to E \mid f \ \text {is continuous} \}\]is a cpo under the pointwise order.
再來就可以選擇 least fixed point 作為 \(\text {fix}(f)\) 的解釋
\[\bigsqcup _{n \in \omega }d_n\]其中
- \(d_0 = \bot _{\llbracket t \rrbracket }\)
- \(d_n = \mathcal {C}\llbracket \Gamma , x : t \triangleright M : t \rrbracket \rho [x \mapsto d_{n-1}]\)
不過這條鏈 \(d_n\) 不需要是唯一的,只要對任何一條都能這樣推理即可。
要證明函數 \(d \mapsto \mathcal {C}\llbracket \Gamma , x : t \triangleright M : t \rrbracket \rho [x \mapsto d]\) 對所有 \(\Gamma \)-環境 \(\rho \) 都成立有點麻煩,需要歸納所有的語法構造,所以這裡就跳過。或許哪天我會寫這部分,不過有興趣的讀者可以先參考 Gunter 的書的第四章,或是自己根據 PCF 這個 metalanguage 進行證明。Sterling 的演講 Synthetic Domains in the 21st Century 也是很好的資源。
Create quiver service with local k8s and docker compose [k8s-0001]
- December 4, 2023
- Lîm Tsú-thuàn
Create quiver service with local k8s and docker compose [k8s-0001]
- December 4, 2023
- Lîm Tsú-thuàn
quiver is a modern commutative diagram editor, and also is a proper small service to show what can we do with local k8s.
Notice that I do these with OrbStack, you will need to do proper modification to work on your computer, so this is not in introduction level.
As OrbStack's document, every running service can be connected via domain *.k8s.orb.local
. So here we are going to create docker image for quiver.
Create docker image for quiver [docker-0001]
- December 4, 2023
- Lîm Tsú-thuàn
Create docker image for quiver [docker-0001]
- December 4, 2023
- Lîm Tsú-thuàn
First, you clone quiver repository into the current directory, then write down Dockerfile
FROM python:3.11.2-slim-buster WORKDIR /app COPY quiver/src /app COPY app.py /app CMD [ "python3", "app.py" ]
The app.py
import http.server import socketserver PORT = 8000 handler = http.server.SimpleHTTPRequestHandler with socketserver.TCPServer(("", PORT), handler) as httpd: print("Server started at localhost:" + str(PORT)) httpd.serve_forever()
Then use command docker build . -t quiver-quiver:latest
to create a docker image.
Pod and service configuration [k8s-0002]
- December 4, 2023
- Lîm Tsú-thuàn
Pod and service configuration [k8s-0002]
- December 4, 2023
- Lîm Tsú-thuàn
Now, we need configuration for pod and service.
apiVersion: v1 kind: Pod metadata: name: quiver labels: app: quiver spec: containers: - name: quiver image: quiver-quiver:latest imagePullPolicy: Never ports: - containerPort: 8000 name: http-web-svc --- apiVersion: v1 kind: Service metadata: name: quiver-service spec: selector: app: quiver ports: - protocol: TCP port: 80 targetPort: http-web-svc type: LoadBalancer
We use they via command kubectl apply -f ./quiver.yml
.
Finally, you can go to http://k8s.orb.local and see you already run quiver tool on local machine. Other way is using traefik with docker compose, and goes to http://quiver.localhost.
使用 traefik 代理 [docker-0002]
- January 25, 2024
- Lîm Tsú-thuàn
使用 traefik 代理 [docker-0002]
- January 25, 2024
- Lîm Tsú-thuàn
在 docker compose 檔案的 services
底下加入下列的代理服務設定
traefik: image: "traefik:v2.10" container_name: "traefik" command: - "--api.insecure=true" - "--providers.docker=true" - "--providers.docker.exposedbydefault=false" - "--entrypoints.web.address=:80" ports: - "80:80" # Web UI - "8080:8080" volumes: - "/var/run/docker.sock:/var/run/docker.sock:ro"
並在實際的服務容器下加入 label 控制 traefik 的動作,就可以指定 DNS 域名了
labels: - "traefik.enable=true" - "traefik.http.routers.whoami.rule=Host(`xxx.localhost`)" - "traefik.http.routers.whoami.entrypoints=web"
Forester 介紹 [forester-0002]
- December 2, 2023
- Lîm Tsú-thuàn
Forester 介紹 [forester-0002]
- December 2, 2023
- Lîm Tsú-thuàn
又是新的筆記軟體?是要換幾種? [forester-0003]
- December 2, 2023
- Lîm Tsú-thuàn
又是新的筆記軟體?是要換幾種? [forester-0003]
- December 2, 2023
- Lîm Tsú-thuàn
市面上有越來越多的筆記軟體,而擁有發佈功能的也不少,也就是說當你寫好筆記時,就可以選擇是否要公開,這種方式非常好用,而且也不再需要擔心文章不能寫一半,這種模式下你的文章會隨著累積而自然組合出新的想法/成果。 在使用 Heptabase 一定時間之後,我對它也相當滿意,但隨著使用,我對能夠掌控細節的需要又開始出現,下面舉出我遇到的問題,以及未來的需求規劃,最終會談到如何在 forester 中實現。
我們需要已完成的軟體 [software-000L]
- December 2, 2023
- Lîm Tsú-thuàn
- https://josem.co/the-beauty-of-finished-software/
我們需要已完成的軟體 [software-000L]
- December 2, 2023
- Lîm Tsú-thuàn
- https://josem.co/the-beauty-of-finished-software/
已完成的軟體這種概念,是指一個軟體的功能已經沒有大幅度更動的必要,可以長期使用在產品上,而軟體本身只會進行必要的安全與移植性更新
外部連結是我讀到這個想法的地方對應到筆記軟體上,我不希望軟體一直更新,尤其是當我一打開工具需要寫筆記時,上面的更新按鈕非常的讓人煩躁。同時,這個想法也是一種解放我們原先對軟體想像的開端,比起軟體如何如何,更重要的是真的去做,外部連結裡面也談到冰與火之歌正是用這樣的軟體寫出。更多的想法可以參考公共程式與洪朝貴老師的盲人摸象看軟體。
白板只適合學習,不適合專家 [noting-0001]
- December 2, 2023
- Lîm Tsú-thuàn
白板只適合學習,不適合專家 [noting-0001]
- December 2, 2023
- Lîm Tsú-thuàn
白板在剛開始學習一個領域或是開發一個專案的時候非常的好用,但隨著技能與專案開始複雜化,白板的資訊就只是過多的無用資訊了。下圖是我的教學專案,一點編譯器入門就已經膨脹到這個程度,維護範疇論的白板經驗告訴我這是不可行的。當然,我知道白板的用途不是如此,問題是如果白板只是一種聯想用、暫時性的存在,那為何不直接用紙筆呢?
一個筆記軟體應該做到什麼? [noting-0002]
- December 2, 2023
- Lîm Tsú-thuàn
一個筆記軟體應該做到什麼? [noting-0002]
- December 2, 2023
- Lîm Tsú-thuàn
一個好的筆記軟體應該要能夠
- 可以隨手記錄雜散的想法,所以要有手機版本
- 只讓成熟的想法公開,所以需要廢紙簍,在改寫之後才移到公開區
- 核心的概念已完成
下面我們就來談,forester 滿足與不滿足哪些要件。
Forester 的特性 [forester-0004]
- December 2, 2023
- Lîm Tsú-thuàn
Forester 的特性 [forester-0004]
- December 2, 2023
- Lîm Tsú-thuàn
forester 是一個精簡、hack 的工具,也就是說目前尚未有穩定的結果,我已經經歷過幾次大規模的更動,萬幸的是
- forester 是開源工具,你可以選擇停留在某個版本不再跟上,或是基於任何一點自行維護後續
- 目前的更動都是為了更符合核心理念,而不是為了增加非必要的功能
Forester 的不完美之處 [forester-0008]
- December 2, 2023
- Lîm Tsú-thuàn
Forester 的不完美之處 [forester-0008]
- December 2, 2023
- Lîm Tsú-thuàn
正如前面所說,forester 的更新是為了更符合核心想法,所以在已完成這點上,是合格的。除此之外,forester 可以使用
\tex{\latex-preamble/xxx}{...}
來使用任何你有興趣的 xxx.sty
(把 .sty
原始碼封裝到變數 \latex-preamble/xxx
中),因此生態成熟度相當高(latex 生態系),這點的直接成果就是可以使用 tikz 繪圖工具,下面是兩個案例。
Example. Category of span [math-001W]
- October 28, 2023
- Lîm Tsú-thuàn
Example. Category of span [math-001W]
- October 28, 2023
- Lîm Tsú-thuàn
A span is a \(\mathcal {C}\)-diagram \(A \leftarrow C \rightarrow B\), there is a category of span with fixed \(\mathbb {C}\)-objects \(A, B\) is:
- objects: \(A \leftarrow C \rightarrow B\)
- morphisms: given by the below diagram, the red-colored morphism \(h\)
Example. Monad [math-00D8]
- September 5, 2024
- Lîm Tsú-thuàn
Example. Monad [math-00D8]
- September 5, 2024
- Lîm Tsú-thuàn
monad 是一個 endofunctor,所以必然跟某個範疇 \(C\) 有關,具有 \(M : C \to C\) 的簽名。並且,有兩個 natural transformation
- \(\eta : 1_C \to M\)
- \(\mu : M \circ M \to M\)
並滿足 monoid 條件。第一是 \(\mu \cdot (\eta \circ M) = id = \mu \cdot (M \circ \eta )\)
第二是 \(\mu \cdot (\mu \circ M) = \mu \cdot (M \circ \mu )\)
因此我們才說 monad 是 endofunctors 構成的 category 中的一個 monoid object。
此外 RSS 是每個頁面都會有一個。在學術上,forester 也有針對 reference 的卡片分類,這裡引入一張卡片展示這個功能:
Example. Elements of ∞-Category Theory [riehl-verity2022]
- 2022
- Emily Riehl, Dominic Verity
- 10.1017/9781108936880
Example. Elements of ∞-Category Theory [riehl-verity2022]
- 2022
- Emily Riehl, Dominic Verity
- 10.1017/9781108936880
The language of ∞-categories provides an insightful new way of expressing many results in higher-dimensional mathematics but can be challenging for the uninitiated. To explain what exactly an ∞-category is requires various technical models, raising the question of how they might be compared. To overcome this, a model-independent approach is desired, so that theorems proven with any model would apply to them all. This text develops the theory of ∞-categories from first principles in a model-independent fashion using the axiomatic framework of an ∞-cosmos, the universe in which ∞-categories live as objects. An ∞-cosmos is a fertile setting for the formal category theory of ∞-categories, and in this way the foundational proofs in ∞-category theory closely resemble the classical foundations of ordinary category theory. Equipped with exercises and appendices with background material, this first introduction is meant for students and researchers who have a strong foundation in classical 1-category theory.
@book{riehl_verity_2022, place={Cambridge}, series={Cambridge Studies in Advanced Mathematics}, title={Elements of ∞-Category Theory}, DOI={10.1017/9781108936880}, publisher={Cambridge University Press}, author={Riehl, Emily and Verity, Dominic}, year={2022}, collection={Cambridge Studies in Advanced Mathematics} }
怎麼安裝 forester? [forester-0005]
- December 2, 2023
- Lîm Tsú-thuàn
怎麼安裝 forester? [forester-0005]
- December 2, 2023
- Lîm Tsú-thuàn
我個人使用的安裝方式是從原始碼編譯(用 nix 管理),因為我會參與開發跟使用最新功能,但這個辦法對沒有那麼想折騰的人來說可能不是那麼理想,這時候可以選擇用 opam install forester
直接使用 opam 上註冊的最新版本。如果你也想要直接用原始碼的話,那麼進入專案之後執行 opam pin add -y .
即可,往後更新只需要執行下列的指令就可以完成。
git pull opam update opam upgrade
此外 changelog 頁面也值得關注,具體的概念跟使用應該去這邊學習。如果你熟悉 nix 的話也可以用我做的 template 專案當起點。
記錄專案歷程的案例 [forester-0006]
- December 2, 2023
- Lîm Tsú-thuàn
記錄專案歷程的案例 [forester-0006]
- December 2, 2023
- Lîm Tsú-thuàn
forester 具有很強的自由度,這也是我寫這段的理由:展示用法的多樣化。我這裡所談的管理方式或許對你來說沒有必要,這是我為什麼現在才談這件事。在我目前對筆記軟體使用上的最後一哩路是專案時程紀錄,因為一個大型的專案會涉及到長期追蹤,在時程安排上,我目前使用的是 orgmode 跟 Heptabase。由於提醒事項這個功能 forester 沒有也不會提供這類功能,所以我不會討論這部分,而且也不需要,我未來會只用 orgmode 紀錄警急需求,而專案則記錄在 forester 上。因此,這裡要談個人專案管理需要什麼。由於 forester 也有 backlink,因此我們可以考慮在每日頁面裡面提及某個事項,比如軟體專案中的某個功能是在這一日進行。並且在專案中建立兩個 scope transclude
\scope{ \put\transclude/title{working} \put\transclude/expanded{true} \query{ \open\query \isect{\tag{project-xxx}}{\tag{TODO}} } } \scope{ \put\transclude/title{complete} \put\transclude/expanded{true} \query{ \open\query \isect{\tag{project-xxx}}{\tag{DONE}} } }
上面的 scope transclude 表示當有 project-xxx
與 TODO
這兩個 tag 時視為事項正在進行,下面表示事項已完成。而我只會在 DONE
的事項上面指定日期,因此我就知道是哪一天完成。但這也有一些缺點,比如我可能需要知道事項是什麼時候開始的,由於 forester 格式開放,因此我可以自行加上我需要的特殊閱讀工具,所以這些也是我在思考要怎麼加入 forester 或是有什麼額外工具可以做到的部分,因此在未來我或許可以談更多關於工作紀錄管理的細節,不過這一段就先到這裡吧。
Conclusion. 如何找到合適的工具 [forester-0007]
- December 2, 2023
- Lîm Tsú-thuàn
Conclusion. 如何找到合適的工具 [forester-0007]
- December 2, 2023
- Lîm Tsú-thuàn
我同意除了 latex 的超優秀支援,其他很多功能都是封閉軟體如我所使用的 Heptabase 可以做到的,所以結論要談為什麼這還是有嘗試的價值。
- forester 是開源的,這表示你有很多選擇:分叉做新的功能、回饋給維護者並知道開發進展、自己選什麼時候要更新
- 它按照相當精簡的規則運作,也就是說學習整套規則並不困難,並且相對容易判斷操作的結果
但在下判斷之前,也要了解到我是使用者也參與開發,所以我的判斷可能過於樂觀。因此我也推薦讀者要學習觀念而不是工具,並也考慮另一個或許不錯的替代品 AFFiNE。最後,就如在已完成中所述,你要真的有在寫筆記,這一切才會對你有意義。
如果有興趣使用,可以參照這篇教學來了解怎麼開始。
Definition. Boolean algebra [math-003I]
- November 29, 2023
- Lîm Tsú-thuàn
Definition. Boolean algebra [math-003I]
- November 29, 2023
- Lîm Tsú-thuàn
A Boolean algebra is a complemented distributive lattice.
Proposition. \({x^\mathsf {c}}^\mathsf {c} = x\) [math-003L]
- November 29, 2023
- Lîm Tsú-thuàn
Proposition. \({x^\mathsf {c}}^\mathsf {c} = x\) [math-003L]
- November 29, 2023
- Lîm Tsú-thuàn
In boolean algebra, the complement of complement of \(x\) is \(x\).
Proof. [#625]
- November 29, 2023
- Lîm Tsú-thuàn
Proof. [#625]
- November 29, 2023
- Lîm Tsú-thuàn
This is a direct result from at most one complement.
Proposition. \(x \sqcap y = 0\) if and only if \(y \sqsubseteq x^{\mathsf {c}}\) [math-003M]
- November 29, 2023
- Lîm Tsú-thuàn
Proposition. \(x \sqcap y = 0\) if and only if \(y \sqsubseteq x^{\mathsf {c}}\) [math-003M]
- November 29, 2023
- Lîm Tsú-thuàn
In boolean algebra, the problem can be expressed categorical: \(x \times y = 0\) iff \(y \to x^{\mathsf {c}}\).
Proof. [#624]
- November 29, 2023
- Lîm Tsú-thuàn
Proof. [#624]
- November 29, 2023
- Lîm Tsú-thuàn
We have product \(x \leftarrow 0 \rightarrow y\), and the \(y \to 1\) (terminal rule), but complement \(x^\mathsf {c}\) existed and \(x + y\) has no need to be \(1\), so somewhere between \(y \to 1\) has a \(x^\mathsf {c}\).
Proposition. \(x \sqsubseteq y\) if and only if \(y^\mathsf {c} \sqsubseteq x^\mathsf {c}\) [math-003N]
- November 29, 2023
- Lîm Tsú-thuàn
Proposition. \(x \sqsubseteq y\) if and only if \(y^\mathsf {c} \sqsubseteq x^\mathsf {c}\) [math-003N]
- November 29, 2023
- Lîm Tsú-thuàn
In boolean algebra, the problem can be expressed categorical: \(x \to y\) iff \(y^\mathsf {c} \to x^\mathsf {c}\).
Proof. [#623]
- November 29, 2023
- Lîm Tsú-thuàn
Proof. [#623]
- November 29, 2023
- Lîm Tsú-thuàn
By applying proposition: \(x \sqcap y = 0\) iff \(y \sqsubseteq x^{\mathsf {c}}\), with fact that \(x \to y\), we know \(y^\mathsf {c} \sqcap x = 0\)
Apply proposition again, we can see the goal existed.
Proposition. \((x \sqcap y)^\mathsf {c} = x^\mathsf {c} \sqcup y^\mathsf {c}\) [math-003O]
- November 29, 2023
- Lîm Tsú-thuàn
Proposition. \((x \sqcap y)^\mathsf {c} = x^\mathsf {c} \sqcup y^\mathsf {c}\) [math-003O]
- November 29, 2023
- Lîm Tsú-thuàn
In boolean algebra, we can rewrite it categorical: \((x \times y)^\mathsf {c} = x^\mathsf {c} + y^\mathsf {c}\).
Proof. [#622]
- November 29, 2023
- Lîm Tsú-thuàn
Proof. [#622]
- November 29, 2023
- Lîm Tsú-thuàn
By removing the thing we no need, we can see that \((x \times y)^\mathsf {c} = x^\mathsf {c} + y^\mathsf {c}\).
Proposition. \((x \sqcup y)^\mathsf {c} = x^\mathsf {c} \sqcap y^\mathsf {c}\) [math-003P]
- November 29, 2023
- Lîm Tsú-thuàn
Proposition. \((x \sqcup y)^\mathsf {c} = x^\mathsf {c} \sqcap y^\mathsf {c}\) [math-003P]
- November 29, 2023
- Lîm Tsú-thuàn
In boolean algebra, we can rewrite in categorical language: \((x + y)^\mathsf {c} = x^\mathsf {c} \times y^\mathsf {c}\).
Proof. [#621]
- November 29, 2023
- Lîm Tsú-thuàn
Proof. [#621]
- November 29, 2023
- Lîm Tsú-thuàn
Indexing boolean algebra [math-003J]
- February 16, 2022
- Lîm Tsú-thuàn
Indexing boolean algebra [math-003J]
- February 16, 2022
- Lîm Tsú-thuàn
Boolean algebra can be encoded by indexing, for example, a venn diagram for two sets \(A, B\) divide diagram to four parts: \(1, 2, 3, 4\). Thus
- \(A = \{1, 2\}\)
- \(B = \{1, 3\}\)
- \(A \cup B = \{1, 2, 3\}\)
- \(A \cap B = \{1\}\)
- \((A \cup B)^{\mathsf {c}} = \{4\}\)
The benefit of the encoding is the encoding let any sets can be treated as finite sets operation. So for any set check a boolean algebra is valid, indexing helps you check them by computer.
Encode to program [cs-000J]
- February 16, 2022
- Lîm Tsú-thuàn
Encode to program [cs-000J]
- February 16, 2022
- Lîm Tsú-thuàn
Here is the racket program.
(define I (set 1 2 3 4)) (define A (set 1 2)) (define B (set 1 3)) (define ∅ (set)) (define ∩ set-intersect) (define ∪ set-union) (define (not S) (set-subtract I S)) (define (→ A B) (∪ (not A) B)) (define (- A B) (∩ A (not B))) (define (≡ A B) (∪ (∩ A B) (∩ (not A) (not B))))
Checking based on encoding [cs-000K]
- February 16, 2022
- Lîm Tsú-thuàn
Checking based on encoding [cs-000K]
- February 16, 2022
- Lîm Tsú-thuàn
Now, you can check \(A \to B = (A - B)^{\mathsf {c}}\) by the following program.
(equal? (→ A B) (not (- A B)))
And you will know \((A \cap (A - B)^{\mathsf {c}}) = \emptyset \) is invalid since the following program returns false.
(equal? (∩ A (not (- A B))) ∅)
You can even extend this method for sets \(A, B, C\), for sets \(A, B, C, D\) and so on, but then that's too far for this article.
Theorem. Each element of distributive lattice has at most one complement [math-003K]
- November 29, 2023
- Lîm Tsú-thuàn
Theorem. Each element of distributive lattice has at most one complement [math-003K]
- November 29, 2023
- Lîm Tsú-thuàn
In a distributive lattice each element has at most one complement, which means \(y, z\) are complements of \(x\) implies \(y = z\).
Proof. [#626]
- November 29, 2023
- Lîm Tsú-thuàn
Proof. [#626]
- November 29, 2023
- Lîm Tsú-thuàn
The proof use category language, \(\sqcap \) (product) and \(\sqcup \) (coproduct).
Assuming there have two complements \(y, z\) for an element \(x\), then \(x + y = x + z = 1\) and \(x \times y = x \times z = 0\). By distributive law we have below diagram
Then we use \(x + y = x + z = 1\) to reduce it and get
Since there has at most one path, the diagram commute, hence \(y = z\).
Soundness 與 completeness [math-0032]
- November 27, 2023
- Lîm Tsú-thuàn
Soundness 與 completeness [math-0032]
- November 27, 2023
- Lîm Tsú-thuàn
為了了解 sound 與 complete 的比喻,我們需要觀察經典邏輯系統的 soundness 與 completeness 定理,因此我們先複習經典邏輯的公理與推導式
Definition. Classical logic [math-0035]
- November 27, 2023
- Lîm Tsú-thuàn
Definition. Classical logic [math-0035]
- November 27, 2023
- Lîm Tsú-thuàn
The twelve forms, where \(\alpha , \beta , \gamma \) denotes arbitrary sentences, are axioms of classical logic.
- \(\alpha \supset (\alpha \land \alpha )\)
- \((\alpha \land \beta ) \supset (\beta \land \alpha )\)
- \((\alpha \supset \beta ) \supset ((\alpha \land \gamma ) \supset (\beta \land \gamma ))\)
- \(((\alpha \supset \beta ) \land (\beta \supset \gamma )) \supset (\alpha \supset \gamma )\)
- \(\beta \supset (\alpha \supset \beta )\)
- \((\alpha \land (\alpha \supset \beta )) \supset \beta \)
- \(\alpha \supset (\alpha \lor \beta )\)
- \((\alpha \lor \beta ) \supset (\beta \lor \alpha )\)
- \(((\alpha \supset \gamma ) \land (\beta \supset \gamma )) \supset ((\alpha \lor \beta ) \supset \gamma )\)
- \(\sim \alpha \supset (\alpha \supset \beta )\)
- \(((\alpha \supset \beta ) \land (\alpha \supset \sim \beta )) \supset \sim \alpha \)
- \(\alpha \lor \sim \alpha \)
with single rule of inference.
Rule of Detachment [#260]
- November 27, 2023
- Lîm Tsú-thuàn
Rule of Detachment [#260]
- November 27, 2023
- Lîm Tsú-thuàn
From \(\alpha \) and \(\alpha \supset \beta \), the sentence \(\beta \) may be derived. Denote derivable formula \(\vdash _{cl} \alpha \), we can rewrite rule of detachment to \[ \frac { \vdash _{cl} \alpha \ \ \ \ \vdash _{cl} (\alpha \supset \beta ) }{ \vdash _{cl} \beta } \]
有了推導規則 Rule of Detachment,經典邏輯系統的 soundness 與 completeness 定理表示
Theorem. Classical logic's soundness [math-0033]
- November 27, 2023
- Lîm Tsú-thuàn
Theorem. Classical logic's soundness [math-0033]
- November 27, 2023
- Lîm Tsú-thuàn
If \(\vdash _{cl} \alpha \), then \(\alpha \) is classically valid.
Theorem. Classical logic's completeness [math-0034]
- November 27, 2023
- Lîm Tsú-thuàn
Theorem. Classical logic's completeness [math-0034]
- November 27, 2023
- Lîm Tsú-thuàn
If \(\alpha \) is classically valid, then \(\vdash _{cl} \alpha \).
這兩個定理也因此可以推廣到更多的系統中,比如靜態分析中的比喻
Example. 靜態分析中的 sound 與 complete [cs-000I]
- November 27, 2023
- Lîm Tsú-thuàn
Example. 靜態分析中的 sound 與 complete [cs-000I]
- November 27, 2023
- Lîm Tsú-thuàn
若是將比喻套進靜態分析中,便可以發現 sound 是「發現的錯誤都是真的」,也就是系統不會誤報;而 complete 則表示「所有的錯誤都會被系統找到」,也就是不會遺漏錯誤。但要記得這兩者在靜態分析中通常無法同時達成,而且兩者的極端都會產生沒用的系統。比如對所有程式都會檢測出錯誤那絕對有滿足 complete,但也肯定是沒用的系統;而滿足 sound 的系統則往往透露太少錯誤,而且這類錯誤通常開發人員也很容易自己發現,因此也不實用。因此靜態分析與證明系統發展上的差異,就是靜態分析需要在 sound 跟 complete 這些屬性裡面取得平衡。
Conclusion. 如何使用 soundness 與 completeness [math-0036]
- November 27, 2023
- Lîm Tsú-thuàn
Conclusion. 如何使用 soundness 與 completeness [math-0036]
- November 27, 2023
- Lîm Tsú-thuàn
因此可以發現,要用 soundness 與 completeness 時,只要關心特定屬性 \(p\),我們說一個系統 sound 就是在問「能導出的結果是否滿足 \(p\)」;我們說一個系統 complete 則是在問「滿足 \(p\) 的結果是否皆能導出」。
Theorem. A space is Hausdorff iff its diagonal map is closed [math-002Z]
- November 23, 2023
- Lîm Tsú-thuàn
Theorem. A space is Hausdorff iff its diagonal map is closed [math-002Z]
- November 23, 2023
- Lîm Tsú-thuàn
The proposition says a space is Hausdorff if and only if its diagonal map \(\Delta : X \to X \times X\) to product space is closed, which given an alternative definition. Notice that close means its complement \(\Delta ^\mathsf {c}\) is open. The definition of \(\Delta \) is
\[ \Delta = \{ (x, x) \mid x \in X \} \]
Remark. [#633]
- November 23, 2023
- Lîm Tsú-thuàn
Remark. [#633]
- November 23, 2023
- Lîm Tsú-thuàn
Not hard to see below argument also applies to all finite \(X\)-product spaces.
Proof. [#634]
- November 23, 2023
- Lîm Tsú-thuàn
Proof. [#634]
- November 23, 2023
- Lîm Tsú-thuàn
The first direction is Hausdorff implies diagonal map is closed. Hausdorff means every two different points has a pair of disjoint neighborhoods \((U \in \mathcal {N}_x, V \in \mathcal {N}_y)\), where \(x \in U\) and \(y \in V\). therefore, every pair \((x, y)\) not line on the diagonal has \(U \times V\) cover them. The union of all these open sets \(U \times V\) indeed covers \(\Delta ^\mathsf {c}\), so the complement \(\Delta \) is closed.
The second direction is diagonal map is closed implies Hausdorff. Since
\[\Delta ^\mathsf {c} = \{(x, y) \mid x, y \in X (x \ne y) \}\]is open, which implies for all \(x, y\) the pair \((x, y) \in \Delta ^\mathsf {c}\). Since \(\mathcal {N}_{(x, y)} = \mathcal {N}_x \times \mathcal {N}_y\), this implies the fact that \(\Delta ^\mathsf {c} \in \mathcal {N}_x \times \mathcal {N}_y\).
Also, for all \(U \in \mathcal {N}_x\) and \(V \in \mathcal {N}_y\), it's natural that \(U \times V \subseteq \Delta ^\mathsf {c}\), since the open set \(U \times V\) at most cover \(\Delta ^\mathsf {c}\).
Consider that reversely again, that means for all \((x, x) \in \Delta \), pair \((x, x) \notin U \times V\) (i.e. \(U \times V\) will not cover any part of diagonal), that implies \(U \cap V = \varnothing \) as desired.
Understanding \(F\)-algebra [math-001K]
- October 24, 2023
- Lîm Tsú-thuàn
Understanding \(F\)-algebra [math-001K]
- October 24, 2023
- Lîm Tsú-thuàn
To understand \(F\)-algebra, we will need some observations, the first one is we can summarize an algebra with a signature. For example, monoid has a signature:
\[ \begin {cases} 1 : 1 \to m \\ \cdot : m \times m \to m \end {cases} \]or we can say ring is:
\[ \begin {cases} 0 : 1 \to m \\ 1 : 1 \to m \\ + : m \times m \to m \\ \times : m \times m \to m \\ - : m \to m \end {cases} \]The next observation is we can consider these \(m\) as objects in a proper category \(C\), at here is a cartesian closed category. For example
- monoid is a \(C\)-morphism \(1 + m \times m \to m\)
- ring is a \(C\)-morphism \(1 + 1 + m \times m + m \times m + m \to m\)
Now, we generalize algebra's definition.
Definition. \(F\)-algebra (algebra for an endofunctor) [math-001L]
- October 24, 2023
- Lîm Tsú-thuàn
Definition. \(F\)-algebra (algebra for an endofunctor) [math-001L]
- October 24, 2023
- Lîm Tsú-thuàn
With a proper category \(C\) which can encode the signature of \(F(-)\), and an endofunctor \(F : C \to C\), the \(F\)-algebra is a triple: \[(F, x, \alpha )\] where \(\alpha : F \; x \to x\) is a \(C\)-morphism.
With the definition of \(F\)-algebra, we wondering if \(F\)-algebras of a fixed \(F\) form a category, and the answer is yes.
Definition. Category of \(F\)-algebras [math-001M]
- October 24, 2023
- Lîm Tsú-thuàn
Definition. Category of \(F\)-algebras [math-001M]
- October 24, 2023
- Lîm Tsú-thuàn
For a fixed endofunctor \(F\) in a proper category \(C\) (below notations omit fixed \(F\)),
- the F-algebras \((x, \alpha )\) form the objects of the category,
- morphisms are homomorphisms of objects \((x, \alpha ) \xrightarrow {F\;m} (y, \beta )\), composition is given by functor laws.
We can extra check identity indeed works.
There is a theorem about the initial object of the category.
Theorem. Lambek's [math-001N]
- October 24, 2023
- Lîm Tsú-thuàn
Theorem. Lambek's [math-001N]
- October 24, 2023
- Lîm Tsú-thuàn
The evaluator \(j\) of an initial algebra \((F, i, j)\) is an isomorphism.
Proof. [#647]
- October 24, 2023
- Lîm Tsú-thuàn
Proof. [#647]
- October 24, 2023
- Lîm Tsú-thuàn
Let \(F\;i\) be an initial in the \(F\)-algebra category, the following diagram commutes for any \(C\)-object \(a\)
Now, replace \(a\) with \(F\;i\), we have commute diagram
Then we consider a trivial commute diagram by duplicating the path \(F\;i \to i\)
Combine two diagrams, then we get another commute diagram
By definition now we know \(j \circ m\) is a homomorphism, and since \(F\;i\) is an initial, we must have \[F\;j \circ F\;m = 1_{Fi}\]
Therefore, we also have \[j \circ m = 1_i\] so \(m\) is the inverse of \(j\), proves \(j\) is an isomorphism.
Catamorphism [math-001P]
- October 24, 2023
- Lîm Tsú-thuàn
Catamorphism [math-001P]
- October 24, 2023
- Lîm Tsú-thuàn
The theorem actually proves the corresponding \(C\)-object \(i\) of initial algebra \((F, i, j)\) is a fixed point of \(F\). By reversing \(j\) with its inverse, we get a commute diagram below.
In Haskell, we are able to define initial algebra
newtype Fix f = Fix (f (Fix f)) unFix :: Fix f -> f (Fix f) unFix (Fix x) = x
View \(j\) as constructor Fix
, \(j^{-1}\) as unFix
, then we can define m = alg . fmap m . unFix
. Since m :: Fix f -> a
, we have definition of catamorphism.
cata :: Functor f => (f a -> a) -> Fix f -> a cata alg = alg . fmap (cata alg) . unFix
An usual example is foldr
, a convenient specialization of catamorphism.
Anamorphism [math-001Q]
- October 24, 2023
- Lîm Tsú-thuàn
Anamorphism [math-001Q]
- October 24, 2023
- Lîm Tsú-thuàn
As a dual concept, we can draw coalgebra diagram
and define anamorphism as well.
ana :: Functor f => (a -> f a) -> a -> Fix f ana coalg = Fix . fmap (ana coalg) . coalg
Conclusion. [#273]
- October 24, 2023
- Lîm Tsú-thuàn
Conclusion. [#273]
- October 24, 2023
- Lîm Tsú-thuàn
I mostly learn F-algebras from Category Theory for Programmers, and take a while to express the core idea in details with my voice with a lot practicing. The article answered some questions, but we always with more. What's an algebra of monad? What's an algebra of a programming language (usually has a recursive syntax tree)? Hope you also understand it well through the article and practicing.
什麼是 Lawvere's fixed point theorem [math-0012]
- October 11, 2023
- Lîm Tsú-thuàn
什麼是 Lawvere's fixed point theorem [math-0012]
- October 11, 2023
- Lîm Tsú-thuàn
這篇文章介紹了 Lawvere's fixed point theorem 的定義與應用
Theorem. Lawvere's fixed point [math-0013]
- October 11, 2023
- Lîm Tsú-thuàn
- http://tac.mta.ca/tac/reprints/articles/15/tr15.pdf
Theorem. Lawvere's fixed point [math-0013]
- October 11, 2023
- Lîm Tsú-thuàn
- http://tac.mta.ca/tac/reprints/articles/15/tr15.pdf
在一個 cartesian closed category 中,如果 \(A \xrightarrow {\phi } B^A\) 是 point-surjective,則所有 \(B \xrightarrow {f} B\) 都存在不動點 \(1 \xrightarrow {s} B\)(滿足 \(f \circ s = s\))。
Proof. [#656]
- October 11, 2023
- Lîm Tsú-thuàn
Proof. [#656]
- October 11, 2023
- Lîm Tsú-thuàn
首先畫出交換圖
其中 \(\delta \) 的定義是 \(c \mapsto \langle c, c \rangle \),所以對 \(1 \xrightarrow {p} A\) 來說 \(\delta \circ p = \langle p, p \rangle \)。沿著這個定義,我們知道 \((\phi \times 1_A) \circ \delta \circ p = \langle \phi \circ p, p\rangle \)。根據 point-surjective 我們知道 \(\phi \circ p\) 對每個 \(p\) 來說都是唯一確定的。現在把往下方 \(B\) 的 \(ev\) 也畫出,即可得出等式:
\[f \circ ev \circ \langle \phi \circ p, p\rangle = ev \circ \langle \phi \circ p, p\rangle \]換句話說 \(B \xrightarrow {f} B\) 的不動點即是
\[ev \circ \langle \phi \circ p, p\rangle \]
Example. 應用到 lambda calculus [math-001S]
- October 26, 2023
- Lîm Tsú-thuàn
Example. 應用到 lambda calculus [math-001S]
- October 26, 2023
- Lîm Tsú-thuàn
編碼的方式是找一個只有兩個物件 \(1, T\) 的 category \(M\),讓 lambda calculus 的 terms 是 \(M\)-morphisms,這些技巧在 categorical semantic 領域內相當常見。
到這裡必須檢查 lambda calculus 確實存在 point-surjective,歡迎自行嘗試。按此編碼後可以得到 \(ev \circ \langle \phi \circ p, p\rangle \xrightarrow {encode} \phi (p)(p)\)。套到等式上 \[f \circ ev \circ \langle \phi \circ p, p\rangle = ev \circ \langle \phi \circ p, p\rangle \] 可以得到以下編碼 \[f(\phi (p)(p)) = \phi (p)(p)\] 把 \(\phi (p)\) 改寫成 \(q\),於是等式可以寫成 \(q(p) = f(\phi (p)(p))\),而函數套用語法可以用 \(\lambda \) 退化,於是得到 \[q = \lambda x. f(\phi (x)(x))\]
注意到 \(q\) 的定義是非遞迴的,因此一定是可定義的。
計算即可發現確實 \(q(p) = \phi (p)(p) = f(\phi (p)(p))\)。因為所有的 \(\lambda \)-term 都屬於 \(T\),所以現在我們知道任何 lambda calculus 的函數都有不動點。
Example. 應用到 Cantor's theorem [math-0016]
- October 11, 2023
- Lîm Tsú-thuàn
Example. 應用到 Cantor's theorem [math-0016]
- October 11, 2023
- Lîm Tsú-thuàn
取 category \(\bold {Sets}\) 並令 \(B = 2\) 就可以證明 Cantor's theorem。我們需要引理
Lemma. No point-surjective morphism [math-0017]
- October 11, 2023
- Lîm Tsú-thuàn
Lemma. No point-surjective morphism [math-0017]
- October 11, 2023
- Lîm Tsú-thuàn
If there exists \(B \xrightarrow {f} B\) such that \(f \circ b \ne b\) for all \(1 \xrightarrow {b} B\), then there has no point-surjective morphism can exist for \(A \xrightarrow {g} B^A\).
This is a reversed version of Lawvere's fixed point theorem, no need an extra proof.
Proof. [#655]
- October 11, 2023
- Lîm Tsú-thuàn
Proof. [#655]
- October 11, 2023
- Lîm Tsú-thuàn
這個定理也可以用到 Gödel incompleteness、Tarski definability 等等問題上。論文 Substructural fixed-point theorems and the diagonal argument: theme and variations 更進一步的簡化了前置條件。
Understand comma category [math-000U]
- October 3, 2023
- Lîm Tsú-thuàn
Understand comma category [math-000U]
- October 3, 2023
- Lîm Tsú-thuàn
Comma category is generated by two functors, denoted \((T \downarrow S)\).
To understand the idea, we can start from slice & co-slice category, which is a special case of comma category. In co-slice category, we have objects \(\langle f, c \rangle \) where \(x \xrightarrow {f} c\), and morphism \(\langle f, c \rangle \xrightarrow {h} \langle f', c' \rangle \) where below diagram commutes:
We give another denotation \((x \downarrow C)\) for object \(x\) and its category \(C\) for this concept, and \((C \downarrow x)\) for the dual.
If we generalize the idea, by replacing category \(C\) with a functor \(S : D \to C\), then we get a category \((x \downarrow S)\) with
- objects \(\langle f, d \rangle \) where \(x \xrightarrow {f} Sd\)
- morphisms \(h : \langle f, d \rangle \to \langle f', d' \rangle \) where below diagram commutes:
If we replace object \(x\) to another functor \(T\)? It's the full picture of comma category:
Definition. Comma category [math-000V]
- October 3, 2023
- Lîm Tsú-thuàn
Definition. Comma category [math-000V]
- October 3, 2023
- Lîm Tsú-thuàn
Given categories and functors
The comma category \((T \downarrow S)\) (or \((T,S)\)) has
- objects \(\langle e,d,f \rangle \) where \(e \in E\), \(d \in D\), and \(T(e) \xrightarrow {f} S(d)\)
- morphisms \(\langle k,h \rangle : \langle e,d,f \rangle \to \langle e',d',f' \rangle \) where below commutes:
Example. Slice category as comma category [math-000W]
- October 3, 2023
- Lîm Tsú-thuàn
Example. Slice category as comma category [math-000W]
- October 3, 2023
- Lîm Tsú-thuàn
With the definition, now we can see how slice & co-slice category is a special case of comma category:
- Replace object \(x\) with a functor \(T : 1 \to C\), it will exactly pick a certain object, in case is \(x\)
- Replace functor \(S : D \to C\) with identity functor of \(C\), and hence, it's the category itself
Example. All morphisms of \(C\) [math-002K]
- October 3, 2023
- Lîm Tsú-thuàn
Example. All morphisms of \(C\) [math-002K]
- October 3, 2023
- Lîm Tsú-thuàn
Take \(T = S = 1_C\), then \((C \downarrow C)\) is \(C^2\) (all morphisms of \(C\))
子類型與多型(泛型) [tt-000F]
- September 23, 2023
- Lîm Tsú-thuàn
子類型與多型(泛型) [tt-000F]
- September 23, 2023
- Lîm Tsú-thuàn
這個文章源自下面的問題
不過想問問專業的⋯⋯Golang 都有 interface 這種東西,提供泛型的必要性是什麼啊?
這是個常見的誤解,因為大部分語言不會多認真跟你講清楚到底啥是啥,看來好像都能接受多種不同的類型輸入不是嗎?所以這裡我們就來看各種機制的定義跟差別。
Go 的 interface [tt-000D]
- September 23, 2023
- Lîm Tsú-thuàn
Go 的 interface [tt-000D]
- September 23, 2023
- Lîm Tsú-thuàn
Go 語言的 interface,範例如下
type Abser interface { Abs() float64 }
其中的 Abs() float64
可以被改寫成抽象語法 Abs : () -> float64
。因此一個 interface \(A\) 有一組與其關聯的一系列簽名 \(\hat P\)。並且,對 Go 而言下列的兩個 interface 並沒有差異
type A interface { F(C) D } type B interface { F(C) D }
因此我們可以更進一步認為 Go 的一個 interface \(A\) 可以完全由其簽名 \(\hat P\) 替換。
Java 的 interface 與 bounded polymorphism (bounded quantification) [tt-000E]
- September 23, 2023
- Lîm Tsú-thuàn
Java 的 interface 與 bounded polymorphism (bounded quantification) [tt-000E]
- September 23, 2023
- Lîm Tsú-thuàn
在 Java 之中可以定義 interface,範例如下
interface Comparable<T> { int compareTo(T other); }
相較於 Go 中不用明確宣告,在 Java 中實現 interface I
需要寫成 class T extends I
,因此雖然 Java 的 interface \(A\) 也有其相關的一組簽名 \(\hat P\),但兩個有同樣簽名 \(\hat P\) 的 interface 不是同一個型別。
而在 Java 中 bounded polymorphism 指的是以下的 interface 使用方法:
<S extends Comparable> S min(S a, S b)
這會使得沒有明確宣告實現 Comparable
的型別無法被傳為 min
的引數。
問題所在 [tt-000G]
- September 23, 2023
- Lîm Tsú-thuàn
問題所在 [tt-000G]
- September 23, 2023
- Lîm Tsú-thuàn
現在考慮一個簽名 \[ f : (S \le A) \Rightarrow S \times S \to S \] 在 Java 裡面可以確實保證兩個參數跟回傳的型別都是同一個。在 Go 裡面這個簽名就只能寫成 \[ f : \hat P \times \hat P \to \hat P \] 而兩個參數跟回傳的型別不一定相同。現在我們就會發現乍看之下 interface 對類型的約束跟多型一樣可以被多個不同的型別滿足,但事實上根本就是不同的東西。
interface 是一種子類型關係,換句話說當 \(T\) 實現 \(A\) 我們就說 \(T \le A\),在每個要求 \(A\) 的位置都可以用 \(T\) 取代。
多型的本體是一個型別等級的參數!在語意學上,上面的簽名可以改寫成 \(f : \Lambda S. S \times S \to S\),當你寫下 \[f \; k\] 的時候,乍看之下是一個完整的呼叫。實際上編譯器會先推導 \(k\) 的類型,記作 \(\uparrow k\),譬如假設 \(k : C\) 則 \(\uparrow k = C\),這時候就可以做型別替換 \((\Lambda S. S \times S \to S) C\) 得出 \(C \times C \to C\)。因此真正的呼叫程式碼是 \[f \; [C] \; k\]
子類型規則並不能取代替換這個語意。在 Java 的 \(f : (S \le A) \Rightarrow S \times S \to S\) 規則下,僅是多檢查了 \(C \le A\) 是否為真,子類型與多型仍然是不同的規則。
Pattern matching on Types: An indirected universe [tt-0005]
- September 15, 2023
- Lîm Tsú-thuàn
Pattern matching on Types: An indirected universe [tt-0005]
- September 15, 2023
- Lîm Tsú-thuàn
By introduce a indirect level of universe \(\mathcal {U}^-\), such that a subtype of normal universe \(\mathcal {U}\), and allows pattern matching. By restricting it can only be used at inductive type definitions' dependent position, it preserves parametricity, solves the problem easier compare with subscripting universe. In this setup, every defined type has type \(\mathcal {U}^-\) first, and hence
- \(\mathbb {N} : \mathcal {U}^-\)
- \(\mathbb {B} : \mathcal {U}^-\)
- \(\mathbb {L} : \mathcal {U} \to \mathcal {U}^-\)
\(\mathbb {L}\) didn't depend on \(\mathcal {U}^-\), so we keep using tagless encoding to explain
data Term Type | ℕ => add (Term ℕ) (Term ℕ) | 𝔹 => eq (Term ℕ) (Term ℕ) | a => if (Term 𝔹) (Term a) (Term a) | a => lit a
We have \(\text {Term} : \mathcal {U}^- \to \mathcal {U}^-\), and then, if one wants List (Term Nat)
it still work since \(\mathcal {U}^- \le \mathcal {U}\). But if one tries to define code below:
inductive Split Type^ | Nat => nat | Bool => bool | _ => else def id (A : Type) (x : A) : A => match Split A | nat => 0 | bool => false | _ => x
Since the \(\mathcal {U}\) isn't the subtype of \(\mathcal {U}^-\), program Split A
won't type check, the definition will not work as intended.
This is indeed more boring than subscripting universe, but easier to check it does't break parametricity.
Till now, I haven't start to check the pattern of type, except the primitive exact value, if I'm going to push this further, a good example is:inductive K Type^ | List a => hi a | _ => heThis is quite intuitive since in implementation inductive types' head are also rigid values, just like constructors.
Subscripting Universe [tt-0003]
- September 14, 2023
- Lîm Tsú-thuàn
Subscripting Universe [tt-0003]
- September 14, 2023
- Lîm Tsú-thuàn
This is an extension means to solve pattern matching on type's problem. We start from my old idea, an extension of inductive types.
Subscripting Inductive types [tt-0009]
- September 14, 2023
- Lîm Tsú-thuàn
Subscripting Inductive types [tt-0009]
- September 14, 2023
- Lîm Tsú-thuàn
An intutive extension of inductive types is, let constructor be subscripting set of the inductive type. For example, a type with definition
inductive Nat | zero | suc Nat
A type Nat[suc]
means only suc ...
is a term, zero
cannot have type Nat[suc]
. It's easy to see NatNonZero = Nat[suc]
, this can also apply to
List1 = List[cons]
-
Int
is also a good motive exampleinductive Int | 0 | + Int[+, zero] | - Int[-, zero]
Int[+]
is positive,Int[-]
is negative. The diagram in its syntactic category:
To ensure this, if the following syntax of each constructor c
is a list of argument types Ti ...
, we say the type of constructor of type T
is Ti ... -> T[c]
. The corresponding part is pattern matching's type rules will refine type T
with the pattern matched constructor c
, below marks all binder's refined type. The type T[c, ...]
is a subtype of T
.
def foo : Int -> Int | 0 => 0 | + p => -- p : Int[+, 0] p | - n => -- n : Int[-, 0] n
Remark. [#298]
- September 14, 2023
- Lîm Tsú-thuàn
Remark. [#298]
- September 14, 2023
- Lîm Tsú-thuàn
An obvious problem is
def neg : Int -> Int | 0 => 0 | + p => - (neg p) | - n => + (neg p)
We can see that the type information is squeezed, the second and third case need type casting. A potential solution is case type, and hence, neg
has type like:
But then what's the type rule of it? Will need some time to explore.
Extend to Universe [tt-000A]
- September 14, 2023
- Lîm Tsú-thuàn
Extend to Universe [tt-000A]
- September 14, 2023
- Lîm Tsú-thuàn
To extend this on to universe type Type
, we say if there is an inductive family T
inductive T (xi : Xi) ... | ci Ti ... | ...
, there is a binding T : Xi ... -> Type[T]
. As usual, Type[T, ...]
is a subtype of Type
. Therefore, in this configuration, writes down id : {A : Type} -> A -> A
still has the only one implementation! And we can do type pattern matching if we have subscriptings. Consider
- \(\mathcal {U}\) as
Type
- \(\mathbb {N}\) as
Nat
- \(\mathbb {B}\) as
Bool
- \(L\) as
List
we have an example diagram as below
A motive example is the tagless encoding:
data Term Type | ℕ => add (Term ℕ) (Term ℕ) | 𝔹 => eq (Term ℕ) (Term ℕ) | a => if (Term 𝔹) (Term a) (Term a) | a => lit a
The final we can consider subtyping more, should we generally introduce subset of subscriptings as super type? In this setup then Type[Nat, Bool] <: Type[Nat] <: Type
.
However, this is an over complicated idea, I prefer indirected universe more.
Generalize concept of element [math-0007]
- September 12, 2023
- Lîm Tsú-thuàn
Generalize concept of element [math-0007]
- September 12, 2023
- Lîm Tsú-thuàn
Element or member is a natural concept in set theory, one can use \(x \in A\) to denote \(x\) is an element of \(A\). We can extend the idea from view it in the category \(\bold {Sets}\):
Each element \(x\) of a set \(A\) corresponding to a function (set-morphism) \[ \{\bullet \} \xrightarrow {x} A \]
Therefore, if we admit a category \(\mathcal {C}\) has a terminal object \(1\), we say an element \(x\) of object \(A \in Ob(\mathcal {C})\) is a morphism \(1 \xrightarrow {x} A\).
NOTE: A terminal object \(1\) has exact one morphism from elsewhere, therefore each \(1 \xrightarrow {x} A\) is a proper representation of a single element \(x \in A\).
Theorem. Equal Arrow [math-0008]
- September 12, 2023
- Lîm Tsú-thuàn
Theorem. Equal Arrow [math-0008]
- September 12, 2023
- Lîm Tsú-thuàn
If \(A \xrightarrow {f} B\) and \(A \xrightarrow {g} B\) are morphisms in the category \(\mathcal {C}\) then \(f = g\) if and only if for every object \(X\) and every morphisms \(X \xrightarrow {x} A\) we have \(f x = g x\)
Proof. [#663]
- September 12, 2023
- Lîm Tsú-thuàn
Proof. [#663]
- September 12, 2023
- Lîm Tsú-thuàn
Pattern matching on type & following problems [tt-0001]
- September 10, 2023
- Lîm Tsú-thuàn
Pattern matching on type & following problems [tt-0001]
- September 10, 2023
- Lîm Tsú-thuàn
I'm considering a weird way to build inductive types, it's start on Zhang's idea, do pattern matching to get constructors.
Zhang's idea [tt-0006]
- December, 2021
- Lîm Tsú-thuàn
Zhang's idea [tt-0006]
- December, 2021
- Lîm Tsú-thuàn
The idea is coming from Zhang's paper, a simpler encoding of indexed types.
An example is Vec
in Agda
data Vec (A : Set a) : ℕ → Set a where [] : Vec A zero _∷_ : ∀ (x : A) (xs : Vec A n) → Vec A (suc n)
One can still try [] : Vec A 10
, although the type check failed, it need a sophisticated unification check.
With Zhang's idea, we can do:
data Vec (A : Set a) : ℕ → Set a where zero => [] suc n => _∷_ A (Vec A n)
Now, [] : Vec A n
where \(n \ne 0\) is impossible to write down as usual, but now it's an easier unification!
Since there has no constructor []
for type Vec A n
where \(n \ne 0\).
Another good example is finite set:
data Fin (n : N) | suc _ => fzero | suc n => fsuc (Fin n)
It requires overlapping pattern. One more last, we cannot define usual equality type here (please check)
data Id (A : Type ℓ) (x : A) : A → Type ℓ where idp : Id A x x
Paper: Simpler indexed type essentially simplifies the problem of constructor selection just by turning the term-match-term problem to a term-match-pattern problem, which rules out numerous complication but also loses the benefit of general indexed types.
The encoding problem of Zhang's idea [tt-0007]
- December, 2022
- Lîm Tsú-thuàn
The encoding problem of Zhang's idea [tt-0007]
- December, 2022
- Lîm Tsú-thuàn
The benefit of the idea is clear, but it disallows definition like tagless interpreter:
data Term : Set → Set1 where lit : ∀ {a} → a → Term a add : Term ℕ → Term ℕ → Term ℕ eq : Term ℕ → Term ℕ → Term 𝔹 if : ∀ {a} → Term 𝔹 → Term a → Term a → Term a eval : ∀ {a} → Term a → a eval (lit x) = x eval (add x y) = eval x + eval y eval (eq x y) = eval x == eval y eval (if c t e) with eval c eval (if c t e) | true = eval t eval (if c t e) | false = eval e
NOTE: There is a workaround in paper, and hence, the problem is inconvenience instead of impossible.
Pattern matching on Type as a solution [tt-0008]
- January, 2023
- Lîm Tsú-thuàn
Pattern matching on Type as a solution [tt-0008]
- January, 2023
- Lîm Tsú-thuàn
If I simply allow pattern matching on "Type", it's able to restore encoding from the problem:
data Term Type | ℕ => add (Term ℕ) (Term ℕ) | 𝔹 => eq (Term ℕ) (Term ℕ) | a => if (Term 𝔹) (Term a) (Term a) | a => lit a
But then it breaks parametricity! One now can read what is a polymorphic type concretely:
data C (A : Type) | ℕ => c1 | 𝔹 => c2 | _ => c3 id : {A : Type} -> C A -> A -> A id c1 x = 3 id c2 x = false id _ x = x
The first simple idea in my mind is forbiddingC P
whereThe question is, does this enough?
P
is a typeC
destruct aP
positionP
is a polymorphic type variable
Gödel incompleteness theorem 到底證明了什麼? [math-00BT]
- August 30, 2023
- Lîm Tsú-thuàn
Gödel incompleteness theorem 到底證明了什麼? [math-00BT]
- August 30, 2023
- Lîm Tsú-thuàn
哥德爾不完備定理是一個相當有趣的邏輯學發現,要了解他的意涵,要先考慮哥德爾的編碼
Gödel number [#453]
- August 30, 2023
- Lîm Tsú-thuàn
Gödel number [#453]
- August 30, 2023
- Lîm Tsú-thuàn
哥德爾數是一種編碼方式,在一個算術系統裡面,當我們把每個字符都排成一個有限的列,我們可以幫每個字符都指定一個自然數。具體來說,我們可能會寫下
Symbol | Number | Meta Meaning |
---|---|---|
\(\neg \) | 1 | not |
\(\lor \) | 2 | or |
\(\land \) | 3 | and |
\(\cdots \) | n | \(\cdots \) |
當有符號 \(s_i (i \in \N )\),其對應的哥德爾數為 \(n_i\)。我們並不是真的關心具體的每個符號,我們做這件事的理由是為了表示哥德爾編碼。所以這裡要開始定義哥德爾編碼,首先先看一個簡單的例子:當有系統的公式符號排列 \(s_1 s_{10} s_4\),我們說公式的哥德爾編碼為 \(2^{n_1}\cdot 3^{n_{10}}\cdot 5^{n_4}\)。
因此用函數 \(\alpha (i)\) 指示一個公式的每個位置 \(i\) 符號的 Gödel number,則哥德爾編碼確切的定義是
\[\prod _{i \in I}p_i^{n_{\alpha (i)}}\],也就是將質數以每個符號對應的哥德爾數為指數,將它們全部乘起來。這個辦法只是為了迫使每個公式有對應的編碼存在。我們用 \(\overline {G}\) 記號表示公式 \(G\) 的哥德爾數。
\(\alpha \) 函數給出第 \(i\) 個出現符號的在表中的位置。
在承認前述的系統 \(P\) 下,可以開始描述。
Theorem. Gödel incompleteness [math-00BU]
- August 30, 2023
- Lîm Tsú-thuàn
Theorem. Gödel incompleteness [math-00BU]
- August 30, 2023
- Lîm Tsú-thuàn
- 存在形式上不能證明卻是真確、可寫下的公式
- 用系統證明自身的一致性會導致不可決定的公式也被證明
Definition. Substitution [#450]
- August 30, 2023
- Lîm Tsú-thuàn
Definition. Substitution [#450]
- August 30, 2023
- Lîm Tsú-thuàn
\(x[m/n]\) 表示將公式 \(x\) 中哥德爾數為 \(n\) 之符號換成 \(m\) 的哥德爾數再求此替換後公式的哥德爾編碼。
例如 \(\neg y[n/\overline {y}] = \overline {\neg n}\)
Proof. [#452]
- August 30, 2023
- Lîm Tsú-thuàn
Proof. [#452]
- August 30, 2023
- Lîm Tsú-thuàn
首先,用 \(\exists x. x \vdash k\) 表示有哥德爾數為 \(k\) 的公式在系統 \(P\) 中得到證明,而 \(x\) 是其演示
Remark. [#451]
- August 30, 2023
- Lîm Tsú-thuàn
Remark. [#451]
- August 30, 2023
- Lîm Tsú-thuàn
哥德爾有一段很長的論證,證明這是原始遞歸函數,以說明這是可以被 \(P\) 表示的,這裡跳過了這部分論證。且這也是為什麼要求系統 \(P\) 是具備算術能力的,因為表示編碼需要自然數算術。
定義 \(n = \lnot \exists x. x \vdash y[y/y]\),但 \(y\) 是未知量,隨意給一個還沒被使用來編碼的數字即可,比如 \(\overline {y}\)。於是我們重寫成 \(n = \lnot \exists x. x \vdash y[y/\overline {y}]\)。
現在構造 \(G = \lnot \exists x. x \vdash n[n/\overline {y}]\),求其哥德爾編碼 \(\overline {G}\) 可以發現正是 \(n[n/\overline {y}]\) 所表示的編碼,因為
\[ n[n/\overline {y}] = \overline {\lnot \exists x. x \vdash n[n/\overline {y}]} = \overline {G} \]因此用 \(\overline {G}\) 替換 \(G\) 中的 \(n[n/\overline {y}]\),會得到
\[\lnot \exists x. x \vdash \overline {G}\]可以發現 \(G\) 的後設含義正是「有哥德爾編碼為 \(\overline {G}\) 的公式沒有系統 \(P\) 中的證明」,然而
- 假設 \(G\) 可以在 \(P\) 中證明為真,就告訴我們 \(\overline {G}\) 對應的公式不存在任何演示可以於 \(P\) 中證明,但那就是我們剛證明的公式 \(G\)。
- 假設 \(G\) 可以在 \(P\) 中證明為否,就導出 \(\overline {G}\) 對應的公式在 \(P\) 中有演示,但那就是我們剛證否的公式 \(G\)。
綜合可知這意思就是 \(G\) 可證,若且唯若 \(G\) 可證否,是故承認 \(G\) 就是承認 \(P\) 不一致;反之,若 \(P\) 一致則 \(G\) 形式上就不可決定。
巧妙的是,並不難看出 \(G\) 的 meta 陳述是真確的,因為確實不存在任何整數作為編碼滿足這個性質。換句話說,存在形式上不能證明卻是真確、可寫下的公式,這就是第一不完備定理。接著根據第一不完備定理知道了 \(G\) 的真確性,卻在 \(P\) 中形式上不可決定,所以 \(P\) 不能證明一個真確的算術公式,因此 \(P\) 必定是不完備的,這就是第二不完備定理。
Conclusion. [#454]
- August 30, 2023
- Lîm Tsú-thuàn
Conclusion. [#454]
- August 30, 2023
- Lîm Tsú-thuàn
因此在 The Blind Spot: Lectures on Logic 中可以看到對兩個定理的陳述更加關注核心:對一個足夠編碼自己又一致的系統
- 存在一個真確的公式 \(G\) 不可決定
- 系統證明自己具有一致性會連帶證明這個不可決定的公式,所以系統無法證明自己的一致性
換句話說,要關心的並不是具體如何構造上面陳述的編碼,而是這類系統編碼系統自身的普遍性問題。
型別有多大? [tt-0013]
- July 1, 2023
- Lîm Tsú-thuàn
型別有多大? [tt-0013]
- July 1, 2023
- Lîm Tsú-thuàn
不久之前看到 fizzyelt 的文章,所我前幾日開始研究自己以前寫的 strictly positive 筆記,因此找到了 Andrej Bauer 在 stackexchange 的回答,整理後寫了這篇文章解釋何謂型別的大小
型別的大小 [tt-0014]
- July 1, 2023
- Lîm Tsú-thuàn
型別的大小 [tt-0014]
- July 1, 2023
- Lîm Tsú-thuàn
要了解型別的大小的意義,可以先考慮一個 small cartesian closed category,令型別是此範疇的物件(只有一個型別的 context)。
應用 slice category [tt-0016]
- July 1, 2023
- Lîm Tsú-thuàn
應用 slice category [tt-0016]
- July 1, 2023
- Lîm Tsú-thuàn
在這個情況下,對任意型別 \(t\),slice category \(C/t\) 表示「到達 \(t\) 的 morphism」所構成的集合,也就是 \(C/t\) 的 objects。
Example. 從 \(1\) 出發 [tt-0017]
- July 1, 2023
- Lîm Tsú-thuàn
Example. 從 \(1\) 出發 [tt-0017]
- July 1, 2023
- Lîm Tsú-thuàn
接著,我們要關心其中沒定義的 morphism,我們將基於此集合討論型別 \(T\) 有多大。技術上來說,是指從 terminal object \(1\) 出發的所有 morphisms(記為 \(\text {Hom}_{C}(1, T)\)),這些 morphisms 對應到內建的形式;以邏輯來說是指公理,而在函數式語言裡面,我們最常看到的定義公理的方式就是 data type!換句話說,型別的大小由建構子決定:
- \(0\) 是 False / Empty type,沒有任何建構子
- \(1\) 是 Unit type,只有一個建構子
- \(2\) 是 Bool type,只有兩個建構子
依此類推可以知道有 \(k\) 個單元建構子(即建構子 c
滿足 c : K
)的型別 K
可以解釋為 \(k\)-type,接著 \(2 \to T\) 的元素應該有幾個呢?答案是 \(T \times T = T^2\),同理我們可以建立 \(k \to T = T \times ... \times T = T^k\) 的關係式。
依此可以建立一個簡單的直覺是 c : T
表示 \(+1\),而更加複雜的型別如 c : (2 -> T) -> T
就表示 \(+T^2\),建構子的參數表現了型別增長的速度,決定了型別的大小。
一個常見的案例是自然數,我們通常定義 \(z : \N \) 和 \(s : \N \to \N \) 兩個建構子來表示自然數 \(\N \)。用 F-algebra 來表示,可以得到 \((1 + \mathbb {N}) \to \mathbb {N}\),從沒有循環參考的角度來看,當前 \(\N \) 的大小即取決於上一個 \(\N \) 的大小。畫出交換圖就可以了解到從基本點 \(z\) 出發,只有 \(s\) 一個方向可以前進,恰恰就是可數無限大的定義,是以看到這與歸納法的對應時,應當不會太過驚訝。
Inductive data type [tt-0018]
- July 1, 2023
- Lîm Tsú-thuàn
Inductive data type [tt-0018]
- July 1, 2023
- Lîm Tsú-thuàn
在 dependent type 語言裡面,data type 會變成 inductive data type,引入了更多的限制,而其中跟大小有關的限制就是這裡想要討論的。
Question. 在定義建構子時 c : (T -> T) -> T
有參數 \(T^T\) ,試問 \(T^T\) 有多大? [#268]
- July 1, 2023
- Lîm Tsú-thuàn
Question. 在定義建構子時 c : (T -> T) -> T
有參數 \(T^T\) ,試問 \(T^T\) 有多大? [#268]
- July 1, 2023
- Lîm Tsú-thuàn
答案是不知道,因為我們根本還不知道 \(T\) 到底是什麼。
Remark. [#269]
- July 1, 2023
- Lîm Tsú-thuàn
Remark. [#269]
- July 1, 2023
- Lîm Tsú-thuàn
當 \(T\) 定義完畢之後,這個簽名用在函數上倒是沒有問題,因為其大小已經確定,不會遇到自我指涉引發的麻煩。
雖然可以用公理強迫 \(T^T\) 有 size,但這樣做一來會破壞計算性;二來會顯著的複雜化 termination check。舉例來說,要是容許定義 c
,就可以寫出
def foo (t : T) : T := match t with | c f => f t
接著 foo (c foo)
就會陷入無限迴圈,為了要有強正規化,我們希望排除所有這類型的程式,比起一個一個去比對,直接禁止定義 c
這類的建構子可以更簡單的達成目的。Haskell/OCaml 的 data type 則不做此限制,因為它們不需要強正規化,這也是為什麼 dependent type 語言常説其 data type 是 inductive data type,並不輕易省略 inductive 這個詞,因為這樣定義的類型滿足 induction principle。
另外一提,Bauer 的回答談到所有建構子都是為了符合 \(c : \Pi _{x : B} (A \; x \to T) \to T\) 的形式,有興趣的讀者可以著手證明。此外 strictly positive 的遞迴定義可能更適合實現檢查機制。
遞迴 [tt-0015]
- July 1, 2023
- Lîm Tsú-thuàn
遞迴 [tt-0015]
- July 1, 2023
- Lîm Tsú-thuàn
把程式作為 object,而 continuation 作為 morphism,就可以發現尾遞迴完全對應到迴圈這個抽象,兩者都有
- \(b : c \to k\) base case 與 break
- \(n : c \to c\) induction case 與 next step
這兩個 morphism。從構造的角度來看,還可以說他們跟自然數有對應,上面的簽名恰恰正是 initial 跟 step。
分形遞迴(Tree Recursion) [tt-0019]
- July 1, 2023
- Lîm Tsú-thuàn
分形遞迴(Tree Recursion) [tt-0019]
- July 1, 2023
- Lîm Tsú-thuàn
典型的情況是 fibonacci 數列,展示了前面的型別大小如何與程式相關,常見的程式定義如下
def fib : Nat → Nat | 0 => 1 | 1 => 1 | n+2 => fib n + fib (n+1)
為了抽出計算部分的代數,我們用 inductive type 定義其計算
inductive Fib (a : Type) : Nat → Type where | z : a → Fib a 0 | o : a → Fib a 1 | s : Fib a n → Fib a (n+1) → Fib a (n + 2)
可以看到 induction case 就是 \((2 \to F a) \to F a = {F a}^2 \to F a = F a \times F a \to F a\),所以對應的程式就是兩次呼叫 fib n + fib (n+1)
。當然,因為 fibonacci 還有一個利用矩陣計算的編碼
這個方法對應到 \(O(n)\) 的演算法,因此 fibonacci 不一定要用分形遞迴計算。這件事也告訴了我們代數簽名有時候比我們具體的計算更寬鬆,上面的 inductive type 並未限制如何使用 s
,也因此可以摺疊時可能存在更快的計算方式。這也說明了當遇到 c : (T -> T) -> T
一類的建構子時,其對應的計算難以寫出的問題,也就是前面沒辦法定義 \(T^T\) 的大小的情形。
Parser combinator:文法規則就是組合子的運用 [cs-000S]
- June 4, 2023
- Lîm Tsú-thuàn
Parser combinator:文法規則就是組合子的運用 [cs-000S]
- June 4, 2023
- Lîm Tsú-thuàn
這裡的想法我以前就在部落格裡面提到了,但是當時的設計並不夠通用,隨著後來拿來寫其他專案的時候標出型別就有了更廣泛的想法。
Definition. 左遞迴 [cs-000L]
- June 4, 2023
- Lîm Tsú-thuàn
Definition. 左遞迴 [cs-000L]
- June 4, 2023
- Lîm Tsú-thuàn
左遞迴是我們定義文法的時候會出現的一種形式,比如
\[\begin {equation} Expr \to Expr + Expr \end {equation}\]翻譯成遞歸下降解析器時會有像下面這樣的程式
def expr : Parsec E := let l <- expr match '+' let r <- expr return E.add l r
這時候 expr
顯然是一個非終止的發散函數,而因為遞迴的原因是運算式的左邊,所以被稱為左遞迴。這樣的 infix 運算形式在文法中很常見,所以我們需要方法來消除文法中的左遞迴。
Definition. Parser combinator [cs-000M]
- June 4, 2023
- Lîm Tsú-thuàn
Definition. Parser combinator [cs-000M]
- June 4, 2023
- Lîm Tsú-thuàn
解析器組合子(parser combinator)最早來自論文 A new top-down parsing algorithm to accommodate ambiguity and left recursion in polynomial time, 在現在的使用中因為不同語言特性跟 parser combinator 指涉的比較像是一種程式方法的情況下,本文中的 parser combinator 是單純指把 parser 跟 higher order function 結合的一種程式方法。這個方案最大的好處就是遞歸下降解析跟程式寫法一一對應,因此相當直覺。
在遞歸下降解析中消除左遞迴的方法 [cs-000N]
- June 4, 2023
- Lîm Tsú-thuàn
在遞歸下降解析中消除左遞迴的方法 [cs-000N]
- June 4, 2023
- Lîm Tsú-thuàn
現在你知道為什麼我們需要了解遞歸下降解析中消除左遞迴的方式,以下面文法來說
\[\begin {align} Expr \to \; &Expr + Expr \\ | \; &Int \\ | \; &( Expr ) \end {align}\]我們可能會將定義改成
\[\begin {align} Expr &\to Term + Term \\ Term &\to Int \; | \; ( Expr ) \end {align}\]這個解法在對應的 parser combinator 中看起來像是
mutual def term := parse_int <|> parens expr def expr : Parsec E := let l <- term match '+' let r <- term return E.add l r end
擴展到 operator 優先序問題 [cs-000O]
- June 4, 2023
- Lîm Tsú-thuàn
擴展到 operator 優先序問題 [cs-000O]
- June 4, 2023
- Lîm Tsú-thuàn
上面的方法解決了左遞迴問題,但是要是有多個不同優先級的運算形式就會讓文法快速膨脹
\[\begin {align} Expr &\to Term + Term \\ Term &\to Factor * Factor \\ Factor &\to Int \; | \; ( Expr ) \end {align}\]這樣單調的修改在文法裡面確實很無聊,不過只要仔細觀察對應的 combinator,就會它們的型別發現這告訴了我們要怎麼利用 higher order function 來解決重複的問題!對 infix 運算形式(左結合)來說,通用的程式是
def infixL (op : Parsec (α → α → α)) (tm : Parsec α) : Parsec α := do let l ← tm match ← tryP op with | .some f => return f l (← tm) | .none => return l
這個 combinator 先解析左邊的 lowertm
,接著要是能夠解析op
就回傳op
combinator 中存放的函數,否則就回傳左半邊的tm
結果。使用上就像這樣
mutual def factor : Parsec Expr def expr : Parsec Expr := factor |> infixL (parseString "*" *> return Expr.mul) |> infixL (parseString "+" *> return Expr.add) end
- 其中
parseString
是個假設會進行 whitespace 過濾並 match 目標字串的 combinator -
Expr.mul
跟Expr.add
的型別被假設為Expr → Expr → Expr
這裡真正發生的就是使用組合子編碼了文法的層級,其中每個規則都被記錄成匿名函數,我們無需再另外命名。
處理優先度相同的運算子 [cs-000P]
- June 4, 2023
- Lîm Tsú-thuàn
處理優先度相同的運算子 [cs-000P]
- June 4, 2023
- Lîm Tsú-thuàn
因為有些運算子優先級相同,所以我們還需要再修改上面的函數來正確的支援這個概念;而且上面的程式為了避免複雜化,只解析一次 operator 加上 tm
就退出了,會導致實際上 1 + 2 * 3 * 4
這種算式的 * 4
部分沒有被解析。要解決這個問題,我們需要貪婪解析右半邊 op tm
的部分。綜上所述我們得到的程式碼是
def infixL (opList : List (Parsec (α → α → α))) (tm : Parsec α) : Parsec α := do let l ← tm let rs ← many do for findOp in opList do match ← tryP findOp with | .some f => return (f, ← tm) | .none => continue fail "cannot match any operator" return rs.foldl (fun lhs (bin, rhs) => (bin lhs rhs)) l
首先我們有一串 operator 而非一個,其次在右邊能被解析成 op tm
時都進行解析,最後用 foldl
把結果轉換成壓縮後的 α
Conclusion. 對文法規則的運用 [cs-000Q]
- June 4, 2023
- Lîm Tsú-thuàn
Conclusion. 對文法規則的運用 [cs-000Q]
- June 4, 2023
- Lîm Tsú-thuàn
我希望這次有成功解釋怎麼從規則對應到 parser combinator,所以相似的規則可以抽出相似的 higher order function 來泛化,讓繁瑣的規則命名變成簡單的函數組合。這個技巧當然不會只有在這裡被使用,只要遇到相似形的文法都可以進行類似的抽換,相似的型別簽名可以導出通用化的關鍵。
Appendix. 其他 expression combinator [cs-000R]
- June 4, 2023
- Lîm Tsú-thuàn
Appendix. 其他 expression combinator [cs-000R]
- June 4, 2023
- Lîm Tsú-thuàn
在這裏提到的所有程式都實作在我幫 lean 寫的一個解析器擴充程式庫 parsec-extra 中
-
右結合的 infix
partial def infixR (opList : List (Parsec (α → α → α))) (tm : Parsec α) : Parsec α := go #[] where go (ls : Array (α × (α → α → α))) : Parsec α := do let lhs ← tm for findOp in opList do match ← tryP findOp with | .some f => return ← go (ls.push (lhs, f)) | .none => continue let rhs := lhs return ls.foldr (fun (lhs, bin) rhs => bin lhs rhs) rhs
-
prefix
op tm
def «prefix» (opList : List $ Parsec (α → α)) (tm : Parsec α) : Parsec α := do let mut op := .none for findOp in opList do op ← tryP findOp if op.isSome then break match op with | .none => tm | .some f => return f (← tm)
-
postfix
op tm
def «postfix» (opList : List $ Parsec (α → α)) (tm : Parsec α) : Parsec α := do let e ← tm let mut op := .none for findOp in opList do op ← tryP findOp if op.isSome then break match op with | .none => return e | .some f => return f e
Cones, their category, and limit [math-002L]
- March 20, 2023
- Lîm Tsú-thuàn
Cones, their category, and limit [math-002L]
- March 20, 2023
- Lîm Tsú-thuàn
In category theory, cone is a kind of natural transformation, to describe a diagram formally. The setup of cone is starting from a diagram, which we will define it as a category \(\mathcal {D}\) (usually is a finite one but no need to be) with two functors to the target category \(\mathcal {C}\). The two functors are
- \(\Delta _c\) takes all objects of \(\mathcal {D}\) to a certain \(\mathcal {C}\)-object \(c\), and all morphisms to the identity \(1_c\)
- \(F\) sends the diagram \(\mathcal {D}\) entirely into \(\mathcal {C}\)
The first functor is very clear, we always can do that for any category; the second functor will need \(\mathcal {C}\) has that diagram. Consider \(\mathcal {D}\) as below
If such diagram exists in \(\mathcal {C}\), then we have a proper way to define \(F\), there can have many such diagram in \(\mathcal {C}\), we denote them as \(\mathcal {C}(\mathcal {D})\). Now consider if there is a morphism from \(c\) to all objects in \(\mathcal {C}(\mathcal {D})\), that lift a natural transformation from \(\Delta _c \to F\).
We say \(c\) is an apex and the \(\mathcal {C}(\mathcal {D})\) is a plane in this sense, thus, such a natural transformation gives concept cone. With a fixed functor \(F\) (we also abuse language to say \(F\) is the diagram), varies \(\Delta _c\) bring different cones! When I get this, the picture in my mind is:
Image the head is apex and the body is the fixed diagram \(F\), you will also get the idea slowly.
To describe above idea, we make another category! By picking all apex of cone as objects, and picking morphism between apex in \(\mathcal {C}\) as morphisms, this is the category of cones (please check it does really a category).
Definition. Category of (co)cones [math-002M]
- March 20, 2023
- Lîm Tsú-thuàn
Definition. Category of (co)cones [math-002M]
- March 20, 2023
- Lîm Tsú-thuàn
With a fixed diagram \(\mathcal {D} \xrightarrow {F} \mathcal {C}\) and existing natural transformations \(\Delta _c \to F\), we get a category that consituited by
\(\Delta _c\) is a functor \(- \mapsto c : \mathcal {D} \to \mathcal {C}\) various on different \(c \in \mathcal {C}\).
- objects: all cone objects \(c\) above the fixed diagram (via \(\Delta _c\) functor).
- morphisms: \(\mathcal {C}\)-morphisms between cones.
Dual natural transformations \(F \xrightarrow {\beta } \Delta _c\) form cocones and a dual category.
The funny part we care here, is the terminal object of the category of cones, that is the next section. A limit or universal cone is a terminal object of category of cones. If you consider it carefully, and you will find this is the best cone of cones, because every other cones can be represented by composition of an addition morphism from itself to the limit!
Definition. Limit and colimit (universal cone and cocone) [math-002N]
- March 20, 2023
- Lîm Tsú-thuàn
Definition. Limit and colimit (universal cone and cocone) [math-002N]
- March 20, 2023
- Lîm Tsú-thuàn
With a fixed diagram \(\mathcal {D} \xrightarrow {F} \mathcal {C}\), a limit is a terminal of the category of cones, denoted as \(\lim _{\mathcal {D}} F\).
- notice that we can freely abuse language and say a \(\mathcal {C}\)-diagram is a functor target to \(\mathcal {C}\)
- Limit might not exist, so you have to ensure there has one.
The dual concept colimit is an initial of category of cocones, denoted as \(\underset {\mathcal {D}} {\text {colim}}F\).
With concept of cone and limit, you might already find there has some concept can be replaced by cone and limit, you're right and that would be fun to rewrite them in this new sense. Have a nice day.
什麼是啟動編譯器? (bootstrap compiler) [cs-000V]
- December 31, 2022
- Lîm Tsú-thuàn
什麼是啟動編譯器? (bootstrap compiler) [cs-000V]
- December 31, 2022
- Lîm Tsú-thuàn
當一個語言逐漸成熟,開發者常常會有一個想法就是用自己開發的語言寫這個語言的編譯器,但是這個決策會導致程式庫中有兩套目標一樣但是實現語言不同的編譯器程式。其一是本來的實現,另一個是用語言自身新寫的。一來這樣開發任何新功能的時候都需要寫兩次;二來這會減少可能的參與者人數,因為這下他得要熟悉兩個語言才行!解決這個問題的辦法就是啟動編譯器,通常是一個在多平台上可以直接執行的檔案。
Definition. 原理 [cs-000W]
- December 31, 2022
- Lîm Tsú-thuàn
Definition. 原理 [cs-000W]
- December 31, 2022
- Lîm Tsú-thuàn
約略是下面描述的樣子:
- 語言本身後端的目標語言可以生成這個啟動編譯器,讓我們先用可執行檔簡單理解它,後面再闡述為什麼用普通的可執行檔可能不是一個好主意
- 每次編譯器用到新的特性的時候,都需要更新啟動編譯器檔案並提交進程式庫
- 有了上述準備,就可以在第一次編譯編譯器自身的時候,用啟動編譯器編譯出最佳化過的編譯器執行檔
現在有了最佳化過的編譯器執行檔,就可以正常的使用語言自己對語言自己進行開發了。
現在可以來想一下為什麼是這樣的流程,首先一個程式語言除非被大量作業系統支援(比如 C、Python),否則系統上是不會有這個程式語言的編譯器的!這樣問題就來了:假設有人試圖參與這個編譯器專案,用的平台剛好跟既有開發者都不一樣,請問要由誰提供已經用語言自身編寫的編譯器的編譯器呢?想當然除了一些喪心病狂的作法,是不可能完成這個任務的!所以一個無論如何都已經可以執行的編譯器,哪怕效能比較差,也具有存在的價值。
而語言自身的編譯器用到新功能的時候,也一定要更新啟動編譯器,否則下一輪的新參與者就沒辦法正確的進行初始編譯。
用普通的可執行檔可能不是一個好主意 [cs-000X]
- December 31, 2022
- Lîm Tsú-thuàn
用普通的可執行檔可能不是一個好主意 [cs-000X]
- December 31, 2022
- Lîm Tsú-thuàn
前面提過說啟動編譯器通常是一個在多平台上可以直接執行的檔案,也提過哪怕效能不佳也可以,這兩個理由使得特定平台的可執行檔不是一個好的選擇。 當然,我們也可以選擇維護每個平台的啟動編譯器,chez scheme 就維護了一堆根據不同平台套用組合的二進位檔案做這件事。
回到正題上,啟動編譯器通常不會選擇這麼複雜的方式,而是會生成可以在多平台上執行的檔案。舉例來說,生成 C 或是 Python 這種已經被許多系統廣泛支援的語言,最近 zig 就是使用 wasm 達成這個目標。但這個選擇也不能太過隨便,比如要是語言自己的 type checking 任務很長,生成 Python 就會得到一個大家都不想等它跑完就不玩了的啟動編譯器。而限制太多的語言像是 haskell 或是 rust 可能也不是優秀的選擇,因為你的語言模型很可能跟這些目標語言非常不相配,進而讓編譯過程非常的痛苦。
Conclusion. [cs-000Y]
- December 31, 2022
- Lîm Tsú-thuàn
Conclusion. [cs-000Y]
- December 31, 2022
- Lîm Tsú-thuàn
有了這些概念,我想你已經有能力為自己的語言寫出啟動編譯器了!那麼剩下的篇幅我就可以來寫點 murmur,我覺得這個概念可以進一步推升到選擇一個夠容易編譯出來,也夠容易寫出通用最佳化編譯器的語言來達成。我個人是很看好 wasm,因為它確實容易當目標、最佳化,只可惜現在還有不少重要的功能都沒有定案。llvm 的 bytecode 確實也是一個方案,寫一個把 llvm bytecode 編譯成 executable 的 python 檔案並不困難,但 llvm 的連結性自己就是一個天殺的大麻煩所以這個方案我很少看到有人使用。Java bytecode 則是讓那些本來就預計只在 JRE 生態系內部的語言從一開始就沒有這個問題,微軟的 CLR 也是類似的狀況,缺陷是最後語言受制於 runtime,這個問題會有多大條取決於語言的目的是什麼。
好像是今年最後一天了,祝你不是在今天看到這篇文章的!
解析 conversion check [tt-001C]
- November 25, 2022
- Lîm Tsú-thuàn
解析 conversion check [tt-001C]
- November 25, 2022
- Lîm Tsú-thuàn
今天要解析的是 Elaboration zoo 中的一段程式,其中用到了 conversion check 的技術。這種合一演算法在 dependent type 語言裡面是主要的核心問題
型別檢查 [tt-001D]
- November 25, 2022
- Lîm Tsú-thuàn
型別檢查 [tt-001D]
- November 25, 2022
- Lîm Tsú-thuàn
這裡列出重要的兩個定義:
- environment:儲存變數的計算結果
- context:儲存變數的型別
type Env = [(Name, Val)] type Ctx = [(Name, VTy)]
下面逐步介紹整個型別檢查的元件
推導 inference [tt-001F]
- November 25, 2022
- Lîm Tsú-thuàn
推導 inference [tt-001F]
- November 25, 2022
- Lîm Tsú-thuàn
在最上層的程式中,推導函數會直接被調用來得出 term 的 type,它會適當的調用 check
去檢查是否有型別錯誤
infer :: Env -> Ctx -> Raw -> M VTy infer env ctx = \case SrcPos pos t -> addPos pos (infer env ctx t) Var x -> case lookup x ctx of Just a -> return a Nothing -> report $ "Name not found: " ++ x U -> return VU t :@ u -> do tty <- infer env ctx t case tty of VPi _ a b -> do check env ctx u a return $ b $ eval env u tty -> report $ "Cannot apply on: " ++ quoteShow env tty Lam {} -> report "cannot infer type for lambda expression" Pi x a b -> do check env ctx a VU check ((x, VVar x) : env) ((x, eval env a) : ctx) b VU return VU Let x a t u -> do check env ctx a VU let ~a' = eval env a check env ctx t a' infer ((x, eval env t) : env) ((x, a') : ctx) u
-
SrcPos
這個情況只需要加上位置訊息之後往下 forward 即可 - 遇到變數時,查找當前的 context 就可以知道型別了
- 再來 universe 的 type 就是 universe
- application (
t :@ u
) 也就是函數套用 (\(\beta \)-reduction) 的情況就比較複雜了- 首先要馬上推導
t
得到tty
- 要是
tty
不是一個函數型別 (\(\Pi \) type) 那麼就回報錯誤 - 否則
tty
的形式就會是 \(\Pi (x:A) \to B\),這時候要檢查u
是否是一個 \(A\) - 最後一步把 \(\Pi (x:A)\to B\) 套用
u
就會得到型別 \(B\ x\),也就是目標
- 首先要馬上推導
- lambda 設定成不能推導,避開 undecidable 的情況
- 對 \(\Pi (x : A) \to B\) 先檢查 \(A\) 是不是型別 (\(\mathbb {U}\)) ,接著擴張 environment 跟 context 再檢查 \(B\ x\) 是不是 \(\mathbb {U}\)
- let 語法寫成
let x : a = t in u
,推導的過程如下- 檢查
a
是型別 - 執行
a
得到a'
,因為要從Tm
變成Val
(也就是化簡過的a
) - 檢查
t
的型別是否是a'
- 把
x : a'
與x = t
的綁定資訊推進 context 與 environment 再拿它們去推導u
- 檢查
最後使用 infer
時,就像是這樣 (...
是省略號):
tm <- parse ... case infer [] [] tm of Left err -> ... Right ty -> ...
檢查 check [tt-001G]
- November 25, 2022
- Lîm Tsú-thuàn
檢查 check [tt-001G]
- November 25, 2022
- Lîm Tsú-thuàn
檢查函數接收一個 term 跟一個 type 用來找出 term 實際類型不匹配 type 的情況
check :: Env -> Ctx -> Raw -> VTy -> M () check env ctx t a = case (t, a) of (SrcPos pos t, _) -> addPos pos (check env ctx t a) (Lam x t, VPi (fresh env -> x') a b) -> -- after replace x in b -- check t : bx check ((x, VVar x') : env) ((x, a) : ctx) t (b (VVar x')) (Let x a' t' u, _) -> do check env ctx a' VU let ~a'' = eval env a' check env ctx t' a'' check ((x, eval env t') : env) ((x, a'') : ctx) u a _ -> do tty <- infer env ctx t unless (conv env tty a) $ report (printf "type mismatch\n\nexpected type:\n\n \%s\n\ninferred type:\n\n \%s\n" (quoteShow env a) (quoteShow env tty))
-
SrcPos
這個情況只需要加上位置訊息之後往下 forward 即可 - 要是 term 是 lambda \(\lambda x . t\) 且 type 是 \(\Pi (x' : A) \to B\)
- 這裡 \(\Pi \) type 用了 view patterns 這個 extension:
fresh env -> x'
- 這部份是因為
x
跟x'
可能是同名的,fresh
確保了它們不會被搞混 - 這個語法的意思是
expression -> pattern
- pattern 用來 matching
- expression 在 match 到之後套用到該 pattern 對應的 expression
- 這部份是因為
- 接著讓環境擴張成
x = x'
跟x : A
- 拿新環境檢查
t
(lambda 的 body)的型別是不是 \(B\ x\)檢查 lambda 的方式就是讓 lambda 跟 \(\Pi \) 套用同一個參數之後再看一次
- 這裡 \(\Pi \) type 用了 view patterns 這個 extension:
- term 是 let 語法時跟推導的情況完全一樣,只差在最後一段是檢查
u
在新環境下是不是check
拿到的那個 type 而不是去推導u
- 除此之外的情況就是調用回去
infer
找出 term 的型別,然後讓它跟check
拿到的 type 做 conversion check
化簡 evaluation [tt-001H]
- November 25, 2022
- Lîm Tsú-thuàn
化簡 evaluation [tt-001H]
- November 25, 2022
- Lîm Tsú-thuàn
化簡函數就是把 term 變成 value 的過程,它只需要 environment 而不需要 context
eval :: Env -> Tm -> Val eval env = \case SrcPos _ t -> eval env t Var x -> fromJust $ lookup x env t' :@ u' -> case (eval env t', eval env u') of (VLam _ t, u) -> t u (t, u) -> VApp t u U -> VU Lam x t -> VLam x (\u -> eval ((x, u) : env) t) Pi x a b -> VPi x (eval env a) (\u -> eval ((x, u) : env) b) Let x _ t u -> eval ((x, eval env t) : env) u
-
SrcPos
一如既往的只是 forward - 變數就是上環境尋找
- \(\beta \)-reduction 的情形就是先化簡要操作的兩端,然後看情況
- 函數那頭是 lambda,就可以當場套用它的 host lambda 得到結果
- 這個情形比較有趣,有很多名字像是卡住、中性之類的描述,簡單來說就是沒辦法繼續化簡的情況。我們用
VApp
儲存這個結果,conversion check 裡面會講到怎麼處理這些東西VApp
也常被叫做 spine
- universe 的值還是 universe
- lambda 跟 \(\Pi \) 好玩的地方在使用 host lambda 編碼計算,這個 lambda 定義成
\u -> ...
- 會用
u
去擴展 environment,也就是(x, u) : env
- 接著用擴展的 environment 執行
t
(在 \(\Pi \) 的情況就是執行b
)
- 會用
- let x : a = t in u 語法就是把 x = t 丟進 environment 去執行 u 而已
Remark. [#295]
- November 25, 2022
- Lîm Tsú-thuàn
Remark. [#295]
- November 25, 2022
- Lîm Tsú-thuàn
卡住在 dependent type 裡非常常見,舉例來說你有個函數
foo : (f : A -> U) -> (a : A) -> f a
在檢查 foo
時執行到 f a
就沒辦法被化簡,因為此時我們拿到的 f
是一個 VVar "f"
而不是 VLam x t
Conversion check 可轉換性檢查 [tt-001I]
- November 25, 2022
- Lîm Tsú-thuàn
Conversion check 可轉換性檢查 [tt-001I]
- November 25, 2022
- Lîm Tsú-thuàn
conversion 是在 environment 中判斷兩個 value 是否能夠互相轉換的函數,對型別來說就是在判斷兩個型別是否相同
conv :: Env -> Val -> Val -> Bool conv env m n = case (m, n) of (VU, VU) -> True (VPi (fresh env -> x) a b, VPi x' a' b') -> conv env a a' && conv ((x, VVar x) : env) (b (VVar x)) (b' (VVar x)) (VLam (fresh env -> x) t, VLam x' t') -> conv ((x, VVar x) : env) (t (VVar x)) (t' (VVar x)) (VLam (fresh env -> x) t, u) -> conv ((x, VVar x) : env) (t (VVar x)) (VApp u (VVar x)) (u, VLam (fresh env -> x) t) -> conv ((x, VVar x) : env) (VApp u (VVar x)) (t (VVar x)) (VVar x, VVar x') -> x == x' (VApp t u, VApp t' u') -> conv env t t' && conv env u u' _ -> False
- 兩個 universe 當然可以互相轉換(注意這個語言從頭到尾都沒在管 universe level 的問題)
- 兩個 \(\Pi (x:A) \to B\) type 的檢查
- 先看兩個 \(A\) 的部分能不能轉換
- 再看統一套用一個變數
x
能不能讓兩個 \(B\ x\) 轉換 - 兩步驟都成功的話,就可以說這兩個 \(\Pi \) type 可以轉換
- 兩個 lambda 是上面的 \(\Pi \) type 的簡化版,拿掉 \(A\) 的部分就是一樣的
- lambda 跟任意 term 或是任意 term 跟 lambda 這兩種情況是對稱的,這時候可以轉換是指:
VApp u (VVar x)
跟t (VVar x)
可以轉換,當- 擴張 environment 加上
x = VVar x
- 任意 term 寫成
u
- host lambda 寫成
t
- 擴張 environment 加上
- 兩個變數是檢查它們是不是同一個變數
- 兩個卡住值的情況下,把裡面儲存的值拿出來看能不能轉換
- 走到這裡就是不能轉換
輔助程式 [tt-001E]
- November 25, 2022
- Lîm Tsú-thuàn
輔助程式 [tt-001E]
- November 25, 2022
- Lîm Tsú-thuàn
這裡就不再列出全部的列印(printing)跟解析(parsing)相關程式,主要關注對上面的程式有用途的部分。
語言的定義 [tt-001J]
- November 25, 2022
- Lîm Tsú-thuàn
語言的定義 [tt-001J]
- November 25, 2022
- Lîm Tsú-thuàn
原始語言的定義如下
type Name = String type Ty = Tm type Raw = Tm data Tm = Var Name -- x | Lam Name Tm -- \x.t | Tm :@ Tm -- t u | U -- universe | Pi Name Ty Ty -- (x : A) -> B x | Let Name Ty Tm Tm -- let x : A = t; u {- helper -} | SrcPos SourcePos Tm -- annotate source position deriving (Eq)
執行會產出的語言的定義如下,可以看到 lambda 跟 \(\Pi \) 都運用了宿主環境的函數
type VTy = Val data Val = VVar Name | VApp Val ~Val | VLam Name (Val -> Val) | VPi Name Val (Val -> Val) | VU
避免命名衝突 [tt-001K]
- November 25, 2022
- Lîm Tsú-thuàn
避免命名衝突 [tt-001K]
- November 25, 2022
- Lîm Tsú-thuàn
fresh
用在生成臨時變數時,不會引發命名衝突
fresh :: Env -> Name -> Name fresh env "_" = "_" fresh env x = case lookup x env of Just _ -> fresh env (x ++ "'") _ -> x
型別檢查的 monad [tt-001L]
- November 25, 2022
- Lîm Tsú-thuàn
型別檢查的 monad [tt-001L]
- November 25, 2022
- Lîm Tsú-thuàn
型別檢查時,下列的程式定義了檢查時的 monad 跟定位錯誤的工具
type M = Either (String, Maybe SourcePos) report :: String -> M a report s = Left (s, Nothing) addPos :: SourcePos -> M a -> M a addPos pos ma = case ma of Left (msg, Nothing) -> Left (msg, Just pos) ma -> ma
還原與正規化 [tt-001M]
- November 25, 2022
- Lîm Tsú-thuàn
還原與正規化 [tt-001M]
- November 25, 2022
- Lîm Tsú-thuàn
這主要就是為了讓執行完的程式印出來的東西可以看
quote :: Env -> Val -> Tm quote env = \case VVar x -> Var x VApp t u -> quote env t :@ quote env u VLam (fresh env -> x) t -> Lam x $ quote ((x, VVar x) : env) (t (VVar x)) VPi (fresh env -> x) a b -> Pi x (quote env a) $ quote ((x, VVar x) : env) (b (VVar x)) VU -> U nf :: Env -> Tm -> Tm nf env = quote env . eval env
Conclusion. [tt-001N]
- November 25, 2022
- Lîm Tsú-thuàn
Conclusion. [tt-001N]
- November 25, 2022
- Lîm Tsú-thuàn
除了學到 addPos
跟 withPos
的有趣小技巧之外,寫下這篇紀錄也讓我更了解 conversion check 的過程跟各個部件的用途,像是 stuck 的存在跟如何處理,或是 lambda 為什麼不共用 infer
再調用 conv
等等。希望對你也一樣有幫助。
Wasm 實用小技巧 [wasm-0008]
- November 12, 2022
- Lîm Tsú-thuàn
Wasm 實用小技巧 [wasm-0008]
- November 12, 2022
- Lîm Tsú-thuàn
最近工作上的開發,對 wasm 的實務又有了更多的掌握,同時發現 wasm 各種資訊的缺乏。很多技術細節散亂在數十個不同的網頁中,各家編譯器跟 wasm 執行環境又充斥讓人頭痛的小毛病。所以我在這裡記錄下當下各種實用的技巧。
Rust 相關的標記屬性 [wasm-0001]
- November 12, 2022
- Lîm Tsú-thuàn
Rust 相關的標記屬性 [wasm-0001]
- November 12, 2022
- Lîm Tsú-thuàn
Rust 中的各種標記對編寫能用的 wasm module 置關重要,在其他語言很多 wasm 的特性根本用不出來。 這是目前多家編譯器各自實作 wasm 的碎片問題,不是每個語言都能良好的支援新的 wasm proposal。
Example. #![feature(wasm_abi)]
跟 extern "wasm"
[wasm-0002]
- November 12, 2022
- Lîm Tsú-thuàn
Example. #![feature(wasm_abi)]
跟 extern "wasm"
[wasm-0002]
- November 12, 2022
- Lîm Tsú-thuàn
用 #![feature(wasm_abi)]
開啟特性之後,就不會發生回傳複雜型別的 extern function 被改成用 i32
參數的問題。 例如以下程式就不會被修改成 foo(i32) -> ()
,而是正常的 foo() -> i32
。
extern "wasm" { fn foo() -> StructType; }
當然,可以看到還是會被轉成用 i32
表示的指標去傳遞資料,但比之前進步很多。
Example. #[link(wasm_import_module = "mod")]
[wasm-0003]
- November 12, 2022
- Lîm Tsú-thuàn
Example. #[link(wasm_import_module = "mod")]
[wasm-0003]
- November 12, 2022
- Lîm Tsú-thuàn
用 #[link(wasm_import_module = "mod")]
修飾程式的用途是正確的引入其他模組, 舉個範例
#[link(wasm_import_module = "host")] extern "wasm" { fn host_println(str_ptr: *const u8, str_len: usize) -> (); }
用這個標記之後,它就會在 host
尋找 host_println
而不是其他名稱的模組,例如預設的模組 env
。
Example. Custom section [wasm-0004]
- November 12, 2022
- Lîm Tsú-thuàn
Example. Custom section [wasm-0004]
- November 12, 2022
- Lîm Tsú-thuàn
這可以拿來塞任何你想要的資訊,或是拿去當 buffer,缺點是除了 Rust 好像沒有編譯器有要支援。
#[link_section = "hello"] pub static SECTION: [u8; 24] = *b"This is a custom section";
WasmEdge SDK [wasm-0005]
- November 12, 2022
- Lîm Tsú-thuàn
WasmEdge SDK [wasm-0005]
- November 12, 2022
- Lîm Tsú-thuàn
要使用 wasmedge SDK,需要在 Cargo.toml
裡面加上依賴,讓 wasmedge-sys 使用 "*" 是因為兩者有對應,所以還是讓建構工具自己找出合適的依賴就好。
wasmedge-sdk = "0.6.0" wasmedge-sys = "*"
現在專案有了正確的依賴,就可以繼續開發了。
Example. Host function 傳遞字串 [wasm-0006]
- November 12, 2022
- Lîm Tsú-thuàn
Example. Host function 傳遞字串 [wasm-0006]
- November 12, 2022
- Lîm Tsú-thuàn
wasm 一個很實際的需求就是傳遞 non-primitive 的資料型別,在 WasmEdge 裡面做這件事的方法其實沒有完善的文件紀錄。 下面的程式碼是 runtime 設定
fn main() -> Result<(), anyhow::Error> { // 設定需要什麼能力 let config = ConfigBuilder::new(CommonConfigOptions::default()) .with_host_registration_config(HostRegistrationConfigOptions::default().wasi(true)) .build()?; // 建立 import object,語意是從 host 引入名為 host_suffix 的函數 let import = ImportObjectBuilder::new() .with_func::<(i32, i32), (i32, i32), !>("host_suffix", host_suffix, None)? .build("host")?; // 建立 vm 並註冊模組 let vm = Vm::new(Some(config))? .register_import_module(import)? .register_module_from_file("app", "app.wasm")?; // 執行叫做 app 模組中名叫 start 的函數並查看結果 let result = vm.run_func(Some("app"), "start", None)?; println!("result: {}", result[0].to_i32()); }
Host function 的定義如下
#[host_function] fn host_suffix(caller: Caller, input: Vec<WasmValue>) -> Result<Vec<WasmValue>, HostFuncError> { let mut mem = caller.memory(0).unwrap(); let addr = input[0].to_i32() as u32; let size = input[1].to_i32() as u32; let data = mem.read(addr, size).expect("fail to get string"); let mut s = String::from_utf8_lossy(&data).to_string(); s.push_str("_suffix"); // 總之 wasm 模組的記憶體肯定不會用到還不存在的位址 let final_addr = mem.size() + 1; // 繼續增加一個 page size 的區塊 mem.grow(1).expect("fail to grow memory"); // 把要傳回去的字串寫入位址 mem.write(s.as_bytes(), final_addr) .expect("fail to write returned string"); Ok(vec![ // 第一個回傳值是指標 WasmValue::from_i32(final_addr as i32), // 第二個回傳值是長度 WasmValue::from_i32(s.len() as i32), ]) }
在 wasm module 那邊則是寫
#![feature(wasm_abi)] #[repr(C)] struct HostString { ptr: *mut u8, size: usize, } #[link(wasm_import_module = "host")] extern "wasm" { fn host_suffix(str_ptr: *const u8, str_len: usize) -> HostString; } #[no_mangle] pub fn start() -> u32 { let s = "hello"; let s2 = unsafe { let HostString { ptr, size } = host_suffix(s.as_ptr(), s.len()); String::from_raw_parts(ptr, size, size) }; s2.len() as u32 }
可以看到 extern "wasm"
裡面 HostString
可以自動從 multi-values 復原回來。
做這個實驗的時候還發生了小插曲,我跟同事發現host_function
其實沒有正確的遵循 modifier, 所以即使你寫#[host_function] pub fn
它還是會把函數變成 private 的。
Example. Host function 存取 vm
中的 wasm module instance [wasm-0007]
- November 12, 2022
- Lîm Tsú-thuàn
Example. Host function 存取 vm
中的 wasm module instance [wasm-0007]
- November 12, 2022
- Lîm Tsú-thuàn
let cvm = Box::new(vm.clone()); let import = ImportObjectBuilder::new() .with_func::<(i32, i32), (), !>( "grow_module_memory", move |caller: CallingFrame, input: Vec<WasmValue>, _: *mut c_void| -> Result<Vec<WasmValue>, HostFuncError> { let mod_name = load_string(caller, input[0].to_i32() as u32, input[1].to_i32() as u32); let target_mod = cvm.to_owned().named_module(mod_name).unwrap(); // memory 這個名字是 LLVM 預設的生成結果 target_mod.memory("memory").unwrap().grow(1); Ok(vec![]) }, None, )?
因為不能試圖移動 vm
,只好複製出來使用。
因為又一個插曲, 所以雖然這個技巧理論上能呼叫另一個註冊模組的函數,但目前功能是殘廢的。
Conclusion. 混亂的標準支援 [wasm-0009]
- November 12, 2022
- Lîm Tsú-thuàn
Conclusion. 混亂的標準支援 [wasm-0009]
- November 12, 2022
- Lîm Tsú-thuàn
總之,這團混亂最大的問題在於 wasm proposal 對實作的要求太少,比如說宣告軟體是否符合標準。也因此支援度混亂不一,各家編譯器跟執行環境都可以喊說自己有支援,但你頭洗下去才發現其實有很多平台特定的要求跟限制。當然反過來說這表示 wasm 正在蓬勃發展,很多有用的規範正在推進,希望能夠給大家帶來更多的功能。
Strictly positive check [tt-0023]
- May 2, 2021
- Lîm Tsú-thuàn
Strictly positive check [tt-0023]
- May 2, 2021
- Lîm Tsú-thuàn
Why? [#249]
- May 2, 2021
- Lîm Tsú-thuàn
Why? [#249]
- May 2, 2021
- Lîm Tsú-thuàn
strictly positive 是 data type 中對 constructor 的一種特殊要求形成的屬性,這是因為如果一個語言可以定義出不是 strictly positive 的 data type,就可以在 type as logic 中定義出任意邏輯,形成不一致系統。
現在我們知道為什麼我們想知道一個 data type 是不是 strictly positive 了!
Example. Not Bad [#250]
- May 2, 2021
- Lîm Tsú-thuàn
Example. Not Bad [#250]
- May 2, 2021
- Lîm Tsú-thuàn
了解完 strictly positive 的必要性後,我們用例子來理解什麼是不一致的系統。這裏我假設讀者都已經知道 type as logic(program as proof) 是什麼,所以不再重複。第一個例子是 not-bad
:
data Bad bad : (Bad → Bottom) → Bad notBad : Bad → Bottom notBad (bad f) = f (bad f) isBad : Bad isBad = bad notBad absurd : Bottom absurd = notBad isBad
Bottom
(\(\bot \)) 本來應該是不可能有任何元素的,即不存在 x
滿足 x : Bottom
這個 judgement,但我們卻成功的建構出 notBad isBad : Bottom
。如此一來我們的型別對應到的邏輯系統就有了缺陷。
Example. Loop [#251]
- May 2, 2021
- Lîm Tsú-thuàn
Example. Loop [#251]
- May 2, 2021
- Lîm Tsú-thuàn
現在我們關心一下第二個例子 loop
(修改自 Certified Programming with Dependent Types):
data Term abs : (Term → Term) → Term app : Term → Term → Term app (abs f) t = f t w : Term w = abs (λ x → app x x) loop : Term loop = app w w
loop
的計算永遠都不會結束,然而證明器用到的 dependent type theory 卻允許型別依賴 loop
這樣的值,因此就能寫出讓 type checker 無法停止的程式。換句話說,證明器仰賴的性質缺失。事實上 Term
跟 Bad
的問題就是違反了 strictly positive 的性質,或許也有人已經發現了兩者 constructor 型別的相似之處。接下來我們來看為什麼這樣的定義會製造出不一致邏輯。
原理 [#252]
- May 2, 2021
- Lîm Tsú-thuàn
原理 [#252]
- May 2, 2021
- Lîm Tsú-thuàn
首先我們需要理解以下兩條規則
- \(B \subseteq B'\) 蘊含 \((A \Rightarrow B) \subseteq (A \Rightarrow B')\)
- \(A \subseteq A'\) 蘊含 \((A \Rightarrow B) \supseteq (A' \Rightarrow B)\)
根據這兩條規則,我們說 arrow types \(A \Rightarrow B\) 是 covariant in B 和 contravariant in A,或是說 A varies negatively 以及 B varies positively in \(A \Rightarrow B\)
所以我們稱 \(A\) 為 negative position、\(B\) 為 positive position,最後擴展到 \(\Pi \) type。至此我們有足夠的資訊來實作了,來看怎麼完成吧!
實作 [#253]
- May 2, 2021
- Lîm Tsú-thuàn
實作 [#253]
- May 2, 2021
- Lîm Tsú-thuàn
首先我們先訂出 data type 的語法框架,然後其中填上檢查程式:假設 constructor 會把其型別去糖,並假設有 check 函數。
(define-syntax-parser data [(_ name:id c*:constructor ...) (for ([c (attribute c*.desugar-type)]) (check #'name c)) #''ok])
接著補上型別依賴的語法,以及把型別帶來的隱式依賴展開,讓 check
檢查到完整的型別。注:這裏的實作其實不是有用到才展開,但剛好我們要舉的例子都沒有踩到這個問題,所以我懶得修正了,讀者實作的時候自己注意一下。
(define-syntax-parser data ; ... [(_ (name:id d*:bind ...) c*:constructor ...) (for ([c (attribute c*.desugar-type)]) (check #'name (foldr (λ (n r) (n r)) c (attribute d*.lam)))) #''ok])
接著我們來看各個 syntax-class
的定義
- pattern 就語法
- lam 把 bind 展開成準 \(\Pi \) type(需要 apply 後才是 \(\Pi \) type)
- desugar-type 把前面的 bind 都套上最後的型別,完成展開
(begin-for-syntax (define-syntax-class type (pattern ty #:attr val (syntax->datum #'ty))) (define-syntax-class bind (pattern (name:id : ty:type) #:attr lam (λ (t) (Pi (syntax->datum #'name) (attribute ty.val) t)))) (define-syntax-class constructor (pattern (name b*:bind ... : ty:type) #:attr desugar-type (foldr (λ (n r) (n r)) (attribute ty.val) (attribute b*.lam)))))
最後則是重頭戲:檢查。我們會假設 constructor 的 type 是 positive 來開始,規則如下:
- 箭頭或是 \(\Pi \) 的左邊跟箭頭或是 \(\Pi \) 本身的屬性相反(i.e. \(\Pi \) 本身是正則左邊是負,反之亦然)
- 箭頭或是 \(\Pi \) 的右邊跟箭頭或是 \(\Pi \) 本身的屬性相同
- endofunctor 不需要繼續檢查下去
(begin-for-syntax (struct Pi (name t1 t2) #:transparent) ; strictly positive check ; @name: name of data type ; @c: type of constructor (define (check name c [positive? #true]) (define n (syntax->datum name)) (define (check-left-right t1 t2) (cond ; endofunctors are positive [(equal? t1 t2) (void)] ; self at negative [(and (equal? (if (symbol? t1) t1 (first t1)) n) (not positive?)) (raise-syntax-error 'negative "bad data type" name)]) (check name t1 (not positive?)) (check name t2 positive?)) (match c [(or (Pi _ t1 t2) `(-> ,t1 ,t2)) (check-left-right t1 t2)] [x (void)]))
結語 [#254]
- May 2, 2021
- Lîm Tsú-thuàn
結語 [#254]
- May 2, 2021
- Lîm Tsú-thuàn
文章到這邊告一段落,也解決了我這一年來對證明器實作的最大疑問之一,進一步的解答可以參考 https://cs.stackexchange.com/questions/55646/strict-positivity/55674#55674
Mark sweep GC [cs-000F]
- September 3, 2018
- Lîm Tsú-thuàn
Mark sweep GC [cs-000F]
- September 3, 2018
- Lîm Tsú-thuàn
Mark-Sweep is a classic GC algorithm, it's combined with two parts, mark and sweep.
mark(root): if not marked?(root): mark(root) for obj in knowns(root): mark(obj)
sweep(heap): for obj in heap: if marked?(obj): unmark(obj) else: release(obj)
If we run collection
(mark-sweep), then since each object is reachable from root
, so no one would be released.
After do some executions, obj1
don't need obj3
anymore, so it became:
Now when we run collection
, obj3
is unreachable from root, so it won't be marked! When running to sweep, it will be dropped.
Polarized-system-f [org-0002]
- July 22, 2023
- Lîm Tsú-thuàn
- 2023-07-22-polarized-system-f.html
Polarized-system-f [org-0002]
- July 22, 2023
- Lîm Tsú-thuàn
- 2023-07-22-polarized-system-f.html
High-performance-graph [org-0004]
- June 28, 2023
- Lîm Tsú-thuàn
- 2023-06-28-high-performance-graph.html
High-performance-graph [org-0004]
- June 28, 2023
- Lîm Tsú-thuàn
- 2023-06-28-high-performance-graph.html
Recur-interpreter [org-0005]
- June 22, 2023
- Lîm Tsú-thuàn
- 2023-06-22-recur-interpreter.html
Recur-interpreter [org-0005]
- June 22, 2023
- Lîm Tsú-thuàn
- 2023-06-22-recur-interpreter.html
Arm64-store-load [org-0009]
- June 4, 2023
- Lîm Tsú-thuàn
- 2023-06-04-arm64-store-load.html
Arm64-store-load [org-0009]
- June 4, 2023
- Lîm Tsú-thuàn
- 2023-06-04-arm64-store-load.html
Dafny-lang [org-000B]
- May 17, 2023
- Lîm Tsú-thuàn
- 2023-05-17-dafny-lang.html
Dafny-lang [org-000B]
- May 17, 2023
- Lîm Tsú-thuàn
- 2023-05-17-dafny-lang.html
The-power-of-oop-and-abstraction [org-000D]
The-power-of-oop-and-abstraction [org-000D]
Pythagorean-triples [org-000E]
- April 16, 2023
- Lîm Tsú-thuàn
- 2023-04-16-pythagorean-triples.html
Pythagorean-triples [org-000E]
- April 16, 2023
- Lîm Tsú-thuàn
- 2023-04-16-pythagorean-triples.html
[PL] STLC 的 categorical semantic [org-000H]
- March 16, 2023
- Lîm Tsú-thuàn
- 2023-03-16-stlc-categorial-semantic.html
[PL] STLC 的 categorical semantic [org-000H]
- March 16, 2023
- Lîm Tsú-thuàn
- 2023-03-16-stlc-categorial-semantic.html
Prime-inf-topology [org-000I]
- March 7, 2023
- Lîm Tsú-thuàn
- 2023-03-07-prime-inf-topology.html
Prime-inf-topology [org-000I]
- March 7, 2023
- Lîm Tsú-thuàn
- 2023-03-07-prime-inf-topology.html
Genetic-algorithm [org-000L]
- January 31, 2023
- Lîm Tsú-thuàn
- 2023-01-31-genetic-algorithm.html
Genetic-algorithm [org-000L]
- January 31, 2023
- Lîm Tsú-thuàn
- 2023-01-31-genetic-algorithm.html
Idris2-nix [org-000M]
- January 1, 2023
- Lîm Tsú-thuàn
- 2023-01-01-idris2-nix.html
Idris2-nix [org-000M]
- January 1, 2023
- Lîm Tsú-thuàn
- 2023-01-01-idris2-nix.html
Note: resource algebra [org-000O]
- December 19, 2022
- Lîm Tsú-thuàn
- 2022-12-19-note-resource.html
Note: resource algebra [org-000O]
- December 19, 2022
- Lîm Tsú-thuàn
- 2022-12-19-note-resource.html
Gcd [org-000P]
- December 9, 2022
- Lîm Tsú-thuàn
- 2022-12-09-gcd.html
Gcd [org-000P]
- December 9, 2022
- Lîm Tsú-thuàn
- 2022-12-09-gcd.html
Rust-wasm-abi [org-000Q]
- December 8, 2022
- Lîm Tsú-thuàn
- 2022-12-08-rust-wasm-abi.html
Rust-wasm-abi [org-000Q]
- December 8, 2022
- Lîm Tsú-thuàn
- 2022-12-08-rust-wasm-abi.html
Concurrent-functional-programming [org-000R]
- December 7, 2022
- Lîm Tsú-thuàn
- 2022-12-07-concurrent-functional-programming.html
Concurrent-functional-programming [org-000R]
- December 7, 2022
- Lîm Tsú-thuàn
- 2022-12-07-concurrent-functional-programming.html
Pos-annotation [org-000S]
- December 6, 2022
- Lîm Tsú-thuàn
- 2022-12-06-pos-annotation.html
Pos-annotation [org-000S]
- December 6, 2022
- Lîm Tsú-thuàn
- 2022-12-06-pos-annotation.html
Note-hls-m1-problem [org-000U]
- November 30, 2022
- Lîm Tsú-thuàn
- 2022-11-30-note-hls-m1-problem.html
Note-hls-m1-problem [org-000U]
- November 30, 2022
- Lîm Tsú-thuàn
- 2022-11-30-note-hls-m1-problem.html
Induction-proof-operation [org-000W]
- November 20, 2022
- Lîm Tsú-thuàn
- 2022-11-20-induction-proof-operation.html
Induction-proof-operation [org-000W]
- November 20, 2022
- Lîm Tsú-thuàn
- 2022-11-20-induction-proof-operation.html
Layering [org-0011]
- November 3, 2022
- Lîm Tsú-thuàn
- 2022-11-03-layering.html
Layering [org-0011]
- November 3, 2022
- Lîm Tsú-thuàn
- 2022-11-03-layering.html
Polymorphism-in-runtime [org-0010]
- November 3, 2022
- Lîm Tsú-thuàn
- 2022-11-03-polymorphism-in-runtime.html
Polymorphism-in-runtime [org-0010]
- November 3, 2022
- Lîm Tsú-thuàn
- 2022-11-03-polymorphism-in-runtime.html
Leftist-tree [org-0013]
- October 30, 2022
- Lîm Tsú-thuàn
- 2022-10-30-leftist-tree.html
Leftist-tree [org-0013]
- October 30, 2022
- Lîm Tsú-thuàn
- 2022-10-30-leftist-tree.html
Note-effect-system-koka [org-0015]
- October 18, 2022
- Lîm Tsú-thuàn
- 2022-10-18-note-effect-system-koka.html
Note-effect-system-koka [org-0015]
- October 18, 2022
- Lîm Tsú-thuàn
- 2022-10-18-note-effect-system-koka.html
Note-product [org-0014]
- October 18, 2022
- Lîm Tsú-thuàn
- 2022-10-18-note-product.html
Note-product [org-0014]
- October 18, 2022
- Lîm Tsú-thuàn
- 2022-10-18-note-product.html
Picopass [org-0017]
- September 17, 2022
- Lîm Tsú-thuàn
- 2022-09-17-picopass.html
Picopass [org-0017]
- September 17, 2022
- Lîm Tsú-thuàn
- 2022-09-17-picopass.html
Practical-de-bruijn [org-0019]
- September 4, 2022
- Lîm Tsú-thuàn
- 2022-09-04-practical-de-bruijn.html
Practical-de-bruijn [org-0019]
- September 4, 2022
- Lîm Tsú-thuàn
- 2022-09-04-practical-de-bruijn.html
Ref-eq [org-0018]
- September 4, 2022
- Lîm Tsú-thuàn
- 2022-09-04-ref-eq.html
Ref-eq [org-0018]
- September 4, 2022
- Lîm Tsú-thuàn
- 2022-09-04-ref-eq.html
Racket-future [org-001A]
- September 3, 2022
- Lîm Tsú-thuàn
- 2022-09-03-racket-future.html
Racket-future [org-001A]
- September 3, 2022
- Lîm Tsú-thuàn
- 2022-09-03-racket-future.html
Dependent-type [org-001B]
- September 1, 2022
- Lîm Tsú-thuàn
- 2022-09-01-dependent-type.html
Dependent-type [org-001B]
- September 1, 2022
- Lîm Tsú-thuàn
- 2022-09-01-dependent-type.html
Ee-lib [org-001C]
- August 28, 2022
- Lîm Tsú-thuàn
- 2022-08-28-ee-lib.html
Ee-lib [org-001C]
- August 28, 2022
- Lîm Tsú-thuàn
- 2022-08-28-ee-lib.html
Typed-racket-intro [org-001D]
- August 19, 2022
- Lîm Tsú-thuàn
- 2022-08-19-typed-racket-intro.html
Typed-racket-intro [org-001D]
- August 19, 2022
- Lîm Tsú-thuàn
- 2022-08-19-typed-racket-intro.html
Racket-preference-test [org-001E]
- August 4, 2022
- Lîm Tsú-thuàn
- 2022-08-04-racket-preference-test.html
Racket-preference-test [org-001E]
- August 4, 2022
- Lîm Tsú-thuàn
- 2022-08-04-racket-preference-test.html
Sauron-dev-log [org-001F]
- July 25, 2022
- Lîm Tsú-thuàn
- 2022-07-25-sauron-dev-log.html
Sauron-dev-log [org-001F]
- July 25, 2022
- Lîm Tsú-thuàn
- 2022-07-25-sauron-dev-log.html
Leibniz-product-rule [org-001J]
- June 30, 2022
- Lîm Tsú-thuàn
- 2022-06-30-leibniz-product-rule.html
Leibniz-product-rule [org-001J]
- June 30, 2022
- Lîm Tsú-thuàn
- 2022-06-30-leibniz-product-rule.html
Set-theoretic-type-difference [org-001K]
- June 28, 2022
- Lîm Tsú-thuàn
- 2022-06-28-set-theoretic-type-difference.html
Set-theoretic-type-difference [org-001K]
- June 28, 2022
- Lîm Tsú-thuàn
- 2022-06-28-set-theoretic-type-difference.html
Common-patterns-in-nanopass [org-001L]
- June 16, 2022
- Lîm Tsú-thuàn
- 2022-06-16-common-patterns-in-nanopass.html
Common-patterns-in-nanopass [org-001L]
- June 16, 2022
- Lîm Tsú-thuàn
- 2022-06-16-common-patterns-in-nanopass.html
Riemann-integral [org-001M]
- June 3, 2022
- Lîm Tsú-thuàn
- 2022-06-03-riemann-integral.html
Riemann-integral [org-001M]
- June 3, 2022
- Lîm Tsú-thuàn
- 2022-06-03-riemann-integral.html
Closure-conversion [org-001N]
- March 21, 2022
- Lîm Tsú-thuàn
- 2022-03-21-closure-conversion.html
Closure-conversion [org-001N]
- March 21, 2022
- Lîm Tsú-thuàn
- 2022-03-21-closure-conversion.html
Ordered-field [org-001O]
- March 4, 2022
- Lîm Tsú-thuàn
- 2022-03-04-ordered-field.html
Ordered-field [org-001O]
- March 4, 2022
- Lîm Tsú-thuàn
- 2022-03-04-ordered-field.html
64Bits-encoding [org-001P]
- February 19, 2022
- Lîm Tsú-thuàn
- 2022-02-19-64bits-encoding.html
64Bits-encoding [org-001P]
- February 19, 2022
- Lîm Tsú-thuàn
- 2022-02-19-64bits-encoding.html
Macro [org-001T]
- January 30, 2022
- Lîm Tsú-thuàn
- 2022-01-30-macro.html
Macro [org-001T]
- January 30, 2022
- Lîm Tsú-thuàn
- 2022-01-30-macro.html
Ssh-to-my-nixos [org-001U]
- January 21, 2022
- Lîm Tsú-thuàn
- 2022-01-21-ssh-to-my-nixos.html
Ssh-to-my-nixos [org-001U]
- January 21, 2022
- Lîm Tsú-thuàn
- 2022-01-21-ssh-to-my-nixos.html
Chez-scheme-and-lib [org-001Z]
- January 14, 2022
- Lîm Tsú-thuàn
- 2022-01-14-chez-scheme-and-lib.html
Chez-scheme-and-lib [org-001Z]
- January 14, 2022
- Lîm Tsú-thuàn
- 2022-01-14-chez-scheme-and-lib.html
Arduino-zig-7-seg-display [org-0021]
- January 10, 2022
- Lîm Tsú-thuàn
- 2022-01-10-arduino-zig-7-seg-display.html
Arduino-zig-7-seg-display [org-0021]
- January 10, 2022
- Lîm Tsú-thuàn
- 2022-01-10-arduino-zig-7-seg-display.html
Forth-aarch64 [org-0022]
- January 8, 2022
- Lîm Tsú-thuàn
- 2022-01-08-forth-aarch64.html
Forth-aarch64 [org-0022]
- January 8, 2022
- Lîm Tsú-thuàn
- 2022-01-08-forth-aarch64.html
Note-nix-command [org-0024]
- January 6, 2022
- Lîm Tsú-thuàn
- 2022-01-06-note-nix-command.html
Note-nix-command [org-0024]
- January 6, 2022
- Lîm Tsú-thuàn
- 2022-01-06-note-nix-command.html
Arduino-zig-blink [org-0025]
- January 4, 2022
- Lîm Tsú-thuàn
- 2022-01-04-arduino-zig-blink.html
Arduino-zig-blink [org-0025]
- January 4, 2022
- Lîm Tsú-thuàn
- 2022-01-04-arduino-zig-blink.html
Julia-macrotools [org-0027]
- December 11, 2021
- Lîm Tsú-thuàn
- 2021-12-11-julia-macrotools.html
Julia-macrotools [org-0027]
- December 11, 2021
- Lîm Tsú-thuàn
- 2021-12-11-julia-macrotools.html
Invent-rectangle-area-formula [org-0029]
- October 8, 2021
- Lîm Tsú-thuàn
- 2021-10-08-invent-rectangle-area-formula.html
Invent-rectangle-area-formula [org-0029]
- October 8, 2021
- Lîm Tsú-thuàn
- 2021-10-08-invent-rectangle-area-formula.html
Syntax-property-and-local-expand [org-002B]
- August 19, 2021
- Lîm Tsú-thuàn
- 2021-08-19-syntax-property-and-local-expand.html
Syntax-property-and-local-expand [org-002B]
- August 19, 2021
- Lîm Tsú-thuàn
- 2021-08-19-syntax-property-and-local-expand.html
Elixir-with [org-002C]
- July 17, 2021
- Lîm Tsú-thuàn
- 2021-07-17-elixir-with.html
Elixir-with [org-002C]
- July 17, 2021
- Lîm Tsú-thuàn
- 2021-07-17-elixir-with.html
Elixir-phoenix-graphql [org-002F]
- July 6, 2021
- Lîm Tsú-thuàn
- 2021-07-06-elixir-phoenix-graphql.html
Elixir-phoenix-graphql [org-002F]
- July 6, 2021
- Lîm Tsú-thuàn
- 2021-07-06-elixir-phoenix-graphql.html
Find-max-subsubsquence [org-002G]
- July 3, 2021
- Lîm Tsú-thuàn
- 2021-07-03-find-max-subsubsquence.html
Find-max-subsubsquence [org-002G]
- July 3, 2021
- Lîm Tsú-thuàn
- 2021-07-03-find-max-subsubsquence.html
Vscode-remote-pack [org-002H]
- June 18, 2021
- Lîm Tsú-thuàn
- 2021-06-18-vscode-remote-pack.html
Vscode-remote-pack [org-002H]
- June 18, 2021
- Lîm Tsú-thuàn
- 2021-06-18-vscode-remote-pack.html
Lexer-and-parser [org-002I]
- June 4, 2021
- Lîm Tsú-thuàn
- 2021-06-04-lexer-and-parser.html
Lexer-and-parser [org-002I]
- June 4, 2021
- Lîm Tsú-thuàn
- 2021-06-04-lexer-and-parser.html
Sexp-macro-and-develop [org-002J]
- May 11, 2021
- Lîm Tsú-thuàn
- 2021-05-11-sexp-macro-and-develop.html
Sexp-macro-and-develop [org-002J]
- May 11, 2021
- Lîm Tsú-thuàn
- 2021-05-11-sexp-macro-and-develop.html
Un-delimited-continuation [org-002N]
- March 13, 2021
- Lîm Tsú-thuàn
- 2021-03-13-un-delimited-continuation.html
Un-delimited-continuation [org-002N]
- March 13, 2021
- Lîm Tsú-thuàn
- 2021-03-13-un-delimited-continuation.html
Sphere-is-convex [org-002O]
- March 10, 2021
- Lîm Tsú-thuàn
- 2021-03-10-sphere-is-convex.html
Sphere-is-convex [org-002O]
- March 10, 2021
- Lîm Tsú-thuàn
- 2021-03-10-sphere-is-convex.html
Note-nix-home-manager [org-002Q]
- February 12, 2021
- Lîm Tsú-thuàn
- 2021-02-12-note-nix-home-manager.html
Note-nix-home-manager [org-002Q]
- February 12, 2021
- Lîm Tsú-thuàn
- 2021-02-12-note-nix-home-manager.html
Nixos-install [org-002R]
- February 4, 2021
- Lîm Tsú-thuàn
- 2021-02-04-nixos-install.html
Nixos-install [org-002R]
- February 4, 2021
- Lîm Tsú-thuàn
- 2021-02-04-nixos-install.html
Summary [org-002S]
- January 29, 2021
- Lîm Tsú-thuàn
- 2021-01-29-summary.html
Summary [org-002S]
- January 29, 2021
- Lîm Tsú-thuàn
- 2021-01-29-summary.html
Installation [org-002T]
- January 19, 2021
- Lîm Tsú-thuàn
- 2021-01-19-installation.html
Installation [org-002T]
- January 19, 2021
- Lîm Tsú-thuàn
- 2021-01-19-installation.html
Termination-check [org-002U]
- January 13, 2021
- Lîm Tsú-thuàn
- 2021-01-13-termination-check.html
Termination-check [org-002U]
- January 13, 2021
- Lîm Tsú-thuàn
- 2021-01-13-termination-check.html
Subtle-racket-macro [org-002V]
- January 7, 2021
- Lîm Tsú-thuàn
- 2021-01-07-subtle-racket-macro.html
Subtle-racket-macro [org-002V]
- January 7, 2021
- Lîm Tsú-thuàn
- 2021-01-07-subtle-racket-macro.html
Imperative-semantic [org-002W]
- December 22, 2020
- Lîm Tsú-thuàn
- 2020-12-22-imperative-semantic.html
Imperative-semantic [org-002W]
- December 22, 2020
- Lîm Tsú-thuàn
- 2020-12-22-imperative-semantic.html
Recommend-books [org-002X]
- December 20, 2020
- Lîm Tsú-thuàn
- 2020-12-20-recommend-books.html
Recommend-books [org-002X]
- December 20, 2020
- Lîm Tsú-thuàn
- 2020-12-20-recommend-books.html
Is-an-oop-square-ra-rectangle [org-002Z]
- November 16, 2020
- Lîm Tsú-thuàn
- 2020-11-16-is-an-oop-square-ra-rectangle.html
Is-an-oop-square-ra-rectangle [org-002Z]
- November 16, 2020
- Lîm Tsú-thuàn
- 2020-11-16-is-an-oop-square-ra-rectangle.html
Summary [org-002Y]
- November 16, 2020
- Lîm Tsú-thuàn
- 2020-11-16-summary.html
Summary [org-002Y]
- November 16, 2020
- Lîm Tsú-thuàn
- 2020-11-16-summary.html
Note-lambda-cube [org-0030]
- September 17, 2020
- Lîm Tsú-thuàn
- 2020-09-17-note-lambda-cube.html
Note-lambda-cube [org-0030]
- September 17, 2020
- Lîm Tsú-thuàn
- 2020-09-17-note-lambda-cube.html
Scribble-and-xelatex [org-0031]
- September 1, 2020
- Lîm Tsú-thuàn
- 2020-09-01-scribble-and-xelatex.html
Scribble-and-xelatex [org-0031]
- September 1, 2020
- Lîm Tsú-thuàn
- 2020-09-01-scribble-and-xelatex.html
Racket-macro-define-where [org-0032]
- August 23, 2020
- Lîm Tsú-thuàn
- 2020-08-23-racket-macro-define-where.html
Racket-macro-define-where [org-0032]
- August 23, 2020
- Lîm Tsú-thuàn
- 2020-08-23-racket-macro-define-where.html
Note-coq-tactics [org-0033]
- August 19, 2020
- Lîm Tsú-thuàn
- 2020-08-19-note-coq-tactics.html
Note-coq-tactics [org-0033]
- August 19, 2020
- Lîm Tsú-thuàn
- 2020-08-19-note-coq-tactics.html
Infinite-how-big [org-0034]
- August 7, 2020
- Lîm Tsú-thuàn
- 2020-08-07-infinite-how-big.html
Infinite-how-big [org-0034]
- August 7, 2020
- Lîm Tsú-thuàn
- 2020-08-07-infinite-how-big.html
Note-bad-idea-s-exp-haskell [org-0036]
- July 31, 2020
- Lîm Tsú-thuàn
- 2020-07-31-note-bad-idea-s-exp-haskell.html
Note-bad-idea-s-exp-haskell [org-0036]
- July 31, 2020
- Lîm Tsú-thuàn
- 2020-07-31-note-bad-idea-s-exp-haskell.html
Note-racket-gui-framework-and-editor [org-0037]
Note-racket-gui-framework-and-editor [org-0037]
How-to-find-mk-fixed-point [org-0038]
- July 26, 2020
- Lîm Tsú-thuàn
- 2020-07-26-how-to-find-mk-fixed-point.html
How-to-find-mk-fixed-point [org-0038]
- July 26, 2020
- Lîm Tsú-thuàn
- 2020-07-26-how-to-find-mk-fixed-point.html
Why-logic-programming [org-0039]
- July 15, 2020
- Lîm Tsú-thuàn
- 2020-07-15-why-logic-programming.html
Why-logic-programming [org-0039]
- July 15, 2020
- Lîm Tsú-thuàn
- 2020-07-15-why-logic-programming.html
Recommend-novel-quality-land [org-003B]
Recommend-novel-quality-land [org-003B]
Algorithm-order [org-003C]
- June 20, 2020
- Lîm Tsú-thuàn
- 2020-06-20-algorithm-order.html
Algorithm-order [org-003C]
- June 20, 2020
- Lîm Tsú-thuàn
- 2020-06-20-algorithm-order.html
Recipe-okonomiyaki [org-003D]
- June 17, 2020
- Lîm Tsú-thuàn
- 2020-06-17-recipe-okonomiyaki.html
Recipe-okonomiyaki [org-003D]
- June 17, 2020
- Lîm Tsú-thuàn
- 2020-06-17-recipe-okonomiyaki.html
Note-zfc [org-003F]
- June 11, 2020
- Lîm Tsú-thuàn
- 2020-06-11-note-zfc.html
Note-zfc [org-003F]
- June 11, 2020
- Lîm Tsú-thuàn
- 2020-06-11-note-zfc.html
Currying [org-003I]
- May 31, 2020
- Lîm Tsú-thuàn
- 2020-05-31-currying.html
Currying [org-003I]
- May 31, 2020
- Lîm Tsú-thuàn
- 2020-05-31-currying.html
Set-theory-three-paradox [org-003H]
- May 31, 2020
- Lîm Tsú-thuàn
- 2020-05-31-set-theory-three-paradox.html
Set-theory-three-paradox [org-003H]
- May 31, 2020
- Lîm Tsú-thuàn
- 2020-05-31-set-theory-three-paradox.html
Hindley-milner-system-incremental-build-and-make-new-language [org-003J]
Hindley-milner-system-incremental-build-and-make-new-language [org-003J]
De-bruijn-index [org-003K]
- May 16, 2020
- Lîm Tsú-thuàn
- 2020-05-16-de-bruijn-index.html
De-bruijn-index [org-003K]
- May 16, 2020
- Lîm Tsú-thuàn
- 2020-05-16-de-bruijn-index.html
Programming-life-retro [org-003L]
- May 13, 2020
- Lîm Tsú-thuàn
- 2020-05-13-programming-life-retro.html
Programming-life-retro [org-003L]
- May 13, 2020
- Lîm Tsú-thuàn
- 2020-05-13-programming-life-retro.html
Algorithm-time-complexity [org-003M]
- May 12, 2020
- Lîm Tsú-thuàn
- 2020-05-12-algorithm-time-complexity.html
Algorithm-time-complexity [org-003M]
- May 12, 2020
- Lîm Tsú-thuàn
- 2020-05-12-algorithm-time-complexity.html
Spaghetti [org-003N]
- May 10, 2020
- Lîm Tsú-thuàn
- 2020-05-10-spaghetti.html
Spaghetti [org-003N]
- May 10, 2020
- Lîm Tsú-thuàn
- 2020-05-10-spaghetti.html
A-beautiful-proof-there-have-infinite-primes [org-003O]
A-beautiful-proof-there-have-infinite-primes [org-003O]
How-to-parse-expression-with-parser-combinator [org-003P]
How-to-parse-expression-with-parser-combinator [org-003P]
Abstraction-of-programming-design-2-user-interface [org-003Q]
Abstraction-of-programming-design-2-user-interface [org-003Q]
Note-how-to-install-nix-on-macos-catalina [org-003R]
Note-how-to-install-nix-on-macos-catalina [org-003R]
Note-cpp-member-initialize-order [org-003S]
- April 13, 2020
- Lîm Tsú-thuàn
- 2020-04-13-note-cpp-member-initialize-order.html
Note-cpp-member-initialize-order [org-003S]
- April 13, 2020
- Lîm Tsú-thuàn
- 2020-04-13-note-cpp-member-initialize-order.html
From-functor-to-applicative [org-003T]
- April 11, 2020
- Lîm Tsú-thuàn
- 2020-04-11-from-functor-to-applicative.html
From-functor-to-applicative [org-003T]
- April 11, 2020
- Lîm Tsú-thuàn
- 2020-04-11-from-functor-to-applicative.html
Note-seven-bridges-of-konigsberg-eulerian-path [org-003U]
Note-seven-bridges-of-konigsberg-eulerian-path [org-003U]
Recommend-novel-skyward [org-003V]
- April 1, 2020
- Lîm Tsú-thuàn
- 2020-04-01-recommend-novel-skyward.html
Recommend-novel-skyward [org-003V]
- April 1, 2020
- Lîm Tsú-thuàn
- 2020-04-01-recommend-novel-skyward.html
Binary-encoding-of-interger [org-003W]
- March 21, 2020
- Lîm Tsú-thuàn
- 2020-03-21-binary-encoding-of-interger.html
Binary-encoding-of-interger [org-003W]
- March 21, 2020
- Lîm Tsú-thuàn
- 2020-03-21-binary-encoding-of-interger.html
A-racket-macro-tutorial-get-http-parameters-easier [org-003Y]
A-racket-macro-tutorial-get-http-parameters-easier [org-003Y]
Suggested-languages [org-003Z]
- February 6, 2020
- Lîm Tsú-thuàn
- 2020-02-06-suggested-languages.html
Suggested-languages [org-003Z]
- February 6, 2020
- Lîm Tsú-thuàn
- 2020-02-06-suggested-languages.html
Last-time-complain-about-go [org-0043]
- January 19, 2020
- Lîm Tsú-thuàn
- 2020-01-19-last-time-complain-about-go.html
Last-time-complain-about-go [org-0043]
- January 19, 2020
- Lîm Tsú-thuàn
- 2020-01-19-last-time-complain-about-go.html
Type-as-constraint-why-we-need-more-type [org-0044]
- January 16, 2020
- Lîm Tsú-thuàn
- 2020-01-16-type-as-constraint-why-we-need-more-type.html
Type-as-constraint-why-we-need-more-type [org-0044]
- January 16, 2020
- Lîm Tsú-thuàn
- 2020-01-16-type-as-constraint-why-we-need-more-type.html
Note-what-is-lambda-calculus [org-0047]
- January 1, 2020
- Lîm Tsú-thuàn
- 2020-01-01-note-what-is-lambda-calculus.html
Note-what-is-lambda-calculus [org-0047]
- January 1, 2020
- Lîm Tsú-thuàn
- 2020-01-01-note-what-is-lambda-calculus.html
Interaction-with-c-in-zig [org-0048]
- December 22, 2019
- Lîm Tsú-thuàn
- 2019-12-22-interaction-with-c-in-zig.html
Interaction-with-c-in-zig [org-0048]
- December 22, 2019
- Lîm Tsú-thuàn
- 2019-12-22-interaction-with-c-in-zig.html
Note-get-labels-from-pod [org-0049]
- December 20, 2019
- Lîm Tsú-thuàn
- 2019-12-20-note-get-labels-from-pod.html
Note-get-labels-from-pod [org-0049]
- December 20, 2019
- Lîm Tsú-thuàn
- 2019-12-20-note-get-labels-from-pod.html
From-infinite-type-to-functor [org-004C]
- December 13, 2019
- Lîm Tsú-thuàn
- 2019-12-13-from-infinite-type-to-functor.html
From-infinite-type-to-functor [org-004C]
- December 13, 2019
- Lîm Tsú-thuàn
- 2019-12-13-from-infinite-type-to-functor.html
Infinite-type [org-004D]
- December 8, 2019
- Lîm Tsú-thuàn
- 2019-12-08-infinite-type.html
Infinite-type [org-004D]
- December 8, 2019
- Lîm Tsú-thuàn
- 2019-12-08-infinite-type.html
Mergeable-replicated-data-types [org-004G]
- November 30, 2019
- Lîm Tsú-thuàn
- 2019-11-30-mergeable-replicated-data-types.html
Mergeable-replicated-data-types [org-004G]
- November 30, 2019
- Lîm Tsú-thuàn
- 2019-11-30-mergeable-replicated-data-types.html
Abstraction-of-programming-design [org-004J]
- November 9, 2019
- Lîm Tsú-thuàn
- 2019-11-09-abstraction-of-programming-design.html
Abstraction-of-programming-design [org-004J]
- November 9, 2019
- Lîm Tsú-thuàn
- 2019-11-09-abstraction-of-programming-design.html
How-to-use-gitignore [org-004K]
- November 8, 2019
- Lîm Tsú-thuàn
- 2019-11-08-how-to-use-gitignore.html
How-to-use-gitignore [org-004K]
- November 8, 2019
- Lîm Tsú-thuàn
- 2019-11-08-how-to-use-gitignore.html
Weird-behavior-gob [org-004L]
- October 31, 2019
- Lîm Tsú-thuàn
- 2019-10-31-weird-behavior-gob.html
Weird-behavior-gob [org-004L]
- October 31, 2019
- Lîm Tsú-thuàn
- 2019-10-31-weird-behavior-gob.html
Dpdk-usertools-devbind [org-004M]
- October 19, 2019
- Lîm Tsú-thuàn
- 2019-10-19-dpdk-usertools-devbind.html
Dpdk-usertools-devbind [org-004M]
- October 19, 2019
- Lîm Tsú-thuàn
- 2019-10-19-dpdk-usertools-devbind.html
Dpdk-input-output-error [org-004N]
- October 18, 2019
- Lîm Tsú-thuàn
- 2019-10-18-dpdk-input-output-error.html
Dpdk-input-output-error [org-004N]
- October 18, 2019
- Lîm Tsú-thuàn
- 2019-10-18-dpdk-input-output-error.html
Nix-report [org-004P]
- September 12, 2019
- Lîm Tsú-thuàn
- 2019-09-12-nix-report.html
Nix-report [org-004P]
- September 12, 2019
- Lîm Tsú-thuàn
- 2019-09-12-nix-report.html
Privileged-pod [org-004Q]
- September 1, 2019
- Lîm Tsú-thuàn
- 2019-09-01-privileged-pod.html
Privileged-pod [org-004Q]
- September 1, 2019
- Lîm Tsú-thuàn
- 2019-09-01-privileged-pod.html
Cgo-can-be-a-trouble [org-004R]
- August 15, 2019
- Lîm Tsú-thuàn
- 2019-08-15-cgo-can-be-a-trouble.html
Cgo-can-be-a-trouble [org-004R]
- August 15, 2019
- Lîm Tsú-thuàn
- 2019-08-15-cgo-can-be-a-trouble.html
Ruby-conf-taiwan-2019 [org-004S]
- August 13, 2019
- Lîm Tsú-thuàn
- 2019-08-13-ruby-conf-taiwan-2019.html
Ruby-conf-taiwan-2019 [org-004S]
- August 13, 2019
- Lîm Tsú-thuàn
- 2019-08-13-ruby-conf-taiwan-2019.html
How-lifetime-trait-can-be-trouble-and-how-to-fix-it [org-004T]
How-lifetime-trait-can-be-trouble-and-how-to-fix-it [org-004T]
Tcpdump-cheat-sheet [org-004U]
- June 25, 2019
- Lîm Tsú-thuàn
- 2019-06-25-tcpdump-cheat-sheet.html
Tcpdump-cheat-sheet [org-004U]
- June 25, 2019
- Lîm Tsú-thuàn
- 2019-06-25-tcpdump-cheat-sheet.html
Simple-way-to-ensure-go-interface-wont-be-implement-accidently [org-004V]
Simple-way-to-ensure-go-interface-wont-be-implement-accidently [org-004V]
Golang-concurrency-bug-i-made [org-004W]
Golang-concurrency-bug-i-made [org-004W]
Kubernetes-networking-concept-and-overview [org-004X]
Kubernetes-networking-concept-and-overview [org-004X]
Hugepages-on-kubernetes [org-004Y]
- May 4, 2019
- Lîm Tsú-thuàn
- 2019-05-04-hugepages-on-kubernetes.html
Hugepages-on-kubernetes [org-004Y]
- May 4, 2019
- Lîm Tsú-thuàn
- 2019-05-04-hugepages-on-kubernetes.html
Five-tools-for-file-transfer [org-004Z]
- April 27, 2019
- Lîm Tsú-thuàn
- 2019-04-27-five-tools-for-file-transfer.html
Five-tools-for-file-transfer [org-004Z]
- April 27, 2019
- Lîm Tsú-thuàn
- 2019-04-27-five-tools-for-file-transfer.html
Grpc-proxy-approach-and-pain [org-0050]
- April 13, 2019
- Lîm Tsú-thuàn
- 2019-04-13-grpc-proxy-approach-and-pain.html
Grpc-proxy-approach-and-pain [org-0050]
- April 13, 2019
- Lîm Tsú-thuàn
- 2019-04-13-grpc-proxy-approach-and-pain.html
Dedekind-cut-and-application [org-0054]
- March 1, 2019
- Lîm Tsú-thuàn
- 2019-03-01-dedekind-cut-and-application.html
Dedekind-cut-and-application [org-0054]
- March 1, 2019
- Lîm Tsú-thuàn
- 2019-03-01-dedekind-cut-and-application.html
Kube-client-go-source-code-tracing [org-0055]
- January 25, 2019
- Lîm Tsú-thuàn
- 2019-01-25-kube-client-go-source-code-tracing.html
Kube-client-go-source-code-tracing [org-0055]
- January 25, 2019
- Lîm Tsú-thuàn
- 2019-01-25-kube-client-go-source-code-tracing.html
Kubernetes-context [org-0058]
- December 9, 2018
- Lîm Tsú-thuàn
- 2018-12-09-kubernetes-context.html
Kubernetes-context [org-0058]
- December 9, 2018
- Lîm Tsú-thuàn
- 2018-12-09-kubernetes-context.html
Fun-network-tcp-close [org-005A]
- November 30, 2018
- Lîm Tsú-thuàn
- 2018-11-30-fun-network-tcp-close.html
Fun-network-tcp-close [org-005A]
- November 30, 2018
- Lîm Tsú-thuàn
- 2018-11-30-fun-network-tcp-close.html
Xdp-some-note [org-0059]
- November 30, 2018
- Lîm Tsú-thuàn
- 2018-11-30-xdp-some-note.html
Xdp-some-note [org-0059]
- November 30, 2018
- Lîm Tsú-thuàn
- 2018-11-30-xdp-some-note.html
Kubernetes-start-from-pod [org-005C]
- October 27, 2018
- Lîm Tsú-thuàn
- 2018-10-27-kubernetes-start-from-pod.html
Kubernetes-start-from-pod [org-005C]
- October 27, 2018
- Lîm Tsú-thuàn
- 2018-10-27-kubernetes-start-from-pod.html
Test-llvm-go-binding-in-travis [org-005D]
- October 6, 2018
- Lîm Tsú-thuàn
- 2018-10-06-test-llvm-go-binding-in-travis.html
Test-llvm-go-binding-in-travis [org-005D]
- October 6, 2018
- Lîm Tsú-thuàn
- 2018-10-06-test-llvm-go-binding-in-travis.html
Httpexpect-go [org-005F]
- September 16, 2018
- Lîm Tsú-thuàn
- 2018-09-16-httpexpect-go.html
Httpexpect-go [org-005F]
- September 16, 2018
- Lîm Tsú-thuàn
- 2018-09-16-httpexpect-go.html
Practical-issue-about-dns-edns0 [org-005I]
- August 7, 2018
- Lîm Tsú-thuàn
- 2018-08-07-practical-issue-about-dns-edns0.html
Practical-issue-about-dns-edns0 [org-005I]
- August 7, 2018
- Lîm Tsú-thuàn
- 2018-08-07-practical-issue-about-dns-edns0.html
Reflection-in-go-create-a-stack-t [org-005J]
Reflection-in-go-create-a-stack-t [org-005J]
Magic-in-redux-go-2.1 [org-005K]
- July 4, 2018
- Lîm Tsú-thuàn
- 2018-07-04-magic-in-redux-go-2.1.html
Magic-in-redux-go-2.1 [org-005K]
- July 4, 2018
- Lîm Tsú-thuàn
- 2018-07-04-magic-in-redux-go-2.1.html
Error-is-value [org-005L]
- June 22, 2018
- Lîm Tsú-thuàn
- 2018-06-22-error-is-value.html
Error-is-value [org-005L]
- June 22, 2018
- Lîm Tsú-thuàn
- 2018-06-22-error-is-value.html
Design-of-redux-go-v2 [org-005N]
- May 17, 2018
- Lîm Tsú-thuàn
- 2018-05-17-design-of-redux-go-v2.html
Design-of-redux-go-v2 [org-005N]
- May 17, 2018
- Lîm Tsú-thuàn
- 2018-05-17-design-of-redux-go-v2.html
Cpp-thread-basic [org-0060]
- June 26, 2017
- Lîm Tsú-thuàn
- 2017-06-26-cpp-thread-basic.html
Cpp-thread-basic [org-0060]
- June 26, 2017
- Lîm Tsú-thuàn
- 2017-06-26-cpp-thread-basic.html
2. Notes [notes]
2. Notes [notes]
Definition. Moving frame (or frame field) [math-00FB]
- December 10, 2024
- Lîm Tsú-thuàn
Definition. Moving frame (or frame field) [math-00FB]
- December 10, 2024
- Lîm Tsú-thuàn
Let \(E_1, E_2, \dots , E_n\) be smooth vector fields defined on some open subset \(U \subseteq M\) of a smooth \(n\)-manifold \(M\). If \(E_1(p), E_2(p), \dots , E_n(p)\) form a basis for \(T_pM\) for each \(p \in U\), then we say \((E_1, E_2, \dots , E_n)\) is a moving frame or a frame field over \(U\).
Remark. [#304]
- December 10, 2024
- Lîm Tsú-thuàn
Remark. [#304]
- December 10, 2024
- Lîm Tsú-thuàn
A immediate consequence is that, for any vector field \(X\) defined on \(U\), we can write
\[X = \sum X^i E_i\]on \(U\). For \((E_i)\) is a moving frame over \(U\).
Remark. [#305]
- December 10, 2024
- Lîm Tsú-thuàn
Remark. [#305]
- December 10, 2024
- Lîm Tsú-thuàn
If \(U = M\) is hold, we say this is a global frame field, most manifolds do not have global frame fields.
Definition. Holonomic [#306]
- December 10, 2024
- Lîm Tsú-thuàn
Definition. Holonomic [#306]
- December 10, 2024
- Lîm Tsú-thuàn
- If a moving frame is identical to some \((\partial _1, \dots , \partial _n)\), then is holonomic.
- If a moving frame is not identical (mostly) to some \((\partial _1, \dots , \partial _n)\), then is non-holonomic.
Tool. Dvisvgm: A fast DVI to SVG converter [software-0015]
- December 9, 2024
- Lîm Tsú-thuàn
Tool. Dvisvgm: A fast DVI to SVG converter [software-0015]
- December 9, 2024
- Lîm Tsú-thuàn
The command-line utility dvisvgm is a tool for TEX/LaTEX users. It converts DVI, EPS, and PDF files to the XML-based vector graphics format SVG.
Definition. Lie algebra [math-00FA]
- December 8, 2024
- Lîm Tsú-thuàn
Definition. Lie algebra [math-00FA]
- December 8, 2024
- Lîm Tsú-thuàn
Manifolds and Differential Geometry
A Lie algebra is
- a vector space \(\mathfrak {a}\)
- a bilinear map \(\mathfrak {a} \times \mathfrak {a} \to \mathfrak {a}\), defined as \((v,w) \mapsto [v,w]\) such that
- \([v,w] = -[w,v]\)
- Jacobi identity \([x,[y,z]] + [y,[z,x]] + [z,[x,y]] = 0\) for all \(x,y,z \in \mathfrak {a}\)
Theorem. Cayley representation for monoids [math-00F8]
- December 4, 2024
- Lîm Tsú-thuàn
Theorem. Cayley representation for monoids [math-00F8]
- December 4, 2024
- Lîm Tsú-thuàn
Notions of Computation as Monoids
Every monoid \((M, \otimes , I)\) is a sub-monoid of the monoid of endomorphisms on \(M\).
Proof. [#307]
- December 4, 2024
- Lîm Tsú-thuàn
Proof. [#307]
- December 4, 2024
- Lîm Tsú-thuàn
Construct \(\text {rep} : M \to (M \to M)\) by currying \(\otimes \) \(\text {rep}(m) := \lambda m'. m \otimes m'\). This function is a monoid morphism, because
- \(\text {rep}(I) = \lambda m. m = id\)
- \[\begin {aligned} &\text {rep}(a \otimes b) = \lambda m'. (a \otimes b) \otimes m' \\ &= \lambda m'. a \otimes (b \otimes m') \\ &= (\lambda m. a \otimes m) \circ (\lambda n. b \otimes n) \\ &= \text {rep}(a) \circ \text {rep}(b) \end {aligned}\]
and it's an injection, since we can define \(\text {abs} : (M \to M) \to M\) such that
\[\text {abs}(k) = k(e)\]so \(\text {abs}(\text {rep(m)}) = m \otimes e = m\).
Definition. Binoidal category [math-00F5]
- December 4, 2024
- Lîm Tsú-thuàn
Definition. Binoidal category [math-00F5]
- December 4, 2024
- Lîm Tsú-thuàn
A binoidal category is a category \(\mathbb {C}\) endowed with an object \(I \in \mathbb {C}\) and an object \(A \otimes B\) for each \(A, B \in \mathbb {C}\). There are functors
- \((A \otimes -) : \mathbb {C} \to \mathbb {C}\)
- \((- \otimes B) : \mathbb {C} \to \mathbb {C}\)
that coincide on \((A \otimes B)\).
Remark. [#308]
- December 4, 2024
- Lîm Tsú-thuàn
Remark. [#308]
- December 4, 2024
- Lîm Tsú-thuàn
The point is the definition allows tensor with identities (whiskering), functorially.
Centre [#309]
- December 4, 2024
- Lîm Tsú-thuàn
Centre [#309]
- December 4, 2024
- Lîm Tsú-thuàn
The centre \(\mathcal {Z}(\mathbb {C})\) is the wide subcategory of morphisms that do satisfy the interchange law with any other morphism.
Definition. Difference lists (Hughes lists) [haskell-0005]
- December 4, 2024
- Lîm Tsú-thuàn
Definition. Difference lists (Hughes lists) [haskell-0005]
- December 4, 2024
- Lîm Tsú-thuàn
Since lists are monoids \(([a], ++, [])\), apply the representation theorem of monoid can get
type EList a = [a] -> [a]
and functions
rep :: [a] -> EList a rep xs = (xs ++) abs :: EList a abs xs = xs []
by the theorem we know abs ∘ rep = id
.
Definition. Effectful category [math-00F4]
- December 4, 2024
- Lîm Tsú-thuàn
Definition. Effectful category [math-00F4]
- December 4, 2024
- Lîm Tsú-thuàn
Promonads and String Diagrams for Effectful Categories
An effectful category is an identity-on-objects functor \(\color {blue}\mathbb {V}\color {black} \to \color {red}\mathbb {C}\color {black}\) from a monoidal category \(\color {blue}\mathbb {V}\color {black}\) (the pure morphisms, or "values") to a premonoidal category \(\color {red}\mathbb {C}\color {black}\) (the effectful morphisms, or "computations"), that strictly preserves all of the premonoidal structure and whose image is central.
Definition. Premonoidal category [math-00F6]
- December 4, 2024
- Lîm Tsú-thuàn
Definition. Premonoidal category [math-00F6]
- December 4, 2024
- Lîm Tsú-thuàn
A premonoidal category is a binoidal category \((\mathbb {C}, \otimes , I)\) together with the following coherence isomorphisms
- \(\alpha _{A,B,C} : A \otimes (B \otimes C) \simeq (A \otimes B) \otimes C\)
- \(\rho _A : A \otimes I \simeq A\)
- \(\lambda _A : I \otimes A \simeq A\)
which are central, natural separately at each given component, and satisfy the pentagon and triangle equations.
Definition. Promonoid [math-00F7]
- December 4, 2024
- Lîm Tsú-thuàn
Definition. Promonoid [math-00F7]
- December 4, 2024
- Lîm Tsú-thuàn
A promonoid in a 2-category is a proarrow \(M : \mathbb {A} \nrightarrow \mathbb {A}\) together with cells
- promultiplication \(m \in \text {cell}(1; M \otimes M, M, 1)\) and
- prounit \(e \in \text {cell}(1; 1, M; 1)\)
satisfying unitiality and asociativity.
Definition. Whiskered composite [math-00F9]
- December 4, 2024
- Lîm Tsú-thuàn
Definition. Whiskered composite [math-00F9]
- December 4, 2024
- Lîm Tsú-thuàn
Elements of ∞-Category Theory
A whiskered composite \(h \alpha k\) of a 2-cell
with a pair of 1-cells \(k : x \to a\) and \(h : b \to y\) is defined by the horizontal composite:
A model of effects [math-00F3]
- December 3, 2024
- Lîm Tsú-thuàn
A model of effects [math-00F3]
- December 3, 2024
- Lîm Tsú-thuàn
The paper Promonads and String Diagrams for Effectful Categories points out
this motivates us to find corresponding object of effects in premonoidal category, and uses the following additional (control) string to point out the order.
Concurrency model? [#310]
- December 3, 2024
- Lîm Tsú-thuàn
Concurrency model? [#310]
- December 3, 2024
- Lîm Tsú-thuàn
If each computation instance has three lines
- black line: pure computation
- red line: ordered effect computation
- gold line: shared states for concurrency
then ensure their tensor will coherence at the gold line. In Collages of String Diagrams they point out an usage of bimodular categories to model basic binary semaphore concept.
Axiom. Propositional extensionality [tt-0021]
- November 28, 2024
- Lîm Tsú-thuàn
Axiom. Propositional extensionality [tt-0021]
- November 28, 2024
- Lîm Tsú-thuàn
The propositional extensionality says that propositions that imply each other are equal
\[\text {propext} : \forall \ p\ q : \text {Prop}.\ (p \leftrightarrow q) \to p = q\]
Axiom. Proof irrelevance [tt-0020]
- November 27, 2024
- Lîm Tsú-thuàn
Axiom. Proof irrelevance [tt-0020]
- November 27, 2024
- Lîm Tsú-thuàn
The proof irrelevance is an axiom can be added into type theory to state that:
\[\frac { \Gamma \vdash p : \text {Prop} \quad \Gamma \vdash h : p \quad \Gamma \vdash h' : p }{ \Gamma \vdash h \equiv h' }\]so using which proofs is irrelevance.
Definition. Associated elements [math-00F0]
- November 20, 2024
- Lîm Tsú-thuàn
Definition. Associated elements [math-00F0]
- November 20, 2024
- Lîm Tsú-thuàn
Let \(D\) be an integral domain, \(a, b \in D\) are associated if \(a = ub\) where \(u\) is a unit of \(D\).
Definition. Irreducible [math-00F1]
- November 20, 2024
- Lîm Tsú-thuàn
Definition. Irreducible [math-00F1]
- November 20, 2024
- Lîm Tsú-thuàn
A nonzero element \(a\) of an integral domain \(D\) is called irreducible if \(a\) is not a unit and whenever \(b,c \in D\) with \(a = bc\), then \(b\) or \(c\) is a unit.
Definition. Primes [math-00F2]
- November 20, 2024
- Lîm Tsú-thuàn
Definition. Primes [math-00F2]
- November 20, 2024
- Lîm Tsú-thuàn
A nonzero element \(a\) of an integral domain \(D\) is called a prime if \(a\) is not a unit and
\[a \mid bc \implies a \mid b \text { or } a \mid c\]
Theorem. Primes => irreducibles [#311]
- November 20, 2024
- Lîm Tsú-thuàn
Theorem. Primes => irreducibles [#311]
- November 20, 2024
- Lîm Tsú-thuàn
In an integral domain, every prime is an irreducible.
The next theorem is why define PID.
Theorem. In PID, irreducibles = primes [#312]
- November 20, 2024
- Lîm Tsú-thuàn
Theorem. In PID, irreducibles = primes [#312]
- November 20, 2024
- Lîm Tsú-thuàn
In an principal integral domain, an element is an irreducible if and only if it is a prime.
Remark. The purpose of semantic theories [tt-001Y]
- November 15, 2024
- Lîm Tsú-thuàn
Remark. The purpose of semantic theories [tt-001Y]
- November 15, 2024
- Lîm Tsú-thuàn
- operational semantic: rules about how we compute
- denotational semantic: an object represents what we compute
Definition. Homogeneous polynomial [math-00EZ]
- November 11, 2024
- Lîm Tsú-thuàn
Definition. Homogeneous polynomial [math-00EZ]
- November 11, 2024
- Lîm Tsú-thuàn
A polynomial is homogeneous if whose nonzero terms all have the same degree.
Example. [#313]
- November 11, 2024
- Lîm Tsú-thuàn
Example. [#313]
- November 11, 2024
- Lîm Tsú-thuàn
Definition. Grothendieck topology [math-00EY]
- November 9, 2024
- Lîm Tsú-thuàn
Definition. Grothendieck topology [math-00EY]
- November 9, 2024
- Lîm Tsú-thuàn
Definition. Sieve [#314]
- November 9, 2024
- Lîm Tsú-thuàn
Definition. Sieve [#314]
- November 9, 2024
- Lîm Tsú-thuàn
A sieve on the object \(U\) is a family of morphisms \(R\) that saturated in the sense that, \((V \xrightarrow {\alpha } U) \in R\) implies \((W \xrightarrow {\alpha \circ \beta } U) \in R\) for any \(W \xrightarrow {\beta } V\).
Let \(C\) be a small category. A Grothendieck topology on \(C\) is defined by specifying, for each object \(U \in C\), a set \(J(U)\) of sieves on \(U\), called covering sieves of the topology, such that
- For any \(U\), the maximal sieve \(\{ \alpha \mid \fbox {?} \xrightarrow {\alpha } U \}\) is in \(J(U)\)
- If \(R \in J(U)\) and \(V \xrightarrow {f} U\) is a morphism of \(C\), then the sieve \[f^*(R) = \{ W \xrightarrow {\alpha } V \mid f\circ \alpha \in R \}\] is in \(J(V)\)
- If \(R \in J(U)\) and \(S\) is a sieve on \(U\) such that, for each \((V \xrightarrow {f} U) \in R\), we have \(f^*(S) \in J(V)\), then \(S \in J(U)\)
Remark. [#315]
- November 9, 2024
- Lîm Tsú-thuàn
Remark. [#315]
- November 9, 2024
- Lîm Tsú-thuàn
條件二使 Grothendieck pretopology 中的 with pullbacks 是不必要的。
Definition. Site [math-00EX]
- November 9, 2024
- Lîm Tsú-thuàn
Definition. Site [math-00EX]
- November 9, 2024
- Lîm Tsú-thuàn
Topos Theory
A site is a small category equipped with a Grothendieck topology (Definition [math-00EY]Definition [math-00EY]).
Definition. Grothendieck topology [math-00EY]
- November 9, 2024
- Lîm Tsú-thuàn
Definition. Grothendieck topology [math-00EY]
- November 9, 2024
- Lîm Tsú-thuàn
Definition. Sieve [#314]
- November 9, 2024
- Lîm Tsú-thuàn
Definition. Sieve [#314]
- November 9, 2024
- Lîm Tsú-thuàn
A sieve on the object \(U\) is a family of morphisms \(R\) that saturated in the sense that, \((V \xrightarrow {\alpha } U) \in R\) implies \((W \xrightarrow {\alpha \circ \beta } U) \in R\) for any \(W \xrightarrow {\beta } V\).
Let \(C\) be a small category. A Grothendieck topology on \(C\) is defined by specifying, for each object \(U \in C\), a set \(J(U)\) of sieves on \(U\), called covering sieves of the topology, such that
- For any \(U\), the maximal sieve \(\{ \alpha \mid \fbox {?} \xrightarrow {\alpha } U \}\) is in \(J(U)\)
- If \(R \in J(U)\) and \(V \xrightarrow {f} U\) is a morphism of \(C\), then the sieve \[f^*(R) = \{ W \xrightarrow {\alpha } V \mid f\circ \alpha \in R \}\] is in \(J(V)\)
- If \(R \in J(U)\) and \(S\) is a sieve on \(U\) such that, for each \((V \xrightarrow {f} U) \in R\), we have \(f^*(S) \in J(V)\), then \(S \in J(U)\)
Remark. [#315]
- November 9, 2024
- Lîm Tsú-thuàn
Remark. [#315]
- November 9, 2024
- Lîm Tsú-thuàn
條件二使 Grothendieck pretopology 中的 with pullbacks 是不必要的。
Definition. Grothendieck pretopology [math-00EW]
- November 6, 2024
- Lîm Tsú-thuàn
Definition. Grothendieck pretopology [math-00EW]
- November 6, 2024
- Lîm Tsú-thuàn
Topos Theory
Let \(C\) be a small category with pullbacks. A Grothendieck pretopology on \(C\) is defined by specifying, for each object \(U \in C\), a set \(P(U)\) of families of morphisms of the form
\[\{ U_i \xrightarrow {\alpha _i} U \mid i \in I \}\]called covering families of the pretopology, such that
- For any \(U\), singleton set of the identity morphism \(\{ U \xrightarrow {1} U \}\) is in \(P(U)\).
- If \(V \to U\) is a morphism in \(C\), and \(\{ U_i \to U \mid i \in I \}\) is in \(P(U)\), then the pullback \(\{ V \times _U U_i \xrightarrow {\pi _1} V \mid i \in I \}\) is in \(P(V)\).
- If \(\{ U_i \xrightarrow {\alpha _i} U \mid i \in I \}\), and \(\{ V_{ij} \xrightarrow {\beta _{ij}} U_i \mid j \in J_i \}\) in \(P(U_i)\) for each \(i \in I\), then \[\{ V_{ij} \xrightarrow {\alpha _i \circ \beta _{ij}} U \mid i \in I, j \in J_i \}\] is in \(P(U)\).
Definition. Second fundamental form [math-00EV]
- November 3, 2024
- Lîm Tsú-thuàn
Definition. Second fundamental form [math-00EV]
- November 3, 2024
- Lîm Tsú-thuàn
Let \(S\) be an oriented regular surface, and let \(p \in S\). Let \(\partial _1, \partial _2\) be an orthonormal basis of \(T_pS\) with respect to which the Weingarten map is represented by a diagonal matrix
\[\mathcal {W}_p = \begin {bmatrix}k_1 & 0 \\ 0 & k_2\end {bmatrix}\]then
- \(\pm \partial _1, \pm \partial _2\) are principal directions of \(S\) at \(p\).
- \(k_1, k_2\) are principal curvatures of \(S\) at \(p\).
- The second fundamental form of \(S\) at \(p\) \[II_p(v) = \langle \mathcal {W}_p(v), v \rangle = \langle -dN_p(v), v \rangle \] for all \(v \in T_pS\)
- If \(v \in T_pS\) with \(|v| = 1\), then \(II_p(v)\) is also called the normal curvature of \(S\) at \(p\) in the direction \(v\).
Remark. [#316]
- November 3, 2024
- Lîm Tsú-thuàn
Remark. [#316]
- November 3, 2024
- Lîm Tsú-thuàn
We now can also represent Gaussian curvature and mean curvature as
\[K(p) = k_1 k_2\]and
\[H(p) = \frac {1}{2}(k_1 + k_2)\]
Definition. Gaussian curvature and mean curvature [math-00ET]
- November 2, 2024
- Lîm Tsú-thuàn
Definition. Gaussian curvature and mean curvature [math-00ET]
- November 2, 2024
- Lîm Tsú-thuàn
This is a formal way of Gaussian curvature (高斯曲率直覺方式)
The determinant of Weingarten map
\[K(p) = \det {\mathcal {W}_p}\]is the Gaussian curvature of \(S\) at \(p\). The half of trace
\[H(p) = \frac {1}{2} \mathcal {W}_p \]is the mean curvature of \(S\) at \(p\).
Definition. Weingarten map (and Gauss map) [math-00EU]
- November 2, 2024
- Lîm Tsú-thuàn
Definition. Weingarten map (and Gauss map) [math-00EU]
- November 2, 2024
- Lîm Tsú-thuàn
Definition. Gauss map [#317]
- November 2, 2024
- Lîm Tsú-thuàn
Definition. Gauss map [#317]
- November 2, 2024
- Lîm Tsú-thuàn
Let \(S\) be an oriented surface, let \(N : S \to \R ^3\) be a unit normal vector field on \(S\). Thus, \(N(p)\) only outputs an element of the sphere \(S^2 \subset \R ^3\), so \(N\) is also a function \(S \to S^2\). Such \(N\) is called the Gauss map.
Differential of Gauss map [#318]
- November 2, 2024
- Lîm Tsú-thuàn
Differential of Gauss map [#318]
- November 2, 2024
- Lîm Tsú-thuàn
Consider \(N : S \to S^2\), its differential is \(dN_p : T_pS \to T_{N(p)} S^2\). However, we can see
\[T_pS = T_{N(p)} S^2\]Thus, we can see \(dN_p : T_pS \to T_pS\).
For every \(p \in S\), the linear transformation
\[\mathcal {W}_p = -dN_p : T_pS \to T_pS\]is called the Weingarten map.
Generalize Gauss map [#319]
- November 2, 2024
- Lîm Tsú-thuàn
Generalize Gauss map [#319]
- November 2, 2024
- Lîm Tsú-thuàn
The idea still work for higher dimension. Let \(S\) be an differentiable manifold with dimension \(n-1\), let \(N : S \to \R ^n\), then \(N : S \to S^{n-1} \subset \R ^n\).
Definition. Riemannian connection [math-00EP]
- October 31, 2024
- Lîm Tsú-thuàn
Definition. Riemannian connection [math-00EP]
- October 31, 2024
- Lîm Tsú-thuàn
Let \(M\) be a differentiable manifold with an affine connection \(\nabla \) and a Riemann metric \(\langle -,- \rangle \).
Compatible [#321]
- October 31, 2024
- Lîm Tsú-thuàn
Compatible [#321]
- October 31, 2024
- Lîm Tsú-thuàn
A connection is compatible with the metric \(\langle -,- \rangle \) if for any smooth curve \(\gamma \) and any pair of parallel vector fields \(P\) and \(P'\) along \(\gamma \), we have
\[\langle P,P' \rangle = \text {constant}\]
Theorem. Levi-Civita [math-00EQ]
- October 31, 2024
- Lîm Tsú-thuàn
Theorem. Levi-Civita [math-00EQ]
- October 31, 2024
- Lîm Tsú-thuàn
Riemannian Geometry §2
Given a Riemann manifold \(M\), there exists a unique affine connection \(\nabla \) on \(M\) satisfying the conditions
- \(\nabla \) is symmetric
- \(\nabla \) is compatible with the Riemann metric.
Proof. [#320]
- October 31, 2024
- Lîm Tsú-thuàn
Proof. [#320]
- October 31, 2024
- Lîm Tsú-thuàn
The \(\nabla \) will be determined by
\[\begin {aligned} \langle Z, \nabla _YX \rangle = &\frac {1}{2}(X\langle Y,Z \rangle + Y\langle Z,X \rangle - Z\langle X,Y \rangle \\ &- \langle [X,Z],Y \rangle - \langle [Y,Z],X \rangle - \langle [X,Y],Z \rangle ) \end {aligned}\]
Remark. [#322]
- October 31, 2024
- Lîm Tsú-thuàn
Remark. [#322]
- October 31, 2024
- Lîm Tsú-thuàn
A Riemannian (or Levi-Civita) connection on \(M\) is the unique connection from Levi-Civita theorem.
Definition. Christoffel symbol [math-00ES]
- October 31, 2024
- Lîm Tsú-thuàn
Definition. Christoffel symbol [math-00ES]
- October 31, 2024
- Lîm Tsú-thuàn
Let \((U,x)\) be a coordinate system. The functions \(\Gamma ^k_{ij}\) defined on \(U\) by
\[\nabla _{\partial _i}\partial _j = \Gamma ^k_{ij}\partial _k\]The coefficients of the connection \(\nabla \) on \(U\) or Christoffel symbols of the connection. From Theorem [math-00EQ]
\[\Gamma ^l_{ij} g_{lk} = \frac {1}{2}(\partial _i g_{jk} + \partial _j g_{ki} - \partial _k g_{ij})\]where \(g_{ij} = \langle \partial _i, \partial _j \rangle \). By inverse matrix \(g^{km}\), we got
\[\Gamma ^m_{ij} = \frac {1}{2} \sum _k (\partial _i g_{jk} + \partial _j g_{ki} - \partial _k g_{ij}) g^{km}\]In term of Christoffel symbols, the covariant derivative has the classical expression:
\[\frac {DV}{dt} = \sum _k ( \frac {d v^k}{d t} + \sum _{i,j} \Gamma ^k_{ij} v^j \frac {d x^i}{d t} ) \partial _k\]
Definition. Lie bracket (or Lie product) for \(C^\infty \) vector fields [math-00EL]
- October 30, 2024
- Lîm Tsú-thuàn
Definition. Lie bracket (or Lie product) for \(C^\infty \) vector fields [math-00EL]
- October 30, 2024
- Lîm Tsú-thuàn
Let \(X\) and \(Y\) be two \(C^\infty \) tangent vector fields on open set \(U\) of a differentiable manifold \(M\), the Lie bracket of \(X\) and \(Y\) is
\[[X,Y] := XY - YX\]which takes two tangent fields and produces a new tangent field. The Lie derivative
\[L_XY = [X,Y]\]
Theorem. The Lie bracket is another tangent vector space [#324]
- October 30, 2024
- Lîm Tsú-thuàn
Theorem. The Lie bracket is another tangent vector space [#324]
- October 30, 2024
- Lîm Tsú-thuàn
Generally \(XY\) is not a tangent vector space, by not having Leibniz property. However, \(XY - YX\) must be.
Proof. [#325]
- October 30, 2024
- Lîm Tsú-thuàn
Proof. [#325]
- October 30, 2024
- Lîm Tsú-thuàn
The boxed part is same at \(XY\) and \(YX\), and generally not \(0\), and \(XY - YX\) leave a part that satisfies Leibniz.
Remark. Geometry meaning [#326]
- October 30, 2024
- Lîm Tsú-thuàn
Remark. Geometry meaning [#326]
- October 30, 2024
- Lîm Tsú-thuàn
Lie bracket 的用途是,衡量
- 先沿著 \(X\) 方向走 \(t\) 再沿著 \(Y\) 走 \(s\)
- 先沿著 \(Y\) 方向走 \(s\) 再沿著 \(X\) 走 \(t\)
這兩種路徑的差距,一般來說都不是零。所以,下面的定理 Lie bracket 是核心關鍵
Theorem. Lie product is zero implies vector fields produce a local coordinates [math-00EM]
- October 30, 2024
- Lîm Tsú-thuàn
Theorem. Lie product is zero implies vector fields produce a local coordinates [math-00EM]
- October 30, 2024
- Lîm Tsú-thuàn
Let \(M\) be a \(n\)-dimensional \(C^\infty \)-manifold, \(q \in M\) and \(X_1, \dots , X_k\) be a list of linear independent \(C^\infty \)-vector fields, and \(1 \le k \le n\). Then if for all \(\alpha , \beta \)
\[[X_\alpha , X_\beta ] = 0\]There exists \(C^\infty \)-immersion locally, i.e.
\[\lambda : U \subseteq \R ^k \looparrowright M\]makes
- \(q \in \lambda (U)\) and
- \(X_\alpha = \frac {\partial \lambda }{\partial x^\alpha }\) for all \(\alpha \).
Proof. [#323]
- October 30, 2024
- Lîm Tsú-thuàn
Proof. [#323]
- October 30, 2024
- Lîm Tsú-thuàn
Let \(\varphi ^\alpha _t\) be the flow of \(X_\alpha \), i.e.
\[ \frac {d }{d t} \varphi ^\alpha _t(x) = X_\alpha \text { at } x \text {, for all } x \in M\]so defines
\[\lambda (x^1, x^2, \dots , x^k) = \varphi ^k_{x^k} \circ \cdots \circ \varphi ^1_{x^1}(q)\]- Apply \(\lambda \) to the origin point is \(q\), \(\lambda (0, \dots , 0) = q\)
- \[\begin {aligned} &\frac {\partial \lambda }{\partial x^\alpha }(x^1, \dots , x^k) \\ = &\frac {\partial }{\partial x^\alpha } \lambda (x^1, \dots , x^k) \\ = &\frac {\partial }{\partial x^\alpha } \varphi ^k_{x^k} \circ \cdots \circ \varphi ^1_{x^1}(q) \\ = &X_\alpha \vert _{\text {at } \lambda (x^1, \dots , x^k)} \end {aligned}\] so \(X_\alpha = \frac {\partial }{\partial x^\alpha }\)
Can see that \(\lambda \) is the target immersion.
Definition. Quotient group [math-00EJ]
- October 29, 2024
- Lîm Tsú-thuàn
Definition. Quotient group [math-00EJ]
- October 29, 2024
- Lîm Tsú-thuàn
Algebra: Chapter 0 §II.7
Let \(H\) be a normal subgroup of \(G\), the quotient group of \(G\) modulo \(H\) denoted \(G / H\), is the group \(G / \sim \) obtained from the relation \(\sim \) defined as
\[G / \sim \ = \{ aH \mid a \in G \} = \{ Ha \mid a \in G \}\]In terms of cosets, the product in \(G / H\) is defined by
\[(aH)(bH) = (ab)H\]The identity \(e_{G / H} = e_G H = H\).
Definition. Coset [math-00EK]
- October 29, 2024
- Lîm Tsú-thuàn
Definition. Coset [math-00EK]
- October 29, 2024
- Lîm Tsú-thuàn
The left-cosets of a subgroup \(H\) in a group \(G\) are the sets \(aH\) for all \(a \in G\). The right-cosets of \(H\) are the sets \(Ha\) for all \(a \in G\).
Notation. Left/right relations [#327]
- October 29, 2024
- Lîm Tsú-thuàn
Notation. Left/right relations [#327]
- October 29, 2024
- Lîm Tsú-thuàn
Definition. Kronecker delta [math-00EG]
- October 28, 2024
- Lîm Tsú-thuàn
Definition. Kronecker delta [math-00EG]
- October 28, 2024
- Lîm Tsú-thuàn
Kronecker delta \(\delta ^i_j\) is a two-index mathematical object such that
\[ \delta ^i_j = \begin {cases} 1 \text { if } i = j \\ 0 \text { if } i \ne j \end {cases} \]
Remark. [#330]
- October 28, 2024
- Lîm Tsú-thuàn
Remark. [#330]
- October 28, 2024
- Lîm Tsú-thuàn
If we are not considering a tensor, denotes \(\delta _{ij}\) is also existed.
Usage [#331]
- October 28, 2024
- Lîm Tsú-thuàn
Usage [#331]
- October 28, 2024
- Lîm Tsú-thuàn
Consider a vector represents via index notation \(A^i\), then
\[A^i = \delta ^i_j A^j\]
Solution. [#332]
- October 28, 2024
- Lîm Tsú-thuàn
Solution. [#332]
- October 28, 2024
- Lîm Tsú-thuàn
Consider \(\delta ^i_j\) as a finite matrix form, and \(i, j\) have the same dimension.
\[\begin {bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end {bmatrix}\]Then \(A^i = \begin {bmatrix}a\\b\\c\end {bmatrix} = \delta ^i_j \begin {bmatrix}a\\b\\c\end {bmatrix} = \delta ^i_j A^j\). It's clear that this idea is general, even \(i, j\) have different dimensions, the form
\[\begin {bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \end {bmatrix} \begin {bmatrix}a\\b\\c\end {bmatrix} = \begin {bmatrix}a\\b\end {bmatrix}\]
Notation. Index form and summation convention [math-00EH]
- October 28, 2024
- Lîm Tsú-thuàn
Notation. Index form and summation convention [math-00EH]
- October 28, 2024
- Lîm Tsú-thuàn
Instead of denotes a vector as \(\vec {A}\), index form denotes \(A^\mu \), \(\mu \) is not exponent here, but index to each component. Let's take a concrete example, if \(A^\mu \) has dimension \(4\), then \(\mu = 0, 1, 2, 3\), thus
\[ A^\mu = \begin {bmatrix}A^0 \\ A^1 \\ A^2 \\ A^3\end {bmatrix} \]An usual example is partial derivations as components (e.g. tangent space (切空間))
\[ \partial _\mu = \frac {\partial }{\partial x^\mu } = \begin {bmatrix}\partial _0\\\partial _1\\\partial _2\\\partial _3\end {bmatrix} = \begin {bmatrix}\frac {\partial }{\partial x^0}\\\frac {\partial }{\partial x^1}\\\frac {\partial }{\partial x^2}\\\frac {\partial }{\partial x^3}\end {bmatrix} \]
Summation convention [#329]
- October 28, 2024
- Lîm Tsú-thuàn
Summation convention [#329]
- October 28, 2024
- Lîm Tsú-thuàn
Let \(A_\mu \) and \(B^\mu \) both be dimension \(4\) vector, then
\[A_\mu B^\mu = \sum _{\mu =0}^3 A_\mu B^\mu = A_0B^0 + A_1B^1 + A_2B^2 + A_3B^3\]
Definition. Linear categories [math-00EE]
- October 28, 2024
- Lîm Tsú-thuàn
Definition. Linear categories [math-00EE]
- October 28, 2024
- Lîm Tsú-thuàn
A Gentle Introduction to Homological Mirror Symmetry, §1.4
Let \(\mathbb {k}\) be a fixed field. A category \(C\) is called a \(\mathbb {k}\)-linear category if all hom-spaces are \(\mathbb {k}\)-vector spaces and the multiplication is bilinear. An object \(X \in C\) is a zero object if for all \(Y \in C\), we have \(\text {Hom}_{C}(X, Y) = \text {Hom}_{C}(Y, X) = 0\).
A functor between two \(\mathbb {k}\)-linear categories is call \(k\)-linear if the maps between the hom-spaces are \(\mathbb {k}\)-linear.
Remark. [#686]
- October 28, 2024
- Lîm Tsú-thuàn
Remark. [#686]
- October 28, 2024
- Lîm Tsú-thuàn
Almost all natural functors between two \(\mathbb {k}\)-linear categories are \(\mathbb {k}\)-linear.
Example. [#687]
- October 28, 2024
- Lîm Tsú-thuàn
Example. [#687]
- October 28, 2024
- Lîm Tsú-thuàn
\(\text {VECT}(\mathbb {k})\), \(\text {vect}(\mathbb {k})\), \(\text {mat}(\mathbb {k})\) are examples of \(\mathbb {k}\)-linear categories. For any \(\mathbb {k}\)-algebra \(A\), we have \(\mathbb {k}\)-linear categories:
- MOD-\(A\) The category of all right \(A\)-modules
- Mod-\(A\) The category of all finitely generated right \(A\)-modules
- mod-\(A\) The category of all finitely-dimensional right \(A\)-modules
The zero object in these categories is zero vector space with trivial \(A\)-action. The hom-spaces in these categories are often denoted by \(\text {Hom}_{A}(M, N)\). Respectively, for left modules we have \(A\)-MOD, \(A\)-Mod, and \(A\)-mod.
Remark. [#688]
- October 28, 2024
- Lîm Tsú-thuàn
Remark. [#688]
- October 28, 2024
- Lîm Tsú-thuàn
Any \(\mathbb {k}\)-algebra \(A\) can also be considered as a \(\mathbb {k}\)-linear category \(A\) with one object.
Definition. Ring algebra [math-00ED]
- October 28, 2024
- Lîm Tsú-thuàn
Definition. Ring algebra [math-00ED]
- October 28, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology, §14.2
A \(R\)-algebra \(C\) is a \(R\)-module \(C\) together with a bilinear map \(\cdot : C \times C \to C\), such that \((C, +, \cdot )\) is a ring.
Definition. Commutative algebra [#333]
- October 28, 2024
- Lîm Tsú-thuàn
Definition. Commutative algebra [#333]
- October 28, 2024
- Lîm Tsú-thuàn
A \(R\)-algebra is commutative if the ring is commutative.
Definition. (co) wedge and (co) end [math-00EC]
- October 26, 2024
- Lîm Tsú-thuàn
Definition. (co) wedge and (co) end [math-00EC]
- October 26, 2024
- Lîm Tsú-thuàn
Let \(P : \mathcal {C}^{op} \times \mathcal {C} \to \mathcal {D}\) be a functor
- a wedge is a dinatural transformation from constant \(\zeta : \Delta _D \multimap P\)
- dually, a cowedge is a dinatural transformation to constant \(\zeta : P \multimap \Delta _D\)
Definition. End [#334]
- October 26, 2024
- Lîm Tsú-thuàn
Definition. End [#334]
- October 26, 2024
- Lîm Tsú-thuàn
A end of \(P\) is an terminal wedge, which means below diagram:
commutes and unique split \(\zeta _X\) for all \(X \in \mathcal {C}\).
Notation. [#335]
- October 26, 2024
- Lîm Tsú-thuàn
Notation. [#335]
- October 26, 2024
- Lîm Tsú-thuàn
Remark. [#336]
- October 26, 2024
- Lîm Tsú-thuàn
Remark. [#336]
- October 26, 2024
- Lîm Tsú-thuàn
Due to functor can be viewed as diagonal functor that has dummy contravariant variable, we have a cool reuse of end notation. Let \(F, G : \mathcal {C} \to \mathcal {D}\) be functors, a natural transformation from \(F\) to \(G\) can be viewed as an end, and hence we have an isomorphism
\[\text {Nat}(F,G) \simeq \int _{X \in \mathcal {C}} \text {Hom}_{\mathcal {D}}(F(X), G(X))\]
Definition. Coend [#337]
- October 26, 2024
- Lîm Tsú-thuàn
Definition. Coend [#337]
- October 26, 2024
- Lîm Tsú-thuàn
A coend of \(P\) is an initial cowedge, which means below diagram:
commutes and unique split \(\zeta _X\) for all \(X \in \mathcal {C}\).
Notation. [#338]
- October 26, 2024
- Lîm Tsú-thuàn
Notation. [#338]
- October 26, 2024
- Lîm Tsú-thuàn
Definition. The arithmetic hierarchy [math-00E8]
- October 26, 2024
- Lîm Tsú-thuàn
Definition. The arithmetic hierarchy [math-00E8]
- October 26, 2024
- Lîm Tsú-thuàn
Mathematical Logic and Computation, §10.2
A formula if arithmetic is said to be \(\Delta _0\) if it has no unbounded quantifiers. Alternatively, the set of \(\Delta _0\) formulas is the smallest set containing atomic formulas in the language of arithmetic and closed under boolean operations and bounded quantification.
The hierarchies of \(\Sigma _n\) and \(\Pi _n\) formulas are defined simultaneously and inductively as follows
- \(\Sigma _0 = \Pi _0 = \Delta _0\)
- If \(A \in \Sigma _n\), then \(A \in \Pi _{n+1}\)
- If \(A \in \Pi _n\), then \(A \in \Sigma _{n+1}\)
- If \(A \in \Sigma _{n+1}\), then \(\exists x A \in \Sigma _{n+1}\)
- If \(A \in \Pi _{n+1}\), then \(\forall x A \in \Pi _{n+1}\)
Definition. Affine connection [math-00EA]
- October 26, 2024
- Lîm Tsú-thuàn
Definition. Affine connection [math-00EA]
- October 26, 2024
- Lîm Tsú-thuàn
- Let \(\mathcal {X}(M)\) be the set of all vector fields of class \(C^\infty \) on a differentiable manifold \(M\).
- Let \(\mathcal {D}(M)\) be the ring of real-valued functions of class \(C^\infty \) defined on \(M\).
An affine connection \(\nabla \) on \(M\) is a mapping
\[ \nabla : \mathcal {X}(M) \times \mathcal {X}(M) \to \mathcal {X}(M) \]
Notation. [#340]
- October 26, 2024
- Lîm Tsú-thuàn
Notation. [#340]
- October 26, 2024
- Lîm Tsú-thuàn
which satisfies the followings
- \(\nabla _{aX+bY}Z = a\nabla _XZ + b\nabla _YZ\)
- \(\nabla _X(aY+bZ) = a\nabla _XY + b\nabla _XZ\)
- Leibnizian: \(\nabla _X(fY) = f\nabla _XY + (Xf)Y\)
for all \(X,Y,Z\in \mathcal {X}(M)\) and \(f,g \in \mathcal {D}(M)\)
Definition. Covariant derivative [math-00EO]
- October 31, 2024
- Lîm Tsú-thuàn
Definition. Covariant derivative [math-00EO]
- October 31, 2024
- Lîm Tsú-thuàn
Let \(M\) be a differentiable manifold with an affine connection \(\nabla \). There exists a unique correspondence which associates to a vector field \(V\) along the differentiable curve \(\gamma : [0,1] \to M\) another vector field \(\frac {DV}{dt}\) along \(\gamma \), called the covariant derivative of \(V\) along \(\gamma \).
\[\frac {DV}{dt} = \frac {d v^j}{d t} \partial _j + \frac {d x^i}{d t} v^j \nabla _{\partial _i}\partial _j\]remind \(\partial _i = \frac {\partial }{\partial x^i}\), and summation convention is applied.
Covariant derivative has properties below:
\[ \begin {equation} \frac {D}{dt}(V+W) = \frac {DV}{dt} + \frac {DW}{dt} \end {equation}\quad \begin {equation} \frac {D}{dt}(fV) = \frac {d f}{d t} V + f\frac {DV}{dt} \end {equation} \]and if \(V\) is induced by a vector field \(Y\), e.g.
\[V(t) = Y(\gamma (t))\]then
\[\frac {DV}{dt} = \nabla _{ \frac {d \gamma }{d t} }Y\]
Definition. Symmetric affine connnection and torsion [math-00ER]
- October 31, 2024
- Lîm Tsú-thuàn
Definition. Symmetric affine connnection and torsion [math-00ER]
- October 31, 2024
- Lîm Tsú-thuàn
An affine connection \(\nabla \) on a smooth manifold \(M\) is said to be symmetric if
\[\nabla _XY - \nabla _YX = [X,Y]\]for all vector fields \(X,Y\) on \(M\). In this case, the torsion tensor defined as
\[T(X,Y) = \nabla _XY - \nabla _YX - [X,Y]\]
Definition. Parallel (affine connection) [math-00EN]
- October 31, 2024
- Lîm Tsú-thuàn
Definition. Parallel (affine connection) [math-00EN]
- October 31, 2024
- Lîm Tsú-thuàn
Let \(M\) be a differentiable manifold with an affine connection \(\nabla \). A vector field \(V\) along a curve \(\gamma : [0,1] \to M\) is called parallel if for all \(t \in [0,1]\) its covariant derivative (Definition [math-00EO]) is zero, i.e.
\[\frac {DV}{dt} = 0\]
Definition. Diffeomorphism and local diffeomorphism [math-00BR]
- June 11, 2024
- October 26, 2024
- Lîm Tsú-thuàn
Definition. Diffeomorphism and local diffeomorphism [math-00BR]
- June 11, 2024
- October 26, 2024
- Lîm Tsú-thuàn
Let \(M_1,M_2\) be differentiable manifolds. A diffeomorphism \(\phi : M_1 \to M_2\) is a map which is
- differentiable
- bijective
- and the inverse \(\phi ^{-1}\) is differentiable.
Definition. Local diffeomorphism [#456]
- June 11, 2024
- October 26, 2024
- Lîm Tsú-thuàn
Definition. Local diffeomorphism [#456]
- June 11, 2024
- October 26, 2024
- Lîm Tsú-thuàn
Let \(\varphi : M \to N\) be a differentiable map, if \(d\varphi _p : T_p M \to T_{\varphi (p)} N\) is an isomorphism, then \(\varphi \) is a local diffeomorphism at \(p\).
Remark. [#457]
- June 11, 2024
- October 26, 2024
- Lîm Tsú-thuàn
Remark. [#457]
- June 11, 2024
- October 26, 2024
- Lîm Tsú-thuàn
Definition. Immersions and embeddings (submanifold) [math-00E9]
- October 26, 2024
- Lîm Tsú-thuàn
Definition. Immersions and embeddings (submanifold) [math-00E9]
- October 26, 2024
- Lîm Tsú-thuàn
A differentiable mapping \(\varphi : M \to N\) is said to be immersion if
\[d\varphi _p : T_p M \to T_{\varphi (p)} N\]is injective for all \(p \in M\).
Remark. [#341]
- October 26, 2024
- Lîm Tsú-thuàn
Remark. [#341]
- October 26, 2024
- Lîm Tsú-thuàn
Say \(M\), \(N\) has dimension \(m\), \(n\), respectively, then \(\varphi \) is an immersion implies \(m \le n\).
If \(\varphi \) is a homeomorphism onto \(\varphi (M) \subset N\), where \(\varphi (M)\) has the subspace topology induced from \(N\), then \(\varphi \) is an embedding, \(M\) is a submanifold of \(N\).
Definition. Gaussian curvature (高斯曲率直覺方式) [math-00E6]
- October 25, 2024
- Lîm Tsú-thuàn
Definition. Gaussian curvature (高斯曲率直覺方式) [math-00E6]
- October 25, 2024
- Lîm Tsú-thuàn
Visual Differential Geometry and Forms: A Mathematical Drama in Five Acts
高斯曲率在點 \(p\) 之公式
\[ \mathcal {K}(p) = \lim _{\Delta _p \to p} \frac {\mathcal {E}(\Delta _p)}{\mathcal {A}(\Delta _p)} \]其中 \(\mathcal {E}(\Delta _p)\) 表示 angular excess,也就是三角形的內角和減去 \(\pi \);\(\mathcal {A}(\Delta _p)\) 表示面積。
Example. [#343]
- October 25, 2024
- Lîm Tsú-thuàn
Example. [#343]
- October 25, 2024
- Lîm Tsú-thuàn
sphere 的高斯曲率:\(\mathcal {K} = +\frac {1}{R^2}\);Hyperbolic Geometry 的高斯曲率:\(\mathcal {K} = -\frac {1}{R^2}\)
Theorem. Angular excess is additive [#344]
- October 25, 2024
- Lîm Tsú-thuàn
Theorem. Angular excess is additive [#344]
- October 25, 2024
- Lîm Tsú-thuàn
令 \(\Delta \) 為曲面上之三角形,考慮一條測地線,從一角 \(\gamma \) 出發到對邊,將 \(\Delta \) 分為兩個三角形 \(\Delta _1\)、\(\Delta _2\)。則
Remark. [#345]
- October 25, 2024
- Lîm Tsú-thuàn
Remark. [#345]
- October 25, 2024
- Lîm Tsú-thuàn
Proof. [#346]
- October 25, 2024
- Lîm Tsú-thuàn
Proof. [#346]
- October 25, 2024
- Lîm Tsú-thuàn
由 \(\beta _1 + \alpha _2 = \pi \) 可知
\[\mathcal {E}(\Delta _1) + \mathcal {E}(\Delta _2) = \alpha + \beta + \gamma _1 + \gamma _2 - \pi = \mathcal {E}(\Delta )\]
Theorem. Local Gauss-Bonnet [math-00E7]
- October 25, 2024
- Lîm Tsú-thuàn
Theorem. Local Gauss-Bonnet [math-00E7]
- October 25, 2024
- Lîm Tsú-thuàn
Visual Differential Geometry and Forms: A Mathematical Drama in Five Acts\[\mathcal {E}(\Delta ) = \alpha + \beta + \gamma - \pi = \iint _\Delta \mathcal {K} d \mathcal {A}\]
Proof. [#342]
- October 25, 2024
- Lîm Tsú-thuàn
Proof. [#342]
- October 25, 2024
- Lîm Tsú-thuàn
First, angular excess is additive, thus if repeatly cut a \(\Delta \) by the method, we get
\[\mathcal {E}(\Delta ) = \sum _i \mathcal {E}(\Delta _i)\]As the subdivision becomes finer and finer, curvature variees less and less each \(\Delta _i\), approaching the constant value \(\mathcal {K}_i\), and in its limit yields
\[\mathcal {E}(\Delta ) = \sum _i \mathcal {K}_i \mathcal {A}(\Delta _i)\]
Example. Finite distributive lattice => frame [math-00E3]
- October 20, 2024
- Lîm Tsú-thuàn
Example. Finite distributive lattice => frame [math-00E3]
- October 20, 2024
- Lîm Tsú-thuàn
Every finite distributive lattice is a frame.
Proof. [#347]
- October 20, 2024
- Lîm Tsú-thuàn
Proof. [#347]
- October 20, 2024
- Lîm Tsú-thuàn
All subsets are finite, thus each of them can define join and meet; and by definition distributive.
Definition. Lifting [math-00E5]
- October 20, 2024
- Lîm Tsú-thuàn
Definition. Lifting [math-00E5]
- October 20, 2024
- Lîm Tsú-thuàn
Let \(X\) be a set, \(X_\bot \) is a pointed poset, by construction
\[X_\bot = X \cup \{ \bot \}\](called \(X\) lifted, or the flat domain on \(X\)), and define a partial order
\[\begin {aligned} &\bot \le \bot \\ &\bot \le x \quad &(x \in X) \\ &x \le y \text { iff } x = y \quad &(x,y \in X) \end {aligned}\]
Definition. Irreducible polynomial [math-00E0]
- October 19, 2024
- Lîm Tsú-thuàn
Definition. Irreducible polynomial [math-00E0]
- October 19, 2024
- Lîm Tsú-thuàn
Let \(D\) be an integral domain, a polynomial \(f(x) \in D[x]\) that
- \(f(x) \ne 0 \in D[x]\)
- \(f(x) \ne 1 \in D[x]\)
is said to be irreducible over \(D\) if, whenever
\[ f(x) = g(x) h(x) \]where \(g(x), h(x) \in D[x]\), then \(g(x) = 1\) or \(h(x) = 1\).
Remark. [#351]
- October 19, 2024
- Lîm Tsú-thuàn
Remark. [#351]
- October 19, 2024
- Lîm Tsú-thuàn
也就是說,沒有辦法把一個不可約多項式表達為兩個多項式的乘積。
Definition. Partial applicative structure [math-00E1]
- October 19, 2024
- Lîm Tsú-thuàn
Definition. Partial applicative structure [math-00E1]
- October 19, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
A partial applicative structure \(A\) consists of
- an inhabited family \(|A|\) of datatypes \(A,B,\dots \), indexed by some set \(T\),
- a (right-associative) binary operation \(\Rightarrow \) on \(|A|\),
- for each \(A, B \in |A|\), a partial function \(\cdot _{AB} : (A \Rightarrow B) \times A \rightharpoonup B\).
Notation. [#348]
- October 19, 2024
- Lîm Tsú-thuàn
Notation. [#348]
- October 19, 2024
- Lîm Tsú-thuàn
We ofren omit \(AB\) from \(\cdot _{AB}\) and treat \(\cdot \) as left-associative.
Definition. Substructure [#349]
- October 19, 2024
- Lîm Tsú-thuàn
Definition. Substructure [#349]
- October 19, 2024
- Lîm Tsú-thuàn
A partial applicative substructure \(A^\#\) of \(A^\circ \) consists of \(A^\# \subset A\) for each datatype \(A \in |A^\circ |\) such that
- if \(f \in (A \Rightarrow B)^\#\) and \(a \in A^\#\), then \(f \cdot a \in B^\#\).
Definition. Relative structure [#350]
- October 19, 2024
- Lîm Tsú-thuàn
Definition. Relative structure [#350]
- October 19, 2024
- Lîm Tsú-thuàn
Above \((A^\circ ; A^\#)\) is a relative partial applicative structure.
- If \(A^\# = A^\circ \), then \((A^\circ ; A^\#)\) is full.
Definition. Typed partial combinatory algebra (TPCA) [math-00E2]
- October 19, 2024
- Lîm Tsú-thuàn
Definition. Typed partial combinatory algebra (TPCA) [math-00E2]
- October 19, 2024
- Lîm Tsú-thuàn
A typed partial combinatory algebra is a partial applicative structure (Definition [math-00E1]) satisfying the following conditions
- For all \(A, B \in |A|\), there is a \(k_{AB} : A \Rightarrow B \Rightarrow A\) such that \[ \forall a.\ k \cdot a \downarrow , \quad \forall a,b.\ k \cdot a \cdot b = a \]
- For all \(A, B, C \in |A|\), there is a \(s_{ABC} : (A \Rightarrow B \Rightarrow C) \Rightarrow (A \Rightarrow B) \Rightarrow (A \Rightarrow C)\) such that \[ \forall f, g.\ s \cdot f \cdot g \downarrow , \quad \forall f,g,a.\ s \cdot f \cdot g \cdot a \simeq (f \cdot a) \cdot (g \cdot a) \]
Any higher-order model yields an underlying TPCA.
LaTeX 如何在公式底下放大括號 (brace under formula) [latex-0003]
LaTeX 如何在公式底下放大括號 (brace under formula) [latex-0003]
範例
\underbrace{x + \cdots + x}_{n-\text{times}}\[ \underbrace {x + \cdots + x}_{n-\text {times}} \]
Definition. Principal ideal domain (PID) [math-00DY]
- October 18, 2024
- Lîm Tsú-thuàn
Definition. Principal ideal domain (PID) [math-00DY]
- October 18, 2024
- Lîm Tsú-thuàn
An integral domain \(R\) is a principal ideal domain if every ideal has the form \(\langle a \rangle = \{ r \cdot a \mid a \in R \}\) for some \(a \in R\).
Theorem. \(F\) a field implies \(F[x]\) a principal ideal domain [math-00DZ]
- October 18, 2024
- Lîm Tsú-thuàn
Theorem. \(F\) a field implies \(F[x]\) a principal ideal domain [math-00DZ]
- October 18, 2024
- Lîm Tsú-thuàn
Let \(F\) be a field, then it's polynomial ring \(F[x]\) is a principal ideal domain.
Proof. [#352]
- October 18, 2024
- Lîm Tsú-thuàn
Proof. [#352]
- October 18, 2024
- Lîm Tsú-thuàn
By \(D\) an integral domain implies \(D[x]\) an integral domain, we know \(F[x]\) is a integral domain. Let \(I\) be an ideal in \(F[x]\), if \(I = \{ 0 \}\), then \(I = \langle 0 \rangle \). Otherwise, \(I \ne \{ 0 \}\)
- Let \(g(x) \in I\) be one of minimum degree
- Since \(g(x) \in I\), we have \(\langle g(x) \rangle \subseteq I\)
- Let \(f(x) \in I\), we might write \(f(x) = g(x)q(x) + r(x)\), only two conditions can hold
- \(r(x) = 0\)
- or \(\deg r(x) < \deg g(x)\)
Definition. Degenerate and non-degenerate (simplex) [math-00DW]
- October 16, 2024
- Lîm Tsú-thuàn
Definition. Degenerate and non-degenerate (simplex) [math-00DW]
- October 16, 2024
- Lîm Tsú-thuàn
With a fixed simplicial set \(X\), a \(n\)-simplex \(x \in X_n\) is said to be degenerate if there is \(m\)-simplex \(y \in X_m\) (\(m < n\)) and a \(\alpha : [n] \to [m]\), such that \(\alpha ^* : X_m \to X_n\) satisfies
\[ x = \alpha ^*(y) \]In words, if there exists a lower \(m\)-simplex and a map from that to this \(n\)-simplex, then this \(n\)-simplex is degenerate.
A \(n\)-simplex is said to be non-degenerate, if it's not degenerate.
Theorem. Caley-Hamilton [math-00DU]
- October 13, 2024
- Lîm Tsú-thuàn
Theorem. Caley-Hamilton [math-00DU]
- October 13, 2024
- Lîm Tsú-thuàn
特徵多項式定義為
\[\Delta _A(\lambda ) = \det (\lambda I_n - A)\]化為矩陣多項式後,代入 \(A\) 結果為零
\[\Delta _A(A) = 0\]
Example. [#353]
- October 13, 2024
- Lîm Tsú-thuàn
Example. [#353]
- October 13, 2024
- Lîm Tsú-thuàn
特徵多項式為 \(\begin {vmatrix}\lambda - 1 & 2 \\ -3 & \lambda - 2\end {vmatrix} = \lambda ^2 - 3 \lambda - 4\),化為矩陣多項式後代入 \(A\) 得
\[ A^2 - 3A - 4I_2 = \begin {bmatrix} 1 & 2 \\ 3 & 2 \end {bmatrix}^2 - 3 \begin {bmatrix} 1 & 2 \\ 3 & 2 \end {bmatrix} - 4 \begin {bmatrix} 1 & 0 \\ 0 & 1 \end {bmatrix} = \begin {bmatrix} 0 & 0 \\ 0 & 0 \end {bmatrix} \]
Theorem. Jordan curve [math-00DR]
- October 5, 2024
- Lîm Tsú-thuàn
Theorem. Jordan curve [math-00DR]
- October 5, 2024
- Lîm Tsú-thuàn
Any simple closed curve cuts the plane to two parts.
Proof. [#354]
- October 5, 2024
- Lîm Tsú-thuàn
Proof. [#354]
- October 5, 2024
- Lîm Tsú-thuàn
Let \(\gamma : [a,b]\to \R ^2\) be a simple closed curve. For any \(p \in \R ^2 \setminus \gamma \) not on the curve, there is a family of vectors
\[ \overrightarrow {p \gamma (t)} \]Take these vectors only by direction form a map \(f_p : [a,b] \to S^1\), and let \(W(p)\) be the degree of \(f_p\).
Consider a very close window, so \(\gamma \) is merely a line, then pick two points \(p_1\) and \(p_2\), such that makes \(|W(p_1) - W(p_2)| = 1\), this is possible because one covers the bottom half of \(S^1\) counterclockwise, the other covers the top half of \(S^1\) clockwise, therefore the difference exactly turned around.
Follow the orientation of \(\gamma \), move the window, can see \(p_1\) and \(p_2\) will not change the coverage at any point of \(\gamma \), and hence there are two path-connected components wrap \(\gamma \).
Finally, for any \(p\) not on the curve \(\gamma \), the shortest path to \(\gamma \) must touch a \(p_1\) or a \(p_2\) first! Thus, the curve indeed cut the plane to two components.
Theorem. Hopf's Umlaufsatz [math-00C6]
- July 3, 2024
- October 3, 2024
- Lîm Tsú-thuàn
Theorem. Hopf's Umlaufsatz [math-00C6]
- July 3, 2024
- October 3, 2024
- Lîm Tsú-thuàn
The rotation index of a simple closed curve \(\gamma \) on plane is either \(1\) or \(-1\).
I highly recommend draw vectors during \(D(1)\) transformation proof step by step.
Proof. [#438]
- July 3, 2024
- October 3, 2024
- Lîm Tsú-thuàn
Proof. [#438]
- July 3, 2024
- October 3, 2024
- Lîm Tsú-thuàn
Let \(\gamma : [a,b] \to \R ^2\) be a simple closed curve.
A crucial step is defined \(\gamma (a) = \gamma (b) = p\), where \(p\) is the tangent point of a \(S^1\) that covers \(\gamma \),
Please try to figure out why this is crucial by yourself.
then consider a triangle
\[T=\{ (t_1, t_2) \mid a \le t_1 \le t_2 \le b \}\]Define a continuous function \(\psi : T \to S^1\) as follows
\[\psi (t_1,t_2)=\begin {cases} \gamma '(t_1) \quad \text {if } t_1 = t_2 \\ -\gamma '(a) \quad \text {if } \{ t_1,t_2 \}=\{ a,b \} \\ \frac {\gamma (t_2) - \gamma (t_1)}{\Vert \gamma (t_2) - \gamma (t_1)\Vert } \quad \text {if } t_1 \ne t_2 \\ \end {cases}\]Thus, for most inputs \(\psi (t_1, t_2)\) is the unit vector from \(\gamma (t_1)\) to \(\gamma (t_2)\). Rest cases are defined to make this function is continuous.
Let \(\alpha _0 : [0,1] \to T\) be the line segment from \((a,a)\) to \((b,b)\)
and \(\alpha _1 : [0,1] \to T\) be the line segment from \((a,a)\) to \((a,b)\) to \((b,b)\)
Now, defines a homotopy from \(\alpha _0\) to \(\alpha _1\), parameterize middle-segments by \(s : [0,1] \to T\) as \(\alpha _s\) to be a continuously family, which means \((s,t) \mapsto \alpha _s(t)\) should be a continuous function from \([0,1] \times [0,1] \to T\).
For each \(s \in [0,1]\), use \(D(s)\) denote the degree of \(\psi \circ \alpha _s : [0,1] \to S^1\).
Use lemma 2 to prove \(D(s)\) is locally constant, this is obvious because each \(s\) should uniquely determined a segment, which leads to same degree (the degree of \(\psi \circ \alpha _s\)). therefore continuous on \([0,1]\).
\(D : [0,1] \to \R \) is integer-valued and continuous, \(D\) must be constant on \([0,1]\), so \(D(1) = D(0)\).
\(D(0)\) by definition is the defree of the unit tangent function of \(\gamma \), which equals to the rotation index of \(\gamma \); we cannot prove \(D(0) = 1 \text { or } -1\), but if we can prove below \(D(1) = 1 \text { or } -1\), we are able to say the proof is complete.
\(D(1)\) must be \(1\) or \(-1\) [#437]
- July 3, 2024
- October 3, 2024
- Lîm Tsú-thuàn
\(D(1)\) must be \(1\) or \(-1\) [#437]
- July 3, 2024
- October 3, 2024
- Lîm Tsú-thuàn
Let's track the transformation:
- From \(\psi (a,a)\) to \(\psi (a,b)\) are vectors \(\vec {aa}\) to \(\vec {ab}\), this is half of circle.
- From \(\psi (a,b)\) to \(\psi (b,b)\) are vectors \(\vec {ab}\) to \(\vec {bb}\), this is another half of circle.
Now we know \(D(1)\) must turn around, and \(\gamma \)'s orientation decides we get \(1\) or \(-1\).
Definition. Noetherian [math-00DO]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Noetherian [math-00DO]
- October 2, 2024
- Lîm Tsú-thuàn
A commutative ring \(R\) is Noetherian if every ideal of \(R\) is finitely generated.
Definition. Free group [math-00DI]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Free group [math-00DI]
- October 2, 2024
- Lîm Tsú-thuàn
A free group \(F(A)\) on set \(A\) will be an initial object in \(\mathcal {F}^A\).
In category language, which means if \(F(A)\) is a free group on \(A\) if there is a set-function \(j : A \to F(A)\) such that, for all groups \(G\) and set-functions \(f : A \to G\), there exists a unique group homomorphism \(\varphi : F(A) \to G\) such that
commutes. Algebra: Chapter 0 proves free group exists for any set \(A\), with beautiful direction-hinted graph. Conclusionally, we can say a free group \(F(A)\) is constructed by
Construction. [#365]
- October 2, 2024
- Lîm Tsú-thuàn
Construction. [#365]
- October 2, 2024
- Lîm Tsú-thuàn
- The elements are list of \(x \in A\) and \(x^{-1} \in A'\), e.g. \(x,y,z \in A\) then \([x, y, z^{-1}] \in F(A)\); the operation is concating lists, this is associative.
- The empty list of element \(e = []\) is the identity of \(F(A)\); since \([] + w = w + [] = w\)
- If \(w\) is reduced list (i.e. remove \(a^{-1} a\) pair), then the inverse of \(w\) is obtained by reversing the list, and replace \(a \in A\) by \(a^{-1} \in A'\) and \(a^{-1}\) by \(a\). Take an example can be more clear: The inverse list of \([a,b^{-1}]\) is \([b, a^{-1}]\), concat them and reduce by step \[ [a,b^{-1}, b, a^{-1}] = [a, a^{-1}] = [] \] Indeed is the identity element \([]\).
Example. [#366]
- October 2, 2024
- Lîm Tsú-thuàn
Example. [#366]
- October 2, 2024
- Lîm Tsú-thuàn
If \(A = \{ a \}\), then \(F(A) \cong \Z \).
Definition. Free abelian group [math-00DL]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Free abelian group [math-00DL]
- October 2, 2024
- Lîm Tsú-thuàn
A free abelian group \(F^{ab}(A)\) on set \(A\), means there is a set-function \(j : A \to F^{ab}(A)\) such that, for all abelian group \(G\) and set-functions \(f : A \to G\), there exists a unique group homomorphism \(\varphi : F^{ab}(A) \to G\) such that the following diagram commutes
Therefore, \(F^{ab}(A)\) is an initial object of the category of abelian groups \(Ab\).
Notation. [#359]
- October 2, 2024
- Lîm Tsú-thuàn
Notation. [#359]
- October 2, 2024
- Lîm Tsú-thuàn
- generalize this \(n \in \N \) with arbitrary set \(A\)
- use \(\Z ^{\oplus A}\) to denote the direct sum of these \(\Z \)
- each elements of \(i \in A\) maps to \(1 \in \Z \) at \(i\)-th place, denote this map \(j : A \to \Z ^{\oplus A}\)
Proposition. For any set \(A\), \(F^{ab}(A) \cong \Z ^{\oplus A}\) [#360]
- October 2, 2024
- Lîm Tsú-thuàn
Proposition. For any set \(A\), \(F^{ab}(A) \cong \Z ^{\oplus A}\) [#360]
- October 2, 2024
- Lîm Tsú-thuàn
Proof. [#361]
- October 2, 2024
- Lîm Tsú-thuàn
Proof. [#361]
- October 2, 2024
- Lîm Tsú-thuàn
Each element of \(\Z ^{\oplus A}\) can be written
\[ \sum _{a \in A} m_a j(a), m_a \ne 0 \text { for finitely many } a \in A\]For any abelian group \(G\), we can define \(\varphi : \Z ^{\oplus A} \to G\) as
\[ \varphi \big ( \sum _{a \in A} m_a j(a) \big ) := \sum _{a \in A} m_a f(a) \]Then check \(\varphi \) is a homomorphism, by commutativity, internal \(m_a\) can put together, so proved.
Definition. Free module [math-00DM]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Free module [math-00DM]
- October 2, 2024
- Lîm Tsú-thuàn
A free \(R\)-module \(F^R(A)\) on a set \(A\) is an initial object in \(R\)-Mod. Since the category of abelian groups \(Ab\) is the category of \(\Z \)-modules \(\Z \)-Mod, it's natural to ask \(R^{\oplus A} \cong F^R(A)\)
Proposition. \(R^{\oplus A} \cong F^R(A)\) [#356]
- October 2, 2024
- Lîm Tsú-thuàn
Proposition. \(R^{\oplus A} \cong F^R(A)\) [#356]
- October 2, 2024
- Lîm Tsú-thuàn
Proof. [#357]
- October 2, 2024
- Lîm Tsú-thuàn
Proof. [#357]
- October 2, 2024
- Lîm Tsú-thuàn
The proof is basically same as free abelian group, by replacing \(\Z \) with general \(R\).
Construction. [#358]
- October 2, 2024
- Lîm Tsú-thuàn
Construction. [#358]
- October 2, 2024
- Lîm Tsú-thuàn
The construction of \(b : A \to R^{\oplus A}\) is clear
\[ b(x) = (b_i(x), b_j(x), \dots ) \]such that, for all \(x \in A\)
\[ b_i(x) := \begin {cases} 1 \text { if } x = i \\ 0 \text { if } x \ne i \end {cases} \]so that every element of \(R^{\oplus A}\) can be written uniquely as a finite sum
\[ \sum _{a\in A} r_a b(a) \]i.e. as finite sum means only finite many \(r_a \ne 0\).
Definition. Free algebra [math-00DN]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Free algebra [math-00DN]
- October 2, 2024
- Lîm Tsú-thuàn
Switch from \(R\)-modules to commutative \(R\)-algebras: polynomial ring \(R[A]\) is a free commutative \(R\)-algebra on the set \(A\).
Definition. Isometry [math-00DJ]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Isometry [math-00DJ]
- October 2, 2024
- Lîm Tsú-thuàn
An isometry of \(n\)-dimensional space \(\R ^n\) is a function \(\R ^n \to \R ^n\) that preserves distance.
Definition. Symmetry group of a figure in \(\R ^n\) space [math-00DX]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Symmetry group of a figure in \(\R ^n\) space [math-00DX]
- October 2, 2024
- Lîm Tsú-thuàn
Let \(F \subseteq \R ^n\) be a set of points in \(\R ^n\), the symmetry group of \(F\) in \(\R ^n\) is the set of all isometries of \(\R ^n\) that carry \(F\) onto itself. The group operation \(\cdot \) is function composition \(\circ \).
Definition. Solvable [math-00DK]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Solvable [math-00DK]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Tower of subgroups [#362]
- October 2, 2024
- Lîm Tsú-thuàn
Definition. Tower of subgroups [#362]
- October 2, 2024
- Lîm Tsú-thuàn
Let \(G\) be a group, a sequence of subgroups is the tower.
\[ G = G_0 \supset G_1 \supset G_2 \supset \cdots \supset G_m \]
Normal tower [#363]
- October 2, 2024
- Lîm Tsú-thuàn
Normal tower [#363]
- October 2, 2024
- Lîm Tsú-thuàn
If each \(G_{i+1}\) is normal in \(G_i\), then the tower is said to be normal.
Abelian tower [#364]
- October 2, 2024
- Lîm Tsú-thuàn
Abelian tower [#364]
- October 2, 2024
- Lîm Tsú-thuàn
If the tower is normal, and each factor group \(G_i / G_{i+1}\) is abelian, then the tower is said to be abelian.
A group \(G\) is said to be solvable if it has an abelian tower, whose last element \(G_m\) is the trivial subgroup.
Type theory 中不同理論的連結 [tt-001W]
- October 1, 2024
- Lîm Tsú-thuàn
Type theory 中不同理論的連結 [tt-001W]
- October 1, 2024
- Lîm Tsú-thuàn
Algebraic Theories (first-order languages) [#289]
- October 1, 2024
- Lîm Tsú-thuàn
Algebraic Theories (first-order languages) [#289]
- October 1, 2024
- Lîm Tsú-thuàn
- CT: categories, functors, natural transformations, products
- Application: syntactic category, Lawvere’s functorial semantics
Simply-Typed Lambda Calculus (STLC) [#290]
- October 1, 2024
- Lîm Tsú-thuàn
Simply-Typed Lambda Calculus (STLC) [#290]
- October 1, 2024
- Lîm Tsú-thuàn
- CT: Cartesian Closed Categories, Yoneda Lemma, representable functors
- Application: semantics of STLC, categorical gluing, conservatively
System F [#291]
- October 1, 2024
- Lîm Tsú-thuàn
System F [#291]
- October 1, 2024
- Lîm Tsú-thuàn
- CT: adjunctions, indexed categories
- Application: semantics of System F
Inductive and recursive types [#292]
- October 1, 2024
- Lîm Tsú-thuàn
Inductive and recursive types [#292]
- October 1, 2024
- Lîm Tsú-thuàn
F-algebra 中的 initial/terminal 等特殊 object
- CT: limits and colimits, fixed points of functors
- Application: semantics of inductive types, domain equations
Linear types [#293]
- October 1, 2024
- Lîm Tsú-thuàn
Linear types [#293]
- October 1, 2024
- Lîm Tsú-thuàn
- CT: symmetric monoidal categories, touch on comonads
- Application: linear/non-linear model of linear logic
Effects [#294]
- October 1, 2024
- Lîm Tsú-thuàn
Effects [#294]
- October 1, 2024
- Lîm Tsú-thuàn
- CT: monads, algebras, Kleisli category
- Application: monads for effects, algebraic effects and handlers
Proposition. The tangent bundle is orientable [math-00DH]
- September 29, 2024
- Lîm Tsú-thuàn
Proposition. The tangent bundle is orientable [math-00DH]
- September 29, 2024
- Lîm Tsú-thuàn
The tangent bundle \(TM\) is orientable even when the manifold \(M\) is not.
Proof. [#367]
- September 29, 2024
- Lîm Tsú-thuàn
Proof. [#367]
- September 29, 2024
- Lîm Tsú-thuàn
We need to show \(y_\beta ^{-1} \circ y_\alpha \) (reparameterize on \(TM\)) has positive determinant, whenever what determinant \(x_\beta ^{-1} \circ x_\alpha \) (reparameterize on \(M\)) has. Let's view reparameterizations as matrices, and by definition \(x_\beta ^{-1} \circ x_\alpha \) works on \(M\) part and \(d(x_\beta ^{-1} \circ x_\alpha )\) works on tangent vectors.
Thus, we can view the reparameterization matrix on \(TM\) as (fill zeros to fit the dimension)
\[\begin {bmatrix} x_\beta ^{-1} \circ x_\alpha & 0 \\ 0 & d(x_\beta ^{-1} \circ x_\alpha ) \end {bmatrix}\]Then we can see that \(y_\beta ^{-1} \circ y_\alpha \) must have positive determinant, since \(d(x_\beta ^{-1}\circ x_\alpha )\) will have the same determinant as \(x_\beta ^{-1}\circ x_\alpha \), so
- if \(x_\beta ^{-1}\circ x_\alpha \) is non-orientable, then the big matrix will cancel the negative, so has positive determinant;
- else it's orientable, then the big matrix directly has positive determinant.
Definition. Determinant of matrix [math-00DF]
- September 29, 2024
- Lîm Tsú-thuàn
Definition. Determinant of matrix [math-00DF]
- September 29, 2024
- Lîm Tsú-thuàn
Definition. Cofactor [#371]
- September 29, 2024
- Lîm Tsú-thuàn
Definition. Cofactor [#371]
- September 29, 2024
- Lîm Tsú-thuàn
The cofactor of an element \(a_{ij}\) of a matrix \(A\) is called \(a^{ij}\) and is defined as \((-1)^{i+j}\) times the determinant of the \((n-1) \times (n-1)\) matrix formed by eliminating from \(A\) the row and column that \(a_{ij}\) belongs to.
With definition of cofactor, we now can define
\[ \det (A) = \sum ^n_{j=1} a_{ij} a^{ij} \]for any fixed \(i\). This recursively defines a determinant for any rank matrix.
Example. [#372]
- September 29, 2024
- Lîm Tsú-thuàn
Example. [#372]
- September 29, 2024
- Lîm Tsú-thuàn
For \(2\times 2\) matrix, we have
\[\begin {bmatrix}a & b \\ c & d\end {bmatrix}\]The determinant of such matrix is defined as \(ad - bc\).
Definition. Signature of metric tensor [math-00DG]
- September 29, 2024
- Lîm Tsú-thuàn
Definition. Signature of metric tensor [math-00DG]
- September 29, 2024
- Lîm Tsú-thuàn
Consider a Riemann metric \(g\) (use angle notation \(\langle -,- \rangle \)), it's a \(\begin {pmatrix}0 \\ 2\end {pmatrix}\) tensor (i.e. it takes two vectors and returns a real number). By definition, \(g\) is symmetric, and hence if use basis of tangent space \(\frac {\partial }{\partial x^i}\) as input vectors, form a symmetric matrix
\[ g_{ij} = \langle \frac {\partial }{\partial x^i}, \frac {\partial }{\partial x^j} \rangle \]
Flat condition [#368]
- September 29, 2024
- Lîm Tsú-thuàn
Flat condition [#368]
- September 29, 2024
- Lîm Tsú-thuàn
As view \(\R ^n\) as a manifold (and when a Riemannian metric is flat) said, we say the metric is the Euclidean metric (flat) if \(g_{ij} = \delta _{ij}\).
But if \(g_{ij}\) is not flat, we want to see if we can simplify it, and indeed there is a way to do so.
Definition. Canonical form [#369]
- September 29, 2024
- Lîm Tsú-thuàn
Definition. Canonical form [#369]
- September 29, 2024
- Lîm Tsú-thuàn
Geometrical Methods of Mathematical Physics §2.29
Consider a transformation \(\Lambda \), we get
\[ g_{i'j'} = \Lambda ^k_{\ \ i'} \Lambda ^l_{\ \ j'} g_{kl} \]Which can also be viewed as \( \Lambda ^T g \Lambda \). Since \(\Lambda \) is picked by us, and \(g\) is symmetric, it's make sense to let
\[ \Lambda = OD \]where \(O^T = O^{-1}\) is a orthogonal matrix and \(D^T = D\) is a diagonal matrix. In this selection, we get
\[ \Lambda ^T = (OD)^T = D^T O^T = D O^{-1} \]and hence, we get
\[ DO^{-1}gOD \]Introduction to Linear Algebra §6.4
\(g\) is symmetric, thus, \(O^{-1}gO = g_d\) is a diagonal matrix, now say if \(g_d = \text {diag}(g_1, g_2, \dots , g_n)\), then we pick
\[ D = \text {diag}(d_1, d_2, \dots , d_n) \]such that \(d_i = \sqrt {\vert g_i \vert }\), then output diagonal matrix will only have \(1\) or \(-1\) as component on the diagonal line. If we choose \(O\) to let all \(1\) or all \(-1\) appear first, we call it the canonical form of metric \(g\). The canonical form is an orthonormal basis.
Definition. Signature [#370]
- September 29, 2024
- Lîm Tsú-thuàn
Definition. Signature [#370]
- September 29, 2024
- Lîm Tsú-thuàn
The sum of the canonical form's diagonal elements (i.e. the trace of the canonical form) is called the signature of the metric \(g\).
If the canonical form is positive-definite or negative-definite, it's flat.
Example. Minkowski metric [math-00EI]
- September 29, 2024
- Lîm Tsú-thuàn
Example. Minkowski metric [math-00EI]
- September 29, 2024
- Lîm Tsú-thuàn
A metric is called a Minkowski metric if it's canonical form is \(\text {diag}(-1, 1, 1, 1)\) or \(\text {diag}(1, -1, -1, -1)\). The special relativity has such a metric for \(n = 4\).
Remark. [#328]
- September 29, 2024
- Lîm Tsú-thuàn
Remark. [#328]
- September 29, 2024
- Lîm Tsú-thuàn
The inverse of Minkowski metric is Minkowski metric.
Definition. Discontinuous action of a group [math-00DC]
- September 24, 2024
- Lîm Tsú-thuàn
Definition. Discontinuous action of a group [math-00DC]
- September 24, 2024
- Lîm Tsú-thuàn
Riemannian Geometry p.22
A group \(G\) acts on a differentiable manifold \(M\) if there exists a map \(\varphi : G \times M \to M\) such that
- For each \(g \in G\), defines \[ \varphi _g : M \to M \varphi _g(p) = \varphi (g, p) \] and \(\varphi _{1_G}(p) = p\) (i.e. identity map)
- For \(a, b \in G\), defines composition like \[\varphi _{ab} = \varphi _a \circ \varphi _b\]
Remark. [#373]
- September 24, 2024
- Lîm Tsú-thuàn
Remark. [#373]
- September 24, 2024
- Lîm Tsú-thuàn
這裡讓一個群 \(G\) 的元素與 \(M \to M\) 的各種變換一一對應
Definition. Properly discontinuous [#374]
- September 24, 2024
- Lîm Tsú-thuàn
Definition. Properly discontinuous [#374]
- September 24, 2024
- Lîm Tsú-thuàn
The action is properly discontinuous if each \(p \in M\) has a neighborhood \(U\) such that \(U \cap \varphi _g(U) = \varnothing \) for all \(g \ne 1_G\)
Remark. [#375]
- September 24, 2024
- Lîm Tsú-thuàn
Remark. [#375]
- September 24, 2024
- Lîm Tsú-thuàn
Definition. 等價類 \(M / G\) [#376]
- September 24, 2024
- Lîm Tsú-thuàn
Definition. 等價類 \(M / G\) [#376]
- September 24, 2024
- Lîm Tsú-thuàn
這個想法很自然的延伸就是定義一個等價類,令 \(a \sim b\) 若且唯若存在某個 \(g \in G\) 滿足 \(b = \varphi _g(a)\)。這個就是 \(M / G\)
Example. Projective spaces [#377]
- September 24, 2024
- Lîm Tsú-thuàn
Example. Projective spaces [#377]
- September 24, 2024
- Lîm Tsú-thuàn
projective spaces 是定義為 \(S^n\) 取 \(x \sim -x\),這表示也可以定義成由群 \(G = \{ A, A^2 = I \}\) 所產生的 quotient space \(S^n / G\)。其中 \(A\) 表示 antipodal mapping
\[ A(x) = -x \]
Coloring 演算法:DSATUR [cs-001J]
- September 14, 2024
- Lîm Tsú-thuàn
Coloring 演算法:DSATUR [cs-001J]
- September 14, 2024
- Lîm Tsú-thuàn
W <- G.vertices -- W 表示 working set while W ≠ ∅ -- 1. 從 W 選出有最大 saturation 的頂點 u -- 2. 選出不在鄰邊的顏色集合中,最小的顏色 c color[u] <- c -- 3. 分配顏色 c 給 u W <- W - {u} -- 從 W 中刪除 u
這個演算法還需要最大 saturation 的定義:
\[ \text {saturation}(u) = \{ c \;|\; \exists v. v\in \text {adjacent}(u) \;\text {and}\; \text {color}(v) = c \} \]saturation 是一個集合,最大指的是該集合的大小, 所以 \(W\) 可以用 leftist tree 之類的結構來快速選出有最大 saturation set 的那個頂點
Tikz 繪製 string diagram 的教學 [software-0014]
Tikz 繪製 string diagram 的教學 [software-0014]
在連結中有詳細的教學,此外要注意放入
\usepackage{tikz} \usepackage{pgfkeys} \usetikzlibrary {backgrounds,arrows}
才能在 latex 中正常使用
Definition. Quantale [math-00DA]
- September 10, 2024
- Lîm Tsú-thuàn
Definition. Quantale [math-00DA]
- September 10, 2024
- Lîm Tsú-thuàn
Seven Sketches in Compositionality: An Invitation to Applied Category Theory
A unital commutative quantale is a symmetric monoidal closed preorder \(\mathcal {V} = (V, \le , I, \otimes , \multimap )\) that has all joins \(\vee A\) exists for all \(A \subseteq V\). The empty join often denote as \(0 := \vee \varnothing \).
If the preorder is non-symmetric, we got non-commutative quantale obviously.
Klesli category [math-00D9]
- September 8, 2024
- Lîm Tsú-thuàn
Klesli category [math-00D9]
- September 8, 2024
- Lîm Tsú-thuàn
A Klesli category \(C^M\) related with a monad \(M : C \to C\) is consisting
- each object \(X \in C^M\) is also an object of \(C\).
- each morphism \(f : X \to Y\) in \(C^M\) is a \(f : X \to M\;Y\) in \(C\).
We will need to check the idea really works, for each object \(X\), the identity morphism \(X \to M\;X\) is given by \(\eta \) of \(M\).
For any two morphisms \(f : X \to M\;Y\) and \(g : Y \to M\;Z\), the composition is
Monad [math-00D8]
- September 5, 2024
- Lîm Tsú-thuàn
Monad [math-00D8]
- September 5, 2024
- Lîm Tsú-thuàn
monad 是一個 endofunctor,所以必然跟某個範疇 \(C\) 有關,具有 \(M : C \to C\) 的簽名。並且,有兩個 natural transformation
- \(\eta : 1_C \to M\)
- \(\mu : M \circ M \to M\)
並滿足 monoid 條件。第一是 \(\mu \cdot (\eta \circ M) = id = \mu \cdot (M \circ \eta )\)
第二是 \(\mu \cdot (\mu \circ M) = \mu \cdot (M \circ \mu )\)
因此我們才說 monad 是 endofunctors 構成的 category 中的一個 monoid object。
Create boot USB on MacOS [disk-0001]
- August 15, 2024
- Lîm Tsú-thuàn
Create boot USB on MacOS [disk-0001]
- August 15, 2024
- Lîm Tsú-thuàn
diskutil list diskutil unmountDisk /dev/diskN sudo dd if=/CentOS-6.6-x86_64-bin-DVD1.iso of=/dev/diskN
Forester 輸出 pdf 的方法 [forester-000B]
- January 5, 2024
- July 28, 2024
- Lîm Tsú-thuàn
- https://lists.sr.ht/~jonsterling/forester-discuss
Forester 輸出 pdf 的方法 [forester-000B]
- January 5, 2024
- July 28, 2024
- Lîm Tsú-thuàn
- https://lists.sr.ht/~jonsterling/forester-discuss
執行 forester build
之後,在 output
目錄中會出現所有的 xxx-NNNN.xml
文件。接著使用 forester-to-latex 中的 xsl 檔案跟 xsltproc
產出 tex 檔案再產生 pdf
xsltproc ./book.xsl ~/blog/trees/math-00D3.xml > test.tex latexmk -interaction=nonstopmode -lualatex xxx-NNNN.tex
Latex 中文支援設定 [latex-0001]
- January 5, 2024
- Lîm Tsú-thuàn
Latex 中文支援設定 [latex-0001]
- January 5, 2024
- Lîm Tsú-thuàn
latex 支援中文需要安插以下的 latex 程式
\usepackage[UTF8]{ctex} \setCJKmainfont{Songti TC} \setCJKmonofont{inconsolata} \renewcommand*{\proofname}{Proof}
註:因為 forster 已經使用了 inconsolata
所以我只是把 setmonofont
修改成 setCJKmonofont
;但處理 setCJKmainfont
要記得檢查系統有什麼繁中字型不能照抄。
Theorem. Kleene's first model 與 Closed lambda terms 不等價 [math-00CZ]
- July 22, 2024
- Lîm Tsú-thuàn
Theorem. Kleene's first model 與 Closed lambda terms 不等價 [math-00CZ]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#391]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#391]
- July 22, 2024
- Lîm Tsú-thuàn
我們從 Proposition [math-00D1] 跟兩個 lemma 得知 \(\mathcal {K}_1 \not \simeq \Lambda ^0 /_{=\beta }\)。
Lemma. Partial combinartory algebra 沒有 decidable equality [math-00D0]
- July 22, 2024
- Lîm Tsú-thuàn
Lemma. Partial combinartory algebra 沒有 decidable equality [math-00D0]
- July 22, 2024
- Lîm Tsú-thuàn
所有 PCA 都沒有 decidable equality。
Proof. [#390]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#390]
- July 22, 2024
- Lîm Tsú-thuàn
考慮一個 PCA \(A\),假定有元素 \(d \in A^\#\) 是一個 decidable equality,這表示對任意 \(x, y \in A\)
\[ d \cdot x \cdot y = \begin {aligned} \begin {cases} \text {true} &\text { if } x = y \\ \text {false} &\text { otherwise} \end {cases} \end {aligned} \]只要定義 \(v = Y(d\ \text {false})\) 就能得到 \(v = d\ \text {false}\ v\),其值不可判定,所以 \(d\) 不是 decidable equality。
Lemma. \(\mathcal {K}_1\) 有 decidable equality [#392]
- July 22, 2024
- Lîm Tsú-thuàn
Lemma. \(\mathcal {K}_1\) 有 decidable equality [#392]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#393]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#393]
- July 22, 2024
- Lîm Tsú-thuàn
Proposition. If two computability models are equivalent, then decidable equality exists for one iff another has one [math-00D1]
- July 22, 2024
- Lîm Tsú-thuàn
Proposition. If two computability models are equivalent, then decidable equality exists for one iff another has one [math-00D1]
- July 22, 2024
- Lîm Tsú-thuàn
若 \(A\) 跟 \(B\) model 等價 \(A \simeq B\),則 \(A\) 有 decidable equality 若且唯若 \(B\) 也有 decidable equality。
Proof. [#389]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#389]
- July 22, 2024
- Lîm Tsú-thuàn
Definition. Computability model of lambda terms [math-00CY]
- July 22, 2024
- Lîm Tsú-thuàn
Definition. Computability model of lambda terms [math-00CY]
- July 22, 2024
- Lîm Tsú-thuàn
The set of lambda terms \(\Lambda / _\sim \) with \(\alpha \) and \(\beta \) equivalence form a computability model.
Weak product [#394]
- July 22, 2024
- Lîm Tsú-thuàn
Weak product [#394]
- July 22, 2024
- Lîm Tsú-thuàn
Check that \(\text {fst}(\text {pair}\ M\ N) \sim M\) and \(\text {snd}(\text {pair}\ M\ N) \sim N\)
Weak terminal [#395]
- July 22, 2024
- Lîm Tsú-thuàn
Weak terminal [#395]
- July 22, 2024
- Lîm Tsú-thuàn
Any element can play the role of a weak terminal: \(\lambda x. i\) for all \(i \in \Lambda / _\sim \)
Weak cartesian closed [#396]
- July 22, 2024
- Lîm Tsú-thuàn
Weak cartesian closed [#396]
- July 22, 2024
- Lîm Tsú-thuàn
Let \(\cdot \) be given by application, if \(M \in \Lambda \) induces an operation in \([L \bowtie L, L]\) representing some \(f : L \times L \to L\) then \(\lambda xy. M(\text {pair}\ x\ y)\) induces the corresponding operation in \(L, L \Rightarrow L\); conversely, if \(N\) induces an operation in \([L, L \Rightarrow L]\), then \(\lambda z. N (\text {fst}\ z) (\text {snd}\ z)\) induces the corresponding one in \([L \bowtie L, L]\).
Definition. Closed terms [#397]
- July 22, 2024
- Lîm Tsú-thuàn
Definition. Closed terms [#397]
- July 22, 2024
- Lîm Tsú-thuàn
There is a submodel \(\Lambda ^0/_\sim \) for closed terms.
Notation. Use \(\beta \)-equivalence [#398]
- July 22, 2024
- Lîm Tsú-thuàn
Notation. Use \(\beta \)-equivalence [#398]
- July 22, 2024
- Lîm Tsú-thuàn
Use \(\beta \)-equivalence then we denote \(\Lambda / _{=_\beta }\).
Theorem. Lambda 通過 K1 再編碼 lambda 不能從 lambda 的 identity 得出 [math-00D2]
- July 22, 2024
- Lîm Tsú-thuàn
Theorem. Lambda 通過 K1 再編碼 lambda 不能從 lambda 的 identity 得出 [math-00D2]
- July 22, 2024
- Lîm Tsú-thuàn
記號繼承自 Higher-Order Computability
標題的描述有點複雜,但其實只是說 \(\kappa \circ \gamma \not \succeq id_{\Lambda ^0 /_{=_\beta }}\),表示 \(\kappa \circ \gamma \) 不是 lambda-definiable。
Proof. [#381]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#381]
- July 22, 2024
- Lîm Tsú-thuàn
兩個 computability model 的等價 \(\simeq \),表示他們可以互相模擬並且兩個模擬的兩種組合都跟模擬自己的函數相似。Kleene's first model \(\mathcal {K}_1\) 與 closed lambda terms \(\Lambda ^0 /_{=_\beta }\) 的模擬細節定義在下面,由於兩者都只有一個 datatype,所以元素的選擇是明顯的。
Definition. \(\Lambda ^0 /_{=_\beta }\) 模擬 \(\mathcal {K}_1\) [#382]
- July 22, 2024
- Lîm Tsú-thuàn
Definition. \(\Lambda ^0 /_{=_\beta }\) 模擬 \(\mathcal {K}_1\) [#382]
- July 22, 2024
- Lîm Tsú-thuàn
\(\kappa : \mathcal {K}_1 \triangleright \Lambda ^0 /_{=_\beta }\) 由以下關係定義
\[ M \Vdash ^\kappa n \text { iff } M =_\beta \widetilde {n} =_\beta \lambda f.\lambda x. f^n x \]\(f^n\) 表示重複 \(f\) 剛好 \(n\) 次
Definition. \(\mathcal {K}_1\) 模擬 \(\Lambda ^0 /_{=_\beta }\) [#383]
- July 22, 2024
- Lîm Tsú-thuàn
Definition. \(\mathcal {K}_1\) 模擬 \(\Lambda ^0 /_{=_\beta }\) [#383]
- July 22, 2024
- Lîm Tsú-thuàn
\(\gamma : \Lambda ^0 /_{=_\beta } \triangleright \mathcal {K}_1\) 由以下關係定義
\[ n \Vdash ^\gamma [M] \text { iff } n = \lceil M' \rceil \text { for some } M' =_\beta M \]\(\lceil M' \rceil \) 是某種 Gödel 編碼
在回答下面兩個問題之前,我們要考慮 \(\gamma \circ \kappa : \mathcal {K}_1 \triangleright \mathcal {K}_1\) 會建立什麼?展開我們可以看到
\[ \gamma \circ \kappa (n) = \gamma (\kappa (n)) = \gamma (\widetilde {n}) = \lceil \widetilde {n} \rceil \]
Lemma. \(\gamma \circ \kappa \preceq id_{\mathcal {K}_1}\) [#384]
- July 22, 2024
- Lîm Tsú-thuàn
Lemma. \(\gamma \circ \kappa \preceq id_{\mathcal {K}_1}\) [#384]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#385]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#385]
- July 22, 2024
- Lîm Tsú-thuàn
Lemma. \(\gamma \circ \kappa \succeq id_{\mathcal {K}_1}\) [#386]
- July 22, 2024
- Lîm Tsú-thuàn
Lemma. \(\gamma \circ \kappa \succeq id_{\mathcal {K}_1}\) [#386]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#387]
- July 22, 2024
- Lîm Tsú-thuàn
Proof. [#387]
- July 22, 2024
- Lîm Tsú-thuàn
反過來就困難得多,\(\kappa \circ \gamma : \Lambda ^0 /_{=_\beta } \triangleright \Lambda ^0 /_{=\beta }\) 展開可以得到
\[ \kappa \circ \gamma (M) = \kappa (\gamma (M)) = \kappa (\lceil M \rceil ) = \widetilde {\lceil M \rceil } \]
Lemma. \(\kappa \circ \gamma \preceq id_{\Lambda ^0 /_{=_\beta }}\) [#388]
- July 22, 2024
- Lîm Tsú-thuàn
Lemma. \(\kappa \circ \gamma \preceq id_{\Lambda ^0 /_{=_\beta }}\) [#388]
- July 22, 2024
- Lîm Tsú-thuàn
這裡需要用到 Kleene enumeration theorem,說明存在一個 \(P \in \Lambda ^0\),令式
\[ P(\widetilde {\lceil M \rceil }) =_\beta M \]對所有 \(M \in \Lambda ^0\) 成立。直覺上來說,是因為我們可以從外部看到 \(\lceil M \rceil \) 的定義之後再找滿足條件的 \(P\)。
Definition. Kleene's first model [math-00CV]
- July 20, 2024
- Lîm Tsú-thuàn
Definition. Kleene's first model [math-00CV]
- July 20, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
Kleene's first model \(\mathcal {K}_1\) is a computability model consists of
- the single datatype \(\N \)
- operations are Turing computable partial functions \(\N \rightharpoonup \N \)
The model has standard products, the computable operation
\[ \langle m,n \rangle = (m+n)(m+n+1)/2 + m \]defines a bijection \(\N \times \N \to \N \) and satisfied weak product. Any element \(i \in \N \) may serve as a weak terminal, because \(\Lambda n. i\) is computale.
Weakly cartesian closed structure [#399]
- July 20, 2024
- Lîm Tsú-thuàn
Weakly cartesian closed structure [#399]
- July 20, 2024
- Lîm Tsú-thuàn
Here \(\N \Rightarrow \N \) can only be \(\N \), so need a suitable operation \(\cdot : \N \times \N \to \N \). Let \(T_0, T_1, \dots \) be some chosen enumeration of all Turing machines for computing partial functions \(\N \rightharpoonup \N \), then there is a Turing machine that accepts two inputs \(e, a\) and returns the result of applying the machine \(T_e\) to the single input \(a\).
Representable of \(f : \N \times \N \rightharpoonup \N \) [#400]
- July 20, 2024
- Lîm Tsú-thuàn
Representable of \(f : \N \times \N \rightharpoonup \N \) [#400]
- July 20, 2024
- Lîm Tsú-thuàn
The partial functions \(f : \N \times \N \rightharpoonup \N \) representable within the model via the standard product operations are just the partial computable ones. We may also see that these coincide exactly with those represented by some total computable \(\tilde {f} : \N \to \N \), in the sense that \(f(c,a) \simeq \tilde {f}(c) \cdot a\) for all \(c,a \in \N \).
Proof. [#401]
- July 20, 2024
- Lîm Tsú-thuàn
Proof. [#401]
- July 20, 2024
- Lîm Tsú-thuàn
One half of this is immediate: given a computable \(\tilde {f}\) the operation \(\Lambda (c,a). \tilde {f}(c) \cdot a\) is computable. The other half is precisely the content of Kleene's s-m-n from basic computability theory: for any Turing machine \(T\) accepting two arguments, there is a machine \(T'\) accepting one argument such that for each \(c\), \(T'(c)\) is an index for a machine computing \(T(c,a)\) from \(a\).
Definition. Weak product [math-00CW]
- July 20, 2024
- Lîm Tsú-thuàn
Definition. Weak product [math-00CW]
- July 20, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
A computability model \(\mathbb {C}\) has weak (binary cartesian) products if there is an operation assigning to each \(A,B \in \vert \mathbb {C} \vert \) a datatype \(A \bowtie B \in \vert \mathbb {C} \vert \) along with operations \(\pi _A \in \mathbb {C}[A \bowtie B, A]\) and \(\pi _B \in \mathbb {C}[A \bowtie B, B]\), such that for any \(f \in C[C,A]\) and \(g \in \mathbb {C}[C,B]\), there exists \(\langle f,g \rangle \in \mathbb {C}[C, A \bowtie B]\) satisfying the following for all \(c \in C\).
- \(\langle f,g \rangle (c) \downarrow \) iff \(f(c) \downarrow \) and \(g(c) \downarrow \)
- if \(\langle f,g \rangle (c)\) is defined, then \(\pi _A(\langle f,g \rangle (c)) = f(c)\) and \(\pi _B(\langle f,g \rangle (c)) = g(c)\)
We say that \(d \in A \bowtie B\) represents the pair \((a,b)\) if \(\pi _A(d) = a\) and \(\pi _B(d) = b\).
Definition. Higher-order structures and (computability) models [math-00CU]
- July 19, 2024
- Lîm Tsú-thuàn
Definition. Higher-order structures and (computability) models [math-00CU]
- July 19, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
Definition. Higher-order structure [#402]
- July 19, 2024
- Lîm Tsú-thuàn
Definition. Higher-order structure [#402]
- July 19, 2024
- Lîm Tsú-thuàn
A higher-order structure is a computability model \(C\) possessing a weak terminal \((I,i)\), and endowed with the following for each \(A, B \in \vert C \vert \)
- a choice of datatype \(A \Rightarrow B \in \vert C \vert \)
- a partial function \(\cdot _{AB} : (A \Rightarrow B) \times A \rightharpoonup B\) (external to the structure of \(C\)).
Notation. Computable elements [#403]
- July 19, 2024
- Lîm Tsú-thuàn
Notation. Computable elements [#403]
- July 19, 2024
- Lîm Tsú-thuàn
The weak terminal picks out a subset \(A^\#\) for each \(A \in |C|\), namely the set of elements of the form \(f(i)\) where \(f \in C[I, A]\) and \(f(i) \downarrow \).
Remark. [#404]
- July 19, 2024
- Lîm Tsú-thuàn
Remark. [#404]
- July 19, 2024
- Lîm Tsú-thuàn
Intuitively, \(A^\#\) plays the role of the computable elements of \(A\).
Definition. Higher-order model [#405]
- July 19, 2024
- Lîm Tsú-thuàn
Definition. Higher-order model [#405]
- July 19, 2024
- Lîm Tsú-thuàn
A higher-order (computability) model is a higher-order structure \(C\) satisfying the following conditions for some (or equivalently any) weak terminal \((I,i)\)
- A partial function \(f : A \rightharpoonup B\) is present in \(C[A,B]\) iff there exists \(\hat {f} \in C[I, A \Rightarrow B]\) such that \[\hat {f}(i) \downarrow , \quad \forall a \in A. \ \hat {f}(i) \cdot a \simeq f(a)\]
- For any \(A,B \in \vert C \vert \), there exists \(k_{AB} \in (A \Rightarrow B \Rightarrow A)^\#\) such that \[\forall a. \ k_{AB} \cdot a \downarrow , \quad \forall a,b. \ k_{AB} \cdot a \cdot b = a\]
- For any \(A,B,C \in \vert C \vert \), there exists \[s_{ABC} \in ((A \Rightarrow B \Rightarrow C) \Rightarrow (A \Rightarrow B) \Rightarrow (A \Rightarrow C))^\#\] such that \[\forall f,g. \ s_{ABC} \cdot f \cdot g \downarrow , \quad \forall f,g,a. \ s_{ABC} \cdot f \cdot g \cdot a \simeq (f \cdot a) \cdot (g \cdot a)\]
Definition. Computability model [math-00CS]
- July 15, 2024
- Lîm Tsú-thuàn
Definition. Computability model [math-00CS]
- July 15, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
A computability model \(C\) over a set \(T\) of type names consists of
- an indexed family \(\vert C \vert = \{ C(\tau ) \mid \tau \in T \}\) of sets, called the datatypes of \(C\),
- for each \(\sigma ,\tau \in T\), a set \(C[\sigma ,\tau ]\) of partial functions \(f : C(\sigma ) \to C(\tau )\), called operations of \(C\)
such that
- for each \(\tau \in T\), the identity function \(id : C(\tau ) \to C(\tau )\) is in \(C[\tau ,\tau ]\)
- for any \(f \in C[\rho , \sigma ]\) and \(g \in C[\sigma , \tau ]\), the composition \(g \circ f \in C[\rho , \tau ]\).
Collary. [#406]
- July 15, 2024
- Lîm Tsú-thuàn
Collary. [#406]
- July 15, 2024
- Lîm Tsú-thuàn
A computability model is a category of sets and partial functions.
Notation. [#407]
- July 15, 2024
- Lîm Tsú-thuàn
Notation. [#407]
- July 15, 2024
- Lîm Tsú-thuàn
Denote \(C[A, B]\) for \(C[\sigma , \tau ]\) where \(A = C(\sigma )\) and \(B = C(\tau )\).
Definition. Total computability model [math-00CT]
- July 15, 2024
- Lîm Tsú-thuàn
Definition. Total computability model [math-00CT]
- July 15, 2024
- Lîm Tsú-thuàn
A computability model is total if every operations \(f \in C[A,B]\) is a total function \(A \to B\).
Theorem. Hiene-Borel [math-00CR]
- July 14, 2024
- Lîm Tsú-thuàn
Theorem. Hiene-Borel [math-00CR]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Möbius strip [math-00CQ]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Möbius strip [math-00CQ]
- July 14, 2024
- Lîm Tsú-thuàn
The Möbius strip (plane model) can be defined as a quotient topology of \([0, 1] \times (-1, 1)\) with usual \(\R \) metric, the equivalence relation is defined as
\[(0, s) \sim (1, -s)\]
Definition. Convergence (in topological space) [math-00CO]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Convergence (in topological space) [math-00CO]
- July 14, 2024
- Lîm Tsú-thuàn
Let \((a_n)_{n\in \N }\) be a sequence of a topological space \(X\), we say it converges to \(a \in X\) if for all neighborhoods \(N_a\) of \(a\), there is a \(N \in \N \) let all \(a_k \in N_a\) for all \(k \ge N\).
Example. Why Hausdorff? [#410]
- July 14, 2024
- Lîm Tsú-thuàn
Example. Why Hausdorff? [#410]
- July 14, 2024
- Lîm Tsú-thuàn
Let \((\R , \mathcal {T})\) be a topological space, \(\mathcal {T} = \{ \varnothing , \R \} \cup \{ (b,\infty ) \mid b \in \R \}\). The sequence
\[(a_n)_{n\in \N } = \bigg (\frac {1}{n}\bigg )_{n\in \N }\]converges to many points.
- Every \((b, \infty )\) with \(b < 0\) is a neighborhoods of \(0\), and all points of the sequence are in it, so \((a_n)\) converges to \(0\).
- However, every \((b, \infty )\) with \(b < -1\) is a neighborhoods of \(-1\), and all points of the sequence are in it, so \((a_n)\) also converges to \(-1\).
The argument can work on every \(b \in \R \) if \(b < 0\), so not every topological space can work with usual convergence definition that generalized from metric space, leads us to define Hausdorff.
Definition. Extensional [tt-001T]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Extensional [tt-001T]
- July 14, 2024
- Lîm Tsú-thuàn
A type theory is extensional if propositional equality implies definitional equality.
Definition. Open and close terms [cs-001F]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Open and close terms [cs-001F]
- July 14, 2024
- Lîm Tsú-thuàn
A term is closed if no variables occur free in it. For example,
- a constant is always closed, e.g. \(1, 2, 3, \text {true}, "hello"\)
- a variable is not closed (so is open) if we cannot find a binder in current context. Notice below example:
(let ([x 1]) (let ([y 2]) (+ x y)))
is closed, but(let ([y 2]) (+ x y))
is not! Ask this question from where is important.
We can reshape this description to: A term is closed if it has no free variables, and a term is open if it's not closed.
Definition. Prime ideals and maximal ideals [math-00CM]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Prime ideals and maximal ideals [math-00CM]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Prime ideal [#413]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Prime ideal [#413]
- July 14, 2024
- Lîm Tsú-thuàn
A prime ideal \(A\) of a commutative ring \(R\) is a proper ideal of \(R\) such that \(a,b \in R\) and \(a \cdot b \in A\) imply \(a \in A\) or \(b \in A\).
Definition. Maximal ideal [#414]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Maximal ideal [#414]
- July 14, 2024
- Lîm Tsú-thuàn
A maximal ideal of a commutative ring \(R\) is a proper ideal of \(R\) such that, whenever \(B\) is an ideal of \(R\) and \(A \subseteq B \subseteq R\), then \(B = A\) or \(B = R\).
Definition. Projective spaces [math-00CP]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Projective spaces [math-00CP]
- July 14, 2024
- Lîm Tsú-thuàn
A projective space \(P^n(\R )\) is the set of all 1-dimensional subspaces of \(\R ^{n+1}\), can be defined as a quotient topology of \(S^n\)
\[S^n = \{ \Vert x\Vert = 1 \mid x \in \R ^{n+1} \}\]by equivalence relation \(x \sim -x\), so
\[ x \sim y := x = y \text { or } x = -y \]so we define \(P^n(\R ) := S^n/_\sim \).
Theorem. Projective spaces are Hausdorff [#408]
- July 14, 2024
- Lîm Tsú-thuàn
Theorem. Projective spaces are Hausdorff [#408]
- July 14, 2024
- Lîm Tsú-thuàn
Each \(P^n(\R )\) is Hausdorff
Proof. [#409]
- July 14, 2024
- Lîm Tsú-thuàn
Proof. [#409]
- July 14, 2024
- Lîm Tsú-thuàn
Theorem. Residue integral domains/fields [math-00CN]
- July 14, 2024
- Lîm Tsú-thuàn
Theorem. Residue integral domains/fields [math-00CN]
- July 14, 2024
- Lîm Tsú-thuàn
Let \(R\) be a commutative ring with unity and \(A\) be an ideal of \(R\).
Theorem. [#411]
- July 14, 2024
- Lîm Tsú-thuàn
Theorem. [#411]
- July 14, 2024
- Lîm Tsú-thuàn
\(R/A\) is an integral domain if and only if \(A\) is prime.
Theorem. [#412]
- July 14, 2024
- Lîm Tsú-thuàn
Theorem. [#412]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Subring [math-00CL]
- July 14, 2024
- Lîm Tsú-thuàn
Definition. Subring [math-00CL]
- July 14, 2024
- Lîm Tsú-thuàn
A subset \(S\) of a ring \(R\) is a subring of \(R\) if \(S\) is itself a ring with the operations of \(R\).
Theorem. How to check a subset if a subring [#415]
- July 14, 2024
- Lîm Tsú-thuàn
Theorem. How to check a subset if a subring [#415]
- July 14, 2024
- Lîm Tsú-thuàn
A nonempty set \(S\) of a ring \(R\) is a subring if \(S\) is closed under subtraction and multiplication. Which means \(a - b \in S\) and \(a \cdot b \in S\) should hold for all \(a, b \in S\).
Example. [#416]
- July 14, 2024
- Lîm Tsú-thuàn
Example. [#416]
- July 14, 2024
- Lîm Tsú-thuàn
\(\{ 0 \}\) and \(\R \) are subrings of \(\R \).
Example. [#417]
- July 14, 2024
- Lîm Tsú-thuàn
Example. [#417]
- July 14, 2024
- Lîm Tsú-thuàn
For each \(n \in \N \), the set
\[n\Z = \{ 0, \pm n, \pm 2n, \pm 3n, \dots \}\]is a subring of \(\Z \).
Definition. Topological system [math-00CK]
- July 13, 2024
- Lîm Tsú-thuàn
Definition. Topological system [math-00CK]
- July 13, 2024
- Lîm Tsú-thuàn
Topology via Logic
Let \(A\) be a frame, its elements are opens. Let \(X\) be a set, its elements are points. Let \(\vDash \) be a subset of \(X \times A\), if \((x,a) \in \ \vDash \) then we write \(x \vDash a\) and say \(x\) satisfies \(a\). \((X,A,\vDash )\) is a topological system if
- if \(S\) is a finite subset of \(A\) \[x \vDash \bigwedge S \iff x \vDash a \text { for all } a \in S\]
- if \(S\) is any subset of \(A\) \[x \vDash \bigvee S \iff x \vDash a \text { for some } a \in S\]
Notation. [#418]
- July 13, 2024
- Lîm Tsú-thuàn
Notation. [#418]
- July 13, 2024
- Lîm Tsú-thuàn
If \(D = (X, A)\) is a topological system, denote \(\Omega D = A\) and \(\text {pt} D = X\).
\[D = (X,A) = (\text {pt} D, \Omega D)\]
Definition. Turing complete [cs-001D]
- July 11, 2024
- Lîm Tsú-thuàn
Definition. Turing complete [cs-001D]
- July 11, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
A language \(L\) is Turing complete if any partial computable function \(\N \rightharpoonup \N \) can be implemented in \(L\).
Definition. Models of Turing machine [math-00CI]
- July 11, 2024
- Lîm Tsú-thuàn
Definition. Models of Turing machine [math-00CI]
- July 11, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
Example. \(T_1\) model [#420]
- July 11, 2024
- Lîm Tsú-thuàn
Example. \(T_1\) model [#420]
- July 11, 2024
- Lîm Tsú-thuàn
Let \(\Gamma \) be a finite set of alphabets, \(M\) be a single datatype of memory states. A memory state is a function \(m : \Z \to \Gamma \). Any Turing machine \(T\) can be regarded as computing a certain partial function \(f_T : M \rightharpoonup M\) in the way: \(f_T(m) = m'\) if the execution of \(T\) with initial state \(m\), eventually halts yielding the final memory state \(m'\).
Example. \(T_2\) model [#421]
- July 11, 2024
- Lîm Tsú-thuàn
Example. \(T_2\) model [#421]
- July 11, 2024
- Lîm Tsú-thuàn
The model \(T_2\) consisting of the single datatype \(\N \) together with all Turing-computable partial functions \(\N \rightharpoonup \N \). This model needs some convention for representing natural numbers via memory states.
Also known as Kleene's first model.
Example. \(T_3\) model [#422]
- July 11, 2024
- Lîm Tsú-thuàn
Example. \(T_3\) model [#422]
- July 11, 2024
- Lîm Tsú-thuàn
The model \(T_3\) conceptually have a read-only input tape, a write-only output tape, and a working tape that permits both reading and writing. The input and output tapes are functions \(d : \N \to \Gamma \), \(D\) is the set of all such total functions. Thus, the model consisting of the single datatype \(D\) and all machine-computable partial functions \(f : D \rightharpoonup D\).
Definition. Simulation of computability models [math-00CJ]
- July 11, 2024
- Lîm Tsú-thuàn
Definition. Simulation of computability models [math-00CJ]
- July 11, 2024
- Lîm Tsú-thuàn
Higher-Order Computability
Let \(C\) and \(D\) be computability models with types indexed by \(T, U\) respectively. A simulation \(\gamma \) of \(C\) in \(D\) (denotes \(C \triangleright D\)) consists of
- a mapping associating each type \(\tau \in T\) a representing type \(\gamma \tau \in U\);
- for each \(\tau \in T\), a relation \(\Vdash ^\gamma _\tau \) between elements of \(D(\gamma \tau )\) and those of \(C(\tau )\).
subject to the following conditions
- For each \(\tau \in T\) and each \(a \in C(\tau )\), there is some \(a' \in D(\gamma \tau )\) such that \(a' \Vdash ^\gamma _\tau a\).
- Every operation \(f \in C[\sigma , \tau ]\) is tracked by some \(f' \in D[\gamma \sigma , \gamma \tau ]\), i.e. if \(f(a)\) is defined and \(a' \Vdash ^\gamma _\tau a\), then \(f'(a')\) is defined and \(f'(a') \Vdash ^\gamma _\tau f(a)\).
Example. \(T_1\) and \(T_2\) (models of Turing machine) [#419]
- July 11, 2024
- Lîm Tsú-thuàn
Example. \(T_1\) and \(T_2\) (models of Turing machine) [#419]
- July 11, 2024
- Lîm Tsú-thuàn
By definition of \(T_2\), a simulation \(T_2 \triangleright T_1\) is given. If \(n \in \N \) and \(m\) is a memory state, we take
\[m \Vdash n\]iff \(m\) represents \(n\) in the sense we have defined. Every operation in \(T_2\) is tracked by one in \(T_1\).
We cannot have a simulation \(T_1 \triangleright T_2\), because there are uncountably many memory states. But there is a simulation for variant of \(T_1\), by restricting \(T_1\)'s memory states to those with a designated blank symbol in all but finitely many cells. Such memory states can be coded as natural numbers, and the action of any Turing machine may then be emulated by a partial computable function \(\N \rightharpoonup \N \). We thus obtain a simulation \(T_1^\text {fin} \triangleright T_2\).
Definition. Lie group [math-00CG]
- July 6, 2024
- Lîm Tsú-thuàn
Definition. Lie group [math-00CG]
- July 6, 2024
- Lîm Tsú-thuàn
A lie group is a \(C^\infty \)-manifold \(G\) that is also a group such that the multiplication
\[\mu : G \times G \to G, \mu (a,b) = ab\]and the inverse
\[\eta : G \to G, \eta (a) = a^{-1}\]are \(C^\infty \) functions.
Proposition. \(L_a\) is a diffeomorphism [#425]
- July 6, 2024
- Lîm Tsú-thuàn
Proposition. \(L_a\) is a diffeomorphism [#425]
- July 6, 2024
- Lîm Tsú-thuàn
The left multiply function \(L_a(b) = ab\) is a diffeomorphism.
Proof. [#426]
- July 6, 2024
- Lîm Tsú-thuàn
Proof. [#426]
- July 6, 2024
- Lîm Tsú-thuàn
We can simply found since \(\mu \) is \(C^\infty \), each partial differential of it still \(C^\infty \), and \(L_{a^{-1}}(b)\) is the inverse function share the same form and hence also \(C^\infty \), concludes that \(L_a\) is a diffeomorphism.
Example. General linear groups [math-00CH]
- July 6, 2024
- Lîm Tsú-thuàn
Example. General linear groups [math-00CH]
- July 6, 2024
- Lîm Tsú-thuàn
The general linear group is defined as
\[ GL(n, \R ) := \{ A \in \R ^{n\times n} \mid \det A \ne 0 \} = \det {}^{-1}(\R \setminus \{ 0 \}) \]The determinant function \(\det : \R ^{n\times n} \to \R \) is continuous, \(GL(n, \R )\) is an open subset of \(\R ^{n\times n}\), with the standard topology on \(\R ^{n\times n}\).
General linear group is Lie group [#423]
- July 6, 2024
- Lîm Tsú-thuàn
General linear group is Lie group [#423]
- July 6, 2024
- Lîm Tsú-thuàn
Proof. [#424]
- July 6, 2024
- Lîm Tsú-thuàn
Proof. [#424]
- July 6, 2024
- Lîm Tsú-thuàn
Consider the \((i,j)\)-entry of the product of its elements \(A, B\)
\[ (AB)_{ij} = \sum _{k=1}^n a_{ik}b_{kj} \]we can see it's a polynomial in the coordinates of \(A\) and \(B\), so \(\mu : GL(n,\R ) \times GL(n,\R ) \to GL(n,\R )\) is a \(C^\infty \) map.
By Cramer's rule, we have
\[ (A^{-1})_{ij} = \frac {1}{\det A} \cdot (-1)^{i+j} ((j,i)\text {-minor of } A) \]which is a \(C^\infty \)-function, and hence \(\eta : GL(n,\R ) \to GL(n,\R )\) is also a \(C^\infty \)-map. Tell \(GL(n, \R )\) is a Lie group.
Example. View \(\R ^n\) as a manifold (and when a Riemannian metric is flat) [math-00CF]
- July 6, 2024
- Lîm Tsú-thuàn
Example. View \(\R ^n\) as a manifold (and when a Riemannian metric is flat) [math-00CF]
- July 6, 2024
- Lîm Tsú-thuàn
\(\R ^n\) is the usual Euclidean space, the distance function
\[d(p - q) = |p - q|\]let \((x^1, \dots , x^n) = x^ie_i\) be the coordinate system on \(\R ^n\), which means
\[e_i = (0, \dots , 1 (\text {position } i), \dots , 0)\]then we can get
\[d(p,q) = \sqrt {\sum _{i=1}^n (x^i(p) - x^i(q))}\]Now for any point \(p \in \R ^n\), its \(T_p\R ^n\) is all vector from \(p\), which means
\[T_p\R ^n \ni X = \overrightarrow {pq} = (x^i(q) - x^i(p))e_i\]so if we consider \(X, Y \in T_p\R ^n\) (\(Y = \overrightarrow {pr}\)), we have
\[g(X,Y) = \sum _{i=1}^n (x^i(q) - x^i(p))(x^i(r) - x^i(p))\]then we get the standard Riemannian metric (Kronecker delta)
\[ g_{ij} = g\big (\frac {\partial }{\partial x^i}, \frac {\partial }{\partial x^j}\big ) = \delta _{ij} = \begin {cases} 1 \text { if } i = j \\ 0 \text { if } i \ne j \end {cases} \]We call any Riemannian metric \(g\) satisfies this condition is flat.
Definition. Frame [math-00CD]
- July 5, 2024
- Lîm Tsú-thuàn
Definition. Frame [math-00CD]
- July 5, 2024
- Lîm Tsú-thuàn
A frame is a complete lattice \(L\) satisfying the distributivity law
\[ (\bigvee A) \wedge b = \bigvee \{ a \wedge b \mid a \in A \} \]for any \(A \subseteq L\) and \(b \in L\).
Remark. Topology via Logic version [#430]
- July 5, 2024
- Lîm Tsú-thuàn
Remark. Topology via Logic version [#430]
- July 5, 2024
- Lîm Tsú-thuàn
A poset \(A\) is a frame iff
- every subset has a join
- every finite subset has a meet
- binary meets distribue over joins \[x \wedge \bigvee Y = \bigvee \{ x \wedge y \mid y \in Y \}\]
Write \(\text {true}\) for empty meet (top), \(\text {false}\) for empty join (bottom).
Example. Observations frame of stream [cs-001R]
- October 20, 2024
- Lîm Tsú-thuàn
Example. Observations frame of stream [cs-001R]
- October 20, 2024
- Lîm Tsú-thuàn
Let \(s_n\) represents the \(n\)-th bit of a stream, and \(s_n = 0\) and \(s_n = 1\) are subbasic observations. No doubt we have
\[s_n = 0 \wedge s_n = 1 \quad = \quad \text {false}\]hold for all \(n\). And then, instead of \(s_n = 0 \vee s_n = 1 \quad =\quad \text {true}\), we interpret \(s_n = 0 \vee s_n = 1\) as the \(n\)-th bit has now been read. Thus, we have
\[ s_{n+1} = 0 \vee s_{n+1} = 1 \implies s_n = 0 \vee s_n = 1 \]Which means, to read \(n+1\)-th bit, we must already read \(n\)-th bit.
Definition. Spatial [#431]
- July 5, 2024
- Lîm Tsú-thuàn
Definition. Spatial [#431]
- July 5, 2024
- Lîm Tsú-thuàn
A frame is said to be spatial if it's isomorphic to a \(\Omega (X)\) which is made by the frame functor.
Definition. Frame functor \(\Omega \) and category of frames [math-00E4]
- July 5, 2024
- Lîm Tsú-thuàn
Definition. Frame functor \(\Omega \) and category of frames [math-00E4]
- July 5, 2024
- Lîm Tsú-thuàn
For any topological space \(X\), we have a frame \(\Omega (X)\) (refers topology and lattice) and frame homomorphisms
\[\Omega (f) : \Omega (Y) \to \Omega (X)\]for continuous maps \(f : X \to Y\) resulting a contravaiant functor
\[\Omega : Top \to Frm\]
Definition. Locale and category of locales [math-00CE]
- July 5, 2024
- Lîm Tsú-thuàn
Definition. Locale and category of locales [math-00CE]
- July 5, 2024
- Lîm Tsú-thuàn
Remark. Topology via Logic version [#427]
- July 5, 2024
- Lîm Tsú-thuàn
Remark. Topology via Logic version [#427]
- July 5, 2024
- Lîm Tsú-thuàn
Let \(A\) be a frame. The locale corresponding to \(A\) is the topological system \(D\) defined by
- \(\Omega D = A\)
- \(\text {pt} D = \{ \text {frame homomorphisms } x : A \to 2 \}\)
- \(x \vDash a\) iff \(x(a) = \text {true}\)
Notation. [#428]
- July 5, 2024
- Lîm Tsú-thuàn
Notation. [#428]
- July 5, 2024
- Lîm Tsú-thuàn
\(2\) stands for a frame that has only \(\{ \text {true},\text {false} \}\) in the carry set, and \(\text {false} \le \text {true}\)
Definition. Category of locales [#429]
- July 5, 2024
- Lîm Tsú-thuàn
Definition. Category of locales [#429]
- July 5, 2024
- Lîm Tsú-thuàn
The category of locales \(Loc\) is the opposite category of category of frames \(Frm\).
Definition. Premanifold [math-00CC]
- July 5, 2024
- Lîm Tsú-thuàn
Definition. Premanifold [math-00CC]
- July 5, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology
A real \(C^\alpha \)-premanifold is a locally \(\R \)-ringed space \((M, \mathcal {O}_M)\) with an open covering
\[ M = \bigcup _{i \in I}U_i \]such that for all \(i \in I\) there exist \(m \in \N \), an open \(Y \subseteq \R ^m\), and an isomorphism of locally \(\R \)-ringed spaces \((U_i, {\mathcal {O}_M}_{\rvert {U_i}}) \cong (Y, \mathcal {C}^\alpha _Y)\) (called chart).
Notation. [#432]
- July 5, 2024
- Lîm Tsú-thuàn
Notation. [#432]
- July 5, 2024
- Lîm Tsú-thuàn
符號 \(\alpha \in \widehat {\N } = \N \cup \{ \infty , \omega \}\),\(C^\alpha \) 是可微分幾次的意思。\((Y, \mathcal {C}^\alpha _Y)\) 是帶有 sheaf of \(\R \)-valued \(C^\alpha \)-functions 的子空間 \(Y\)。
Definition. Differentiable mapping (from manifold to manifold) [math-00CB]
- July 4, 2024
- Lîm Tsú-thuàn
Definition. Differentiable mapping (from manifold to manifold) [math-00CB]
- July 4, 2024
- Lîm Tsú-thuàn
Let \(M, N\) be differentiable manifolds, a mapping \(\varphi : M \to N\) is differentiable at \(p\) if
\[ y^{-1} \circ \varphi \circ x : \R ^m \to \R ^n \]is differentiable at \(x^{-1}(p)\).
I found the diagram below is helpful.
Definition. Differential of mapping [math-00CA]
- July 4, 2024
- Lîm Tsú-thuàn
Definition. Differential of mapping [math-00CA]
- July 4, 2024
- Lîm Tsú-thuàn
Remark. [#433]
- July 4, 2024
- Lîm Tsú-thuàn
Remark. [#433]
- July 4, 2024
- Lîm Tsú-thuàn
The differential of map \(\varphi \) at \(p\) is a map of tangent vectors \(T_p M \to T_{\varphi (p)} N\)
Let \(M, N\) be differentiable manifolds (\(m\) and \(n\) dimensional, resp) and let \(\varphi : M \to N\) be a differentiable mapping (Definition [math-00CB]). For every \(p \in M\) and for each \(v \in T_p M\), choose a differentiable curve \(\alpha : (-\epsilon ,\epsilon ) \to M\) with \(\alpha (0) = p\), \(a'(0) = v\). Take \(\beta = \varphi \circ \alpha \). The linear mapping
\[\begin {aligned} &d \varphi _p &:& &T_p M \to T_{\varphi (p)} N \\ &d\varphi _p(v) &=& &\beta '(0) \end {aligned}\]is called the differential of \(\varphi \) at \(p\).
Proposition. The choice of curve is irrelevant [#434]
- July 4, 2024
- Lîm Tsú-thuàn
Proposition. The choice of curve is irrelevant [#434]
- July 4, 2024
- Lîm Tsú-thuàn
The differential does not depend on the choice of \(\alpha \).
Proof. [#435]
- July 4, 2024
- Lîm Tsú-thuàn
Proof. [#435]
- July 4, 2024
- Lîm Tsú-thuàn
We first expand the mapping \(\varphi \) to parameterized form
\[ y^{-1} \circ \varphi \circ \textcolor {red}{x}(q) = (y_1(x_1, \dots , x_m), \dots , y_n(x_1, \dots , x_m)) \]then expand \(\alpha \) to parameterized form
\[ \textcolor {red}{x^{-1}} \circ \alpha (t) = (x_1(t), \dots , x_m(t)) \]Therefore, use first after the second formula
- cancel \(\textcolor {red}{x}\) in the middle, get \(y^{-1} \circ \textcolor {blue}{\varphi \circ \alpha }\)
- apply \(\beta = \varphi \circ \alpha \), get \(y^{-1} \circ \beta \)
so
\[ y^{-1} \circ \beta (t) = (y_1(x_1(t), \dots , x_m(t)), \dots , y_n(x_1(t), \dots , x_m(t))) \]and hence we can express \(\beta '(0)\) as
\[ \beta '(0) = d\varphi _p(v) = \bigg (\frac {\partial y_i}{\partial x_j}\bigg ) (x_j'(0)) \\ = \begin {bmatrix} \frac {\partial y_1}{\partial x_1} & \cdots & \frac {\partial y_1}{\partial x_m} \\ \vdots & \ddots & \vdots \\ \frac {\partial y_n}{\partial x_1} & \cdots & \frac {\partial y_n}{\partial x_m} \\ \end {bmatrix} \begin {bmatrix} x_1'(0) \\ \vdots \\ x_m'(0) \\ \end {bmatrix} \]
Agda unimath symbols [agda-0006]
- July 3, 2024
- Lîm Tsú-thuàn
Agda unimath symbols [agda-0006]
- July 3, 2024
- Lîm Tsú-thuàn
equivalence \simeq |
\(\simeq \) |
---|---|
equal \= |
\(=\) |
Definition. Characteristic of ring [math-00C8]
- July 3, 2024
- Lîm Tsú-thuàn
Definition. Characteristic of ring [math-00C8]
- July 3, 2024
- Lîm Tsú-thuàn
The characteristic of a ring \(R\) is the least positive integer \(n\) such that
\[\forall x \in R, nx = 0\]\(nx\) is the shorthand of \(\underbrace {x + \cdots + x}_{n-\text {times}}\)
If no such integer exists, then the characteristic is \(0\).
Theorem. Characteristic of an integral domain [math-002O]
- July 3, 2024
- Lîm Tsú-thuàn
Theorem. Characteristic of an integral domain [math-002O]
- July 3, 2024
- Lîm Tsú-thuàn
The characteristic of an integral domain is \(0\) or prime.
Definition. Dinatural transformation (diagonal naturality) [math-00C7]
- July 3, 2024
- Lîm Tsú-thuàn
Definition. Dinatural transformation (diagonal naturality) [math-00C7]
- July 3, 2024
- Lîm Tsú-thuàn
Let \(C,D\) be two categories. Given two functors \(P, Q : C^{op} \times C \to D\) a dinatural transformation \(\alpha : P \multimap Q\) consists of a family of morphisms
\[ \alpha _c : P(c,c) \to Q(c,c) \]indexed by the objects \(c \in C\) and such that for any \(f : c \to c'\) the following diagram commutes
Definition. Rotation index of curve on plane (or degree of curve) [math-00C5]
- July 3, 2024
- Lîm Tsú-thuàn
Definition. Rotation index of curve on plane (or degree of curve) [math-00C5]
- July 3, 2024
- Lîm Tsú-thuàn
Let \(\gamma : [a,b] \to \R ^2\) be a regular closed curve on plane \(\R ^2\), then there exists a smooth function \(\theta : [a,b] \to \R \) such that for all \(t \in [a,b]\), the unit tangent vector satisfies
\[\vec {\mathfrak {t}}(t) = (\cos \theta (t), \sin \theta (t))\]the rotation index of \(\gamma \) is defined as
\[ \frac {1}{2\pi } (\theta (b) - \theta (a)) \]
Remark. [#439]
- July 3, 2024
- Lîm Tsú-thuàn
Remark. [#439]
- July 3, 2024
- Lîm Tsú-thuàn
The rough meaning of rotation index is the number of times the domain \([a,b]\) is wrapped counterclockwise around the circle.
Proposition. [#440]
- July 3, 2024
- Lîm Tsú-thuàn
Proposition. [#440]
- July 3, 2024
- Lîm Tsú-thuàn
If \(f : [a,b] \to S^1\) is a continuous function with \(f(a) = f(b)\), then there exists a continuous angle function \(\theta : [a,b] \to \R \) such that for all \(t \in [a,b]\)
\[ f(t) = (\cos \theta (t), \sin \theta (t)) \]This function is unique up to adding an integer multiple of \(2\pi \).
Lemma. [#441]
- July 3, 2024
- Lîm Tsú-thuàn
Lemma. [#441]
- July 3, 2024
- Lîm Tsú-thuàn
Let \(f_1, f_2 : [a,b] \to S^1\) be continuous functions with \(f_1(a) = f_2(b)\) and \(f_2(a) = f_2(b)\). If \(f_1\) and \(f_2\) have different rotation indicies (Definition [math-00C5]), then exists \(t_0 \in [a,b]\) satisfies
\[f_1(t_0) = -f_2(t_0)\]
Proof. [#442]
- July 3, 2024
- Lîm Tsú-thuàn
Proof. [#442]
- July 3, 2024
- Lîm Tsú-thuàn
Let \(\theta _1, \theta _2 : [a,b] \to \R \) be angle functions respectively. Consider
\[\delta (t) = \theta _2(t) - \theta _1(t)\]This is not zero since the rotation indicies are different, so we have
\[ \vert \delta (b) - \delta (a) \vert = \vert (\theta _2(b) - \theta _2(a)) - (\theta _1(b) - \theta _1(a)) \vert \ge 2\pi \]since \(\delta \) has a net change of at least \(2\pi \), there must be an odd integer \(n\) multiple \(n\pi \) between \(\delta (a)\) and \(\delta (b)\). The intermediate value theorem implies that \(\delta \) achieves this value for some \(t_0 \in [a,b]\), so \(f_1(t_0) = -f_2(t_0)\).
The idea behinds this is two angles will be exactly be oppsite place on \(S^1\) at some point \(t_0\).
Definition. Ringed spaces and locally ringed spaces [math-00C3]
- July 1, 2024
- Lîm Tsú-thuàn
Definition. Ringed spaces and locally ringed spaces [math-00C3]
- July 1, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology, §4.1
Definition. \(R\)-ringed space [#443]
- July 1, 2024
- Lîm Tsú-thuàn
Definition. \(R\)-ringed space [#443]
- July 1, 2024
- Lîm Tsú-thuàn
Definition. Stalk [math-00B5]
- May 9, 2024
- Lîm Tsú-thuàn
Definition. Stalk [math-00B5]
- May 9, 2024
- Lîm Tsú-thuàn
Let \(X\) be a topological space, \(\mathcal {F} : \mathcal {O}(X)^{op} \to Sets\) be a presheaf on \(X\). The colimit
\[\mathcal {F}_x := \underset {\mathcal {U}(x)} {\text {colim}} \mathcal {F}\]is called the stalk of \(\mathcal {F}\) in \(x\). Where \(\mathcal {U}(x)\) is the set of open neighborhoods of \(x\) for each point \(x \in X\).
The set of open neighborhoods as full subcategory [#475]
- May 9, 2024
- Lîm Tsú-thuàn
The set of open neighborhoods as full subcategory [#475]
- May 9, 2024
- Lîm Tsú-thuàn
\(\mathcal {U}(x)\) ordered by inclusion, can be viewed as a full subcategory of \(\mathcal {O}(X)\).
Definition. Locally \(R\)-ringed space [#444]
- July 1, 2024
- Lîm Tsú-thuàn
Definition. Locally \(R\)-ringed space [#444]
- July 1, 2024
- Lîm Tsú-thuàn
A locally \(R\)-ringed space is an \(R\)-ringed space \(X,\mathcal {O}_{X}\) such that for each point \(x \in X\), the stalk (Definition [math-00B5]) \(\mathcal {O}_{X,x}\) is a local ring. We then denote
- by \(\mathfrak {m}_x\) the maximal ideal of \(\mathcal {O}_{X,x}\)
- and by \(\kappa (x) := \mathcal {O}_{X,x} / \mathfrak {m}_x\) its residue field.
Proposition. A connected graph is a tree iff for each subgraph exists a point with degree 0 or 1 [math-00C2]
- June 30, 2024
- Lîm Tsú-thuàn
Proposition. A connected graph is a tree iff for each subgraph exists a point with degree 0 or 1 [math-00C2]
- June 30, 2024
- Lîm Tsú-thuàn
A connected graph \(T\) is a tree if and only if for each subgraph, there exists a point with degree 0 or 1.
Proof. [#445]
- June 30, 2024
- Lîm Tsú-thuàn
Proof. [#445]
- June 30, 2024
- Lîm Tsú-thuàn
(\(\Longrightarrow \)) First, we only need to consider connected subgraph, since \(T\) is a tree. Then for any subgraph we can inherit tree order from the tree, then form a subtree and hence has leaf (with degree 1) or has a single point (with degree 0).
(\(\Longleftarrow \)) Suppose \(T\) is not a tree, which means it has a cycle, then we pick that cycle as subgraph, and that's contradict to the condition, and hence \(T\) is a tree.
Definition. Martin-Löf category [math-00C1]
- June 28, 2024
- Lîm Tsú-thuàn
Definition. Martin-Löf category [math-00C1]
- June 28, 2024
- Lîm Tsú-thuàn
A Martin-Löf category is a locally cartesian closed category with disjoint coproducts and initial algebras for container functors, so it closed under formation of W-types.
Definition. Container [math-00C0]
- June 28, 2024
- Lîm Tsú-thuàn
Definition. Container [math-00C0]
- June 28, 2024
- Lîm Tsú-thuàn
Containers: Constructing strictly positive types
A unary container is given by a type of shapes \(S\) and a family of position types indexed by \(S\), thus
\[ s : S \vdash P(s) \]as a container we dnote this as \((s : S \triangleright P s)\) or \((S \triangleright P)\). An extension of a container is a functor
\[ \llbracket S \triangleright P \rrbracket X = \sum _{s : S} P(s) \to X \]
Example. [#446]
- June 28, 2024
- Lîm Tsú-thuàn
Example. [#446]
- June 28, 2024
- Lîm Tsú-thuàn
注意到 \(X\) 是一個類型,\(P(s)\) 也是一個類型。用 \(\text {List} = \mu X. 1 + A \times X\) 舉例的話就是
\[ \llbracket \N \triangleright \text {Fin} \rrbracket X = \sum _{n : \N } \text {Fin}(n) \to X \]因此對於能充分表達類型的範疇 \(\mathbb {C}\),將 extension 作為 container functor 的定義。
Definition. Container functor [math-00AS]
- April 29, 2024
- Lîm Tsú-thuàn
Definition. Container functor [math-00AS]
- April 29, 2024
- Lîm Tsú-thuàn
A functor \(F : \mathbb {C} \to \mathbb {C}\) is a container functor iff it is naturally isomorphic to a functor of the form
\[X \mapsto \sum _{a : A} B(a) \to X\]or more concisely \(\sum _A(B \to X)\), for some family \(A \vdash B\) in \(\mathbb {C}\), i.e., \(A \in \mathbb {C}\) and \(B \in \mathbb {C} / A\).
NOTE: due to the relation \(A \vdash B\), we need \(\mathbb {C}\) be at least LCCC, and induce the definition of Martin-Löf category.
Definition. Strictly positive types [math-00BZ]
- June 28, 2024
- Lîm Tsú-thuàn
Definition. Strictly positive types [math-00BZ]
- June 28, 2024
- Lîm Tsú-thuàn
Containers: Constructing strictly positive types
Strictly positive types are those types which can be formed using \(0, 1, +, \times , \to , \mu , \nu \) with the restriction that types on the left hand side of the arrow have to be closed with respect to type variables. So, a strictly positive type in \(n\) variables is a type expression (with type variables \(X_1, \dots , X_n\)) by the following rules inductively
- if \(K\) is a constant type then \(K\) is strictly positive.
- each type variable \(X_i\) is strictly positive.
- if \(F,G\) are strictly positive, then so are \(F + G\) and \(F \times G\).
- if \(K\) is a constant type and \(F\) is strictly positive, then \(K \to F\) is strictly positive.
- if \(F\) is a strictly positive type with \(n+1\) variables, then \(\mu X. F\) and \(\nu X. F\) are strictly positive types in \(n\) variables.
and non-inductive strictly positive type means the expression has no any \(\mu \) and \(\nu \) involved.
The central insight of the paper is all strictly positive types can be represented as containers.
Example. Lists over \(A\) [#447]
- June 28, 2024
- Lîm Tsú-thuàn
Example. Lists over \(A\) [#447]
- June 28, 2024
- Lîm Tsú-thuàn
Lists over \(A\) can be expressed as a solution to \(\text {List}\ A \cong 1 + A \times \text {List}\ A\), there are two canonical choices of fixpoint
- Finite lists corresponds to the initial algebra of the signature functor. Denotes \[\text {List}\ A = \mu X.1+A\times X\]
- Potentially infinite lists corresponds to the terminal coalgebra of the same functor. Denotes \[\text {List}^{\infty }\ A = \nu X. 1 + A \times X\]
檢查機制 org-002K
Definition. Quotient topology [math-00BY]
- June 23, 2024
- Lîm Tsú-thuàn
Definition. Quotient topology [math-00BY]
- June 23, 2024
- Lîm Tsú-thuàn
Let \(X\) be a topological space, \(X/_\sim \) is a set defined as
\[X/_\sim = \{ [x]_\sim \mid x \in X \}\]
Notation. [#448]
- June 23, 2024
- Lîm Tsú-thuàn
Notation. [#448]
- June 23, 2024
- Lîm Tsú-thuàn
\([x]_\sim \) denotes the equivalence class of \(x \in X\).
and a surjective map
\[\begin {aligned} &\pi : X \to X/_\sim \\ &\pi = x \mapsto [x]_\sim \end {aligned}\]Then the quotient topology on \(X/_\sim \) is induced by: \(U\) is open in \(X/_\sim \) if \(\pi ^{-1}(U)\) is open in \(X\).
Proposition. Universal property in the category of topological spaces [#449]
- June 23, 2024
- Lîm Tsú-thuàn
Proposition. Universal property in the category of topological spaces [#449]
- June 23, 2024
- Lîm Tsú-thuàn
For every topological space \(Z\) and every map \(f : S \to Z\), \(f\) is continuous iff \(f \circ \pi \) is continuous.
Example. Parallel or [cs-001C]
- June 20, 2024
- Lîm Tsú-thuàn
Example. Parallel or [cs-001C]
- June 20, 2024
- Lîm Tsú-thuàn
This function is a minimal example that concurrency might not able to do it:
|| |
true |
false |
\(\bot \) |
---|---|---|---|
true |
true |
true |
true |
false |
true |
false |
\(\bot \) |
\(\bot \) | true |
\(\bot \) | \(\bot \) |
If a concurrency process is actually do by time sharing with the only unit, it might fall into a loop at one side and never check another computation, and hence cannot have the same semantic.
Example. The ring of integers [math-00BX]
- June 18, 2024
- Lîm Tsú-thuàn
Example. The ring of integers [math-00BX]
- June 18, 2024
- Lîm Tsú-thuàn
The ring of integers is the tuple \((\mathbb {Z}, 0, 1, +, \times )\).
Definition. Orthogonal (matrix) [math-00BW]
- June 17, 2024
- Lîm Tsú-thuàn
Definition. Orthogonal (matrix) [math-00BW]
- June 17, 2024
- Lîm Tsú-thuàn
A \(n \times n\) matrix \(A\) is called orthogonal if \(| A \cdot p | = | p |\) for all \(p \in \R ^n\).
distance notation: \(| p | = | p - 0 | = d(p, 0)\)
Definition. Rigid motion of \(\R ^n\) [math-00BV]
- June 17, 2024
- Lîm Tsú-thuàn
Definition. Rigid motion of \(\R ^n\) [math-00BV]
- June 17, 2024
- Lîm Tsú-thuàn
A rigid motion of \(\R ^n\) is a function \(f : \R ^n \to \R ^n\) that preserves distances:
\[d(f(p), f(q)) = d(p, q)\]for all \(p, q \in \R ^n\)
Definition. Inner product space [math-00BS]
- June 12, 2024
- Lîm Tsú-thuàn
Definition. Inner product space [math-00BS]
- June 12, 2024
- Lîm Tsú-thuàn
Let \(X\) be a vector space over a field \(\mathbb {F}\), if there is a function \(\langle -,- \rangle : X \times X \to \mathbb {F}\), such that
- positive-definiteness: \(\langle x,x \rangle \ge 0\), and \(\langle x,x \rangle = 0\) if and only if \(x = 0\)
- conjugate symmetry: \(\langle x,y \rangle = \overline {\langle y,x \rangle }\)
- linearity for first argument
Conjugate symmetry will be just symmetry if \(\mathbb {F} = \R \).
Example. [#455]
- June 12, 2024
- Lîm Tsú-thuàn
Example. [#455]
- June 12, 2024
- Lîm Tsú-thuàn
The usual \(\R ^n\) space has inner product
\[ \langle u,v \rangle = a_1b_1 + a_2b_2 + \cdots + a_nb_n = \sum _{i=0}^n a_ib_i \]where \(u = \begin {bmatrix}a_1\\ \vdots \\ a_i \\ \vdots \\ a_n \end {bmatrix}\) and \(v = \begin {bmatrix}b_1\\ \vdots \\ b_i \\ \vdots \\ b_n \end {bmatrix}\).
Method. How to prove a set is not a variety [math-00BQ]
- June 10, 2024
- Lîm Tsú-thuàn
Method. How to prove a set is not a variety [math-00BQ]
- June 10, 2024
- Lîm Tsú-thuàn
Example. \(X\) is not a variety [#458]
- June 10, 2024
- Lîm Tsú-thuàn
Example. \(X\) is not a variety [#458]
- June 10, 2024
- Lîm Tsú-thuàn
Proof. [#459]
- June 10, 2024
- Lîm Tsú-thuàn
Proof. [#459]
- June 10, 2024
- Lîm Tsú-thuàn
Let \(X = V(f_i)_{i\in I}\), each \(f_i(x, x) = 0\). Let \(g(x) = f_i(x,x)\) for some \(i\). Since Proposition [math-00BP] we have \(g(1) = f_i(1,1) = 0\), implies \((1,1) \in X\), leads to contradiction. Thus, \(X\) is not an affine variety.
Example. \(R\) is not a variety [#460]
- June 10, 2024
- Lîm Tsú-thuàn
Example. \(R\) is not a variety [#460]
- June 10, 2024
- Lîm Tsú-thuàn
Proof. [#461]
- June 10, 2024
- Lîm Tsú-thuàn
Proof. [#461]
- June 10, 2024
- Lîm Tsú-thuàn
Let \(R = V(f_i)_{i\in I}\), each \(f_i(x, y) = 0\). We can write \(f_i\) in form
\[ f_i = \sum _{j = 0}^2 g_j(y) x^j \]since all \(x\in \R \) are included, and hence \(g_j\) are forced to be zero functions, and hence are zero polynomials. Which force \(R\) to include all \(y\in \R \) in \(R\), leads to contradiction. Thus, \(R\) is not an affine variety.
Proposition. Zero polynomial iff zero function when the field is infinite [math-00BP]
- June 10, 2024
- Lîm Tsú-thuàn
Proposition. Zero polynomial iff zero function when the field is infinite [math-00BP]
- June 10, 2024
- Lîm Tsú-thuàn
Remark. [#462]
- June 10, 2024
- Lîm Tsú-thuàn
Remark. [#462]
- June 10, 2024
- Lîm Tsú-thuàn
This proposition is helpful when we are going to show a set is not a variety.
Let \(k\) be an infinite field and let \(f \in k[x_1, \dots , x_n]\) be a polynomial. Then \(f = 0\) in \(k[x_1, \dots , x_n]\) if and only if \(f : k^n \to k\) is the zero function.
Proof. [#463]
- June 10, 2024
- Lîm Tsú-thuàn
Proof. [#463]
- June 10, 2024
- Lîm Tsú-thuàn
The zero polynomial's coefficients are all zero, so if direction is clear. The converse part can be show by induction on the number of variables \(n\):
- When \(n = 1\), a nonzero polynomial in \(k[x]\) of degree \(m\) has at most \(m\) distinct roots. For the particular \(f\), \(f(a) = 0\) is assumed for all \(a \in k\). Since \(k\) is infinite, we just show \(f\) get infinitely many roots, and hence \(f\) must be the zero polynomial.
-
Assume converse is true for \(n-1\), and let \(f \in k[x_1,\dots ,x_n]\) be a polynomial that vanishes at all points of \(k^n\). By collecting the various powers of \(x_n\), \(f\) can be wrote in the form
\[ f = \sum _{i=0}^N g_i(x_1, \dots , x_{n-1}) x^i_n \]where \(g_i \in k[x_1,\dots ,x_{n-1}]\). We will show that each \(g_i\) is the zero polynomial in \(n-1\) variables, which will force \(f\) to be the zero polynomial in \(k[x_1, \dots , x_n]\).
If we fix \((a_1, \dots , a_{n-1}) \in k^{n-1}\), we get the polynomial \(f(a_1, \dots , a_{n-1}, x_n) \in k[x_n]\). By our hypothesis on \(f\), this vanishes for every \(a_n \in k\). It follows from the case \(n=1\) that \(f(a_1, \dots , a_{n-1}, x_n)\) is the zero polynomial in \(k[x_n]\).
Use the above formula of \(f\), we see that the coefficients of \(f(a_1,\dots ,a_{n-1},x_n)\) are \(g_i(a_1, \dots ,a_{n-1})\), and thus \(g_i(a_1,\dots ,a_{n-1}) = 0\) for all \(i\). Since \((a_1,\dots ,a_{n-1})\) was arbitrarily chosen in \(k^{n-1}\), it follows that each \(g_i\) gives the zero function on \(k[x_1, \dots , x_{n-1}]\). Our inductive assumption then implies that each \(g_i\) is the zero polynomial in \(k[x_1, \dots , x_{n-1}]\). This force \(f\) to be the zero polynomial in \(k[x_1,\dots ,x_n]\) and completes the proof.
Definition. Differentiable manifold [math-00BN]
- June 8, 2024
- Lîm Tsú-thuàn
Definition. Differentiable manifold [math-00BN]
- June 8, 2024
- Lîm Tsú-thuàn
A differentiable manifold of dimension \(n\) is a set \(M\) and a family of injective mappings \(x_\alpha : U_\alpha \subset \R ^n \to M\) of open sets \(U_\alpha \) of \(\R ^n\) into \(M\) such that
- \(\bigcup _\alpha x_\alpha (U_\alpha ) = M\)
- for any pair \(\alpha , \beta \) with \(x_\alpha (U_\alpha ) \cap x_\beta (U_\beta ) = W \ne \varnothing \), the sets \(x_\alpha ^{-1}(W)\) and \(x_\beta ^{-1}(W)\) are open sets in \(\R ^n\) and the mappings \(x_\beta ^{-1} \circ x_\alpha \) and \(x_\alpha ^{-1} \circ x_\beta \) are differentiable.
- The family \(\{ (U_\alpha , x_\alpha ) \}\) is maximal relative to the conditions (1) and (2).
A family \(\{ (U_\alpha , x_\alpha ) \}\) is called a differentiable structure on \(M\).
Proposition. Product of differentiable manifold [math-00BO]
- June 8, 2024
- Lîm Tsú-thuàn
Proposition. Product of differentiable manifold [math-00BO]
- June 8, 2024
- Lîm Tsú-thuàn
Let \(M\) and \(N\) be differentiable manifolds (Definition [math-00BN]), and let \(\{ (U_\alpha ,x_\alpha ) \}\), \(\{ (V_\beta ,y_\beta ) \}\) be differentiable structures respectively. A mapping \(z_{\alpha \beta }(p,q) = (x_\alpha (p), y_\beta (q))\) for all \(p \in U_\alpha \) and \(q \in V_\beta \), then \(\{ (W_{\alpha \beta }, z_{\alpha \beta }) \}\) is a differentiable structure on \(M \times N\).
Proof. [#464]
- June 8, 2024
- Lîm Tsú-thuàn
Proof. [#464]
- June 8, 2024
- Lîm Tsú-thuàn
We need two parts: covering and differentiable to show it.
- First we need to show \(\{ (U_\alpha \times V_\beta , z_{\alpha \beta }) \}\) covers \(M \times N\), by \[ \bigcup _{\alpha \beta } z_{\alpha \beta }(U_\alpha \times V_\beta ) = \bigcup _{\alpha \beta } (x_\alpha (U_\alpha ), y_\beta (V_\beta )) = \bigcup _\alpha x_\alpha (U_\alpha ) \times \bigcup _\beta y_\beta (V_\beta ) \] so the \(M \times N\) is covered by definition componentwise.
- Then we are going to show for any \(\alpha \beta \) and \(\gamma \delta \), with \(z_{\alpha \beta }(W_{\alpha \beta }) \cap z_{\gamma \delta }(W_{\gamma \delta }) = Z \ne \varnothing \), the mappings \(z^{-1}_{\alpha \beta }(Z)\) and \(z^{-1}_{\gamma \delta }(Z)\) are open sets. Consider \(z^{-1}_{\alpha \beta }(Z) = (x^{-1}_\alpha (Z), y^{-1}_\beta (Z))\), each component is open by definition, so immediately tell us \(z^{-1}_{\alpha \beta }(Z)\) is open in the induced product topology. The same argument can be applied to \(z^{-1}_{\gamma \delta }(Z)\). Finally, we need to show \(z_{\gamma \delta }^{-1} \circ z_{\alpha \beta }\) and \(z_{\alpha \beta }^{-1} \circ z_{\gamma \delta }\) are differentiable, again by symmetry we only need to do it once: \[ (z_{\gamma \delta }^{-1} \circ z_{\alpha \beta })(W_{\alpha \beta }) = (x_\gamma ^{-1} \circ x_\alpha (p), y_\delta ^{-1} \circ y_\beta (q)) \] and components are differentiable by definition, so we get a differential of \(z_{\gamma \delta }^{-1} \circ z_{\alpha \beta }\) by taking differential componentwise.
Proposition. [#465]
- June 8, 2024
- Lîm Tsú-thuàn
Proposition. [#465]
- June 8, 2024
- Lîm Tsú-thuàn
It's notable that \(\pi _1 : M \times N \to M\) and \(\pi _2 : M \times N \to N\) are differentiable.
Proof. [#466]
- June 8, 2024
- Lîm Tsú-thuàn
Proof. [#466]
- June 8, 2024
- Lîm Tsú-thuàn
\(\pi _1\) is differentiable if \(x_\alpha ^{-1} \circ \pi _1 \circ z_{\alpha \beta }\) is differentiable, so we expand it
\[ x_\alpha ^{-1} \circ \pi _1 \circ (x_\alpha , y_\beta ) = x_\alpha ^{-1} \circ x_\alpha \]and this function by definition is differentiable. The same argument can be applied to \(\pi _2\).
Definition. Ideal [math-00BM]
- June 2, 2024
- Lîm Tsú-thuàn
Definition. Ideal [math-00BM]
- June 2, 2024
- Lîm Tsú-thuàn
A subring \(A\) of a ring \(R\) is a ideal of \(R\) if for every \(r \in R\) and every \(a \in A\), both \(r \cdot a\) and \(a \cdot r\) are in \(A\).
Theorem. How to check a subset is an ideal [#467]
- June 2, 2024
- Lîm Tsú-thuàn
Theorem. How to check a subset is an ideal [#467]
- June 2, 2024
- Lîm Tsú-thuàn
A nonempty subset \(A\) is an ideal of \(R\) if
- \(a - b \in A\) for all \(a, b \in A\)
- \(r \cdot a\) and \(a \cdot r\) are in \(A\) whenever \(a \in A\) and \(r \in R\).
Definition. Affine variety [math-00BL]
- June 1, 2024
- Lîm Tsú-thuàn
Definition. Affine variety [math-00BL]
- June 1, 2024
- Lîm Tsú-thuàn
Let \(k\) be a field, and let \(f_1, \dots , f_s\) be polynomials in \(k[x_1, \dots , x_n]\) (or \(k[\underline {x}]\) for short). Then an affine variety
\[ V(f_1, \dots , f_s) = \{ (a_1, \dots , a_n) \in k^n \mid f_i(a_1,\dots ,a_n)=0 \text { for all } 1 \le i \le s \} \]is the set of all solutions of the system of equations
\[f_1(x_1, \dots , x_n) = \cdots = f_s(x_1, \dots , x_n) = 0\]
Theorem. Fermat's little theorem [math-00BK]
- May 31, 2024
- Lîm Tsú-thuàn
Theorem. Fermat's little theorem [math-00BK]
- May 31, 2024
- Lîm Tsú-thuàn
If \(p\) is prime, then \(a^p \div p\) has the remainder \(a\).
Proof. [#468]
- May 31, 2024
- Lîm Tsú-thuàn
Proof. [#468]
- May 31, 2024
- Lîm Tsú-thuàn
- The idea is imaging there are \(p\)-points circles, each point has a color picked from \(a\) colors.
- There are exactly \(a^p\) possible circles, now we group circles that isomorphic under rotation together, we can see that at most \(p\) circles each group.
- Now, a \(p\)-points circles group can only have \(p\) elements or it has \(1\) elements, because no pattern can repeated in \(p\)-points.
- Then we already complete, we can separate \(a^p\) many circles to \(N\) groups, each with \(p\) circles, and remains \(a\) circles are single colored.
Definition. Riemann manifold and Riemann metric [math-00BI]
- May 30, 2024
- Lîm Tsú-thuàn
Definition. Riemann manifold and Riemann metric [math-00BI]
- May 30, 2024
- Lîm Tsú-thuàn
Let \(M\) be a manifold, \((M,g)\) is a Riemann manifold if for each point \(p \in M\) there is an inner product function defined for tangent space \(T_pM\)
\[ \langle -,- \rangle : T_pM \times T_pM \to \R \]such that have
- bilinearity: \(\langle X,Y \rangle \) is linear for both \(X\) and \(Y\), where \(X,Y \in T_pM\).
- positive-definiteness: \(\langle X,X \rangle \ge 0\) for all \(X \in T_pM\), and \(\langle X,X \rangle = 0\) iff \(X = 0\).
- symmetry: \(\langle X,Y \rangle = \langle Y,X \rangle \) for all \(X,Y \in T_pM\).
we called \(\langle -,- \rangle \) is the Riemann metric (or just metric) of the space \(M\).
Notation. [#470]
- May 30, 2024
- Lîm Tsú-thuàn
Notation. [#470]
- May 30, 2024
- Lîm Tsú-thuàn
Below are all usual notation for the metric
\[\langle -,- \rangle = \langle -,- \rangle _p = g(-,-)\]Let \(x^i\) be basis of a local coordinate at \(p\), then \(T_pM\) has basis \(\partial _i = \frac {\partial }{\partial x^i}\)
\[ g_{ij} = \langle \partial _i, \partial _j \rangle \]\((g_{ij})\) will be the matrix that each component is \(g_{ij}\). The inverse matrix denotes \((g^{ij})\)
For any two points \(p,q \in M\), we define the distance function
\[ d(p,q) = \inf _\gamma s(\gamma ) \]\(\gamma \) is any differentiable curve (aka \(\gamma : [0,1] \to M\)) connects \(p\) and \(q\), where \(s\) defined as
\[ s(\gamma ) = \int ^1_0 \sqrt {\langle \frac {d \gamma }{d t} , \frac {d \gamma }{d t} \rangle } dt \]Notice the \(\inf _\gamma \) means, we take the shortest path.
Proposition. Riemann manifold => metric space [math-00BJ]
- May 30, 2024
- Lîm Tsú-thuàn
Proposition. Riemann manifold => metric space [math-00BJ]
- May 30, 2024
- Lîm Tsú-thuàn
A Riemann manifold \((M,d)\) is a metric space, i.e. proving three properties below:
- positive-definiteness: \(d(p,q) \ge 0\), and \(d(p,q)=0 \iff p = q\)
- symmetry: \(d(p,q) = d(q,p)\)
- triangle inequality: \(d(p,r) + d(r,q) \ge d(p,q)\)
Proof. [#469]
- May 30, 2024
- Lîm Tsú-thuàn
Proof. [#469]
- May 30, 2024
- Lîm Tsú-thuàn
By definition, \(d(p,q) = s(\gamma )\) for a \(\gamma \) with least \(s(\gamma )\), so
\[ d(p,q) = \int ^1_0 \sqrt {\langle \frac {d \gamma }{d t} , \frac {d \gamma }{d t} \rangle } dt \]since \(\langle -,- \rangle \) is positive-defined, the integral result is positive.
\[\begin {aligned} & d(p,q) = 0 \\ \iff & \exists \gamma , \langle \frac {d \gamma }{d t} , \frac {d \gamma }{d t} \rangle = 0 \\ \iff & \exists \gamma , \frac {d \gamma }{d t} = 0 \\ \iff & p = q \end {aligned}\]To show symmetry, we suppose it does not
\[ d(p,q) = s(\gamma _0) \ne s(\gamma _1) = d(q,p) \]whether \(s(\gamma _0) \gt s(\gamma _1)\) or \(s(\gamma _0) \lt s(\gamma _1)\), we know it doesn't make sense to use \(\gamma _0\) (or \(\gamma _1\)) to be shortest path, and hence one of \(d(p,q)\) and \(d(q,p)\)'s definition is wrong, so \(d(p,q) = d(q,p)\) has to be hold.
To show triangle inequality, we first rewrite
\[ d(p,r) + d(r,q) \ge d(p,q) \]in terms of curves
\[ s(\gamma _0) + s(\gamma _1) \ge s(\gamma _2) \]but notice that \(\gamma _1\) after \(\gamma _0\) is also a curve from \(p\) to \(q\), and \(\gamma _2\) by definition is one of the path with shortest length, and hence the length of \(\gamma _1\) plus \(\gamma _0\) at less equals to the length of \(\gamma _2\), or be bigger.
Tool. Chocolatey [windows-0001]
- May 29, 2024
- https://chocolatey.org/install
Tool. Chocolatey [windows-0001]
- May 29, 2024
- https://chocolatey.org/install
Chocolatey - Software Management for Windows. Installation command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Reload the path in PowerShell [windows-0003]
Reload the path in PowerShell [windows-0003]
This is because after chocolatey installation, the environment needs to be renew.
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
Tool. Visual studio community 2022 [windows-0002]
- May 29, 2024
- Lîm Tsú-thuàn
Tool. Visual studio community 2022 [windows-0002]
- May 29, 2024
- Lîm Tsú-thuàn
Installation. [#272]
- May 29, 2024
- Lîm Tsú-thuàn
Installation. [#272]
- May 29, 2024
- Lîm Tsú-thuàn
Use chocolatey
choco install visualstudio2022community
Command to enter visual studio developement shell [windows-0004]
- May 29, 2024
- Lîm Tsú-thuàn
Command to enter visual studio developement shell [windows-0004]
- May 29, 2024
- Lîm Tsú-thuàn
In powershell
$vsPath = (vswhere -latest -property installationPath) Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64"
Example. How to run VS Installer from CLI [windows-0005]
- May 29, 2024
- Lîm Tsú-thuàn
Example. How to run VS Installer from CLI [windows-0005]
- May 29, 2024
- Lîm Tsú-thuàn
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" modify --channelId "VisualStudio.17.Release" --productID "Microsoft.VisualStudio.Product.Community" --add "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" --add "Microsoft.VisualStudio.Component.Windows11SDK.14393" --add "Microsoft.VisualStudio.Component.VC.ATL" --quiet --norestart
Definition. Abelian group [math-00BH]
- May 28, 2024
- Lîm Tsú-thuàn
Definition. Abelian group [math-00BH]
- May 28, 2024
- Lîm Tsú-thuàn
A group \(G\) is abelian if for all \(g,h \in G\), we have
\[gh = hg\]
Definition. The category of abelian groups \(Ab\) [#471]
- May 28, 2024
- Lîm Tsú-thuàn
Definition. The category of abelian groups \(Ab\) [#471]
- May 28, 2024
- Lîm Tsú-thuàn
This is a subcategory of the category of groups.
- Objects are abelian groups
- Morphisms are group homomorphisms
Definition. Conjugation [math-00BG]
- May 28, 2024
- Lîm Tsú-thuàn
Definition. Conjugation [math-00BG]
- May 28, 2024
- Lîm Tsú-thuàn
For two elements \(g,h \in G\) of a group \(G\), the conjugation \(g^h = h^{-1} g h\). This can be applied to a subset \(A \subseteq G\), by \(A^k = \{ a^k \mid a \in A \}\).
Definition. Conjugate [#472]
- May 28, 2024
- Lîm Tsú-thuàn
Definition. Conjugate [#472]
- May 28, 2024
- Lîm Tsú-thuàn
Two subsets \(A,B\) of \(G\) are conjugate if there exists \(h \in G\) such that \(B = A^h\), this is an equivalence relation, and hence has equivalence class \(\text {conj}(A)\). A singleton \(\{ g \}\) via \(g \in G\) simply denote by \(\text {conj}(g)\).
Definition. Self-conjugate [#473]
- May 28, 2024
- Lîm Tsú-thuàn
Definition. Self-conjugate [#473]
- May 28, 2024
- Lîm Tsú-thuàn
A subset \(A\) is self-conjugate if \(\text {conj}(A) = \{ A \}\).
Definition. Linear functional [math-00BE]
- May 18, 2024
- Lîm Tsú-thuàn
Definition. Linear functional [math-00BE]
- May 18, 2024
- Lîm Tsú-thuàn
Linear Algebra Done Right
A linear functional on a space \(V\) is a linear map from \(V\) to its scalar field \(F\).
Definition. Norm, \(\Vert v \Vert \) [math-00BC]
- May 15, 2024
- Lîm Tsú-thuàn
Definition. Norm, \(\Vert v \Vert \) [math-00BC]
- May 15, 2024
- Lîm Tsú-thuàn
For \(v \in V\), the norm of \(v\), denoted \(\Vert v \Vert \) is defined by
\[ \Vert v \Vert = \sqrt {\langle v,v \rangle } \]\(\langle v,v \rangle \) is a inner product of the vector space.
Definition. Orthonormal basis [math-00BA]
- May 15, 2024
- Lîm Tsú-thuàn
Definition. Orthonormal basis [math-00BA]
- May 15, 2024
- Lîm Tsú-thuàn
An orthonormal basis of \(V\) is an orthonormal (Definition [math-00BB]) list of vectors in \(V\) that is also a basis of \(V\).
Definition. Orthonormal [math-00BB]
- May 15, 2024
- Lîm Tsú-thuàn
Definition. Orthonormal [math-00BB]
- May 15, 2024
- Lîm Tsú-thuàn
A list of vectors is orthonormal if each vector in the list has norm \(1\) and is orthogonal to all other vectors in the list. In the other word
\[ \langle e_j , e_k \rangle = \begin {cases} 1 \text { if } j = k \\ 0 \text { if } j \ne k \end {cases} \]
Proposition. How is orthonormal basis important [math-00BD]
- May 15, 2024
- Lîm Tsú-thuàn
Proposition. How is orthonormal basis important [math-00BD]
- May 15, 2024
- Lîm Tsú-thuàn
Any vector \(v \in V\) can be represented by a basis
\[ v = a_1e_1 + \cdots + a_ne_n = \sum ^n_{i=0} a_i e_i \]For arbitrary basis of \(V\), to compute each \(a_i\) is hard. But for orthonormal basis is very easy, we have \(a_i = \langle v,e_i \rangle \). Therefore, one can write
\[ v = \langle v,e_1 \rangle e_1 + \cdots + \langle v,e_n \rangle e_n = \sum ^n_{i=0} \langle v,e_i \rangle e_i \]
Proof. [#474]
- May 15, 2024
- Lîm Tsú-thuàn
Proof. [#474]
- May 15, 2024
- Lîm Tsú-thuàn
First write a vector in linear combination form \(v = a_1e_1 + \cdots + a_ne_n\). Now see that
\[ \langle v,e_i \rangle = a_1 \langle e_i,e_1 \rangle + \cdots + a_n \langle e_i,e_n \rangle \]By definition, we have a list of \(0\) except \(1 = \langle e_i,e_i \rangle \), and hence \(\langle v,e_i \rangle = a_i\)
Definition. Étalé space [math-00B6]
- May 10, 2024
- Lîm Tsú-thuàn
Definition. Étalé space [math-00B6]
- May 10, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology
Let \(X\) be a topological space, an étalé space over \(X\) is a pair \((E, \pi )\), where \(E\) is a topological space and \(\pi : E \to X\) is a local homeomorphism.
Definition. Category of étalé spaces [math-00B7]
- May 10, 2024
- Lîm Tsú-thuàn
Definition. Category of étalé spaces [math-00B7]
- May 10, 2024
- Lîm Tsú-thuàn
A category of étalé spaces has
- The objects are étalé spaces \((E,\pi )\)
- A morphism \(f : (E_1, \pi _1) \to (E_2, \pi _2)\) is a continuous map \(f : E_1 \to E_2\) such that \(\pi _1 = \pi _2 \circ f\).
Denote by \(Ét/X\) the category of étalé spaces over \(X\).
Definition. Local homeomorphism [math-00B8]
- May 10, 2024
- Lîm Tsú-thuàn
Definition. Local homeomorphism [math-00B8]
- May 10, 2024
- Lîm Tsú-thuàn
A continuous map \(f : X \to Y\) is a local homeomorphism if there exists an open covering \((U_i)_i\) of \(X\) such that \(f_{\rvert U_i} : U_i \to Y\) is an open topological embedding.
Definition. Topological embedding [math-00B9]
- May 10, 2024
- Lîm Tsú-thuàn
Definition. Topological embedding [math-00B9]
- May 10, 2024
- Lîm Tsú-thuàn
A topological embedding is a map \(j : Y \to X\) such that yields a homeomorphism \(Y \to j(Y)\), where \(j(Y)\) is endowed with the topology induced by the topology on \(X\).
- An embedding is open if \(j\) is an open map.
- An embedding is closed if \(j\) is a closed map.
Definition. Primitive recursive function [math-00B4]
- May 9, 2024
- Lîm Tsú-thuàn
Definition. Primitive recursive function [math-00B4]
- May 9, 2024
- Lîm Tsú-thuàn
Mathematical Logic and Computation
The set of primitive recursive functions is the set of functions from the natural numbers to the natural numbers, of various arities, defined inductively:
- The constant \(0\) is primitive recursive.
- The successor function, \(succ\), is primitive recursive.
- Each projection function \(\pi ^n_i\) is primitive recursive.
-
closed under composition
If \(f\) is a \(k\)-ary primitive recursive function and \(g_0, \dots , g_{k-1}\) are \(l\)-ary primitive recursive functions, then the composition of \(f\) with \(g_0, \dots , g_{k-1}\) is primitive recursive (\(l\)-ary): \[ f(g_0(x_0, \dots , x_{l-1}), \dots , g_{k-1}(x_0, \dots , x_{l-1})) \] -
closed under primitive recursion
If \(f\) is a \(k\)-ary primitive recursive function and \(g\) is a \(k+2\)-ary primitive recursive function, then the function defined by primitive recursion from \(f\) and \(g\) is primitive recursive: \[\begin {aligned} h(0, z_0, \dots , z_{k-1}) &= f(z_0, \dots , z_{k-1}) \\ h(x+1, z_0, \dots , z_{k-1}) &= g(x, h(x, z_0, \dots , z_{k-1}), z_0, \dots , z_{k-1}) \end {aligned}\]
Definition. Sheaf [math-00B3]
- May 8, 2024
- Lîm Tsú-thuàn
Definition. Sheaf [math-00B3]
- May 8, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology, §3.1
Let \(X\) be a topological space, a sheaf \(\mathcal {F}\) is a presheaf that for all open sets \(U\) in \(X\) and every open covering \(U = \bigcup _{i\in I}U_i\) the following condition holds:
Condition. Sh [#476]
- May 8, 2024
- Lîm Tsú-thuàn
Condition. Sh [#476]
- May 8, 2024
- Lîm Tsú-thuàn
Given \(s_i \in \mathcal {F}(U_i)\) for all \(i \in I\) such that
\[ {s_i}_{\rvert {U_i \cap U_j}} = {s_j}_{\rvert {U_i \cap U_j}} \]for all \(i,j\in I\). Then there exists a unique \(s \in \mathcal {F}(U)\) such that \({s_i}_{\rvert {U_i}} = s_i\) for all \(i \in I\).
A morphism of sheaves is a morphism of presheaves, we denote \(\text {Sh}(X)\) for the category of sheaves on \(X\).
Definition. Basis (topological) [math-00B0]
- May 7, 2024
- Lîm Tsú-thuàn
Definition. Basis (topological) [math-00B0]
- May 7, 2024
- Lîm Tsú-thuàn
A set \(\mathcal {B}\) of open subsets of \(X\) is a basis of the topology if every open subset of \(X\) is a union of sets in \(\mathcal {B}\).
Definition. Compact space [math-00AX]
- May 7, 2024
- Lîm Tsú-thuàn
Definition. Compact space [math-00AX]
- May 7, 2024
- Lîm Tsú-thuàn
A topological space \(X\) is compact if every open covering of \(X\) has a finite subcovering.
Definition. Countability properties [math-00AW]
- May 7, 2024
- Lîm Tsú-thuàn
Definition. Countability properties [math-00AW]
- May 7, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology
Let \(X\) be a topological space.
- \(X\) is first countable if each point has a countable basis.
- \(X\) is second countable if the topology has a countable basis.
- \(X\) is a Lindelöf space if every open covering of \(X\) has a countable subcovering.
- \(X\) is separable if it contains a countable dense subset.
- \(X\) is \(\sigma \)-compact if it's the union of countably many compact subspaces.
Definition. Covering [math-00AZ]
- May 7, 2024
- Lîm Tsú-thuàn
Definition. Covering [math-00AZ]
- May 7, 2024
- Lîm Tsú-thuàn
Let \(X\) be a topological space and let \(Y\) be a subset of \(X\). A family \((A_i)_{i \in I}\) of subsets of \(X\) is called a covering of \(Y\) in \(X\) if
\[Y \subseteq \bigcup _{i\in I} A_i\]- A covering \((A_i)_{i \in I}\) is called an open covering if all \(A_i\) are open in \(X\).
- A covering \((A_i)_{i \in I}\) is called an closed covering if all \(A_i\) are closed in \(X\).
Definition. Locally compact space [math-00AY]
- May 7, 2024
- Lîm Tsú-thuàn
Definition. Locally compact space [math-00AY]
- May 7, 2024
- Lîm Tsú-thuàn
Definition. Intensionality [tt-001P]
- May 6, 2024
- Lîm Tsú-thuàn
Definition. Intensionality [tt-001P]
- May 6, 2024
- Lîm Tsú-thuàn
A type theory is intensional if it distinguishes between equalities that
- hold by reduction (definitionally equality)
- and those hold by proof (propositional equality)
Definition. Definitionally equality [tt-001Q]
- May 6, 2024
- Lîm Tsú-thuàn
Definition. Definitionally equality [tt-001Q]
- May 6, 2024
- Lîm Tsú-thuàn
Two terms \(u, v : T\) are definitionally equal if they reduce to the same normal form.
Definition. Propositional equality [tt-001R]
- May 6, 2024
- Lîm Tsú-thuàn
Definition. Propositional equality [tt-001R]
- May 6, 2024
- Lîm Tsú-thuàn
Two terms \(u, v : T\) are propositionally equal if there is a proof \(u = v\) using the inductive equality type \(=\) at type \(T\). For example, an inductive equality type in agda looks like
data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x
Proposition. Preimage of each basis is open is sufficient to be continuous [math-00AV]
- May 5, 2024
- Lîm Tsú-thuàn
Proposition. Preimage of each basis is open is sufficient to be continuous [math-00AV]
- May 5, 2024
- Lîm Tsú-thuàn
Prove that a function \(f : X \to Y\) is continuous if and only if \(f^{-1}B\) is open for every \(B\) in a basis for the topology on \(Y\).
Proof. [#481]
- May 5, 2024
- Lîm Tsú-thuàn
Proof. [#481]
- May 5, 2024
- Lîm Tsú-thuàn
Preimage of each basis is open is sufficient to be continuous › forward [#479]
- May 5, 2024
- Lîm Tsú-thuàn
Preimage of each basis is open is sufficient to be continuous › forward [#479]
- May 5, 2024
- Lîm Tsú-thuàn
A function is continuous iff \(f^{-1}U\) is open whenever \(U\) is open in \(Y\), of course, basis are open.
Preimage of each basis is open is sufficient to be continuous › backward [#480]
- May 5, 2024
- Lîm Tsú-thuàn
Preimage of each basis is open is sufficient to be continuous › backward [#480]
- May 5, 2024
- Lîm Tsú-thuàn
Reversely, \(f^{-1}B\) is open for every basis \(B\). Every \(U\) is open is built by some union of basis, \(f^{-1}U\) is built by some union of \(f^{-1}B\) open sets, and hence are open sets, implies a function is continuous.
Proposition. Completement of interior and closure [math-00AT]
- April 29, 2024
- Lîm Tsú-thuàn
Proposition. Completement of interior and closure [math-00AT]
- April 29, 2024
- Lîm Tsú-thuàn
Consider a topological space \(X\) and an arbitrary subset \(A\) of it,
- show that \(X \setminus \text {int}(A) = \overline {X \setminus A}\).
- show that \(X \setminus \overline {A} = \text {int}(X \setminus A)\).
Proof. [#484]
- April 29, 2024
- Lîm Tsú-thuàn
Proof. [#484]
- April 29, 2024
- Lîm Tsú-thuàn
The idea is based on facts about interior and closure:
- \(U\) is the interior of \(A\) means there will no any open set \(K\) satisfy \(U \subset K \subset A\).
- \(C\) is the closure of \(A\) means there will no any closed set \(F\) satisfy \(A \subset F \subset C \subset X\).
Part. [#482]
- April 29, 2024
- Lîm Tsú-thuàn
Part. [#482]
- April 29, 2024
- Lîm Tsú-thuàn
Suppose \(X \setminus \text {int}(A) \ne \overline {X \setminus A} = \mathfrak {C}\), then we have
\[ X \setminus A \subset \overline {X \setminus A} \subset X \setminus \text {int}(A) \]implies that
\[ \text {int}(A) \subset X \setminus \mathfrak {C} \subset A \]shows \(\text {int}(A)\) is not the interior of \(A\), leads contradiction, so \(X \setminus \text {int}(A) = \overline {X \setminus A}\).
Part. [#483]
- April 29, 2024
- Lîm Tsú-thuàn
Part. [#483]
- April 29, 2024
- Lîm Tsú-thuàn
Suppose \(X \setminus \overline {A} \ne \text {int}(X \setminus A) = \mathfrak {O}\), then we are saying
\[ X \setminus \overline {A} \subset \text {int}(X \setminus A) \subset X \setminus A \]implies that
\[ A \subset X \setminus \mathfrak {O} \subset \overline {A} \]shows \(\overline {A}\) is not the closure of \(A\), leads contradiction, so \(X \setminus \overline {A} = \text {int}(X \setminus A)\).
Definition. Assembly [math-00AP]
- April 20, 2024
- Lîm Tsú-thuàn
Definition. Assembly [math-00AP]
- April 20, 2024
- Lîm Tsú-thuàn
Categorical Realizability
An assembly over a pca \(\mathcal {A}\) is a set \(X\) together with a relation \(\Vdash \) between \(\mathcal {A}\) and \(X\) such that for all \(x \in X\), there exists at least one element \(a\in \mathcal {A}\) with \(a\Vdash x\).
The relation \(a \Vdash x\) pronounced "\(a\) realizes \(x\)" or "\(a\) is a realizer of \(x\)". \(a\) can be thought as an implementation of \(x \in X\) in the pca \(\mathcal {A}\).
Notation. \((|X|,\Vdash _X)\) [#498]
- April 20, 2024
- Lîm Tsú-thuàn
Notation. \((|X|,\Vdash _X)\) [#498]
- April 20, 2024
- Lîm Tsú-thuàn
Given an assembly \(X\), we wrote \(|X|\) for its underlying set and \(\Vdash _X\) for its relation between \(\mathcal {A}\) and \(|X|\).
Example. Encode booleans [#499]
- April 20, 2024
- Lîm Tsú-thuàn
Example. Encode booleans [#499]
- April 20, 2024
- Lîm Tsú-thuàn
The assembly of booleans is defined as
\[ |2| \doteq \{ 0,1 \} \quad \text {with realizers}\quad \bold {false}\Vdash _2 0 \;\text {and}\; \bold {true}\Vdash _2 1 \]
Example. Encode natural numbers [#500]
- April 20, 2024
- Lîm Tsú-thuàn
Example. Encode natural numbers [#500]
- April 20, 2024
- Lîm Tsú-thuàn
The assembly of natural numbers is defined as
\[ |N| \doteq \N \quad \text {with realizers}\quad \bar {n}\Vdash _N n \;\text {for each}\;n\in \N \]
Example. \(\mathcal {K}_1\) model [#501]
- April 20, 2024
- Lîm Tsú-thuàn
Example. \(\mathcal {K}_1\) model [#501]
- April 20, 2024
- Lîm Tsú-thuàn
A \(\mathcal {K}_1\) model as pca and the set of all Turing computable functions:
\[ |X| \doteq \{ f : \N \rightharpoonup \N \mid f\ \text {is Turing computable} \} \quad \text {and}\quad m \Vdash _X f \iff \varphi _m = f \]
Definition. Category of assembilies over a pca [math-00AR]
- April 20, 2024
- Lîm Tsú-thuàn
Definition. Category of assembilies over a pca [math-00AR]
- April 20, 2024
- Lîm Tsú-thuàn
Categorical Realizability
First, we define map between assemblies.
Definition. Assembly map [#485]
- April 20, 2024
- Lîm Tsú-thuàn
Definition. Assembly map [#485]
- April 20, 2024
- Lîm Tsú-thuàn
An assembly map from an assembly \(X\) to an assembly \(Y\) is a function \(f : |X| \to |Y|\) that is tracked by some element.
Definition. Track [math-00AQ]
- April 20, 2024
- Lîm Tsú-thuàn
Definition. Track [math-00AQ]
- April 20, 2024
- Lîm Tsú-thuàn
For assembilies \(X\) and \(Y\), we say that an element \(t \in \mathcal {A}\) tracks a function \(f : |X| \to |Y|\) if for all \(x \in |X|\) and \(a \in \mathcal {A}\), if \(a \Vdash _X x\), then \(t\ a\) is defined and \(t\ a \Vdash _Y f(x)\).
Then, we check assembilies and assembly maps form a category.
Proposition. Assembilies and assembly maps form a category [#486]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Assembilies and assembly maps form a category [#486]
- April 20, 2024
- Lîm Tsú-thuàn
Proof. [#487]
- April 20, 2024
- Lîm Tsú-thuàn
Proof. [#487]
- April 20, 2024
- Lîm Tsú-thuàn
Notation. \(\text {Asm}_{\mathcal {A}}\) [#488]
- April 20, 2024
- Lîm Tsú-thuàn
Notation. \(\text {Asm}_{\mathcal {A}}\) [#488]
- April 20, 2024
- Lîm Tsú-thuàn
We denote \(\text {Asm}_{\mathcal {A}}\) for the category of assembilies over a pca \(\mathcal {A}\).
Example. [#489]
- April 20, 2024
- Lîm Tsú-thuàn
Example. [#489]
- April 20, 2024
- Lîm Tsú-thuàn
The trivial pca has \(\text {Asm}_{\{ \star \}} = \text {Set}\).
Proposition. Terminal object [#490]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Terminal object [#490]
- April 20, 2024
- Lîm Tsú-thuàn
The terminal object \(1\) in \(\text {Asm}_{\mathcal {A}}\) is given by
\[ |1| \doteq \{ \star \} \quad \text {and}\quad a\Vdash _1 \star \ \text {for all}\ a \in \mathcal {A} \]
Proposition. Products [#491]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Products [#491]
- April 20, 2024
- Lîm Tsú-thuàn
The product \(X \times Y\) of two assembilies is given by
\[ |X \times Y| \doteq |X| \times |Y| \quad \text {and}\quad \bold {pair}\ a\ b \Vdash _{X \times Y} (x, y) \ \text {for all}\ a \Vdash _X x \ \text {and}\ b \Vdash _Y y \]
Proposition. Exponentials [#492]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Exponentials [#492]
- April 20, 2024
- Lîm Tsú-thuàn
The exponential \(Y^X\) of two assembilies is given by
\[ |Y^X| \doteq \text {the set of assembly maps from}\ X\ \text {to}\ Y \quad \text {and}\quad t \Vdash _{Y^X} f\ \text {if}\ t\ \text {tracks}\ f \]
Proof. [#493]
- April 20, 2024
- Lîm Tsú-thuàn
Proof. [#493]
- April 20, 2024
- Lîm Tsú-thuàn
The evaluation morphism \(ev : Y^X \times X \to Y\) is given by \((f,x) \mapsto f(x)\) is tracked by \(\langle x \rangle .\ \bold {fst}\ u(\bold {snd}\ u)\). Every \(g : Z \times X \to Y\) induces a unique assembly map \(\bar {g} : Z \to Y^X\) making the commute diagram:
Since there is a unique assignment \(\bar {g}(z) \doteq (x \mapsto g(z, x))\) and the assignment is tracked by \(\langle u \rangle .\ (\langle v \rangle .\ t_g(\bold {pair}\ u\ v))\) when \(t_g\) tracks \(g\).
Proposition. Equalizers [#494]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Equalizers [#494]
- April 20, 2024
- Lîm Tsú-thuàn
The equalizer \(E\) of two assembly maps \(f,g : X \to Y\) is given by
\[ |E| \doteq \{ x \in |X| \mid f(x) = g(x) \} \quad \text {and}\quad a \Vdash _E x\ \text {if}\ a \Vdash _X x \]
Proposition. Initial object [#495]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Initial object [#495]
- April 20, 2024
- Lîm Tsú-thuàn
The initial object \(0\) is given by \(|0| \doteq \varnothing \) with empty realizability relation (no element so empty realizability is fine).
Proposition. Coproducts [#496]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Coproducts [#496]
- April 20, 2024
- Lîm Tsú-thuàn
The coproduct \(X + Y\) is defined by
\[\begin {aligned} |X + Y| \doteq |X| + |Y| \quad \text {and}\quad \bold {left}\ &a \Vdash _{X+Y} \text {inl}(x)\ \text {for}\ a \Vdash _X x \\ \bold {right}\ &b \Vdash _{X+Y} \text {inr}(y)\ \text {for}\ b \Vdash _Y y \end {aligned}\]where
\[ \bold {left} \doteq \bold {pair}\ \bold {false} \ \text {and}\ \bold {right} \doteq \bold {pair}\ \bold {true} \]
Proposition. Coequalizers [#497]
- April 20, 2024
- Lîm Tsú-thuàn
Proposition. Coequalizers [#497]
- April 20, 2024
- Lîm Tsú-thuàn
The coequalizer \(C\) of assembly maps \(f,g : X \to Y\) is given by
\[ |C| \doteq |Y|/\sim \quad \text {and}\quad a \Vdash _C [y] \ \text {if}\ a \Vdash _Y y' \ \text {for some}\ y' ~ y \]where \(\sim \) is the least equivalence relation on \(|Y|\) generated by \(f(x) ~ g(x)\) for all \(x \in |X|\).
Definition. Track [math-00AQ]
- April 20, 2024
- Lîm Tsú-thuàn
Definition. Track [math-00AQ]
- April 20, 2024
- Lîm Tsú-thuàn
For assembilies \(X\) and \(Y\), we say that an element \(t \in \mathcal {A}\) tracks a function \(f : |X| \to |Y|\) if for all \(x \in |X|\) and \(a \in \mathcal {A}\), if \(a \Vdash _X x\), then \(t\ a\) is defined and \(t\ a \Vdash _Y f(x)\).
Theorem. Any two connected points has isomorphic fundamental group [math-00AO]
- April 19, 2024
- Lîm Tsú-thuàn
Theorem. Any two connected points has isomorphic fundamental group [math-00AO]
- April 19, 2024
- Lîm Tsú-thuàn
Let \(b,c\in X\), \(\alpha \) is a path from \(b\) to \(c\), then \(\alpha \) induces an isomorphism of \(\pi _1(Xb)\) and \(\pi _1(X,c)\)
\[\begin {aligned} a_\star : \pi _1(X,c) &\to \pi _1(X, b) \\ [\gamma ] &\mapsto a_\star ([\gamma ]) = [\alpha ][\gamma ][\alpha ]^{-1} \end {aligned}\]
Proof. [#502]
- April 19, 2024
- Lîm Tsú-thuàn
Proof. [#502]
- April 19, 2024
- Lîm Tsú-thuàn
- By \[ a_\star ([\beta ][\gamma ]) = [\alpha ][\beta ][\gamma ][\alpha ]^{-1} = [\alpha ][\beta ][\alpha ]^{-1}[\alpha ][\gamma ][\alpha ]^{-1} = a_\star ([\beta ])a_\star ([\gamma ]) \] so \(a_\star \) is a isomorphism of group.
- By \(a_\star ([\beta ]) = a_\star ([\gamma ])\) implies \[ [\beta ] = [\alpha ]^{-1}[\alpha ][\beta ][\alpha ]^{-1}[\alpha ] = [\alpha ]^{-1}[\alpha ][\gamma ][\alpha ]^{-1}[\alpha ] = [\gamma ] \] so \(a_\star \) is injective.
- If \(\eta \) is a loop on \(b\), then \(\gamma = (\alpha ^{-1}\eta )\alpha \) is a loop on \(c\), thus, \[ a_\star ([\gamma ]) = [\alpha ][\gamma ][\alpha ]^{-1} = [\alpha ][\alpha ]^{-1}[\eta ][\alpha ]^{-1}[\alpha ] = [\eta ] \] so \(a_\star \) is surjective.
Proposition. Fundamental group [math-00AM]
- April 19, 2024
- Lîm Tsú-thuàn
Proposition. Fundamental group [math-00AM]
- April 19, 2024
- Lîm Tsú-thuàn
數學:我思故我在
\(\pi _1(X,b)\) is the fundamental group with base-point \(b\) on \(X\), in the following sense. With a topology space \(X\) and a point \(b \in X\), consider a homotopy class of all loops on \(b\). The collection of these paths are \(\pi _1(X,b)\), there are four properties
- Closed. If \([\alpha ], [\beta ] \in \pi _1(X,b)\), then \([\alpha ][\beta ] = [\alpha \beta ] \in \pi _1(X,b)\)
- Associated
- \([b]\) is an identity element of \(\pi _1(X,b)\)
- Invertible, so for all \(\gamma \in \pi _1(X,b)\), \(\gamma ^{-1}\) exists.
Proposition. \(\pi _1(X,b)\) with homotopy composition is a group. [#503]
- April 19, 2024
- Lîm Tsú-thuàn
Proposition. \(\pi _1(X,b)\) with homotopy composition is a group. [#503]
- April 19, 2024
- Lîm Tsú-thuàn
Proof. [#504]
- April 19, 2024
- Lîm Tsú-thuàn
Proof. [#504]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. Path-connected space [#505]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. Path-connected space [#505]
- April 19, 2024
- Lîm Tsú-thuàn
Due to the isomorphic theorem, on a path-connected space \(X\), we define \(\pi _1(X)\) as the fundamental group of space \(X\).
Definition. Simply connected [#506]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. Simply connected [#506]
- April 19, 2024
- Lîm Tsú-thuàn
If a topological space \(X\) is path-connected and \(\pi _1(X) \cong 0\).
Example. [#507]
- April 19, 2024
- Lîm Tsú-thuàn
Example. [#507]
- April 19, 2024
- Lîm Tsú-thuàn
A convex subset \(\Omega \subseteq \R ^n\) is simply connected.
Definition. Homotopy class (同倫類) [math-00AL]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. Homotopy class (同倫類) [math-00AL]
- April 19, 2024
- Lîm Tsú-thuàn
數學:我思故我在
因為 homotopy 是等價關係,因此可以把 \(a\) 點到 \(b\) 點的所有路徑用同倫關係分成數類,這些類就叫做 homotopy class。一條路徑 \(\gamma \) 所屬的同倫類記為 \([\gamma ]\)。
Definition. 同倫類的乘積 [#508]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. 同倫類的乘積 [#508]
- April 19, 2024
- Lîm Tsú-thuàn
若 \(\alpha \) 表示 \(a\) 到 {b} 的一條路徑,\(\beta \) 表示 \(b\) 到 {c} 的一條路徑,則可以定義 \([\alpha ][\beta ] = [\alpha \beta ]\)。
- 若 \([\alpha _0] = [\alpha _1]\) 且 \([\beta _0] = [\beta _1]\) 則 \([\alpha _0\beta _0][\alpha _1\beta _1]\)
- 同倫類的乘積滿足結合律 \[ ([\alpha][\beta])[\gamma] = [\alpha\beta][\gamma] = [(\alpha\beta)\gamma] = [\alpha(\beta\gamma)] = [\alpha][\beta\gamma] = [\alpha]([\beta][\gamma])\]
Definition. Loop (常數路徑) [math-00AN]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. Loop (常數路徑) [math-00AN]
- April 19, 2024
- Lîm Tsú-thuàn
數學:我思故我在
同倫中端點是 \(a\) 到 \(a\) 的這種路徑叫做 loop,擴展記號寫成 \([a]\)。顯然若有 \(\gamma \) 是 \(a\) 到 \(b\) 的路徑則
\[[a][\gamma ] = [\gamma ] = [\gamma ][b]\]
Definition. Inverse path [#509]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. Inverse path [#509]
- April 19, 2024
- Lîm Tsú-thuàn
若有路徑 \(\gamma \) 從 \(a\) 到 \(b\) 則 \(\gamma ^{-1}\) 表示從 \(b\) 到 \(a\)。且若 \([\gamma _0] = [\gamma _1]\) 則 \([\gamma _0^{-1}] = [\gamma _1^{-1}]\)
Definition. 反同倫類 [#510]
- April 19, 2024
- Lîm Tsú-thuàn
Definition. 反同倫類 [#510]
- April 19, 2024
- Lîm Tsú-thuàn
Inverse path 讓我們可以定義反同倫類
\[[\gamma ]^{-1} = [\gamma ^{-1}]\]
Proposition. [#511]
- April 19, 2024
- Lîm Tsú-thuàn
Proposition. [#511]
- April 19, 2024
- Lîm Tsú-thuàn
若 \(\gamma \) 是由 \(a\) 到 \(b\) 的路徑,則 \([\gamma ][\gamma ]^{-1} = [a]\)
Proof. [#512]
- April 19, 2024
- Lîm Tsú-thuàn
Proof. [#512]
- April 19, 2024
- Lîm Tsú-thuàn
Programming in pcas [math-00AK]
- April 18, 2024
- Lîm Tsú-thuàn
Programming in pcas [math-00AK]
- April 18, 2024
- Lîm Tsú-thuàn
Categorical Realizability
Definition. Term [#513]
- April 18, 2024
- Lîm Tsú-thuàn
Definition. Term [#513]
- April 18, 2024
- Lîm Tsú-thuàn
Fix a countably infinite set of variables, inductively define the set of terms over a pca \(\mathcal {A}\):
- a variable is a term,
- an element of \(\mathcal {A}\) is a term,
- given two terms \(s\) and \(t\), we may form a new term \(s\ t\).
Definition. Defined terms [#514]
- April 18, 2024
- Lîm Tsú-thuàn
Definition. Defined terms [#514]
- April 18, 2024
- Lîm Tsú-thuàn
A closed term is defined if, when we interpret \(s\ t\) as \(s\) applied to \(t\) in \(\mathcal {A}\), all these applications are defined.
Extends to open term \(t\) then is if all possible substitutions of all variables in \(t\) by elements of \(\mathcal {A}\), the obtained closed term is defined.
Definition. "\(\lambda \)-abstraction" in pca [#515]
- April 18, 2024
- Lîm Tsú-thuàn
Definition. "\(\lambda \)-abstraction" in pca [#515]
- April 18, 2024
- Lîm Tsú-thuàn
For a variable \(x\) and a term \(t\), we can define a new term \(\langle x \rangle .\ t\) by recursion on terms:
- \(\langle x \rangle .\ x \doteq I = S\ K\ K\),
- \(\langle x \rangle .\ y \doteq K\ y\) if \(y\) is a variable different from \(x\),
- \(\langle x \rangle .\ a \doteq K\ a\) for \(a \in \mathcal {A}\),
- \(\langle x \rangle .\ (t_1\ t_2) \doteq S(\langle x \rangle .\ t_1)(\langle x \rangle .\ t_2)\).
Notation. [#516]
- April 18, 2024
- Lîm Tsú-thuàn
Notation. [#516]
- April 18, 2024
- Lîm Tsú-thuàn
\(\langle xy \rangle .\ t\) writes for \(\langle x \rangle .\ (\langle y \rangle .\ t)\)
Example. [#517]
- April 18, 2024
- Lîm Tsú-thuàn
Example. [#517]
- April 18, 2024
- Lîm Tsú-thuàn
Now, we can work on it, e.g.
\[ \bold {true} \doteq \langle xy \rangle .\ x \\ \bold {false} \doteq \langle xy \rangle .\ y \\ \bold {if} \doteq \langle x \rangle {x} \]so
\[ \bold {if}\ \bold {true}\ a\ b = a \quad \text {and}\quad \bold {if}\ \bold {false}\ a\ b = a \]Pair and projections are
\[ \bold {pair} \doteq \langle xyz \rangle .\ zxy \\ \bold {fst} \doteq \langle w \rangle .\ w\ \bold {true} \\ \bold {snd} \doteq \langle w \rangle .\ w\ \bold {false} \]
Definition. Scott domain [math-00AJ]
- April 15, 2024
- Lîm Tsú-thuàn
Definition. Scott domain [math-00AJ]
- April 15, 2024
- Lîm Tsú-thuàn
A Scott domain \((X, \mathcal {F})\) is a set \(X\) with an axiomatics \(\mathcal {F}\) made of sequents \(x_1, \dots , x_n \vdash x\) and \(x_1, \dots , x_n \vdash x_i, \dots \) (\(x, x_i \in X\)) consistent with respect to logical consequence.
Definition. Coherent subset [#518]
- April 15, 2024
- Lîm Tsú-thuàn
Definition. Coherent subset [#518]
- April 15, 2024
- Lîm Tsú-thuàn
A coherent subset of \((X,\mathcal {F})\) is a set \(A \subseteq X\) such that
\[ \mathcal {F} \cup \{ \vdash x \mid x \in A \} \]is consistent.
Definition. Saturated [#519]
- April 15, 2024
- Lîm Tsú-thuàn
Definition. Saturated [#519]
- April 15, 2024
- Lîm Tsú-thuàn
A coherent subset is saturated when all \(y\) such that \( \mathcal {F} \cup \{ \vdash x \mid x \in A \} \) proves \(\vdash y\) already belong to \(A\).
Definition. Partial combinatory algebra (pca) [math-00AH]
- April 12, 2024
- Lîm Tsú-thuàn
Definition. Partial combinatory algebra (pca) [math-00AH]
- April 12, 2024
- Lîm Tsú-thuàn
Categorical Realizability
A partial combinatory algebra is a set \(\mathcal {A}\) together with a partial operation \(\mathcal {A} \times \mathcal {A} \to \mathcal {A}\), denoted by juxtaposition, \((a,b)\mapsto a\ b\), such that there exist elements \(K\) and \(S\) satisfying:
- \((K\ a)\ b = a\) for all \(a, b \in \mathcal {A}\)
- \(((S\ f)\ g)\) is defined for all \(f,g \in \mathcal {A}\) and
- \(((S\ f)\ g)\ a \cong (f\ a)(g\ a)\) for all \(f,g,a \in \mathcal {A}\)
\(\cong \) here stands for Kleene equality and means: either both sides are undefined, or both are defined and are equal elements of \(\mathcal {A}\).
Example. Trivial pca [#520]
- April 12, 2024
- Lîm Tsú-thuàn
Example. Trivial pca [#520]
- April 12, 2024
- Lîm Tsú-thuàn
The trivial pca is a set \(\{ \star \}\) with application map \((\star , \star ) \mapsto \star \). For sure, \(K := \star \) and \(S := \star \).
Example. Untyped \(\lambda \)-calculus as pca \(\Lambda \) [#521]
- April 12, 2024
- Lîm Tsú-thuàn
Example. Untyped \(\lambda \)-calculus as pca \(\Lambda \) [#521]
- April 12, 2024
- Lîm Tsú-thuàn
Write \(\Lambda \) for closed terms of untyped lambda calculus quotiented by the equivalence relation generated by \(\beta \)-reduction. With application of lambda calculus the set \(\Lambda \) forms a pca with \(K\) and \(S\) given by the equivalence classes of \(\lambda xy.x\) and \(\lambda xyz.(xz)(yz)\), respectively.
Example. 流形 two-sphere manifold \(S^2\) [math-00AE]
- April 6, 2024
- Lîm Tsú-thuàn
Example. 流形 two-sphere manifold \(S^2\) [math-00AE]
- April 6, 2024
- Lîm Tsú-thuàn
一個球面 \(S^2\) 當然可以用 \(\R ^3\) 的子集合描述
\[ \{ (x,y,z) \mid x^2+y^2+z^2=1 \} \]但這需要一個外部的空間 \(\R ^3\) 來表示它,而微分幾何的目的正是探討如何從內部的觀點來處理一個形狀。從微分幾何出發,表示要尋找一些 chart map \(\phi : S^2 \to \R ^n\),而且我們知道一個 chart map 肯定不能達成目標,因為 \(S^2\) 是 compact space,而 \(\R ^n\) 則並非如此,因此無法找到 \(S^2\) 到 \(\R ^n\) 的 chart map (條件 topological homeomorphism (同胚))。
由於 \(S^2\) 並不複雜,我們很快就能想到如果是兩個不同點出發的投影幾何,就能做出 \(S^2\) 的 atlas。為了計算上的簡便,把 \(S^2\) 想像成地球,並取北極點 \(N = (0,0,1)\) 與南極點 \(S = (0,0,-1)\)。接著,用赤道面作為投射的目標,這個平面由 \(\{ (r,s,0) \mid r,s\in \R \}\) 構成。不同的 \(r,s\) 所定義的點與 \(S\) 之間的直線,會與 \(S^2\) 正好交於一點 \(Q \in S^2\)。此點可以描述為
\[ Q = S + \lambda (P-S) = (0,0,-1) + \lambda (r,s,1) = (\lambda r,\lambda s, \lambda - 1) \]現在重新考慮 \(S^2\) 的 \(\R ^3\) 子集合描述,得到等式
\[ (\lambda r)^2 + (\lambda s)^2 + (\lambda - 1)^2 = 1 \\ \iff \lambda ^2r^2 + \lambda ^2s^2 + \lambda ^2-2\lambda +1 = 1 \\ \iff \lambda ^2(r^2+s^2+1)-2\lambda = 0 \\ \iff \lambda = 0\ \text {or}\ \lambda = \frac {2}{1+r^2+s^2} \]用非平凡解替換 \(Q\) 的公式得
\[ Q = (\frac {2r}{1+r^2+s^2}, \frac {2s}{1+r^2+s^2}, \frac {1-r^2-s^2}{1+r^2+s^2}) \]這個定義等於是 \(\R ^2 \to S^2 \setminus \{ S \}\) 的函數,因為沒有任何 \(r,s \in \R \) 可以令 \(Q\) 是 \(S\)。把前述的函數表示為 \(\phi _S^{-1}\),反過來求 \(\phi _S : S^2 \setminus \{ S \} \to \R ^2\):
\[ (r,s,0) = \lambda (x,y,z) + (1-\lambda )(0,0,-1) \]因此 \(\lambda = \frac {1}{z+1}\),得 \(r=\frac {x}{1+z},s=\frac {y}{1+z}\)。跟 \(\phi _S^{-1}\) 的公式結合,發現這確實是一對 homeomorphism,因此 \(\phi _S : S^2 \setminus \{ S \} \to \R ^2\) 是一個 chart map。
對 \(N\) 做一樣的操作可以得到 \(\phi _N\) 作為另一個 chart map \(r = \frac {-x}{z-1},s=\frac {-y}{z-1}\)。由於在各自的極點外 \(\phi _S\) 與 \(\phi _N\) 皆是同胚映射,因此這時候已經算出了 \(\{ (S^2\setminus \{ S \}, \phi _S), (S^2\setminus \{ N \}, \phi _N) \}\) 足以作為 \(S^2\) 的 altas。
Definition. Deductively closed [math-00A8]
- April 5, 2024
- Lîm Tsú-thuàn
Definition. Deductively closed [math-00A8]
- April 5, 2024
- Lîm Tsú-thuàn
If \(\Gamma \vdash A\), then \(A \in \Gamma \).
Definition. Homotopy relation [math-00AD]
- April 5, 2024
- Lîm Tsú-thuàn
Definition. Homotopy relation [math-00AD]
- April 5, 2024
- Lîm Tsú-thuàn
數學:我思故我在
假設 \(X\) 為一拓樸空間,其中從 \(a\) 點到 \(b\) 點有兩條 path 為 \(\gamma _0, \gamma _1\)。我們稱 \(\gamma _0\) 與 \(\gamma _1\) 在固定端點下同倫 (homotopic with endpoints fixed),記為 \(\gamma _0 \cong \gamma _1\ \text {rel}\{ 0,1 \}\),若存在一個連續函數
\[ F : [0,1] \times [0,1] \to X \\ (s,t) \mapsto F(s,t) \]滿足
- \(F(s, 0) = \gamma _0(s)\)
- \(F(s, 1) = \gamma _1(s)\)
- \(F(0, t) = a\)
- \(F(1, t) = b\)
這時候,說 \(F\) 是 \(\gamma _0\) 與 \(\gamma _1\) 之間的一個同倫 (homotopy)。
Proposition. 同倫是一種等價關係 [#522]
- April 5, 2024
- Lîm Tsú-thuàn
Proposition. 同倫是一種等價關係 [#522]
- April 5, 2024
- Lîm Tsú-thuàn
- 自反性:若 \(\gamma : [a, b]\),取 \(\{ \gamma _t = \gamma \}_{0\le t\le 1}\) 就能構成一個 \(\gamma \) 到 \(\gamma \) 的同倫。
- 交換性:若 \(F(s,t)\) 是從 \(\gamma _0\) 到 \(\gamma _1\) 的同倫,則 \(G(s,t) = F(s,1-t)\) 是一個 \(\gamma _1\) 到 \(\gamma _0\) 的同倫。
- 傳遞性:若 \(F(s,t)\) 是從 \(\gamma _0\) 到 \(\gamma _1\) 的同倫,\(G(s,t)\) 是從 \(\gamma _1\) 到 \(\gamma _2\) 的同倫,則 \[ H(s,t) = \begin {cases} F(s,2t) \quad \text {where } 0\le t \le \frac {1}{2} \\ G(s,2t-1) \quad \text {where } \frac {1}{2} \le t \le 1 \end {cases} \] 是從 \(\gamma _0\) 到 \(\gamma _2\) 的同倫。
Definition. Path-connected (or arcwise connected) [math-00AC]
- April 5, 2024
- Lîm Tsú-thuàn
Definition. Path-connected (or arcwise connected) [math-00AC]
- April 5, 2024
- Lîm Tsú-thuàn
數學:我思故我在
如果對拓樸空間 \(X\) 上的任意兩點 \(a \in X\) 與 \(b \in X\),存在一個連續函數
\[\begin {aligned} \gamma : [0&,1] &\to & &X \\ &t &\mapsto & &\gamma (t) \end {aligned}\]滿足 \(\gamma (0) = a\) 且 \(\gamma (1) = b\),我們稱 \(X\) 為 path-connected。
Proposition. Connected space [#523]
- April 5, 2024
- Lîm Tsú-thuàn
Proposition. Connected space [#523]
- April 5, 2024
- Lîm Tsú-thuàn
如果拓樸空間上任意兩點都有路徑連通,則整個空間是連通的。
Definition. Consistent [math-00A7]
- April 4, 2024
- Lîm Tsú-thuàn
Definition. Consistent [math-00A7]
- April 4, 2024
- Lîm Tsú-thuàn
Mathematical Logic and Computation
A set of propositional formulas is inconsistent if it proves \(\bot \), and consistent otherwise.
Definition. Saturated set of formulas [math-00A6]
- April 4, 2024
- Lîm Tsú-thuàn
Definition. Saturated set of formulas [math-00A6]
- April 4, 2024
- Lîm Tsú-thuàn
Mathematical Logic and Computation
A set of formulas \(\Gamma \) is saturated if the following hold
- \(\Gamma \) is deductively closed
- If \(A \lor B \in \Gamma \), then \(A \in \Gamma \) or \(B \in \Gamma \)
When dealing intuitionistic logic rather than minimal logic, add condition that \(\Gamma \) is consistent.
Forester 如何讓 subtree 預設為隱藏 [forester-000C]
- March 31, 2024
- Lîm Tsú-thuàn
Forester 如何讓 subtree 預設為隱藏 [forester-000C]
- March 31, 2024
- Lîm Tsú-thuàn
這是在郵件列表問到的方法,因為 subtree 也可以被 scope
影響,所以只要寫成下面這樣就可以了
\scope{ \put\transclude/expanded{false} \subtree{ } }
Definition. Fiber bundle [math-007K]
- March 26, 2024
- Lîm Tsú-thuàn
Definition. Fiber bundle [math-007K]
- March 26, 2024
- Lîm Tsú-thuàn
A fiber bundle is a space \(E\) for which the following are given
- a base manifold \(B\)
- a projection \(\pi : E \to B\)
- a typical fiber \(F\)
- a structure group \(G\) of homeomorphisms of \(F\) onto itself
- and a family \(\{ U_j \}\) of open sets covering \(B\)
all of which satisfy the following restrictions
Condition. [#576]
- March 26, 2024
- Lîm Tsú-thuàn
Condition. [#576]
- March 26, 2024
- Lîm Tsú-thuàn
Locally the bundle is trivial, which means that the bundle over any set \(U_j\) which is just \(\pi ^{-1}(U_j)\), has a homeomorphism onto the product space \(U_j \times F\). Part of this homeomorphism is a homeomorphism from each fiber, say \(\pi ^{-1}(x)\) where \(x \in B\), onto \(F\). We define \(h_j(x)\) as
\[ h_j(x) = \pi ^{-1}(x) \]
Condition. [#577]
- March 26, 2024
- Lîm Tsú-thuàn
Condition. [#577]
- March 26, 2024
- Lîm Tsú-thuàn
When two open sets \(U_j\) and \(U_k\) overlap, a given point \(x \in U_j \cap U_k\) has two homeomorphism \(h_j(x)\) and \(h_k(x)\) from its fiber onto \(F\). Since a homeomorphism is invertible, the map \(h_j(x) \circ h_k^{-1}(x)\) is a homeomorphism of \(F\) onto \(F\). This is required to be an element of the structure group \(G\).
Example. [#578]
- March 26, 2024
- Lîm Tsú-thuàn
Example. [#578]
- March 26, 2024
- Lîm Tsú-thuàn
An example is tangent bundle \(TM\), the fibers are the spaces \(T_p\) for each point \(p\).
Example. [#579]
- March 26, 2024
- Lîm Tsú-thuàn
Example. [#579]
- March 26, 2024
- Lîm Tsú-thuàn
Let \(E = TS^1, B = S^1\), typical fiber \(F = \R ^1\), and projection \(\pi = (x, \vec {v}) \mapsto x\), where \(x \in S^1\) and \(\vec {v}\) is a vector in tangent space \(T_x\), \(\vec {v} \in T_x\). The homeomorphism of \(T_x\) onto \(\R \) which are part of the definition of \(TS^1\) are defined to be
\[\begin {aligned} &h_j(x) : T_x \to \R \\ &h_j(x) = \vec {v} \mapsto \alpha _{(j)} \end {aligned}\]If \(x\) is in two neighborhoods \(U_j\) and \(U_k\) there are two such homeomorphims \(T_x \to \R \), and since \(\lambda _j\) and \(\lambda _k\) are unrelated, the \(\alpha _{(j)}\) and \(\alpha _{(k)}\) can be any two nonzero real numbers, the homeomorphim \(h_j(x) \circ h_k^{-1}(x) : F \to F\) is therefore just multiplication by the numbers.
\[ r_{jk} = \alpha _{(j)} / \alpha _{(k)} \]since \(r_{jk}\) is any real number other than zero, the structure group is \(\R ^1 \setminus \{ 0 \}\).
In passing above for an \(n\)-dimensional manifold \(M\), the structure group of \(TM\) is the set of all \(n\times n\) matrices with nonzero determinant, which is called \(\text {GL}(n, \R )\) (general linear groups).
Theorem. Rank-nullity [linear-000D]
- March 24, 2024
- Lîm Tsú-thuàn
Theorem. Rank-nullity [linear-000D]
- March 24, 2024
- Lîm Tsú-thuàn
So called fundamental theorem of linear maps in Linear Algebra Done Right.
Suppose \(V\) is a finite-dimensional vector space and \(T : V \to W\). Then \(\text {range }T \) is finite-dimensional and
\[ \dim V = \dim \text {null}\;T + \dim \text {range}\;T \]or \(\dim V = \text {rank}\;T + \text {nullity}\;T \) by definition that
\[ \text {nullity}\;T = \dim \text {null}\;T \\ \text {rank}\;T = \dim \text {range}\;T \]
Definition. Kripke models [math-00A3]
- March 13, 2024
- Lîm Tsú-thuàn
Definition. Kripke models [math-00A3]
- March 13, 2024
- Lîm Tsú-thuàn
The Blind Spot: Lectures on Logic
A Kripke model is a non-empty partially ordered set \((I, \preceq )\), equipped with a relation \(i \Vdash P\) between elements of \(I\) and propositional atoms. Satisfies
\[ i \Vdash P \land i \preceq j \implies j \Vdash P \]For each \(A\) and each \(i \in I\) we define \(i \Vdash A\):
- \(i \nVdash 0\)
- \(i \Vdash A \land B \iff i \Vdash A \text { and } i \Vdash B\)
- \(i \Vdash A \lor B \iff i \Vdash A \text { or } i \Vdash B\)
- \( i \Vdash A \Rightarrow B \iff \forall j \succeq i, \text {if } j \Vdash A \text { then } j \Vdash B \)
- \( i \Vdash \lnot A \iff \forall j \succeq i, j \nVdash A \)
The elements of \(I\) are called nodes or worlds of the Kripke model.
Definition. Gamma function [math-00A2]
- March 12, 2024
- Lîm Tsú-thuàn
Definition. Gamma function [math-00A2]
- March 12, 2024
- Lîm Tsú-thuàn
Let \(\alpha > 0\)
\[ \Gamma (\alpha ) = \int _0^\infty { e^{-x} x^{\alpha - 1} dx } \]Another way is from The Art of Computer Programming, Vol. 1: Fundamental Algorithms
\[ n! = \Gamma (n+1) = n \Gamma (n) \]and hence
\[ \Gamma (x) = \frac {x!}{x} = \lim _{m\to \infty } \frac {m^x m!}{x(x+1)(x+2)\cdots (x+m)} \]Obviously \(\Gamma (z)\) is not well defined when \(z\) is zero or negative integer, but \(1/\Gamma (z)\) is well defined for all complex \(z\).
\[ \frac {1}{\Gamma (z)} = \frac {1}{2\pi i} \oint \frac {e^t dt}{t^z} \]
Theorem. [#530]
- March 12, 2024
- Lîm Tsú-thuàn
Theorem. [#530]
- March 12, 2024
- Lîm Tsú-thuàn
If \(\alpha > 0\), then \(\int _0^\infty { e^{-x} x^{\alpha - 1} dx }\) converges.
Theorem. [#531]
- March 12, 2024
- Lîm Tsú-thuàn
Theorem. [#531]
- March 12, 2024
- Lîm Tsú-thuàn
If \(\alpha > 1\), then \(\Gamma (\alpha ) = (\alpha -1)\Gamma (\alpha -1)\).
Theorem. [#532]
- March 12, 2024
- Lîm Tsú-thuàn
Theorem. [#532]
- March 12, 2024
- Lîm Tsú-thuàn
- \(\Gamma (1) = 1\)
- \(\Gamma (\frac {1}{2}) = \sqrt {\pi }\)
- For all \(n \in \N \), \(\Gamma (n) = (n-1)!\)
- For any \(n = 2m\), \[ \Gamma (\frac {n}{2}) = \frac {n-2}{2}\frac {n-4}{2} \cdots \frac {2}{2} \Gamma (1) = \frac {(n-2)(n-4)\cdots 4 \cdot 2}{2^{\frac {n}{2}-1}} \]
- For any \(n = 2m+1\), \[ \Gamma (\frac {n}{2}) = \frac {n-2}{2}\frac {n-4}{2} \cdots \frac {1}{2} \Gamma (\frac {1}{2}) = \frac {(n-2)(n-4)\cdots 3 \cdot 1}{2^\frac {n-1}{2}}\sqrt {\pi } \]
Wasmedge 的 cmake options [wasmedge-0002]
- March 12, 2024
- Lîm Tsú-thuàn
Wasmedge 的 cmake options [wasmedge-0002]
- March 12, 2024
- Lîm Tsú-thuàn
-DWASMEDGE_BUILD_TOOLS=ON
-DWASMEDGE_BUILD_TESTS=ON
-DCMAKE_BUILD_TYPE=Debug
-GNinja
基本指令
cmake -Bbuild -GNinja . cmake --build build
Wasmedge 測試 [wasmedge-0003]
Wasmedge 測試 [wasmedge-0003]
執行 ctest
指令,要記得開始 build tests (參考 wasmedge 的 cmake options)。常見選項
ctest -V ctest -R <name> ctest -j
Lemma. Exchange (dcpo) [math-009W]
- March 5, 2024
- Lîm Tsú-thuàn
Lemma. Exchange (dcpo) [math-009W]
- March 5, 2024
- Lîm Tsú-thuàn
Let \(P\) and \(Q\) be directed posets, \(D\) be a cpo, and
\[ f : P \times Q \to D \]be a monotone function. Then
\[ \coprod _{x\in P}\coprod _{y\in Q} f(x,y) = \coprod _{y\in Q}\coprod _{x\in P} f(x,y) \]
Proof. [#536]
- March 5, 2024
- Lîm Tsú-thuàn
Proof. [#536]
- March 5, 2024
- Lîm Tsú-thuàn
For every \(x' \in P\), we have
\[ \coprod _{y \in Q} f(x', y) \sqsubseteq \coprod _{y\in Q}\coprod _{x\in P} f(x,y) \]implies for every \(y' \in Q\), we have
\[ f(x', y') \sqsubseteq \coprod _{y\in Q}\coprod _{x\in P} f(x,y) \]It's easy to do again then have (notice the resolve order)
\[ f(x', y') \sqsubseteq \coprod _{x\in P}\coprod _{y\in Q} f(x,y) \]for any \(x'\in P, y'\in Q\), and hence the equality holds.
Provability relation [math-009X]
- March 5, 2024
- Lîm Tsú-thuàn
Provability relation [math-009X]
- March 5, 2024
- Lîm Tsú-thuàn
Here proves under propositional logic, below three can be carry over to first-order logic.
Proposition. Weakening [math-009Y]
- March 5, 2024
- Lîm Tsú-thuàn
Proposition. Weakening [math-009Y]
- March 5, 2024
- Lîm Tsú-thuàn
If \(\Gamma \vdash A\) and \(\Gamma ' \supseteq \Gamma \) then \(\Gamma ' \vdash A\).
Proof. [#535]
- March 5, 2024
- Lîm Tsú-thuàn
Proof. [#535]
- March 5, 2024
- Lîm Tsú-thuàn
- If \(A \in \Gamma \), then \(A \in \Gamma '\) as well.
- If \(A\) is an axiom, and then it is provable from any context.
- Suppose \(\Gamma \vdash B\) and \(\Gamma \vdash B \to A\) for some \(B\), by induction, so does \(\Gamma '\), and hence \(\Gamma ' \vdash A\).
Proposition. Finite character [math-009Z]
- March 5, 2024
- Lîm Tsú-thuàn
Proposition. Finite character [math-009Z]
- March 5, 2024
- Lîm Tsú-thuàn
If \(\Gamma \vdash A\) then for some finite subset \(\Gamma '\) of \(\Gamma \), \(\Gamma ' \vdash A\).
Proof. [#534]
- March 5, 2024
- Lîm Tsú-thuàn
Proof. [#534]
- March 5, 2024
- Lîm Tsú-thuàn
- If \(A\) is axiom, then \(\Gamma ' = \varnothing \).
- If \(A \in \Gamma \), then \(\Gamma ' = \{ A \}\).
- Inductively, we have two finite subsets \(\Gamma _0 \vdash B \to A\) and \(\Gamma _1 \vdash B\), then \(\Gamma ' = \Gamma _0 \cup \Gamma _1\) still a finite subset of \(\Gamma \), and apply Proposition [math-009Y] (weakening) we have \(\Gamma ' \vdash A\).
Theorem. Deduction [math-00A0]
- March 5, 2024
- Lîm Tsú-thuàn
Theorem. Deduction [math-00A0]
- March 5, 2024
- Lîm Tsú-thuàn
If \(\Gamma \cup \{ A \} \vdash B\) then \(\Gamma \vdash A \to B\).
Proof. [#533]
- March 5, 2024
- Lîm Tsú-thuàn
Proof. [#533]
- March 5, 2024
- Lîm Tsú-thuàn
- If \(B \in \Gamma \) or \(B\) is an axiom, use instance of axiom: \(B \to (A \to B)\), we can prove \(\Gamma \vdash A \to B\).
- If \(B = A\), use \(B \to (B \to B)\), we have \(\Gamma \vdash B \to B\).
- Therefore, the final consideration is, for some formula \(C\), \(\Gamma \cup \{ A \} \vdash C \to B\) and \(\Gamma \cup \{ A \} \vdash C\). By inductive hypothesis, we have \(\Gamma \vdash A \to (C \to B)\) and \(\Gamma \vdash A \to C\). Use instance of axiom 2 \[ \Gamma \vdash (A \to (C \to B)) \to ((A \to C) \to (A \to B))\] then apply MP get \(\Gamma \vdash A \to B\).
矩陣方向 [math-00A1]
- March 5, 2024
- Lîm Tsú-thuàn
矩陣方向 [math-00A1]
- March 5, 2024
- Lîm Tsú-thuàn
Tutorial. A Quick Introduction to Denotational Semantics using Agda [agda-0002]
- March 4, 2024
- Bob Atkey
- https://gist.github.com/bobatkey/52ea69e8ad83b438c5318346200ab4f0
Tutorial. A Quick Introduction to Denotational Semantics using Agda [agda-0002]
- March 4, 2024
- Bob Atkey
- https://gist.github.com/bobatkey/52ea69e8ad83b438c5318346200ab4f0
notes for talk given at TUPLE 2024
This is a very good start point before formalizing languages that more complicated.
Wasmedge plugin 系統 [wasmedge-0001]
- March 4, 2024
- Lîm Tsú-thuàn
Wasmedge plugin 系統 [wasmedge-0001]
- March 4, 2024
- Lîm Tsú-thuàn
要使用 wasmedge plugin,需要設定環境變數讓 wasmedge 知道 plugin 的檔案位置。例如
WASMEDGE_PLUGIN_PATH=~/secondstate/WasmEdge/build/plugins/wasi_http
Theorem. Binomial [math-009U]
- March 3, 2024
- Lîm Tsú-thuàn
Theorem. Binomial [math-009U]
- March 3, 2024
- Lîm Tsú-thuàn
or
\[ (x + y)^n = \sum _{k=0}^n \binom {n}{k} x^k y^{n-k} \]
Definition. Sequent (or judgement) [math-009V]
- March 3, 2024
- Lîm Tsú-thuàn
Definition. Sequent (or judgement) [math-009V]
- March 3, 2024
- Lîm Tsú-thuàn
A context
\[\Gamma = A_1, \dots , A_n\]is a list of propositions. A sequent, or a judgement, is a pair
\[\Gamma \vdash A\]the statement can be read as \(A\) is provable from \(\Gamma \).
Definition. Zero object [math-009R]
- March 3, 2024
- Lîm Tsú-thuàn
Definition. Zero object [math-009R]
- March 3, 2024
- Lîm Tsú-thuàn
A zero object \(0\) is an object which is both initial and terminal.
Definition. Zero morphism [math-009S]
- March 3, 2024
- Lîm Tsú-thuàn
Definition. Zero morphism [math-009S]
- March 3, 2024
- Lîm Tsú-thuàn
In a category with zero object, a morphism \(f : A \to B\) is a zero morphism if it factors through the zero object \(0\).
Collary. [#537]
- March 3, 2024
- Lîm Tsú-thuàn
Collary. [#537]
- March 3, 2024
- Lîm Tsú-thuàn
The zero morphism is unique, this is easy to check by universal property of zero object.
Definition. Kernel and cokernel in the category with zero object [math-009T]
- March 3, 2024
- Lîm Tsú-thuàn
Definition. Kernel and cokernel in the category with zero object [math-009T]
- March 3, 2024
- Lîm Tsú-thuàn
In a category with zero object \(0\), the kernel of an arrow \(f : A \to B\) is the equalizer of \(f\) and the zero morphism \(A \to 0 \to B\). The cokernel of \(f\) is defined dually.
Since kernel is an equalizer, it's a monomorphism (equalizer is monomorphism).
Definition. Bounded complete domain (bc-domain) [math-009O]
- March 2, 2024
- Lîm Tsú-thuàn
Definition. Bounded complete domain (bc-domain) [math-009O]
- March 2, 2024
- Lîm Tsú-thuàn
Semantics of Programming Languages: structures and techniques
A bc-domain is a bounded-complete algebraic cpo.
Theorem. [#539]
- March 2, 2024
- Lîm Tsú-thuàn
Theorem. [#539]
- March 2, 2024
- Lîm Tsú-thuàn
If \(D\) and \(E\) are bc-domains, then so is \([D \to E]\).
Definition. Modules over a ring [math-009M]
- February 26, 2024
- Lîm Tsú-thuàn
Definition. Modules over a ring [math-009M]
- February 26, 2024
- Lîm Tsú-thuàn
Let \(R\) be a ring. The concept of module is the generalization of vector space, but replace fields with rings.
Notation. [#540]
- February 26, 2024
- Lîm Tsú-thuàn
Notation. [#540]
- February 26, 2024
- Lîm Tsú-thuàn
The category of \(R\)-modules denotes \(R\)-Mod.
Definition. Left-\(R\)-module [#541]
- February 26, 2024
- Lîm Tsú-thuàn
Definition. Left-\(R\)-module [#541]
- February 26, 2024
- Lîm Tsú-thuàn
A left-\(R\)-module on an abelian group \(M\) consists of a map \( \cdot : R \times M \to M, (r,m) \mapsto rm \) such that
- \(r \cdot (m + n) = r \cdot m + r \cdot n\)
- \((r+s) \cdot m = r \cdot m + s \cdot m\)
- \((rs) \cdot m = r \cdot (s \cdot m)\)
- \(1 \cdot m = m\)
Definition. Right-\(R\)-module [#542]
- February 26, 2024
- Lîm Tsú-thuàn
Definition. Right-\(R\)-module [#542]
- February 26, 2024
- Lîm Tsú-thuàn
A right-\(R\)-module on an abelian group \(M\) consists of a map \( \cdot : M \times R \to M, (m,r) \mapsto mr \) such that
- \((m + n) \cdot r = m \cdot r + n \cdot r\)
- \(m \cdot (r+s) = m \cdot r + m \cdot s\)
- \(m \cdot (rs) = (m \cdot r) \cdot s\)
- \(m \cdot 1 = m\)
Proposition. Relation with abelian groups [#543]
- February 26, 2024
- Lîm Tsú-thuàn
Proposition. Relation with abelian groups [#543]
- February 26, 2024
- Lîm Tsú-thuàn
The abelian groups are exactly the modules over the ring of integers \(\Z \).
Definition. Kan extension in 2-category [math-009K]
- February 23, 2024
- Lîm Tsú-thuàn
Definition. Kan extension in 2-category [math-009K]
- February 23, 2024
- Lîm Tsú-thuàn
In a 2-category \(\mathcal {C}\), consider two 1-cells \(f : A \to C\) and \(g : A \to B\). The Kan extension of \(f\) along \(g\), when exists, is a pair \((h, \alpha )\) where
- \(h : B \to C\) is a 1-cell and \(\alpha : f \Rightarrow hg\) is a 2-cell.
- given any pair \((k, \beta )\) with \(k : B \to C\) and \(\beta : f \Rightarrow kg\), there exists a unique 2-cell \(\gamma : h \Rightarrow k\) such that \[ (\gamma \circ i_g) \cdot \alpha = \beta \]
Definition. Modification [math-009L]
- February 23, 2024
- Lîm Tsú-thuàn
Definition. Modification [math-009L]
- February 23, 2024
- Lîm Tsú-thuàn
Consider 2-categories \(C, D\), 2-functors \(F, G : C \rightrightarrows D\) and 2-natural-transformations \(\alpha , \beta : F \Rightarrow G\). A modification
\[ \Xi : \alpha \rightsquigarrow \beta \]consists in giving, for every object \(X \in C\), a 2-cell \( \Xi _X : \alpha _X \Rightarrow \beta _X\) is such a way that the following axiom is satisfied: for every pair of morphisms \(f, g : X \rightrightarrows X'\) and every 2-cell \(\alpha : f \Rightarrow g\) in \(C\), the equality
\[ \Xi _{X'} \circ F\alpha = G\alpha \circ \Xi _X\]holds in \(D\).
Definition. The category \(\bold {Ring}\) [math-009J]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. The category \(\bold {Ring}\) [math-009J]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Ring homomorphism [#544]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Ring homomorphism [#544]
- February 20, 2024
- Lîm Tsú-thuàn
A ring homomorphism is a function \(\varphi : R \to S\) such that preserves two operations
- \(\varphi (a + b) = \varphi (a) + \varphi (b)\) for all \(a,b\in R\)
- \(\varphi (a \cdot b) = \varphi (a) \cdot \varphi (b)\) for all \(a,b\in R\)
- and identity \(\varphi (1_R) = 1_S\).
The initial in this category is \((\Z , +, \cdot )\).
Proposition. If \(0=1\) holds, then the ring is a zero-ring [math-009I]
- February 20, 2024
- Lîm Tsú-thuàn
Proposition. If \(0=1\) holds, then the ring is a zero-ring [math-009I]
- February 20, 2024
- Lîm Tsú-thuàn
If \(0=1\) holds in a ring \(R\), then the ring is a zero-ring
Proof. [#545]
- February 20, 2024
- Lîm Tsú-thuàn
Proof. [#545]
- February 20, 2024
- Lîm Tsú-thuàn
For all \(r \in R\) below hold
- \(r \cdot 1 = r\) by definition
- \(r \cdot 0 = r\) by \(0 = 1\)
- \(r = 0\) by \(r \cdot 0 = 0\)
and hence \(R\) is a zero-ring.
Definition. Polynomial (and ring of polynomials over \(R\)) [math-009H]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Polynomial (and ring of polynomials over \(R\)) [math-009H]
- February 20, 2024
- Lîm Tsú-thuàn
Algebra: Chapter 0
Let \(R\) be a ring, a polynomial \(f(x)\) is a finite linear combination of nonnegative powers of \(x\) with coefficients \(a_i\) in \(R\):
\[ f(x) = \sum _{i \ge 0} a_i x^i = a_0 + a_1 x + a_2 x^2 + \cdots \]\(a_i\) are coefficients and \(a_i = 0\) for \(i \gg 0\).
- The set of polynomials with variable \(x\) over \(R\) denotes \(R[x]\).
- The set of polynomials with finitely \(n\)-variables over \(R\) denotes \(R[x_1, x_2, \dots , x_n]\).
- The set of polynomials with variables \(x \in A\) over \(R\) denotes \(R[A]\).
Definition. Equality [#546]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Equality [#546]
- February 20, 2024
- Lîm Tsú-thuàn
Two polynomials are equal if all the coefficients are equal.
Proposition. \(R[x]\) is also a ring [#547]
- February 20, 2024
- Lîm Tsú-thuàn
Proposition. \(R[x]\) is also a ring [#547]
- February 20, 2024
- Lîm Tsú-thuàn
with operations
- \[ f(x) + g(x) = \sum _{i \ge 0} (a_i + b_i) x^i \]
- \[ f(x) \cdot g(x) = \sum _{k \ge 0}\sum _{i+j = k} a_i b_j x^{i + j} \]
Definition. Ring [math-009E]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Ring [math-009E]
- February 20, 2024
- Lîm Tsú-thuàn
Algebra: Chapter 0
A ring \(R\) is an abelian group \((R,+)\) with a multiplication operator \(\cdot \) such that \((R, \cdot )\) is a monoid, and further interacting with \(+\) via distributive properties below
\[ (r + s) \cdot t = r \cdot t + s \cdot t \text { and } t \cdot (r + s) = t \cdot r + t \cdot s \]hold for all \(r,s,t \in R\).
Definition. Ring without identity (or without \(1\)) [#550]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Ring without identity (or without \(1\)) [#550]
- February 20, 2024
- Lîm Tsú-thuàn
Ring without identity means \(\cdot \) has associative, but no identity, and hence \((R, \cdot )\) is not a monoid, but a semigroup in this definition.
Definition. Commutative ring [#551]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Commutative ring [#551]
- February 20, 2024
- Lîm Tsú-thuàn
A ring is commutative if \(r \cdot s = s \cdot r\) for all \(r,s\in R\).
Example. \(\Z / n \Z \) [#552]
- February 20, 2024
- Lîm Tsú-thuàn
Example. \(\Z / n \Z \) [#552]
- February 20, 2024
- Lîm Tsú-thuàn
These groups are also commutative rings by adding \([a]_n \cdot [b]_n = [ab]_n\) as multiplication.
The cancel law cannot generally works in rings, in particular, \[[2]_6 \cdot [4]_6 = [2]_6 \cdot [1]_6\] holds in the commutative ring \(\Z / 6 \Z \), but \([4]_6 \ne [1]_6\).
Definition. Left/right zero divisor [#553]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Left/right zero divisor [#553]
- February 20, 2024
- Lîm Tsú-thuàn
A left zero divisor is an element \(a\) in a ring \(R\) if there exist elements \(b \ne 0\) in \(R\) for which \(ab = 0\).
A right zero divisor \(a \in R\) inherits above, but if \(ba = 0\).
Definition. Left/right unit [math-009G]
- February 20, 2024
- Lîm Tsú-thuàn
Definition. Left/right unit [math-009G]
- February 20, 2024
- Lîm Tsú-thuàn
An element \(u \in R\) of ring \(R\) is
- a left unit if exists \(v \in R\) such that \(uv = 1\);
- a right unit if \(vu = 1\).
An useful interpretion of \(\bold {Bool}\)-profunctor [math-009B]
- February 17, 2024
- Lîm Tsú-thuàn
An useful interpretion of \(\bold {Bool}\)-profunctor [math-009B]
- February 17, 2024
- Lîm Tsú-thuàn
An useful interpretion of a \(\bold {Bool}\)-profunctor \(\varphi : A^{op} \times B \to \bold {Bool}\) is given \(b \in B\) we can do \(a \in A\).
Example. [#557]
- February 17, 2024
- Lîm Tsú-thuàn
Example. [#557]
- February 17, 2024
- Lîm Tsú-thuàn
Let
- \(b\) be "driving a car"
- \(b'\) be "walking"
and suppose \(b' \to b\), means "if one can walk to somewhere, then one can drive to that place". Let \(a\) be "go to school"; if I can walk to school, then \(\varphi (a, b') = true\), by it's a functor \(\varphi (a, b') \to \varphi (a, b)\) exists, which means I can also drive a car to school.
Definition. Connected category [math-009D]
- February 17, 2024
- Lîm Tsú-thuàn
Definition. Connected category [math-009D]
- February 17, 2024
- Lîm Tsú-thuàn
A category \(C\) is connected if it is non-empty and, given any two objects \(X, Y \in C\), there is a finite sequence of zigzag \[X = Z_0, Z_1, Z_2, \dots , Z_{n-1}, Z_n = Y\] together with either a \(Z_{i} \to Z_{i+1}\) or \(Z_{i+1} \to Z_{i}\) where \(0 \le i \lt n\), in the category \(C\).
Remark. [#554]
- February 17, 2024
- Lîm Tsú-thuàn
Remark. [#554]
- February 17, 2024
- Lîm Tsú-thuàn
The direction of arrows in zigzag is not the point, refers to Eric Wofsey's answer.
Definition. Final functor [math-009C]
- February 17, 2024
- Lîm Tsú-thuàn
Definition. Final functor [math-009C]
- February 17, 2024
- Lîm Tsú-thuàn
A functor \(F : C \to D\) is final if for every category \(A\) and functor \(F : D \to A\), we have
- if the limit \((L, (p_d)_{d \in D})\) of \(F\) exists, then \((L, (p_{G(c)})_{c \in C})\) is the limit of \(F \circ G\)
- if the limit of \(F \circ G\) exists, then the limit of \(F\) exists
Proposition. [#555]
- February 17, 2024
- Lîm Tsú-thuàn
Proposition. [#555]
- February 17, 2024
- Lîm Tsú-thuàn
A functor \(G : C \to D\) is final as long as it satisfies
\[\forall d \in D, \exists c \in C, \exists G(c) \xrightarrow {f} d\]and for all black part, the orange part exists and the diagram commutes
Proof. [#556]
- February 17, 2024
- Lîm Tsú-thuàn
Proof. [#556]
- February 17, 2024
- Lîm Tsú-thuàn
Handbook of categorical algebra, volume 1, proposition 2.11.2
Proposition. Example of Hilbert's proof method [math-009A]
- February 16, 2024
- Lîm Tsú-thuàn
Proposition. Example of Hilbert's proof method [math-009A]
- February 16, 2024
- Lîm Tsú-thuàn
Prove that if \(\Gamma \vdash A \to B\) and \(\Gamma \vdash B \to C\) then \(\Gamma \vdash A \to C\).
這完全是朋友教我的,自己試就算了xd
Proof. [#558]
- February 16, 2024
- Lîm Tsú-thuàn
Proof. [#558]
- February 16, 2024
- Lîm Tsú-thuàn
Let \(\Gamma = \{ A \to B, B \to C \}\)
- \((B \to C) \to (A \to (B \to C))\) by axiom \(A \to (B \to A)\)
- \(A \to (B \to C)\) by \(\Gamma \) and MP (modus ponens)
- \({(A \to (B \to C)) \to ((A \to B) \to (A \to C))}\) is an axiom
- \((A \to B) \to (A \to C)\) by 2, 3, and MP
- \(A \to C\) by \(\Gamma \), 4, and MP
Definition. Change-of-base functor (or base change functor) [math-0096]
- February 13, 2024
- Lîm Tsú-thuàn
Definition. Change-of-base functor (or base change functor) [math-0096]
- February 13, 2024
- Lîm Tsú-thuàn
Let \(C\) be a category with pullbacks, for each arrow \(f : A \to B\) there is an induced functor, called base change functor
\[ f^* : C/B \to C/A \]by the pullback along \(f\). The functor is created by for each \(p : K \to B\), there exists pullback \(P\) for \((p, f)\)
Therefore, for each \(p \in C/B\), \(f^*\) is defined as \(p \mapsto p^*\). Consider \(P'\) as another pullback from \(K' \to B\), this induces \(P\) as the pullback of \((P' \to K', K \to K')\).
Collary. [#562]
- February 13, 2024
- Lîm Tsú-thuàn
Collary. [#562]
- February 13, 2024
- Lîm Tsú-thuàn
If \(C\) is finitely complete, then the pullback is the product \(P = A \times K\).
Proposition. Locally cartesian closed iff each base change functor admits a right adjoint [math-0098]
- February 13, 2024
- Lîm Tsú-thuàn
Proposition. Locally cartesian closed iff each base change functor admits a right adjoint [math-0098]
- February 13, 2024
- Lîm Tsú-thuàn
Let \(C\) be a finitely complete category. Then \(C\) is locally cartesian closed if and only if each \(f^* : C/B \to C/A\) from \(f : A \to B\) admits a right adjoint \(\prod _f : C/A \to C/B\).
Proof. [#561]
- February 13, 2024
- Lîm Tsú-thuàn
Proof. [#561]
- February 13, 2024
- Lîm Tsú-thuàn
Suppose \(f^* \dashv \Pi _f\), then
\[ \text {Hom}_{C/A}(f^*(Y), X) \cong \text {Hom}_{C/B}(Y, \Pi _f(X)) \]holds; and \(f^* = K \mapsto A \times K\) by \(C\) with finite limits.
Remember induced by \(f\) is an important condition to ensure some arrows will be there.
Locally cartesian closed iff each base change functor admits a right adjoint › forward [#559]
- February 13, 2024
- Lîm Tsú-thuàn
Locally cartesian closed iff each base change functor admits a right adjoint › forward [#559]
- February 13, 2024
- Lîm Tsú-thuàn
We are trying to prove \[ \text {Hom}_{C/A}(A\times Y, X) \cong \text {Hom}_{C/B}(Y, \Pi _f(X)) \] for all \(A, Y, X \in C\); since slice categories are cartesian closed, picking \(\Pi _f(-) = (-)^A\) in \(C/B\); then doing exponential adjunction, we can prove this is the right adjoint of \(f^*\).
Locally cartesian closed iff each base change functor admits a right adjoint › backward [#560]
- February 13, 2024
- Lîm Tsú-thuàn
Locally cartesian closed iff each base change functor admits a right adjoint › backward [#560]
- February 13, 2024
- Lîm Tsú-thuàn
Apply adjunction condition then cancel \(X\), then we have \[ A \times (-) \cong (-)^A \] this admits exponential functor in \(C/B\) for all \(A, B \in C\), and hence each slice category is cartesian closed.
Definition. Internal category [math-0093]
- February 11, 2024
- Lîm Tsú-thuàn
Definition. Internal category [math-0093]
- February 11, 2024
- Lîm Tsú-thuàn
Let \(C\) be a category with pullbacks, an internal category \(A\) in \(C\) is defined as
- an object \(A_0 \in C\), called the object of objects
- an object \(A_1 \in C\), called the object of arrows
- two morphisms \(s, t : A_1 \to A_0\) in \(C\), called respectively source and target
- an arrow \(i : A_0 \to A_1\) in \(C\), called identity
- an arrow \(c : A_1 \times A_1 \to A_1\) in \(C\), called composition, form a pullback \((A_1\times A_1, \pi _1, \pi _0)\)
These data must satisfy the following axioms:
- \(s \circ i = 1_{A_0} = t \circ i\)
- \(t \circ \pi _1 = t \circ c\) and \(s \circ \pi _0 = s \circ c\)
- \(c \circ (1_{A_1}, i \circ s) = 1_{A_1} = c \circ (i\circ t, 1_{A_1})\)
- \(c \circ (1_{A_1} \times c) = c \circ (c \times 1_{A_1})\)
Definition. Internal functor [math-0094]
- February 11, 2024
- Lîm Tsú-thuàn
Definition. Internal functor [math-0094]
- February 11, 2024
- Lîm Tsú-thuàn
Let \(C\) be a category with pullbacks. Given two internal categories \(C, D\), an internal functor \(F : C \to D\) is a pair of morphisms \((F_0, F_1)\) in \(C\)
\[ F_0 : C_0 \to D_0 \\ F_1 : C_1 \to D_1 \]which satisfies the following conditions
- \(s \circ F_1 = F_0 \circ s\) and \(t \circ F_1 = F_0 \circ t\)
- \(F_1 \circ i = i \circ F_0\)
- \(F_1 \circ c = c \circ (F_1 \times F_1)\)
Definition. Internal natural transformation [math-0095]
- February 13, 2024
- Lîm Tsú-thuàn
Definition. Internal natural transformation [math-0095]
- February 13, 2024
- Lîm Tsú-thuàn
Let \(A, B\) be two internal categories, and internal functors \(F, G : A \to B\), an internal natural transformation \(F \Rightarrow G\) is a morphism \(\alpha : A_0 \to B_1\) such that
- \(s \circ \alpha = F_0\) and \(t \circ \alpha = G_0\)
- \(c \circ (\alpha \circ t, F) = c \circ (G, \alpha \circ s)\)
Proposition. Cauchy completion exists for small categories [math-008X]
- February 10, 2024
- Lîm Tsú-thuàn
Proposition. Cauchy completion exists for small categories [math-008X]
- February 10, 2024
- Lîm Tsú-thuàn
Every small category \(C\) can be embedded as a full subcategory in a Cauchy complete small category \(\overline C\).
- given a functor \({F : C \to D}\) where \(D\) is Cauchy complete, \(F\) extends uniquely (up to isomorphism) as a functor \(\overline F : \overline C \to D\)
- given another functor \(G : C \to D\), its extension \(\overline G : \overline C \to D\) and a natural tranformation \(\alpha : F \Rightarrow G\), \(\alpha \) extends uniquely to a natural transformation \(\overline \alpha : \overline F \Rightarrow \overline G\)
- the inclusion \(C \to \overline {C}\) is an equivalence of categories iff, on \(C\), every retract of a representable functor is itself a representable.
Definition. Adjunction [math-0091]
- February 10, 2024
- Lîm Tsú-thuàn
Definition. Adjunction [math-0091]
- February 10, 2024
- Lîm Tsú-thuàn
The following statements are equivalent:
- \(G\) is a left adjoint to \(F\)
- there exist natural transformation \(\eta : 1_D \Rightarrow F \circ G\) and \(\epsilon : G \circ F \Rightarrow 1_C\) such that \[ (F * \epsilon ) \circ (\eta * F) = 1_F \ \text {and}\; (\epsilon * G) \circ (G * \eta ) = 1_G \]
- there exist bijections \[ \theta _{AB} : \text {Hom}_{C}(G(B), A) \cong \text {Hom}_{D}(B, F(A)) \] for every object \(A \in C\) and \(B \in D\) and bijections are natural both in \(A\) and \(B\)
- \(F\) is a right adjoint to \(G\)
Definition. Reflection of object [math-0090]
- February 10, 2024
- Lîm Tsú-thuàn
Definition. Reflection of object [math-0090]
- February 10, 2024
- Lîm Tsú-thuàn
Let \(F : C \to D\) be a functor and \(B \in D\). A reflection of \(B\) along \(F\) is a pair \((R_B \in C, \eta _B)\) where
- \(\eta _B : B \to F(R_B)\) is a morphism in \(D\)
- if \(A \in C\) and \(f : B \to F(A)\) is a morphism in \(D\), there exists a unique morphism \(g : R_B \to A\) such that \(f = F(g) \circ \eta _B\)
Definition. Solution set condition [math-008Z]
- February 10, 2024
- Lîm Tsú-thuàn
Definition. Solution set condition [math-008Z]
- February 10, 2024
- Lîm Tsú-thuàn
A fucntor \(F : C \to D\) satisfies the solution set condition with respect to an object \(B \in D\) when there exists a set \(S_B \subseteq |A|\) of objects such that
\[ \begin {aligned} &\forall A \in C, \\ &\forall g : B \to F(A), \\ &\exists S \in S_B, \exists f : S \to A, \\ &\exists h : B \to F(S), \\ &g = F(f) \circ h \end {aligned} \]The set \(S_B\) called a solution set.
Definition. Lax functor [math-001B]
- February 9, 2024
- Lîm Tsú-thuàn
Definition. Lax functor [math-001B]
- February 9, 2024
- Lîm Tsú-thuàn
A Lax functor \(F : A \to B\) between 2-categories \(A, B\) consists
- for each 0-cell \(X \in A\), \(F(A) \in B\)
- for each pair of 0-cells \(X, Y \in A\), a functor \[ F_{XY} : A(X,Y) \to B(F(X),F(Y)) \]
- for each triple of 0-cells \(X, Y, Z \in A\), a natural transformation \(\gamma _{XYZ}\) \[ \gamma _{XYZ} : c_{F(X),F(Y),F(Z)} \circ (F_{XY} \times F_{YZ}) \Rightarrow F_{XY} \circ c_{XYZ} \]
- for each \(X \in A\), a natural transformation \(\delta _X : u_{F(X)} \Rightarrow F_{XX} \circ u_X\)
Axiom. Composition [#651]
- February 9, 2024
- Lîm Tsú-thuàn
Axiom. Composition [#651]
- February 9, 2024
- Lîm Tsú-thuàn
For every triple of 1-cells \(X \xrightarrow {f} Y \xrightarrow {g} Z\) in \(A\), the following equality between 2-cells holds
Axiom. Unit [#652]
- February 9, 2024
- Lîm Tsú-thuàn
Axiom. Unit [#652]
- February 9, 2024
- Lîm Tsú-thuàn
For every 1-cell \(f : X \to Y\) in \(A\), the following equality holds
Definition. Pseudo functor [math-008V]
- February 9, 2024
- Lîm Tsú-thuàn
Definition. Pseudo functor [math-008V]
- February 9, 2024
- Lîm Tsú-thuàn
When \(\gamma _{XYZ}\) and \(\delta _X\) are natural isomorphisms, then a Lax functor \(F\) is called a pseudo-functor.
Definition. Cauchy complete category [math-008U]
- February 8, 2024
- Lîm Tsú-thuàn
Definition. Cauchy complete category [math-008U]
- February 8, 2024
- Lîm Tsú-thuàn
A category \(C\) is Cauchy complete if all idempotents \(e\) of \(C\) split, which mean, form a retraction \(e = i \circ r\).
Proposition. Cauchy completion exists for small categories [math-008X]
- February 10, 2024
- Lîm Tsú-thuàn
Proposition. Cauchy completion exists for small categories [math-008X]
- February 10, 2024
- Lîm Tsú-thuàn
Every small category \(C\) can be embedded as a full subcategory in a Cauchy complete small category \(\overline C\).
- given a functor \({F : C \to D}\) where \(D\) is Cauchy complete, \(F\) extends uniquely (up to isomorphism) as a functor \(\overline F : \overline C \to D\)
- given another functor \(G : C \to D\), its extension \(\overline G : \overline C \to D\) and a natural tranformation \(\alpha : F \Rightarrow G\), \(\alpha \) extends uniquely to a natural transformation \(\overline \alpha : \overline F \Rightarrow \overline G\)
- the inclusion \(C \to \overline {C}\) is an equivalence of categories iff, on \(C\), every retract of a representable functor is itself a representable.
Theorem. [math-008W]
- February 10, 2024
- Lîm Tsú-thuàn
Theorem. [math-008W]
- February 10, 2024
- Lîm Tsú-thuàn
Let \(A, B\) be two small categories, the following conditions are equivalent
- the categories \([A^{op}, Set]\) and \([B^{op}, Set]\) are equivalent
- \(A\) and \(B\) have the same Cauchy completion
Theorem. General adjoint functor [math-008Y]
- February 10, 2024
- Lîm Tsú-thuàn
Theorem. General adjoint functor [math-008Y]
- February 10, 2024
- Lîm Tsú-thuàn
Let \(F : A \to B\) be a functor, where \(A\) is Cauchy complete, the following conditions are equivalent
- \(F\) has a left adjoint
- \(F\) is absolutely flat and satisfies the solution set condition for each \(X \in C\)
Definition. Kan extension [math-008R]
- February 8, 2024
- Lîm Tsú-thuàn
Definition. Kan extension [math-008R]
- February 8, 2024
- Lîm Tsú-thuàn
Let \(F : A \to B\) and \(G : A \to C\) be functors. The left Kan extension of \(G\) along \(F\), if exists, is a pair \(\text {Lan}_F G = (K, \alpha )\)
where \(K : B \to C\) is a functor and \(\alpha : G \Rightarrow K \circ F\) is a natural transformation. If there exists another pair \((H, \beta )\), then there is a natural transformation \(\gamma : K \Rightarrow H\) satisfying \[\beta = (\gamma * F) \circ \alpha \]
Definition. Filtered and cofiltered category [math-008O]
- February 8, 2024
- Lîm Tsú-thuàn
Definition. Filtered and cofiltered category [math-008O]
- February 8, 2024
- Lîm Tsú-thuàn
A category \(C\) is filtered if for every finite diagram in it, there exists a cocone, and for every two parallel arrows in it \(u, v : A \to B\), there exists \(w : B \to C\) such that \(w \circ u = w \circ v\).
A category \(C\) is cofiltered if \(C^{op}\) is filtered. In the other words, for every finite diagram in it, there exists a cone, and for every two parallel arrows in it \(u, v : B \to C\), there exists \(w : A \to B\) such that \(u \circ w = v \circ w\).
Definition. Filtered colimit [math-008S]
- February 8, 2024
- Lîm Tsú-thuàn
Definition. Filtered colimit [math-008S]
- February 8, 2024
- Lîm Tsú-thuàn
A filtered colimit is a colimit of a functor \(F : D \to C\) where \(D\) is a filtered category.
Definition. Flat functor [math-008N]
- February 8, 2024
- Lîm Tsú-thuàn
Definition. Flat functor [math-008N]
- February 8, 2024
- Lîm Tsú-thuàn
A functor \(F : \mathcal {C} \to \bold {Set}\) is flat if the category \(\text {Elts(F)}\) is cofiltered. A functor \(F : \mathcal {C} \to \mathcal {D}\) is flat if for each \(A : \mathcal {D}\) the functor \(\text {Hom}_{\mathcal {D}}(A, F(-)) : \mathcal {C} \to \bold {Set}\) is flat.
Collary. Closed on composition [#565]
- February 8, 2024
- Lîm Tsú-thuàn
Collary. Closed on composition [#565]
- February 8, 2024
- Lîm Tsú-thuàn
Which means compose two flat functors will get a flat functor.
Proposition. Hom functor is flat [math-008P]
- February 8, 2024
- Lîm Tsú-thuàn
Proposition. Hom functor is flat [math-008P]
- February 8, 2024
- Lîm Tsú-thuàn
Let \(\text {Hom}_{C}(X, -)\) be a hom functor of \(X \in C\), the functor is flat.
Proof. [#564]
- February 8, 2024
- Lîm Tsú-thuàn
Proof. [#564]
- February 8, 2024
- Lîm Tsú-thuàn
The category of elements \(\text {Elts}(\text {Hom}_{C}(X, -))\) has an object \((X, 1_X)\). Consider any \((X, 1_X) \to (Y, f)\), it will be an arrow \(g : X \to Y\) such that \(f = g \circ 1_X\), and hence \((X,1_X)\) is an initial object, serve as a cone for any diagram.
Proposition. Functor with a left adjoint is flat [math-008Q]
- February 8, 2024
- Lîm Tsú-thuàn
Proposition. Functor with a left adjoint is flat [math-008Q]
- February 8, 2024
- Lîm Tsú-thuàn
If functor \(F : A \to B\) with a left adjoint, then \(F\) is flat.
Proof. [#563]
- February 8, 2024
- Lîm Tsú-thuàn
Proof. [#563]
- February 8, 2024
- Lîm Tsú-thuàn
The target is prove \(\text {Hom}_{B}(X, F(-))\) is flat. Let \(G : B \to A\) be a left adjoint, then
\[ \text {Hom}_{B}(X, F(-)) \cong \text {Hom}_{A}(G(X), -) \]follows Proposition [math-008P] we have \(\text {Hom}_{A}(G(X), -)\) is flat, and hence \(\text {Hom}_{B}(X, F(-))\) is flat.
Definition. Absolutely flat [math-0092]
- February 11, 2024
- Lîm Tsú-thuàn
Definition. Absolutely flat [math-0092]
- February 11, 2024
- Lîm Tsú-thuàn
A functor \(F : A \to B\) is absolutely flat if it is \(\alpha \)-flat for every regular cardinal \(\alpha \).
Definition. Idempotent morphism [math-008T]
- February 8, 2024
- Lîm Tsú-thuàn
Definition. Idempotent morphism [math-008T]
- February 8, 2024
- Lîm Tsú-thuàn
A morphism \(e : A \to A\) is idempotent if \(e \circ e = e\).
Definition. \(\text {Elts(F)}\) category [math-001R]
- February 7, 2024
- Lîm Tsú-thuàn
Definition. \(\text {Elts(F)}\) category [math-001R]
- February 7, 2024
- Lîm Tsú-thuàn
Let \(F : \mathcal {C} \to \bold {Set}\) be a functor, the category \(\text {Elts(F)}\) of elements of \(F\) is defined as
- \((A, a) \in \text {Elts(F)}\) where \(A \in \mathcal {C}\) and \(a \in F(A)\)
- \((A, a) \to (B, b)\) is an arrow \(A \xrightarrow {f} B\) in \(\mathcal {C}\) where \(F(f)(a) = b\)
- compositions in \(\text {Elts(F)}\) are induced by compositions in \(\mathcal {C}\)
Definition. Left exact functor [math-008K]
- February 7, 2024
- Lîm Tsú-thuàn
Definition. Left exact functor [math-008K]
- February 7, 2024
- Lîm Tsú-thuàn
Let \(A, B\) be two finitely complete categories, a functor \(F : A \to B\) is left exact if it preserves finite limits.
Collary. Closed on composition [#568]
- February 7, 2024
- Lîm Tsú-thuàn
Collary. Closed on composition [#568]
- February 7, 2024
- Lîm Tsú-thuàn
Which means compose two left exact functors will get a left exact functor.
Definition. \(\text {Lex}(A, \bold {Set})\) category [#569]
- February 7, 2024
- Lîm Tsú-thuàn
Definition. \(\text {Lex}(A, \bold {Set})\) category [#569]
- February 7, 2024
- Lîm Tsú-thuàn
The category \(\text {Lex}(A, \bold {Set})\) is a full subcategory of the functor category \([A, \bold {Set}]\), where have only left exact functors.
Calculus of fractions [math-008I]
- February 6, 2024
- Lîm Tsú-thuàn
Calculus of fractions [math-008I]
- February 6, 2024
- Lîm Tsú-thuàn
Definition. Right calculus of fractions [math-008A]
- February 5, 2024
- Lîm Tsú-thuàn
Definition. Right calculus of fractions [math-008A]
- February 5, 2024
- Lîm Tsú-thuàn
Let \(\mathbb {C}\) be a category, and \(\Sigma \) is a class of morphisms. The class \(\Sigma \) admits a right calculus of fractions when the following conditions hold:
- \(1_x \in \Sigma \) for all \(x \in \mathbb {C}\)
- given \(x \xrightarrow {s} y \in \Sigma \) and \(y \xrightarrow {t} z \in \Sigma \), then \(t \circ s \in \Sigma \) (closed under composition)
- if there has \(s \in \Sigma \) and \(f \in \mathbb {C}\), then there exists \(t \in \Sigma \) and \(g \in \mathbb {C}\) makes the diagram commutes
- if there has \(s \in \Sigma \) with \(s \circ f = s \circ g\); then there exists \(t \in \Sigma \) makes \(f \circ t = g \circ t\)
Definition. Left calculus of fractions [math-008G]
- February 6, 2024
- Lîm Tsú-thuàn
Definition. Left calculus of fractions [math-008G]
- February 6, 2024
- Lîm Tsú-thuàn
If \((C^{op}, \Sigma ^{op})\) admits right calculus of fractions (Definition [math-008A]), then \((C, \Sigma )\) admits left calculus of fractions.
Proposition. [math-008H]
- February 6, 2024
- Lîm Tsú-thuàn
Proposition. [math-008H]
- February 6, 2024
- Lîm Tsú-thuàn
Let \(B\) be a category and a reflective subcategory \(A \xrightarrow {i} B\), with reflection \(r \dashv i\). Write \(\Sigma \) for the class of all \(B\)-morphisms \(f\) such that \(r(f)\) is an isomorphism. The category of fractions exists and is equivalent to \(B \xrightarrow {r} A\). Then the class \(\Sigma \) admits a left calculus of fractions.
Definition. Category of fractions (localization) [math-0089]
- February 5, 2024
- Lîm Tsú-thuàn
Definition. Category of fractions (localization) [math-0089]
- February 5, 2024
- Lîm Tsú-thuàn
Consider a category \(C\) and a class of \(C\)-arrows \(\Sigma \). The category of fractions \(C[\Sigma ^{-1}]\) is said to exist if there exists a functor
\[ \varphi : C \to C[\Sigma ^{-1}] \]with properties
- \(\varphi (f)\) is an isomorphism for all \(f \in \Sigma \)
- if there is a functor \(F : C \to D\) such that \(F(f)\) is an isomorphism for all \(f \in \Sigma \), there exists a unique functor \(G : C[\Sigma ^{-1}] \to D\) such that \(F = G \circ \varphi \)
Proposition. Category of fractions with right calculus [math-008J]
- February 6, 2024
- Lîm Tsú-thuàn
Proposition. Category of fractions with right calculus [math-008J]
- February 6, 2024
- Lîm Tsú-thuàn
When \((\mathcal {C}, \Sigma )\) admits right calculus of fractions, the category of fractions Definition [math-0089] \(\mathcal {C}[\Sigma ^{-1}]\) can be said in a simpler way:
- The objects of are same objects in \(\mathcal {C}\)
- A morphism \(f : A \to B\) in \(\mathcal {C}[\Sigma ^{-1}]\) is an equivalence class of triples \((s, I, f)\) where \(s \in \Sigma \) and \(f \in \mathcal {C}\) if another triple \((s, I, f)\) is equivalent to \((t, J, g)\) when there exist \(x : X \to I\) and \(y : X \to J\) such that \(s \circ x = t \circ y \in \Sigma \) and \(f \circ x = g \circ y\).
Each composition of the equivalence classes \[ [(s,I,f) : A \to B], [(t,J,g) : B \to C] \] in \(\mathcal {C}[\Sigma ^{-1}]\) is \( [(s \circ r, K, g \circ h)] : A \to C \) where \(r \in \Sigma \) and \(h \in \mathcal {C}\) are any morphisms such that \(f \circ r = t \circ h\)
Proposition. Category of fractions preserves finite limits [math-008B]
- February 5, 2024
- Lîm Tsú-thuàn
Proposition. Category of fractions preserves finite limits [math-008B]
- February 5, 2024
- Lîm Tsú-thuàn
If \(C\) is finitely complete and \(\Sigma \) admits a right calculus of fractions and the category of fractions Definition [math-0089] \(C[\Sigma ^{-1}]\) exists, then \(C[\Sigma ^{-1}]\) and the canonical functor \(\varphi : C \to C[\Sigma ^{-1}]\) preserves finite limits.
Definition. Saturated [math-008C]
- February 5, 2024
- Lîm Tsú-thuàn
Definition. Saturated [math-008C]
- February 5, 2024
- Lîm Tsú-thuàn
Let \(C\) be a category and \(\Sigma \) is a class of morphisms where \(\varphi : C \to C[\Sigma ^{-1}]\) exists. Then \(\Sigma \) is saturated if \(\varphi (f)\) is an isomorphism iff \(f \in \Sigma \).
Definition. Factorization system [math-008D]
- February 5, 2024
- Lîm Tsú-thuàn
Definition. Factorization system [math-008D]
- February 5, 2024
- Lîm Tsú-thuàn
A factorization system on a category \(C\) is a pair of classes of morphisms \((\mathcal {E},\mathcal {M})\), such that
- every isomorphism belongs to both \(\mathcal {E}\) and \(\mathcal {M}\)
- both \(\mathcal {E}\) and \(\mathcal {M}\) are closed under composition
- \(e\ \bot \ m\) holds orthogonal relation for all \(e \in \mathcal {E}\) and \(m \in \mathcal {M}\)
- every morphism \(f \in C\) can be factored as \(f = m \circ e\) where \(e \in \mathcal {E}\) and \(m \in \mathcal {M}\)
Definition. Orthogonal relation [math-008E]
- February 5, 2024
- Lîm Tsú-thuàn
Definition. Orthogonal relation [math-008E]
- February 5, 2024
- Lîm Tsú-thuàn
Two arrows \(A \xrightarrow {f} B\) and \(C \xrightarrow {g} D\) in a category \(C\), \(f\) is orthogonal to \(g\) and denoted \(f\ \bot \ g\), if given arbitrary morphisms \(u, v\) such that \( v \circ f = g \circ u \) then there exists a unique morphism \(w\) such that \(w \circ f = u\) and \(g \circ w = v\), as commute diagram
Basic block [cs-001B]
- February 4, 2024
- Lîm Tsú-thuàn
Basic block [cs-001B]
- February 4, 2024
- Lîm Tsú-thuàn
A basic block is a linear sequence of instructions such that, one can only run this sequence from the entry instruction, and will only exit when reach the final instruction. Compiler will decompose the program into several basic blocks when do analysis.
Definition. Generators (category theory) [math-0084]
- February 3, 2024
- Lîm Tsú-thuàn
Definition. Generators (category theory) [math-0084]
- February 3, 2024
- Lîm Tsú-thuàn
A family \((G_i)_{i\in I}\) of objects of \(\mathcal {C}\) is a family of generators if, given any two parallel morphisms \[u, v : A \to B\] in \(\mathcal {C}\), \[ \forall i\in I. \forall G_i \xrightarrow {g} A. u \circ g = v \circ g \implies u = v \] when a family has only one object, the object \(G\) is called a generator.
Proposition. Hom-functor of a generator is faithful [math-0085]
- February 3, 2024
- Lîm Tsú-thuàn
Proposition. Hom-functor of a generator is faithful [math-0085]
- February 3, 2024
- Lîm Tsú-thuàn
of a generator \(G \in \mathcal {C}\) is faithful.
Proposition. [math-0087]
- February 3, 2024
- Lîm Tsú-thuàn
Proposition. [math-0087]
- February 3, 2024
- Lîm Tsú-thuàn
In a category with coproducts, and family of generators \((G_i)_{i\in I}\), then there is a unique morphism from coproduct of \((G_i)\) to each \(C\) forms
\[ \coprod _{i\in I}G_i \xrightarrow {\gamma _C} C \]each \(f\) can be factor as \(f = \gamma _C \circ f'\) is an epimorphism.
Definition. Strong/regular family of generators [math-0086]
- February 3, 2024
- Lîm Tsú-thuàn
Definition. Strong/regular family of generators [math-0086]
- February 3, 2024
- Lîm Tsú-thuàn
Follows Proposition [math-0087], if each epimorphism \(\gamma _C\) is strong/regular than \((G_i)_{i\in I}\) is a strong/regular family.
Definition. Dense family of generators [math-0088]
- February 3, 2024
- Lîm Tsú-thuàn
Definition. Dense family of generators [math-0088]
- February 3, 2024
- Lîm Tsú-thuàn
Let \(\mathcal {G}\) be a full subcategory generated by family \((G_i)_{i\in I}\), and \(\mathcal {G} / X\) for full subcategory of \(\mathcal {C} / X\) collecting \(f : G_i \to X\).
Expand the definition of \(\mathcal {G} / X\), it's saying that if \(G_i \to X\) is there, than \(G_i \in \mathcal {G} / X\), of course will be a subcategory, since \(\mathcal {G} / X \subseteq \mathcal {C} / X\) by \(\mathcal {C}\) potentially have more \(Y \to X\).
Then family \((G_i)\) is a dense family if for each object \(X \in \mathcal {C}\), the colimit of the functor \[ \begin {aligned} &\Gamma ^X : &\mathcal {G} / X &\to &\mathcal {C} \\ &\Gamma ^X = &G_i \xrightarrow {f} X &\mapsto &G_i \end {aligned} \] is \((X, (f)_{f\in \mathcal {G} / X})\).
Lemma. Yoneda [math-0080]
- February 2, 2024
- Lîm Tsú-thuàn
Lemma. Yoneda [math-0080]
- February 2, 2024
- Lîm Tsú-thuàn
Let \(C\) be a category, \(F : C \to \bold {Set}\) is a set-valued functor. There is a bijection between \(F(A)\) and all natural transformations from \(\text {Hom}_{C}(A, -)\) to \(F\), which means
\[ [C,\bold {Set}] (\text {Hom}_{C}(A, -), F) \cong F(A) \]
Proof. [#570]
- February 2, 2024
- Lîm Tsú-thuàn
Proof. [#570]
- February 2, 2024
- Lîm Tsú-thuàn
Proposition. Triangles amount of \(n\)-vertex graph with \(\lfloor {n^2/4}\rfloor +1\) edges [math-007Y]
- January 29, 2024
- Lîm Tsú-thuàn
Proposition. Triangles amount of \(n\)-vertex graph with \(\lfloor {n^2/4}\rfloor +1\) edges [math-007Y]
- January 29, 2024
- Lîm Tsú-thuàn
Every \(n\)-vertex graph with at least \(\lfloor n^2/4 \rfloor + 1\) edges contains at least \(\lfloor n/2 \rfloor \) triangles.
Proof. [#571]
- January 29, 2024
- Lîm Tsú-thuàn
Proof. [#571]
- January 29, 2024
- Lîm Tsú-thuàn
A \(n\)-vertex graph \(G\) with \(\lfloor n^2/4 \rfloor \) edges is isomorphic to \(K_{\lfloor n/2 \rfloor ,\lceil n/2 \rceil }\). Insert a new edge on bipartite graph can only connect two vertices of the same part, will create \(\lfloor n/2 \rfloor \) triangles. Therefore, at least \(\lfloor n/2 \rfloor \) triangles will be there for edges \(\lfloor n^2/4 \rfloor +1\).
Definition. Frobenius monoid [math-007T]
- January 27, 2024
- Lîm Tsú-thuàn
Definition. Frobenius monoid [math-007T]
- January 27, 2024
- Lîm Tsú-thuàn
Let \(X\) be an object in a symmetric monoidal category \((\mathcal {C}, \otimes , I)\). A Frobenius structure on \(X\) consists of a 4-tuple \((\mu ,\eta ,\delta ,\epsilon )\) such that \((X, \mu ,\eta )\) is a commutative monoid and \((X,\delta ,\epsilon )\) is a cocommutative comonoid, which satisfies the six equations above ((co)associativity, (co)unitality, (co)commutativity), as well as the following equations:
and
An object \(X\) equipped with a Frobenius structure is a Frobenius monoid.
Theorem. Mantel's [math-007S]
- January 26, 2024
- Lîm Tsú-thuàn
Theorem. Mantel's [math-007S]
- January 26, 2024
- Lîm Tsú-thuàn
Graph Theory and Additive Combinatorics: Exploring Structure and Randomness
Every \(n\)-vertex triangle-free graph has at most \(\lfloor n^2/4 \rfloor \) edges.
Proof. [#573]
- January 26, 2024
- Lîm Tsú-thuàn
Proof. [#573]
- January 26, 2024
- Lîm Tsú-thuàn
Proposition. 群的運算表中每行每列每個元素都正好出現一次 [alg-0001]
- January 26, 2024
- Lîm Tsú-thuàn
Proposition. 群的運算表中每行每列每個元素都正好出現一次 [alg-0001]
- January 26, 2024
- Lîm Tsú-thuàn
運算表是群 \(G\) 的函數 \(G \times G \to G\),把 \(g,h\in G\) 映到 \(gh\)
Proof. [#676]
- January 26, 2024
- Lîm Tsú-thuàn
Proof. [#676]
- January 26, 2024
- Lîm Tsú-thuàn
首先是唯一性的證明,假設 \(g\) 列有重複的結果 \(h\),這表示存在 \(ga = gb = h\),但我們總是可以取消 \(g\) 所以這表示 \(a = b\),這跟前提 \(a \ne b\) 矛盾,故 \(h\) 是唯一的;行是同樣的證明。
接著要能證明每個元素都有出現過。
- \(e\) 行列上每個元素都出現正好一次
- 為了跟 \(e\) 行列一一對應並且不違反唯一性,事實上只能選擇全部元素的排列,而再下一次選擇也只能選還沒出現過的排列
Definition. Grothendieck universe [math-007L]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Grothendieck universe [math-007L]
- January 20, 2024
- Lîm Tsú-thuàn
A Grothendieck universe \(\mathcal {U}\) is a set such that
- If \(x \in \mathcal {U}\) and \(y \in x\), then \(y \in \mathcal {U}\).
- If \(x \in \mathcal {U}\), then its power set \(\mathcal {P(x) \in \mathcal {U}}\).
- If \(I \in \mathcal {U}\) and \(x_i \in \mathcal {U}\) for each \(i \in I\), then the union \(\bigcup _{i\in I}x_i \in \mathcal {U}\).
- The set of finite ordinals \(\N \in \mathcal {U}\).
Definition. Jacobian matrix [math-007N]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Jacobian matrix [math-007N]
- January 20, 2024
- Lîm Tsú-thuàn
For a function \(f : \R ^n \to \R ^m\), maps \(x \in \R ^n\) to \(f(x) \in \R ^m\), the Jacobian matrix is a \(m\times n\) matrix, defined as
\[ J = \begin {bmatrix} \frac {\partial f}{\partial x_1} & \cdots & \frac {\partial f}{\partial x_n} \end {bmatrix} = \begin {bmatrix} \frac {\partial f_1}{\partial x_1} & \cdots & \frac {\partial f_1}{\partial x_n} \\ \vdots & \ddots & \vdots \\ \frac {\partial f_m}{\partial x_1} & \cdots & \frac {\partial f_m}{\partial x_n} \end {bmatrix} \]or we can say \(J_{ij} = \frac {\partial f_i}{\partial x_j}\).
Axiom. Axiom of universe [math-007M]
- January 20, 2024
- Lîm Tsú-thuàn
Axiom. Axiom of universe [math-007M]
- January 20, 2024
- Lîm Tsú-thuàn
Every set belongs to some universe.
Definition. Multilinear function [linear-0007]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Multilinear function [linear-0007]
- January 20, 2024
- Lîm Tsú-thuàn
A function \(f : V^k \to \R \) is \(k\)-linear if it's linear in each of its \(k\) arguments:
\[ f(\dots , av+bw, \dots ) = af(\dots , v, \dots ) + bf(\dots , w, \dots ) \]for all \(a,b\in \R \) and \(v,w\in V\). \(V\) is a vector space, and \(V^k\) is cartesian product space.
Definition. Tensor product of k-linear functions [linear-0008]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Tensor product of k-linear functions [linear-0008]
- January 20, 2024
- Lîm Tsú-thuàn
Let \(f\) be a \(k\)-linear function and \(g\) be a \(l\)-linear function on a vector space \(V\), their tensor product is the \((k+l)\)-linear function \(f \otimes g\) defined as
\[ f\otimes g(v_1, \dots , v_{k+l}) = f(v_1, \dots , v_k) g(v_{k+1}, \dots , v_{k+l}) \]The \(k,l\) are indicies.
Definition. Natural transformation and isomorphism [math-007R]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Natural transformation and isomorphism [math-007R]
- January 20, 2024
- Lîm Tsú-thuàn
Let \(C\) and \(D\) be categories, and let \(F, G : C \to D\) be functors. A natural transformation \(\alpha : F \Rightarrow G\) is a function that
- for each object \(c \in C\), a morphism \(\alpha _c : F(c) \to G(c)\) in \(D\), called the \(c\)-component of \(\alpha \);
- for every morphism \(f : c \to d\) in \(C\), below equation hold \[\alpha _d \circ F(f) = G(f) \circ \alpha _c\] This is the naturality condition. The naturality condition can also be written as a commutative diagram:
A natural transformation is called a natural isomorphism if each component \(\alpha _c\) is an isomorphism in \(D\).
Definition. Metric space [math-007A]
- January 16, 2024
- Lîm Tsú-thuàn
Definition. Metric space [math-007A]
- January 16, 2024
- Lîm Tsú-thuàn
Introduction to Topology
A metric space \((X, d)\) consists of:
- a set \(X\), its elements are called points;
- a function \(d : X \times X \to \R _{\ge 0}\), where \(d(x,y)\) is called the distance between \(x\) and \(y\).
These satisfy the following properties:
- \(d(x,x) = 0\) for all \(x \in X\);
- if \(d(x,y) = 0\) then \(x = y\);
- \(d(x,y) = d(y,x)\) for all \(x,y \in X\);
- \(d(x,y) + d(y,z) \ge d(x,z)\) for all \(x,y,z\in X\).
A metric space is extened if \(d : X \times X \to [0, \infty ] = \R _{\ge 0} \{ \infty \}\).
Definition. Monoidal category [math-0070]
- January 14, 2024
- Lîm Tsú-thuàn
Definition. Monoidal category [math-0070]
- January 14, 2024
- Lîm Tsú-thuàn
A monoidal category \((B, \otimes , I, \alpha , \lambda , \rho )\) is a category \(B\) with a bifunctor \(\otimes : B \times B \to B\), an object \(I \in B\), and three natural isomorphisms \(\alpha , \lambda , \rho \).
- \(\alpha _{a,b,c}\) stands for associative, if \(a, b, c \in B\), then we have \((a \otimes b) \otimes c \cong a \otimes (b \otimes c)\)
- \(\lambda _a\) stands for \(I \otimes a \cong a\)
- \(\rho _a\) stands for \(a \otimes I \cong a\)
with following coherence conditions:
Axiom. Pentagonal coherence [math-0071]
- January 14, 2024
- Lîm Tsú-thuàn
Axiom. Pentagonal coherence [math-0071]
- January 14, 2024
- Lîm Tsú-thuàn
The following diagram commutes for all objects \(a, b, c, d \in B\).
Axiom. Triangle coherence [math-0072]
- January 14, 2024
- Lîm Tsú-thuàn
Axiom. Triangle coherence [math-0072]
- January 14, 2024
- Lîm Tsú-thuàn
The following diagram commutes for all objects \(a, c \in B\).
This immdeiately provides \(\lambda _I = \rho _I : I \otimes I \to I\).
Definition. Strict monoidal category [math-0075]
- January 16, 2024
- Lîm Tsú-thuàn
Definition. Strict monoidal category [math-0075]
- January 16, 2024
- Lîm Tsú-thuàn
A monoidal category is strict if three natural isomorphisms are identities.
Definition. Symmetric monoidal category [math-0076]
- January 16, 2024
- Lîm Tsú-thuàn
Definition. Symmetric monoidal category [math-0076]
- January 16, 2024
- Lîm Tsú-thuàn
A monoidal category is symmetric if we add a coherence:
\[a \otimes b \cong b \otimes a\]
Definition. Closed monoidal category [math-007E]
- January 18, 2024
- Lîm Tsú-thuàn
Definition. Closed monoidal category [math-007E]
- January 18, 2024
- Lîm Tsú-thuàn
A monoidal category \(\mathcal {V}\) is closed if for every two objects \(B,C\in \mathcal {V}\), there is an object \(B \multimap C \in \mathcal {V}\), called hom-element or exponential, such that
\[ \text {Hom}_{\mathcal {V}}(A \otimes B, C) \cong \text {Hom}_{\mathcal {V}}(A, B \multimap C) \]
Proposition. [math-0074]
- January 14, 2024
- Lîm Tsú-thuàn
Proposition. [math-0074]
- January 14, 2024
- Lîm Tsú-thuàn
The following diagram in a monoidal category commutes
Proof. [#685]
- January 14, 2024
- Lîm Tsú-thuàn
Proof. [#685]
- January 14, 2024
- Lîm Tsú-thuàn
First considering pentagonal with \(a = b := I\) and \(c := b\) then \(d := c\)
then we have a huge picture that attach second coherence axiom on to pentagonal.
Now, we need to prove \(\alpha _{I,b,c} \circ \rho _I \otimes 1 = (\rho _I \otimes 1) \otimes 1 \circ \alpha _{I\otimes I,b,c}\), but \(\alpha _{I\otimes I,b,c}\) and \(\alpha _{I,b,c}\) are same arrangement by lifting \(I\otimes I\) and \(I\) as parameter. Then \(\rho _I\) is the only left function, therefore, this diagram commutes.
本日最佳軟體描述 [software-000W]
- January 13, 2024
- Lîm Tsú-thuàn
- https://hachyderm.io/@thomasfuchs/111746519049501824
本日最佳軟體描述 [software-000W]
- January 13, 2024
- Lîm Tsú-thuàn
- https://hachyderm.io/@thomasfuchs/111746519049501824
- Blockchain: a slow database
- Crypto: an expensive slow database
- NFT: an expensive slow database to store URLs
- AI: a way to write slow and inefficient algorithms
- LLM: a database that stores text in a slow and inefficient way
- Chat GPT: an expensive imprecise query language for slow and inefficient text databases that often returns wrong results
Proposition. Two functors to preorder have at most one natural transformation [math-006T]
- January 12, 2024
- Lîm Tsú-thuàn
Proposition. Two functors to preorder have at most one natural transformation [math-006T]
- January 12, 2024
- Lîm Tsú-thuàn
If \(\mathcal {P}\) is a preorder, and \(\mathcal {C}\) is an abritary category, then at most one natural transformation for two functors \(F, G : \mathcal {C} \to \mathcal {P}\).
Proof. [#591]
- January 12, 2024
- Lîm Tsú-thuàn
Proof. [#591]
- January 12, 2024
- Lîm Tsú-thuàn
Proposition. \(\lceil x/3 \rceil : \Z \to \R \) has no left adjoint [math-006S]
- January 11, 2024
- Lîm Tsú-thuàn
Proposition. \(\lceil x/3 \rceil : \Z \to \R \) has no left adjoint [math-006S]
- January 11, 2024
- Lîm Tsú-thuàn
In this sense, a left adjoint is a functor from preorder \((\R , \le )\) to \((\Z , \le )\).
Proof. [#592]
- January 11, 2024
- Lîm Tsú-thuàn
Proof. [#592]
- January 11, 2024
- Lîm Tsú-thuàn
If we suppose \(L\) is a left adjoint of \(\lceil x/3 \rceil \), then we should have a diagram
Now, consider \(z = 1\), by Archimedean's principle, we have \(\forall y > 0, \lceil y/3 \rceil \le 1\); thus, we have \(L(1) \le 0\) and hence \(L(1) \le 0\).
However, this leads to \(1 \le 0\), so there has no left adjoint for \(\lceil x/3 \rceil : \Z \to \R \).
Theorem. Pullback transfer mono [math-006Q]
- January 10, 2024
- Lîm Tsú-thuàn
Theorem. Pullback transfer mono [math-006Q]
- January 10, 2024
- Lîm Tsú-thuàn
If below is pullback and \(f\) is mono, then \(f'\) is mono.
Proof. [#594]
- January 10, 2024
- Lîm Tsú-thuàn
Proof. [#594]
- January 10, 2024
- Lîm Tsú-thuàn
First transform the square
The two small square behind are pullbacks,
- the left one stands for any morphism;
- the right one is pullback from mono
, so the big square also a pullback. Now, transform to another view, which shares the same big square.
Consider the right small square is a pullback, leads left small square is a pullback as well; thus, the \(f'\) is mono.
Latex math symbols [latex-0002]
- January 9, 2024
- Lîm Tsú-thuàn
Latex math symbols [latex-0002]
- January 9, 2024
- Lîm Tsú-thuàn
linear logic's \multimap |
\(\multimap \) |
---|---|
QED \square |
\(\square \) |
variant of \(\rho \) \varrho |
\(\varrho \) |
斜上 arrow \nearrow |
\(\nearrow \) |
向上的 partial arrow \upharpoonright |
\(\upharpoonright \) |
\Vdash |
\(\Vdash \) |
\vDash |
\(\vDash \) |
\preceq |
\(\preceq \) |
\succeq |
\(\succeq \) |
\widetilde{x} |
\(\widetilde {x}\) |
\wedge |
\(\wedge \) |
\vee |
\(\vee \) |
\bowtie |
\(\bowtie \) |
Definition. Open/closed set in \(\R \) [math-006O]
- January 9, 2024
- Lîm Tsú-thuàn
Definition. Open/closed set in \(\R \) [math-006O]
- January 9, 2024
- Lîm Tsú-thuàn
A \(U \subseteq \R \) is oepn if for every \(x \in U\), there is a number \(\delta > 0\) such that \((x - \delta , x + \delta ) \subseteq U\). A set \(A\) is closed if its complement set \(A^c\) is open.
Definition. Lift monad [math-006I]
- January 8, 2024
- Lîm Tsú-thuàn
Definition. Lift monad [math-006I]
- January 8, 2024
- Lîm Tsú-thuàn
Let \(D\) be a DCPO, the lifting of \(D\) is adding a least element \(\bot \) to be pointed \(D_\bot \). Thus, a lift monad \((-)_\bot : DCPO \to DCPO\) is an endofunctor that sends a \(D\) to \(D_\bot \).
Definition. Klesli category of the lift monad (\(DCPO_\bot \)) [math-006J]
- January 9, 2024
- Lîm Tsú-thuàn
Definition. Klesli category of the lift monad (\(DCPO_\bot \)) [math-006J]
- January 9, 2024
- Lîm Tsú-thuàn
It's obvious the lift monad creates a Klesli category, \(DCPO_\bot \), has same objects as \(DCPO\); however, a \(D \to E\) morphism in \(DCPO_\bot \) is caming from a morphism \(D \to E_\bot \) in \(DCPO\), a partial continuous function.
Theorem. The categorical product in \(DCPO\) is a symmetric monoidal product in \(DCPO_\bot \), denotes \((\otimes , \bot )\) [math-006K]
- January 9, 2024
- Lîm Tsú-thuàn
Theorem. The categorical product in \(DCPO\) is a symmetric monoidal product in \(DCPO_\bot \), denotes \((\otimes , \bot )\) [math-006K]
- January 9, 2024
- Lîm Tsú-thuàn
\(DCPO_\bot \) is closed with respect to this monoidal structure. Let the internal hom \(D \multimap E\) defined as \(D \Rightarrow _{DCPO} E_\bot \). Then \((-) \otimes D\) is left adjoint of \(D \multimap (-)\).
Definition. Universal domain [math-006L]
- January 9, 2024
- Lîm Tsú-thuàn
Definition. Universal domain [math-006L]
- January 9, 2024
- Lîm Tsú-thuàn
Let \(\mathbb {U}\) be a DCPO \(\N \multimap 2\), we called it the universal domain.
Definition. Domain [math-006M]
- January 9, 2024
- Lîm Tsú-thuàn
Definition. Domain [math-006M]
- January 9, 2024
- Lîm Tsú-thuàn
A DCPO \(D\) is a domain if it is a retract of \(\mathbb {U}\) in \(DCPO_\bot \).
Definition. Pointed poset [math-006D]
- January 8, 2024
- Lîm Tsú-thuàn
Definition. Pointed poset [math-006D]
- January 8, 2024
- Lîm Tsú-thuàn
Definition. Formal language [math-005Y]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. Formal language [math-005Y]
- January 6, 2024
- Lîm Tsú-thuàn
一個形式語言是一個三元組 \((\Gamma , \Delta , a)\) 構成的集合,
- \(\Gamma \) 是可數多個 function symbols
- \(\Delta \) 是可數多個 relation symbols
- \(a : \Gamma \cup \Delta \to \N \) 指示每個符號的 arity (接受幾個參數)
Definition. Language structure (model) [math-005Z]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. Language structure (model) [math-005Z]
- January 6, 2024
- Lîm Tsú-thuàn
A \(L\)-structure \(\mathfrak {U} = (U, I)\) of a language \(L\) is a set \(U\) called universe of model, and a function \(I\) assigns to each \(k\)-ary function symbol in \(\Gamma \) a \(k\)-ary function \(U \to U\) and to each \(k\)-ary relation symbol a \(k\)-ary relation on \(U\). Denotes
- interpretion of function \(f^\mathfrak {U} = I(f)\)
- interpretion of relation \(R^\mathfrak {U} = I(R)\)
Definition. Homomorphism between models [math-0060]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. Homomorphism between models [math-0060]
- January 6, 2024
- Lîm Tsú-thuàn
Let \(\mathfrak {U}\) and \(\mathfrak {B}\) are models of \(L\), a homomorphism \(\varphi \) is a function from \(|\mathfrak {U}| \to |\mathfrak {B}|\) such that, for all for \( a_0, \cdots , a_{k-1} \in |\mathfrak {U}| \)
- for every \(k\)-ary function symbol \(f \in L\) \[\varphi (f^\mathfrak {U}(a_0, \cdots , a_{k-1})) = f^\mathfrak {B}(\varphi (a_0), \cdots , \varphi (a_{k-1}))\]
- for every \(k\)-ary relation symbol \(R \in L\), if \(\varphi (R^\mathfrak {U}(a_0, \cdots , a_{k-1}))\), then \(R^\mathfrak {B}(\varphi (a_0), \cdots , \varphi (a_{k-1}))\)
A homomorphism is embedding if it's injective and the second clause is strengthened to
\(\varphi (R^\mathfrak {U}(a_0, \cdots , a_{k-1}))\) if and only if \(R^\mathfrak {B}(\varphi (a_0), \cdots , \varphi (a_{k-1}))\)
Proposition. Model isomorphism iff surjective embedding [math-0061]
- January 6, 2024
- Lîm Tsú-thuàn
Proposition. Model isomorphism iff surjective embedding [math-0061]
- January 6, 2024
- Lîm Tsú-thuàn
Proof. [#602]
- January 6, 2024
- Lîm Tsú-thuàn
Proof. [#602]
- January 6, 2024
- Lîm Tsú-thuàn
Forward can be omitted since it's proved by definition, and backward can be proved as below.
- Embedding's definition requires injective;
- surjective and injective implies same bijective; therefore, for each relation \(R^\mathfrak {U}\) there is exactly a \(R^\mathfrak {B}\);
- final, since the embedding requires \(R^\mathfrak {U}(...) \iff R^\mathfrak {B}(...)\), the mapping composition is an identity.
Definition. The set of terms [math-0062]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. The set of terms [math-0062]
- January 6, 2024
- Lîm Tsú-thuàn
For a language \(L\), the set of terms of \(L\) is defined inductively as below
- if \(x\) is a variable then \(x\) is a term;
- if \(c\) is a constant symbol in \(\Gamma \) then \(c\) is a term;
- if \(f \in \Gamma \) is a function symbol with \(k\) arity and \(t_0, \cdots , t_{k-1}\) are terms, then \(f(t_0, \cdots , t_{k-1})\) is a term.
Example. Propositional formulas [math-0063]
- January 6, 2024
- Lîm Tsú-thuàn
Example. Propositional formulas [math-0063]
- January 6, 2024
- Lîm Tsú-thuàn
A set of propositional formulas is defined inductively
- if \(P\) is a propositional variable then \(x\) is a propositional formula;
- \(\bot \) is a propositional formula;
- if \(A\) and \(B\) are propositional formulas, then \((A\land B)\), \((A\lor B)\), and \(A \to B\) are propositional formulas.
Definition. Tree [math-0064]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. Tree [math-0064]
- January 6, 2024
- Lîm Tsú-thuàn
Let \(\Sigma \) be abritary set, a tree on \(\Sigma \) is a set of finite sequences of elements of \(\Sigma \) that closed under initial segments.
Definition. Initial segment (prefix string) [math-0065]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. Initial segment (prefix string) [math-0065]
- January 6, 2024
- Lîm Tsú-thuàn
A string \(s\) is an initial segment of \(t\) if \(length(s) < length(t)\) and \(s\) is a prefix string of \(t\), denotes \(s \subseteq t\).
closed under initial segments means if \(\tau \) is in the tree and \(\sigma \subseteq \tau \) then \(\sigma \) is also in the tree.
Definition. Path (tree) [math-006C]
- January 8, 2024
- Lîm Tsú-thuàn
Definition. Path (tree) [math-006C]
- January 8, 2024
- Lîm Tsú-thuàn
A path through a tree \(T\) is a set \(P\) such that
- any two elements are comparable, which means for any two \(\sigma , \tau \in P\) then \(\sigma \subseteq \tau \) or \(\tau \subseteq \sigma \); and
- a path is called maximal, if a node \(\rho \) is comparable with any element of \(P\), then \(\rho \in P\).
Collary. Properties of this tree definition [math-0069]
- January 6, 2024
- Lîm Tsú-thuàn
Collary. Properties of this tree definition [math-0069]
- January 6, 2024
- Lîm Tsú-thuàn
- Every tree except the empty tree has \(()\) as root.
- Every node has finitely many ancestors (all prefix of a finite string form a finite set).
Notation. [math-007V]
- January 28, 2024
- Lîm Tsú-thuàn
Notation. [math-007V]
- January 28, 2024
- Lîm Tsú-thuàn
- \(T_{\upharpoonright \sigma }\) 表示以 \(\sigma \) 為根的子樹。
- 如果 \((T_a)_{a_\in \Sigma }\) 是樹組成的串列,則 \(\sup _{a \in \Sigma }{T_a}\) 定義為樹: \[\{ () \} \cup \{ \text {concat}(a, \sigma ) \mid a \in \Sigma , \sigma \in T_a \}\] 因為至多有 \(|\Sigma |\) 個分支。
Definition. Well-founded tree [math-0066]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. Well-founded tree [math-0066]
- January 6, 2024
- Lîm Tsú-thuàn
The set of well-founded trees of \(\Sigma \) is defined inductively
- empty tree \(()\) is well-founded
- If \((T_a)_{a \in \Sigma }\) is a sequence of well-founded trees, then the tree \(\sup _{a \in \Sigma }{T_a}\) is well-founded.
Proposition. A tree is well-founded tree iff it has no infinite path [math-0067]
- January 6, 2024
- Lîm Tsú-thuàn
Proposition. A tree is well-founded tree iff it has no infinite path [math-0067]
- January 6, 2024
- Lîm Tsú-thuàn
Proof. [#601]
- January 6, 2024
- Lîm Tsú-thuàn
Proof. [#601]
- January 6, 2024
- Lîm Tsú-thuàn
By induction
- The empty tree is finite.
- If each \(T_a\) has no infinite path for each \(a \in \Sigma \), then the extended \(\sup _{a \in \Sigma }{T_a}\) can't have infinite path.
Definition. Finitely branching tree [math-006A]
- January 6, 2024
- Lîm Tsú-thuàn
Definition. Finitely branching tree [math-006A]
- January 6, 2024
- Lîm Tsú-thuàn
A tree is finitely branching if every node has finitely many children.
Lemma. König's [math-0068]
- January 6, 2024
- Lîm Tsú-thuàn
Lemma. König's [math-0068]
- January 6, 2024
- Lîm Tsú-thuàn
Let \(T\) be a finitely branching tree on \(\Sigma \). Then below are equivalent
- \(T\) is finite.
- There is a \(n \in \N \), every path through \(T\) at most \(n\).
- \(T\) is well-founded.
An equivalent statement is: a finitely branching tree with infinite nodes has infinite path.
Proof. [#600]
- January 6, 2024
- Lîm Tsú-thuàn
Proof. [#600]
- January 6, 2024
- Lîm Tsú-thuàn
1 implies 2 and 3 is clearly. Prove 3 implies 1 can complete the proof, using propoisition 3.4, \(T\) has no infinite path, and \(T\) is finitely branching; which means the amount of nodes are a sum of a finite sequence of finite natural numbers, leads to \(T\) is finite.
Example. A well-founded tree with every \(n\)-path [math-006B]
- January 6, 2024
- Lîm Tsú-thuàn
Example. A well-founded tree with every \(n\)-path [math-006B]
- January 6, 2024
- Lîm Tsú-thuàn
Remark. [#599]
- January 6, 2024
- Lîm Tsú-thuàn
Remark. [#599]
- January 6, 2024
- Lîm Tsú-thuàn
這個反例證明了 well-founded 樹還是可以有無限多個元素,只要容許無限多分支。
A tree that, for all \(n \in \N \), the \(n\)-length path through it are existed, can still be well-founded. Consider a tree indexed by \(\Sigma = \N \), with nodes \( \{ 1, 21, 321, 4321, \cdots \} \) up to \(\omega \). It looks like
The tree has all finite \(n\)-path, but has no infinite path.
Example. Binary tree's depth and size [math-007W]
- January 28, 2024
- Lîm Tsú-thuàn
Example. Binary tree's depth and size [math-007W]
- January 28, 2024
- Lîm Tsú-thuàn
令 \(\Sigma = \{ 0, 1 \}\) 的有限樹,這正是一般二元樹的定義。下面定義樹的深度與元素數量
- \(\text {depth}(\empty ) = -1\)
- \(\text {depth}(T) = \max (\text {depth}(T_{\upharpoonright (0)}), \text {depth}(T_{\upharpoonright (1)})) + 1\) for \(T\ne \empty \)
- \(\text {size}(\empty ) = 0\)
- \(\text {size}(T) = 1 + \text {size}(T_{\upharpoonright (0)}) + \text {size}(T_{\upharpoonright (1)})\) for \(T\ne \empty \)
Proposition. Binary tree's size bound [math-007X]
- January 28, 2024
- Lîm Tsú-thuàn
Proposition. Binary tree's size bound [math-007X]
- January 28, 2024
- Lîm Tsú-thuàn
對任意二元樹 \(a\) 有 \(\text {size}(a) \le 2^{\text {depth}(a)+1} - 1\)
Proof. [#572]
- January 28, 2024
- Lîm Tsú-thuàn
Proof. [#572]
- January 28, 2024
- Lîm Tsú-thuàn
二元樹的 \(\text {size}\) 可以表示為等比數列和 \(1 + 2 + 4 + 8 + \cdots \),故為
\[ \frac {1(1 - 2^n)}{1-2} = 2^n - 1 \]\(n\) 正好等於 \(\text {depth}(a)+1\),故 \(\text {size}(a) \le 2^{\text {depth}(a)+1} - 1\)。
Conjecture. Collatz [math-005X]
- January 4, 2024
- Lîm Tsú-thuàn
Conjecture. Collatz [math-005X]
- January 4, 2024
- Lîm Tsú-thuàn
Start from a natural number \(n\),
- if it's an even, divides \(2\);
- else multiply \(3\) then plus \(1\);
repeating the process will get \(1\).
Definition. Formal system [math-005V]
- January 2, 2024
- Lîm Tsú-thuàn
Definition. Formal system [math-005V]
- January 2, 2024
- Lîm Tsú-thuàn
Fully abstract reference [cs-0019]
- January 2, 2024
- Lîm Tsú-thuàn
- https://types.pl/@krismicinski/111682700996819977
Fully abstract reference [cs-0019]
- January 2, 2024
- Lîm Tsú-thuàn
- https://types.pl/@krismicinski/111682700996819977
這個概念是我看到 Kristopher 的貼文 (上列連結) 之後回應的統整。簡單來說目前的 C 位址並非是完全抽象的,因此會導致 double free 會出問題。而正確解決這件事的方式就是讓 reference 是一個完全抽象的存在,並且加上 shift 數表示移位操作。在這個體系下每次我使用 malloc(size)
的時候,都應該得到一個與真實儲存偏移值完全無關,不提供通用逆函數的數字來表示這個 reference,而 shift 數表示我正在操作此 reference 的第幾個 bit。這樣 double free 的時候因為對應的 reference 已經被釋放了,因此就不會對真實的偏移值造成影響。進一步可以使用 bit stealing 來表示 reference,因為真實位址通常不會真的用到全部的 64-bits。
Definition. Profunctor [math-005W]
- January 2, 2024
- Lîm Tsú-thuàn
Definition. Profunctor [math-005W]
- January 2, 2024
- Lîm Tsú-thuàn
A profunctor \(\phi : C \nrightarrow D\) is a functor \(\phi : D^{op} \times C \to \bold {Set}\), such that if \(f \in D\) and \(g \in C\),
and there is an element \(x \in \phi (d', c)\), then \(x \circ f \in \phi (d, c)\) and \(g \circ x \in \phi (d', c')\).
It's related to (co)end.
Remark. [#603]
- January 2, 2024
- Lîm Tsú-thuàn
Remark. [#603]
- January 2, 2024
- Lîm Tsú-thuàn
Profunctor creates a "pseudo" arrow between two categories \(C\) and \(D\).
Definition. Enriched profunctor [#604]
- January 2, 2024
- Lîm Tsú-thuàn
Definition. Enriched profunctor [#604]
- January 2, 2024
- Lîm Tsú-thuàn
It's natural to not restrict ourselves in \(\bold {Set}\). Let \(\mathcal {V}\) be a unital commutative quantale, and let \(\mathcal {X}\) and \(\mathcal {Y}\) be \(\mathcal {V}\)-categories. A \(\mathcal {V}\)-profunctor from \(\mathcal {X}\) to \(\mathcal {Y}\), denoted \(\phi : \mathcal {X} \nrightarrow \mathcal {Y}\), is a \(\mathcal {V}\)-functor
\[\phi : \mathcal {X}^{op} \times \mathcal {Y} \to \mathcal {V}\]
不確定性的來源 [math-005U]
- January 2, 2024
- Lîm Tsú-thuàn
不確定性的來源 [math-005U]
- January 2, 2024
- Lîm Tsú-thuàn
- 系統本身就公理化隨機性,例如量子力學
- 不完全觀測,例如公司的行為對外部人士而言比內部人士更模糊,預測也就更可能失效
- 不完全的模型,當模型出於限制而不得不捨棄資訊時,可能導致不能完全抽象化的處理問題。在現實的工程問題裡面常常要面臨精度有限的狀況,模型要盡量處理,避免嚴重失效
Elaboration with first-class implicit function types 演算法特性 [tt-001B]
- January 1, 2024
- Lîm Tsú-thuàn
Elaboration with first-class implicit function types 演算法特性 [tt-001B]
- January 1, 2024
- Lîm Tsú-thuàn
Elaboration with first-class implicit function types
此演算法可判定,且解是唯一的。理由如下
- 一個 renaming 是不是 epimorphism
- 分解 renaming
- strengthening
因此 pattern unification 可判定,且因為 2 3 都只有唯一解,所以整個 unification 的解是唯一的。其實際演示參考 elaboration zoo 中的合一演算法與隱式參數。
Definition. Heyting algebra (Brouwerian lattice) [math-005R]
- January 1, 2024
- Lîm Tsú-thuàn
Definition. Heyting algebra (Brouwerian lattice) [math-005R]
- January 1, 2024
- Lîm Tsú-thuàn
A Heyting algebra is a bounded lattice equipped with a binary operation \(a \to b\) of implication such that \(c \land a \le b\) is equivalent to \(c \le (a \to b)\).
Proposition. [math-005S]
- January 1, 2024
- Lîm Tsú-thuàn
Proposition. [math-005S]
- January 1, 2024
- Lîm Tsú-thuàn
A Heyting algebra \(H\) is a boolean algebra iff for all \(x \in H\)
\[\lnot \lnot x = x\]or equivalent
\[x \lor \lnot x = 1\]
Theorem. Taylor's expansion [math-005O]
- January 1, 2024
- Lîm Tsú-thuàn
Theorem. Taylor's expansion [math-005O]
- January 1, 2024
- Lîm Tsú-thuàn
If \(f : I \to \R \) is \((n + 1)\)-differentable, if \(\Delta a \in \R \) and \(a + \Delta a \in I\) then
\[ f(a + \Delta a) = \sum _{k = 0}^n { \frac {f^{(k)}(a)} {k!} \cdot {\Delta a}^k + R_n(\Delta a) } \]and there is a \(\xi \in (a, a + \Delta a)\) or \(\xi \in (a + \Delta a, a)\), such that
\[ R_n(\Delta a) = \frac { f^{(n+1)}(\xi ) }{(n+1)!} \cdot {\Delta a}^{n+1} \]
Notation. [#606]
- January 1, 2024
- Lîm Tsú-thuàn
Notation. [#606]
- January 1, 2024
- Lîm Tsú-thuàn
Reference. What Every Programmer Should Know About Memory 繁體中文翻譯版本 [cs-001E]
- 2007
- 2024
- Chi-En Wu, Jim Huang
- https://sysprog21.github.io/cpumemory-zhtw/
Reference. What Every Programmer Should Know About Memory 繁體中文翻譯版本 [cs-001E]
- 2007
- 2024
- Chi-En Wu, Jim Huang
- https://sysprog21.github.io/cpumemory-zhtw/
Definition. Composition of partial maps [math-005T]
- January 1, 2024
- Lîm Tsú-thuàn
Definition. Composition of partial maps [math-005T]
- January 1, 2024
- Lîm Tsú-thuàn
Consider partial maps \(u = [f,m]\) and \(v = [g,n]\), the composition is a partial map \[v \circ u = [ m \circ f^{-1}(n) , g \circ n^*f]\] makes below pullback
Definition. Domain structure [math-005P]
- January 1, 2024
- Lîm Tsú-thuàn
Definition. Domain structure [math-005P]
- January 1, 2024
- Lîm Tsú-thuàn
A domain structure \((\mathcal {K}, \mathcal {D})\) is a pair, where \(\mathcal {D}\) is a well-powered category \(\mathcal {D}\) and a category \(\mathcal {K}\), such that \(\mathcal {D}\) is a full-on-objects subcategory of \(\mathcal {K}\) all of whose morphisms are monos in \(\mathcal {K}\), with the following closure property: Every diagram
is a pullback in \(\mathcal {K}\), with \(f \in \mathcal {K}\), \(n \in D\), and \(f^{-1}(n) \in \mathcal {D}\).
Remark. [#605]
- January 1, 2024
- Lîm Tsú-thuàn
Remark. [#605]
- January 1, 2024
- Lîm Tsú-thuàn
Notice how is this related to composition of partial maps.
Library. Ppx deriving [ocaml-0002]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/ocaml-ppx/ppx_deriving
Library. Ppx deriving [ocaml-0002]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/ocaml-ppx/ppx_deriving
這個專案的用途是幫 type 生成各種函數,像是輸出的字串只要在最後加上 [@@deriving show]
就能夠使用 ([%show: xxx] v)
來把 v : xxx
變成 string
。但我們很有可能會想控制輸出的內容,一個常見的案例是 AST 的 pretty print,這裡面的 [@printer ...]
指令可以控制輸出用的樣板,show_xxx
可以遞迴調用產出的 printer。
type typ = | Var of string [@printer fun fmt -> fprintf fmt "%s"] | Arrow of typ * typ [@printer fun fmt (a, b) -> fprintf fmt "%s -> %s" (show_typ a) (show_typ b)] [@@deriving show]
對結構類的資料也有作用
type card = { title: string; [@printer fun fmt -> fprintf fmt "<%s>"] date: string }
- 此外,也能生成
eq, ord
等函數 -
enum
能指定數值 -
iter, map, fold
能產生結構的列舉程式 -
make
,這裡面可以用[@default v]
讓欄位的預設值變成v
增加 uid (gpg) [software-000U]
- December 31, 2023
- Lîm Tsú-thuàn
增加 uid (gpg) [software-000U]
- December 31, 2023
- Lîm Tsú-thuàn
- Type command
gpg --edit-key XXXXXX
; - in gpg interactive mode enter
adduid
, then answer questions; - in gpg interactive mode enter
quit
then save.
Theorem. Terminal and pullback leads to all finite limit [math-005G]
- December 29, 2023
- Lîm Tsú-thuàn
Theorem. Terminal and pullback leads to all finite limit [math-005G]
- December 29, 2023
- Lîm Tsú-thuàn
A category \(C\) with a terminal and all pullbacks has all finite limits:
- It has binary products, since for any \(A, B \in C\) can form a pullback
- and hence all finite products;
- equalizer \(e\) of pair \(f, g : X \to Y\) can be constructed by a pullback
Then apply all finite limits can be constructed from finite products and equalizers.
Module system's algorithm: topological sort [cs-000T]
- December 29, 2023
- Lîm Tsú-thuàn
Module system's algorithm: topological sort [cs-000T]
- December 29, 2023
- Lîm Tsú-thuàn
steps
- The Graph should be DAG
- remove vertex with in-degree \(0\) and put them into a keep list
- return the keep list at the end
Definition. Partial derivation [math-005M]
- December 29, 2023
- Lîm Tsú-thuàn
Definition. Partial derivation [math-005M]
- December 29, 2023
- Lîm Tsú-thuàn
A partial derivation is defined on function with more than one parameter, e.g. two parameters function
\[z = f(x,y)\]then
\[ \begin {aligned} \frac {\partial z}{\partial x} &= \lim _{h \to 0}{\frac {f(x+h, y) - f(x,y)}{h}} \\&= f_x(x,y) \quad \text {(if this is still a function)} \end {aligned} \]and
\[ \begin {aligned} \frac {\partial z}{\partial y} &= \lim _{h \to 0}{\frac {f(x, y+h) - f(x,y)}{h}} \\&= f_y(x,y) \quad \text {(if this is still a function)} \end {aligned} \]Extend the symbol, for function \(f\) below
\[f(x_1, x_2, ..., x_n)\]where \(n \in \N , n \ge 2\). We have
\[ \frac {\partial }{\partial x_i} = \lim _{h\to 0}\frac { f(x_1, \cdots , x_i + h, \cdots , x_n) - f(x_1, x_2, ..., x_n) }{h} \]
Definition. Satisfiable problem (Boolean algebra) [math-005E]
- December 29, 2023
- Lîm Tsú-thuàn
Definition. Satisfiable problem (Boolean algebra) [math-005E]
- December 29, 2023
- Lîm Tsú-thuàn
The four definition below are equivalent
- \(F\) is unsatisfiable
- \(F = 0\)
- \(\bar F = 1\)
- \(\bar F\) is a tautology
Therefore, a satisfiable problem is a logical statement such that it's inverse is not a tautology.
Two perspective about function [math-005C]
- December 29, 2023
- Lîm Tsú-thuàn
Two perspective about function [math-005C]
- December 29, 2023
- Lîm Tsú-thuàn
- For each element of domain, assigns an element of codomain; or
- for each element of codomain, there is a fibre set.
We will say a function \(f\) is partial iff there has some elements \(x\) of domain, \(f(x)\) has no definition; of course, we can also detect a partial function via two functions.
Definition. Uniformly continuous (real analysis) [math-005D]
- December 29, 2023
- Lîm Tsú-thuàn
Definition. Uniformly continuous (real analysis) [math-005D]
- December 29, 2023
- Lîm Tsú-thuàn
We say \(f : A \to \R \) if for all \(\epsilon > 0\) there exists some \(\delta > 0\) such that, for all \(x,y\in A\)
\[|x - y| < \delta \quad \implies \quad |f(x) - f(y)| < \epsilon \]
Definition. Harmonic series [math-0051]
- December 28, 2023
- Lîm Tsú-thuàn
Definition. Harmonic series [math-0051]
- December 28, 2023
- Lîm Tsú-thuàn
The definition of Harmonic series is
\[ \sum _{k=1}^\infty \frac {1}{k} \]The most famous fact about it is it's divergent, this is again a good example shows that intuitive is not work here, even the adding things are smaller and smaller, the sum is divergent.
Definition. Cardinal [math-0055]
- December 28, 2023
- Lîm Tsú-thuàn
Definition. Cardinal [math-0055]
- December 28, 2023
- Lîm Tsú-thuàn
\(\alpha \) is a cardinal iff \(\alpha = |\alpha |\); a cardinal of a set \(A\) (\(A\) is well-ordered) is the least \(\alpha \) that \(\alpha \approx A\), denotes \(|A|\); a cardinal \(\alpha \) is infinite if \(\alef _0 \precsim \alpha \).
Under the axiom of choice, \(|A|\) is defined for every \(A\).
To expand the definition, we need below
- \(A \precsim B\) iff there is a 1-1 function from \(A\) to \(B\).
- \(A \approx B\) iff there is a 1-1 function from \(A\) onto \(B\).
- \(A \prec B\) iff \(A \precsim B\) and \(B \not \precsim A\).
Theorem. Schröder-Bernstein (伯恩斯坦-施洛德) [math-0056]
- December 28, 2023
- Lîm Tsú-thuàn
Theorem. Schröder-Bernstein (伯恩斯坦-施洛德) [math-0056]
- December 28, 2023
- Lîm Tsú-thuàn
- If \(U \approx |\N |\), we said it's countable infinite (usual denotes \(\alef _0 = |\N |\)); and
- if \(|\N | \prec U\) then we said it's uncountable infinite.
Theorem. Cantor's [math-0059]
- December 28, 2023
- Lîm Tsú-thuàn
Theorem. Cantor's [math-0059]
- December 28, 2023
- Lîm Tsú-thuàn
Which means there is no surjective map from \(A\) to its powerset of \(A\).
Continuum hypothesis [math-005A]
- December 28, 2023
- Lîm Tsú-thuàn
Continuum hypothesis [math-005A]
- December 28, 2023
- Lîm Tsú-thuàn
The hypothesis says no cardinal \(\xi \) satisfies
\[\alef _0 \prec \xi \prec 2^{\alef _0}\]However, the hypothesis is independent from ZFC. The generalized version, for all infinite cardinal \(\alef \), no \(\xi \) satisfies
\[\alef \prec \xi \prec 2^{\alef }\]is also independent.
Conic sections (圓錐曲線) [math-005B]
- December 28, 2023
- Lîm Tsú-thuàn
Conic sections (圓錐曲線) [math-005B]
- December 28, 2023
- Lîm Tsú-thuàn
Definition. Continuous (topological) [math-004Y]
- December 28, 2023
- Lîm Tsú-thuàn
Definition. Continuous (topological) [math-004Y]
- December 28, 2023
- Lîm Tsú-thuàn
A topological function \(f : X \to Y\) is continuous iff for every open set \(V\) in \(Y\), the preimage \(f^{-1}(V)\) is open in \(X\).
It's easy to port this definition back to analysis (or metric space) by picking \(\epsilon \)-neighborhood.
Theorem. Convergent series and Cauchy criterion [math-0052]
- December 28, 2023
- Lîm Tsú-thuàn
Theorem. Convergent series and Cauchy criterion [math-0052]
- December 28, 2023
- Lîm Tsú-thuàn
If \(\sum _{k=1}^\infty {a_k}\) and \(\sum _{k=1}^\infty {b_k}\) are convergent, and the \(\lambda \in \R \), then
- \[\sum _{k=1}^\infty {a_k + b_k} = \sum _{k=1}^\infty {a_k} + \sum _{k=1}^\infty {b_k}\] is convergent; and
- \[\sum _{k=1}^\infty {\lambda \cdot a_k} = \lambda \cdot \sum _{k=1}^\infty {a_k}\] is convergent.
A convergent sequence is a Cauchy sequence (in real analysis), it says
\[ \sum _{k=1}^\infty {a_k} \ \text {is convergent} \iff \forall \epsilon > 0, \exists N \in \N , \forall N \le m \le n, \bigg | \sum _{k = m}^n {a_k} \bigg | < \epsilon \]也就是,存在 \(N\) 讓級數在超過 \(N\) 之後隨便加都可以任意小。
Definition. Differentiable (derivative) [math-004Z]
- December 28, 2023
- Lîm Tsú-thuàn
Definition. Differentiable (derivative) [math-004Z]
- December 28, 2023
- Lîm Tsú-thuàn
A function \(f(x)\) is differentiable at a point \(a\) if \(a\) is contained in an open interval of domain, and the limit
\[ \lim _{h \to 0} \frac {f(a + h) - f(a) }{h} \]exists. We also denote \( \frac {d f}{d x} (a)\) or \( \frac {d y}{d x} \), the later is more common in my background that \(y = f(x)\), but the first one is more suitable if we like to view derivative as a function.
The concept differentiable is more strict that continuous, this is a common mistake that early mathematicians made, until Weierstrass found the first example of a function that is continuous everywhere but differentiable nowhere.
Rule. Derivative rules [math-005H]
- December 29, 2023
- Lîm Tsú-thuàn
Rule. Derivative rules [math-005H]
- December 29, 2023
- Lîm Tsú-thuàn
For every real-functions \(f, g\) that differentable at \(a\) and a constant \(c\)
- \[ \frac {d }{d x} (cf) = c \cdot \frac {d f}{d x} \]
- Sum rule \[ \frac {d }{d x} (f + g) = \frac {d f}{d x} + \frac {d g}{d x} \]
- Leibiniz product rule \[ \frac {d }{d x} (f \cdot g) = f \frac {d g}{d x} + g \frac {d f}{d x} \]
Example. \(f(x) = x^a\) [math-005J]
- December 29, 2023
- Lîm Tsú-thuàn
Example. \(f(x) = x^a\) [math-005J]
- December 29, 2023
- Lîm Tsú-thuàn
We first consider \(f(x) = x^2\), in this case we apply product rule by view it as \(x^2 = x \cdot x\):
\[ \frac {d }{d x} (x^2) = \frac {d }{d x} (x \cdot x) = x \cdot \frac {d x}{d x} + \frac {d x}{d x} x = 2x \]For \( \frac {d }{d x} (x^3)\) we have
\[ \frac {d }{d x} (x^3) = \frac {d }{d x} (x^2\cdot x) = x \cdot \frac {d x^2}{d x} + \frac {d x}{d x} \cdot x^2 = x \cdot 2x + x^2 = 3 x^2 \]It's easy to see for \(a \in \N \) we have
\[ \frac {d }{d x} (x^a) = \frac {d }{d x} (x^{a-1}\cdot x)= x \cdot \frac {d x^{a-1}}{d x} + x^{a-1}\]Inductively get
\[ \frac {d }{d x} (x^a) = a x ^ {a-1}\]
Example. \(f(x) = a^x\), \(f(x) = log_a x\), and famous \(e^x\) [math-005K]
- December 29, 2023
- Lîm Tsú-thuàn
Example. \(f(x) = a^x\), \(f(x) = log_a x\), and famous \(e^x\) [math-005K]
- December 29, 2023
- Lîm Tsú-thuàn
This will need to back to original definition:
\[ \begin {aligned} \frac {d }{d x} (a^x) &= \lim _{h\to 0}\frac { a^{x+h} - a^x }{ h } \\ &= a^x \lim _{h\to 0}\frac {a^h - 1}{h} \\ &= a^x \frac {1}{\log _a e} \\ &= a^x \log _e a \\ &= a^x \ln a \end {aligned} \]
Lemma. \(\lim _{h\to 0}\frac {a^h - 1}{h} = \frac {1}{\log _a e}\) [math-005N]
- December 30, 2023
- Lîm Tsú-thuàn
Lemma. \(\lim _{h\to 0}\frac {a^h - 1}{h} = \frac {1}{\log _a e}\) [math-005N]
- December 30, 2023
- Lîm Tsú-thuàn
The idea is, under \(h \to 0\), \(a^h\) is closed to \(1\), thus, if we say \(t \to \infty \), then
\[1 + \frac {1}{t} \to 1\]can replace \(a^h\). Therefore, we have
\[ \lim _{h \to 0, t \to \infty }{ \frac { (1 + \frac {1}{t}) - 1 }{h} } \]Now, we want to remove \(h\), let \(h = \log _a {(1 + \frac {1}{t})}\)
\[ \lim _{t \to \infty }{ \frac { \frac {1}{t} }{ \log _a (1 + \frac {1}{t}) } } = \lim _{t \to \infty }{ \frac {1}{ \log _a (1 + \frac {1}{t})^t } } \]Apply
\[\lim _{t \to \infty }{ (1 + \frac {1}{t})^t } = e \]Now get
\[ \lim _{t \to \infty }{ \frac {1}{\log _a e} } = { \frac {1}{\log _a e} } \]This leads to famous result
\[ \frac {d }{d x} (e^x) = e^x \ln e = e^x\]Consider \(log_a x\) is the inverse of \(a^x\) such that continuous and monotone, thus
\[ \frac {d }{d x} (log_a x) = \frac {1}{x \ln a}\]also leads
\[ \frac {d }{d x} (\ln x) = \frac {1}{x \ln e} = \frac {1}{x}\]
Rule. Chain rule [math-005I]
- December 29, 2023
- Lîm Tsú-thuàn
Rule. Chain rule [math-005I]
- December 29, 2023
- Lîm Tsú-thuàn
Definition. Dimension (維度) [math-0050]
- December 28, 2023
- Lîm Tsú-thuàn
Definition. Dimension (維度) [math-0050]
- December 28, 2023
- Lîm Tsú-thuàn
The dimension of a space is the cardinal of its basis. For vector space, the definition is in common sense that \(n\)-D such that \(n \in \N \), but there also has Hausdroff dimension that very unusual.
事實上,這個定義下座標系就是指一組 basis。
Definition. Reordering (series) [math-0053]
- December 28, 2023
- Lîm Tsú-thuàn
Definition. Reordering (series) [math-0053]
- December 28, 2023
- Lîm Tsú-thuàn
A series \(\sum _{k=1}^\infty {a_k}\) and a bijective map \(\tau : \N \to \N \), a reordering of series \(\sum _{k=1}^\infty {a_k}\) is a series
\[ \sum _{k=1}^\infty {a_{\tau (k)}} \]
Theorem. Absolutely convergent [math-0054]
- December 28, 2023
- Lîm Tsú-thuàn
Theorem. Absolutely convergent [math-0054]
- December 28, 2023
- Lîm Tsú-thuàn
A series is absolutely convergent, then its reordering cannot change the limit; of course, the reordering is then absolutely convergent
\[ \sum _{k=1}^\infty {a_k} = \sum _{k=1}^\infty {a_{\tau (k)}} \]
加解密訊息 gpg [software-000S]
- December 28, 2023
- Lîm Tsú-thuàn
加解密訊息 gpg [software-000S]
- December 28, 2023
- Lîm Tsú-thuàn
export 公鑰
gpg --armor --export <email>
加密指令可以用 pipeline
echo "message" | gpg --encrypt --armor --recipient <email>
或是檔案
gpg --encrypt --armor --recipient <email> --output [encrypted_file] [msg_file]
解密
gpg --decrypt [encrypted_file]
Definition. Manifold (流形) [math-004V]
- December 20, 2023
- Lîm Tsú-thuàn
Definition. Manifold (流形) [math-004V]
- December 20, 2023
- Lîm Tsú-thuàn
Definition. Alternative (based on premanifold) [#612]
- December 20, 2023
- Lîm Tsú-thuàn
Definition. Alternative (based on premanifold) [#612]
- December 20, 2023
- Lîm Tsú-thuàn
A \(C^\alpha \)-manifold is a \(C^\alpha \)-premanifold whose underlying topological space is Hausdroff and second countable.
當一個連通拓墣空間 \(M\) 可以表示成有限開覆蓋時,對其中每個點 \(p \in M\) 都存在鄰域 \(U\) 帶有所謂的 chart map \(U \xhookrightarrow {\varphi } \R ^n\),其中 \(\varphi \) 是一個同胚映射,所以 \(\varphi (U)\) 是 \(\R ^n\) 中的開集合;這時候說 \(M\) 是拓墣流形(topological manifold),並且稱 \(\varphi \) 指定了一組鄰近座標 (local coordinates),或是直接說 \(\varphi \) 是一組座標,根據定義一組座標跟一個點可以互相表示。
每個 chart map \(\varphi : U \hookrightarrow \R ^n\) 都可以看成多個 component maps 構成的一個 map
\[ \varphi (p) = (\varphi ^1(p), \varphi ^2(p), \cdots , \varphi ^n(p)) \]通常個別的 chart map 是不能描述整個流型的,但流型可以被一組 chart maps 覆蓋,因此引出了 atlas 的概念。
Remark. [#613]
- December 20, 2023
- Lîm Tsú-thuàn
Remark. [#613]
- December 20, 2023
- Lîm Tsú-thuàn
chart map 當然也可以定義成 \(U \subset \R ^n \hookrightarrow M\),這通常跟作者習慣用哪一個方向思考有關。
Definition. Atlas [math-00AA]
- April 5, 2024
- Lîm Tsú-thuàn
Definition. Atlas [math-00AA]
- April 5, 2024
- Lîm Tsú-thuàn
An atlas for a manifold \(M\) is an indexed set \(\{ \phi _i : U_i \to W_i \}\) of charts such that together all the domains \(U_i\) cover \(M\) (\(M = \bigcup _{i\in I} U_i\)).
為了能夠在上面操作微積分,所以額外要求 \(\varphi \) 是可微分的,這時候稱 \(M\) 為可微流形 (differentiable manifold)。
Definition. Curve (曲線) [math-006X]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Curve (曲線) [math-006X]
- January 13, 2024
- Lîm Tsú-thuàn
manifold 上的一個曲線是一個 \(g : \R \to M\) 的 injective 函數,通常把實數參數記為 \(\lambda \) 並寫成 \(g(\lambda )\)。也有定義成 \([0,1] \to M\) 或是 \((-\epsilon ,\epsilon ) \to M\) 的,這些概念其實都類似。
Definition. Closed [#583]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Closed [#583]
- January 13, 2024
- Lîm Tsú-thuàn
A curve \(\gamma : [a,b] \to M\) is closed if \(\gamma (a) = \gamma (b)\).
Definition. Simple [#584]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Simple [#584]
- January 13, 2024
- Lîm Tsú-thuàn
A curve \(\gamma : [a,b] \to M\) is simple if there is no \(s, t \in [ a, b )\) satisfy \(\gamma (s) = \gamma (t)\).
The idea is the curve does not self cross.
Definition. Tangent space (切空間) [math-006W]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Tangent space (切空間) [math-006W]
- January 13, 2024
- Lîm Tsú-thuàn
對一個 manifold \(M\) 上的一點 \(p \in M\) 來說,切空間是一組向量的線性組合構成的向量空間,記成 \(T_pM\),總共有三種不同觀點但等價的定義。
Definition. Kinematic tangent space [#585]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Kinematic tangent space [#585]
- January 13, 2024
- Lîm Tsú-thuàn
流形 \(M\) 上通過點 \(p \in M\) 的不同曲線 \(c : I \to M\) 的切向量 \(\dot {c}(0)\) 的同餘 \([c]\)。為了方便,會定義 \(c(0) = p\)。
\[(T_pM)_{\text {kin}} = \mathcal {C}_p / \sim \]其中 \(\mathcal {C}_p\) 定義為所有 \(c(0) = p\) 的光滑曲線。
Definition. Physicists tangent space [#586]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Physicists tangent space [#586]
- January 13, 2024
- Lîm Tsú-thuàn
對 maximal atlas \(\mathcal {A}\) 的每個 chart 附加一組切向量空間並定義同餘。
Definition. Algebraic tangent space [#587]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Algebraic tangent space [#587]
- January 13, 2024
- Lîm Tsú-thuàn
Manifolds and Differential Geometry §2.1.3
把 tangent vector 定義為 \(v_p : C^\infty (M) \to \R \) 的線性函數,並且滿足 Leibniz law,若 \(f,g \in C^\infty (M)\) 則
\[v_p(fg) = v_p(f)g(p) + f(p)v_p(g)\]可以看到顯然 \(C^\infty (M) = M \to \R \)。這裡,我們也稱 tangent vector \(v_p\) 是 algebra \(C^\infty (M)\) 在 \(p\) 點的微分
Definition. Vector tangent (切向量) [math-006Y]
- January 13, 2024
- Lîm Tsú-thuàn
Definition. Vector tangent (切向量) [math-006Y]
- January 13, 2024
- Lîm Tsú-thuàn
用代數版本可以看出,給定 \((U, x)\) 作為 \(p\) 的 chart,則切空間的標準基底是
\[\frac {\partial }{\partial x^i} \Biggr \rvert _p : C^\infty (M) \to \R \]套用 \(f : C^\infty (M)\) 定義為
\[\frac {\partial }{\partial x^i} \Biggr \rvert _p f := \frac {\partial f}{\partial x^i}(p)\]
Definition. Vector field [math-00AB]
- April 5, 2024
- Lîm Tsú-thuàn
Definition. Vector field [math-00AB]
- April 5, 2024
- Lîm Tsú-thuàn
A smooth vector field on \(M\) is a smooth map from \(M\) to tangent bundle
\[X : M \to TM\]such that \(X(p) \in T_pM\). We denote \(X_p := X(p)\)
Remark. [#524]
- April 5, 2024
- Lîm Tsú-thuàn
Remark. [#524]
- April 5, 2024
- Lîm Tsú-thuàn
換句話說,一個向量場的用途就是,為每一點 \(p \in M\) 選一個關聯向量 \(\vec {v} \in T_p M\)。
Example. Vector field \((x, -y)\) on \(\R ^2\) [linear-000A]
- January 20, 2024
- Lîm Tsú-thuàn
Example. Vector field \((x, -y)\) on \(\R ^2\) [linear-000A]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Dual space (covectors/linear forms/one-forms) [math-007O]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Dual space (covectors/linear forms/one-forms) [math-007O]
- January 20, 2024
- Lîm Tsú-thuàn
Let \(V\) be a vector space over a field \(F\), a covector is a function \(\widetilde {\omega } : V \to F\) such that preserves linearity:
\[ \alpha \widetilde {\omega }(\vec {v}) + \beta \widetilde {\omega }(\vec {w}) = \widetilde {\omega }(\alpha \vec {v} + \beta \vec {w}) \]for all \(\alpha , \beta \in F\). Then we define multiplication
\[ (\alpha \widetilde {\omega })(\vec {v}) = \alpha \widetilde {\omega }(\vec {v}) \]and addition
\[ (\widetilde {\omega } + \widetilde {\sigma })(\vec {v}) = \widetilde {\omega }(\vec {v}) + \widetilde {\sigma }(\vec {v}) \]Thus, all covectors form a dual vector space \(V^*\).
Definition. Cotangent space [#574]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Cotangent space [#574]
- January 20, 2024
- Lîm Tsú-thuàn
For a tangent space \(T_pM\), covectors at the point \(p\) make a vector space as \(T_pM\), so called cotangent space of \(T_pM\), denotes \(T^*_pM\).
Notation. [#575]
- January 20, 2024
- Lîm Tsú-thuàn
Notation. [#575]
- January 20, 2024
- Lîm Tsú-thuàn
A basis of tangent space usually denote as
\[(\frac {\partial }{\partial x^1}, \dots , \frac {\partial }{\partial x^n}) = (\partial _1, \dots , \partial _n)\]A basis of cotangent space denote as
\[(dx^1, \dots , dx^n)\]and by definition
\[dx^i (\frac {\partial }{\partial x^j}) = \delta ^i_{\ j}\]
Example. Row vector as covector of column vector [math-007P]
- January 20, 2024
- Lîm Tsú-thuàn
Example. Row vector as covector of column vector [math-007P]
- January 20, 2024
- Lîm Tsú-thuàn
平面裡面的 row vector \(\begin {bmatrix}a&b\end {bmatrix}\) 可以視為 column vector \(\begin {bmatrix}x \\ y\end {bmatrix}\) 的函數,定義成
\[ \begin {bmatrix}a&b\end {bmatrix}(\begin {bmatrix}x \\ y\end {bmatrix}) := \begin {bmatrix}a&b\end {bmatrix}\begin {bmatrix}x \\ y\end {bmatrix} = ax + by \]
Definition. Congruence [math-007Q]
- January 20, 2024
- Lîm Tsú-thuàn
Definition. Congruence [math-007Q]
- January 20, 2024
- Lîm Tsú-thuàn
Congruence is a set of curves that fill the manifold, or some part of it.
Definition. \(pred(A,x,R)\) [math-004O]
- December 19, 2023
- Lîm Tsú-thuàn
Definition. \(pred(A,x,R)\) [math-004O]
- December 19, 2023
- Lîm Tsú-thuàn
If \(x \in A\) then define
\[pred(A, x, R) = \{ y \in A \mid y R x \}\]
選擇公理的意義 [math-004N]
- December 19, 2023
- Lîm Tsú-thuàn
選擇公理的意義 [math-004N]
- December 19, 2023
- Lîm Tsú-thuàn
選擇公理的邏輯式要求對所有集合 \(A\) 存在 relation \(R\) 可以排序 \(A\):
\[\forall A, \exists R, A \ \text {well-ordered by} \ R\]這個定義的用途是為了用反覆選擇 \(R\)-least element 從而進行 cardinal 的比較。但實際上這是獨立的,所以從集合論 ZF 出發我們只能選擇要不要相信這個公理。
Axiom. Large cardinal [math-004D]
- December 17, 2023
- Lîm Tsú-thuàn
Axiom. Large cardinal [math-004D]
- December 17, 2023
- Lîm Tsú-thuàn
For every cardinal \(\kappa \) there exists an inaccessible cardinal \(\kappa '\) with \(\kappa ' > \kappa \).
Definition. Ordinal [math-004L]
- December 17, 2023
- Lîm Tsú-thuàn
Definition. Ordinal [math-004L]
- December 17, 2023
- Lîm Tsú-thuàn
A set \(A\) is an ordinal off \(A\) is transitive and well-ordered by \(\in _A\).
\[\in _A = \{ \langle y, z \rangle \in A \times A \mid y \in z \}\]
Example. [math-004M]
- December 17, 2023
- Lîm Tsú-thuàn
Example. [math-004M]
- December 17, 2023
- Lîm Tsú-thuàn
Notice \(\{ \{ \{ \varnothing \} \}, \{ \varnothing \}, \varnothing \}\) is an example of transitive but not an ordinal.
We usually drop \(\in _A\) part and just say an ordinal \(A\).
Theorem. [math-004P]
- December 19, 2023
- Lîm Tsú-thuàn
Theorem. [math-004P]
- December 19, 2023
- Lîm Tsú-thuàn
- If \(x\) is an ordinal and \(y \in x\), then \(y\) is an ordinal and \(y = pred(x, y, \in _x) = \{ m \in x \mid m \in _x y \}\)
- If \(x\) and \(y\) are ordinals and \(x \cong y\) then \(x = y\)
- If \(x\) and \(y\) are ordinals, then \(x = y \lor x \in y \lor y \in x\)
- If \(x\), \(y\), and \(z\) are ordinals, then \(x \in y \land y \in z \implies x \in z\)
- If \(C\) is a non-empty set of ordinals, then exist least element \(x\), such that \[\forall y \in C, x \in y \lor x = y\]
Theorem. There is no set of all ordinals [math-004Q]
- December 19, 2023
- Lîm Tsú-thuàn
Theorem. There is no set of all ordinals [math-004Q]
- December 19, 2023
- Lîm Tsú-thuàn
The formal description is
\[\lnot \exists x, \forall x, x \ \text {is an ordinal} \implies x \in z\]
Proof. [#615]
- December 19, 2023
- Lîm Tsú-thuàn
Proof. [#615]
- December 19, 2023
- Lîm Tsú-thuàn
We can first define such set:
\[ON = \{ x \mid x \ \text {is ordinal} \}\]however, we can prove \(ON\) is well-ordered via theorem 2-3,4,5; then we can prove \(ON\) is transitive via theorem 2-1.
No need complicated philosophy here, this is just no greatest ordinal there.
Lemma. Ordinal condition [math-004R]
- December 19, 2023
- Lîm Tsú-thuàn
Lemma. Ordinal condition [math-004R]
- December 19, 2023
- Lîm Tsú-thuàn
A set of ordinals \(A\) is an ordinal iff \(\forall x \in A, \forall y \in x \implies y \in A\).
Definition. Successor (ordinal) [math-004S]
- December 19, 2023
- Lîm Tsú-thuàn
Definition. Successor (ordinal) [math-004S]
- December 19, 2023
- Lîm Tsú-thuàn
Let \(\alpha \) be an ordinal
\[S(\alpha ) = \alpha \cup \{ \alpha \}\]
Lemma. Successor is ordinal [math-004T]
- December 19, 2023
- Lîm Tsú-thuàn
Lemma. Successor is ordinal [math-004T]
- December 19, 2023
- Lîm Tsú-thuàn
For any ordinal \(\alpha \),
- the successor \(S(\alpha )\) is an ordinal;
- \(\alpha < S(\alpha )\)
- \(\forall \beta , \beta < S(\alpha ) \implies \beta \le \alpha \)
This is how we build natural number from set theory (one of methods).
Definition. The least ordinal omega [math-004U]
- December 19, 2023
- Lîm Tsú-thuàn
Definition. The least ordinal omega [math-004U]
- December 19, 2023
- Lîm Tsú-thuàn
The natural number building leads to \(\omega \) is the set of natural numbers (all finite ordinals).
Remark. [#614]
- December 19, 2023
- Lîm Tsú-thuàn
Remark. [#614]
- December 19, 2023
- Lîm Tsú-thuàn
\(\omega \) is the least limit ordinal.
Definition. Well-ordering [math-004J]
- December 17, 2023
- Lîm Tsú-thuàn
Definition. Well-ordering [math-004J]
- December 17, 2023
- Lîm Tsú-thuàn
A set \(A\) with a relation \(R\) is well-ordering iff \(\langle A, R \rangle \) is a total ordering and every non-empty subset \(S\) of \(A\) has an \(R\)-least element \(l\), which means for any \(x \in S\), the \(lRx\) holds.
Definition. Transitive set [math-004C]
- December 16, 2023
- Lîm Tsú-thuàn
Definition. Transitive set [math-004C]
- December 16, 2023
- Lîm Tsú-thuàn
A set \(x\) is transitive iff every element of \(x\) is a subset of \(x\).
Axiom. Neumann-Bernays-Gödel axioms [math-004A]
- December 15, 2023
- Lîm Tsú-thuàn
Axiom. Neumann-Bernays-Gödel axioms [math-004A]
- December 15, 2023
- Lîm Tsú-thuàn
In this system, class is the basic objects of the theory, and a set is just a class that can be an element of other classes.
Atuin [software-000Q]
- December 15, 2023
- Lîm Tsú-thuàn
- https://atuin.sh
Atuin [software-000Q]
- December 15, 2023
- Lîm Tsú-thuàn
- https://atuin.sh
atuin 紀錄 CLI history,互動操作更方便而且可以跨電腦同步指令
atuin
gives better interactive interface to do command history search, once you found a target, use
-
<tab>
to back to shell and edit the command; and -
<enter>
to execute the command directly.
There is a post teach you to use self hosted sync server.
Definition. Category [math-0049]
- December 15, 2023
- Lîm Tsú-thuàn
Definition. Category [math-0049]
- December 15, 2023
- Lîm Tsú-thuàn
A category is a collection \(C\), the elements are called morphisms, together with two endofunctions \(s, t : C \to C\) ("source" and "target") on \(C\) and a partial function \(\circ : C \times C \to C\), such that satisfy the following axioms
- \(x \circ y\) is defined if and only if \(s(x) = t(y)\);
- \(s(s(x)) = s(x) = t(s(x))\) and \(t(t(x)) = t(x) = s(t(x))\) so \(s\) and \(t\) are idempotent endofunctions on \(C\) with same image;
- if \(x \circ y\) is defined, then \(s(x \circ y) = s(y)\) and \(t(x \circ y) = t(x)\);
- \((x \circ y) \circ z = x \circ (y \circ z)\);
- \(x \circ s(x) = x\) and \(t(x) \circ x = x\).
Notation. Composition of morphisms [#618]
- December 15, 2023
- Lîm Tsú-thuàn
Notation. Composition of morphisms [#618]
- December 15, 2023
- Lîm Tsú-thuàn
We usually denote \(f \circ g\) (\(f\) after \(g\)), but also ok with \(fg\) or \(g \gg f\) (\(g\) then \(f\)).
One can compare this version with usual definition (below). This version is more essentials, in the sense that, a category is the "algebra of morphisms".
Definition. Category (usual) [math-0009]
- September 13, 2023
- Lîm Tsú-thuàn
Definition. Category (usual) [math-0009]
- September 13, 2023
- Lîm Tsú-thuàn
We say \(\mathcal {C}\) is a category if
- There is a collection of objects, denoted \(Ob(\mathcal {C})\). If \(x\) is an object of \(\mathcal {C}\), denoted \(x \in Ob(\mathcal {C})\).
- There is a collection of morphisms, denoted \(\mathcal {C}(a, b)\). A morphism \(f\) has a source object and a target object, they can be the same one, for \(a, b \in Ob(\mathcal {C})\), denoted \(f : a \to b\) or \(f \in \mathcal {C}(a, b)\).
They satisfied:
- For every object \(x\), there is an identity morphism \(1_x : x \to x\), an identity has to satisfy
- \(f \circ 1_x = f\);
- \(1_x \circ g = g\)
Remark. [#662]
- September 13, 2023
- Lîm Tsú-thuàn
not every morphism \(f : x \to x\) is an identity.
- if there are any two morphisms with proper form (one's source is the target of another) are composable, for example \(f : a \to b\) and \(g : b \to c\), since \(g\)'s source is the target of \(f\), then there is a composition morphism \(k = g \circ f\);
- for any three composable morphisms \(f, g, h\) \[f \circ (g \circ h) = (f \circ g) \circ h\].
Category size [math-000O]
- September 26, 2023
- Lîm Tsú-thuàn
Category size [math-000O]
- September 26, 2023
- Lîm Tsú-thuàn
If we define categories on the usual set/class formalization setting (means ZF with NBG axioms), we are now able to define what's small (a set) and large (a class). Beside that, using large cardinal axiom we can fix a sequence of inaccessible cardinals \[\kappa _0 < \kappa _1 < \kappa _2 < \cdots \] and their associated universes \(\mathcal {V}_{<\kappa }\); in this sense, a set is
- small if it's contained in \(\mathcal {V}_{<\kappa _0}\);
- large if it's contained in \(\mathcal {V}_{<\kappa _1}\);
- very large if it's contained in \(\mathcal {V}_{<\kappa _2}\);
- very very large if it's contained in \(\mathcal {V}_{<\kappa _3}\), and so on.
One can see that we discuss categories in different foundations, the definitions about categories size below depends on the particular foundation we pick.
Definition. Small category [math-004F]
- December 17, 2023
- Lîm Tsú-thuàn
Definition. Small category [math-004F]
- December 17, 2023
- Lîm Tsú-thuàn
With a particular foundation, a category is small if its collection of morphisms is small.
Definition. Locally small category [math-004G]
- December 17, 2023
- Lîm Tsú-thuàn
Definition. Locally small category [math-004G]
- December 17, 2023
- Lîm Tsú-thuàn
With a particular foundation, a category is locally small if all hom-collections \(\text {Hom}_\mathcal {C}(a, b)\) are small.
otherwise, a category is large.
Some definition even take locally small as default, usually is because author are not going to discuss category theory itself, but use categories as a tool to discuss other topics.
The condition that the collection of morphisms is a set implies the collection of objects is a set.The set/class distinction is raised from set theory, since the collection of all sets as collection of objects forms a category of sets, denotes \(\bold {Sets}\). Its collection of objects cannot be a set, we have to consider this fundamental issue.
Follows the size idea, we can also consider finite category.
Definition. Finite category [math-0020]
- October 29, 2023
- Lîm Tsú-thuàn
Definition. Finite category [math-0020]
- October 29, 2023
- Lîm Tsú-thuàn
A category is finite if its objects and morphisms are both finite set.
We can easier find why monoid is an one object category with this definition:
Definition. Monoid [math-004B]
- December 15, 2023
- Lîm Tsú-thuàn
Definition. Monoid [math-004B]
- December 15, 2023
- Lîm Tsú-thuàn
A monoid is a category such that, any two morphisms \(x, y\) satisfy
- \(s(x) = s(y)\)
- \(s(x) = t(y)\), could be replaced with \(t(x) = t(y)\), but this one might need further check in mind.
These say two things: 1. it has the only one object 2. we can determined the \(I\) element is the identity morphism.
Definition. Usual version [#248]
- December 15, 2023
- Lîm Tsú-thuàn
Definition. Usual version [#248]
- December 15, 2023
- Lîm Tsú-thuàn
A monoid \((M, \bullet )\) constituted by a set \(M\) and a binary function \(\bullet : M \times M \to M\), such that
- \((a \bullet b) \bullet c = a \bullet (b \bullet c)\) for all \(a,b,c \in M\)
- exists an identity element \(I\) let \(I \bullet a = a \bullet I\) for all \(a \in M\)
This is also why we have a joke: a category is just a monoidoid (extend monoid concept to work with many-object).
Croc [software-000P]
- December 15, 2023
- https://github.com/schollz/croc
Croc [software-000P]
- December 15, 2023
- https://github.com/schollz/croc
The tool send files from one computer to another securely.
Migrate gpg keys to new machine [software-000O]
- December 15, 2023
- Lîm Tsú-thuàn
Migrate gpg keys to new machine [software-000O]
- December 15, 2023
- Lîm Tsú-thuàn
gpg -a --export > publickeys.asc gpg -a --export-secret-keys > privatekeys.asc gpg --export-ownertrust > trust.txt
Then use tools e.g. croc to transfer files. Apply below commands in new machine
gpg --import publickeys.asc gpg --import privatekeys.asc gpg -K gpg -k gpg --import-ownertrust trust.txt
Now your gpg is migrated.
Zoxide [software-000N]
- December 15, 2023
- Lîm Tsú-thuàn
- https://github.com/ajeetdsouza/zoxide
Zoxide [software-000N]
- December 15, 2023
- Lîm Tsú-thuàn
- https://github.com/ajeetdsouza/zoxide
Remark. [#299]
- December 15, 2023
- Lîm Tsú-thuàn
Remark. [#299]
- December 15, 2023
- Lîm Tsú-thuàn
zoxide 這個軟體讓我們用簡短的縮寫跳轉到曾經去過的目錄
This is a smarter cd
command. When I do z xxx
, it would bring me to the most frequently used directory with "xxx" in the name. More you use it, it would get more accurated.
在 macOS 上製作 EndeavourOS live USB [linux-0005]
- December 13, 2023
- Lîm Tsú-thuàn
在 macOS 上製作 EndeavourOS live USB [linux-0005]
- December 13, 2023
- Lîm Tsú-thuàn
在下載好 iso 檔案之後,把 USB 隨身碟接上 macOS 電腦,用 diskutil
判斷是哪個 diskN
裝置,然後用下列指令把檔案安裝進去
diskutil eraseDisk "MS-DOS FAT32" USB /dev/diskN diskutil unmountDisk /dev/diskN sudo dd bs=4M if=Endeavouros-Galileo-11-2023.iso of=/dev/diskN conv=fsync oflag=direct status=progress
Definition. Partial map [math-0048]
- December 11, 2023
- Lîm Tsú-thuàn
Definition. Partial map [math-0048]
- December 11, 2023
- Lîm Tsú-thuàn
A total map is a set function, a well-known concept.
A partial function \(A \rightharpoonup B\) can be described by
- a subset \(D \subseteq A\); therefore, is an injection \(m : D \rightarrowtail A\); and
- a total map \(f : D \to B\)
we said \([m, f] : A \rightharpoonup B\) is a description of the partial function. Descriptions are not unique, for any two \([m, f]\) and \([n, g]\) that describes same partial function, there exists an isomorphism \(i\) satisfies
\[m = n \circ i \ \text {and} \ f = g \circ i\]A partial map is an equivalence class of these descriptions.
Definition. Composition of partial maps [math-005T]
- January 1, 2024
- Lîm Tsú-thuàn
Definition. Composition of partial maps [math-005T]
- January 1, 2024
- Lîm Tsú-thuàn
Consider partial maps \(u = [f,m]\) and \(v = [g,n]\), the composition is a partial map \[v \circ u = [ m \circ f^{-1}(n) , g \circ n^*f]\] makes below pullback
Definition. Classifier of partial maps [math-007U]
- January 28, 2024
- Lîm Tsú-thuàn
Definition. Classifier of partial maps [math-007U]
- January 28, 2024
- Lîm Tsú-thuàn
The \(LB\) stands for lifting of \(B\).
Let \((\mathcal {K}, \mathcal {D})\) be a domain structure. A classifier of partial maps with target \(B\) is a mono \(n : B \rightarrowtail LB\) in \(\mathcal {D}\) such that for every partial map \([m,f] : A \rightharpoonup B\), there is a unique total map \(\chi _{[m,f]} : A \to LB\) called characteristic map of \([m,f]\), make below a pullback.
Definition. Directed-complete partial order (DCPO) [math-0045]
- December 10, 2023
- Lîm Tsú-thuàn
Definition. Directed-complete partial order (DCPO) [math-0045]
- December 10, 2023
- Lîm Tsú-thuàn
A poset \(D\) is complete if every directed subset \(P \subseteq D\) has a least upper bound.
Example. Every discrete poset is a DCPO [math-006E]
- January 8, 2024
- Lîm Tsú-thuàn
Example. Every discrete poset is a DCPO [math-006E]
- January 8, 2024
- Lîm Tsú-thuàn
Every discrete poset \((A, =)\) is a DCPO, every singleton sets \(\forall x \in A, \set {x}\) are directed, with least upper bound \(x\).
Definition. Category of DCPOs [math-006F]
- January 8, 2024
- Lîm Tsú-thuàn
Definition. Category of DCPOs [math-006F]
- January 8, 2024
- Lîm Tsú-thuàn
DCPOs with Scott continuous, via Scott topology, it's a full subcategory of the category of topological spaces.
Definition. Scott open [math-003X]
- December 9, 2023
- Lîm Tsú-thuàn
Definition. Scott open [math-003X]
- December 9, 2023
- Lîm Tsú-thuàn
Let \(D\) be a cpo. A subset \(U\) of \(D\) is said to be Scott oepn if
- whenever \(x \in U\) and \(x \sqsubseteq y\) then \(y \in U\); and
- whenever \(M \subseteq D\) is directed and \(\bigsqcup M \in U\), then \(M \cap U \ne \emptyset \).
Definition. Scott topology and continuous [math-003Y]
- December 9, 2023
- Lîm Tsú-thuàn
Definition. Scott topology and continuous [math-003Y]
- December 9, 2023
- Lîm Tsú-thuàn
Scott open subsets of \(D\) form a topology, this is the Scott topology on \(D\). A continuous function \(f : D \to E\) will preserve directed least element \[ f(\sqcup _D X) = \sqcup _E f(X) \] for all directed \(X \subseteq D\).
Definition. 2-Category [math-003R]
- December 8, 2023
- Lîm Tsú-thuàn
Definition. 2-Category [math-003R]
- December 8, 2023
- Lîm Tsú-thuàn
A 2-category \(\mathcal {C}\) is a category with
- a collection of objects (also known as 0-cells);
- for each pair of objects \(a, b \in \mathcal {C}\), a collection of arrows \(f : a \to b\) (also known as 1-cells), these being the objects of the hom-category \(\mathcal {C}(a,b)\); and
- for each pair of 1-cells \(f, g : a \to b\), a collection of arrows between arrows , called 2-cells, these being the morphisms \(\alpha : f \Rightarrow g\) of the hom-category \(\mathcal {C}(a,b)\) from \(f\) to \(g\).
such that
Condition. Vertical composite (category from 1-cells and 2-cells) [math-003S]
- December 8, 2023
- Lîm Tsú-thuàn
Condition. Vertical composite (category from 1-cells and 2-cells) [math-003S]
- December 8, 2023
- Lîm Tsú-thuàn
For each fixed pair of objects \(a , b \in \mathcal {C}\), the 1-cells and 2-cells form a category:
- A pair of 2-cells as below-left admits a vertical composite as below-right.
- Each 1-cell \(f : a \to b\) has an identity 2-cell.
Condition. Category from 0-cells and 1-cells [math-003T]
- December 8, 2023
- Lîm Tsú-thuàn
Condition. Category from 0-cells and 1-cells [math-003T]
- December 8, 2023
- Lîm Tsú-thuàn
The objects and 1-cells define a category; each object has an identity arrow \(1_a : a \to a\).
Condition. Horizontal composite (category from 0-cells and 2-cells) [math-003U]
- December 8, 2023
- Lîm Tsú-thuàn
Condition. Horizontal composite (category from 0-cells and 2-cells) [math-003U]
- December 8, 2023
- Lîm Tsú-thuàn
The objects and 2-cells form a category.
- A pair of 2-cells as below-left admits a horizontal composite as below-right
- The identity 2-cells on identity 1-cells define identities for horizontal composition.
Condition. Functorial (middle-four interchange) [math-003V]
- December 8, 2023
- Lîm Tsú-thuàn
Condition. Functorial (middle-four interchange) [math-003V]
- December 8, 2023
- Lîm Tsú-thuàn
The horizontal composition is functorial with respect to the vertical composition:
- The horizontal composition of identiy 2-cells is an identity 2-cell: which means \(1_g \circ 1_f = 1_{gf}\).
- middle-four interchange: The horizontal composite of the vertical composites coincides with the vertical composite of the horizontal composites.
Definition. Adjoint pair in 2-category [math-0099]
- February 15, 2024
- Lîm Tsú-thuàn
Definition. Adjoint pair in 2-category [math-0099]
- February 15, 2024
- Lîm Tsú-thuàn
Let \(f : A \to B, g : B \to A\) be 1-cells in \(C\), the \((f,g)\) is an adjoint pair if there exists 2-cells
- \(\eta : 1_B \Rightarrow fg\) and
- \(\epsilon : gf \Rightarrow 1_A\)
such that
\[ (1_f \circ \epsilon ) \cdot (\eta \circ 1_f) = 1_f \ \text {and}\; (\epsilon \circ 1_g) \cdot (1_g \circ \eta ) = 1_g \]this is called triangular condition.
Definition. Kan extension in 2-category [math-009K]
- February 23, 2024
- Lîm Tsú-thuàn
Definition. Kan extension in 2-category [math-009K]
- February 23, 2024
- Lîm Tsú-thuàn
In a 2-category \(\mathcal {C}\), consider two 1-cells \(f : A \to C\) and \(g : A \to B\). The Kan extension of \(f\) along \(g\), when exists, is a pair \((h, \alpha )\) where
- \(h : B \to C\) is a 1-cell and \(\alpha : f \Rightarrow hg\) is a 2-cell.
- given any pair \((k, \beta )\) with \(k : B \to C\) and \(\beta : f \Rightarrow kg\), there exists a unique 2-cell \(\gamma : h \Rightarrow k\) such that \[ (\gamma \circ i_g) \cdot \alpha = \beta \]
Mercurial 使用流程 [mercurial-0002]
- December 8, 2023
- Lîm Tsú-thuàn
- https://g0v.social/@dannypsnl/111528511542325133
Mercurial 使用流程 [mercurial-0002]
- December 8, 2023
- Lîm Tsú-thuàn
- https://g0v.social/@dannypsnl/111528511542325133
基於 mercurial 的一些特性,得出多人協作下 mercurial 的開發流程
當然,要是只有自己在開發的話倒是不用這麼麻煩,因為自己開發就算忘記先 pull 也很容易 merge 成功。
-
mkdir repo
目錄 - 把 remote clone 到
repo/public
目錄 - 開發時直接
hg clone public feature-xxx
- 在
feature-xxx
目錄裡面寫好之後直接送 email 出去 - 在 public 裡面只做
-
hg import
mbox -
hg pull/up
跟hg push
hg tag (release)
-
Proposition. \(4^n - 1\) 可以被 3 整除 [math-003Q]
- December 7, 2023
- Lîm Tsú-thuàn
Proposition. \(4^n - 1\) 可以被 3 整除 [math-003Q]
- December 7, 2023
- Lîm Tsú-thuàn
這裡只是想嘗試非歸納證明的方法。
在證明之前需要一些觀察。首先,可以把命題改寫成對所有 \(n\) 存在 \(k\) 令 \(4^n - 1 = 3k\),於是開始觀察數列 \(4^n - 1\) 與 \(k\) 的關係
\(n\) | \(4^n - 1\) | \(k\) |
---|---|---|
\(1\) | \(3\) | \(1\) |
\(2\) | \(15\) | \(5\) |
\(3\) | \(63\) | \(21\) |
\(4\) | \(255\) | \(85\) |
只看到這邊應該還沒辦法知道什麼,不過只要拿到一個數列我們就能嘗試 The book of numbers 中提到的技術:項差列。在這裡,根據 \(n\) 而得到的 \(k\) 們的項差列是
\[\{4, 16, 85\} = \{5 - 1, 21 - 5, 85 - 21\}\]據此可以提出一個猜想:
\[4^n - 1 = 3 \cdot \sum _0^{n-1}{4^n}\]也就是說,總是存在 \(k = \sum _0^{n-1}{4^n}\) 這個整數。
Proof. [#620]
- December 7, 2023
- Lîm Tsú-thuàn
Proof. [#620]
- December 7, 2023
- Lîm Tsú-thuàn
經過一番改寫之後,我們終於可以開始證明。
\[\begin {equation} 4^n - 1 = 3 \cdot \sum _0^{n-1}{4^n} \end {equation}\] \[\begin {equation} 4^n = 1 + 3 \cdot \sum _0^{n-1}{4^n} \end {equation}\] \[\begin {equation} 4^n = 1 + 3 \cdot 4^0 + 3 \cdot \sum _1^{n-1}{4^n} \end {equation}\] \[\begin {equation} 4^n = 4 + 3 \cdot \sum _1^{n-1}{4^n} \end {equation}\]根據等比數列和可以求得
\[\begin {equation} 4^n = 4 + 3 \cdot \frac {4(1-4^{n-1})}{1 - 4} \end {equation}\] \[\begin {equation} 4^n = 4 + 3 \cdot \frac {4 - 4^n}{1 - 4} \end {equation}\] \[\begin {equation} 4^n = 4 + 3 \cdot \frac {4^n - 4}{3} \end {equation}\] \[\begin {equation} 4^n = 4 + (4^n - 4) \end {equation}\]式 (8) 證明關係式確實成立,\(4^n - 1\) 可以分解成 \(3k = 3 ( \frac {4^n - 4}{3} )\),由於 \(k\) 來自整數和,所以也還是一個整數 \(\square \)
Collary. Haskell 不滿足 cartesian closed 的理由 [tt-001A]
- December 7, 2023
- Lîm Tsú-thuàn
Collary. Haskell 不滿足 cartesian closed 的理由 [tt-001A]
- December 7, 2023
- Lîm Tsú-thuàn
因為只要把 Haskell 的 undefined
被包進 pair (undefined, undefined)
,根據 lazy semantic 就不會執行裡面的兩個函數,因此不應有異常,而呼叫 undefined
則會有異常,因此表達成數學式就是
在新版本裡面這個問題被「修正」了,問題是這導致 (undefined, undefined)
不遵循 lazy semantic,在理論上只是變成更大的問題。
Strip extension [mercurial-0001]
- December 5, 2023
- Lîm Tsú-thuàn
- https://wiki.mercurial-scm.org/StripExtension
Strip extension [mercurial-0001]
- December 5, 2023
- Lîm Tsú-thuàn
- https://wiki.mercurial-scm.org/StripExtension
The command performs real revert for commit.
hg strip -r . --keep
Forester 的日期卡片 [forester-0009]
- December 4, 2023
- Lîm Tsú-thuàn
- http://www.jonmsterling.com/jms-00F0.xml
Forester 的日期卡片 [forester-0009]
- December 4, 2023
- Lîm Tsú-thuàn
- http://www.jonmsterling.com/jms-00F0.xml
根據 Jon 在 external 連結中的描述,只要日期 2023-12-04.tree
這樣的卡片存在,則每則該日筆記的日期就會產出一個連結到這張日期卡片上,要如何運用還需要研究。
我想這對 forester-0006 描述的問題也有用
語言搜集列表 (programming languages) [software-000K]
- December 2, 2023
- Lîm Tsú-thuàn
語言搜集列表 (programming languages) [software-000K]
- December 2, 2023
- Lîm Tsú-thuàn
列表的主要原則是展示一個語言的強項、好用的工具跟做出的產品,所以大致上不是入門內容,不過我也可能在其中指向其他外部教學文章。
內容會不定期更新,可以訂閱每個語言的 RSS(網址.xml
部分改成.rss.xml
)。
Reference. OCaml [ocaml-0001]
- 1996
- https://ocaml.org/
Reference. OCaml [ocaml-0001]
- 1996
- https://ocaml.org/
An industrial-strength functional programming language with an emphasis on expressiveness and safety. When developing ocaml project, you might like to run dune build --watch
and keep modify your files.
Library. Ppx deriving [ocaml-0002]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/ocaml-ppx/ppx_deriving
Library. Ppx deriving [ocaml-0002]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/ocaml-ppx/ppx_deriving
這個專案的用途是幫 type 生成各種函數,像是輸出的字串只要在最後加上 [@@deriving show]
就能夠使用 ([%show: xxx] v)
來把 v : xxx
變成 string
。但我們很有可能會想控制輸出的內容,一個常見的案例是 AST 的 pretty print,這裡面的 [@printer ...]
指令可以控制輸出用的樣板,show_xxx
可以遞迴調用產出的 printer。
type typ = | Var of string [@printer fun fmt -> fprintf fmt "%s"] | Arrow of typ * typ [@printer fun fmt (a, b) -> fprintf fmt "%s -> %s" (show_typ a) (show_typ b)] [@@deriving show]
對結構類的資料也有作用
type card = { title: string; [@printer fun fmt -> fprintf fmt "<%s>"] date: string }
- 此外,也能生成
eq, ord
等函數 -
enum
能指定數值 -
iter, map, fold
能產生結構的列舉程式 -
make
,這裡面可以用[@default v]
讓欄位的預設值變成v
Library. Eio [ocaml-0003]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/ocaml-multicore/eio
Library. Eio [ocaml-0003]
- December 31, 2023
- Lîm Tsú-thuàn
- https://github.com/ocaml-multicore/eio
Effects-based direct-style IO for multicore OCaml.
Library. Yuujinchou [ocaml-0004]
- July 20, 2020
- Favonia
- https://redprl.org/yuujinchou/yuujinchou/index.html
Library. Yuujinchou [ocaml-0004]
- July 20, 2020
- Favonia
- https://redprl.org/yuujinchou/yuujinchou/index.html
This library was motivated by the name modifiers in the "import" or "include" statements present in all practical programming languages.
Library. Asai [ocaml-0005]
- January 8, 2024
- https://ocaml.org/p/asai/0.3.0/doc/index.html
Library. Asai [ocaml-0005]
- January 8, 2024
- https://ocaml.org/p/asai/0.3.0/doc/index.html
"asai" is the transliteration of "浅井", the family name of the character Kei Asai (浅井 ケイ) in the Japanese light novel Sagrada Reset (サクラダリセット, also known in English as Sakurada Reset). His ability is perfect photographic memory that is even immune to the "Reset" ability owned by another main character. This OCaml library should record all messages, just like the character.
Library. Algeff [ocaml-0008]
- January 8, 2024
- https://github.com/RedPRL/algaeff
Library. Algeff [ocaml-0008]
- January 8, 2024
- https://github.com/RedPRL/algaeff
🦠 Reusable components based on algebraic effects
Library. Menhir [ocaml-0007]
Library. Menhir [ocaml-0007]
Menhir is a parser generator. It turns high-level grammar specifications, decorated with “semantic actions” (fragments of executable code), into parsers. It is based on Knuth’s LR(1) parser construction technique. It is strongly inspired by its precursors: yacc, ML-Yacc, and ocamlyacc, but offers a large number of minor and major improvements that make it a more modern tool.
Sherlodoc [ocaml-0006]
- February 9, 2024
- Lîm Tsú-thuàn
- https://doc.sherlocode.com/
Sherlodoc [ocaml-0006]
- February 9, 2024
- Lîm Tsú-thuàn
- https://doc.sherlocode.com/
Fuzzy search in OCaml's documentation for almost all opam packages.
Tutorial. [#277]
- 1996
Tutorial. [#277]
- 1996
Reference. Agda [agda-0001]
- 2007
- Ulf Norell, Catarina Coquand
- https://github.com/agda/agda
Reference. Agda [agda-0001]
- 2007
- Ulf Norell, Catarina Coquand
- https://github.com/agda/agda
Agda is a dependently typed programming language / interactive theorem prover.
Tool. Agda 的開發工具 [agda-0005]
- April 1, 2024
- Lîm Tsú-thuàn
Tool. Agda 的開發工具 [agda-0005]
- April 1, 2024
- Lîm Tsú-thuàn
我使用的編輯器工具是 agda mode on VS Code,也可以用 emacs 之類的。常用操作有
-
ctrl+c
,ctrl+l
會編譯檢查檔案,假設程式中有?
,會被替換成所謂的 hole{! !}
,其實就是待寫的程式 -
ctrl+c
,ctrl+,
可以窺看 hole 的目標類型,與當前 context 有哪些 term 可用 -
ctrl+c
,ctrl+r
會把 hole 中你打的程式碼往前提取,當然前提是類型是正確的 -
ctrl+c
,ctrl+m
會把 hole 中你打的程式碼直接當成結果,一樣類型要是正確的 - 一般來說一個 agda 定義如下
hello : A → B hello a = {! !}
ctrl+c, ctrl+c 會問你要把哪個變數用構造子分開,回答a
,假設有a1
與a2
兩個構造子,程式就會變成hello : A → B hello a1 = {! !} hello a2 = {! !}
Remark. [#677]
- April 1, 2024
- Lîm Tsú-thuàn
Remark. [#677]
- April 1, 2024
- Lîm Tsú-thuàn
使用 Linux 的使用者可以更改預設的 copy/cut 指令以免衝突。
Tutorial. A Quick Introduction to Denotational Semantics using Agda [agda-0002]
- March 4, 2024
- Bob Atkey
- https://gist.github.com/bobatkey/52ea69e8ad83b438c5318346200ab4f0
Tutorial. A Quick Introduction to Denotational Semantics using Agda [agda-0002]
- March 4, 2024
- Bob Atkey
- https://gist.github.com/bobatkey/52ea69e8ad83b438c5318346200ab4f0
notes for talk given at TUPLE 2024
This is a very good start point before formalizing languages that more complicated.
Reference. Agda-unimath [agda-unimath]
- 2023
- 2024
- Rijke, Egbert, Stenholm, Elisabeth, Prieto-Cubides, Jonathan, Bakke, Fredrik
- https://unimath.github.io/agda-unimath/HOME.html
Reference. Agda-unimath [agda-unimath]
- 2023
- 2024
- Rijke, Egbert, Stenholm, Elisabeth, Prieto-Cubides, Jonathan, Bakke, Fredrik
- https://unimath.github.io/agda-unimath/HOME.html
@software{agda-unimath, author = {Rijke, Egbert and Stenholm, Elisabeth and Prieto-Cubides, Jonathan and Bakke, Fredrik and {others}}, license = {MIT}, title = {{The agda-unimath library}}, url = {https://github.com/UniMath/agda-unimath/} }
Reference. TLA+ [tlaplus-0001]
Reference. TLA+ [tlaplus-0001]
TLA+ is a high-level language for modeling programs and systems--especially concurrent and distributed ones. It's based on the idea that the best way to describe things precisely is with simple mathematics.
Tool. TLA+ 的開發工具 [tlaplus-0004]
- April 5, 2024
- Lîm Tsú-thuàn
Tool. TLA+ 的開發工具 [tlaplus-0004]
- April 5, 2024
- Lîm Tsú-thuàn
我使用的編輯器工具是 TLA+ on vscode,常用操作是用 Cmd+Shift+P
調用指令
-
TLA+: Parse module
解析模組並且更新生成的約束 -
TLA+: Check model with TLC
按照.cfg
檔案的指示檢查模組ㄋ
PlusCal language [tlaplus-0003]
PlusCal language [tlaplus-0003]
PlusCal is an algorithm language—a language for writing and debugging algorithms. It is especially good for algorithms to be implemented with multi-threaded code. Instead of being compiled into code, a PlusCal algorithm is translated into a TLA+ specification. An algorithm written in PlusCal is debugged using the TLA+ tools—mainly the TLC model checker. Correctness of the algorithm can also be proved with the TLAPS proof system, but that requires a lot of hard work and is seldom done.
Reference. Lean Theorem Prover [lean-0001]
- December 2, 2023
- Lîm Tsú-thuàn
- https://lean-lang.org/
- https://leanprover.github.io
Reference. Lean Theorem Prover [lean-0001]
- December 2, 2023
- Lîm Tsú-thuàn
- https://lean-lang.org/
- https://leanprover.github.io
Lean is a functional programming language that makes it easy to write correct and maintainable code. You can also use Lean as an interactive theorem prover. Lean programming primarily involves defining types and functions. This allows your focus to remain on the problem domain and manipulating its data, rather than the details of programming.
Library. Mathlib4 [lean-0002]
- December 2, 2023
- Lîm Tsú-thuàn
- https://github.com/leanprover-community/mathlib4
Library. Mathlib4 [lean-0002]
- December 2, 2023
- Lîm Tsú-thuàn
- https://github.com/leanprover-community/mathlib4
Lean 作為證明器的主要成果,有大量的數學證明。
Proof search in Lean4 [software-000A]
- October 11, 2023
- Lîm Tsú-thuàn
- https://proofassistants.stackexchange.com/a/415/302
Proof search in Lean4 [software-000A]
- October 11, 2023
- Lîm Tsú-thuàn
- https://proofassistants.stackexchange.com/a/415/302
With below line in Lean prover
import Mathlib.Tactic.Observe
One can use exact?
, apply?
tactics to search in Lean4 library.
Reference. Julia [julia-0001]
- January 27, 2024
- Lîm Tsú-thuàn
- https://julialang.org/
Reference. Julia [julia-0001]
- January 27, 2024
- Lîm Tsú-thuàn
- https://julialang.org/
Julia was designed with technical and scientific users in mind. These users often have very large data sets or very complex mathematical problems that they want to solve. This means they want to write code that can run on a computer very quickly, so that they don’t have to wait days or even weeks to get a result. Most of the programming languages that run very fast are also quite a bit trickier to use than some “high level” languages that you might have heard of, like Python or Matlab. For example, C and Fortran are known to be very fast, but they require that the user provides a lot of information to the computer about the program they are writing as they write it. This takes more time and often more programming experience than working in a language like Python.
Library. AlgebraicJulia [julia-0002]
- January 27, 2024
- Lîm Tsú-thuàn
- https://www.algebraicjulia.org/
Library. AlgebraicJulia [julia-0002]
- January 27, 2024
- Lîm Tsú-thuàn
- https://www.algebraicjulia.org/
這個程式庫可以操作跟繪製範疇論相關的概念,由數個子專案組成。
Library. ManifoldDiffEq [julia-0003]
- January 27, 2024
- Lîm Tsú-thuàn
- https://juliamanifolds.github.io/ManifoldDiffEq.jl/stable/
Library. ManifoldDiffEq [julia-0003]
- January 27, 2024
- Lîm Tsú-thuàn
- https://juliamanifolds.github.io/ManifoldDiffEq.jl/stable/
The package ManifoldDiffEq aims to provide a library of differential equation solvers on manifolds. The library is built on top of Manifolds.jl and follows the interface of OrdinaryDiffEq.jl.
Example. ForwardDiff [julia-0004]
- March 11, 2024
- Lîm Tsú-thuàn
Example. ForwardDiff [julia-0004]
- March 11, 2024
- Lîm Tsú-thuàn
計算 Jacobian 矩陣與行列式
using ForwardDiff using StaticArrays f(x,y) = @SVector [x^2 + y^3 - 1, x^4 - y^4 + x*y] a = [1.0,3.0] J = ForwardDiff.jacobian(x -> f(x[1],x[2]), a) using LinearAlgebra J |> det
Reference. Racket [racket-0001]
- 1995
- Matthew Flatt, Robert Bruce Findler, Krishnamurthi
- https://racket-lang.org/
Reference. Racket [racket-0001]
- 1995
- Matthew Flatt, Robert Bruce Findler, Krishnamurthi
- https://racket-lang.org/
著重在創造語言的程式語言,主要的缺點是它真的太擅長創造新的語言了,整合其他人的程式碼並不容易,實際上僅適合個人研究/專案等用途。不過在程式語言理論中的工具相當齊全,這是一個好的採用理由。
Library. PLT redex [racket-0002]
- December 2, 2023
- Lîm Tsú-thuàn
- https://docs.racket-lang.org/redex/
Library. PLT redex [racket-0002]
- December 2, 2023
- Lîm Tsú-thuàn
- https://docs.racket-lang.org/redex/
這是一個定義形式系統跟化簡規則的工具,典型的用途是分析化簡的分支,對系統的公式支援多種輸出格式,另外它整合了 racket 的繪圖工具讓你直接看到化簡過程(下圖複製自教學網站)。
Library. Turnstile [racket-0003]
Library. Turnstile [racket-0003]
可以快速產生新的型別論的語言,而且各個規則可以模組化的定義,不需要寫在一起。
Library. Plot [racket-0004]
- December 2, 2023
- Lîm Tsú-thuàn
- https://docs.racket-lang.org/plot/
Library. Plot [racket-0004]
- December 2, 2023
- Lîm Tsú-thuàn
- https://docs.racket-lang.org/plot/
racket 內建的繪圖工具,對 3D 數學的支援良好(下圖複製自教學網站)。
Reference. Haskell [haskell-0001]
Reference. Haskell [haskell-0001]
Haskell 是一個函數式與多態並且相當在意不可變與惰性的程式語言,這個進入點用來記錄 Haskell 中好用的工具與程式庫。
Tool. Ghcup [haskell-0002]
- December 2, 2023
- Lîm Tsú-thuàn
- https://www.haskell.org/ghcup/
Tool. Ghcup [haskell-0002]
- December 2, 2023
- Lîm Tsú-thuàn
- https://www.haskell.org/ghcup/
安裝與版本管理工具,最常用到的指令是 ghcup tui
,可以開啟 terminal UI 進行安裝與卸載操作。
Library. Megaparsec [haskell-0003]
- December 2, 2023
- Lîm Tsú-thuàn
- https://hackage.haskell.org/package/megaparsec
Library. Megaparsec [haskell-0003]
- December 2, 2023
- Lîm Tsú-thuàn
- https://hackage.haskell.org/package/megaparsec
進行文字解析的程式庫,特色是採用 parser combinator,是同類程式庫中目前功能最齊全的
Extension. Flexible contexts [haskell-0004]
- May 10, 2023
- Lîm Tsú-thuàn
Extension. Flexible contexts [haskell-0004]
- May 10, 2023
- Lîm Tsú-thuàn
Open FlexibleContexts
extension can release the power of monad transformers, a simple example here
import Control.Monad.Except import Control.Monad.State foo :: (MonadIO m) => (MonadError String m) => (MonadState Int m) => m () foo = do liftIO $ putStrLn "hello" modify (+ 1) throwError "error"
The program
- prints
hello
- modifies its state
- throw an error at the end
these effects are able since the type class constraints are IO
, State Int
, and Except String
. Then, we can instantized the function:
foo1 :: ExceptT String (StateT Int IO) () foo1 = foo foo2 :: StateT Int (ExceptT String IO) () foo2 = foo
let's take a look at how to invoke
main :: IO () main = do (a, s) <- runStateT (runExceptT foo1) 0 putStrLn $ show a putStrLn $ show s
The output is
hello Left "error" 1
Even the program is failed, you still get the state! However, foo2
gives a different result:
main :: IO () main = do b <- runExceptT $ runStateT foo2 0 putStrLn $ show b
This program drop the state whenever the program failed. The result is
hello 1
This is why the contexts are called flexible. The order of transformers is non-trivial, it can affect the behavior of the program. Two transformers bring two order, three bring six order, though not every permutation is useful or make different, but a flexible program maybe more polymorphic than one think. That maybe will not be your expectation, and hence, you might need to export a stable interface for your module, but inside of your module? Just let it free.
Reference. Dafny [dafny-0001]
- December 2, 2023
- Lîm Tsú-thuàn
- https://dafny.org/
Reference. Dafny [dafny-0001]
- December 2, 2023
- Lîm Tsú-thuàn
- https://dafny.org/
Dafny is a verification-aware programming language that has native support for recording specifications and is equipped with a static program verifier.
Example. 集合操作 [dafny-0002]
- February 9, 2024
- Lîm Tsú-thuàn
Example. 集合操作 [dafny-0002]
- February 9, 2024
- Lîm Tsú-thuàn
數學符號 | dafny 程式 |
---|---|
聯集 \(A \cup B\) | A + B |
交集 \(A \cap B\) | A * B |
差集 \(A \setminus B\) | A - B |
勢 \(|A|\) | |A| |
\(x \in A\) | x in A |
\(x \not \in A\) | x !in A or !(x in A) |
\(A \subset B\) | A < B |
\(A \subseteq B\) | A <= B |
Reference. F* [fstar-0001]
- December 2, 2023
- Lîm Tsú-thuàn
- https://www.fstar-lang.org/
Reference. F* [fstar-0001]
- December 2, 2023
- Lîm Tsú-thuàn
- https://www.fstar-lang.org/
F* (pronounced F star) is a general-purpose proof-oriented programming language, supporting both purely functional and effectful programming. It combines the expressive power of dependent types with proof automation based on SMT solving and tactic-based interactive theorem proving.
Definition. Lattice [math-003A]
- November 29, 2023
- Lîm Tsú-thuàn
Definition. Lattice [math-003A]
- November 29, 2023
- Lîm Tsú-thuàn
A lattice is a poset such that any two elements \(x, y\) of it have
- A greatest lower bound \(x \sqcap y\) or \(x \wedge y\) (also called meet, or categorical product)
- A least upper bound \(x \sqcup y\) or \(x \vee y\) (also called join, or categorical coproduct)
Definition. Bounded lattice [math-003B]
- November 29, 2023
- Lîm Tsú-thuàn
Definition. Bounded lattice [math-003B]
- November 29, 2023
- Lîm Tsú-thuàn
A lattice is bounded if it has both initial and terminal.
Proposition. As a category, lattice always has pullbacks and pushouts [math-003C]
- November 29, 2023
- Lîm Tsú-thuàn
Proposition. As a category, lattice always has pullbacks and pushouts [math-003C]
- November 29, 2023
- Lîm Tsú-thuàn
For any two elements of lattice, there is a pullback and pushout.
Proof. [#627]
- November 29, 2023
- Lîm Tsú-thuàn
Proof. [#627]
- November 29, 2023
- Lîm Tsú-thuàn
Any two elements has a product and coproduct, which means below diagram exists
and just like preorder pullbacks are products reason, there has at most one \(x \sqcap y \to x \sqcup y\), so this diagram must be a pullback square, and must also be a pushout square.
Example. Powerset and lattice [math-003D]
- November 29, 2023
- Lîm Tsú-thuàn
Example. Powerset and lattice [math-003D]
- November 29, 2023
- Lîm Tsú-thuàn
Powersets \(\mathscr {P}(A)\) of a set \(A\) with \(\subseteq \) relation is a lattice, where
- join of \(x, y\) is their union \(x \cup y\)
- meet of \(x, y\) is their interesection \(x \cap y\)
- unit is the set \(A\)
- zero is \(\varnothing \)
Example. Topology and lattice [math-003E]
- November 29, 2023
- Lîm Tsú-thuàn
Example. Topology and lattice [math-003E]
- November 29, 2023
- Lîm Tsú-thuàn
Let \(I\) be a topological space, its open sets \(\Theta \) with \(\subseteq \) forms a lattice \((\Theta , \subseteq )\) just like powerset and lattice, since open sets \(\Theta \) will be a sub collection of \(\mathscr {P}(I)\).
Definition. Distributive lattice [math-003F]
- November 29, 2023
- Lîm Tsú-thuàn
Definition. Distributive lattice [math-003F]
- November 29, 2023
- Lîm Tsú-thuàn
A lattice \(A\) is said to be distributive if admits the following law
\[x \sqcap (y \sqcup z) = (x \sqcap y) \sqcup (x \sqcap z)\]for all \(x, y, z \in A\), or equivalent version is \(x \sqcup (y \sqcap z) = (x \sqcup y) \sqcap (x \sqcup z)\).
Definition. Complement in lattice [math-003G]
- November 29, 2023
- Lîm Tsú-thuàn
Definition. Complement in lattice [math-003G]
- November 29, 2023
- Lîm Tsú-thuàn
In a bounded lattice, \(y\) is a complement of \(x\) if \(x \sqcup y = 1\) and \(x \sqcap y = 0\). A bounded lattice is complemented if each of its element has a complement in the lattice.
Collary. Recheck lattice's example [math-003H]
- November 29, 2023
- Lîm Tsú-thuàn
Collary. Recheck lattice's example [math-003H]
- November 29, 2023
- Lîm Tsú-thuàn
- powerset with subset relation is complemented for instance.
- compare with powerset example, topology with subset relation is complemented only when each open set \(A\) is closed, this is because the \(A^{\mathsf {c}} \in \Theta \) iff \(A\) is closed.
Proposition. All preorder pullbacks are products [math-0038]
- November 28, 2023
- Lîm Tsú-thuàn
Proposition. All preorder pullbacks are products [math-0038]
- November 28, 2023
- Lîm Tsú-thuàn
The proposition is saying the preorder diagram below is a pullback square if and only if \(p\) is a product of \(a\) and \(b\).
Proof. [#630]
- November 28, 2023
- Lîm Tsú-thuàn
Proof. [#630]
- November 28, 2023
- Lîm Tsú-thuàn
The proof is easy, in preorder at most one arrow \(a \to b\) for all objects \(a, b\). Therefore, we can make below diagram commutes
Definition. Pullback and pushout [math-0039]
- November 28, 2023
- Lîm Tsú-thuàn
Definition. Pullback and pushout [math-0039]
- November 28, 2023
- Lîm Tsú-thuàn
A pullback is a limit of \(\bullet \rightarrow \bullet \leftarrow \bullet \); a pushout is a colimit of \(\bullet \leftarrow \bullet \rightarrow \bullet \).
Pullback square [#628]
- November 28, 2023
- Lîm Tsú-thuàn
Pullback square [#628]
- November 28, 2023
- Lîm Tsú-thuàn
Pushout square [#629]
- November 28, 2023
- Lîm Tsú-thuàn
Pushout square [#629]
- November 28, 2023
- Lîm Tsú-thuàn
Lemma. Free pullback [math-006R]
- January 10, 2024
- Lîm Tsú-thuàn
Lemma. Free pullback [math-006R]
- January 10, 2024
- Lîm Tsú-thuàn
For any morphism \(f\) the below is pullback.
Proof. [#593]
- January 10, 2024
- Lîm Tsú-thuàn
Proof. [#593]
- January 10, 2024
- Lîm Tsú-thuàn
Definition. Skeletal category [math-0037]
- November 27, 2023
- Lîm Tsú-thuàn
Definition. Skeletal category [math-0037]
- November 27, 2023
- Lîm Tsú-thuàn
Git send-email setup with Protonmail [software-000J]
- November 24, 2023
- Lîm Tsú-thuàn
Git send-email setup with Protonmail [software-000J]
- November 24, 2023
- Lîm Tsú-thuàn
In the original setup I already explain the configuration, to do the same with Protonmail will need to install Proton Mail Bridge, then with configuration as below.
[sendemail] smtpEncryption = STARTTLS smtpServer = 127.0.0.1 smtpUser = <your id>@protonmail.com smtpServerPort = 1025 smtpPass = <your password>
Definition. Monomorphisms and epimorphisms [math-0030]
- November 24, 2023
- Lîm Tsú-thuàn
Definition. Monomorphisms and epimorphisms [math-0030]
- November 24, 2023
- Lîm Tsú-thuàn
- An arrow \(f : A \to B\) is mono if it's left-cancelable: \(f \circ x_1 = f \circ x_2 \implies x_1 = x_2\)
- An arrow \(f : A \to B\) is epi if it's right-cancelable: \(x_1 \circ f = x_2 \circ f \implies x_1 = x_2\)
Definition. Split mono and epi arrows [math-0031]
- November 24, 2023
- Lîm Tsú-thuàn
Definition. Split mono and epi arrows [math-0031]
- November 24, 2023
- Lîm Tsú-thuàn
- An arrow \(f : A \to B\) is split mono if there is an post-inverse arrow \(k : B \to A\) such that \[k \circ f = id_A\]
- An arrow \(f : A \to B\) is split epi if there is an pre-inverse arrow \(h : B \to A\) such that \[f \circ h = id_B\]
Proposition. Split mono/epi implies mono/epi [#631]
- November 24, 2023
- Lîm Tsú-thuàn
Proposition. Split mono/epi implies mono/epi [#631]
- November 24, 2023
- Lîm Tsú-thuàn
Proof. [#632]
- November 24, 2023
- Lîm Tsú-thuàn
Proof. [#632]
- November 24, 2023
- Lîm Tsú-thuàn
For split mono, if \(f \circ x_1 = f \circ x_2\) then \(k \circ f \circ x_1 = k \circ f \circ x_2\) implies \(x_1 = x_2\). Similar for split epi.
Definition. Regular monomorphism/eipmorphism [math-0081]
- February 3, 2024
- Lîm Tsú-thuàn
Definition. Regular monomorphism/eipmorphism [math-0081]
- February 3, 2024
- Lîm Tsú-thuàn
A monomorphism is regular if it is the equalizer of a pair of arrows; an eipmorphism is regular if it is the coequalizer of a pair of arrows.
Definition. Strong epimorphism [math-0082]
- February 3, 2024
- Lîm Tsú-thuàn
Definition. Strong epimorphism [math-0082]
- February 3, 2024
- Lîm Tsú-thuàn
An epimorphism is strong if for every diagram \(z \circ u = v \circ f\), with \(z\) is mono,
there is a unique \(w : B \to X\) makes \(w \circ f = u\) and \(z \circ w = v\).
Collary. [math-0083]
- February 3, 2024
- Lîm Tsú-thuàn
Collary. [math-0083]
- February 3, 2024
- Lîm Tsú-thuàn
- Composition of strong epimorphism is a strong epimorphism.
- If a composition \(f\circ g\) is a strong epimorphism, then \(f\) is a strong epimorphism.
- Every regular monomorphism/eipmorphism is strong.
Definition. Alternative definition of strong epimorphism [math-008F]
- February 6, 2024
- Lîm Tsú-thuàn
Definition. Alternative definition of strong epimorphism [math-008F]
- February 6, 2024
- Lîm Tsú-thuàn
An epimorphism is strong if and only if for every monomorphism \(g\), \(f\) is orthogonal to \(g\) (\(f\ \bot \ g\)).
Proposition. Iso implies mono and epic [math-0073]
- January 14, 2024
- Lîm Tsú-thuàn
Proposition. Iso implies mono and epic [math-0073]
- January 14, 2024
- Lîm Tsú-thuàn
An isomorphism \(\alpha \) is both mono and epic.
Proof. [#582]
- January 14, 2024
- Lîm Tsú-thuàn
Proof. [#582]
- January 14, 2024
- Lîm Tsú-thuàn
- If \(\alpha f = \alpha g\), then \(\alpha ^{-1}\alpha f = \alpha ^{-1}\alpha g\), and then \(f = g\);
- if \(f\alpha = g\alpha \), then \(f\alpha \alpha ^{-1} = g\alpha \alpha ^{-1}\), and then \(f = g\).
Proposition. Reframe mono/epi in pullback/pushout [math-006V]
- January 13, 2024
- Lîm Tsú-thuàn
Proposition. Reframe mono/epi in pullback/pushout [math-006V]
- January 13, 2024
- Lîm Tsú-thuàn
If \(f\) is a monic then below is pullback
and if \(g\) is an epic then below is a pushout
Proof. [#588]
- January 13, 2024
- Lîm Tsú-thuàn
Proof. [#588]
- January 13, 2024
- Lîm Tsú-thuàn
\(f\) is monic means \(fa = fb \implies a = b\), therefore, consider
if \(fa = fb\) then there are unique \(a'\) and \(b'\), where \(a = 1_\bullet a'\) and \(b = 1_\bullet b'\), makes \(f 1_\bullet a' = f 1_\bullet b'\), by mono we know \(1_\bullet a' = 1_\bullet b'\). Therefore, by cancel law we can only have \(a' = b'\), then \(a = b\).
Apply dual we get epic can reframe as a pushout.
Theorem. Pullback transfer mono [math-006Q]
- January 10, 2024
- Lîm Tsú-thuàn
Theorem. Pullback transfer mono [math-006Q]
- January 10, 2024
- Lîm Tsú-thuàn
If below is pullback and \(f\) is mono, then \(f'\) is mono.
Proof. [#594]
- January 10, 2024
- Lîm Tsú-thuàn
Proof. [#594]
- January 10, 2024
- Lîm Tsú-thuàn
First transform the square
The two small square behind are pullbacks,
- the left one stands for any morphism;
- the right one is pullback from mono
, so the big square also a pullback. Now, transform to another view, which shares the same big square.
Consider the right small square is a pullback, leads left small square is a pullback as well; thus, the \(f'\) is mono.
Example. \(\pi : [0, 1] \to S^1\) [math-002X]
- November 22, 2023
- Lîm Tsú-thuàn
Example. \(\pi : [0, 1] \to S^1\) [math-002X]
- November 22, 2023
- Lîm Tsú-thuàn
The map \(\pi : [0,1] \to S^1\) defined by \(\pi (t) = (\cos (2\pi t), \sin (2\pi t))\) is a quotient map.
Definition. Product topology [math-002Y]
- November 22, 2023
- Lîm Tsú-thuàn
Definition. Product topology [math-002Y]
- November 22, 2023
- Lîm Tsú-thuàn
For two topological spaces \(X, Y\), their product topological space \(X \times Y\) is cartesian product of sets \(X\) and \(Y\), where open sets are cartesian product \(U \times V\) of all open sets \(U \subset X, V \subset Y\).
Definition. Simplicial set and simplex [math-002W]
- November 21, 2023
- Lîm Tsú-thuàn
Definition. Simplicial set and simplex [math-002W]
- November 21, 2023
- Lîm Tsú-thuàn
A simplicial set is a presheaf \(X : \Delta ^{op} \to Sets\) over the category \(\Delta \), denote \(sSet = \widehat \Delta \) for the category of simplicial sets.
A \(n\)-simplex \(x\) is an element of \(x \in X_n := X([n])\).
Definition. Degenerate and non-degenerate (simplex) [math-00DW]
- October 16, 2024
- Lîm Tsú-thuàn
Definition. Degenerate and non-degenerate (simplex) [math-00DW]
- October 16, 2024
- Lîm Tsú-thuàn
With a fixed simplicial set \(X\), a \(n\)-simplex \(x \in X_n\) is said to be degenerate if there is \(m\)-simplex \(y \in X_m\) (\(m < n\)) and a \(\alpha : [n] \to [m]\), such that \(\alpha ^* : X_m \to X_n\) satisfies
\[ x = \alpha ^*(y) \]In words, if there exists a lower \(m\)-simplex and a map from that to this \(n\)-simplex, then this \(n\)-simplex is degenerate.
A \(n\)-simplex is said to be non-degenerate, if it's not degenerate.
Definition. Subspace (vector space) [math-002T]
- November 14, 2023
- Lîm Tsú-thuàn
Definition. Subspace (vector space) [math-002T]
- November 14, 2023
- Lîm Tsú-thuàn
A set \(U\) is a subspace of vector space \(V\) if all linear combinations of vectors are closed.
Closed means results of the operation are still elements of subspace.
Example. Set of sequences of a field [linear-0004]
- January 18, 2024
- Lîm Tsú-thuàn
Example. Set of sequences of a field [linear-0004]
- January 18, 2024
- Lîm Tsú-thuàn
Let \(F\) be a field than \(\set {(x_1, x_2, 0) \mid x_1, x_2 \in F}\) is a subspace of \(F^3\).
Proposition. When a subset is a subspace [linear-0005]
- January 18, 2024
- Lîm Tsú-thuàn
Proposition. When a subset is a subspace [linear-0005]
- January 18, 2024
- Lîm Tsú-thuàn
A subset \(U\) of \(V\) is a subspace of \(V\) iff \(U\) satisfies below three conditions
- \(0 \in U\);
- \(u,w \in U\) implies \(u + w \in U\);
- \(a \in F\) and \(u \in U\) implies \(au \in U\).
Proposition. Direct sum of subspaces [linear-0006]
- January 18, 2024
- Lîm Tsú-thuàn
Proposition. Direct sum of subspaces [linear-0006]
- January 18, 2024
- Lîm Tsú-thuàn
Suppose \(U\) and \(W\) are subspaces of \(V\). Then \(U + W\) is a direct sum if and only if \(U \cap W = \{ 0 \}\)
Definition. (co) equalizer [math-002P]
- November 12, 2023
- Lîm Tsú-thuàn
Definition. (co) equalizer [math-002P]
- November 12, 2023
- Lîm Tsú-thuàn
An (co)equalizer is a (co)limit of the diagram
by \(eq(f,g)\) is the limit and \(coeq(f,g)\) is the colimit
Therefore, for two morphisms \(f, g : A \to B\) in a category \(C\), their equalizer (if existed) is an object \(eq(f, g)\) with a morphism \(eq(f, g) \xrightarrow {e} A\), such that \(f \circ e = g \circ e\), and given any \(h : C \to A\) satisfy \(f \circ h = g \circ h\), there is a unique factorization \(k\) let \(h = e \circ k\).
Remark. [#638]
- November 12, 2023
- Lîm Tsú-thuàn
Remark. [#638]
- November 12, 2023
- Lîm Tsú-thuàn
equalizer 是常見的等式類定義的範疇描述
\[\{ x^2 + 1 = 0 \mid x \in \R \}\]此例的 \(f(x) = x^2 + 1\) 而 \(g(x) = 0\)
The dual concept coequalizer is a colimit of same diagram, and hence the coequalizer (if existed) of \(f,g : A\to B\) is an object \(coeq(f,g)\) with a morphism \(c : B \to coeq(f,g)\) such that \(c \circ f = c \circ g\), and any \(h : A \to X\) satisfy \(h \circ f = h \circ g\) can be expressed as \(h = h' \circ c\) via a unique factorization \(h'\).
A factorization, of course, is a morphism.
Remark. [#639]
- November 12, 2023
- Lîm Tsú-thuàn
Remark. [#639]
- November 12, 2023
- Lîm Tsú-thuàn
coequalizer 是在函數局部相似處取值的函數的範疇描述,比如 holomorphic function 在複數平面 \(\mathbb {C}\) 中於 \(a\) 點局部相似就是在 \(|z - a| < r\) 的範圍內兩個 holomorphic functions 的展開式相同,這也被稱為 \(a\) 處此函數的 germs 類。
Proposition. Equalizer is monomorphism [math-002S]
- November 12, 2023
- Lîm Tsú-thuàn
Proposition. Equalizer is monomorphism [math-002S]
- November 12, 2023
- Lîm Tsú-thuàn
If \(E \xrightarrow {e} A\) is an equalizer, then \(e\) is a monomorphism.
Proof. [#635]
- November 12, 2023
- Lîm Tsú-thuàn
Proof. [#635]
- November 12, 2023
- Lîm Tsú-thuàn
If there is any \(f, g : C \to E\), due to \(C \to A\) has a unique \(C \to E\), therefore, \(f = g\) must be true.
Proposition. With binary product and pullback admits equalizer [math-002Q]
- November 12, 2023
- Lîm Tsú-thuàn
Proposition. With binary product and pullback admits equalizer [math-002Q]
- November 12, 2023
- Lîm Tsú-thuàn
A category with binary product and pullback admits equalizer.
Proof. [#637]
- November 12, 2023
- Lîm Tsú-thuàn
Proof. [#637]
- November 12, 2023
- Lîm Tsú-thuàn
We don't have to denote it as \(eq(f,g)\). Anyway, it's a pullback means \[(f,g) \circ e = (1_B, 1_B) \circ e\] , which admits \(f \circ e = g \circ e\).
Proposition. With equalizer, finite product admits all finite limits [math-002R]
- November 12, 2023
- Lîm Tsú-thuàn
Proposition. With equalizer, finite product admits all finite limits [math-002R]
- November 12, 2023
- Lîm Tsú-thuàn
If a category has equalizers and finite products then it has finite limits.
Proof. [#636]
- November 12, 2023
- Lîm Tsú-thuàn
Proof. [#636]
- November 12, 2023
- Lîm Tsú-thuàn
Has all finite products means whatever singular points have a product, and has all equalizers means all multi-arrows has an equalizer, this is indeed all finite limits.
Definition. Categories with attributes [tt-000W]
- November 11, 2023
- Lîm Tsú-thuàn
Definition. Categories with attributes [tt-000W]
- November 11, 2023
- Lîm Tsú-thuàn
A category with attributes consists of:
- A small category \(\mathbb {C}\) with a terminal object \(\diamond \)
- Each object \(\Gamma \) of \(\mathbb {C}\) has a set \(\text {Ty}(\Gamma )\)
- For each \(\Gamma \) and each \(A \in \text {Ty}(\Gamma )\), there is an \(\mathbb {C}\)-object \(\Gamma .A\) and a \(\mathbb {C}\)-morphism \(p_A : \Gamma .A \to \Gamma \)
- For each \(\sigma : \Delta \to \Gamma \) in \(\mathbb {C}\), a function \((-)[\sigma ] : \text {Ty}(\Gamma ) \to \text {Ty}(\Delta )\) and a morphism \(\Delta .A[\sigma ] \xrightarrow {\sigma .A} \Gamma .A\)
- \(A[1_\Gamma ] = A\)
- \(A[\sigma \circ \tau ] = A[\sigma ][\tau ]\) for each \(\Theta \xrightarrow {\tau } \Delta \xrightarrow {\sigma } \Gamma \)
- \((\sigma \circ \tau ).A = (\sigma .A) \circ (\tau .A[\sigma ])\) for each \(\Theta \xrightarrow {\tau } \Delta \xrightarrow {\sigma } \Gamma \)
Collary. Dependent type in categories with attributes [tt-000X]
- November 11, 2023
- Lîm Tsú-thuàn
Collary. Dependent type in categories with attributes [tt-000X]
- November 11, 2023
- Lîm Tsú-thuàn
Depedent types in context \(\Gamma \) are elements of \(\text {Ty}(\Gamma )\); object \(\Gamma .A\) represents the result of extending the context \(\Gamma \) by the type \(A\). Terms \(\Gamma \vdash a : A\) are interpreted as sections of map \[\Gamma .A \xrightarrow {p_A} \Gamma \]
Collary. Rewrite equations to diagrams [tt-000Y]
- November 11, 2023
- Lîm Tsú-thuàn
Collary. Rewrite equations to diagrams [tt-000Y]
- November 11, 2023
- Lîm Tsú-thuàn
Of course, equations can also rewrite to diagrams:
and composition of substituions
Definition. Categories with families [tt-000Z]
- November 11, 2023
- Lîm Tsú-thuàn
Definition. Categories with families [tt-000Z]
- November 11, 2023
- Lîm Tsú-thuàn
Definition. Families [tt-0011]
- November 12, 2023
- Lîm Tsú-thuàn
Definition. Families [tt-0011]
- November 12, 2023
- Lîm Tsú-thuàn
\(\bold {Fam}\) is a category of families of small sets, consists with
- objects: pair \(\langle I, (A_i)_{i\in I} \rangle \), consisting of a set \(I\) and an \(I\)-indexed family of sets \((A_i)_{i\in I}\)
- morphisms: a pair of function \(f : I \to J\) and \(I\)-indexed family of functions \[A_i \xrightarrow {g_i} B_{f(i)}\], denote as \[ \langle f, (g_i)_{i\in I} \rangle : \langle I, (A_i)_{i\in I} \rangle \to \langle J, (B_j)_{j\in J} \rangle \]
A category with families is a category \(\mathbb {C}\) with a distinguished terminal object \(\diamond \), and the following
- A functor \(T : \mathbb {C}^{op} \to \bold {Fam}\), such that \(T(\Gamma ) = \langle \text {Ty}(\Gamma ), \text {Tm}(\Gamma , A)_{A \in \text {Ty}(\Gamma )} \rangle \) and denote \[ \langle A[\sigma ], a[\sigma ] \rangle \text { where } A[\sigma ] \in \text {Ty}(\Delta ) \ \text {and} \ a[\sigma ] \in \text {Tm}(\Delta , A[\sigma ])\] as the result of applying \(T(\sigma : \Delta \to \Gamma )\) to \[\langle A, a \rangle \text { where } A \in \text {Ty}(\Gamma ) \ \text {and} \ a \in \text {Tm}(\Gamma , A)\] , recursively.
- For each \(\Gamma \) and each type \(A \in \text {Ty}(\Gamma )\), there is an \(\mathbb {C}\)-object \(\Gamma .A\), a \(\mathbb {C}\)-morphism \(\Gamma .A \xrightarrow {p_A} \Gamma \) and an element \(q_A \in \text {Ty}(\Gamma .A, A[p_A])\)
such that for any two contexts \(\Gamma \), \(\Delta \) and morphism of them \(\Delta \xrightarrow {\sigma } \Gamma \) satisfy
Collary. Dependent type in categories with families [tt-0010]
- November 12, 2023
- Lîm Tsú-thuàn
Collary. Dependent type in categories with families [tt-0010]
- November 12, 2023
- Lîm Tsú-thuàn
Each element \(A \in \text {Ty}(\Gamma )\) is a dependent type \(\Gamma \vdash A\), and each element \(a \in \text {Tm}(\Gamma , A)\) is a term \(\Gamma \vdash a : A\).
Definition. Initial and terminal (category theory) [math-002F]
- November 3, 2023
- Lîm Tsú-thuàn
Definition. Initial and terminal (category theory) [math-002F]
- November 3, 2023
- Lîm Tsú-thuàn
An object \(I\) of \(\mathbb {C}\) is initial if for any other object \(A\), there is an unique morphism \(I \to A\).
An object \(T\) of \(\mathbb {C}\) is terminal if for any other object \(A\), there is an unique morphism \(A \to T\).
Definition. Internal language of topos (Mitchell-Benabou language) [math-002D]
- November 3, 2023
- Lîm Tsú-thuàn
Definition. Internal language of topos (Mitchell-Benabou language) [math-002D]
- November 3, 2023
- Lîm Tsú-thuàn
Mitchell-Benabou language, also known as internal language of topos, every term can be interpreted as a morphism in the topos (in multiple ways), such that the final target is its type.
- For every object \(A\) of a topos \(\mathbb {C}\) there has an infinite list \(a_0, a_1, ...\) called variables over \(A\), we denote \(a_i.A\) for \(a_i\) is a variable of type \(A\).
- If \(A \xrightarrow {f} B\) is a \(\mathbb {C}\)-morphism, and \(s\) is a term of type \(A\), then \(f\ s\) is a term of type \(B\).
- \(\mathbb {C}\)-morphism \(1 \xrightarrow {c} A\) is considered as a term of type \(A\), we also say such \(c\) is a constant of type \(A\).
- For every term \(s_1\) of type \(A\) and \(s_2\) of type \(B\), there is a term \(\langle s_1, s_2 \rangle \) of type \(A \times B\). Notice that \(\langle s_1, s_2 \rangle \) need not been a morphism.
- For every term \(t\) of type \(B\) and a variable \(a.A\), there is a term \((\lambda a . A) s\) of type \(B^A\).
Definition. Simplicial category (simplex category) \(\Delta \) [math-002G]
- November 3, 2023
- Lîm Tsú-thuàn
Definition. Simplicial category (simplex category) \(\Delta \) [math-002G]
- November 3, 2023
- Lîm Tsú-thuàn
The simplicial category is formed by
- objects: \([n] = (\{0, 1, ..., n\} , \le )\), the finite set is linearly ordered, \(0 \le 1 \le \cdots \le n\).
- morphisms: monotone maps \([m] \to [n]\) such that for every pair \(i, j \in [0, 1, ..., m]\), if \(i \le j\) then \(f(i) \le f(j)\)
we denote this category as \(\Delta \). There are two special maps in \(\Delta \):
Definition. Face map [math-004H]
- December 17, 2023
- Lîm Tsú-thuàn
Definition. Face map [math-004H]
- December 17, 2023
- Lîm Tsú-thuàn
For every \(n \ge 0\) and \(0 \le i \le n\), face maps are the maps
\[d_i : [n-1] \to [n]\]such that uniquely determined by \(i \not \in \text {Im}(d_i)\) and \(d_i\) is injective.
Definition. Degeneracy map [math-004I]
- December 17, 2023
- Lîm Tsú-thuàn
Definition. Degeneracy map [math-004I]
- December 17, 2023
- Lîm Tsú-thuàn
For every \(n \ge 1\) and \(0 \le i \le n-1\), degeneracy maps are the maps
\[s_i : [n] \to [n-1]\]such that uniquely determined by \(|s_i^{-1}(i)| = 2\) and \(s_i\) is surjective.
Remark. [#616]
- December 17, 2023
- Lîm Tsú-thuàn
Remark. [#616]
- December 17, 2023
- Lîm Tsú-thuàn
By definition, we have \(s_i(i) = s_i(i+1) = i\).
Definition. Standard n-simplex (geometrical way to realize simplex category) [math-00EF]
- October 28, 2024
- Lîm Tsú-thuàn
Definition. Standard n-simplex (geometrical way to realize simplex category) [math-00EF]
- October 28, 2024
- Lîm Tsú-thuàn
The standard \(n\)-simplex is the topological space
\[ \text {Simp}_{n} = \{ (x_0, \dots , x_{n-1}) \in [0,1]^n \mid \sum _i x_i = 1 \} \]so \(\text {Simp}_{0}\) is a point, \(\text {Simp}_{1}\) is a line, \(\text {Simp}_{2}\) is a triangle.
Example. [#640]
- November 3, 2023
- Lîm Tsú-thuàn
Example. [#640]
- November 3, 2023
- Lîm Tsú-thuàn
Torus can be realized by functor \(S\)
- \(S[0] = \{ P \}\)
- \(S[1] = \{ l_0,l_1,l_2 \}\)
- \(S[2] = \{ a, b \}\)
The action on the hom-spaces is
- \(S\delta _i(l_j) = p\)
- \(S(\delta _i)(a) = l_i\)
- \(S(\delta _i)(b) = l_{2-i}\)
Definition. Small-complete [math-002E]
- November 3, 2023
- Lîm Tsú-thuàn
Definition. Small-complete [math-002E]
- November 3, 2023
- Lîm Tsú-thuàn
A category \(\mathbb {C}\) is small-complete if for all small category \(\mathbb {S}\), the functor \(\mathbb {S} \to \mathbb {C}\) has a limit. We can narrow it to finite complete.
Definition. Finitely complete category [math-001Z]
- October 29, 2023
- Lîm Tsú-thuàn
Definition. Finitely complete category [math-001Z]
- October 29, 2023
- Lîm Tsú-thuàn
A category \(C\) is finitely complete if it admits all finite limits, that means all limits for any diagrams \(F : J \to C\), where \(J\) is a finite category.
Definition. Left exact functor [math-008K]
- February 7, 2024
- Lîm Tsú-thuàn
Definition. Left exact functor [math-008K]
- February 7, 2024
- Lîm Tsú-thuàn
Let \(A, B\) be two finitely complete categories, a functor \(F : A \to B\) is left exact if it preserves finite limits.
Collary. Closed on composition [#568]
- February 7, 2024
- Lîm Tsú-thuàn
Collary. Closed on composition [#568]
- February 7, 2024
- Lîm Tsú-thuàn
Which means compose two left exact functors will get a left exact functor.
Definition. \(\text {Lex}(A, \bold {Set})\) category [#569]
- February 7, 2024
- Lîm Tsú-thuàn
Definition. \(\text {Lex}(A, \bold {Set})\) category [#569]
- February 7, 2024
- Lîm Tsú-thuàn
The category \(\text {Lex}(A, \bold {Set})\) is a full subcategory of the functor category \([A, \bold {Set}]\), where have only left exact functors.
Definition. Syntactic category (category of contexts) [tt-000R]
- November 3, 2023
- Lîm Tsú-thuàn
Definition. Syntactic category (category of contexts) [tt-000R]
- November 3, 2023
- Lîm Tsú-thuàn
Given a type theory \(T\), a syntactic category \(\text {Con}(T)\) given by
- objects are contexts in the type theory
- morphisms are substitutions between contexts
Let \(\Gamma \) and \(\Delta \) be contexts of a type theory \(T\)
\[ \Gamma = x_0 : A_0, x_1 : A_1(\overrightarrow {x_0}), x_2 : A_2(\overrightarrow {x_{1}}), ..., x_n : A_n(\overrightarrow {x_{n-1}}) \]and
\[ \Delta = y_0 : B_0, y_1 : B_1(\overrightarrow {y_0}), y_2 : B_2(\overrightarrow {y_{1}}), ..., y_m : B_m(\overrightarrow {y_{m-1}}) \]The \(\overrightarrow {x_n}\) notation expanded to \(x_0, ..., x_n\) that represents types can depends on eariler variables. Then a morphism \(\Gamma \to \Delta \) is a sequence of terms
\[\begin {aligned} &\Gamma \vdash \sigma _0 : B_0 \\ &\Gamma \vdash \sigma _1 : B_1(\overrightarrow {\sigma _0}) \\ &... \\ &\Gamma \vdash \sigma _m : B_m(\overrightarrow {\sigma _{m-1}}) \end {aligned}\]So a morphism of contexts is a sequence of terms satisfying requirement of target context \(\Delta \), where we should be able to construct these terms from source context \(\Gamma \). The abbreviation of these terms are \(\sigma = (\sigma _0, ..., \sigma _m)\). For any context with size \(n\), the identity substitution is obvious: its variables \(x_0, ..., x_n\).
Collary. Empty context [tt-000S]
- November 3, 2023
- Lîm Tsú-thuàn
Collary. Empty context [tt-000S]
- November 3, 2023
- Lîm Tsú-thuàn
The empty context is denoted as \(\bullet \), it's the terminal object of the category, this is obvious since only one way to satisfy the empty context: do nothing.
Definition. Closed types and closed terms [tt-000U]
- November 3, 2023
- Lîm Tsú-thuàn
Definition. Closed types and closed terms [tt-000U]
- November 3, 2023
- Lîm Tsú-thuàn
A type \(A\) is closed, if it's derivable from empty context \(\bullet \).
\[\bullet \vdash A \text { type}\]Any closed type can be viewed as a context by concat it back to empty context
\[\bullet , (\_ : A) = (\_ : A)\]by abusing the notation, we also say it's a context \(A\). In this sense, a closed term is a morphism \(\bullet \to A\), where \(A\) is a closed type.
Example. [tt-000T]
- November 3, 2023
- Lîm Tsú-thuàn
Example. [tt-000T]
- November 3, 2023
- Lîm Tsú-thuàn
If a type theory \(T\) has a closed type \(\N \),
\[\bullet \xrightarrow {(1,1)} (m : \N , n : \N ) \xrightarrow {m + n} \N \]the composition above is \(2 : \bullet \to \N \).
Collary. Relation with classifying category [tt-000V]
- November 5, 2023
- Lîm Tsú-thuàn
Collary. Relation with classifying category [tt-000V]
- November 5, 2023
- Lîm Tsú-thuàn
Syntactic category is highly related to classifying categories, which is focusing on type's signature. If we must find a different, classifying categories are not with any fixed judgement rules, so they can be shared by different type theories. In fact, if a classifying category with axioms, denote as \(Cl(\Sigma , \mathcal {A})\), I believe it's the syntactic category here, since a type theory is made by signature and axioms (equation rules).
Definition. Unification [cs-000H]
- November 1, 2023
- Lîm Tsú-thuàn
Definition. Unification [cs-000H]
- November 1, 2023
- Lîm Tsú-thuàn
Unification is an usual operation in logic programming language and type system, for example, one can say "I let a is b" then ask "Is b equals to a?". This is very common thing, in polymorphic type system, we want to avoid type application again and again, especially when it's trivial to find. That's why we have unification algorithm. In polymorphic type system, we want to have a property: If \(A \cong B\), I can use \(A\) as \(B\) and vice versa. Therefore, an unification algorithm will receive a question like:
Is \(\text {List Nat} \cong \text {List } A\)? (In the sense that \(A\) is a type variable.)
By the structural recursion rule, that question can be break down to
If \(\text {Nat} \cong A\), then \(\text {List Nat} \cong \text {List } A\)
By the primitive rule, a variable is similar to anything with the same type. At here, they both have type \(\text {Type}\), so
\[A : \text {Type} \cong \text {Nat} : \text {Type}\]So the unification algorithm will judge they are the same type, users can pass \(\text {List Nat}\) as \(\text {List } a\). However, one must remember, once in a context we already verify an equation
\[A \cong \text {Nat}\]another equation will fail, for example
\[A \cong \text {Bool}\]this is because \(\text {Nat} \ncong \text {Bool}\). So \(f\ a\ b\) is an invalid term under context
\[ \bullet , f : \forall A : A \to A \to A, a : \text {Nat}, b : \text {Bool} \]
Definition. Kernel [math-0025]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Kernel [math-0025]
- October 31, 2023
- Lîm Tsú-thuàn
The kernel of \(\varphi : G \to G'\) is a special kind subgroup of \(G\) such that \[ \text {ker } \varphi \ \dot {=} \ \{ g \in G \mid \varphi (g) = 1_{G'} \} = \varphi ^{-1}(1_{G'}) \]
Proposition. [math-0026]
- October 31, 2023
- Lîm Tsú-thuàn
Proposition. [math-0026]
- October 31, 2023
- Lîm Tsú-thuàn
Let \(\varphi : G \to G'\) be a homomorphism, for any trivial map \(\varphi \circ \alpha \), the inclusion map \(\text {ker }\varphi \) from the kernel to \(G\), below diagram commutes
Proof. [#643]
- October 31, 2023
- Lîm Tsú-thuàn
Proof. [#643]
- October 31, 2023
- Lîm Tsú-thuàn
Lemma. Kernel is normal subgroup [math-0028]
- October 31, 2023
- Lîm Tsú-thuàn
Lemma. Kernel is normal subgroup [math-0028]
- October 31, 2023
- Lîm Tsú-thuàn
The kernel \(\text {ker }\varphi \) is a normal subgroup of \(G\).
Proof. [#641]
- October 31, 2023
- Lîm Tsú-thuàn
Proof. [#641]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Normal subgroup [math-0027]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Normal subgroup [math-0027]
- October 31, 2023
- Lîm Tsú-thuàn
A subgroup \(N\) is a normal subgroup of \(G\) if for all \(g \in G\) and \(n \in N\) the condition holds
\[gng^{-1} \in N\]Another definition: A subgroup \(H\) of a group \(G\) is a normal subgroup if it is self-conjugate.
Remark. [#642]
- October 31, 2023
- Lîm Tsú-thuàn
Remark. [#642]
- October 31, 2023
- Lîm Tsú-thuàn
The relation of left/right-coset corresponding to a subgroup \(H\) coincide if and only if \(H\) is normal.
Lemma. Kernel is normal subgroup [math-0028]
- October 31, 2023
- Lîm Tsú-thuàn
Lemma. Kernel is normal subgroup [math-0028]
- October 31, 2023
- Lîm Tsú-thuàn
The kernel \(\text {ker }\varphi \) is a normal subgroup of \(G\).
Proof. [#641]
- October 31, 2023
- Lîm Tsú-thuàn
Proof. [#641]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Presheaf [math-002C]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Presheaf [math-002C]
- October 31, 2023
- Lîm Tsú-thuàn
A presheaf \(F\) of a small category \(C\) is a functor \(F : C^{op} \to \bold {Sets}\).
- Since they are functors, presheaves form a functor category \(\bold {Sets}^{C^{op}}\), we also denoted \(\bold {Sets}^{C^{op}}\) as \(\widehat C\).
- If replace \(\bold {Sets}\) with \(V\), we also say \(F : C^{op} \to V\) is a \(V\)-valued presheaf.
Collary. Fibre and section [math-002V]
- November 21, 2023
- Lîm Tsú-thuàn
Collary. Fibre and section [math-002V]
- November 21, 2023
- Lîm Tsú-thuàn
The set \(X_a\) via a presheaf \(X\) evaluates at an object \(a\) is sometimes called the fibre, the elements of \(X_a\) thus named sections of \(X\) over \(a\).
Definition. Presheaf on topological space [math-00B2]
- May 8, 2024
- Lîm Tsú-thuàn
Definition. Presheaf on topological space [math-00B2]
- May 8, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology
A elaborated version about presheaf \(\mathcal {F}\) on a topological space \(X\) consists of the following data:
- For every open set \(U\) of \(X\) a set \(\mathcal {F}(U)\).
- For each pair of open sets \(U \subseteq V\) a restriction map \(\text {res}^V_U : \mathcal {F}(V) \to \mathcal {F}(U)\)
such that the following conditions hold:
- \(\text {res}^U_U = 1_{\mathcal {F}(U)}\) for every open set \(U\) of \(X\).
- For \(U \subseteq V \subseteq W\) open sets of \(X\), \[\text {res}^W_U = \text {res}^V_U \circ \text {res}^W_V\]
In this case, we denote the category of presheaves on \(X\) as \(\text {PSh(X)}\).
Notation. [#477]
- May 8, 2024
- Lîm Tsú-thuàn
Notation. [#477]
- May 8, 2024
- Lîm Tsú-thuàn
If \(U \subseteq V\) are open sets of \(X\) and \(s \in \mathcal {F}(V)\) we will usually use \(s \vert _U\) instead of \(\text {res}^V_U(s)\).
Use categorical version [#478]
- May 8, 2024
- Lîm Tsú-thuàn
Use categorical version [#478]
- May 8, 2024
- Lîm Tsú-thuàn
If we consider open sets of \(X\) as a category (morphisms are relation \(U \subseteq V\), denote \(\mathcal {O}(X)\)), then we can apply the categorical definition (Definition [math-002C]Definition [math-002C]).
Definition. Subgroup [math-0029]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Subgroup [math-0029]
- October 31, 2023
- Lîm Tsú-thuàn
A group \(H\) is called a subgroup of \(G\) if there is an inclusion function \(i : H \hookrightarrow G\) is a group homomorphism.
Equivalent, a subgroup \(H\) is a subset of \(G\) containing the unit element, and \(H\) is closed under composition (if \(a,b\in H\) then \(ab\in H\)) and inverse (if \(x \in H\) then \(x^{-1} \in H\)).
Proposition. When a subset is a subgroup [math-0023]
- October 31, 2023
- Lîm Tsú-thuàn
Proposition. When a subset is a subgroup [math-0023]
- October 31, 2023
- Lîm Tsú-thuàn
A nonempty subset \(H\) of a group \(G\) is a subgroup (shares \(G\)'s operation) if and only if
\[\forall a, b \in H, \; ab^{-1} \in H\]
Proof. [#645]
- October 31, 2023
- Lîm Tsú-thuàn
Proof. [#645]
- October 31, 2023
- Lîm Tsú-thuàn
If \(H\) is a subgroup, the element calculus of course closed under \(H\). Now, prove the oppsite that condition hold implies \(H\) is a subgroup. Since \(H\) is nonempty, there is an element \(h \in H\), by condition, we know
\[1_G = hh^{-1} \in H\]thus \(H\) has an identity. Let \(a = 1_G\) and \(b = h\), then we have
\[h^{-1} = 1_Gh^{-1} \in H\]thus \(H\) have inverses of its elements. Let \(a = x\) and \(b = y^{-1}\), get
\[x y = x (y^{-1})^{-1} \in H\]thus \(H\) is closed under the operation. Finally, since \(H\) shares \(G\)'s operation, the associative is preserved, proves \(H\) is a group.
Definition. Kernel [math-0025]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Kernel [math-0025]
- October 31, 2023
- Lîm Tsú-thuàn
The kernel of \(\varphi : G \to G'\) is a special kind subgroup of \(G\) such that \[ \text {ker } \varphi \ \dot {=} \ \{ g \in G \mid \varphi (g) = 1_{G'} \} = \varphi ^{-1}(1_{G'}) \]
Proposition. [math-0026]
- October 31, 2023
- Lîm Tsú-thuàn
Proposition. [math-0026]
- October 31, 2023
- Lîm Tsú-thuàn
Let \(\varphi : G \to G'\) be a homomorphism, for any trivial map \(\varphi \circ \alpha \), the inclusion map \(\text {ker }\varphi \) from the kernel to \(G\), below diagram commutes
Proof. [#643]
- October 31, 2023
- Lîm Tsú-thuàn
Proof. [#643]
- October 31, 2023
- Lîm Tsú-thuàn
Lemma. Kernel is normal subgroup [math-0028]
- October 31, 2023
- Lîm Tsú-thuàn
Lemma. Kernel is normal subgroup [math-0028]
- October 31, 2023
- Lîm Tsú-thuàn
The kernel \(\text {ker }\varphi \) is a normal subgroup of \(G\).
Proof. [#641]
- October 31, 2023
- Lîm Tsú-thuàn
Proof. [#641]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Classifying category (term model) [tt-000O]
- October 29, 2023
- Lîm Tsú-thuàn
Definition. Classifying category (term model) [tt-000O]
- October 29, 2023
- Lîm Tsú-thuàn
Categorical Logic and Type Theory
A classifying category (or term model) \(Cl(\Sigma )\) is a category generated by term calculus on a signature \(\Sigma \).
- objects: variable context \(\Gamma = (v_1 : T_1, ..., v_n : T_n)\)
- morphisms: \(\Gamma \to \Delta \) is a \(m\)-tuples \((M_1, ..., M_m)\) of terms such that we can derive \[\Gamma \vdash M_i : T_i\] where \(\Delta = (v_1 : T_1, ..., v_m : T_m)\)
Identity is ensured by use variables of the context as terms.
Composition
is a \(k\)-tuples \((L_1, ..., L_k)\) defined by simultaneous substitution \[L_i = N_i[M_1/v_1, ..., M_m/v_m]\]
Proposition. Classifying category has finite products [tt-000P]
- October 29, 2023
- Lîm Tsú-thuàn
Proposition. Classifying category has finite products [tt-000P]
- October 29, 2023
- Lîm Tsú-thuàn
For any two contexts \(\Gamma \) and \(\Delta \), the concatenation \(\Gamma , \Delta \) is the product of them.
Definition. Elementary topos (plural topoi) [math-001X]
- October 29, 2023
- Lîm Tsú-thuàn
Definition. Elementary topos (plural topoi) [math-001X]
- October 29, 2023
- Lîm Tsú-thuàn
A topos \(\xi \) is a category with all finite limits, equipped with an object \(\Omega \), and for each \(\xi \)-object \(A\), there is an isomorphism for subobjects of \(A\) and morphisms from \(A \to \Omega \). \[\text {Sub}_{\xi }(A) \cong \text {Hom}_{\xi }(A, \Omega )\] The condition also called well-powered, which ensures \(\Omega \) is a subobject classifier. Then, a functor \(P : \xi ^{op} \to \xi \) with condition \[\text {Hom}_{\xi }(B \times A, \Omega ) \cong \text {Hom}_{\xi }(A, PB)\] This also tells \(PB = \Omega ^B\). Thus, We can also combine them into one axiom. \[\text {Sub}_{\xi }(B \times A) \cong \text {Hom}_{\xi }(A, \Omega ^B)\]
Definition. Another topos definition [math-002J]
- November 4, 2023
- Lîm Tsú-thuàn
Definition. Another topos definition [math-002J]
- November 4, 2023
- Lîm Tsú-thuàn
We can also define topos as a cartesian closed category with a subobject classifier. This version is not that essential but convenience to work with, also
Definition. Models of signature and their category [tt-000Q]
- October 29, 2023
- Lîm Tsú-thuàn
Definition. Models of signature and their category [tt-000Q]
- October 29, 2023
- Lîm Tsú-thuàn
A model of many-typed signature \(\Sigma \) in a category \(B\) with finite products, is a functor \(\mathcal {M}\) from classifying category to \(B\) \[Cl(\Sigma ) \xrightarrow {\mathcal {M}} B\] preserving finite products. The category of \(B\)-models is a subcategory of functor category \([Cl(\Sigma ), B]\) such that objects are models.
Definition. Subobject classifier [math-001Y]
- October 29, 2023
- Lîm Tsú-thuàn
Definition. Subobject classifier [math-001Y]
- October 29, 2023
- Lîm Tsú-thuàn
A subobject classifier in a category \(C\) with finite limits is a monic \(true : 1 \to \Omega \), such that for every monic \(m : S \rightarrowtail A\) there is a unique morphism \(\phi \) forms a pullback square.
By abuse of language, a subobject of \(A\) is an object \(S\) that with a monic \(m : S \rightarrowtail A\), or the monic \(m\). The class of subobjects of \(A\) is \(\text {Sub}_{C}(A)\).
Definition. Category of span [math-001W]
- October 28, 2023
- Lîm Tsú-thuàn
Definition. Category of span [math-001W]
- October 28, 2023
- Lîm Tsú-thuàn
A span is a \(\mathcal {C}\)-diagram \(A \leftarrow C \rightarrow B\), there is a category of span with fixed \(\mathbb {C}\)-objects \(A, B\) is:
- objects: \(A \leftarrow C \rightarrow B\)
- morphisms: given by the below diagram, the red-colored morphism \(h\)
Definition. Product and coproduct (category theory) [math-001V]
- October 28, 2023
- Lîm Tsú-thuàn
Definition. Product and coproduct (category theory) [math-001V]
- October 28, 2023
- Lîm Tsú-thuàn
A product of two \(C\)-object \(a, b\) is an object \(p\) with a pair of morphisms \[a \xleftarrow {\pi _1} p \xrightarrow {\pi _2} b\] , makes below diagram commutes , and the dashed line is unique.
We usually denoted product as \(a \times b\). The dual coproduct is an object \(c\) with a pair of morphisms \[a \xrightarrow {inj_1} c \xleftarrow {inj_2} b\] , makes below diagram commutes , and the dashed line is unique.
We usually denoted coproduct as \(a + b\).
Definition. Category of span [math-001W]
- October 28, 2023
- Lîm Tsú-thuàn
Definition. Category of span [math-001W]
- October 28, 2023
- Lîm Tsú-thuàn
A span is a \(\mathcal {C}\)-diagram \(A \leftarrow C \rightarrow B\), there is a category of span with fixed \(\mathbb {C}\)-objects \(A, B\) is:
- objects: \(A \leftarrow C \rightarrow B\)
- morphisms: given by the below diagram, the red-colored morphism \(h\)
Definition. Functor [math-001T]
- October 27, 2023
- Lîm Tsú-thuàn
Definition. Functor [math-001T]
- October 27, 2023
- Lîm Tsú-thuàn
A functor \(F : C \to D\) is a map from category \(C\) to category \(D\), such that
- assigns each object \(c \in C\) an object \(F(c) \in D\),
- assigns each morphism \(f\) in \(C\) a morphism \(F(f)\) in \(D\).
- preserves identity \(F(1_c) = 1_{F(c)}\)
- preserves composition of morphisms \(F(a \circ b) = F(a) \circ F(b)\)
Collary. Endofunctor [math-002A]
- October 27, 2023
- Lîm Tsú-thuàn
Collary. Endofunctor [math-002A]
- October 27, 2023
- Lîm Tsú-thuàn
\(C \to C\) functor is called endofunctor.
Definition. Presheaf [math-002C]
- October 31, 2023
- Lîm Tsú-thuàn
Definition. Presheaf [math-002C]
- October 31, 2023
- Lîm Tsú-thuàn
A presheaf \(F\) of a small category \(C\) is a functor \(F : C^{op} \to \bold {Sets}\).
- Since they are functors, presheaves form a functor category \(\bold {Sets}^{C^{op}}\), we also denoted \(\bold {Sets}^{C^{op}}\) as \(\widehat C\).
- If replace \(\bold {Sets}\) with \(V\), we also say \(F : C^{op} \to V\) is a \(V\)-valued presheaf.
Collary. Fibre and section [math-002V]
- November 21, 2023
- Lîm Tsú-thuàn
Collary. Fibre and section [math-002V]
- November 21, 2023
- Lîm Tsú-thuàn
The set \(X_a\) via a presheaf \(X\) evaluates at an object \(a\) is sometimes called the fibre, the elements of \(X_a\) thus named sections of \(X\) over \(a\).
Definition. Presheaf on topological space [math-00B2]
- May 8, 2024
- Lîm Tsú-thuàn
Definition. Presheaf on topological space [math-00B2]
- May 8, 2024
- Lîm Tsú-thuàn
Manifolds, Sheaves, and Cohomology
A elaborated version about presheaf \(\mathcal {F}\) on a topological space \(X\) consists of the following data:
- For every open set \(U\) of \(X\) a set \(\mathcal {F}(U)\).
- For each pair of open sets \(U \subseteq V\) a restriction map \(\text {res}^V_U : \mathcal {F}(V) \to \mathcal {F}(U)\)
such that the following conditions hold:
- \(\text {res}^U_U = 1_{\mathcal {F}(U)}\) for every open set \(U\) of \(X\).
- For \(U \subseteq V \subseteq W\) open sets of \(X\), \[\text {res}^W_U = \text {res}^V_U \circ \text {res}^W_V\]
In this case, we denote the category of presheaves on \(X\) as \(\text {PSh(X)}\).
Notation. [#477]
- May 8, 2024
- Lîm Tsú-thuàn
Notation. [#477]
- May 8, 2024
- Lîm Tsú-thuàn
If \(U \subseteq V\) are open sets of \(X\) and \(s \in \mathcal {F}(V)\) we will usually use \(s \vert _U\) instead of \(\text {res}^V_U(s)\).
Use categorical version [#478]
- May 8, 2024
- Lîm Tsú-thuàn
Use categorical version [#478]
- May 8, 2024
- Lîm Tsú-thuàn
If we consider open sets of \(X\) as a category (morphisms are relation \(U \subseteq V\), denote \(\mathcal {O}(X)\)), then we can apply the categorical definition (Definition [math-002C]Definition [math-002C]).
Definition. Weakly initial [math-001U]
- October 27, 2023
- Lîm Tsú-thuàn
Definition. Weakly initial [math-001U]
- October 27, 2023
- Lîm Tsú-thuàn
An object \(x\) is weakly initial if for every other object \(y\) there is a morphism \(x \to y\).
Definition. Initial algebra [math-001O]
- October 24, 2023
- Lîm Tsú-thuàn
Definition. Initial algebra [math-001O]
- October 24, 2023
- Lîm Tsú-thuàn
A F-algebra \((F, i, j)\) is an initial algebra if and only if \(F\ i\) is an initial object of the category of F-algebras.
Derive Y combinator [cs-000D]
- October 23, 2023
- Lîm Tsú-thuàn
Derive Y combinator [cs-000D]
- October 23, 2023
- Lîm Tsú-thuàn
Consider \(F\) is a fixed point we are seeking, then \[F' = \lambda f. F(f \; f)\] is a variant version of \(F\), by \(f \; f = f\) and \(F \; x = x\) we believing. Now, using substitution we can obtain \(F' F' = F(F' F')\), which means \(F' F'\) is the fixed point of \(F\). Therefore, we derived \[(\lambda f. F(f \; f)) (\lambda f. F(f \; f))\] and the Y combinator is \[\lambda F. (\lambda f. F(f \; f)) (\lambda f. F(f \; f))\]
Proposition. Preserve finite order [math-001H]
- October 23, 2023
- Lîm Tsú-thuàn
Proposition. Preserve finite order [math-001H]
- October 23, 2023
- Lîm Tsú-thuàn
If \(g \in G\) is an element of finite order, and \(\varphi : G \to H\) is a homomorphism, then \( | \varphi (g) | \) divides \(|g|\).
Proof. [#650]
- October 23, 2023
- Lîm Tsú-thuàn
Proof. [#650]
- October 23, 2023
- Lîm Tsú-thuàn
Definition. Hausdorff space (\(T_2\) space) [math-001D]
- October 22, 2023
- Lîm Tsú-thuàn
Definition. Hausdorff space (\(T_2\) space) [math-001D]
- October 22, 2023
- Lîm Tsú-thuàn
A space \(X\) is Hausdorff if and only if for every two points \(x, y \in X\) (where \(x \ne y\)), there exist disjoint open sets \(U\) and \(V\) with \(x \in U\) and \(y \in V\).
Example. Metric spaces are Hausdorff [math-001E]
- October 22, 2023
- Lîm Tsú-thuàn
Example. Metric spaces are Hausdorff [math-001E]
- October 22, 2023
- Lîm Tsú-thuàn
Let \(x, y\) be different points (\(x \ne y\)) in a metric space, we will get a distance \(d(x, y) > 0\), then we can see two open balls \(B_\epsilon (x)\) and \(B_\epsilon (y)\) (where \(\epsilon \le \frac {d(x,y)}{2}\)) are indeed disjoint.
Definition. Category \(\text {Grp}\) [math-0019]
- October 19, 2023
- Lîm Tsú-thuàn
Definition. Category \(\text {Grp}\) [math-0019]
- October 19, 2023
- Lîm Tsú-thuàn
The category \(\text {Grp}\)'s objects are formed by all groups, and morphisms are group homomorphism.
Definition. Group homomorphism [math-0018]
- October 19, 2023
- Lîm Tsú-thuàn
Definition. Group homomorphism [math-0018]
- October 19, 2023
- Lîm Tsú-thuàn
考慮群 \(G\) 到群 \(H\) 的變換 \[\varphi : (G, m_G) \to (H, m_H)\] 時,除了這必然是個映射底層集合 \(G \to H\) 的函數之外,還希望能夠考慮到 \(m_G\) 的行為被保留。因此,將 group homomorphism 定義成滿足下圖交換的函數 \(\varphi \)
傳統寫法是 \(\varphi : G \to H\) 對所有 \(a, b \in G\) 須滿足 \(\varphi (a \cdot b) = \varphi (a) \cdot \varphi (b)\)
但為什麼這也能保證 unit 跟 inverse 也會被保留呢?想知道的人可以參考命題。
- 如果 \(g \circ f\) 跟 \(f \circ g\) 都是 identity homomorphism 則 \(f,g\) 都是 isomorphism \(G \cong G'\)
- 如果 \(G = G'\) 則 isomorphism 加強成 automorphism
- 如果 \(f : G \to G\) 則稱 \(f\) 為 endomorphism
Proposition. The unit and inverse are preserved via group homomorphism [math-001A]
- October 19, 2023
- Lîm Tsú-thuàn
Proposition. The unit and inverse are preserved via group homomorphism [math-001A]
- October 19, 2023
- Lîm Tsú-thuàn
The statement can be expressed as: Let \(\varphi : G \to H\) be a group homomorphism, then
- \(\varphi (1_G) = 1_H\)
- and \(\forall g \in G, \varphi (g^{-1}) = \varphi (g)^{-1}\).
Proof. [#653]
- October 19, 2023
- Lîm Tsú-thuàn
Proof. [#653]
- October 19, 2023
- Lîm Tsú-thuàn
For the first property, we use \[1_H \cdot \varphi (1_G) = \varphi (1_G) = \varphi (1_G \cdot 1_G) = \varphi (1_G) \cdot \varphi (1_G)\] as the lemma, by cancel \(\varphi (1_G)\) we get \(1_H = \varphi (1_G)\).
For the second part, we use \[ \varphi (a) \cdot \varphi (a)^{-1} = 1 = \varphi (1) = \varphi (a \cdot a^{-1}) = \varphi (a) \cdot \varphi (a^{-1}) \] as the lemma, by cancel \(\varphi (a)\) we get \(\varphi (a)^{-1} = \varphi (a^{-1})\).
Formalization. [#654]
- October 19, 2023
- Lîm Tsú-thuàn
Formalization. [#654]
- October 19, 2023
- Lîm Tsú-thuàn
import Mathlib.Algebra.Group.Defs import Mathlib.Algebra.Hom.Group.Defs
Before we start to prove the proposition, we have to define is_hom
for what's a homomorphism
def is_hom [Group G] [Group H] [MulHomClass F G H] (φ : F) : Prop := ∀ a b : G, φ (a * b) = φ (a) * φ (b)
Then below code proves the proposition
theorem preserve_identity [Group G] [Group H] [MulHomClass F G H] (φ : F) : is_hom φ → 1 = φ 1 := by intro H have inner_one : φ 1 = φ (1 * 1) := by refine Eq.symm (FunLike.congr_arg φ ?h₂) exact one_mul 1 have lem : 1 * φ 1 = φ 1 * φ 1 := by rw [one_mul <| φ 1, ← H] exact inner_one apply mul_right_cancel (a := 1) (b := φ 1) (c := φ 1) lem
theorem preserve_inv [Group G] [Group H] [MulHomClass F G H] (φ : F) : is_hom φ → ∀ a : G, (φ a)⁻¹ = φ a⁻¹ := by intro H a have lem : φ a * (φ a)⁻¹ = φ a * φ a⁻¹ := by refine Iff.mpr mul_left_cancel_iff ?_ refine DivisionMonoid.inv_eq_of_mul (φ a) (φ a⁻¹) ?_ rw [← H, mul_right_inv a] exact Eq.symm (preserve_identity φ H) exact mul_left_cancel (a := φ a) (b := (φ a)⁻¹) (c := φ a⁻¹) lem
量子位元基本運算 [cs-000C]
- October 18, 2023
- Lîm Tsú-thuàn
量子位元基本運算 [cs-000C]
- October 18, 2023
- Lîm Tsú-thuàn
- 第一種運算是 NOT \(\oplus \),會把量子位元中的左 \(|0\rangle \) 與右 \(|1\rangle \) 互換
- 第二種運算 HAD \(\fbox {H}\) 會把疊加態均分,但在初始為偏右時會旋轉右的相位。另外,與 NOT 相同的是套用兩次同樣會回到原本的狀態
Nix 指令更新 [software-0009]
- October 11, 2023
- Lîm Tsú-thuàn
Nix 指令更新 [software-0009]
- October 11, 2023
- Lîm Tsú-thuàn
安裝指令 nix profile install <package name>
取代了 nix-env -iA <package name>
Definition. Point surjective [math-0014]
- October 11, 2023
- Lîm Tsú-thuàn
Definition. Point surjective [math-0014]
- October 11, 2023
- Lîm Tsú-thuàn
A morphism \(A \xrightarrow {\phi } B\) is point-surjective iff for every point \(1 \xrightarrow {q} B\), there exists a point \(1 \xrightarrow {p} A\) that lifts \(q\) (satisfy \(\phi \circ p = q\)).
Proof search in Lean4 [software-000A]
- October 11, 2023
- Lîm Tsú-thuàn
- https://proofassistants.stackexchange.com/a/415/302
Proof search in Lean4 [software-000A]
- October 11, 2023
- Lîm Tsú-thuàn
- https://proofassistants.stackexchange.com/a/415/302
With below line in Lean prover
import Mathlib.Tactic.Observe
One can use exact?
, apply?
tactics to search in Lean4 library.
Definition. Weakly point surjective [math-0015]
- October 11, 2023
- Lîm Tsú-thuàn
Definition. Weakly point surjective [math-0015]
- October 11, 2023
- Lîm Tsú-thuàn
A morphism \(\phi : B \to C^A\) is weakly point surjective, iff for every \(A \xrightarrow {f} C\) there is \(1 \xrightarrow {x} B\) such that for every \(1 \xrightarrow {a} A\), we have commute diagram
The \(C^A \to C^A \times A\) is given by
This is a weaker version of point-surjective.
Lazy lambda calculus reduction model & computation resource [cs-0006]
Lazy lambda calculus reduction model & computation resource [cs-0006]
The algebra of term constructors [cs-0007]
- October 10, 2023
- Lîm Tsú-thuàn
The algebra of term constructors [cs-0007]
- October 10, 2023
- Lîm Tsú-thuàn
A functor \(LC : Set \to Set\) takes any set of variables \(V\) to the set of term \(T = LC(V)\), this is the term constructors' algebra. \[ \begin {aligned} &- : &V \to T \quad &\text {mbox variable} \\ &-(-) : &T \times T \to T \quad &\text {mbox abstraction} \\ &\lambda : &V \times T \to T \quad &\text {mbox application} \\ \end {aligned} \]
Infinite loop [cs-0008]
- October 10, 2023
- Lîm Tsú-thuàn
Infinite loop [cs-0008]
- October 10, 2023
- Lîm Tsú-thuàn
Consider \[\Omega = \omega (\omega )\] where \(\omega = \lambda x. x(x)\), it's easier to verify \(\Omega \downarrow _{\beta } \Omega \), an infinite loop. Now think about \[(\lambda x. \lambda y. x)(\lambda x. x)(\Omega )\], this example is interesting if we consider eager/lazy semantic. In the eager semantic, the result is stuck due to \(\Omega \), because we calculate \(\Omega \) before we use it as an argument. In the lazy semantic, the result is identity function \(\lambda x.x\).
The idea of the post [cs-0009]
- October 10, 2023
- Lîm Tsú-thuàn
The idea of the post [cs-0009]
- October 10, 2023
- Lîm Tsú-thuàn
The key point of the post is about: when \(\beta \)-reduction can happend anywhere in the term, there are too many 2-morphisms to model lazy lambda calculus. Therefore, the post suggests introducing reduction context \[[-] : T \to T\] into the algebra above, for marking where we can do \(\beta \)-reduction. The new rules are
- Propagates the reduction context to the head position of the term. \[[t(t')] \downarrow _{\text {ctx}} [[t] (t')]\]
- Restrict \(\beta \)-reduction to a reduciton context. \[ [[\lambda x. t] (t')] \downarrow _{\beta } [t] \{t'/ x\} \]
Reuse the idea to control computation [cs-000A]
- October 10, 2023
- Lîm Tsú-thuàn
Reuse the idea to control computation [cs-000A]
- October 10, 2023
- Lîm Tsú-thuàn
The post also suggests if we replace rule \[[t(t')] \downarrow _{\text {ctx}} [[t] (t')]\] with \[[t(t')] \downarrow _{\text {ctx}} [t] (t')\] the number of occurences of \([ - ]\) will never increase. Then \([[ \cdots [t] \cdots ] ]\) the number of \(\beta \)-reductions are bound. In the paper, they reuse this way to represent a processor or computer in a network.
Below implements a part of the system.
inductive Tm : Type where | var : String → Tm | app : Tm → Tm → Tm | lam : String → Tm → Tm | ctx : Tm → Tm def Tm.subst (t : Tm) (s : Tm) (x : String) : Tm := match t with | .var y => if x == y then s else .var y | .app t u => .app (t.subst s x) (u.subst s x) | .lam y b => if x == y then .lam y b else .lam y (b.subst s x) | .ctx t => .ctx (t.subst s x) def Tm.r : Tm → Tm | .ctx (.app t t') => .ctx (.app (.ctx t |> r) t') | t => t def Tm.β : Tm → Tm | .ctx (.app (.ctx (.lam x t)) t') => subst (.ctx t) t' x | .ctx t => .ctx (t.β) | .app t t' => .app t.β t' | t => t def ω : Tm := .lam "x" (.app (.var "x") (.var "x")) def Ω : Tm := (.app ω ω) def e : Tm := (.ctx (.app (.app (.lam "x" (.lam "y" (.var "x"))) (.lam "x" (.var "x"))) Ω)) #eval e #eval e.r #eval e.r.β #eval e.r.β.β
用 quarto 產出 reveal.js 簡報 [software-0008]
- October 10, 2023
- Lîm Tsú-thuàn
用 quarto 產出 reveal.js 簡報 [software-0008]
- October 10, 2023
- Lîm Tsú-thuàn
Quarto 這個工具有相當多功能,我只是想要移植以往放在 hackmd 上的簡報,因為簡報使用了 graphviz 的功能,所以我沒有辦法像 hami2023 那樣直接嵌入這個網站裡面,至少 reveal.js 內建的功能沒辦法如此。而 quarto render
產生的網頁也一樣有問題,所以最後 type cafe2023 跟 hami2022 還是放到了獨立的專案之中,用 GitHub Pages 運作。這篇筆記因而誕生,首先要用
quarto create-project <name>
產生一個專案,接著就能進去改檔案了。在 <name>.qmd
裡面安插
title: "XXX" author: "your name" format: revealjs
也可以更進一步的設定 reveal.js 的選項
format: revealjs: theme: dark
接著可以用 quarto preview
觀察簡報的狀態。對於我需要的 graphviz 功能,可以在檔案中寫下
```{dot} graph G { layout=neato run -- intr; intr -- runbl; runbl -- run; run -- kernel; kernel -- zombie; kernel -- sleep; kernel -- runmem; sleep -- swap; swap -- runswap; runswap -- new; runswap -- runmem; new -- runmem; sleep -- runmem; } ```
最後,下列指令就可以自動發布 GitHub Pages 了(要先確認 git remote origin
連結到的專案確實能發佈 Pages)。
quarto publish gh-pages
Proof Net 雜記 [math-000X]
- October 5, 2023
- Lîm Tsú-thuàn
Proof Net 雜記 [math-000X]
- October 5, 2023
- Lîm Tsú-thuàn
Proof net 是 Girard 的 linear logic 引入的一種新語法,用圖去表現證明,在研究 cut-elimination 時更加方便。
Parametricity properties [tt-000I]
- October 5, 2023
- Lîm Tsú-thuàn
Parametricity properties [tt-000I]
- October 5, 2023
- Lîm Tsú-thuàn
Polymorphic type in System F severely constrain the behavior of their elements. For example, if \(i : \forall (t.t \to t)\), then the definition can only be \(i = \lambda x.x\).
Similarly, there only have two terms, \[\Lambda t. \lambda x : t. \lambda y : t. x\] and \[\Lambda t. \lambda x : t. \lambda y : t. y\] with type \(\forall (t.t\to t\to t)\).
Such thing that, properties of a program in System F can be knowing by type known as parametricity properties.
Git send-email 的設定 [software-0005]
- October 1, 2023
- Lîm Tsú-thuàn
Git send-email 的設定 [software-0005]
- October 1, 2023
- Lîm Tsú-thuàn
I use gmail, and hence, I need to get a Google app password. After having the password, one has to setup ~/.gitconfig
with content:
[sendemail] smtpEncryption = tls smtpServer = smtp.gmail.com smtpUser = <your id>@gmail.com smtpServerPort = 587 smtpPass = <your password>
Then you are able to use git send-email
command:
git switch -c branch-patch git format-patch main git send-email 0001-***********.patch
prompt will ask some questions, an important one is which mailing list is your target? After command success, your patch are sent.
For certain git repository you're working on, can config local repository via git config --edit
, and add below to omit email list in command line.
[sendemail] to = <target email list>
Theorem. Turing halting [cs-0005]
- September 29, 2023
- Lîm Tsú-thuàn
Theorem. Turing halting [cs-0005]
- September 29, 2023
- Lîm Tsú-thuàn
Compactness and Contradiction
Let \(P\) be a program that takes a string \(S\) as input, returns a yes-no answer \(P(S)\) as output, and which always halts in finite time. Then there exists a string \(G\) that is a program with no input, such that if \(P\) is given \(G\) as input, then \(P\) does not determine correctly whether \(G\) halts in finite time.
Proof. [#673]
- September 29, 2023
- Lîm Tsú-thuàn
Proof. [#673]
- September 29, 2023
- Lîm Tsú-thuàn
- If \(R\) is not a program that takes a string as input, it halts.
- Otherwise, if runs \(P\) with input \(R(R)\) (which is a program with no inpupt).
- If \(P(R(R))\) returns no, it halts, while if \(P(R(R))\) returns yes, it runs forever.
Lemma. Zorn's [math-000T]
- September 29, 2023
- Lîm Tsú-thuàn
Lemma. Zorn's [math-000T]
- September 29, 2023
- Lîm Tsú-thuàn
From Compactness and Contradiction
Let \(C\) be a partially ordered class with
- At least one element belongs to \(C\)
- If \(x \in C\), then there is \(y \in C\) such that \(y > x\)
- If \((x_\beta )_{\beta \in B}\) is a totally ordered set in \(C\), indexed by another set \(B\), then there exists an upper bound \(y \in C\) such that \(y \ge x_\beta \) for all \(\beta \in B\)
- This lemma is equivalent to axiom of choice.
Proposition. Busy beaver function [cs-0004]
- September 27, 2023
- Lîm Tsú-thuàn
Proposition. Busy beaver function [cs-0004]
- September 27, 2023
- Lîm Tsú-thuàn
Compactness and Contradiction
Let \(f : \N \to \N \) be a computable function. Then there exists a natural number \(n\) and a program \(G\) of length \(n\) (taking no input) that halts in finite time, but requires more than \(f(n)\) steps before it halts.
Proof. [#674]
- September 27, 2023
- Lîm Tsú-thuàn
Proof. [#674]
- September 27, 2023
- Lîm Tsú-thuàn
Definition. Slice & Coslice category [math-0004]
- September 26, 2023
- Lîm Tsú-thuàn
Definition. Slice & Coslice category [math-0004]
- September 26, 2023
- Lîm Tsú-thuàn
For a category \(C\) and an object \(x \in C\), there is a slice category \(C/x\) and a coslice category \(x/C\) (dual concept).
\(C/x\)-objects are all \(C\)-morphisms where target is \(x\), \(C/x\)-morphisms are all \(C\)-morphism \(g\) where makes the following diagram commutes:
\(x/C\)-objects is dual, they are \(C\)-morphisms where source is \(x\).
Proposition. \((a, id_a)\) is terminal of \(A/a\) [math-001F]
- February 24, 2023
- Lîm Tsú-thuàn
Proposition. \((a, id_a)\) is terminal of \(A/a\) [math-001F]
- February 24, 2023
- Lîm Tsú-thuàn
It's easy to prove the statement by checking the following diagram is commute.
or we can also reduce the diagram to
Draw a \(A/a\) diagram makes it clear, the following relationship stands for every proper \(b\) in \(A\).
Proposition. Any \(f : a \to a'\) in \(A\) gives functor \(f_* : A/a \to A/a'\) [math-001G]
- February 24, 2023
- Lîm Tsú-thuàn
Proposition. Any \(f : a \to a'\) in \(A\) gives functor \(f_* : A/a \to A/a'\) [math-001G]
- February 24, 2023
- Lîm Tsú-thuàn
The functor \(f_*\) takes any object \(g : b \to a\) of \(A/a\) to \(f \circ g\) of \(A/b\).
The first point is realizing if such \(f\) existed, then we have same two \(b, b'\), for both \(a, a'\), by concating \(f\) after every \(b \to a\) morphism. This makes sure we will have if objects existed in \(A/a\) so do in \(A/a'\), remember functor no need to cover \(A/a'\). Now, we can have the proof diagram:
Convert it to a functor diagram will help.
Example. \(\bold {Sets}/I\) [math-000S]
- September 11, 2023
- Lîm Tsú-thuàn
Example. \(\bold {Sets}/I\) [math-000S]
- September 11, 2023
- Lîm Tsú-thuàn
The \(\bold {Sets}/I\) is a category with
- objects families \((X \xrightarrow {\varphi } I)\)
- morphisms \((X \xrightarrow {\varphi } I) \xrightarrow {f} (Y \xrightarrow {\psi } I)\) are functions \(f : X \to Y\) making the following diagram commutes:
Collary. Slice of sets is set-valued functor [math-002B]
- October 31, 2023
- Lîm Tsú-thuàn
Collary. Slice of sets is set-valued functor [math-002B]
- October 31, 2023
- Lîm Tsú-thuàn
Combine with topos fundamental theorem, the category of presheaves is a topos.
Definition. Functor category [math-000P]
- September 26, 2023
- Lîm Tsú-thuàn
Definition. Functor category [math-000P]
- September 26, 2023
- Lîm Tsú-thuàn
For any two categories \(C, D\), their functors and natural tranformations form a category, denotes \([C, D]\) or \(D^C\).
- The objects are functors with type \(C \to D\).
- The morphisms are natural tranformations for functors.
Lemma. Size of functor categories [math-000N]
- September 26, 2023
- Lîm Tsú-thuàn
Lemma. Size of functor categories [math-000N]
- September 26, 2023
- Lîm Tsú-thuàn
- If category \(C\) is small and \(D\) is locally small, then functor category \([C, D]\) is locally small.
- If category \(C\) and \(D\) are locally small, then \([C, D]\) need not be locally small.
Theorem. \((A \iff (A \to B)) \to B\) [tt-000H]
- September 24, 2023
- Lîm Tsú-thuàn
- https://mathstodon.xyz/@MartinEscardo/111115846596114122
Theorem. \((A \iff (A \to B)) \to B\) [tt-000H]
- September 24, 2023
- Lîm Tsú-thuàn
- https://mathstodon.xyz/@MartinEscardo/111115846596114122
Here is a proof in Lean4.
variable (A B : Prop) theorem h (a : A ↔ (A → B)) : B := match a with | ⟨f, g⟩ => f (g (λ a => f a a)) (g (λ a => f a a))
Go 的 interface [tt-000D]
- September 23, 2023
- Lîm Tsú-thuàn
Go 的 interface [tt-000D]
- September 23, 2023
- Lîm Tsú-thuàn
Go 語言的 interface,範例如下
type Abser interface { Abs() float64 }
其中的 Abs() float64
可以被改寫成抽象語法 Abs : () -> float64
。因此一個 interface \(A\) 有一組與其關聯的一系列簽名 \(\hat P\)。並且,對 Go 而言下列的兩個 interface 並沒有差異
type A interface { F(C) D } type B interface { F(C) D }
因此我們可以更進一步認為 Go 的一個 interface \(A\) 可以完全由其簽名 \(\hat P\) 替換。
Definition. Group by Category [math-000L]
- September 23, 2023
- Lîm Tsú-thuàn
Definition. Group by Category [math-000L]
- September 23, 2023
- Lîm Tsú-thuàn
If a small category \(\mathcal {C}\) has only one object, and each morphism is an isomorphism, then there is a group detected by the category.
Category \(\mathcal {C}\) | Group \(G\) |
---|---|
morphisms in \(\mathcal {C}\) | elements of the group |
composition of morphism | The binary operation of the group |
identity morphism of the only object | identity element of the group |
Java 的 interface 與 bounded polymorphism (bounded quantification) [tt-000E]
- September 23, 2023
- Lîm Tsú-thuàn
Java 的 interface 與 bounded polymorphism (bounded quantification) [tt-000E]
- September 23, 2023
- Lîm Tsú-thuàn
在 Java 之中可以定義 interface,範例如下
interface Comparable<T> { int compareTo(T other); }
相較於 Go 中不用明確宣告,在 Java 中實現 interface I
需要寫成 class T extends I
,因此雖然 Java 的 interface \(A\) 也有其相關的一組簽名 \(\hat P\),但兩個有同樣簽名 \(\hat P\) 的 interface 不是同一個型別。
而在 Java 中 bounded polymorphism 指的是以下的 interface 使用方法:
<S extends Comparable> S min(S a, S b)
這會使得沒有明確宣告實現 Comparable
的型別無法被傳為 min
的引數。
Definition. Partial order [math-000K]
- September 23, 2023
- Lîm Tsú-thuàn
Definition. Partial order [math-000K]
- September 23, 2023
- Lîm Tsú-thuàn
Definition. Usual [#266]
- September 23, 2023
- Lîm Tsú-thuàn
Definition. Usual [#266]
- September 23, 2023
- Lîm Tsú-thuàn
A partial order is a preorder such that anti-symmetric, which means if \(A \le B\) and \(B \le A\), then \(A = B\).
Definition. As category [#267]
- September 23, 2023
- Lîm Tsú-thuàn
Definition. As category [#267]
- September 23, 2023
- Lîm Tsú-thuàn
A category version is a preorder such that each isomorphism is identical (equality).
Definition. Preorder [math-000J]
- September 23, 2023
- Lîm Tsú-thuàn
Definition. Preorder [math-000J]
- September 23, 2023
- Lîm Tsú-thuàn
We usual define a preorder is a set \(X\) with a binary relation \(\le \), where the relation is reflexive and transitive.
Every preorder can also be viewed as a small category, where all composition morphism of \(A \to B\) and \(B \to C\) is the unique morphism \(A \to C\). Or we say there is at most one morphism from one object to another.
結成浩的費馬最後定理玩笑 [math-000M]
- September 23, 2023
- Lîm Tsú-thuàn
結成浩的費馬最後定理玩笑 [math-000M]
- September 23, 2023
- Lîm Tsú-thuàn
#lang rhombus operator n^m: ~stronger_than: + math.expt(n, m)
951413^7 + 853562^7 = 1035740599994317978862520154990926528420925
1005025^7 = 1035709726461858968099232282235113525390625
Find command [software-0002]
- September 18, 2023
- Lîm Tsú-thuàn
Find command [software-0002]
- September 18, 2023
- Lîm Tsú-thuàn
For example, one can cd /usr/local
and search simdjson library related files
find . -name 'simdjson*'
Definition. \(\omega \)-chain [math-000H]
- September 17, 2023
- Lîm Tsú-thuàn
Definition. \(\omega \)-chain [math-000H]
- September 17, 2023
- Lîm Tsú-thuàn
A \(\omega \)-chain \((x_n)_{n\in \omega }\) in partial order \(D\) is a set of elements \(x_n \in D\) such that \(x_n \sqsubseteq x_m\) whenever \(n \le m\). A partial order \(D\) is \(\omega \)-complete (and hance an \(\omega \)-cpo) if every \(\omega \)-chain has a least upper bound. Given \(\omega \)-cpo's \(D\) and \(E\), a monotone function \(f : D \to E\) is said to be \(\omega \)-continuous if
\[ f(\bigsqcup _{n\in \omega } x_n) = \bigsqcup _{n\in \omega } f(x_n) \]for any \(\omega \)-chain \((x_n)_{n\in \omega }\).
Remark. [#661]
- September 17, 2023
- Lîm Tsú-thuàn
Remark. [#661]
- September 17, 2023
- Lîm Tsú-thuàn
\(\omega \)-chain preserves it's least upper bound with \(\omega \)-continuous function.
Theorem. Fixed Points in \(\omega \)-Cpo's [math-000I]
- September 17, 2023
- Lîm Tsú-thuàn
Theorem. Fixed Points in \(\omega \)-Cpo's [math-000I]
- September 17, 2023
- Lîm Tsú-thuàn
Suppose \(D\) is \(\omega \)-cpo and \(f : D \to D\) is \(\omega \)-continuous. For \(x \in D\) such that \(x \sqsubseteq f(x)\), there is a least element \(y \in D\) such that
- \(y = f(y)\), and
- \(y \sqsubseteq z\) for any fixed point \(z \in D\) such that bigger than \(x\) (\(x \sqsubseteq z\))
Theorem. Fixed Point [math-000F]
- September 17, 2023
- Lîm Tsú-thuàn
Theorem. Fixed Point [math-000F]
- September 17, 2023
- Lîm Tsú-thuàn
If \(D\) is a pointed cpo and \(f : D \to D\) is continuous, then it has a least fixed point \(\text {fix}(f) \in D\) that satisfied
- \(\text {fix}(f) = f(\text {fix}(f))\), and
- \(\text {fix}(f) \sqsubseteq x\) for any fixed point \(x \in D\) (A fixed point means \(x = f(x)\)).
Theorem. Generalized Fixed Point [math-003W]
- December 9, 2023
- Lîm Tsú-thuàn
Theorem. Generalized Fixed Point [math-003W]
- December 9, 2023
- Lîm Tsú-thuàn
Functors and Type Refinement system [tt-000C]
- September 17, 2023
- Lîm Tsú-thuàn
Functors and Type Refinement system [tt-000C]
- September 17, 2023
- Lîm Tsú-thuàn
Lean4's Vector [tt-000B]
- September 17, 2023
- Lîm Tsú-thuàn
Lean4's Vector [tt-000B]
- September 17, 2023
- Lîm Tsú-thuàn
Instead of usual definition, the Vector
in Lean Prover is based on subtype.
def Vector (α : Type u) (n : ℕ) := { l : List α // l.length = n }
Rhombus: definition of function [cs-0002]
- September 17, 2023
- Lîm Tsú-thuàn
Rhombus: definition of function [cs-0002]
- September 17, 2023
- Lîm Tsú-thuàn
Three ways of writing factorial
fun factorial(x): match x | 0: 1 | n: n * factorial(n-1) fun | factorial(0): 1 | factorial(n): n * factorial(n-1) operator n!: ~stronger_than: + - * / match n | 0: 1 | _: n * (n - 1)!
Rhombus: repetitions [cs-0003]
- September 17, 2023
- Lîm Tsú-thuàn
Rhombus: repetitions [cs-0003]
- September 17, 2023
- Lîm Tsú-thuàn
Repetitions is a syntax extension of rhombus language.
def [n, ...] = [1, 2, 3] [factorial(n), ...] // [1, 2, 6] [n+10, ...] // [11, 12, 13]
An usual \(\mathbb {Z}\) definition [tt-0004]
- September 15, 2023
- Lîm Tsú-thuàn
An usual \(\mathbb {Z}\) definition [tt-0004]
- September 15, 2023
- Lîm Tsú-thuàn
def T : Nat -> Type | 0 => Unit | .suc _ => Bool inductive Int : Type where | mk : (n : Nat) -> T n -> Int
Therefore, the definition has
-
Int.mk 0 ()
for \(0\) -
Int.mk n true
for positive integer \(n\) -
Int.mk n false
for negative integer \(-n\)
For the same number indeed has definitional equality.
Pattern matching on Types: An indirected universe [tt-0005]
- September 15, 2023
- Lîm Tsú-thuàn
Pattern matching on Types: An indirected universe [tt-0005]
- September 15, 2023
- Lîm Tsú-thuàn
By introduce a indirect level of universe \(\mathcal {U}^-\), such that a subtype of normal universe \(\mathcal {U}\), and allows pattern matching. By restricting it can only be used at inductive type definitions' dependent position, it preserves parametricity, solves the problem easier compare with subscripting universe. In this setup, every defined type has type \(\mathcal {U}^-\) first, and hence
- \(\mathbb {N} : \mathcal {U}^-\)
- \(\mathbb {B} : \mathcal {U}^-\)
- \(\mathbb {L} : \mathcal {U} \to \mathcal {U}^-\)
\(\mathbb {L}\) didn't depend on \(\mathcal {U}^-\), so we keep using tagless encoding to explain
data Term Type | ℕ => add (Term ℕ) (Term ℕ) | 𝔹 => eq (Term ℕ) (Term ℕ) | a => if (Term 𝔹) (Term a) (Term a) | a => lit a
We have \(\text {Term} : \mathcal {U}^- \to \mathcal {U}^-\), and then, if one wants List (Term Nat)
it still work since \(\mathcal {U}^- \le \mathcal {U}\). But if one tries to define code below:
inductive Split Type^ | Nat => nat | Bool => bool | _ => else def id (A : Type) (x : A) : A => match Split A | nat => 0 | bool => false | _ => x
Since the \(\mathcal {U}\) isn't the subtype of \(\mathcal {U}^-\), program Split A
won't type check, the definition will not work as intended.
This is indeed more boring than subscripting universe, but easier to check it does't break parametricity.
Till now, I haven't start to check the pattern of type, except the primitive exact value, if I'm going to push this further, a good example is:inductive K Type^ | List a => hi a | _ => heThis is quite intuitive since in implementation inductive types' head are also rigid values, just like constructors.
Scheduler [cs-0001]
- September 15, 2023
- Lîm Tsú-thuàn
Scheduler [cs-0001]
- September 15, 2023
- Lîm Tsú-thuàn
For each process:
shared scheduler_lock : SpinLock shared ready_list : queue thread private current_thread : thread procedure reschedule() t : thread loop t := ready_list.dqueue() if t != null exit scheduler_lock.release() scheduler_lock.acquire() transfer(t) procedure yield() disable_signals() scheduler_lock.acquire() ready_list.enqueue(current_thread) reschedule() scheduler_lock.release() reenable_signals() procedure sleep_on(Q : queue thread) Q.enqueue(current_thread) reschedule()
Table. Transclusion options in Forester 2.2 [forester-0001]
- September 15, 2023
- Jon Sterling
- https://www.jonmsterling.com/jms-0069.xml
Table. Transclusion options in Forester 2.2 [forester-0001]
- September 15, 2023
- Jon Sterling
- https://www.jonmsterling.com/jms-0069.xml
Fluid Binding | Default | Meaning |
---|---|---|
\transclude/title |
(none) | To override the tree's title during transclusion. |
\transclude/taxon |
(none) | To override the tree's taxon during transclusion. |
\transclude/toc |
true |
Show the tree in the table of contents. |
\transclude/expanded |
true |
Whether the tree is expanded or not. |
\transclude/heading |
true |
If set to false , the tree's contents will be inlined. |
\transclude/metadata |
false |
Show in a tree's heading. |
\transclude/numbered |
true |
Whether the tree is displayed with a number or not, transitively on subtrees. |
Cartesian Closed Category [math-000D]
- September 14, 2023
- Lîm Tsú-thuàn
Cartesian Closed Category [math-000D]
- September 14, 2023
- Lîm Tsú-thuàn
Definition. Cartesian closed category [math-002H]
- September 14, 2023
- Lîm Tsú-thuàn
Definition. Cartesian closed category [math-002H]
- September 14, 2023
- Lîm Tsú-thuàn
Elements of ∞-Category Theory §A.1
A category \(\mathcal {V}\) is cartesian closed when it
- admits finite products, or equivalently, a terminal object \(1 \in \mathcal {V}\) and binary products and,
- for each \(v \in \mathcal {V}\), the functor \(v \times - : \mathcal {V} \to \mathcal {V}\) admits a right adjoints \((-)^v : \mathcal {V} \to \mathcal {V}\).
Definition. Introduction version [math-002I]
- November 4, 2023
- Lîm Tsú-thuàn
Definition. Introduction version [math-002I]
- November 4, 2023
- Lîm Tsú-thuàn
The introduction version about cartesian closed is focusing on a category has
- terminal object \(1\)
- product \(A \times B\) for any two objects \(A, B\)
- exponential \(B^A\) for any two objects \(A, B\)
Of course, this is equivalent to Definition [math-002H].
Example. [math-000E]
- September 14, 2023
- Lîm Tsú-thuàn
Example. [math-000E]
- September 14, 2023
- Lîm Tsú-thuàn
- The category of sets \(\bold {Sets}\) is cartesian closed, with \(B^A\) defined to be the set of functions from \(A\) to \(B\). It is actually an example of topos.
- The category of small categories \(\mathcal {Cat}\) is cartesian closed, with \(B^A\) defined to be the category of functors and natural transformations from \(A\) to \(B\).
- The category of Scott domains \(\mathcal {SDom}\) is cartesian closed.
Subscripting Inductive types [tt-0009]
- September 14, 2023
- Lîm Tsú-thuàn
Subscripting Inductive types [tt-0009]
- September 14, 2023
- Lîm Tsú-thuàn
An intutive extension of inductive types is, let constructor be subscripting set of the inductive type. For example, a type with definition
inductive Nat | zero | suc Nat
A type Nat[suc]
means only suc ...
is a term, zero
cannot have type Nat[suc]
. It's easy to see NatNonZero = Nat[suc]
, this can also apply to
List1 = List[cons]
-
Int
is also a good motive exampleinductive Int | 0 | + Int[+, zero] | - Int[-, zero]
Int[+]
is positive,Int[-]
is negative. The diagram in its syntactic category:
To ensure this, if the following syntax of each constructor c
is a list of argument types Ti ...
, we say the type of constructor of type T
is Ti ... -> T[c]
. The corresponding part is pattern matching's type rules will refine type T
with the pattern matched constructor c
, below marks all binder's refined type. The type T[c, ...]
is a subtype of T
.
def foo : Int -> Int | 0 => 0 | + p => -- p : Int[+, 0] p | - n => -- n : Int[-, 0] n
Remark. [#298]
- September 14, 2023
- Lîm Tsú-thuàn
Remark. [#298]
- September 14, 2023
- Lîm Tsú-thuàn
An obvious problem is
def neg : Int -> Int | 0 => 0 | + p => - (neg p) | - n => + (neg p)
We can see that the type information is squeezed, the second and third case need type casting. A potential solution is case type, and hence, neg
has type like:
But then what's the type rule of it? Will need some time to explore.
Definition. \(\mathcal {V}\)-enriched categories [math-000C]
- September 13, 2023
- Lîm Tsú-thuàn
Definition. \(\mathcal {V}\)-enriched categories [math-000C]
- September 13, 2023
- Lîm Tsú-thuàn
Category Theory for Programmers and Seven Sketches in Compositionality: An Invitation to Applied Category Theory.
Let \(\mathcal {V}\) be a monoidal category, and say it's the base category.
A category is a \(\mathcal {V}\)-enriched category (or \(\mathcal {V}\)-category) if
- its morphisms is the objects of \(f \in \mathcal {V}\)
- composite of morphisms \(f,g\) by tensor \(f \otimes g\)
we may also say it's enriched from \(\mathcal {V}\).
NOTE: In Elements of ∞-Category Theory the enrichment is more specific than this, the base category shall be a cartesian closed category.
Definition. More restricted definition of enriched category [math-000Q]
- September 26, 2023
- Lîm Tsú-thuàn
Definition. More restricted definition of enriched category [math-000Q]
- September 26, 2023
- Lîm Tsú-thuàn
Seven Sketches in Compositionality: An Invitation to Applied Category Theory
Let \(\mathcal {V} = (V, \le , I, \otimes )\) be a symmetric monoidal preorder. A \(\mathcal {V}\text {-category}\) \(\mathcal {X}\) consists of two contituents
- one specifies a set \(Ob(\mathcal {X})\), elements of the set are objects
- for every two objects \(x,y\), one specifies an element \(\mathcal {X}(x,y) \in V\), called the hom-object
they satisfy two propreties
- for every object \(x \in Ob(\mathcal {X})\), we have \(I \le \mathcal {X}(x, x)\)
- for every three objects \(x,y,z \in Ob(\mathcal {X})\), we have \(\mathcal {X}(x,y) \otimes \mathcal {X}(y,z) \le \mathcal {X}(x,z)\)
We call \(\mathcal {V}\) the base of enrichment for \(\mathcal {X}\), or say that \(\mathcal {X}\) is enriched in \(\mathcal {V}\).
Definition. Bool-categories [math-000R]
- September 26, 2023
- Lîm Tsú-thuàn
Definition. Bool-categories [math-000R]
- September 26, 2023
- Lîm Tsú-thuàn
\(\bold {Bool}\)-categories are preorders. Notice that, \(\bold {Bool}\) itself is a preorder, and hence, \(\bold {Bool}\) enriches itself.
Definition. Bool, monoidal structure on \(\mathbb {B}\) [math-006Z]
- January 14, 2024
- Lîm Tsú-thuàn
Definition. Bool, monoidal structure on \(\mathbb {B}\) [math-006Z]
- January 14, 2024
- Lîm Tsú-thuàn
The monoidal structure denotes \(\bold {Bool} = (\mathbb {B}, \le , \text {true}, \land )\),
- with a set \(\mathbb {B} = \{ \text {true}, \text {false} \}\);
- the only morphism \(\text {false} \le \text {true}\);
- and a monoidal product \(\land \).
\(\land \) | \(\text {false}\) | \(\text {true}\) |
---|---|---|
\(\text {false}\) | \(\text {false}\) | \(\text {false}\) |
\(\text {true}\) | \(\text {false}\) | \(\text {true}\) |
從 preoder 構造 \(\bold {Bool}\)-category 的方法是把 \(a \to b\) 標記為 \(a \le b = \text {true}\),否則 \(a \le b = \text {false}\),然後表列出來,熟悉圖論的讀者就可以發現這正好是普通圖的矩陣;從 \(\bold {Bool}\)-category 構造 preorder 的方式是把表列的元素先畫成點,再把值為 \(\text {true}\) 的部分作為邊繪出,最後捨棄出自傳遞性的邊。
Definition. Lawvere metric space (Cost-categories) [math-007B]
- January 17, 2024
- Lîm Tsú-thuàn
Definition. Lawvere metric space (Cost-categories) [math-007B]
- January 17, 2024
- Lîm Tsú-thuàn
A Lawvere metric space is a Cost-categories, the Cost defines as below
Definition. Cost (Lawvere's monoidal preorder) [math-007C]
- January 17, 2024
- Lîm Tsú-thuàn
Definition. Cost (Lawvere's monoidal preorder) [math-007C]
- January 17, 2024
- Lîm Tsú-thuàn
Let \([0,\infty ]\) denote the set of nonnegative real numbers tigether with \(\infty \). Consider the preorder \(([0,\infty ], \ge )\), with the usual notion of \(\ge \), where \(\infty \ge x\) for all \(x \in [0, \infty ]\).
A monoidal structure on this preorder is
\[ \bold {Cost} := ([0,\infty ], \ge , 0, +) \], where \(x + \infty = \infty \) for all \(x \in [0,\infty ]\).
這個結構可以對應權重圖,把每個存在的直接邊的權重寫到乘法表中,非直接邊就記成 \(\infty \),自己到自己則記成 \(0\);逆向的時候把權重邊畫出即可。
但要注意圖對應的 category size
Example. 實際案例 [math-007D]
- January 17, 2024
- Lîm Tsú-thuàn
Example. 實際案例 [math-007D]
- January 17, 2024
- Lîm Tsú-thuàn
\(d(\nearrow )\) | A | B | C | D | E |
---|---|---|---|---|---|
A | \(0\) | \(\infty \) | \(3\) | \(\infty \) | \(\infty \) |
B | \(2\) | \(0\) | \(\infty \) | \(3\) | \(\infty \) |
C | \(4\) | \(\infty \) | \(0\) | \(\infty \) | \(\infty \) |
D | \(\infty \) | \(\infty \) | \(\infty \) | \(0\) | \(\infty \) |
E | \(\infty \) | \(\infty \) | \(5\) | \(6\) | \(0\) |
Daily Suomea [finnish-0001]
- September 12, 2023
- Lîm Tsú-thuàn
Daily Suomea [finnish-0001]
- September 12, 2023
- Lîm Tsú-thuàn
Suomea | English |
---|---|
Jää on kylmää. | Ice is cold. |
Marja on pieni ja sininen. | The berry is small and blue. |
Puro on jäässä. | The stream is frozen. |
Koko puro on jäässä. | The whole stream is frozen. |
Koko perhe etsii poroa. | The whole family is looking for the reindeer. |
Karhu seisoo kylmässä purossa. | The bear is standing in the cold stream. |
Harmaa velho kävelee metsässä. | The gray wizard walks in the forest. |
Daily Japanese [jp-0001]
- September 12, 2023
- Lîm Tsú-thuàn
Daily Japanese [jp-0001]
- September 12, 2023
- Lîm Tsú-thuàn
Japanese | 中文 |
---|---|
うどん | 烏龍麵 |
うどん ていし よくはいくら ですか | 烏龍麵定食要多少錢? |
ラーメン を ひとつ ください | 請給我一碗拉麵 |
コーピー を ふたつ ください | 請給我兩杯咖啡 |
System F 中的 \(1\) 與 \(2\) [tt-0002]
- September 12, 2023
- Lîm Tsú-thuàn
System F 中的 \(1\) 與 \(2\) [tt-0002]
- September 12, 2023
- Lîm Tsú-thuàn
根據 parametricity properties,對於類型 \(\forall X. X \to X\),可以發現其唯一的元素正是 \(\Lambda X. \lambda x. x\);而對於類型 \(\forall X. X \to X \to X\) 則有唯二的元素
- \(\Lambda X. \lambda x. \lambda y. x\)
- \(\Lambda X. \lambda x. \lambda y. y\)
因此也可以定義 \(1 = \forall X. X \to X\) 跟 \(2 = \forall X. X \to X \to X\),這個定義很容易推廣到任意整數。更有趣的是我們能定義出一個 \(V\) 滿足 \(V \cong (V \to 2) \to 2\),用集合論解釋的話就會發現這導引出 \(V\) 的 powerset 小於自己,在集合論中是矛盾的,因此 System F 無法用集合論作模型。
Definition. Family over Set [math-0003]
- September 11, 2023
- Lîm Tsú-thuàn
Definition. Family over Set [math-0003]
- September 11, 2023
- Lîm Tsú-thuàn
With a display function \(\varphi : X \to I\), we say
- \(X\) is a family over \(I\)
- and that \(\varphi \) displays the family \((X_i)\)
Definition. Slice category \(\bold {Sets}/I\) [math-000S]
- September 11, 2023
- Lîm Tsú-thuàn
Definition. Slice category \(\bold {Sets}/I\) [math-000S]
- September 11, 2023
- Lîm Tsú-thuàn
The \(\bold {Sets}/I\) is a category with
- objects families \((X \xrightarrow {\varphi } I)\)
- morphisms \((X \xrightarrow {\varphi } I) \xrightarrow {f} (Y \xrightarrow {\psi } I)\) are functions \(f : X \to Y\) making the following diagram commutes:
Collary. Slice of sets is set-valued functor [math-002B]
- October 31, 2023
- Lîm Tsú-thuàn
Collary. Slice of sets is set-valued functor [math-002B]
- October 31, 2023
- Lîm Tsú-thuàn
Combine with topos fundamental theorem, the category of presheaves is a topos.
Definition. Arrow category \(\bold {Sets}^{\to }\) [math-0005]
- September 11, 2023
- Lîm Tsú-thuàn
Definition. Arrow category \(\bold {Sets}^{\to }\) [math-0005]
- September 11, 2023
- Lîm Tsú-thuàn
The \(\bold {Sets}^{\to }\) is a category with
- objects: families \((X \xrightarrow {\varphi } I)\), for arbitrary sets \(I\).
- morphisms: \((X \xrightarrow {\varphi } I) \xrightarrow {(u, f)} (Y \xrightarrow {\psi } J)\) are pairs of functions \(u : I \to J\) and \(f : X \to Y\) for which the following diagram commutes:
Mastodon 私訊相比於一般通訊軟體 e.g. LINE, Telegram [software-0001]
- September 10, 2023
- Lîm Tsú-thuàn
Mastodon 私訊相比於一般通訊軟體 e.g. LINE, Telegram [software-0001]
- September 10, 2023
- Lîm Tsú-thuàn
好處
- 可以有效分類特定話題,例如一個串是講約去哪裡吃飯、另一個串講專業內容
- 可以用僅限提及的人,限制可見性,所以可以形成一定程度的群組概念
- 兩方站點的站長都能看到內容
- 客戶端不支援把一群提及名單固定成群組,這或許是一個可行的客戶端新功能
類與集合 [math-0001]
- September 10, 2023
- Lîm Tsú-thuàn
類與集合 [math-0001]
- September 10, 2023
- Lîm Tsú-thuàn
類區分為兩種:一種是可以順利進行類運算的「良性類」,我們把這種「良性類」稱為集合;另一種是要限制運算的「本性類」,對於本性類,類運算並不是都能進行的。 在數學導論中有更完整的背景介紹為何要定義的如此複雜。
Definition. 零測度 measure zero [math-0011]
- August 20, 2023
- Lîm Tsú-thuàn
Definition. 零測度 measure zero [math-0011]
- August 20, 2023
- Lîm Tsú-thuàn
當集合 \(A\) 對任意 \(\epsilon > 0\) 都存在一組為可數多個的區間 \(I_k\),滿足全部 \(I_k\) 可以蓋住 \(A\) \[ A \subseteq \bigcup _{k=1}^{\infty } {I_k} \] 跟所有 \(I_k\) 的長度和小於 \(\epsilon \) \[ \sum _{k=1}^{\infty }{\mathcal {L}(I_k)} < \epsilon \] 兩個條件
其中 \(\mathcal {L}\) 的定義是區間的長度,比如 \([a, b]\) 跟 \((a, b)\) 的長度都是 \(b-a\)
Tagless final [cs-000G]
- May 30, 2023
- Lîm Tsú-thuàn
Tagless final [cs-000G]
- May 30, 2023
- Lîm Tsú-thuàn
最簡單的 final 編碼(用函數編碼) [#274]
- May 30, 2023
- Lîm Tsú-thuàn
最簡單的 final 編碼(用函數編碼) [#274]
- May 30, 2023
- Lîm Tsú-thuàn
但這種方法只能對一種特定的 interpreter 擴展
def naive_lit (x : Int) : Int := x def naive_add (a b : Int) : Int := a + b
利用 type class [#275]
- May 30, 2023
- Lîm Tsú-thuàn
利用 type class [#275]
- May 30, 2023
- Lîm Tsú-thuàn
可以對任意 interpreter 擴充
class Expr (α : Type) where lit : Int → α add : α → α → α def lit [e : Expr α] : Int → α := e.lit def add [e : Expr α] : α → α → α := e.add
這可以讓我們寫出下面的使用案例
instance : Expr Int where lit x := x add a b := a + b instance : Expr String where lit x := s!"{x}" add a b := s!"{a} + {b}" def expr [Expr α] : α := add (lit 1) (lit 2) #eval (expr : String) -- "1 + 2" #eval (expr : Int) -- 3
這個編碼確實對任意 interpreter 都可以擴充,舉例來說
class ExprSub (α : Type) where sub : α → α → α instance : ExprSub Int where sub a b := a - b instance : ExprSub String where sub a b := s!"{a} - {b}" def sub [e : ExprSub α] : α → α → α := e.sub def expr [Expr α] [ExprSub α] : α := sub (add (lit 1) (lit 2)) (lit 3) #eval (expr : String) -- "1 + 2 - 3" #eval (expr : Int) -- 0
可以看到只要增加新的約束,interpreter 就會被擴充。但這個編碼要是遇到不同型別就會掛掉,所以需要引入一層 type 函數
Tagless final(引入 Type → Type
) [#276]
- May 30, 2023
- Lîm Tsú-thuàn
Tagless final(引入 Type → Type
) [#276]
- May 30, 2023
- Lîm Tsú-thuàn
除了 expression 的編碼,也一併定義這裡要支援的兩個 interpreter
class FTExpr (f : Type → Type) : Type where lit : Int → f Int add : f Int → f Int → f Int compare : f Int → f Int → f Bool @[reducible] def Pretty (_ : Type) : Type := String instance : FTExpr Pretty where lit x := s!"{x}" add a b := s!"{a} + {b}" compare a b := s!"{a} =? {b}" @[reducible] def Eval (α : Type) : Type := α instance : FTExpr Eval where lit x := x add a b := a + b compare a b := a == b
使用起來這也比較複雜一點,我們要定義一串有點亂的程式
def ftlit [e : FTExpr f] : Int → f Int := e.lit def ftadd [e : FTExpr f] : f Int → f Int → f Int := e.add def ftcompare [e : FTExpr f] : f Int → f Int → f Bool := e.compare def ft_expr [FTExpr f] : f Bool := ftcompare (ftlit 3) (ftadd (ftlit 1) (ftlit 2)) def ft_expr2 [FTExpr f] : f Int := ftadd (ftlit 1) (ftlit 2)
現在可以驗證看看結果
#eval (ft_expr : Eval Bool) -- true #eval (ft_expr : Pretty Bool) -- "3 =? 1 + 2" #eval (ft_expr2 : Eval Int) -- 3 #eval (ft_expr2 : Pretty Int) -- "1 + 2"
你可以像前面那樣增加其他的運算機制到 interpreter 上來檢驗是否可以達到
- 靜態檢查 syntax 的構造是正確的
- 可以只寫擴充的部分的 syntax 跟對應的 interpreter 行為
在 okmij 中可以找到更多對 tagless final 的研究,但對我來說現在這樣應該就夠了 XD
Extension. Flexible contexts [haskell-0004]
- May 10, 2023
- Lîm Tsú-thuàn
Extension. Flexible contexts [haskell-0004]
- May 10, 2023
- Lîm Tsú-thuàn
Open FlexibleContexts
extension can release the power of monad transformers, a simple example here
import Control.Monad.Except import Control.Monad.State foo :: (MonadIO m) => (MonadError String m) => (MonadState Int m) => m () foo = do liftIO $ putStrLn "hello" modify (+ 1) throwError "error"
The program
- prints
hello
- modifies its state
- throw an error at the end
these effects are able since the type class constraints are IO
, State Int
, and Except String
. Then, we can instantized the function:
foo1 :: ExceptT String (StateT Int IO) () foo1 = foo foo2 :: StateT Int (ExceptT String IO) () foo2 = foo
let's take a look at how to invoke
main :: IO () main = do (a, s) <- runStateT (runExceptT foo1) 0 putStrLn $ show a putStrLn $ show s
The output is
hello Left "error" 1
Even the program is failed, you still get the state! However, foo2
gives a different result:
main :: IO () main = do b <- runExceptT $ runStateT foo2 0 putStrLn $ show b
This program drop the state whenever the program failed. The result is
hello 1
This is why the contexts are called flexible. The order of transformers is non-trivial, it can affect the behavior of the program. Two transformers bring two order, three bring six order, though not every permutation is useful or make different, but a flexible program maybe more polymorphic than one think. That maybe will not be your expectation, and hence, you might need to export a stable interface for your module, but inside of your module? Just let it free.
Definition. Category of (co)cones [math-002M]
- March 20, 2023
- Lîm Tsú-thuàn
Definition. Category of (co)cones [math-002M]
- March 20, 2023
- Lîm Tsú-thuàn
With a fixed diagram \(\mathcal {D} \xrightarrow {F} \mathcal {C}\) and existing natural transformations \(\Delta _c \to F\), we get a category that consituited by
\(\Delta _c\) is a functor \(- \mapsto c : \mathcal {D} \to \mathcal {C}\) various on different \(c \in \mathcal {C}\).
- objects: all cone objects \(c\) above the fixed diagram (via \(\Delta _c\) functor).
- morphisms: \(\mathcal {C}\)-morphisms between cones.
Dual natural transformations \(F \xrightarrow {\beta } \Delta _c\) form cocones and a dual category.
Definition. Limit and colimit (universal cone and cocone) [math-002N]
- March 20, 2023
- Lîm Tsú-thuàn
Definition. Limit and colimit (universal cone and cocone) [math-002N]
- March 20, 2023
- Lîm Tsú-thuàn
With a fixed diagram \(\mathcal {D} \xrightarrow {F} \mathcal {C}\), a limit is a terminal of the category of cones, denoted as \(\lim _{\mathcal {D}} F\).
- notice that we can freely abuse language and say a \(\mathcal {C}\)-diagram is a functor target to \(\mathcal {C}\)
- Limit might not exist, so you have to ensure there has one.
The dual concept colimit is an initial of category of cocones, denoted as \(\underset {\mathcal {D}} {\text {colim}}F\).
The encoding problem of a simpler encoding of indexed types [tt-0007]
- December, 2022
- Lîm Tsú-thuàn
The encoding problem of a simpler encoding of indexed types [tt-0007]
- December, 2022
- Lîm Tsú-thuàn
The benefit of the idea is clear, but it disallows definition like tagless interpreter:
data Term : Set → Set1 where lit : ∀ {a} → a → Term a add : Term ℕ → Term ℕ → Term ℕ eq : Term ℕ → Term ℕ → Term 𝔹 if : ∀ {a} → Term 𝔹 → Term a → Term a → Term a eval : ∀ {a} → Term a → a eval (lit x) = x eval (add x y) = eval x + eval y eval (eq x y) = eval x == eval y eval (if c t e) with eval c eval (if c t e) | true = eval t eval (if c t e) | false = eval e
NOTE: There is a workaround in paper, and hence, the problem is inconvenience instead of impossible.
型別檢查 [tt-001D]
- November 25, 2022
- Lîm Tsú-thuàn
型別檢查 [tt-001D]
- November 25, 2022
- Lîm Tsú-thuàn
這裡列出重要的兩個定義:
- environment:儲存變數的計算結果
- context:儲存變數的型別
type Env = [(Name, Val)] type Ctx = [(Name, VTy)]
下面逐步介紹整個型別檢查的元件
推導 inference [tt-001F]
- November 25, 2022
- Lîm Tsú-thuàn
推導 inference [tt-001F]
- November 25, 2022
- Lîm Tsú-thuàn
在最上層的程式中,推導函數會直接被調用來得出 term 的 type,它會適當的調用 check
去檢查是否有型別錯誤
infer :: Env -> Ctx -> Raw -> M VTy infer env ctx = \case SrcPos pos t -> addPos pos (infer env ctx t) Var x -> case lookup x ctx of Just a -> return a Nothing -> report $ "Name not found: " ++ x U -> return VU t :@ u -> do tty <- infer env ctx t case tty of VPi _ a b -> do check env ctx u a return $ b $ eval env u tty -> report $ "Cannot apply on: " ++ quoteShow env tty Lam {} -> report "cannot infer type for lambda expression" Pi x a b -> do check env ctx a VU check ((x, VVar x) : env) ((x, eval env a) : ctx) b VU return VU Let x a t u -> do check env ctx a VU let ~a' = eval env a check env ctx t a' infer ((x, eval env t) : env) ((x, a') : ctx) u
-
SrcPos
這個情況只需要加上位置訊息之後往下 forward 即可 - 遇到變數時,查找當前的 context 就可以知道型別了
- 再來 universe 的 type 就是 universe
- application (
t :@ u
) 也就是函數套用 (\(\beta \)-reduction) 的情況就比較複雜了- 首先要馬上推導
t
得到tty
- 要是
tty
不是一個函數型別 (\(\Pi \) type) 那麼就回報錯誤 - 否則
tty
的形式就會是 \(\Pi (x:A) \to B\),這時候要檢查u
是否是一個 \(A\) - 最後一步把 \(\Pi (x:A)\to B\) 套用
u
就會得到型別 \(B\ x\),也就是目標
- 首先要馬上推導
- lambda 設定成不能推導,避開 undecidable 的情況
- 對 \(\Pi (x : A) \to B\) 先檢查 \(A\) 是不是型別 (\(\mathbb {U}\)) ,接著擴張 environment 跟 context 再檢查 \(B\ x\) 是不是 \(\mathbb {U}\)
- let 語法寫成
let x : a = t in u
,推導的過程如下- 檢查
a
是型別 - 執行
a
得到a'
,因為要從Tm
變成Val
(也就是化簡過的a
) - 檢查
t
的型別是否是a'
- 把
x : a'
與x = t
的綁定資訊推進 context 與 environment 再拿它們去推導u
- 檢查
最後使用 infer
時,就像是這樣 (...
是省略號):
tm <- parse ... case infer [] [] tm of Left err -> ... Right ty -> ...
檢查 check [tt-001G]
- November 25, 2022
- Lîm Tsú-thuàn
檢查 check [tt-001G]
- November 25, 2022
- Lîm Tsú-thuàn
檢查函數接收一個 term 跟一個 type 用來找出 term 實際類型不匹配 type 的情況
check :: Env -> Ctx -> Raw -> VTy -> M () check env ctx t a = case (t, a) of (SrcPos pos t, _) -> addPos pos (check env ctx t a) (Lam x t, VPi (fresh env -> x') a b) -> -- after replace x in b -- check t : bx check ((x, VVar x') : env) ((x, a) : ctx) t (b (VVar x')) (Let x a' t' u, _) -> do check env ctx a' VU let ~a'' = eval env a' check env ctx t' a'' check ((x, eval env t') : env) ((x, a'') : ctx) u a _ -> do tty <- infer env ctx t unless (conv env tty a) $ report (printf "type mismatch\n\nexpected type:\n\n \%s\n\ninferred type:\n\n \%s\n" (quoteShow env a) (quoteShow env tty))
-
SrcPos
這個情況只需要加上位置訊息之後往下 forward 即可 - 要是 term 是 lambda \(\lambda x . t\) 且 type 是 \(\Pi (x' : A) \to B\)
- 這裡 \(\Pi \) type 用了 view patterns 這個 extension:
fresh env -> x'
- 這部份是因為
x
跟x'
可能是同名的,fresh
確保了它們不會被搞混 - 這個語法的意思是
expression -> pattern
- pattern 用來 matching
- expression 在 match 到之後套用到該 pattern 對應的 expression
- 這部份是因為
- 接著讓環境擴張成
x = x'
跟x : A
- 拿新環境檢查
t
(lambda 的 body)的型別是不是 \(B\ x\)檢查 lambda 的方式就是讓 lambda 跟 \(\Pi \) 套用同一個參數之後再看一次
- 這裡 \(\Pi \) type 用了 view patterns 這個 extension:
- term 是 let 語法時跟推導的情況完全一樣,只差在最後一段是檢查
u
在新環境下是不是check
拿到的那個 type 而不是去推導u
- 除此之外的情況就是調用回去
infer
找出 term 的型別,然後讓它跟check
拿到的 type 做 conversion check
化簡 evaluation [tt-001H]
- November 25, 2022
- Lîm Tsú-thuàn
化簡 evaluation [tt-001H]
- November 25, 2022
- Lîm Tsú-thuàn
化簡函數就是把 term 變成 value 的過程,它只需要 environment 而不需要 context
eval :: Env -> Tm -> Val eval env = \case SrcPos _ t -> eval env t Var x -> fromJust $ lookup x env t' :@ u' -> case (eval env t', eval env u') of (VLam _ t, u) -> t u (t, u) -> VApp t u U -> VU Lam x t -> VLam x (\u -> eval ((x, u) : env) t) Pi x a b -> VPi x (eval env a) (\u -> eval ((x, u) : env) b) Let x _ t u -> eval ((x, eval env t) : env) u
-
SrcPos
一如既往的只是 forward - 變數就是上環境尋找
- \(\beta \)-reduction 的情形就是先化簡要操作的兩端,然後看情況
- 函數那頭是 lambda,就可以當場套用它的 host lambda 得到結果
- 這個情形比較有趣,有很多名字像是卡住、中性之類的描述,簡單來說就是沒辦法繼續化簡的情況。我們用
VApp
儲存這個結果,conversion check 裡面會講到怎麼處理這些東西VApp
也常被叫做 spine
- universe 的值還是 universe
- lambda 跟 \(\Pi \) 好玩的地方在使用 host lambda 編碼計算,這個 lambda 定義成
\u -> ...
- 會用
u
去擴展 environment,也就是(x, u) : env
- 接著用擴展的 environment 執行
t
(在 \(\Pi \) 的情況就是執行b
)
- 會用
- let x : a = t in u 語法就是把 x = t 丟進 environment 去執行 u 而已
Remark. [#295]
- November 25, 2022
- Lîm Tsú-thuàn
Remark. [#295]
- November 25, 2022
- Lîm Tsú-thuàn
卡住在 dependent type 裡非常常見,舉例來說你有個函數
foo : (f : A -> U) -> (a : A) -> f a
在檢查 foo
時執行到 f a
就沒辦法被化簡,因為此時我們拿到的 f
是一個 VVar "f"
而不是 VLam x t
Conversion check 可轉換性檢查 [tt-001I]
- November 25, 2022
- Lîm Tsú-thuàn
Conversion check 可轉換性檢查 [tt-001I]
- November 25, 2022
- Lîm Tsú-thuàn
conversion 是在 environment 中判斷兩個 value 是否能夠互相轉換的函數,對型別來說就是在判斷兩個型別是否相同
conv :: Env -> Val -> Val -> Bool conv env m n = case (m, n) of (VU, VU) -> True (VPi (fresh env -> x) a b, VPi x' a' b') -> conv env a a' && conv ((x, VVar x) : env) (b (VVar x)) (b' (VVar x)) (VLam (fresh env -> x) t, VLam x' t') -> conv ((x, VVar x) : env) (t (VVar x)) (t' (VVar x)) (VLam (fresh env -> x) t, u) -> conv ((x, VVar x) : env) (t (VVar x)) (VApp u (VVar x)) (u, VLam (fresh env -> x) t) -> conv ((x, VVar x) : env) (VApp u (VVar x)) (t (VVar x)) (VVar x, VVar x') -> x == x' (VApp t u, VApp t' u') -> conv env t t' && conv env u u' _ -> False
- 兩個 universe 當然可以互相轉換(注意這個語言從頭到尾都沒在管 universe level 的問題)
- 兩個 \(\Pi (x:A) \to B\) type 的檢查
- 先看兩個 \(A\) 的部分能不能轉換
- 再看統一套用一個變數
x
能不能讓兩個 \(B\ x\) 轉換 - 兩步驟都成功的話,就可以說這兩個 \(\Pi \) type 可以轉換
- 兩個 lambda 是上面的 \(\Pi \) type 的簡化版,拿掉 \(A\) 的部分就是一樣的
- lambda 跟任意 term 或是任意 term 跟 lambda 這兩種情況是對稱的,這時候可以轉換是指:
VApp u (VVar x)
跟t (VVar x)
可以轉換,當- 擴張 environment 加上
x = VVar x
- 任意 term 寫成
u
- host lambda 寫成
t
- 擴張 environment 加上
- 兩個變數是檢查它們是不是同一個變數
- 兩個卡住值的情況下,把裡面儲存的值拿出來看能不能轉換
- 走到這裡就是不能轉換
Proposition. Identity in group is unique [math-000Z]
- November 23, 2022
- Lîm Tsú-thuàn
Proposition. Identity in group is unique [math-000Z]
- November 23, 2022
- Lîm Tsú-thuàn
If \(h \in G\) is an identity of group \(G\), then \(h = 1_G\).
Proof. [#658]
- November 23, 2022
- Lîm Tsú-thuàn
Proof. [#658]
- November 23, 2022
- Lîm Tsú-thuàn
- \(a = a \cdot 1_G\) for all \(a\)
- \(a = h \cdot a\) for all \(a\) (\(h\) is an identity)
Proposition. Inverse of an element is unique [math-0010]
- November 23, 2022
- Lîm Tsú-thuàn
Proposition. Inverse of an element is unique [math-0010]
- November 23, 2022
- Lîm Tsú-thuàn
Let \(f\) has inverse \(a\) and \(b\), then \(a = b\)
Proof. [#657]
- November 23, 2022
- Lîm Tsú-thuàn
Proof. [#657]
- November 23, 2022
- Lîm Tsú-thuàn
- \(f \cdot a = e\)
- \(f \cdot b = e\)
Racket 升級指令 [software-000B]
- November 17, 2022
- Lîm Tsú-thuàn
Racket 升級指令 [software-000B]
- November 17, 2022
- Lîm Tsú-thuàn
racket 8.7 這次我比較晚更新,才發現我居然用了快 10 秒才想到下面的 migrate 指令,所以我覺得要把流程紀錄一下。 下載網站就和過去的發佈一樣在 https://download.racket-lang.org/,只要根據自己的電腦選擇合適的版本即可。
設定 environment variable [#255]
- November 17, 2022
- Lîm Tsú-thuàn
設定 environment variable [#255]
- November 17, 2022
- Lîm Tsú-thuàn
這邊是跟 executable 有關的設定,下面會為 macOS 特化
export PATH=/Applications/Racket\ v8.7/bin:$PATH export PATH=$HOME/Library/Racket/8.7/bin:$PATH
Migrate 指令 [#256]
- November 17, 2022
- Lîm Tsú-thuàn
Migrate 指令 [#256]
- November 17, 2022
- Lîm Tsú-thuàn
這可以把之前安裝的東西搬到新家
raco pkg migrate 8.6
如何用 gpg 簽署 git commit [software-000C]
- November 16, 2022
- Lîm Tsú-thuàn
如何用 gpg 簽署 git commit [software-000C]
- November 16, 2022
- Lîm Tsú-thuàn
GPG 還蠻麻煩的,所以順手紀錄一下整個流程順便複習自己的知識
列出系統上的 keys [software-000D]
列出系統上的 keys [software-000D]
用 gpg --list-secret-keys --keyid-format=long
讀出 keys
生成新的 gpg key [software-000E]
生成新的 gpg key [software-000E]
要是你還沒有 key,那麼就需要 gpg --gen-key 先生成一把
gpg --default-new-key-algo rsa4096 --gen-key
它會詢問
- Real name:
- Email address:
- 確認生成
- 問你要不要 passphrase(設定就是使用的時候需要密碼)
注意要是你的 gpg key 還需要能夠加密的話,就需要用 gpg --full-generate-key
並選擇正確的選項。
設定 git [software-000F]
設定 git [software-000F]
要讓 git 採用 gpg 簽名,首先要設定
git config commit.gpgsign true
你會輸入 git config --global user.signingkey <keyid>
讓 git 知道要用哪一隻,假設說你的 key ID 是 3AA5C3431567BD2
,那就會像是下面的指令
git config --global user.signingkey 3AA5C3431567BD2
在 GitHub 上設定 [software-000G]
在 GitHub 上設定 [software-000G]
要讓 GitHub 也能認出來,就需要用 gpg --export -a <keyid>
去拿到 PGP public key block,然後在SSH and GPG keys 設定頁面把 PGP public key block 填進去。
Joint denial [math-001C]
- September 20, 2022
- Lîm Tsú-thuàn
Joint denial [math-001C]
- September 20, 2022
- Lîm Tsú-thuàn
記錄一下一個有趣的函數:joint denial(又稱為 Peirce's arrow 或是 NOR)。它的真值表是
\(P\) | \(Q\) | \(P \downarrow Q\) |
---|---|---|
\(true\) | \(true\) | \(false\) |
\(true\) | \(false\) | \(false\) |
\(false\) | \(true\) | \(false\) |
\(false\) | \(false\) | \(true\) |
這個函數好玩的地方是我們熟悉的所有邏輯謂詞都可以用它替換
- \(\neg P = P \downarrow P\)
- \(P \rightarrow Q = ((P \downarrow P) \downarrow Q) \downarrow ((P \downarrow P) \downarrow Q)\)
- \(P \land Q = (P \downarrow P) \downarrow (Q \downarrow Q)\)
- \(P \lor Q = (P \downarrow Q) \downarrow (P \downarrow Q)\)
Definition. Archimedean Principle [math-000Y]
- April 10, 2022
- Lîm Tsú-thuàn
Definition. Archimedean Principle [math-000Y]
- April 10, 2022
- Lîm Tsú-thuàn
The Archimedean principle is: If \(a\) and \(b\) are real numbers with \(a > 0\), then there exists a natural number \(n\) such that \(na > b\).
So \(n > \frac {b}{a}\), by this we can have a particular example.
Apply principle to an example [#659]
- April 10, 2022
- Lîm Tsú-thuàn
Apply principle to an example [#659]
- April 10, 2022
- Lîm Tsú-thuàn
Let \(a = \epsilon \) and \(b = 1\), then \(n > \frac {1}{\epsilon }\), and \(\epsilon > \frac {1}{n}\). Show that \[\inf \Big (\Big \{ \frac {1}{n} : n \in \mathbb {N} \Big \} \Big ) = 0\].
Proof. [#660]
- April 10, 2022
- Lîm Tsú-thuàn
Proof. [#660]
- April 10, 2022
- Lîm Tsú-thuàn
Let \(A = \{\frac {1}{n} : n \in \mathbb {N}\}\). Since \(1\) and \(n\) are positive for each \(n \in \mathbb {N}\), shows \(\frac {1}{n} > 0\), so \(0\) is a lower bound of \(A\).
Let \(\epsilon > 0\), by Archimedean principle there exists some \(n \in \mathbb {N}\) such that \(\frac {1}{n} < \epsilon \). This element is in \(A\) and is less than \(0 + \epsilon \). Thus, \(0\) is infimum of \(A\) by definition: \(0 + \epsilon \) is not a lower bound of \(A\) for all \(\epsilon > 0\).
Homotopy type theory (HoTT) [tt-000J]
- April 2, 2022
- Lîm Tsú-thuàn
- hott.html
Homotopy type theory (HoTT) [tt-000J]
- April 2, 2022
- Lîm Tsú-thuàn
- hott.html
這篇是我對 HoTT (Homotopy Type Theory) 的理解與整理,連結是相關的程式。
Identity [tt-000K]
Identity [tt-000K]
要理解 hott 就要先知道 unique identity,即 x ≡ y
這樣的型別,在 extensional type theory(e.g. MLTT)裡面只有一個元素,即對 P Q : x ≡ y
可以證明 P ≡ Q
。這就叫 UIP(Uniqueness of Identity Proofs)
UIP : (X : Set) → ∀{x x' : X} → ∀(r s : x ≡ x') → r ≡ s UIP X {x} {.x} refl refl = refl
Axiom K 跟它的關係是 \(K \implies \text {UIP}\) 且 \(\text {UIP} \implies K\) 。
但這個公理成立的時候我們沒辦法表示一些 topology,比如說 circle。因為 identity 在 HoTT 裡對應的解釋是一個 path,x ≡ y
就是 x
到 y
的路徑,而 P Q : x ≡ y
自然就是 x
到 y
的兩條路徑,如果 P ≡ Q
可證明,那 P
就跟 Q
可以替換,於是你可以先變成一條線,再收縮成一個點。circle 需要的兩條路徑就沒辦法成立,此類的拓墣都沒辦法表示,因此 agda 給了一個選項 without K 來取消這個公理,才能編寫 homotopy 系列的類型論。
一個具體的情況是 Bool
可以有兩種同構,也就是 id ∘ id
跟 not ∘ not
,然而這兩條路徑在 extensional type theory 裡面無法區分,也就是可以證明兩者相等,在同倫類型論之中則否。
\(n\)-types [tt-000L]
\(n\)-types [tt-000L]
另一個重要的性質是 \(n\)-types,使用 \(n\) 維度之上沒有洞的特性來分類類型
- 從 -2 的 contractible。繼續往下也是 contractible,contractible 即一個與點同倫的型別,因此「可收縮」
- 到 -1 proposition
- 0 set
- 1 groupoid
- 往上可以無限加,這就是 hlevel
命題被解釋成是一個點,也就是 true;或是一個什麼都沒有的空間,也就是 false。所以定義為
isProp : ∀{i} → Type i → Type i isProp A = (x y : A) → x ≡ y
Definition. Propositional truncation [tt-000M]
Definition. Propositional truncation [tt-000M]
Let \(T\) be a type, the propositional truncation of \(T\) is the type \(\Vert T \Vert \) defined by
- an element constructor \(\vert t \vert : \Vert T \Vert \) for all \(t : T\);
- an identification constructor providing an identification of type \(x = y\) for all \(x, y : \Vert T \Vert \).
截斷 \(\Vert A \Vert \) 表示 \(A\) 有證明,但沒有具體證明的資訊
Universal property [#296]
Universal property [#296]
For any proposition \(P\), precomposition with \(\vert \_\vert \) is an equivalence of type
\[ (\Vert T \Vert ) \to P \cong (T \to P) \]
Definition. Non-empty type [#297]
Definition. Non-empty type [#297]
Let \(T\) be a type, we say \(T\) is non-empty if we have an element of \(\Vert T \Vert \).
Univalence [tt-000N]
Univalence [tt-000N]
允許用 equivalence 構造出 equality
Arm64 print number by use svc [asm-0001]
- January 19, 2022
- Lîm Tsú-thuàn
Arm64 print number by use svc [asm-0001]
- January 19, 2022
- Lîm Tsú-thuàn
.global printNumberEntry printNumberEntry: // asked two words on stack sub sp, sp, #16 mov x15, #10 mov x12, x0 // print prepare // fd(x0) = 1(stdout) mov x0, #1 // len(x2) = 1 mov x2, #1 // Unix write system call mov x16, #4 printNumber: // number = x12 // x14 = x12 / 10 // now x14 is rounded-down quotient of x12 udiv x14, x12, x15 // x13 = x14 * 10 - x12 msub x13, x14, x15, x12 // store rounded-down quotient to x12 for next loop mov x12, x14 // digit to string add x13, x13, #48 strb w13, [sp] // buf(x1) = sp mov x1, sp svc #0 // loop part cmp x12, #0 b.eq exit b printNumber exit: mov x13, #10 strb w13, [sp] mov x1, sp svc #0 // put used stack back add sp, sp, #16 ret
Note about a simpler encoding of indexed types [tt-0006]
- December, 2021
- Lîm Tsú-thuàn
Note about a simpler encoding of indexed types [tt-0006]
- December, 2021
- Lîm Tsú-thuàn
The idea is coming from Zhang's paper, a simpler encoding of indexed types.
An example is Vec
in Agda
data Vec (A : Set a) : ℕ → Set a where [] : Vec A zero _∷_ : ∀ (x : A) (xs : Vec A n) → Vec A (suc n)
One can still try [] : Vec A 10
, although the type check failed, it need a sophisticated unification check.
With Zhang's idea, we can do:
data Vec (A : Set a) : ℕ → Set a where zero => [] suc n => _∷_ A (Vec A n)
Now, [] : Vec A n
where \(n \ne 0\) is impossible to write down as usual, but now it's an easier unification!
Since there has no constructor []
for type Vec A n
where \(n \ne 0\).
Another good example is finite set:
data Fin (n : N) | suc _ => fzero | suc n => fsuc (Fin n)
It requires overlapping pattern. One more last, we cannot define usual equality type here (please check)
data Id (A : Type ℓ) (x : A) : A → Type ℓ where idp : Id A x x
Paper: Simpler indexed type essentially simplifies the problem of constructor selection just by turning the term-match-term problem to a term-match-pattern problem, which rules out numerous complication but also loses the benefit of general indexed types.
How to setup a julia project [software-000H]
- August 7, 2020
- Lîm Tsú-thuàn
How to setup a julia project [software-000H]
- August 7, 2020
- Lîm Tsú-thuàn
Tape julia
in shell, after getting into the interactive environment of Julia, tape right square bracket to get into pkg mode:
_ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.5.0 (2020-08-01) _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release |__/ | (@v1.5) pkg>
In this mode tape: generate HelloWorld
(@v1.5) pkg> generate HelloWorld
In the current directory would have a new directory called HelloWorld
. In directory HelloWorld/
we will see:
Project.toml src/ HelloWorld.jl
To play with definitions in module HelloWorld
, in pkg mode tape activate .
(@v1.5) pkg> activate .
Then use ;
+ enter
back to interactive mode:
julia> import HelloWorld julia> using HelloWorld
\(\lambda 2\) (lambda 2 system) [tt-0012]
- June 12, 2020
- Lîm Tsú-thuàn
\(\lambda 2\) (lambda 2 system) [tt-0012]
- June 12, 2020
- Lîm Tsú-thuàn
Consider identity function:
\[ \lambda x : nat.x \\ \lambda x : bool.x \\ \lambda x : (nat \to bool).x \]For per type, there is an identity function, but all with same definition. Therefore, we want to use the same way to build it, here we go:
\[\lambda \alpha : \star . \lambda x : \alpha . x\]\(*\) denotes a type of all types, since \(\lambda \alpha : \star . \lambda x : \alpha . x\) is a term, we say this is terms depend on types. This is second order \(\lambda \)-abstraction(or type-abstraction).
Rules [#236]
- June 12, 2020
- Lîm Tsú-thuàn
Rules [#236]
- June 12, 2020
- Lîm Tsú-thuàn
-
second order abstraction rule:
\[\frac { \Gamma , \alpha : \star \vdash M : A }{ \Gamma \vdash \lambda \alpha : \star .M : \Pi \alpha : \star . A }\] -
second order application rule:
\[\frac { \Gamma \vdash M : \Pi \alpha : \star .A \;\;\; \Gamma \vdash B : \star }{ \Gamma \vdash M B : A[a := B] }\]
Iptables and rawsocket [software-000Z]
- July 12, 2019
- Lîm Tsú-thuàn
Iptables and rawsocket [software-000Z]
- July 12, 2019
- Lîm Tsú-thuàn
因為我很懶所以就隨便記錄一下 iptables 就好了
iptables -t nat -I PREROUTING -j LOG --log-prefix="table nat PREROUTING start "
-
-t
指定 table -
-I
是 insert to XXX 的意思 -
-j
是插入的規則 -
LOG
會讓 kernel 印出經過這個規則的封包 -
--log-prefix
是附在這些封包訊息前面的字串
另外如果使用 rawsocket 來製作 gateway,必須處理 kernel 的重複封包,因為原理上是 kernel 把封包複製一份給 user space,我最近遇到的問題就是因為 kernel 原本的那份封包被放回 NIC 的 TX ring,出到 bridge 時又被 routing rule 丟回來 (ip route add CIDR via GATEWAY_IP
),所以這些封包就在 gateway 跟 bridge 之間被踢來踢去近乎佔滿所有網卡的 IO 導致淒慘的 45kbps 效能 (笑)
Tool. xsltproc
[software-0010]
Tool. xsltproc
[software-0010]
The tool xsltproc
can load .xsl
and .xml
files and produces proper output. For example, using https://git.sr.ht/~jonsterling/forester-to-latex one can produce latex slide from forester tree:
xsltproc ~/forester-to-latex/beamer.xsl math-000E.xml
Tool. DjVu.js [software-0011]
Tool. DjVu.js [software-0011]
The tool can open .djvu
files, some books use this format.
Tool. Penrose [software-000Y]
Tool. Penrose [software-000Y]
Penrose is a tool to create beautiful diagrams.
3. Projects [projs]
3. Projects [projs]
Agda-tree [agdatree-0001]
Agda-tree [agdatree-0001]
Converts *.lagda.tree
to *.tree
.
Contribution. Forester [forester]
Contribution. Forester [forester]
Html2tree [html2tree-0001]
Html2tree [html2tree-0001]
Converts html syntax to forester namespace html syntax.
Contribution. Llir/llvm [llir]
- 2018
- 2024
-
Robin, Lîm Tsú-thuàn
- https://github.com/llir/llvm
Contribution. Llir/llvm [llir]
- 2018
- 2024
- Robin, Lîm Tsú-thuàn
- https://github.com/llir/llvm
project: | github.com/llir/llvm |
ticket tracker: | github.com/llir/llvm/issues |
Minic [minic-0001]
Minic [minic-0001]
這個專案是承襲 multipass compiler 精神的編譯器教學專案。將編譯器分成多個階段,可以大幅減少每個階段的複雜性,提升可維護的程度,在效能上也沒有嚴重的損失。以下是編譯器的主要工作階段
Pass. Remove complex operands [minic-0009]
- July 25, 2024
- Lîm Tsú-thuàn
Pass. Remove complex operands [minic-0009]
- July 25, 2024
- Lîm Tsú-thuàn
這個 pass 的目的是確保所有操作(不管是內建的加減乘除指令或是函數呼叫的引數)的 operand 都是 atomic。
Definition. Atomic [#247]
- July 25, 2024
- Lîm Tsú-thuàn
Definition. Atomic [#247]
- July 25, 2024
- Lîm Tsú-thuàn
雖然不同語言對什麼是 atomic 有不同的定義,但通常都是整數或是變數等電腦容易表達的資料。
雖然電腦沒有變數的直接概念,但暫存器跟堆疊可以提供適當的模擬。
實現這個 pass 的想法是
rco_atom : expr -> atom * (string * rco_expr) list
rco_expr : expr -> rco_expr
rco_atom
回傳的第二個結果用來生成對應的 let bindings。
這同時也是 Compiling with Continuations 第二章中指出用 continuations 表達控制流的好處之一。
Pass. Explicate control [minic-0002]
- January 28, 2024
- Lîm Tsú-thuàn
Pass. Explicate control [minic-0002]
- January 28, 2024
- Lîm Tsú-thuàn
這個 pass 把簡單表達式 rco_expr
轉換成 C-風格的程式,定義如下(略去 cexpr
、catom
等)
type ctail = | Return of cexpr | Seq of cstmt * ctail | Goto of label | If of { cmp : cmp_op; a : catom; b : catom; thn : label; els : label } and cstmt = Assign of string * cexpr | AsStmt of ctail and basic_block = { name : label; body : ctail } and basic_blocks = (label * basic_block) list
可以從下列四個函數出發
explicate_tail : rco_expr -> ctail (* 參數意義分別是 指定值的表達式、指定變數名稱、續延 *) explicate_assign : rco_expr -> string -> ctail -> ctail (* 參數意義分別是 predicate 表達式、then 續延、else 續延 *) explicate_pred : rco_expr -> ctail -> ctail -> ctail explicate_atom : atom -> catom
當然,也不能忘記這個 pass 還需要產出一串基本區塊,因此需要加入適當的 basic_blocks ref
。
Pass. Instruction selection [minic-0003]
- January 28, 2024
- Lîm Tsú-thuàn
Pass. Instruction selection [minic-0003]
- January 28, 2024
- Lîm Tsú-thuàn
Patch instruction for each assign statement and return expression from previous C-style AST.
Pass. Liveness analysis [minic-0006]
- February 4, 2024
- Lîm Tsú-thuàn
Pass. Liveness analysis [minic-0006]
- February 4, 2024
- Lîm Tsú-thuàn
This compiler analysis is trying to find out living variable set of current statement (or instruction since it’s easier to do it with asm-like program). The definition is:
- \(L_\text {after} (k) = L_\text {before} (k+1)\)
- \(L_\text {before}(k) = (L_\text {after}(k) \setminus W(k)) \cup R(k)\)
where
- \(R(k)\) are read variables of the instruction \(I_k\)
- \(W(k)\) is the written location of the instruction \(I_k\)
For example, arm64 instruction mov x0, x1
means moving x1
to x0
, and hence \(R(k) = \{ x1 \}\) and \(W(k) = \{ x0 \}\)
Jump instruction [minic-0007]
- February 4, 2024
- Lîm Tsú-thuàn
Jump instruction [minic-0007]
- February 4, 2024
- Lîm Tsú-thuàn
Jump instruction has a special rule, it’s \(L_\text {after}\) will be the read set of the target block. Refers to CFG. Conditional jump should use the union of read sets of target blocks, since it jumps to more than one place.
Call instruction [minic-0008]
- February 4, 2024
- Lîm Tsú-thuàn
Call instruction [minic-0008]
- February 4, 2024
- Lîm Tsú-thuàn
- Related caller-saved registers should be recorded as write set
- argument-passing registers read set, and hence call instruction should store the arity to ensure only recording enough variables
Pass. Control flow analysis [minic-0005]
- February 4, 2024
- Lîm Tsú-thuàn
Pass. Control flow analysis [minic-0005]
- February 4, 2024
- Lîm Tsú-thuàn
- 如果一個 basic block 沒有續延 (successor),就可以直接套用 Pass [minic-0006] (liveness analysis)
- 否則就需要先去分析其續延 Block,也因此還需要維護一個 block label 到 liveset 的映射
- 迴圈需要另外處理
一個在沒有迴圈下可行的方案是利用 coroutine,當
- 需要的 basic blocks 皆已分析就可以分析此 block
- 否則就 yield 給其他 coroutine 執行
Pass. 衝突圖分析 [minic-000C]
- September 14, 2024
- Lîm Tsú-thuàn
Pass. 衝突圖分析 [minic-000C]
- September 14, 2024
- Lîm Tsú-thuàn
這個 pass 的用途是根據 liveset (Pass [minic-0006]) 分析不能同時使用的變數跟 register,把這些衝突關係記錄成一張圖
- If instruction \(I_k\) is a move instruction
movq s, d
, then for every \(v \in L_\text {after}(k)\), if \(v \ne d\) and \(v \ne s\), add edge \((d, v)\) - For any other instruction \(I_k\), for every \(d \in W(k)\) and every \(v \in L_\text {after}(k)\), if \(v \ne d\), add edge \((d, v)\)
Pass. Register allocation [minic-000B]
- September 14, 2024
- Lîm Tsú-thuàn
Pass. Register allocation [minic-000B]
- September 14, 2024
- Lîm Tsú-thuàn
register allocation 是根據衝突圖,進行實際的 register 分配。這個需求就等於在 conflict graph 上著色,相鄰點不同色,所以需要著色演算法。
Coloring 演算法:DSATUR [cs-001J]
- September 14, 2024
- Lîm Tsú-thuàn
Coloring 演算法:DSATUR [cs-001J]
- September 14, 2024
- Lîm Tsú-thuàn
W <- G.vertices -- W 表示 working set while W ≠ ∅ -- 1. 從 W 選出有最大 saturation 的頂點 u -- 2. 選出不在鄰邊的顏色集合中,最小的顏色 c color[u] <- c -- 3. 分配顏色 c 給 u W <- W - {u} -- 從 W 中刪除 u
這個演算法還需要最大 saturation 的定義:
\[ \text {saturation}(u) = \{ c \;|\; \exists v. v\in \text {adjacent}(u) \;\text {and}\; \text {color}(v) = c \} \]saturation 是一個集合,最大指的是該集合的大小, 所以 \(W\) 可以用 leftist tree 之類的結構來快速選出有最大 saturation set 的那個頂點
Pass. Patch stack operations [minic-000A]
- September 14, 2024
- Lîm Tsú-thuàn
Pass. Patch stack operations [minic-000A]
- September 14, 2024
- Lîm Tsú-thuàn
After register allocation, we might have instruction trying to read/write a stack pointer with shift. However, one cannot just touch stack like that in AArch64, and hence, we need a patch to replace
- insert
ldr
to read stack - insert
str
to write stack
in proper place.
Arm64 的比較指令 [minic-0004]
- February 4, 2024
- Lîm Tsú-thuàn
Arm64 的比較指令 [minic-0004]
- February 4, 2024
- Lîm Tsú-thuàn
假設今天想要比較 x0 <= x1
是否為真,那就可以用下列指令
cmp x0, x1 mov x2, 1 mov x3, 0 csel x0, x2, x3, le
最後的 csel
會在 LE 成立時把 x0
設定為 x2
,反之則把 x0
設為 x3
,以此達成儲存比較結果的功能
Typed/racket eff [typed-racket-eff]
Typed/racket eff [typed-racket-eff]
An effect system integrated with typed/racket.
Violet [violet-0001]
Violet [violet-0001]
violet is a programming language I created for researching dependent type in use, the source code is written in lean. If you want to contribute the project, you will need the below information:
project: | sr.ht/~dannypsnl/violet |
ticket tracker: | sr.ht/~dannypsnl/violet/trackers |
mailing lists: | sr.ht/~dannypsnl/violet/lists |
- send patch to development mailing list: ~dannypsnl/[email protected].
- discuss on lists.sr.ht/~dannypsnl/violet-discuss.
Changelog. Violet 0.1 [Unreleased] [violet-0002]
- January 1, 2024
Changelog. Violet 0.1 [Unreleased] [violet-0002]
- January 1, 2024
The language currently support
- inductive types definition (incomplete)
- top-level function definition
- recursion for top level definitons
- implicit parameters
- pattern matching
- tuples
- record definition
Webmentions DB [webmentionsdb-0001]
Webmentions DB [webmentionsdb-0001]
A local cache management system for webmentions, it daily
- fetch new mentions from https://webmention.io/
- produce mentions tree for each mentioned target (a URL that usually is your site post).
Contribution. 帶你探索 functional programming [functional-programming]
Contribution. 帶你探索 functional programming [functional-programming]
project: | github.com/FizzyElt/functional-programming |
ticket tracker: | github.com/FizzyElt/functional-programming/discussions |
Racket-llvm [racket-llvm]
Racket-llvm [racket-llvm]
LLVM bindings for racket
Redux [redux]
Redux [redux]
Rocket [rocket]
- 2018
- 2022
-
Lîm Tsú-thuàn, kw
- https://github.com/dannypsnl/rocket
Rocket [rocket]
- 2018
- 2022
- Lîm Tsú-thuàn, kw
- https://github.com/dannypsnl/rocket
4. Talks [talks]
4. Talks [talks]
Reference. General recursion [talk-0006]
- October, 2023
- Lîm Tsú-thuàn
- Kaohsiung Medical University, Healthcare Adminstration and Medical Informatics
- Slides
Reference. General recursion [talk-0006]
- October, 2023
- Lîm Tsú-thuàn
- Kaohsiung Medical University, Healthcare Adminstration and Medical Informatics
- Slides
Reference. Types cross languages [talk-0005]
- July, 2023
- Lîm Tsú-thuàn
- ∞-type café 2023
- Slides
Reference. Types cross languages [talk-0005]
- July, 2023
- Lîm Tsú-thuàn
- ∞-type café 2023
- Slides
Reference. Can this program stop? [talk-0004]
- November, 2022
- Lîm Tsú-thuàn
- Kaohsiung Medical University, Healthcare Adminstration and Medical Informatics
- Slides
Reference. Can this program stop? [talk-0004]
- November, 2022
- Lîm Tsú-thuàn
- Kaohsiung Medical University, Healthcare Adminstration and Medical Informatics
- Slides
Reference. Closure conversion [talk-0003]
- July, 2022
- Lîm Tsú-thuàn
- coscup 2022
- Slides
Reference. Closure conversion [talk-0003]
- July, 2022
- Lîm Tsú-thuàn
- coscup 2022
- Slides
Reference. Clojure isn't lisp enough [talk-0002]
- April, 2021
- Lîm Tsú-thuàn
- clojure taiwan
- Slides
Reference. Clojure isn't lisp enough [talk-0002]
- April, 2021
- Lîm Tsú-thuàn
- clojure taiwan
- Slides
Reference. Macro as type [talk-0001]
- March, 2021
- Lîm Tsú-thuàn
- racketfest 2021
- Slides
- Video
Reference. Macro as type [talk-0001]
- March, 2021
- Lîm Tsú-thuàn
- racketfest 2021
- Slides
- Video
5. Tools [tools]
5. Tools [tools]
Tool 5.3. Lean [#242]
Tool 5.3. Lean [#242]
- language reference https://lean-lang.org/doc/reference/latest/
- document of mathlib https://leanprover-community.github.io/mathlib4_docs/
5.4. Math online resources [#243]
5.4. Math online resources [#243]
- Kerodon https://kerodon.net/
- The Clowder Project https://www.clowderproject.com/index.html
- Complex Analysis https://complex-analysis.com/content/table_of_contents.html
Tool 5.5. Tikz [#244]
Tool 5.5. Tikz [#244]
manual https://tikz.dev/