Closed ayanamists closed 1 year ago
Hi @ayanamists, the error message is confusing here. The issue is regarding the monotonicity property of the wp
argument of PURE
.
We don't normally use PURE
directly but rather use its Hoare-style variant Pure
; it is more readable and also gets past this monotonicity requirement.
let g (x:int) : Pure int (requires True) (ensures fun y -> y >= 0) = op_Multiply x x
To convince F* that the wp written in your example is monotonic (you can see the definition of monotonicity in ulib/prims.fst
), we need to use the as_pure_wp
combinator from ulib/FStar.Monotonic.Pure
:
val f (x:ℤ) : PURE ℤ (as_pure_wp (λ post → ∀ y. y ≥ 0 ⟹ post y))
let f x = op_Multiply x x
But we should fix the error message in any case.
Hi @ayanamists, the error message is confusing here. The issue is regarding the monotonicity property of the
wp
argument ofPURE
.We don't normally use
PURE
directly but rather use its Hoare-style variantPure
; it is more readable and also gets past this monotonicity requirement.let g (x:int) : Pure int (requires True) (ensures fun y -> y >= 0) = op_Multiply x x
To convince F* that the wp written in your example is monotonic (you can see the definition of monotonicity in
ulib/prims.fst
), we need to use theas_pure_wp
combinator fromulib/FStar.Monotonic.Pure
:val f (x:ℤ) : PURE ℤ (as_pure_wp (λ post → ∀ y. y ≥ 0 ⟹ post y)) let f x = op_Multiply x x
But we should fix the error message in any case.
I got it. Thank you for your reply!
I have pushed a small fix so that the error message is now:
Test.fst(4,38-4,65): (Error 19) Subtyping check failed; expected type wp: Prims.pure_wp' Prims.int {Prims.pure_wp_monotonic Prims.int wp}; got type post: (_: Prims.int -> Prims.logical) -> Prims.logical; The SMT solver could not prove the query. Use --query_stats for more details. (see also prims.fst(326,38-326,60))
And it highlights the wp body.
Thanks again for the report.
I'm now reading Dijkstra Monad for free and try this code :
fstar.exe output:
It seems to complain that
int
should beType0
but gotType0
(For me, this error is confusing)Do I make any mistake ? Or fstar prevent user from using
PURE
effect directly ?The version info of fstar.exe