Type systems and logic
codewords.hackerschool.com
codewords.hackerschool.com
> The most straightforward way to represent the proposition
> “not A” with the type A -> ⊥, where ⊥ is what’s called an
> empty type – a type with no values. (This type’s symbol
> comes from mathematics. It is usually pronounced
> “bottom.”) A -> Void can be read as “if we have an A, we
> can use it to make something that doesn’t exist”
Unless the author means something different from what I think, using "void" here is very confusing. "void", as it appears in C, Java, et. al. is not all like a bottom type. A bottom type means "there can be no value here". In other words, a function whose return type was bottom could not return. Coming from an imperative mindset, one way to understand that is to consider this function: foo() { throw "!"; }
You can never get a value out of this function. If you do: var result = foo();
result will never get assigned. So, here, foo's return type really is "bottom". This is different from void—a function that returns successfully but emits no value.Instead of corresponding to "bottom", void maps to the unit type: the empty tuple.
You are trying to equate mathematical functions and software functions (i.e. co-routines). They are not the same thing.
A co-routine does not have a domain and co-domain. When we declare a function type
F(T_1, T_2) T_3, T_4, ... {}
we are saying that a co-routine begins in a pair type (T_1, T_2), it ends in a function type (return) mapping the T_3 and T_4 values to a pair type (Pointer, Data) for both values (as a simplified view).
> So, here, foo's return type really is "bottom".
No, the return co-routine is a routine that finishes successfully but "emits" no value. There are no bottom or unit types anywhere in this. Sorry.
The article uses "⊥" in one sentence and "Void" in the next without clarifying if "Void" is synonymous with bottom or if a new concept is being introduced.
Either way, my point was that programmers coming from the large slew of Algol68-derived languages will see "void" here and likely think it has something to do with the "void" they're familiar with when it does not.
As far as I know, in practice, "void" in C, Java, et. al. works more like the unit type than a bottom type and/or this not-very-well-defined-by-the-article void type.
If I'm wrong, I'd like to know more, but preferably in language a little more familiar to a working programmer than describing software functions as "co-routines which do not have a domain and co-domain".
Then the article proceeds to not conretely define what a "Type System" is. They just say: oh like those things that Haskel and OCaml do.
Then they just jump to concluding:
> Type systems don’t correspond to classical logic, but to something called “constructive logic”.
Wait, what? Why? And please don't explain constructive logic as your explanation of 'why'. That doesn't explain the presumption above. In fact, you still have not even told us what exactly you mean by Type System.
> correspond to propositional logic
So, by Type Systems we mean a Heyting Algebra?
> dependent types are first-order predicate logic
So dependent types are algebras that carry the same properties as propositional logic? But, I thought Type Systems were the logic?
> Type-based logic forces us to use constructive logic rather than classical logic
This is a completely different conclusion than the premise of the article.
It seems, that the author has a good understanding of a not well understood relationship i.e. the relationship between Types and and what we refer to as "a logic".
Similarly, there isn't really any definition of a logic. Some authors talk about a proof system + a semantics, which is also not precise, and also not general enough (some constructivists don't want the semantics).
So it seems hard to do better than this?
As someone who's comfortable with an informal approach to mathematical logic but has never done any programming with dependent types, I wonder if this may be hitting on a fundamental point.
Certain presences can be interpreted as absences, i.e., the absence of their absence, in just the same way as certain statements can be interpreted as the negations of their negations. (In classical logic, but not in constructivist logic, all statements can be so interpreted.)
Is there any chance that the 'presences' needed in dependent type theory are those that can be expressed as the 'absence of an absence' (something like that it is not so important what characteristics an object does have, as what assumptions about the object can't go wrong)?