Skip to content

Commit 5279af1

Browse files
committed
refactor: add new lemmas, simplify old proof
1 parent c781fc1 commit 5279af1

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ Additions to existing modules
237237
∙-cong-∣ : x ∣ y → a ∣ b → x ∙ a ∣ y ∙ b
238238
```
239239

240+
* In `Data.Fin.Permutation.Components`:
241+
```agda
242+
transpose-iij : (i j : Fin n) → transpose i i j ≡ j
243+
transpose-ijj : (i j : Fin n) → transpose i j j ≡ i
244+
transpose-iji : (i j : Fin n) → transpose i j i ≡ j
245+
transpose-transpose : transpose i j k ≡ l → transpose j i l ≡ k
246+
```
247+
240248
* In `Data.Fin.Properties`:
241249
```agda
242250
≡-irrelevant : Irrelevant {A = Fin n} _≡_

src/Data/Fin/Permutation/Components.agda

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,18 @@ module Data.Fin.Permutation.Components where
1111
open import Data.Bool.Base using (Bool; true; false)
1212
open import Data.Fin.Base using (Fin; suc; opposite; toℕ)
1313
open import Data.Fin.Properties
14-
using (_≟_; opposite-prop; opposite-involutive; opposite-suc)
15-
open import Data.Nat.Base as ℕ using (zero; suc; _∸_)
16-
open import Data.Product.Base using (proj₂)
17-
open import Function.Base using (_∘_)
14+
using (_≟_; ≟-diag; ≟-diag-refl
15+
; opposite-prop; opposite-involutive; opposite-suc)
1816
open import Relation.Nullary.Reflects using (invert)
19-
open import Relation.Nullary using (does; _because_; yes; no)
20-
open import Relation.Nullary.Decidable using (dec-true; dec-false)
17+
open import Relation.Nullary.Decidable.Core using (does; _because_)
2118
open import Relation.Binary.PropositionalEquality.Core
22-
using (_≡_; refl; sym; trans)
23-
open import Relation.Binary.PropositionalEquality.Properties
24-
using (module ≡-Reasoning)
25-
open import Algebra.Definitions using (Involutive)
26-
open ≡-Reasoning
19+
using (_≡_; refl; sym)
2720

2821
------------------------------------------------------------------------
2922
-- Functions
3023
------------------------------------------------------------------------
3124

32-
-- 'tranpose i j' swaps the places of 'i' and 'j'.
25+
-- 'transpose i j' swaps the places of 'i' and 'j'.
3326

3427
transpose : {n} Fin n Fin n Fin n Fin n
3528
transpose i j k with does (k ≟ i)
@@ -42,17 +35,31 @@ transpose i j k with does (k ≟ i)
4235
-- Properties
4336
------------------------------------------------------------------------
4437

38+
transpose-iij : {n} (i j : Fin n) transpose i i j ≡ j
39+
transpose-iij i j with j ≟ i in j≟i
40+
... | true because [j≡i] = sym (invert [j≡i])
41+
... | false because _ rewrite j≟i = refl
42+
43+
transpose-ijj : {n} (i j : Fin n) transpose i j j ≡ i
44+
transpose-ijj i j with j ≟ i
45+
... | true because [j≡i] = invert [j≡i]
46+
... | false because _ rewrite ≟-diag-refl j = refl
47+
48+
transpose-iji : {n} (i j : Fin n) transpose i j i ≡ j
49+
transpose-iji i j rewrite ≟-diag-refl i = refl
50+
51+
transpose-transpose : {n} {i j k l : Fin n}
52+
transpose i j k ≡ l transpose j i l ≡ k
53+
transpose-transpose {n} {i} {j} {k} {l} eq with k ≟ i in k≟i
54+
... | true because [k≡i] rewrite ≟-diag (sym eq) = sym (invert [k≡i])
55+
... | false because [k≢i] with k ≟ j in k≟j
56+
... | true because [k≡j] rewrite eq | transpose-ijj j l = sym (invert [k≡j])
57+
... | false because [k≢j] rewrite eq | k≟j | k≟i = refl
58+
4559
transpose-inverse : {n} (i j : Fin n) {k}
4660
transpose i j (transpose j i k) ≡ k
47-
transpose-inverse i j {k} with k ≟ j
48-
... | true because [k≡j] rewrite dec-true (i ≟ i) refl = sym (invert [k≡j])
49-
... | false because [k≢j] with k ≟ i
50-
... | true because [k≡i]
51-
rewrite dec-false (j ≟ i) (invert [k≢j] ∘ trans (invert [k≡i]) ∘ sym)
52-
| dec-true (j ≟ j) refl
53-
= sym (invert [k≡i])
54-
... | false because [k≢i] rewrite dec-false (k ≟ i) (invert [k≢i])
55-
| dec-false (k ≟ j) (invert [k≢j]) = refl
61+
transpose-inverse i j = transpose-transpose refl
62+
5663

5764
------------------------------------------------------------------------
5865
-- DEPRECATED NAMES

0 commit comments

Comments
 (0)