fixed bug in Lists

This commit is contained in:
wadler 2018-03-15 11:11:08 -03:00
parent 18dd52b4d0
commit 72ed3ad3d9

View file

@ -795,9 +795,9 @@ All-++ : ∀ {A : Set} {P : A → Set} (xs ys : List A) → All P (xs ++ ys) ≃
All-++ xs ys = All-++ xs ys =
record record
{ to = to xs ys { to = to xs ys
; fro = fro xs ys ; from = from xs ys
; invˡ = invˡ xs ys ; from∘to = from∘to xs ys
; invʳ = invʳ xs ys ; to∘from = to∘from xs ys
} }
where where
@ -807,19 +807,19 @@ All-++ xs ys =
to (x ∷ xs) ys (Px ∷ AllPxsys) with to xs ys AllPxsys to (x ∷ xs) ys (Px ∷ AllPxsys) with to xs ys AllPxsys
... | ⟨ AllPxs , AllPys ⟩ = ⟨ Px ∷ AllPxs , AllPys ⟩ ... | ⟨ AllPxs , AllPys ⟩ = ⟨ Px ∷ AllPxs , AllPys ⟩
fro : ∀ { A : Set} {P : A → Set} (xs ys : List A) → All P xs × All P ys → All P (xs ++ ys) from : ∀ { A : Set} {P : A → Set} (xs ys : List A) → All P xs × All P ys → All P (xs ++ ys)
fro [] ys ⟨ [] , AllPys ⟩ = AllPys from [] ys ⟨ [] , AllPys ⟩ = AllPys
fro (x ∷ xs) ys ⟨ Px ∷ AllPxs , AllPys ⟩ = Px ∷ fro xs ys ⟨ AllPxs , AllPys ⟩ from (x ∷ xs) ys ⟨ Px ∷ AllPxs , AllPys ⟩ = Px ∷ from xs ys ⟨ AllPxs , AllPys ⟩
invˡ : ∀ { A : Set} {P : A → Set} (xs ys : List A) → (AllPxsys : All P (xs ++ ys)) → from∘to : ∀ { A : Set} {P : A → Set} (xs ys : List A) → (AllPxsys : All P (xs ++ ys)) →
fro xs ys (to xs ys AllPxsys) ≡ AllPxsys from xs ys (to xs ys AllPxsys) ≡ AllPxsys
invˡ [] ys AllPys = refl from∘to [] ys AllPys = refl
invˡ (x ∷ xs) ys (Px ∷ AllPxsys) = cong (Px ∷_) (invˡ xs ys AllPxsys) from∘to (x ∷ xs) ys (Px ∷ AllPxsys) = cong (Px ∷_) (from∘to xs ys AllPxsys)
invʳ : ∀ { A : Set} {P : A → Set} (xs ys : List A) → (AllPxsAllPys : All P xs × All P ys) → to∘from : ∀ { A : Set} {P : A → Set} (xs ys : List A) → (AllPxsAllPys : All P xs × All P ys) →
to xs ys (fro xs ys AllPxsAllPys) ≡ AllPxsAllPys to xs ys (from xs ys AllPxsAllPys) ≡ AllPxsAllPys
invʳ [] ys ⟨ [] , AllPys ⟩ = refl to∘from [] ys ⟨ [] , AllPys ⟩ = refl
invʳ (x ∷ xs) ys ⟨ Px ∷ AllPxs , AllPys ⟩ rewrite invʳ xs ys ⟨ AllPxs , AllPys ⟩ = refl to∘from (x ∷ xs) ys ⟨ Px ∷ AllPxs , AllPys ⟩ rewrite to∘from xs ys ⟨ AllPxs , AllPys ⟩ = refl
\end{code} \end{code}
*Exercise* `Any-++` *Exercise* `Any-++`