Rendered at 09:21:35 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
mananaysiempre 24 hours ago [-]
A couple of notes:
- There’s also the notation 0 for the empty (never, noreturn) type. In addition to matching the number of members, the notations 0 and 1 make sense also as units (neutral elements) of addition and multiplication respectively: 0 + A ≅ A + 0 ≅ A, 1 × A ≅ A × 1 ≅ A in a natural way[1]; and also 0 × A ≅ A × 0 ≅ 0.
- That a constant dependent sum is a product, and a constant dependent product is an exponential, is (undeniably confusing at first but) just[2] the naïve schoolbook definition that A × B = B added to itself A times and A^B = A multiplied by itself B times.
- That a constant dependent product is a function type is just the naïve definition that a function is a table of its values at each input (a tuple, with elements numbered by the possible inputs). A dependent function ( = dependent product), then, is the same thing but the allowable values in each cell of the table vary depending on the cell.
- That the function type is the exponential type is also part of common set-theory notation. For instance, 2^ℕ is a not-infrequent name for the set in the Cantor theorem (subsets of the naturals).
[1] As in, those are not literally the same type but are one-to-one in a single natural way. The word “natural” here has a surprisingly deep technical meaning but one that corresponds to the colloquial pretty well.
[2] “Just”, “simply”, etc. are as usual terms of art that mean that the statement feels very simple once you get it, and conversely that if it does not feel simple then you haven’t gotten it and should stop and think until it does. That thinking can take substantial time and effort.
feelamee 9 hours ago [-]
hm, why 0 and 1 so special?
Is there like "next" operation for which 2 is special?
Like - if there:
product = constant dependent sum
exponential = constant dependent product
then what is constant dependent exponential?
ky3 22 hours ago [-]
In theory
> 0 × A ≅ A × 0 ≅ 0.
In practice, 0 × A ≅ A × 0 ≅ A for the temptation is too great to divide by zero and I don't know of a single programming language that doesn't succumb.
Sharlin 22 hours ago [-]
In the sense that all sorts of operations are in practice divergent for some values of the domain, yeah. But in languages with explicit uninhabited types, the normal rules of algebra apply to those. For example, in Rust which finally got its canonical "never" type stabilized, `(i32, !)` is uninhabited and `Result<i32, !>` is always `Ok(_)` and the compiler knows it.
mananaysiempre 21 hours ago [-]
You’re only right for lazy pairs, I think.
In a strict language (or with a strict pair in a lazy language), you normally won’t be able to (integer) divide by zero while computing a value, then go on to ignore that, pack that erroneous value into a pair, and extract the other, valid value from it and go on with your life.
Similarly, if your program has hung while computing one half of a pair then (except in lazy languages) it will have hung while computing the pair as a whole as well.
(Haskell’s type algebra is indeed somewhat subtler.)
xelxebar 23 hours ago [-]
Natural number, natural logarithm, natural units, natural frequency. I'm not a fan of the term, though it's better than the worst offenders, "normal" and "regular"
> In the normal extension K/Q, every normal subgroup of the regular representation acts on a normal scheme that is regular in codimension one, whose normal bundle — orthonormal to the regular surface at each regular value — carries a normal operator whose spectrum follows a normal distribution over a space that is at once regular and normal, all indexed by a regular cardinal.
mananaysiempre 21 hours ago [-]
Yeah not those, those are legacy, we don’t speak about them :) The “natural” here is that of “natural isomorphism” and more generally the category-theoretic “natural transformation”, which is the one that is virtually always meant when people that the two things are “naturally” identified and the like.
That’s what they mean for example when they say that a finite-dimensional vector space is naturally isomorphic to its double dual, but while it’s also isomorphic to its ordinary dual, it’s not naturally so. Of course, in an introductory course they’ll just say the latter is dependent on an arbitrary choice of basis; but personally I find it quite beautiful that the notion “independent of arbitrary choices” is even formalizable, let alone in such generality as to span from vector spaces to programming languages.
xelxebar 15 hours ago [-]
Careful. Naturality and canonicality are different concepts.
Case in point, pick a couple linear isomorphisms φ: V → V* and ψ: W → W*, and let f: V → W be a linear map. Then f* = ψ∘f∘φ⁻¹: V* → W* is also linear and makes the isomorphisms natural via the commutivity relation ψ∘f = f*∘φ. If you pick isomorphisms for all your vector spaces of interest, you get a functor –*: Vector → Vector and the natural isomorphism Φ: Id → –*.
Notice, in particular, that every different choice of isomorphism, even for a single space, induces a different functor, though. This means that the set of functors from vector spaces to their duals is 1-to-1 with the set of natural isomorphisms.
In fact, we didn't actually use vector spaces properties in the above other than the existence of isomorphisms. We really are just showing that isomorphic objects in category theory are completely interchangeable.
tome 18 hours ago [-]
> it’s also isomorphic to its ordinary dual, it’s not naturally so
So they say, but no one seems to know how to formalise that! It's repeated so often you would think such an claim could be trivially refuted, but it turns out not.
Here's a formalization of the equivalence[1] and the naturality[2] of the equivalence between a module and its double dual, though I couldn't find it formalized in category theoretic lingo yet.
Vector spaces are naturally isomorphic to their dual as per my sibling comment. The issue is that pople generally want more out of their duals than just the bare construction as functionals, which is the only thing you get with Vect, the category of vector spaces with linear maps.
If you instead work with functionals rather than bare vector spaces, then there isn't even a functor to the duals, much less an isomorphism. This category is a richer version of Vect, since you can embed Vect into it fully faithfully via the normal double dual map, and it does a better job of capturing all the linear algebra you see with duals.
ch4s3 16 hours ago [-]
Dependent types are an interesting space in programming, I'd expect to see them pop up more in the next year or two as lean has caught on. Cure lang recently caught my eye, dependent types on the BEAM.
Nice; I hope "Cure" catches on. Given that AI-generated code are only going to keep increasing we need more verification-aware languages and having it on BEAM is just great.
I am aware of Lynx, I briefly talked to the author of Cure about it (Lynx) the other week. It seems like Cure takes the approach of using Idris in the core of the language to build the type system. I'm probably explaining that poorly.
Did you build Hold Ledger?
My own project uses lemmas at compile time to prove properties of functions with SMT in the compiler[1]
Nice. So "March" language is a standalone native language but having many of the features/properties from Erlang/BEAM with advanced type system for verification? That is a great idea.
He says - I was simply tired to implement critical parts in Idris and then translate the code to Elixir once proved to be correct. So it seems he basically created the language by taking the type system from Idris and marrying it to BEAM semantics.
No, i have not yet built nor played with Hold Ledger.
solomonb 1 days ago [-]
This is fun. His array example `Σ len: usize . Array(Int, len)` is the list polynomial functor (1 + X + X² + ...) applied to ints.
Sharlin 22 hours ago [-]
I find it particularly pleasing how a list can be defined as either:
1) a tagged union of homogeneous tuples of every possible size, ie. (1 + X + X² + ...), or
2) the inductive form, favored in FP: either the empty list or the first element and another list, ie. 1 + X * L
and how it’s easy to show that the two definitions are equivalent:
L = 1 + X + X² + ...
// factor out X
= 1 + X (1 + X + X² + ...)
// note that the (...) is the definition of L
= 1 + X * L
solomonb 18 hours ago [-]
Indeed! L is the least fixed point of `F(L) = 1 + X × L`. You get to the series by applying F repeatedly starting from the empty type:
Note that in order to understand the above you need to grasp "Type of Types" i.e. Sorts.
The whole Typed Lambda Calculus to Calculus of Constructions (based on dependent types) is very nicely and succinctly explained by Helmut Brandl in his 100-page booklet Typed Lambda Calculus / Calculus of Constructions - https://hbr.github.io/Lambda-Calculus/index.html
hiker 15 hours ago [-]
Sure, from this pov logic is just dependently typed lambda calculus where the types are quotiented by `True` (i.e. all inhabitants, if any, are equal; aka propositional irrelevance). Also see Corollary 4.7.3. in Awodey and Bauer's book on Categorical Logic [1].
Still the combinatorics side TFA talks about look beyond this quotient shadow at the actual number of inhabitants.
I meant to go from simpler to more complex logics. Categorical logic is too general and best looked at later.
Propositional Logic -> Predicate Logic (FOL) -> Higher Order Logic. This involves truth tables, models and semantic argument deductive systems (i.e. proofs) which are applicable everywhere.
Then move onto (or parallely) computation specific, Intuitionistic Constructive Logic -> Lambda Calculus -> Lambda Cube. This gives you the whole gamut of Type Theories.
Finally, the Curry-Howard Correspondence ties both the above together.
- There’s also the notation 0 for the empty (never, noreturn) type. In addition to matching the number of members, the notations 0 and 1 make sense also as units (neutral elements) of addition and multiplication respectively: 0 + A ≅ A + 0 ≅ A, 1 × A ≅ A × 1 ≅ A in a natural way[1]; and also 0 × A ≅ A × 0 ≅ 0.
- That a constant dependent sum is a product, and a constant dependent product is an exponential, is (undeniably confusing at first but) just[2] the naïve schoolbook definition that A × B = B added to itself A times and A^B = A multiplied by itself B times.
- That a constant dependent product is a function type is just the naïve definition that a function is a table of its values at each input (a tuple, with elements numbered by the possible inputs). A dependent function ( = dependent product), then, is the same thing but the allowable values in each cell of the table vary depending on the cell.
- That the function type is the exponential type is also part of common set-theory notation. For instance, 2^ℕ is a not-infrequent name for the set in the Cantor theorem (subsets of the naturals).
[1] As in, those are not literally the same type but are one-to-one in a single natural way. The word “natural” here has a surprisingly deep technical meaning but one that corresponds to the colloquial pretty well.
[2] “Just”, “simply”, etc. are as usual terms of art that mean that the statement feels very simple once you get it, and conversely that if it does not feel simple then you haven’t gotten it and should stop and think until it does. That thinking can take substantial time and effort.
Like - if there: product = constant dependent sum exponential = constant dependent product then what is constant dependent exponential?
> 0 × A ≅ A × 0 ≅ 0.
In practice, 0 × A ≅ A × 0 ≅ A for the temptation is too great to divide by zero and I don't know of a single programming language that doesn't succumb.
In a strict language (or with a strict pair in a lazy language), you normally won’t be able to (integer) divide by zero while computing a value, then go on to ignore that, pack that erroneous value into a pair, and extract the other, valid value from it and go on with your life.
Similarly, if your program has hung while computing one half of a pair then (except in lazy languages) it will have hung while computing the pair as a whole as well.
(Haskell’s type algebra is indeed somewhat subtler.)
> In the normal extension K/Q, every normal subgroup of the regular representation acts on a normal scheme that is regular in codimension one, whose normal bundle — orthonormal to the regular surface at each regular value — carries a normal operator whose spectrum follows a normal distribution over a space that is at once regular and normal, all indexed by a regular cardinal.
That’s what they mean for example when they say that a finite-dimensional vector space is naturally isomorphic to its double dual, but while it’s also isomorphic to its ordinary dual, it’s not naturally so. Of course, in an introductory course they’ll just say the latter is dependent on an arbitrary choice of basis; but personally I find it quite beautiful that the notion “independent of arbitrary choices” is even formalizable, let alone in such generality as to span from vector spaces to programming languages.
Case in point, pick a couple linear isomorphisms φ: V → V* and ψ: W → W*, and let f: V → W be a linear map. Then f* = ψ∘f∘φ⁻¹: V* → W* is also linear and makes the isomorphisms natural via the commutivity relation ψ∘f = f*∘φ. If you pick isomorphisms for all your vector spaces of interest, you get a functor –*: Vector → Vector and the natural isomorphism Φ: Id → –*.
Notice, in particular, that every different choice of isomorphism, even for a single space, induces a different functor, though. This means that the set of functors from vector spaces to their duals is 1-to-1 with the set of natural isomorphisms.
In fact, we didn't actually use vector spaces properties in the above other than the existence of isomorphisms. We really are just showing that isomorphic objects in category theory are completely interchangeable.
So they say, but no one seems to know how to formalise that! It's repeated so often you would think such an claim could be trivially refuted, but it turns out not.
* https://mathoverflow.net/questions/345136/is-a-vector-space-...
* https://h2.jaguarpaw.co.uk/posts/vector-space-naturally-isom...
[1] https://leanprover-community.github.io/mathlib4_docs/Mathlib...
[2] https://leanprover-community.github.io/mathlib4_docs/Mathlib...
If you instead work with functionals rather than bare vector spaces, then there isn't even a functor to the duals, much less an isomorphism. This category is a richer version of Vect, since you can embed Vect into it fully faithfully via the normal double dual map, and it does a better job of capturing all the linear algebra you see with duals.
[1] https://cure-lang.org/
In case you didn't already know, Jose Valim has released Lynx: Write proofs about Erlang/Elixir programs using Lean - https://news.ycombinator.com/item?id=50620224
Did you build Hold Ledger?
My own project uses lemmas at compile time to prove properties of functions with SMT in the compiler[1]
[1] https://march-lang.org/docs/lemmas/
Cure's author's comments on Idris' connection to Cure - https://elixirforum.com/t/cure-a-new-language-compiled-to-be...
He says - I was simply tired to implement critical parts in Idris and then translate the code to Elixir once proved to be correct. So it seems he basically created the language by taking the type system from Idris and marrying it to BEAM semantics.
No, i have not yet built nor played with Hold Ledger.
1) a tagged union of homogeneous tuples of every possible size, ie. (1 + X + X² + ...), or
2) the inductive form, favored in FP: either the empty list or the first element and another list, ie. 1 + X * L
and how it’s easy to show that the two definitions are equivalent:
F(0) = 1
F^2(0) = 1 + X
F^3(0) = 1 + X + X^2
1) Propositional Logic = Simple Types
2) Predicate Logic = Dependent Types (https://en.wikipedia.org/wiki/Dependent_type) where;
2.1) Existential Quantification = Σ-types (aka Dependent Sum/Pair) - https://en.wikipedia.org/wiki/Dependent_type#%CE%A3_type
2.2) Universal Quantification = Π-types (aka Dependent Product/Function) - https://en.wikipedia.org/wiki/Dependent_type#%CE%A0_type
Note that in order to understand the above you need to grasp "Type of Types" i.e. Sorts.
The whole Typed Lambda Calculus to Calculus of Constructions (based on dependent types) is very nicely and succinctly explained by Helmut Brandl in his 100-page booklet Typed Lambda Calculus / Calculus of Constructions - https://hbr.github.io/Lambda-Calculus/index.html
Still the combinatorics side TFA talks about look beyond this quotient shadow at the actual number of inhabitants.
[1] https://awodey.github.io/catlog/notes/catlogdraft.pdf
Propositional Logic -> Predicate Logic (FOL) -> Higher Order Logic. This involves truth tables, models and semantic argument deductive systems (i.e. proofs) which are applicable everywhere.
Then move onto (or parallely) computation specific, Intuitionistic Constructive Logic -> Lambda Calculus -> Lambda Cube. This gives you the whole gamut of Type Theories.
Finally, the Curry-Howard Correspondence ties both the above together.