[M malloc Book Delivery Issue 1] Isomorphism: Mathematics in Programming

Preliminary overview

In recent years, with the development of artificial intelligence, large-scale distributed computing, multi-core CPU and heterogeneous computing, various programming technologies in computers have changed in terms of programming language, software architecture, compiler, hardware architecture, integrated circuit design, etc. There are drastic changes. In terms of programming languages, more and more mainstream languages ​​introduce the concept of functional programming. In terms of software architecture, there are more parallel computing things and various distributed and concurrent models to make full use of multi-core CPUs. Compilers have developed in more fields of application, such as MLIR, TVM, etc., making full use of hardware acceleration units in heterogeneous computing. In terms of hardware architecture, with the rise of various hardware acceleration units, the original pattern of CPU as the computing center has been changed, and calculations rely more on various hardware acceleration units. In terms of integrated circuit design, in order to realize various hardware acceleration units, it is necessary to shorten the circuit design cycle to more quickly respond to various frequently changing needs. In recent years, many companies have used Bluespec, Chisel, SpinalHDL and other functional features. language to design integrated circuits.

As a programmer, how to deal with these changes? If we have to learn every time a new technology appears, it will make us exhausted and feel like we can't learn - there are too many things to learn. But in fact the basis of these new technologies has not changed much, and some are even recombined on the original basis. Therefore, we should learn more basic technologies, improve abstract thinking ability, and be good at discovering the essence of different technologies and the similar relationship between different technologies (better isomorphic relationship). In this way, we can adapt to all changes without change, master various technologies, and master new technologies at a relatively small cost.

Image] [image

Isomorphism: Math in Programming
Author: Liu Xinyu
`From numbers, recursion, symmetry, categories, fusion, infinity, paradox`
Seven aspects introduce the mathematical foundations and principles of computer programs

The author's idea
In this book, the author expounds some basic mathematical concepts and abstraction methods related to programming in great detail and clearly, and shows these concepts in actual programming, using functional programming language to show in actual programming How good abstractions are made. By reading this book, readers will gain a new way of thinking about programming, good abstraction ability, and have a clearer understanding of mathematical concepts in programming (especially some of the functional programming that has received more and more attention in recent years) Fundamental concepts such as lambda calculus, recursion, algebraic data types, functors, natural transformations, etc.). This book will be very helpful for subsequent learning of functional programming languages ​​or understanding of functional features in mainstream languages.

brief introduction

This book introduces the mathematical basis and principles of computer programs from seven aspects: number, recursion, symmetry, category, fusion, infinity, and paradox, and uses the concept of "isomorphism" as a clue to reveal that programming is essentially isomorphic with mathematics . Chapter 1 introduces the Peano arithmetic axiom system. Through 5 axioms, it builds the cornerstone of the computer program building; through examples such as one-way linked list and Fibonacci sequence, it shows the calculation structure that is isomorphic to natural numbers. Chapter 2 introduces recursion, starting with Euclid's algorithm, and finally building the mathematical principles of recursion on top of Lambda calculus and Y combinators. Chapter 3 introduces abstract algebraic structures such as symmetry groups, rings, and fields, and explains Galois theory, the pearl of abstract thinking. Chapter 4 introduces category theory, and builds many programming concepts such as lists, exceptions, polymorphism, type systems, and composite data structures on the basis of category theory. Chapter 5 introduces fusion laws, which are powerful tools for algorithm derivation and optimization. Chapter 6 introduces infinity, gives Cantor's infinite set theory and the concept of transfinite numbers, and introduces the concept of flow in programming and the relationship of infinity. Chapter 7 concludes the book with Russell's paradox, computability, and Gödel's incompleteness theorem, introducing the boundaries of computing power and implications for the fundamental philosophy of programming.
The book also introduces the life experiences and anecdotes of relevant mathematicians in each chapter, explains how they overcome difficulties, pursue truth, and create miracles, and intersperses interesting connections among programming, mathematics, art, and music.

About the Author

Xinyu Liu
, R&D Manager of Amazon China R&D Center, is responsible for the development of distributed warehousing and logistics systems. In 1999 and 2002, he received his bachelor's degree and master's degree from the Department of Automation, Tsinghua University, respectively. Focusing on functional basic algorithms for a long time, he is the author of "New Solutions to Algorithms" (published in 2017).

Experts recommend

Bacon said: "Mathematics is the gymnastics of thinking." Programming is a highly complex thinking activity. The benefits of learning mathematical ideas for programming are self-evident. The author of this book has read a large number of mathematical classics, selected exquisite mathematical ideas such as recursion and symmetry from the perspective of isomorphism, and conceived it as a book to present to everyone, which is very rare! This is a book that condenses thoughts, concise and to the point, it is worth savoring carefully.
赵俊民 北京荣耀终端有限公司软件架构师

This book not only fully and thoroughly explained the profound isomorphism theory in the algebraic system, but also clearly explained the historical context of the development of mathematics, especially the application of mathematical theory to all aspects of real life, which benefited me as a mathematics lover A lot. It is really gratifying that this book has been published now, so that more mathematics lovers can have the opportunity to read it.
李曲 浙江工业大学计算机学院教师

This book explains the knowledge of mathematical logic, abstract algebra and functional programming in easy-to-understand words. This is the best introductory book on category theory that I have ever read. Every undergraduate student majoring in computer science should read it First read this book.
chirsz GitHub读者

