Expression Inference

In type inference, the compiler starts with the formal structure of a function--its representation in some programming language--and infers the type that such an expression must have.

Two ideas I have posted, implicit arguments and commutative programming languages, perform inference in the reverse direction: they start with the type of a function, and infer what the arguments are. In other words, they determine the structure of an expression based on its type. This is a more general concept that I'll call "expression inference."

I do not think that "value inference," even though values are normally thought of as the counterparts of types, is a good name for this type of inference. The reason is that type inference also infers values; the type of an expression must combine with the form of the expression to determine the actual value of the expression. Both "type inference" and "expression inference" can be thought of simply as two different kinds of "value inference."

Commutative programming and implicit arguments are two examples of expression inference. Some more examples of what you might ask the compiler to do with expression inference (and, in some cases, dependent types): The last example illustrates that a compiler performing expression inference with dependent types could in theory write your whole program, if you gave it a formal specification and unlimited time to try alternatives. Expression inference in this context is actually general automated theorem proving, by the Curry-Howard isomorphism.

© Bart Parkis
Last modified:Tue May 19 19:07:52 2009