Re:A simple ray tracer in Lean 4
by haskellandchill on Monday February 01, 2021 @02:02PM
(#25992167)
Cool. Actually I should know more about this since I took a lecture series with Krishnaswami on this topic. He combines the two type systems in a way that makes sense and can produce a programming language.
But yes, for the linearity control you'd need to model variables within the type system and indirect to a function handling h's resource relationship instead of using it directly.
Formally I would like to compare linear types and dependent types and their ability to encode or not each other. I don't know what the tools for that are.
A common example is a file handle: I can prove that the 'close' function will produce a closed handle, e.g.
I can prove that those handles point to the same file: I can prove arbitrary relationships between the input values and the output value. Yet nothing I do restrict the structure of a term, like how many times a variable is used, to prevent e.g. For that sort of control, we need to build the ability to track things into the term language itself; either by adding linear types (or equivalent) to the language, or building a new incompatible language on top (as I mentioned above).