难以在 Idris 中应用证明

Difficulty applying a proof in Idris

我正在尝试证明 属性 我定义的一种数据类型,如下所示:

reverseProof' : (inputBlock : Block iType iSize iInputs)
          -> (ind : Fin rSize)
          -> (rInputs : Vect rSize Ty)
          -> (receiveBlock : Block rType rSize rInputs)
          -> (prf : index ind rInputs = iType)
          -> (newInsert : MaybeBlockty iType)
          -> (HVect (replaceAt ind (MaybeBlockty iType) (map MaybeBlockty rInputs))) 
          ->  (HVect (map MaybeBlockty rInputs))

为了证明这一点,我试图使用一个较早的事实证明:

replaceAtProof' : (xs : Vect n a) 
           -> (i : Fin n)
           -> (f : a -> b) 
           -> ((index i xs) = x) 
           -> (replaceAt i (f x) (map f xs)) = (map f xs) 

我希望只要尝试重写 reverseAtProof' 中的适当表达式就可以实现这一点,但是当尝试重写如下时:

reverseProof' inputBlock ind rInputs receiveBlock prf newInsert x = rewrite replaceAtProof' rInputs ind MaybeBlockty prf in x

我收到如下错误:

When checking right hand side of reverseProof' with expected type HVect (map MaybeBlockty rInputs)

rewriting replaceAt ind
          (Maybe (len : Nat ** tyList : Vect len Ty ** Block iType len tyList))
          (Data.Vect.Vect n implementation of Prelude.Functor.Functor, method map MaybeBlockty rInputs) 

to 

           Data.Vect.Vect n implementation of Prelude.Functor.Functor, method map MaybeBlockty rInputs 

did not change type HVect (Data.Vect.Vect n implementation of Prelude.Functor.Functor, method map MaybeBlockty rInputs)

我读到这个错误是说它无法应用尝试的重写,因为它在 x 中找不到指定的模式。这似乎是因为编译器减少了

的定义
MaybeBlockty iType

成为

Maybe (len : Nat ** tyList : Vect len Ty ** Block iType len tyList)

:编辑 MaybeBlockty

的定义

我有什么办法可以防止这种情况发生,以便应用给定的重写,还是我误读了给定的错误?

rewrite 使用提供的从左到右的相等性更改目标的类型。由于您需要它适合 x 的类型,因此您的重写应该朝相反的方向进行:尝试 rewrite sym $ replaceAtProof' rInputs ind MaybeBlockty prf in x