When I read this book for the first time, I felt like I was reading college textbooks, but college textbooks rarely have so many vivid stories to set off and relate. After reading this book carefully, I found that many tasks in real development can be done more interesting and fancy, even if you want to play some tricks, you will not be seen through at a glance. It doesn’t matter if you think this book is too complicated, you might as well read it first, as long as you have a general understanding of what is said in the book, it is enough, and then keep it on your desk, and when you need it, you can use it to find out what to do. You can definitely surpass most of your peers in mathematics.
余晟 《正则指引》作者

book catalog

Table of contents

foreword

Chapter 1 Number 1

1.1 Birth of numbers 1

1.2 Peano's natural number axiom 2

1.3 Natural numbers and computer programs 4

1.4 Structure of natural numbers 6

1.5 Isomorphism of natural numbers 10

1.6 Form and structure 14

Chapter 2 Recursion 16

2.1 Everything is number 16

2.2 Euclidean Algorithm 18

2.2.1 Euclid and Geometry

Original "19

2.2.2 Overview of Euclidean Algorithm 19

2.2.3 Extended Euclidean Algorithm 22

2.2.4 Significance of Euclidean algorithm 26

2.3λ operation28

2.3.1 Expression simplification 30

2.3.2 Lambda Abstraction 31

2.3.3 Lambda transformation rules 31

2.4 Definition of recursion 35

2.5 Significance of λ-calculus 36

2.6 More recursive structures 38

2.7 Form and structure of recursion 39

2.8 Appendix: The complete program of pouring water quiz 42

Chapter 3 Symmetry 43

3.1 What is symmetry 43

3.2 Group 46

3.2.1 Group definition 50

3.2.2 Monoids and semigroups 52

3.2.3 Properties of groups 55

3.2.4 Permutation groups 58

3.2.5 Groups and symmetries 61

3.2.6 Rotational symmetry and cyclic groups 62

3.2.7 The subcircle equation 65

3.2.8 Subgroups 66

3.2.9 Lagrange's theorem 72

3.3 Rings and Domains 82

3.3.1 Ring definition 84

3.3.2 Division rings and domains 86

3.4 Galois theory 87

3.4.1 Domain extension 87

3.4.2 From Newton, Lagrange to Gal

Rova 89

3.4.3 Automorphisms and Galois groups 95

3.4.4 Galois Fundamental Theorem 96

3.4.5 Solvability 98

3.5 Appendix: Galois groups 100

Chapter 4 Categories 102

4.1 Overview of the category 104

4.1.1 Examples of categories 106

4.1.2 Arrows ≠ functions 110

4.2 Functors 111

4.2.1 Definition of functor 111

4.2.2 Examples of functors 112

4.3 Products and sums 118

4.3.1 Definitions of products and sums 120

4.3.2 Properties of products and sums 122

4.3.3 Products and sums as functors 123

4.4 Natural transformations 126

4.4.1 Examples of natural transformations 127

4.4.2 Natural isomorphism 130

4.5 Data types 131

4.5.1 Start and end objects 131

4.5.2 Power 136

4.5.3 Cartesian closure and object arithmetic 140

4.5.4 Polynomial functors 142

4.5.5F - Algebra 143

4.6 Summary 156

4.7 Further reading 158

4.8 Appendix: Example Code 158

Chapter 5 Fusion 160

5.1 Superposition-constructed fusion 161

5.1.1 List superposition operation 162

5.1.2 Superposition-constructing fusion laws 163

5.1.3 The construction form of the list 164

5.1.4 Simplification using fusion laws 165

5.1.5 Type restrictions 167

5.1.6 Deriving fusion laws from category theory 168

5.2 Counting 100171

5.2.1 Exhaustive method 171

5.2.2 Improvements 173

5.3 Summary and further reading 175

5.4 Appendix: Codes for Clever Calculation 100 Problem 175

Chapter 6 177

6.1 Proposition of the concept of infinity 179

6.1.1 The philosophy of infinity 181

6.1.2 The method of exhaustion and calculus 183

6.2 Infinity and programming 186

6.3 Real infinite thinking 191

6.3.1 Gardens of the Infinite Kingdom 192

6.3.2 One-to-one correspondence and infinite sets 194

6.3.3 Countable infinity and uncountable infinity 200

6.3.4 Dedekind partition 203

6.3.5 Transfinite numbers and the continuum hypothesis 205

6.4 Infinity and art 209

6.5 Appendix: Example Code 214

6.6 Appendix: Proof of Cantor's Theorem 215

6.7 Appendix: Bach's Musical Consecration

Canon 216 with infinite ascent

Chapter 7 Paradox 218

7.1 Boundaries of Computation 221

7.2 Russell's paradox 222

7.3 Divergence of mathematical foundations 225

7.3.1 Logicism 225

7.3.2 Intuitionism 227

7.3.3 Formalism 229

7.3.4 Axiomatic set theory 230

7.4 Gödel's incompleteness theorem 232

7.5 Proofs of incompleteness theorems 234

7.5.1 Building formal systems 234

7.5.2 Gödel matching numbers 237

7.5.3 Constructing self-references 238

7.6 Universal programs and diagonal proofs 239

7.7 Epilogue 240

Appendix 241

Proof of the Commutative Law of Addition 241

The Uniqueness of Products and Sums 242

The Cartesian product of sets and the disjoint union form the product

Proofs of sums and sums 243

Refer to answer 246

References 296

picture

Guess you like

Origin blog.csdn.net/m0_64361522/article/details/132106895