What does `|` mean in a goal-type in Agda?

时间:2015-12-10 01:13:30

标签: types functional-programming agda dependent-type theorem-proving

I'm reading the Brutal Meta-introduction to Agda.

In the section on "Rewriting with with and Unification" they mention a a case where a type of a goal goes from:

(filter p (a ∷ as) | p a) ≡ (filterN p (a ∷ as) | p a)

to

(filter p (a ∷ rs) | r) ≡ (filterN p (a ∷ rs) | r)

after adding a with clause.

I've seen similar notation show up in goals and error messages when writing Agda code.

I'm wondering, does it mean to have a variable to the right of |, in this notation? Is this documented anywhere?

1 个答案:

答案 0 :(得分:1)

如果你看一下过滤器的定义,你会看到像

这样的子句
... | true  = a ∷ (filter p as)

的简写
filter p (a ∷ as) | true = a ∷ (filter p as)

|目标中的符号表示这些条款,这意味着例如

filter p (a ∷ as) | e

等于"a∷(滤波器p as)"当" e"等于" true"。

在你的情况下,你有一个变量' r',所以如果你对它进行模式匹配,事情会计算得更多。