Category Theory Illustrated: Logic (2021)
(abuseofnotation.github.io)- Logic starts from atomic propositions accepted as true and builds larger propositions using operators such as
and,or, andimplies; as in category theory, composition is central. - Classical logic interprets propositions as true/false Boolean values, and logical operators as Boolean functions, handling negation, conjunction, disjunction, implication, and equivalence with truth tables.
- The BHK interpretation of intuitionistic logic views propositions as objects that have proofs, interpreting
A ∧ Bas a pair of proofs andA → Bas a function that turns a proof ofAinto a proof ofB. - In some categories, objects correspond to propositions and morphisms to proofs; in orders, this appears as a preorder or partial order where
A ≤ BmeansA → B. - Intuitionistic logic corresponds order-theoretically to Heyting algebra, and in general category theory to a bicartesian closed category; conjunction, disjunction, true, false, and implication correspond respectively to meet/join, terminal/initial, and exponential object.
Logic starting from propositions
- Logic deals with formal rules that are consistent with themselves regardless of observation, and is a system for concluding or proving that something else is true when something is known.
- A mathematical theory can be seen as logic plus additional definitions.
- Set theory can be defined by adding the primitive concept of a set membership relation to the standard axioms of logic.
- To begin logic, you need an initial set of propositions accepted as true or false.
- These are called premises, atomic propositions, or primary propositions.
- Two or more propositions become a single composite proposition through logical operators such as
and,or, andimplies/entails.∧meansand.∨meansor.→meansfollowsor implication.
- Composite propositions can again be composed with other propositions, just like atomic propositions.
Modus ponens and tautologies
- Modus ponens is an old logical pattern: if
Ais true andA → Bis true, thenBis also true.- Its form is
(A ∧ (A ⇒ B)) → B. - It is expressed with examples such as “If Socrates is human, and if humans die, then Socrates dies.”
- Its form is
- Logic deals not only with single operations but also with combinations of, and relationships among, multiple logical operations.
- The relationship between
andandimpliesappears in modus ponens. - The distributive laws of
andandorare also a major topic of interest.
- The relationship between
- A tautology is a proposition that is always true regardless of the truth values of its component propositions.
- Modus ponens is always true as an entire formula, whether
AandBare true or false. - A proposition that is always false is called a contradiction.
- Adding
notto a tautology makes it a contradiction, and addingnotto a contradiction makes it a tautology.
- Modus ponens is always true as an entire formula, whether
- A proposition whose truth or falsity changes depending on values is called a contingent statement, and falls outside the main concerns of logic.
- The simplest tautology is the law of identity, that each proposition implies itself.
Axiom schemas and logical systems
- Tautologies become the basis of axiom schemas and rules of inference.
- An axiom schema is a formula containing placeholders, and concrete propositions can be made by replacing the placeholders with propositions.
- If you remove colors or concrete propositions from modus ponens, the general structure remains.
- By inserting atomic or composite propositions into that structure, you can make a specific modus ponens proposition.
- Rules of inference can be used in almost the same way as axiom schemas, and axiom schemas can also be applied like rules of inference.
- Every tautology can be used as an axiom schema.
- A logical system or formal system is a collection of axiom schemas and rules of inference, and it generates all possible propositions by applying them.
- As an example, a system made up of five axiom schemas and the modus ponens rule of inference is presented.
- The fact that such a logical system is complete is connected to Gödel's completeness theorem.
Truth-functional interpretation of classical logic
- Classical logic is based on the dichotomy that a proposition is either true or false.
- In the classical interpretation, propositions and operators are defined as follows.
- A proposition is something true or false, like a Boolean value.
- A logical operator is a function that takes one or more Boolean values and returns a Boolean value.
- Negation
¬pis a unary operation, changing true to false and false to true.- The same content can be expressed with a truth table.
- Double-negation elimination is proved by applying negation twice and returning to the starting value.
andtakes two Boolean values and returns true only when both are true.p ∧ q → pp ∧ q → q
orreturns true if at least one of two Boolean values is true.p → p ∨ qq → p ∨ q
implies, or material condition, is writtenp → q, and is false only whenpis true andqis false.- In classical logic,
p → qis the same as the case where¬p ∨ qis true.
- In classical logic,
if and only if, oriff, is true when two propositions have the same value.P ↔ Qis equivalent toP → Q ∧ Q → P.
- The equivalence of
p → qand¬p ∨ qcan be proved not only with truth tables but also with axioms and rules of inference.- A complete proof of equivalence requires proofs in both directions.
Intuitionistic logic and the BHK interpretation
- Intuitionistic logic views proof as construction rather than the discovery of universal truth.
- From this viewpoint, we cannot use the dichotomy that every proposition must be either true or false.
- Some propositions may be unproved not because they are false, but because they lie outside the scope of the given logical system.
- The twin prime conjecture is often presented as such an example.
- In the Brouwer–Heyting–Kolmogorov (BHK) interpretation, proofs, rather than propositions, are central.
- A proposition is something that has a proof.
- Logical operators are constructions that make proofs from other proofs.
- A proof of
A ∧ Bis a pair consisting of a proof ofAand a proof ofB, that is, a product. A → Bmeans that there exists a function converting a proof ofAinto a proof ofB.- The set of proofs of
A → Bis expressed as the set of functions fromAtoB, that is, a hom-set. - If this set is empty, there is no way to turn a proof of
Ainto a proof ofB.
- The set of proofs of
- The BHK interpretation has no separate iff operator, but it does have arrows.
- When there is a function from
AtoBand fromBtoA, the two propositions are treated as equivalent. - From the set viewpoint, this is a situation where the proof sets of the two propositions are isomorphic.
- When there is a function from
- Negation does not simply mean that there is no proof; rather, one must show that assuming
Ais true leads to a contradiction.⊥serves as the proof of a formula with no proof, namely False or the bottom value.- In BHK,
¬Ais read asA → ⊥. - In set theory,
⊥is represented by the empty set.
Viewing logic as a category
- The BHK interpretation provides a high-level perspective for interpreting logic through category theory.
- Some categories can be seen as logical systems.
- Objects are propositions.
- Morphisms are proofs.
- Not every category becomes a logical system; conditions are needed so that there are objects corresponding to valid logical propositions and no objects corresponding to invalid propositions.
- A category satisfying such conditions is called a bicartesian closed category.
- As a simple case, looking first at an order, a logical system and its set of atomic propositions form a category.
- If there is only one way from
AtoB, or differences are ignored, it becomes a preorder. - If propositions that follow from each other are regarded as equivalent, it becomes a partial order.
A ≤ BmeansA → B.
- If there is only one way from
- In a Hasse diagram, when
Ais belowB,A → Bholds.
Order-theoretic correspondences of logical operations
- In the BHK interpretation, logical
andandorappear as product and sum; in order theory, they correspond to meet and join. - To be a logical system, any two propositions must be combinable with
andoror, so the order must have meet and join for all elements.- Such an order is called a lattice.
- An important law between
andandoris distributivity.- If
A ∧ (B ∨ C) ≅ (A ∧ B) ∨ (A ∧ C)holds for allA,B, andC, it is a distributive lattice.
- If
- To express intuitionistic logic, the lattice must also have elements corresponding to
TrueandFalse.Falseis written⊥, and is connected to the principle of explosion, that if there is a proof of False, then any proposition can be proved.Trueis written⊤; it follows from every proposition, but nothing meaningful follows from it by itself.
- In an order,
TrueandFalseare respectively the greatest object and the least object.- In category-theoretic terms, they correspond to the terminal object and the initial object.
- A lattice with least and greatest elements is a bounded lattice.
Implication objects and exponential objects
- A lattice expressing a logical system needs, for every pair
A,B, an implication object representing the proposition thatAimpliesB. - This object is defined by the modus ponens structure.
A ∧ (A ⇒ B) → Bmust hold.
- This condition alone is not enough.
- Other objects such as
A ⇒ B ∧ CorA ⇒ B ∧ C ∧ Dcould fit in the same place. - The actual
A ⇒ Bis the greatest object among theXs satisfyingA ∧ X → B.
- Other objects such as
- In order theory,
A ⇒ Bis called an exponential element or relative pseudo-complement.- It is the greatest
XsatisfyingA ∧ X ≤ B.
- It is the greatest
- Logically, the most trivial proposition
XsatisfyingA ∧ X → Bis the implication propositionA ⇒ B. - Category-theoretically, it is defined as an exponential object or internal homomorphism object.
- There must be a morphism
A × X → B. - From any other candidate object with the same property, there must exist a unique morphism to the actual exponential object.
- There must be a morphism
- This definition of the implication object fits intuitionistic logic.
- In classical logic, because of the law of excluded middle,
A ⇒ Bsimplifies to¬A ∨ B.
- In classical logic, because of the law of excluded middle,
- Like meet, join, and implication objects,
A ⇒ Bis defined up to a unique isomorphism.
Heyting algebra and bicartesian closed categories
- Intuitionistic logic consists of
True,False,and,or, andimplies. - Expressed as an order, it becomes a Heyting algebra.
- It has join and meet.
- It has greatest and least objects.
- It has implication objects.
- An intuitionistic logical system can be viewed as a Heyting algebra.
andandorare meet and join.TrueandFalseare greatest and least objects.impliesis the exponential object.
- If the same definition is adapted to general categories, it becomes a bicartesian closed category.
- It has products and coproducts.
- It has initial and terminal objects.
- It has exponential objects.
- An intuitionistic logical system can also be viewed as a bicartesian closed category.
andandorare product and coproduct.TrueandFalseare terminal and initial objects.impliesis the exponential object.
- A lattice that follows classical logic must be complemented in addition to being bounded and distributive.
- For each proposition
A, there is a unique¬AsatisfyingA ∨ ¬A = 1andA ∧ ¬A = 0. - Such a lattice is called a Boolean algebra.
- For each proposition
A simple proof in categorical logic
A ∨ ⊤ ≅ ⊤follows directly from the definition of join.- Join is the least upper bound greater than or equal to two objects.
- Since the only object greater than or equal to
⊤is⊤itself, the join of anyAand⊤is⊤. - Logically, this is the tautology “any
Aor True is True.”
- If
A → Bexists, thenA ∨ B = B.- If one of two objects is above the other, the join is the higher object.
- This can be seen as a generalization of
A ∨ ⊤ = ⊤. - This is because
A → ⊤always holds for every objectA.
- The law of identity can also be proved with an implication object.
A ⇒ Ais the greatestXsatisfyingA ∧ X → A.- Since this condition holds for every
X, it becomes the greatest object⊤. - Therefore,
A → Ais always true.
- If
Asemantically entailsBin every model,A ⊨ B, thenA ⇒ Balso corresponds to⊤.- Since
Aitself already impliesB,A ∧ X → Bholds for everyX. - This is also called the deduction theorem.
- Since
Building logic with Free Heyting algebra
- To perform logic, first choose the atomic propositions to use according to the problem domain.
- If the chosen kind of logic is intuitionistic logic, you must draw composite propositions such as
A ∧ BandA ∨ Bas a graph for everyAandB. - Since compositions of composite propositions must also be included again, the full list becomes infinite.
- Whether one proposition implies another is checked by following paths of arrows out from the starting proposition.
- Performing logic is the process of finding a path from what is already known to what one wants to prove, or of constructing a proof by manipulating proofs already in hand.
- In intuitionistic logic, it is generally difficult to prove that some fact is unreachable from the axioms, that is, that it cannot be proved.
1 bình luận
Ý kiến trên Hacker News
Trang này thật sự rất tuyệt, và tôi đã gặp lại nó nhiều lần khi học các nội dung liên quan
Dù vậy, tôi vẫn muốn bỏ một phiếu cho hướng học với Milewski. Học thứ này là cả một hành trình, và tác giả của ct-illustrated có vẻ vẫn đang ở giữa hành trình đó
Milewski là người đã đi con đường ấy nhiều lần rồi, nên sách và blog của ông ấy là điểm khởi đầu tốt
https://github.com/hmemcpy/milewski-ctfp-pdf Book
https://bartoszmilewski.com/2014/10/28/category-theory-for-p... Blog
Có vẻ ông ấy cho rằng cứ viết bằng văn xuôi nhẹ nhàng, thiếu chính xác thì cái gì cũng dễ hiểu hơn, nhưng vì thế nó gần như vô dụng với tư cách tài liệu tham khảo
Hoàn toàn không phải vậy¹
¹) https://news.ycombinator.com/item?id=41756286
Nhưng ở chỗ làm, tôi đang dùng lý thuyết phạm trù cho toàn bộ mô hình miền của mình
Trước đây đã từng được thảo luận dưới một URL khác
https://news.ycombinator.com/item?id=28660131 (2 bình luận)
https://news.ycombinator.com/item?id=28660157 (112 bình luận)
Ở phần đầu cuốn sách, tôi bắt gặp câu này rất hay khi so sánh toán học với khoa học hay kỹ thuật
“Vì điều này mà các nhà toán học rơi vào một vị thế kỳ lạ, có thể nói là rất đặc thù, nơi họ luôn phải biện hộ cho công việc mình làm dưới góc độ giá trị đối với các lĩnh vực học thuật khác. Xin nhấn mạnh lại, nếu chuyện này xảy ra với bất kỳ lĩnh vực học thuật nào khác thì sẽ bị xem là vô lý.”
Bất kỳ ai từng học một lĩnh vực không dẫn trực tiếp tới kết quả kiếm ra tiền đều có thể đồng cảm với ý này, và thật vui khi nghe rằng cả những người có năng khiếu về số má cũng phải vật lộn với dao cạo của Milton Friedman
Toàn bộ nghiên cứu “hậu thực dân” ngày nay chẳng qua chỉ là backend của quyền lực mềm Mỹ, và khi chiến tranh nổ ra có lẽ còn sẽ là backend của cả quyền lực cứng
Sơ đồ vòng tròn trong vòng tròn sẽ không chịu tải tốt khi mở rộng quy mô nếu các vòng tròn bên trong luôn được đặt ở giữa theo chiều dọc
Có câu chuyện thành công nào về việc dùng lý thuyết phạm trù để giải quyết hữu ích một bài toán CS/SWE mà nếu không có lý thuyết phạm trù thì không giải được không? Monad không tính, vì nếu tình huống cần thì người ta tự nhiên cũng sẽ phát minh ra nó thôi
Tôi đã học nó một năm ở cao học nhưng cuối cùng vẫn bỏ cuộc
Một trong những định lý nền tảng nhất của bổ đề Yoneda trực tiếp nói rằng mọi bài toán được diễn đạt bằng ngôn ngữ của các phạm trù đều có thể được dịch sang ngôn ngữ của tập hợp và hàm số. Điều tương tự cũng đúng với mọi đối tượng toán học được định nghĩa bằng tập hợp, nên bạn luôn có thể thay tên bằng định nghĩa
Phần mà ngôn ngữ phạm trù đóng góp vào khung ngầm của một lý thuyết không thể lớn hơn định nghĩa của “phạm trù”, mà định nghĩa đó thì rất nhỏ. Cũng giống như hỏi tại sao lại dùng nhóm trong khi “một phép toán trên tập hợp có tính kết hợp, tính đóng, đơn vị và nghịch đảo” có vẻ dễ tiếp cận hơn
Đại số trừu tượng dựa trên một thư viện các định nghĩa chỉ những kiểu phép toán trên tập hợp vừa đủ đơn giản nhưng lại xuất hiện rất thường xuyên. Công cụ hay kỹ thuật không phải là thứ có thể tìm thấy bên trong định nghĩa
Vành, không gian vectơ, mô-đun thường được chấp nhận ngay, nhưng với phạm trù thì lại chia thành người tin và người không tin. Tôi tò mò vì sao chuyện đó lại xảy ra
Khi tôi phỏng vấn Leland McInnes, ông ấy giải thích khá chi tiết rằng lý thuyết phạm trù đã đóng vai trò lớn trong việc nối các điểm lại với nhau, dù trong mã nguồn thực tế của kết quả cuối cùng nó không nhất thiết là bắt buộc
Nhìn vào mức cải thiện tương đối so với t-SNE, vốn là kỹ thuật tiên tiến nhất trước đó, đây là ví dụ duy nhất khiến tôi phải nghĩ lại về những chỉ trích của mình đối với cách người ta nói về lý thuyết phạm trù trong phần mềm
https://arxiv.org/abs/1802.03426
Lý thuyết phạm trù là một ngôn ngữ đồng thời là một công cụ, nên điều gì nói được bằng ngôn ngữ phạm trù thì cũng có thể nói bằng ngôn ngữ khác
Giống như ô tô, nếu bạn học được cách lái — mà đường cong học tập ở đây cực kỳ dốc — thì bạn có thể đi nhanh hơn. Về nguyên tắc thì không có gì là không thể đến được chỉ vì bạn không nhắc tường minh đến các khái niệm của lý thuyết phạm trù
Theo hiểu biết rất hạn chế của tôi, một phần quan trọng của lý thuyết phạm trù là đặc trưng hóa các đối tượng bằng tính chất phổ quát
Một tính thực dụng khác của lý thuyết phạm trù là nó cung cấp ngôn ngữ chung để các nhà khoa học máy tính, nhà toán học và nhà vật lý cùng trao đổi. Nếu mọi người đều gọi cùng một mẫu hình bằng những cái tên khác nhau và các định nghĩa hơi không tương thích với nhau thì cộng tác sẽ không dễ
Bản pre-alpha hiện chủ yếu dành cho mô hình hóa động lực học hệ thống, nhưng chúng tôi xem nền tảng phạm trù là thiết yếu cho phạm vi công việc mà mình nhắm tới. Tôi rất sẵn lòng nghe ý kiến của bất kỳ ai
https://topos.site/blog/2024-10-02-introducing-catcolab/
Tôi nghĩ lý thuyết phạm trù hữu ích, nhưng có lẽ vẫn chưa phải trong điện toán
Nếu không có việc thực tế buộc phải dùng, nó tất nhiên sẽ rất khó. Có thực sự cần phải hiểu thấu đáo tính chất phổ quát, hàm tử adjoint, và bổ đề Yoneda không? Nếu không cần, thì việc học xem chúng là gì sẽ rất vất vả
Điều thú vị là kinh nghiệm lập trình hàm giúp ích cho việc hiểu lý thuyết phạm trù, nhưng chiều ngược lại thì không hẳn vậy. Ví dụ, đa hình tham số đem lại trực giác về biến đổi tự nhiên, và biến đổi tự nhiên là cốt lõi của mọi ứng dụng của lý thuyết phạm trù
Những ứng dụng thật sự thuyết phục của lý thuyết phạm trù mang tính toán học rất cao. Có thể tìm thấy chúng trong tôpô đại số, lý thuyết biểu diễn, hình học đại số và logic phi cổ điển
https://en.m.wikipedia.org/wiki/ZX-calculus
https://zxcalculus.com/
https://www.reddit.com/r/quantum/s/2NzsJaDYwm
Có lỗi
“Modus ponens là một mệnh đề gồm hai mệnh đề khác, ở đây ký hiệu là A và B; nếu mệnh đề A đúng và mệnh đề A --> B cũng đúng, tức A hàm ý B, thì ta nói B cũng đúng. Ví dụ, nếu biết ‘Socrates là con người’ và ‘con người thì phải chết’, ta cũng biết ‘Socrates phải chết’.”
Ví dụ này không phải là một trường hợp của modus ponens, vốn là quy tắc của logic mệnh đề, mà là tam đoạn luận hạng từ cần đến logic vị từ
Ở đây nói rằng “logic là khoa học về cái khả hữu”, nhưng chẳng phải logic nên là khoa học về cái tất định sao?
Tôi cho rằng cốt lõi là cho phép ta nói một cách dứt khoát điều gì là hợp lệ và điều gì không
Ký pháp sơ đồ khá thú vị
Tác giả có đưa ra các quy tắc suy luận cho các phép biến đổi bảo toàn chân lý của sơ đồ không?