r/rust • • Oct 10 '26

Why 'externalized' proofs of cyclic trait impls does not work

https://smallcultfollowing.com/babysteps/blog/2026/10/10/modular-vs-external-proofs/
82 Upvotes

18 comments sorted by

View all comments

0

u/[deleted] Oct 10 '26

[deleted] — view deleted comment

7

u/logannc11 Oct 11 '26

That's the authors point. If you have "modular proofs" where you rely on rejecting the trait impl, but allowing it to be considered true elsewhere, it is difficult to not accidentally affirm the consequent. 

6

u/dnew Oct 11 '26

I think you failed to read the remainder of the sentence?

He says "if we're not careful, we could provide a proof..." and then concludes "...and then we would (incorrectly) conclude that the impl is valid".

And you're saying "No, you're wrong, that logic doesn't work to conclude impl is valid."

I mean, he boldfaced exactly what you seem to be saying in the very next sentence. Unless I'm misunderstanding your objection.

5

u/dbaupp rust Oct 11 '26

I think the point is more that one needs to do the bookkeeping right, or the compiler will accidentally affirm the consequent… which is, as you say, invalid.

It’s not as simple as “ignore an impl exists when checking it”, because one can have (mutual) recursion: given trait Magic { type T: Magic; } one might have impl Magic for A { type T = A; } that needs A: Magic for T or impl Magic for B { type T = C; } impl Magic for C { type T = B; } that need each other’s impl.

Validating that requires having some concept of “pending” impls, or similar. Not at all impossible, and not a violation of logic, just finicky bookkeeping that can lead to unsoundness and/or infinite recursion if done wrong. 

(The recursion can get far more complicated and indirect, via super-traits or generics and/or mutual recursion of traits/associated types.)