Closed karolserkis closed 6 years ago
Hi, you need to annotate the eval
function to help F* prove termination:
val eval : env -> #t:ty -> ex:expr t -> Tot (option (value t)) (decreases ex)
The decreases
clause tells F* that ex
decreases in the recursive calls to eval
.
Hope this helps, you could also read more about it here (Sec. 5): https://fstar-lang.org/tutorial/.
Thanks! I understand now. The notation of the error message "%[" << and "uu___16 ] " confused me, but if I just look at the: ex:EvalExpr.expr (EvalExpr.Int) ------ vs ------ EvalExpr.Int; ex it pointed me in the right place. Thanks it worked! All verified.
Great! Closing the issue.
On Fri, Mar 23, 2018 at 01:04:32AM +0000, Karol Serkis wrote:
val eval : env -> #t:ty -> ex:expr t -> option (value t) let rec eval e #t = function [...] | Comp op e1 e2 -> (match eval e e1 , eval e e2 with | Some (IntVal i1), Some (IntVal i2) -> Some (BoolVal (compOpSem op i1 i2)) | _ -> None ) EvalExpr(54,35-54,37): (Error 19) Subtyping check failed; expected type (ex:EvalExpr.expr (EvalExpr.Int){ %[ EvalExpr.Int; ex ] << %[ t; uu___16 ] }); got type EvalExpr.expr (EvalExpr.Int) (see also EvalExpr(45,20-57,7))
The <<
indicates a termination check problem: You need (decreases ex)
.
After reading (Sec. 5) of the tutorial more carefully, I see that more clearly now! Thanks.
This is my module that is failing on the
| Comp op e1 e2 ->
of eval function below, in spite of the previous| Bin op e1 e2 ->
being completely ok and both take types 'int -> int ->' that are the same...I am unsure what its complaining about and don't understand how to proceed here.