Remix.run Logo
▲ danilafe 23 minutes ago

This is an interesting idea. At its core, IRs tend to be smaller and have better defined semantics. Of course, you'd have to use something other than the IR itself as the metalanguage (not a problem, though). Perhaps the reason this hasn't been attempted as often (I read the sibling Sel4 discussion about refinements) is twofold:

1. The mechanical effort required to show that the IR satisfies some abstract specification. Sel4 requires several refinement proofs (I am trusting the sibling comment on this), which suggests a great deal of effort. Perhaps LLMs (taken as "smart heuristics for proof code generation") can be of use here.

2. IR serves a secondary purpose as a target for compiler transformations. I've written myself about formally verifying compiler analyses[1] and I've proven a rudimentary LICM optimization in Lean based on these analyses (I haven't had a chance to write that one up), but it took a great deal of effort. We may then be forced either not to optimize or to trust something like LLVM (but...here be dragons? :P ).

So there is a tension between "simple core language" and "mutable substrate for optimization". And that doesn't even bring into question MLIR dialects and progressive lowering!

[1]: https://danilafe.com/series/static-program-analysis-in-agda/

▲dnautics 4 minutes ago | parent [-]

true. it does depend on the nature of the IR, modern languages have many layers of IRs. For example, I have made some progress interpreting Zig's "AIR" which is in the sweet spot where it doesn't yet launch into an LLVM-level "mutable substrate for optimization". Now, what I have is currently entirely heuristic, but I'm considering patching a theorem prover in to it.

https://github.com/ityonemo/clr

▲danilafe a few seconds ago | parent [-]

Very interesting, thank you for sharing!