Agda, type of proofs and with clause

旧城冷巷雨未停 提交于 2019-12-05 19:19:33

Just do not pattern-match on p x:

predicate {A} {p} {xs = []} = all[]
predicate {A} {p} {x :: xs} with inspect (p x) 
predicate {A} {p} {x :: xs} | it true  pf rewrite pf = {!!}
predicate {A} {p} {x :: xs} | it false pf rewrite pf = {!!}

Note, that the inspect idiom is deprecated. Use inspect on steroids. You can find it in the standard library here.

Your code becomes

predicate : ∀ {A : Set} {p : A -> Bool } {xs : List A } -> 
            All (satisfies p) (filter p xs)  
predicate {A} {p} {xs = []} = all[]
predicate {A} {p} {xs = x :: xs} with p x | inspect p x
predicate {A} {p} {x :: xs} | true  | [ pf ] = {!!}
predicate {A} {p} {x :: xs} | false | [ pf ] = {!!}

with pf being in the first hole

.Data.Unit.Core.reveal (.Data.Unit.Core.hide p x) == true

which beta-reduces to p x == true. I.e. if you have

test : ∀ {A : Set} {p : A -> Bool} {x} -> p x == true -> True
test _ = _ 

then placing test {p = p} pf in the first hole and typing C-c C-d gives you True.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!