The algebra (and calculus) of algebraic data types
The relationship between algebraic data types (ADTs) and mathematical algebra is explored, emphasizing similarities in operations. Examples like Choice and binary trees illustrate how algebraic rules apply to ADTs, despite challenges with structures like Nat. Poking holes in data structures is introduced as a way to understand calculus on data types.
Read original articleThe article delves into the relationship between algebraic data types (ADTs) and mathematical algebra, highlighting their similarities in operations. It explores how counting the number of inhabitants of a type aligns with algebraic expressions and how algebraic manipulations can provide insights into the nature of data types. The text demonstrates these concepts through examples like Choice and binary trees, showcasing how algebraic rules can be applied to ADTs. Additionally, it touches on the challenges faced when dealing with certain data structures like Nat, where inconsistencies arise. The piece also introduces the idea of poking holes in data structures as a precursor to understanding calculus on data types, drawing parallels between finding holes in data and the rules of differentiation. Through these explorations, the article aims to provide a deeper understanding of the algebraic foundations of ADTs and their implications for programming.
Related
Relational Algebra Primer
Relational algebra is crucial for databases like PostgreSQL and MySQL. Bmg, a Ruby tool, enhances querying with in-memory datasets, complementing SQL databases. Understanding relational algebra boosts SQL skills and data processing efficiency.
Relational Algebra Primer
Relational algebra underpins databases like PostgreSQL and MySQL. Bmg, a Ruby tool, bridges relational algebra and SQL databases, aiding data manipulation. Understanding relational algebra enriches SQL database skills and Bmg utilization.
Guide to Machine Learning with Geometric, Topological, and Algebraic Structures
The paper discusses the shift in machine learning towards handling non-Euclidean data with complex structures, emphasizing the need to adapt classical methods and proposing a graphical taxonomy to unify recent advancements.
Parse, Don't Validate
The article explores type-driven design in programming, emphasizing "Parse, don’t validate" in Haskell. It showcases using types for robust code, avoiding errors, and enhancing input parsing efficiency in various tasks.
Types as Interfaces
The article explores using wrapper types like Msg and Timestamped in Haskell to annotate data without modifying existing types directly. It discusses challenges in composing annotated types and suggests using typeclasses for solutions. Emphasizes simplifying code for essential variants.
But, fascinatingly, integration does in fact have a meaning. First, recall from the OP that d/dX List(X) = List(X) * List(X). You punched a hole in a list and you got two lists: the list to the left of the hole and the list to the right of the hole.
Ok, so now define CrazyList(X) to be the anti-derivative of one list: d/dX CrazyList(X) = List(X). Then notice that punching a hole in a cyclic list does not cause it to fall apart into two lists, since the list to the left and to the right are the same list. CrazyList = CyclicList! Aka a ring buffer.
There's a paper on this, apologies I can't find it right now. Maybe Alternkirch or a student of his.
The true extent of this goes far beyond anything I imagined, this is really only the tip of a vast iceberg.
> Nat = 1 + Nat. This equation is clearly inconsistent, since x=1+x is false for all possible values of x.
Ah, but no, my friend. That equation is false merely for all possible finite values of x. But why impose such a constraint? We've already been identifying a correspondence between certain types and the number of inhabitants they have. Nat has countably many inhabitants. And one more than countably infinite is countably infinite!
The algebra and calculus of algebraic data types - https://news.ycombinator.com/item?id=17942112 - Sept 2018 (48 comments)
The Algebra of Algebraic data types - https://news.ycombinator.com/item?id=9775467 - June 2015 (40 comments)
Dumb idea: Unzipping?
Differentiation takes as input the overall structure and extracts the behavior at a certain location. Integration takes the behavior at many different locations and returns a coherent picture of the overall structure.
I'm struggling to picture the math. Does this work the way I envision?
1) A brief introduction to the Algebra of Types (nice intuitive explanation) - https://code.egym.de/a-brief-introduction-to-the-algebra-of-...
2) Algebraic data type - https://en.wikipedia.org/wiki/Algebraic_data_type
3) Comparison of programming languages (algebraic data type) - https://en.wikipedia.org/wiki/Comparison_of_programming_lang...
This makes me wonder, is there a ring of types? There's addition and multiplication. Division and subtraction aren't necessary to define a ring, so their absence isn't particularly surprising.
However, I have grown skeptical on its pedagogical use in programming. Specifically, I question if it is really how most people think in terms of programming.
I further question if this is how most modelling considers things. An easy example would be chemistry. There are algebraic ideas in chemistry, but I would struggle to say how they look the same as this.
Am I looking past an obvious aide to modelling that these approaches can give? I appreciate how this post acknowledges that there are not obvious uses of integration and such, but I feel that sort of proves my point. There are familiar mathematical tools that are good to use when we can. This does not mean you need to force them onto everything you have.
It would probably help me a ton, if I ever saw these applied to state machines?
Related
Relational Algebra Primer
Relational algebra is crucial for databases like PostgreSQL and MySQL. Bmg, a Ruby tool, enhances querying with in-memory datasets, complementing SQL databases. Understanding relational algebra boosts SQL skills and data processing efficiency.
Relational Algebra Primer
Relational algebra underpins databases like PostgreSQL and MySQL. Bmg, a Ruby tool, bridges relational algebra and SQL databases, aiding data manipulation. Understanding relational algebra enriches SQL database skills and Bmg utilization.
Guide to Machine Learning with Geometric, Topological, and Algebraic Structures
The paper discusses the shift in machine learning towards handling non-Euclidean data with complex structures, emphasizing the need to adapt classical methods and proposing a graphical taxonomy to unify recent advancements.
Parse, Don't Validate
The article explores type-driven design in programming, emphasizing "Parse, don’t validate" in Haskell. It showcases using types for robust code, avoiding errors, and enhancing input parsing efficiency in various tasks.
Types as Interfaces
The article explores using wrapper types like Msg and Timestamped in Haskell to annotate data without modifying existing types directly. It discusses challenges in composing annotated types and suggests using typeclasses for solutions. Emphasizes simplifying code for essential variants.