Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
1–10 of 24 posts
Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#2Couldn't you do that in a more conventional type/class system without using an actual proof system? Instead of there being a Socket type/class, just make a Socket_Fresh, Socket_Bound, Socket_Listening, Socket_Connected, and maybe Socket_Closed (not 100% sure, would have to think about whether that's a thing or not), each of which takes the previous in its constructor. Or does that make it too hard to use?
Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#3> Lean 4 offers a fourth option: make the bug unrepresentable at the type level, then erase the proof at compile time so the generated code is identical to raw C. Couldn't you do that in a more conventional type/class system without using an actual proof system? Instead of there being a Socket type/class, just make a Socket_Fresh, Socket_Bound, Socket_Listening, Socket_Connected, and maybe Socket_Closed (not 100% sur…
Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#4Also, boo AI slop. If you’re going to use AI to help write your technical blog posts please please please edit out all the “No X. No Y. Just pure Z.” marketing-speak.
Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#5I don't know where it will end up on the spectrum of systems languages; it may end up being too niche or incomplete, but so far I think I'm scratching the right itch, at least for myself.
Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#6Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#7Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#8Lean doesn’t have any kind of substructural typing, does it? At a glance it looks like you need to manually (lexically) rebind the socket at each step in the operation, and there’s nothing stopping you from holding onto a socket in a now-invalid state and making mess of things, right? Also, boo AI slop. If you’re going to use AI to help write your technical blog posts please please please edit out all the “No X. No Y…
Likewise, with implicit weakening, nothing stops you from dropping the socket without closing it.
Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#9Re: Zero-Cost POSIX Compliance: Encoding the Socket State Machine in Lean's Types
#10> Lean 4 offers a fourth option: make the bug unrepresentable at the type level, then erase the proof at compile time so the generated code is identical to raw C. Couldn't you do that in a more conventional type/class system without using an actual proof system? Instead of there being a Socket type/class, just make a Socket_Fresh, Socket_Bound, Socket_Listening, Socket_Connected, and maybe Socket_Closed (not 100% sur…
The innovation is making that have zero runtime cost. (Though to be fair, I doubt the runtime cost is really significant...)