难以在伊德里斯申请证明

时间:2017-09-11 20:38:55

标签: idris theorem-proving

我试图通过以下定义的数据类型证明某个属性:

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

的定义

我有什么方法可以阻止这种情况发生,以便适用给定的重写,或者我误读了给定的错误?

1 个答案:

答案 0 :(得分:2)

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

相关问题