【发布时间】:2020-07-22 17:50:39
【问题描述】:
我想知道是否有系统的方法可以将 Coq 定义解释为 agda 程序。我正在翻译部分编程基础,但无法让 tUpdate 函数在下面工作。为什么这会失败。 coq代码被注释掉了。
--Definition total_map (A : Type) := string -> A.
totalMap : Set → Set
totalMap A = String → A
-- Definition t_empty {A : Type} (v : A) : total_map A :=
-- (fun _ => v).
tEmpty : {A : Set} (v : A) → totalMap A
tEmpty = λ v x → v
-- Definition t_update {A : Type} (m : total_map A)
-- (x : string) (v : A) :=
-- fun x' => if eqb_string x x' then v else m x'.
tUpdate : {A : Set} (m : totalMap A) (x : String) (v : A) → Set
tUpdate m x v = λ x' → (if (x == x') then v else m x')
lambda 项产生以下错误
(x' : String) → A !=< Set of type Set
when checking that the expression
λ x' → if x == x' then v else m x' has type Set
这是否是进行此翻译的正确通用模式,例如,此翻译是否合理且完整?
编辑:
我意识到 update 应该返回一个地图,但我很困惑,因为它 coq 似乎可以推断出这一点,而 agda 不能?我仍然欢迎对后一个问题提供更一般的答案。
tUpdate : {A : Set} (m : totalMap A) (x : String) (v : A) → totalMap A
tUpdate m x v = λ x' → (if (x == x') then v else m x')
【问题讨论】:
标签: compilation coq translate agda