Made fromIntegerNat use case instead of if#4357
Made fromIntegerNat use case instead of if#4357SaraWolffs wants to merge 2 commits intoidris-lang:masterfrom
case instead of if#4357Conversation
Using `if` with an `assert_smaller` could cause infinite compile-time looping. To prevent this, a pattern match on 0 was needed, but pattern-matching on Integers stops terms from reducing in proofs. This should fix that by avoiding the original issue.
|
The appveyor build is failing (travis build as well), but I can't for the life of me see why. Relevant bits of the log: The compiler itself builds just fine. Looking at Transform.hs, it seems to expect an |
|
Thanks for the PR! I'll try and see what happens. |
Using
ifwith anassert_smallercould cause infinite compile-time looping. To prevent this, a pattern match on0was needed, but functions that match on Integers don't reduce in proofs. This should fix that forfromIntegerNatby avoiding the original issue (tested, this version doesn't loop on\i=>fromIntegerNat iat the REPL, which the old version did without the0match).The new code has been tested correct for (-1), 0, 5, 10, 100, 1000 and 1234. It does seem to be slightly slower than the original, but neither is very fast. Proving things for
Integeris probably still not a good idea, but it should now at least be possible to convert aSo (i > 0)to anIsSucc (fromIntegerNat i), in theory (untested, I'm bad at proofs, butcomputedoes now reducefromIntegerNat ito acaseblock).As a minor simultaneous change, the
fromIntegerNattakes an argumenti, forInteger, rather thannforNat.