Skip to content

Commit ebeb3be

Browse files
authored
Show that index (∈-lookup i xs) is in fact i (#1264)
1 parent 02ad1f4 commit ebeb3be

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ Other minor additions
506506
take⁺ : ∀ {n} m {xs} → All P {m + n} xs → All P {m} (take m xs)
507507
```
508508

509+
* Added new proofs to `Data.Vec.Membership.Propositional.Properties`:
510+
```agda
511+
index-∈-lookup : (i : Fin n) (xs : Vec A n) → Any.index (∈-lookup i xs) ≡ i
512+
```
513+
509514
Refactorings
510515
------------
511516

src/Data/Vec/Membership/Propositional/Properties.agda

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ open import Data.Vec hiding (here; there)
1414
open import Data.Vec.Relation.Unary.Any using (here; there)
1515
open import Data.List.Base using ([]; _∷_)
1616
open import Data.List.Relation.Unary.Any using (here; there)
17-
open import Data.Vec.Relation.Unary.Any using (Any; here; there)
17+
open import Data.Vec.Relation.Unary.Any as Any using (Any; here; there)
1818
open import Data.Vec.Membership.Propositional
1919
open import Data.List.Membership.Propositional
2020
using () renaming (_∈_ to _∈ₗ_)
2121
open import Level using (Level)
2222
open import Function using (_∘_; id)
2323
open import Relation.Unary using (Pred)
24-
open import Relation.Binary.PropositionalEquality using (refl)
24+
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong)
2525

2626
private
2727
variable
@@ -36,6 +36,10 @@ private
3636
∈-lookup zero (x ∷ xs) = here refl
3737
∈-lookup (suc i) (x ∷ xs) = there (∈-lookup i xs)
3838

39+
index-∈-lookup : {n} (i : Fin n) (xs : Vec A n) Any.index (∈-lookup i xs) ≡ i
40+
index-∈-lookup zero (x ∷ xs) = refl
41+
index-∈-lookup (suc i) (x ∷ xs) = cong suc (index-∈-lookup i xs)
42+
3943
------------------------------------------------------------------------
4044
-- map
4145

0 commit comments

Comments
 (0)