Skip to content

assert Gcd(2,2)==2 fails #3971

Answered by MikaelMayer
hmijail asked this question in Q&A
May 8, 2023 · 1 comments · 10 replies
Discussion options

You must be logged in to vote

I converted the issue to a discussion because if Dafny can't prove something, it does not mean the thing isn't true or that Dafny is bogus, it only means Dafny needs more guidance. It's not because the Fermat theorem is true that Dafny should be able to prove assert forall x, y, z, n | n > 2 ::Power(x, n) + Power(y, n) == Power(z, n) ==> x == y == z == 0. Try to prove that GCD(2, 2) == 2 by hand. Given the mathematics definitions, it's not obvious.

Here is what you can enter to help Dafny prove what you want:

assert Gcd(2,2)==2 by {
    assert Factors(2) == {1, 2} by {
      calc {
        Factors(2);
        set p: pos | p <= 2 && IsFactor(p, 2);
        { 
          assert IsFactor(1, 2) 

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@MikaelMayer
Comment options

@hmijail
Comment options

@hmijail
Comment options

@MikaelMayer
Comment options

@atomb
Comment options

Answer selected by hmijail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
3 participants
Converted from issue

This discussion was converted from issue #3968 on May 08, 2023 15:48.