Remix.run Logo
▲ Formalizing CPython(broyojo.com)
72 points by carnevalem 8 hours ago | 19 comments
▲anewhnaccount2 5 hours ago | parent | next [-]

Same approach for Julias stdlib: https://discourse.julialang.org/t/formalizing-julia-in-lean-...

▲Alexander-Barth 44 minutes ago | parent [-]

Interesting also prompt of the python formalization (and the blog post) mentions the julia-in-lean:

https://github.com/Broyojo/python-formalization/blob/main/AG...

▲jakobnissen 4 hours ago | parent | prev | next [-]

I think this approach to bug hunting is super promising (obviously - it finds a ton of bugs). The long-term problem is how this kind of bug-hunting can be done routinely, e.g. as part of a test suite. The approach taken by these people, the same approach as when the Julia folks did it, isn't really automatable, because it requires a lot of both human and AI agent work.

I guess longer term it needs to be built into the language, to prevent code and lean proofs from drifting. I.e. it could be opt-in properties that are written along the code, and which is then checked in the test suite. So very similar to ordinary compiler checks, except more expressive and expensive, and done only at test time.

▲stabbles 2 hours ago | parent | next [-]

At that point you might as well use Lean?

It would solve the two language problem :-)

▲araquesebastian an hour ago | parent [-]

yep

▲skeledrew an hour ago | parent | prev | next [-]

Interesting. Now I have an idea to extend my tooling flow, thanks.

▲abhiram-ar an hour ago | parent | prev [-]

bend programming language already solved this problem: https://bend-lang.com/

▲erfgh an hour ago | parent | prev | next [-]

Does anyone read articles written by AI? This is a serious question.

▲LtWorf an hour ago | parent [-]

I think AI output is like your own farts. We all smell our own but others don't want to be subject to it.

▲eternauta3k 3 hours ago | parent | prev | next [-]

Is there a way to avoid the translation or replace it with normal parsing?

▲choeger 3 hours ago | parent [-]

In principle, yes.

I am not a lean expert, but I imagine that python primitives like dicts, ints, functions, etc., have been defined in lean. So if you add a way to annotate python code with a proof, you should as well be able to automatically translate it to Lean completely.

▲perching_aix 3 hours ago | parent [-]

it's a matter of how much of a modeling gap do you choose to accept.

for full, honest to god, end to end verification this would be insufficient. but you don't need that in order to reap benefits.

just gotta make sure you actually bound the triage process with some sort of automated verification process. like comparative test cases or similar. otherwise it's just a particularly expensive way of agentic hallucination.

▲actionfromafar 31 minutes ago | parent | prev | next [-]

Stupid question: if the lean4 code is a copy of the C code, how does "it" know which code is a bug and which code is working as intended?

▲bb88 3 hours ago | parent | prev | next [-]

Only 418?

I would have expected around 10k.

Edit: Professional python programmer.

▲perching_aix 3 hours ago | parent [-]

they don't have full coverage yet

▲senderista 3 hours ago | parent | prev | next [-]

Cite an AI-written document? Hell no.

▲woggy 3 hours ago | parent | prev [-]

Can we just develop in Lean and compile to something else for speed?

▲iib 3 hours ago | parent | next [-]

Lean is actually pretty speedy as is, and it enables much harder optimizations[1]

[1] https://github.com/kim-em/lean-zip#verification-enables-perf...

▲pjmlp 2 hours ago | parent | prev [-]

Of course.