Skip to content

Conversation

@JakeGinesin
Copy link
Contributor

@JakeGinesin JakeGinesin commented Sep 25, 2025

94 was completed with advice from @elanortang, and 97 was a joint effort between @SSSPigeon and I.

Used Verus version 2025.08.23.bb6fd4e pinned here.

Copy link
Contributor

@parno parno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good -- thanks for the contribution! I've left a handful of comments. Also, please run verusfmt on your files, so everything stays consistent.


}

fn skjkasdkd(lst: Vec<u32>) -> (ret: u32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really weird keyboard-mash of a function name. I realize it's the one the prompt chose, but I think it would help to add a comment to that effect, so future readers aren't puzzled by it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

spec_find_largest_prime(
[email protected]_values(|val: u32| val as nat)
) as nat
) || ret == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The English spec doesn't say what to do if the input doesn't have any prime values. I would lean towards adding a precondition that the list does indeed contain at least one prime value. That way you can remove the || ret == 0. If you want to avoid a precondition, then I think the idiomatic approach would be to return Option<u32>, and then to specify in the postcondition that None implies there were no prime values in the input. If you don't include that condition, then a trivial implementation can satisfy the spec by always returning None (or 0 with the current spec).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the canonical it seems to me the default behavior is returning 0 if no primes are found:

def skjkasdkd(lst):
    def isPrime(n):
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                return False

        return True
    maxx = 0
    i = 0
    while i < len(lst):
        if(lst[i] > maxx and isPrime(lst[i])):
            maxx = lst[i]
        i+=1
    result = sum(int(digit) for digit in str(maxx))
    return result

but it is also true that spec_find_largest_prime will return 0 if it takes a list without a prime anyways, so it seems the || ret == 0 clause is redundant in the specification anyways.

if i <= 0 {
0
} else {
let first_i = s.take(i as int); // first i digits
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in the rest of the comments, I think you want "integers"/"numbers", not "digits"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

@parno parno merged commit afdd879 into secure-foundations:main Oct 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants