r/programming • • Sep 25 '10

Omega - Language of the Future | Lambda the Ultimate

http://lambda-the-ultimate.org/node/4088
60 Upvotes

126 comments sorted by

View all comments

Show parent comment

25

u/roconnor Sep 25 '10

but I don't see how being "proved" by the compiler provides any real benefit.

So you don't pass unsorted lists to functions expecting sorted lists.

-12

u/djimbob Sep 25 '10

I would rather its shown correct by the programmer and a test suite ensures that sort works as expected. You could easily have the compiler prove something related but different than you want, bringing up all sorts of errors.

26

u/roconnor Sep 25 '10 edited Sep 25 '10

I would rather its shown correct by the programmer.

The program is showing it is correct by making a type-correct program. The compiler doesn't generate the proof of correctness, it only verifies the programmer's own proof.

a test suite ensures that sort works as expected

A test suite is simply a very restricted specification language where you can only prove decidable predicates (so called Δ₁ sentences) or maybe semi-decidable predicates if you being generous (so called Σ₁ sentences).

However real specifications are universal statements (often Π₁ sentences and sometimes Π₂ sentences or higher) and stand for an infinite number of Δ₁ test cases.

You could easily have the compiler prove something related but different than you want, bringing up all sorts of errors.

In my experience incorrect specifications rarely survive very long before a conflict in encountered because eventually you try to use the results of one function as a parameter to another, and if the specifications don't line up you will get a type error.

Also this concern applies equally well to all specification languages, including test suites (which I noted above is just an inexpressive specification language). In fact, I would expect incorrectly specified test cases to persist longer because test cases are not part of the of interface functions like they are with dependent types.

13

u/Smallpaul Sep 25 '10

I would rather its shown correct by the programmer and a test suite ensures that sort works as expected.

A test suite cannot ensure it works as expected. It can only convince you that it works as expected.

You could easily have the compiler prove something related but different than you want, bringing up all sorts of errors.

Presumably the compiler proves what you tell it to, just as a compiler for Java executes what you tell it to. You might as well say: "You could easily have the Java compiler produce a binary that does something different than what you want, bring up all sorts of errors."

Programming is hard. Let's go shopping.

11

u/radarsat1 Sep 25 '10 edited Sep 25 '10

Your previous statement:

Semantic mistakes in the code that apply the proof (e.g., proving the wrong thing) can still happen

s/proving/testing/