stainless icon indicating copy to clipboard operation
stainless copied to clipboard

Require (or at least allow) witnesses for choose

Open vkuncak opened this issue 3 years ago • 2 comments

Choose construct is used internally in Stainless as well as exposed to the user. However, soundness of choose depends on the conjunction of the type and the predicate being non-empty. The proof obligation for this is in fact a quantified statement, which breaks the design principle that core functionality should not require quantifiers.

I thus propose that we introduce explicitly provided witnesses for choose, so that we eliminate the need for quantifiers.

choose((x:T) => p, witness)

would check witness:T (however that should be represented in the SystemFR type checker) and then check

assert(p(witness))

vkuncak avatar Apr 26 '22 12:04 vkuncak

For abstract methods, instead of using ???, let us introduce ???(w) where w specifies a witness value.

vkuncak avatar May 20 '22 08:05 vkuncak

I would like a solution that in most of our current cases avoids the need for solving quantified constraints. @samarion we may need your opinion as it seems to be affecting core of Inox.

vkuncak avatar May 20 '22 08:05 vkuncak