pattern-matching - 在 Agda 中如何使用 with 检查?

标签 pattern-matching coq type-inference agda

我正在尝试从 agda 的编程基础中重现一个非常简单的 coq 证明,并被告知我需要使用 with 检查来证明与字符串本身的( bool )可判定性上的模式匹配的矛盾。我收到以下错误,文档甚至没有提供与检查一起使用的正确程序。为什么这种类型推断不正确,我该如何解决我的错误?

module Maps where

open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; subst; trans; sym; inspect)
open import Data.String using (_++_; _==_; _≟_; String)
open import Data.Bool using (T; Bool; true; false; if_then_else_)

-- Coq-- Theorem eqb_string_refl : forall s : string, true = eqb_string s s.
eqbstringrefl' : (s : String) →  true ≡ (s == s)
eqbstringrefl' s with inspect (s == s) 
... | false with≡ eq = {!!}
... | true with≡ eq  = {!!}

(s == s) 以红色突出显示并产生以下错误
Bool !=< (x : _A_70) → _B_71 x of type Set
when checking that the inferred type of an application
Bool
matches the expected type
(x : _A_70) → _B_71 x

最佳答案

inspect标准库中的函数具有以下类型:

inspect : ∀ {A : Set a} {B : A → Set b}
          (f : (x : A) → B x) (x : A) → Reveal f · x is f x

如您所见,它需要两个显式参数:一个函数 f和一个值 x . user manual有一节介绍了如何使用检查习语,特别是第二个示例使用了与 inspect 基本相同的定义作为标准库。

关于pattern-matching - 在 Agda 中如何使用 with 检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61131939/

相关文章:

unix - AWK 根据搜索模式打印特定行

coq - 大小未知的有限列表

Java regex - 如何获取空格和字符?

java - 如何在Java上编写 "(event, state) -> state"函数

coq - 如何编写行为类似于 "destruct ... as"的策略?

math - 如何描述 Coq 中的一对多关系?

objective-c - 是否有等效于 C#'s ' var' 关键字的 Objective-C?

typescript :在可选的第一个泛型之后推断泛型的类型

java - 在方法参数中强制执行泛型类型相等性约束

Swift "h"must be bound in every pattern 错误 - 开关问题