Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Dependent typing and its downsides

Name: Anonymous 2016-01-04 12:29

1. There's many more ways of doing things compared to more simply typed languages so that API design becomes pretty delicate. I can think of four or five feasible types to assign to the simple list head function for instance. With more complex functions this gets even worse and the number of possible types increases. When working in teams you then need to become pretty stringent over matters of style.
2. 40 years after the initial publications on dependent type theory equality is still an absolute disaster. There's a whole panoply of various equalities, equivalences, and similar, that you need to be aware of to get anything serious done. There's definitional equality, propositional equality, heterogeneous equality, bisimulations for stream types, decidable fragments of these, and so on.
3. Definitional equality is antimodular in that it exposes implementation details of functions to clients, making them brittle to implementation details. For example 0 + x reduces to x but x + 0 does not, solely because of how + was implemented.
4. Closely related to the previous point, but proofs in general are extremely brittle to even minor implementation changes, though this is not restricted to dependently typed systems and affects any reasoning tool. Even minor architectural changes therefore become nightmarish tests of resolve.
5. Coq, Agda, and other dependently typed proof assistants suffer from a lack of automation compared to e.g. Isabelle, which being based on classical logic can hook directly into the masses of research carried out on automated reasoning for classical logic fairly easily. Coq still has no usable equivalent of sledgehammer or Isabelle's smooth SMT solver integration, for instance, which makes a big difference when constructing large proofs.
6. When things go wrong, they go wrong badly, and it's often very hard to work out what the problem is unless you have an intimate knowledge of the internals of the type checker, unification machinery, reduction machinery, tactic subsystem, and so on. Further, error messages can become impenetrable very quickly making debugging e.g. a higher order unification problem extremely hard.
7. You need a level of mathematical sophistication to use these systems that most programmers lack. Even worse, even trained mathematicians find adjusting to predicative, constructive reasoning using type theory (i.e. Agda or Idris) a major hurdle. Last summer I had a summer student work with me on a project in Agda who had never programmed before. He was however a very gifted mathematician, yet by far the greatest hurdle he had to overcome when learning Agda was adjusting to constructive reasoning, and adjusting to the idea that proofs are first class objects that can be passed as arguments to and returned from functions. This idea was mind blowing!
8. Repetition everywhere! A vector is a list indexed by its length. As a result, it shares many similar operations (e.g. map, filter, append, and so on) with a plain list datatype yet these operations all need to be reimplemented despite nothing much changing other than the types. For every different list-like indexed type, you also need to reimplement these same operations, and same proofs, over and over again. "Don't Repeat Yourself" is thrown out of the window.
Java's architecture astronauts are well known. Dependently typed languages enable something much worse: type astronauts. A function cannot merely be written that works on some concrete type. It needs to be abstracted and abstracted until it operates on elements of some obscure algebraic structure mentioned once, in passing, in a PhD thesis in 1983. Further, datatypes become decorated with invariants to such an extent it becomes impossible to work out what they actually do. "Keep it simple, Stupid" and "You aren't gonna need it" are both thrown out of the window.

Name: Anonymous 2016-01-04 14:19

0. No way to make quotients, the most important way to abstract in mathematics

Name: Chad 2016-01-04 16:36

I can think of four or five feasible types to assign to the simple list head function for instance.
Definition head {t : Type} (l : list t) : option l

Name: Anonymous 2016-01-04 16:48

Definition head {t : Type} (l : list t) {Prf : l <> nil} : l.

Name: Anonymous 2016-01-04 16:48

Definition head {t : Type} (l : list t) : {l = nil} + l.

Name: Anonymous 2016-01-04 17:23

>>1
Many of those are very interesting points, a few important things to keep in mind though are that type theory is a very young field and they've made a lot of progress in the past ten years, so it's not like we hit a roadblock 40 years ago and no amount of research has been able to get past it, people are working very hard on a lot of these problems and there are some real finished and useful projects to show for their efforts (sel4, fscq, compcert, etc). That all being said, there's a lot of room for improvement - one of the reasons programming with dependent types is rather difficult is because the huge amount of freedom granted to you by the system, lack of extant "best practices", and the way implementation details can seriously effect how hard your proofs are (your mention of + on natural numbers is a great example of thise) means that it's not immediately obvious how to structure, design, and implement nontrivial dependently-typed programs, especially ones intended to be reusable as parts of larger projects.

proofs in general are extremely brittle to even minor implementation changes
This is a really big problem! One solution is to take something like Adam Chlipala's approach, where something isn't considered properly "proven" until it has a high degree of automation to it, to the point where you basically generate it with a tactic or function - this seems to work quite well when you're able to apply it. In general though, naively-written proofs can be quite sensitive to minor changes in types or functions (or even interpreter internals, e.g. how names get automatically assigned to existentials).

When things go wrong, they go wrong badly, and it's often very hard to work out what the problem is
Another good point, for example doing things wrong often leads to impossible goals whose impossibility is not immediately obvious, and error messages about things like "non-strictly positive types" or something can be confusing for a beginner. Being able to more quickly figure out when something has gone, and what it was would be extremely helpful.

You need a level of mathematical sophistication to use these systems that most programmers lack. Even worse, even trained mathematicians find adjusting to predicative, constructive reasoning using type theory (i.e. Agda or Idris) a major hurdle
I don't really think this is going to go away, even with better type theories and proof assistants. I suspect writing formal computer-checkable proofs is always going to be a skill different from conventional math or programming, at least as we know them today.

>>2
No way to make quotients, the most important way to abstract in mathematics
This is perhaps one of the most immediate problems with dependently-typed programming because it gets in the way of actually getting any work done. Sure, you've got setoids and stuff in Coq, but they're a real pain in the butt to use. Something more first-class would be a tremendous help I think.

Name: Anonymous 2016-01-06 12:01

>>2
What do you mean by "quotients"? I would presume it's not the results of division.

Name: Anonymous 2016-01-06 12:42

Name: Anonymous 2016-01-06 15:22

>>7
basic example to define the integers Z out of natural numbers you take pairs of nautarn numbers (nat * nat) as the data structure representing x-y.
This works great you can add: (x,y)+(u,v)=(x+u,y+v)
and multiply (x,y)*(u,v) = (xu + yv, xv + yu)
but theres multiple ways to represent any given number, (x,y) = (u,v) if x+v = y+u

so what you need to do is define a quotient type (nat * nat)/(=) which will ensure that every function respects equality relationship

Name: Anonymous 2016-01-06 18:46

Name: Anonymous 2016-01-06 20:24

>>10
NuPRL is kind of an exception to these ``FP'' languages. There's something much more elegant about it than all of those and it's not just the syntax either. I think it's the subtyping.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List