簡體   English   中英

如何在 Agda 中使用 with inspect ?

[英]How does one use the with inspect in Agda?

我試圖從agda 的編程基礎中重現一個非常簡單的coq 證明,並被告知我需要使用withinspect 來證明與字符串自身的(bool)可判定性上的模式匹配的矛盾。 我收到以下錯誤,文檔甚至沒有給出使用 with inspect 的正確程序。 為什么這種類型推斷不正確,我該如何解決我的錯誤?

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 function有以下類型:

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

如您所見,它需要兩個顯式 arguments:一個 function f和一個值x 用戶手冊有一節介紹如何使用檢查習語,特別是第二個示例使用與標准庫基本相同的inspect定義。

標准庫有一個處理inspect習語的README文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM