Types Agda未消除目标中的子句,尽管目标上有模式匹配

Types Agda未消除目标中的子句,尽管目标上有模式匹配,types,proof,agda,theorem-proving,Types,Proof,Agda,Theorem Proving,我有一段agda代码,格式如下: Terminates : I believe the below snippet models your problem accurately: module _ where open import Data.Maybe open import Data.Product open import Relation.Binary.PropositionalEquality open import Data.Unit open import Data.Maybe.

我有一段agda代码,格式如下:


Terminates : I believe the below snippet models your problem accurately:

module _ where

open import Data.Maybe
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Data.Unit
open import Data.Maybe.Relation.Unary.Any

variable
  A B : Set

Terminates : ∀ {A B : Set} → (A → Maybe B) → Set
Terminates f = Σ _ λ x → Is-just (f x)

example : ∀ (f : A → Maybe B) x y → f x ≡ just y → Terminates f
example f x y p = x , {!!}


终止:我相信下面的代码片段准确地模拟了您的问题:

just _x_26 != f x of type Maybe B
when checking that the inferred type of an application
  Any (λ _ → ⊤) (just _x_26)
matches the expected type
  Is-just (f x)
这里,孔的类型是
正好是(fx)
,我们想用证明
p
来解决它。问题是我们不能只把tt写进洞里:

example : ∀ (f : A → Maybe B) x y → f x ≡ just y → Terminates f
example f x y p = x , subst Is-just (sym p) (just tt)
因为
fx
不能简化为
只是
,因为我们对
f
x
一无所知。但是等等,我们确实知道一些关于它的事情-
p
。因此,我们需要安排
p
在这里发挥作用:

这里,(在统一之后)我们有
just tt:Is just(just y)
,我们用等式
sym p:just y重写它的类型≡ fx
,to
subst(just tt):是just(fx)
,这正是我们的目标