Quantcast
Channel: Dafny: An Automatic Program Verifier for Functional Correctness
Viewing all articles
Browse latest Browse all 1106

Commented Unassigned: Assertion violation - induction hypothesis [173]

$
0
0
Please, some help with the following assertion violation
http://rise4fun.com/Dafny/cLnNL

Comments: My guess is that the proof being constructed goes something like this: http://rise4fun.com/Dafny/0FG7 ``` function power(b:int,e:nat):int { if e == 0 then 1 else b*power(b,e-1) } lemma {:induction false} Lemma_SquareAndHalve(b:int, e:nat) requires e%2 == 0 && e > 0 ensures power(b,e) == power(b*b,e/2); { if e == 2 { assert power(b,2) == b*power(b,1) == power(b*b,1); } else { calc { power(b*b,e/2); == b*b*power(b*b,(e/2)-1); == b*b*b*b*power(b*b,(e/2)-2); == b*b*b*b*power(b*b,(e-4)/2); == {if(e>4) { Lemma_SquareAndHalve(b,e-4);} else {assert (e-4)/2 == 0;} } b*b*b*b*power(b,e-4); == b*b*power(b,e-2); == power(b,e); } } } ```

Viewing all articles
Browse latest Browse all 1106


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>