Fix: order of parameter in split function.

The `merge` relation can be illustrated as follow:

    merge xs ys zs ≡ xs + ys = zs

This shows a key point: every element of `xs` is contained in `zs`.

The original definition of `split` makes no sense under this revelation.

    split : ∀ {A : Set} {P : A → Set} (P? : Decidable P) (xs : List A)
      → ∃[ ys ] ∃[ zs ] ( merge xs ys zs × All P ys × All (¬_ ∘ P) zs )

`zs` will contain all elements of `xs` (the input!) and we also have that `All (¬_ ∘ P) zs`. This function signature cannot be inhabited, as it would imply that for any `P : A → Set` and any `x : A` we have `¬(P x)`.
This commit is contained in:
Pedro Minicz 2019-10-26 15:25:03 -03:00
parent 0e1c5d34ea
commit 1f5fe587d9

View file

@ -1080,8 +1080,8 @@ Define the following variant of the traditional `filter` function on lists,
which given a decidable predicate and a list returns all elements of the
list satisfying the predicate:
split : ∀ {A : Set} {P : A → Set} (P? : Decidable P) (xs : List A)
→ ∃[ ys ] ∃[ zs ] ( merge xs ys zs × All P ys × All (¬_ ∘ P) zs )
split : ∀ {A : Set} {P : A → Set} (P? : Decidable P) (zs : List A)
→ ∃[ xs ] ∃[ ys ] ( merge xs ys zs × All P xs × All (¬_ ∘ P) ys )
```
-- Your code goes here