match x with -6ren">
gpt4 book ai didi

coq - "if"不仅仅是 "match"的糖

转载 作者:行者123 更新时间:2023-12-04 20:27:42 24 4
gpt4 key购买 nike

这两个定义有什么区别:

Definition f : forall x:bool, if x then bool else nat :=
fun x => match x with
| true => true
| false => 42
end.
(* ^ Accepted by Coq *)

Definition g : forall x:bool, if x then bool else nat :=
fun x => if x then true else 42.
(* ^ REJECTED *)

之前,我假设 if字面意思是 match 的糖但似乎在依赖模式匹配方面受到更多限制,即使它也支持 return反正语法。

这是故意的,如果是,规则是什么?

最佳答案

这对我来说似乎是一个错误:如果你让 Coq 打印 f ,它显示 match作为 if .

f = 
fun x : bool =>
if x as x0 return (if x0 then bool else nat) then true else 42
: forall x : bool, if x then bool else nat

f is not universe polymorphic
Argument scope is [bool_scope]

关于coq - "if"不仅仅是 "match"的糖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55028919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com