范畴学和物理 Category Theory & Physics

文小刚[MIT 终身教授]:

近代数学不是一个仅仅关于“数”的学问。以范畴学(Category Theory) 为代表的近代数学,更是一门关于关系(Morphism)结构(Structure) 的抽象学问。有趣的是,近年来,这些看似和现实毫无关系的数学理论,特别是:

  1. 代数拓扑Algebraic Topology,
  2. 代数几何 Algebraic Geometry,
  3. 范畴学 Category Theory

已经开始和现代物理深度碰撞

物理革命和新的数学:

1. Newton Physics =>他发明 New Math “Calculus”

2. Maxwell Physics => Magnetic Field => New Math : Fibre Bundle

3. Einstein General Relativity => Gravitational-Space-Time => New Math : Riemann Non-Euclidean Geometry

4. Quantum Physcis => Particles + Wave => Linear Algebra (Quantum Mechanics)

5. Quantum IT Revolution => 量子信息和它们的量子纠缠 (Quantum Entanglement)

我们现在正在经历一场新的物理革命——第二次量子革命。这次革命的主角是量子信息和它们的量子纠缠。这次我们所遇到的新现象,就是很多很多量子比特(qbits) 的纠缠。这种多体量子纠缠的内部结构,正是我们既说不出来,又没有名字的新现象。我们现在正在发展一套新的数学理论(某种形式的范畴学),来试图描写这种新现象。

https://m.toutiaocdn.com/group/6786864463778677252/?app=news_article_lite&timestamp=1580324149&req_id=202001300255480101941000191343BA89&group_id=6786864463778677252

A Programmer’s Regret: Neglecting Math at University – Adenoid Adventures

Advanced Programming needs Advanced Math: eg.

Video Game Animation: Verlet Integration

AI: Stats, Probability, Calculus, Linear Algebra

Search Engine : PageRank: Linear Algebra

Abstraction in Program “Polymorphism” : Monoid, Category, Functor, Monad

Program “Proof” : Propositions as Types, HoTT

https://awalterschulze.github.io/blog/post/neglecting-math-at-university/

Abstraction: Monoid, Category

Category

New Math applied in Modern Physics

【文小刚:物理学的新革命——凝聚态物理中的近代数学 | 众妙之门】
https://m.toutiaocdn.com/group/6712424299841454595/?app=news_article_lite&timestamp=1562923076&req_id=20190712171755010152027098774DD5D&group_id=6712424299841454595&tt_from=android_share&utm_medium=toutiao_android&utm_campaign=client_share

Keywords:

  • Quantum Entanglement (QE) : 量子纠缠
  • Topological Order (Long-range QE) : 拓扑序
  • Topological Insulator (Short-range QE) : 拓扑绝缘体
  • Rigid State : 凝聚态
  • Cohomology : 上同调
  • Tensor : 张量
  • Category Theory : 范畴学
  • Group Theory : 群论
  • Algebraic Topology : 代数拓扑

….

1. Four “Physics” Revolutions aided by Math

Math is applied to explain the Nature (Physics) :

Calculus (Differential Equation) : Newtonian Physics

Riemann Geometry : Einstein General Relativity

Partial Differential Equation: Maxwell Electro-Magnetic Field

Linear Algebra (Matrix) : Quantum Mechanics

Group Theory: Physics / Chemistry Symmetry

Next…

Category Theory : Topological Order of the long-range Quantum Entanglement

Algebraic Topology: Topological Insulator (2016 Nobel Prize Physcis)

2. The 5th Physics Revolution aided by New Math tool : Category Theory

3. Category Theory = “Structural Relationship” Math

4. Algebraic Topology

(想看更多合你口味的内容,马上下载 今日头条)
http://app.toutiao.com/news_article/?utm_source=link

An “Introduction of Introduction” to Category Theory

Category : 范畴 has 3 things: (hence richer than a Set 集合 which is only a collection of objects)

  1. Objects 对象
  2. Arrow (Morphism 态射) between Objects, includes identity morphism.
  3. Associativity 结合性

