Name alternative for "dodgy mode"

At Foundation for Probably Correct Mode - faster, but may rarely produce incorrect results by JohnAAbbott · Pull Request #2395 · Nemocas/AbstractAlgebra.jl · GitHub , we have a foundation for a “probably correct mode”, which is faster, but does not come with strong guarantees that the result is always correct. We are looking for alternatives for the name “dodgy mode” for this feature.

Please vote for your favorite alternative from the list presented, or comment below to add your own favorite alternative to the running!

  • Here be dragons
  • Yolo
  • Fast and risky
  • Probably correct
  • Physicists favourite/mode
0 voters

I think “yolo” is the funniest, but for long-term use I’d want the function people actually call to say something like:

enable_possibly_faster_and_possibly_wrong_results()

The mode could even be called ‘possibly faster and possibly wrong’, people understand clearly what’s going on and aren’t tempted into thinking ‘probably correct’ means they can report incorrect answers.

That explains both the motivation and the risk, without promising it will actually be faster. I’d particularly want “wrong” in the name: “probably correct” sounds too reassuring.

GCC’s -ffast-math is a cautionary example, it’s caused dozen of articles, and complaints, and bug reports over the year – documenting the trade-off doesn’t stop people being surprised by it, and it’s important people clearly realise when they read code what’s going on.

1 Like

Interesting points! A descriptive function name surely has the advantage that users won’t need to refer to the manual to find out what FastAndFuriousDragonYOLO_mode is. Your proposal is a bit wordy; can we find a more succinct but equally comprehensible name? fast_but_maybe_wrong_mode

It is true that the dodgy version may, for certain “simple” inputs, be no faster than the verified version. So one could argue that maybe_faster_but_maybe_wrong_modeis a more accurate descriptive name; but I have doubts about this longer name (or similar) genuinely being better in use. fast_but_risky_modeis less clear, but likely it suffices once the reader has read the manual – to me it seems that fast_but_risky_modehas a nice ring to it, so should be easier to memorize? fast_risky_mode is shorter, but does not sound as memorable (to me).

I guess this function will in general be called once, at the top of a file / function?

And in general saying ‘once they’ve read the manual’ seems like a dangerous plan, let’s be honest, how many people who added ‘-ffast-math’ went and read the documentation for fast-math? (I realise this isn’t the same, I just feel it’s the closest comparison I know of). Of course we can’t protect users from all their mistakes, but this is also a global change, once it’s called it changes everything, including other functions that get called in other files?

Now I say that out loud, that sounds worrying, is it the case by calling this function I could break other people’s code I call later in my file? Even in a different library that happens to call into oscar?

Right now, more detailed documentation is in a PR. We shall first decide the new name; then I’ll revise the PR; then it can be merged (if other hindrances are not identified).

Your “worrying” situation is indeed that which arises. A first point is that the chance of a wrong result be produced is very low – think less than 1 in 10^10, or even 1 in 10^20. We do not exclude the possibility of pathological families of inputs where the probability is less favourable: for instance, fast probabilistic primality tests can produce erroneous results, but it is not easy to find such pathological inputs (for one such test, it is conjectured that such inputs exist, but I believe that no-one has been able to construct a concrete one).

It is a bit early to say what a typical use-case is. In an interactive session, we think that it could follow the following pattern:

> clear_log_of_dodgy_steps();
> enable_dodgy_mode();
> # do your computation
> disable_dodgy_mode();
> get_log_of_dodgy_steps()  # if empty then computation is guaranteed correct

The function is_prime has a “dodgy variant”. If dodgy mode is enabled, not every call to is_prime will record an entry in the log: only those calls where the value returned might be incorrect are recorded in the log

Two more name candidates. Both say what is skipped instead of promising speed, which isn’t guaranteed either, as John notes:

  • unverified: allow_unverified_results(), unverified_steps()
  • proofs off, as in Sage’s proof.all(False) and Nemo’s own next_prime(x, proved): set_proof(false), unproven_steps()

On Chris’s question, two ideas.

  1. Make a scoped form the main entry point. Then the mode ends with the computation, even after an error or Ctrl-C, which John’s enable/disable pattern doesn’t survive:

    clear_dodgy_steps()
    with_dodgy_mode() do
        # your computation
    end
    get_dodgy_steps()
    

    Sage does the same with with proof.WithProof('arithmetic', False):. It can wrap the current globals now and move to a ScopedValue later, which also makes it task-local.

  2. Let explicit arguments win over the mode, as next_prime(x, true) does in the Nemo PR. Then code that needs a proof can ask for one, whatever the caller switched on.

Actually, the scoped form could even return the dodgy steps together with the result, instead of writing them to a global log, like so:

result, steps = with_dodgy_mode() do
    # your computation
end

