Any-comm : ∀ {A : Set} {P : A → Set} (xs ys : List A) →
Any P (xs ++ ys) → Any P (ys ++ xs)
Any-comm xs [] prf = {!!}
Goal: Any P xs
————————————————————————————————————————————————————————————
prf : Any P (xs ++ [])
xs : List A
P : A → Set (not in scope)
A : Set (not in scope)
如何在此处使用附加标识重写prf
?我想我可以改写匹配的目标,但前提是可以这样做吗?我觉得以后会更整洁。
答案 0 :(得分:1)
啊,看来我对重写工作原理的假设是错误的。
Any-comm xs [] prf rewrite sym (++-identityʳ xs) = {!!}
Goal: Any P (xs ++ [])
————————————————————————————————————————————————————————————
prf : Any P ((xs ++ []) ++ [])
P : A → Set (not in scope)
xs : List A
A : Set (not in scope)
当我尝试以上内容时,我惊讶地发现它重写了目标和前提。因此,重写前提的方法就是。
Any-comm xs [] prf rewrite ++-identityʳ xs = prf
我不确定这是否会如此令人惊讶,但尽管几乎遍历了PLFA书第1卷的全部内容,但我没有注意到这一点。这种行为不同于Coq的重写。