Functor (函子) between 2 Categories (preserve structure)

Natural Transformation 自然变换

  • Example :
    Matrices -> Determinants

    ..

    Category Theory III for Programmers (Part 1 & 2)

    The most interesting “Category Theory” (范畴论) for Programmers course III by Dr. Bartosz Milewski , a follow-up of last year’s course II.

    Prerequisites:

    1. Fundamental of Category Theory: Functor, Natural Transformation, etc. (Course II Series)
    2. (Nice to have) : Basic Haskell Functional Programming Language. (Quick Haskell Tutorial)

    1.1: Overview Part 1

    Category Theory (CT) = Summary of ALL Mathematics

    Functional Programming = Application of CT

    Philosophical Background:

    • Math originated 3,000 years ago in Geometry by Greek Euclid with Axioms and deductive (演译) Proof-driven Logic.
    • Geometry = Geo (Earth) + Metry (Measurement).
    • Math evolved from 2-dimensional Euclidean Geometry through 17 CE French Descartes’s Cartesian Geometry using the 13CE Arabic invention “Algebra” in Equations of n dimensions: (x_1, x_2,..., x_n) , (y_1, y_2,..., y_n)
    • Use of Algebra: 1) Evaluation of algebraic equations (in CT: “Functor”) ; 2) Manipulation. eg. Substitution (in CT : “Monad” ), Container (in CT: “Endo-Functor” ), Algebraic Operations (in CT: “Pure, Return, Binding” ).
    • Lawvere Theories: unified all definitions of Monoids (from Set to CT)
    • Free Monoid = “List” (in Programming). Eg. Concatenation of Lists = new List (Composition, Associative Law) ; Empty List (Unit Law).
    • Advance of Math in 21CE comes back to Geometry in new Math branches like Algebraic Geometry, Algebraic Topology, etc.

    Note: The only 2 existing human Languages invented were derived from forms & shapes (images) of the mother Earth & Nature:

    1. Ancient Greek Geometry (3000 years) ;
    2. Ancient Chinese Pictogram Characters (象形汉字, 3000 years 商朝. 甲骨文 ) .

    https://youtu.be/F5uEpKwHqdk

    1.1: Overview Part 2

    Keypoints: (just a ‘helicopter’ view of the whole course syllabus)

    • Calculus: infinite Product, infinite Sum (co-Product), End, co-End.
    • Kan-extensions
    • Geometry in “Abstract” aka Topology: “Topos”
    • Enriched Category : (2-category) Analogy : complex number makes Trigonometry easy; same does Enriched Category.
    • Groupoid => “HTT” : Homotopic Type Theory

    https://youtu.be/CfoaY2Ybf8M

    2.1 String Diagrams (Part 1)

    Composing Natural Transformations (Vertical & Horizontal): \alpha \; \beta (assumed naturality)

    https://youtu.be/eOdBTqY3-Og

    2.2 Monad & Adjunction

    https://youtu.be/lqq9IFSPp7Q

    Refs:

    1. Download BM’s book “Category Theory for Programmers” :

    https://github.com/hmemcpy/milewski-ctfp-pdf

    Applied Category Theory Course by Prof John Baez

    Join John Baez’s Azimuth Math Forum 导读 (Study Tour Guide) in Applied Category Theory (CT):

    https://forum.azimuthproject.org/discussion/1717/welcome-to-the-applied-category-theory-course?from=timeline

    John Baez (1961-) is the world’s expert in Category Theory. He gave a talk on CT in Hokkaido University last year.

    The 导读 is using a book by 2 mathematicians Brenden Fong and David Spivak in “Applied Category Theory” – Download the free book of this course here.

    Note: Both John Baez and his wife Lisa Raphals (Professor in Chinese) work now in National University of Singapore – Center of Quantum Technologies & Philosophy, respectively.

    Programmers need Advanced Math ?

    As software becomes more complicated for high-speed trains, driverless cars, missile weapons. .. and AI deeplearning algorithm, we can’t depend our life safety on the programmers who don’t understand the advanced maths behind these algorithms.

    The Advanced Math is the Category Theory – the most advanced math foundation above “Set Theory” since WW2. Functional Programming is based on Category Theory with mathematical functions – always output correctly with no “side-effects”.

    https://www.extremetech.com/computing/259977-software-increasingly-complex-thats-dangerous

    Category Theory – Purest of pure mathematical disciplines may also be a cornerstone of applied solutions in computational science

    There exists in almost all Universities a clear division between pure and applied mathematics. A friendly (and sometimes not so friendly) rivalry exists between both sides of the divide, with separate conferences, separate journals and in many cases even a whole separate language. Category Theory was seen as such an abstract area of research that even pure mathematicians started to refer to it as “abstract nonsense“, and until the mid 1980’s almost all category theorists occupied a place hidden somewhere up above the ‘cloud level’ in the highest reaches of the peaks that defined “pure” maths.

    By the mid 1990’s and then by the turn of the millenium, a whole world of computer programmers were learning basic category theory as part of their induction into functional programming. The best known product of these efforts is the Haskell language, but even in the past 7 or 8 yrs, workshops on category theory for computer programmers of all types have flourished and proliferated. It is almost as if there are two separate communities masquerading as one – mathematical category theory and computer programming category theory – and never the twain would meet. Or so it seemed, until now.

    https://www.linkedin.com/pulse/category-theory-classic-dichotomy-purest-pure-may-also-khan-ksg/

    Alejandro Serrano: Category Theory Through Functional Programming

    (Part 1/3) – λC 2017

    What is Category ?

    Objects

    Morphism (Arrows )

    Rule1: Associative

    Rule 2: Identity

    A <– C –> B

    Product of Categories : A x B

    Unique

    Sum of Categories: A + B

    Unique

    (Either a b)

    Co-Product

    Reverse all arrows.

    Unique

    Functor F: C-> D

    Mapping of all objects (A, B) in categories C,D

    Mapping of arrows f
    f : A -> B
    Ff : FA -> FB (preservation)
    F Id = Id
    F (f。g) = Ff。Fg

    Example:

    Constant C -> F
    FC = k
    Ff = Id

    Arrow Functor F: C -> D

    For any object A in C,

    F A = D -> A
    (Functional Type is also Type)

    Functors compose !

    Category of categories:

    Objects: categories

    Arrows : Functors

    Haskell Category (Hask) is always Endo-Functor, ie Category Hask to itself.

    Mapping of arrows.

    Mapping of Objects = predefined

    (Part 2/3) – λC 2017

    (part 3/3) – λC 2017

    Category Theory II 9: Lenses

    Lens = {get, set}

    w = whole tuple, p = a field

    get :: w -> p
    set :: w -> p -> w

    Example: take a pair (tuple)

    get1 (x, y) = x

    get1 :: (a, b) -> a

    set1 (x, y) x’ = (x’,y)

    set1 :: (a, b) -> a -> (a,b)

    Polymorphic Types: change type of field

    set :: w -> p’ -> w’
    set1 :: (a, b) -> a’ -> (a’,b)

    Lens Laws:

    set w (get w) = id 

    get (set w p) = p

    get (set w p) p’ = set w p’

    Combine get & set (co-Algebra):

    \boxed {w \to(p, p \to w)}

    data Store p w = Store p (p-> w)

    fmap g (Store p f ) = Store p (g.f)
    g: w-> v
    pf : p -> w
    g.f : p-> v

    Store = functor from w to Store = coalgebra = comonad [W a ->a]

    instance Comonad (Store p) where

    extract (Store p f) = f p

    duplicate  (Store x f) = Store x ( λy -> Store y f)

    [Think of p as key, f is the lookup function
    f p = retrieve current value]

    Comonad & coalgebra – compatible?

    (Coalgebra) coalg ::a -> w a
    (Comonad) extract :: w a -> a
    duplicate :: w a ->w (w a)

    coalg w = Store (get w) (set w)

    set w (get w) = id [Lens Law]

    \boxed {\text {Lens = comonad + coalgebra}}

    If Type change (Set = Index Store : a = p, b = p’, t = w)

    IStore a b t = IStore a (b ->t)

    Object-oriented: eg. school.class.student

    <=>”.” = functional programming 



    9.2 Lenses 

    Type Lense s t a b = forall f . Functor f => (a -> f b) -> s -> f t

    s \to \forall f. (a \to f b ) \to f t

    s  ->IStore a b t

    forall  = polymorphism (?  Natural Transformation)

    Yoneda Embedding Lemma

     [C, Set](C (a -> – ), C (b -> – )) ~ C(b, a)

    Adjunction: C (Ld,C) ~ D (D,  Rc)


    Reference: “Understanding Yoneda”

    https://bartoszmilewski.com/2013/05/15/understanding-yoneda/

    adjoint functor in nLab

    Yoneda lemma in nLab

    维基百科: Hom functor
    https://www.zhihu.com/question/23324349/answer/54242934

    The Yoneda Lemma

    Representable Functor F of C ( a, -):

    \boxed {(-)^{a} = \text {F} \iff a = \text {log F}}

    Video 4.2 Yoneda Lemma

    Prove : 

    Yoneda Lemma :
    \text {F :: C} \to \text {Set}

    \boxed {\alpha \text { :: [C, Set] (C (a, -),F) } \simeq \text {F a}}

    \alpha : \text {Natural Transformation}
    \simeq : \text {(Natural) Isomorphism, "naturally" } \forall ( a, F )

    Proof: By “Diagram chasing” below, shows that

    Left-side
    : \alpha \text { :: [C, Set] (C (a, -),F) } is indeed a (co-variant) Functor. (Higher-order Function)

    Right-side: Functor “F a“. (Data Structure)

    \boxed {\forall x, (a \to x) \to \text { F } x \simeq \text { F } a }

    Note: When talking about the natural transformations, always mention their component “x”: \alpha_{x}, \beta_{x}

    Video 5.1 Yoneda Embedding

    Example 1: F = List functor [x]

    \boxed {\alpha \text { :: } (a \to x) \to [x] \simeq [a] }

    Example 2: F = C (b, -)

    \boxed {\alpha \text { :: [C, Set] (C (a, -), C (b, -) ) } \simeq \text {C (b, a)}}

    Note: check a , b is in co-variant or contra-variant position.

    Example 3: F = Id

    \boxed {\alpha \text { :: } (a \to x) \to x \simeq a }

    Right-hand-side: a (data structure)

    Left-hand-side : “(a -> x) “is a function called “handler” (or “continuation“) which takes the argument “a” to provide it as output : “(a -> x ) -> x“.

    eg. handler to database query, over internet…(technique used in Compiler)

    Co-Yoneda Lemma : (Contra-variant a , F)

    \boxed {\alpha \text { :: [C, Set] (C(-, a),F) } \simeq \text {F a}}

    Yoneda Embedding: Full and Faithful
    \alpha \text { :: [C, Set] (C (a, -), C (b, -) ) } \simeq \text {C (b, a)}

    Note: Instead of proving a , b are isomorphic, sometimes it is easier to prove the functors C(a, -) & C(b, -) are isomorphic.[Proof Trivial: functors preserve composition and identity]

    ApplicationCo-Yoneda Lemma : (Contra-variant a , F)
    \boxed {\text {[C, Set] (C(- , a), C(- , b) } \simeq \text {C(a ,b)}}

    Pre-order Category \boxed {a \leq b}

    \forall x, \text {C(x , a)} \to \text {C(x , b)} \simeq \text {C(a , b)}

    C(x , a) = x \leq a = \{\varnothing, 1 \}
    C(x , b) = x \leq b =\{\varnothing, 1 \}

    3 possibilities: (“1” = singleton)
    id_{\varnothing} :: \varnothing \to \varnothing
    absurd :: \varnothing \to 1
    id_{1} :: 1 \to 1
    Note: 1 \to \varnothing impossible (function must have an image)

    Verify

    Right-Hand Side: a \leq b

    Left-Hand Side: \forall x,( x \leq a \implies x \leq b) \implies a \leq b

    Yoneda Embedding (Lagatta)

    BM Category Theory II 1.1: Declarative vs Imperative Approach

    Excellent lecture using Physics and IT to illustrate the 2 totally different approaches in Programming:

    1. Imperative (or Procedural) – micro-steps or Local 微观世界 [eg. C / C++, Java, Python…]
    2. Declarative (or Functional) – Macro-view or Global 大千世界 [eg. Lisp / Clojure, Scala, F#, Haskell…]

    In Math

    1. Analysis (Calculus) 
    2. Algebra (Structures: Group, Ring, Field, Vector Space, Category …)

    In Physics:

    1. Newton (Laws of Motion), Maxwell (equations) 
    2. Fermat (*)  (Light travels in least time), Feynman (Quantum Physics).

    In IT: Neural Network (AI)  uses both 1 & 2.

    More examples…

    In Medicine:

    1. Western Medicine: germs/ viruses, anatomy, surgery
    2. Traditional Chinese Medicine (中医): Accupunture, Qi, Yin-Yang.

    Note (*): Fermat : My alma mater university in Toulouse (France) named after this 17CE amateur mathematician, who worked in day time as a Chief Judge of Toulouse City, after works spending time in Math and Physcis. He co-invented Analytic Geometry (with Descartes), Probability (with Pascal), also was the “Father of Number Theory” (The Fermat’s ‘Little’ Theorem and The Fermat’s ‘Last’ Theorem). He used Math to prove light travels in straight line (before Newton) due to “Least Time taken” (explained here in this BM video).

    https://tomcircle.wordpress.com/2013/04/05/lay-cables-at-least-cost/


    Revision :Part 1 Motivation & Philosophy of Category Theory

    BM Category Theory : Motivation and Philosophy

    Object-Oriented  has 2 weaknesses for Concurrency and Parallel programming : 

    1. Hidden Mutating States; 
    2. Data Sharing.

    Category Theory (CT): a higher abstraction of all different Math structures : Set , Logic, Computing math, Algebra… =>

    \boxed {\text {CT reveals the way how our brain works by analysing, reasoning about structures !}}

    Our brain works by:  1) Abstraction 2) Composition 3) Identity (to identify)

    What is a Category ? 
    1) Abstraction:

    •  Objects
    • Morphism (Arrow)

    2) Composition: Associative 
    3) Identity

    Notes: 

    • Small  Category with “Set” as object. 
    • Large Category without Set as object.
    • Morphism is a Set : “Hom” Set.


    Example in Programming
    :

    • Object : Types Set
    • Morphism : Function “Sin” converts degree to R: \sin \frac {\pi}{2} = 1

    Note: We just look at the Category “Types Set” from external Macroview, “forget ” what it contains, we only know the “composition” (Arrows) between the Category “Type Set”, also “forget” what these Arrows (sin,cosin, tgt, etc) actually are, we only study these arrows’ behavior (Associativity).

    2.1 : Function of Set, Morphism of Category

    Set: A function is 

    • Surjective (greek: epic / epimorphism 满射),
    • Injective (greek : monic / monomorphism 单射)

    Category:  [Surjective]

    g 。f = h 。f
    => g = h (Right Cancellation )

    2.2 Monomorphism 

    f 。g = f 。h
    => g = h
    (Left cancellation)

    \boxed { \text {Epimorphism + Monomorphism =? Isomorphism }}

    NOT Necessary !! Reason ( click here): 

    In Haskell, 2 foundation Types: Void, Unit

    Void = False
    Unit ( ) = True

    Functions : absurd, unit
    absurd :: Void -> a (a = anything)
    unit :: a -> ()

    [to be continued 3.1 ….]

    代 数拓扑 Algebraic Topology (Part 1/3)

    Excellent Advanced Math Lecture Series (Part 1 to 3) by 齊震宇老師

    (2012.09.10) Part I:

    History: 1900 H. Poincaré invented Topology from Euler Characteristic (V -E + R = 2)

    Motivation of Algebraic Topology : Find Invariants [1]of various topological spaces (in higher dimension). 求拓扑空间的“不变量” eg.

    • Vector Space (to + – , × ÷ by multiplier Field scalars);
    • Ring (to + x) in co-homology
    • etc.

    then apply algebra (Linear Algebra, Matrices) with computer to compute these invariants  (homology, co-homology, etc).

    A topological space can be formed by a “Big Data” Point Set, e.g. genes, tumors, drugs, images, graphics, etc. By finding (co)- / homology – hence the intuitive Chinese term (上) /同调 [2] – is to find “holes” in the Big Data in the 10,000 (e.g.) dimensional space the hidden information (co-relationship, patterns, etc).
    Note: [1] Analogy of an”Invariant” in Population: eg. “Age” is an invariant can be added in the “Population Space” as the average age of the citizens.

    Side Reading (Very Clear) : Invariant and the Fundamental Group Primer

    Note [2]: Homology 同调 = same “tune”.

    南朝 刘宋 谢灵运山水诗:
    “谁谓古今殊,异代可同调
    同调 = Homology
    (希腊 homo = 同, -logy = 知识 / 调)

    – “Reading an ancient text  allows us to think “in tune” (or resonant) with the ancient author.”

    [温习] Category Theory Foundation – 3 important concepts:

    • Categories
    • Functors
    • Natural Transformation

    [Skip if you are familiar with Category Theory Basics: Video 16:30 mins to 66:00 mins.]


    [主题] Singular Homology Groups 奇异同调群  (See excellent writeup in Wikipedia) (Video 66:20 mins to end)

    1. Singular Simplices 奇异 单纯
    2. Singular Chain Groups 奇异 链 群
    3. Boundary Operation 边界
    4. Singular Chain Complex 奇异 单纯复形

    Part 1/3 Video (Whole) :

    Category Theory in Computing Languages

    ​Is there any connection between category theory and the way computer languages work? by Thorsten Altenkirch 

    Yes, lots.

    Just one example: a function with 2 inputs from A and B and results from C would have the type A x B -> C but in functional languages like Haskell we are using A -> (B -> C), i.e. a function that returns a function. This “currying” is exactly a the categorical definition of a cartesian closed category as one where Hom(AxB,C) is isomorphic to Hom(A,B -> C) and in this case you can replace Hom(X,Y) with X -> Y.

    It is well known that effects in functional programming can be modelled by monads which is a concept from category theory. Nowadays a weaker structure called applicative functors has become very popular – needless to say also a concept from Category Theory.

    Not all languages are functional (yet) but even non-functional languages can be understood using concepts from category theory.

    See also: 

    Free Categories, Free MonoIds, Monads = MonoId+Endofunctor

    Monad Diagram

    Category Theory by Steven Roman (Part I)

    Excellent Category Theory lectures by retired Prof Steven Roman  from Uni. California: he used pen and A4 – paper with iPhone camera. Simple & good. (Only lighting could be brighter.)

    Category Theory is one level higher abstraction, above the Abstract Algebra (Group, Ring, Field, Vector Space, Set…). It is the “Math of Math”, to make difficult math easy by studying the ‘Relationship’ (or Morphism, drawn as Arrows).

    Lecture 1: study five topics
    ◇ Category
    ◇ Functor
    ◇ Natural Transformatiom
    ◇ Universal Ptoperty
    ◇ Adjoint

    image

    UMP :
    image