Then there’s nothing to clear first, steps from earlier computations can’t end up in your log, and the logged arguments are freed along with the result. Though we should also ensure that nesting with_dodgy_mode does the right thing (whatever that is). Otherwise a library that wraps an internal call hides those steps from its caller… but maybe that’s actually OK, if the library knows that it will turn dodgy intermediate results into safe ones… E.g. some algorithms can work with a probable prime, and using a non-prime will be detected – the main reason to run an unsafe primality test first then is speed, to avoid a computation that fails anyway.

2 Likes

I quite like getting the log immediately, as a user – it means you can’t ignore it (or not know it exists). Of course someone might not read it, but even someone who never reads the docs will know they get some kind of log. Also the ‘with_dodgy_mode()’ discourages people from just turning it on in the first line of their program and forgetting about it.

One thing to check in the implementation, make sure you can nest it, the inner one should just get it’s dodgy calls, the outer one should get all of the calls (this might be obvious, just thought it’s worth mentioning).

I must “meditate” upon the semantics of dodgy mode when nested: it is not so obvious to me what ought to happen. Indeed, it is not so obvious to me when nesting could even occur.

As Max pointed out, there are functions ( _e.g._ next_prime) which already offer a boolean option to indicate whether the returned value should be proved/verified; and when the option is explicitly given, this will override the global dodgy mode setting. Are there genuine examples of library functions which would need to alter the global dodgy mode setting?

I am uncertain about Chris’s suggestion that dodgy calls be logged on multiple log-lists: in principle, the nesting could be arbitrarily deep, so a single dodgy call may need to be logged on arbitrarily many lists. I wonder if this is really behaviour that we would want.

I don’t imagine the library would alter the global dodgy mode setting, but I’m imagining maybe I write a function which uses dodgy mode, I send them my code, then a friend calls that function while they also adjust dodgy mode themselves. The problem with a global ‘dodgy mode’ is their call to dodgy mode would filter down into my code, which might have intended to make some calls with, and some calls without, dodgy mode.

Of course the answer to this can be ‘don’t go calling your friend’s code while you have dodgy mode turned on’, but the question is should that be some kind of rule, or just common sense?

Thanks for the suggestion of the scoped form – I’ll investigate. As I said in a reply to Chris Jefferson a short while ago, it is not clear to me when nesting might actually occur: are there really instance of library function which would alter the global dodgy mode setting?

Personally, I expect dodgy mode to be primarily (solely?) for interactive use.

The current prototype has a notion of function families: each family is associated to a Symbol. Dodgy mode can be enabled/disabled separately for each family, though there is also a shortcut to enable/disable for all families. An example of a family is :is_prime which takes effect in the functions is_prime and next_prime.

So long as two functions belong to different families there should be no “interference” of the sort you describe.

BACK TO THE MAIN TOPIC

This thread is actually about choosing a name: the prototype uses dodgy and that is the word we have been using casually here.

Max made two concrete suggestions:

  • unverified
  • proofs off (perhaps expressed via the name component unproven ?)

I propose a minor variant of Max’s first suggestion:

  • unchecked

To me “unchecked” seems less scary than “unverified” even though the two words are almost synonymous. This would lead to function names such as enable_unchecked_mode and get_log_of_unchecked_steps

The name disable_unchecked_mode is a little awkward because it contains a double negative. Actually, following the design of the prototype we would have set_unchecked_mode(family, bool) Thus the pattern I wrote last week would become something like:

> clear_log_of_unchecked_steps()
> set_unchecked_mode(true)
> # do your computation
> set_unchecked_mode(false)
> get_log_of_unchecked_steps()

It is unfortunate that the names for querying and obtaining the log do not have a common prefix…

I feel ‘unchecked’ isn’t scary enough – this suggests other things are ‘checked’ – which to me nowadays implied something like a lean-verified proof, a much higher standard that is being achieved here.

For example in the SAT community, unchecked means ‘we did not execute a computer-verified proof of the result’: https://helda.helsinki.fi/server/api/core/bitstreams/479ee28a-6c55-4259-9306-6a3eb3166932/content , but it’s still expected to be correct, so under that metric everything in both GAP and Oscar is ‘unchecked’ (unless anyone is doing work on lean proofs I’ve missed)

I understand your position here, but am inclined to believe that OSCAR is sufficiently far removed from the SAT community (or SMT community) that we are not obliged to adopt their convention regarding the meaning of unchecked.

Lean-verification is nice to have but I’d question it’s being of a much higher standard : see Lean & Collatz conjecture. I believe that so far no-one has found a composite number which is reported as prime in the current GMP implementation; and I surmise that considerable effort by experts in the area has been invested. In summary the probability of an unchecked result being wrong is almost certainly extremely low.

Another name proposal: Plausible mode. This has a more “positive” ring to it, while also being somewhat indicative: the produced result is plausibly correct