@@ -11,9 +11,11 @@ module Data.Fin.Permutation where
11
11
open import Data.Bool.Base using (true; false)
12
12
open import Data.Fin.Base using (Fin; suc; cast; opposite; punchIn; punchOut)
13
13
open import Data.Fin.Patterns using (0F; 1F)
14
- open import Data.Fin.Properties using (punchInᵢ≢i; punchOut-punchIn;
15
- punchOut-cong; punchOut-cong′; punchIn-punchOut
16
- ; _≟_; ¬Fin0; cast-involutive; opposite-involutive)
14
+ open import Data.Fin.Properties
15
+ using (¬Fin0; _≟_; ≟-≡-refl; ≟-≢
16
+ ; cast-involutive; opposite-involutive
17
+ ; punchInᵢ≢i; punchOut-punchIn; punchIn-punchOut
18
+ ; punchOut-cong; punchOut-cong′)
17
19
import Data.Fin.Permutation.Components as PC
18
20
open import Data.Nat.Base using (ℕ; suc; zero; 2+)
19
21
open import Data.Product.Base using (_,_; proj₂)
@@ -26,9 +28,8 @@ open import Function.Properties.Inverse using (↔⇒↣)
26
28
open import Function.Base using (_∘_; _∘′_)
27
29
open import Level using (0ℓ)
28
30
open import Relation.Binary.Core using (Rel)
29
- open import Relation.Nullary using (does; ¬_; yes; no)
30
- open import Relation.Nullary.Decidable using (dec-yes; dec-no)
31
- open import Relation.Nullary.Negation using (contradiction)
31
+ open import Relation.Nullary.Decidable.Core using (does; yes; no)
32
+ open import Relation.Nullary.Negation.Core using (¬_; contradiction)
32
33
open import Relation.Binary.PropositionalEquality.Core
33
34
using (_≡_; _≢_; refl; sym; trans; subst; cong; cong₂)
34
35
open import Relation.Binary.PropositionalEquality.Properties
@@ -167,19 +168,19 @@ remove {m} {n} i π = permutation to from inverseˡ′ inverseʳ′
167
168
168
169
inverseʳ′ : StrictlyInverseʳ _≡_ to from
169
170
inverseʳ′ j = begin
170
- from (to j) ≡⟨⟩
171
- punchOut {i = i} {πˡ (punchIn (πʳ i) (punchOut to-punchOut))} _ ≡⟨ punchOut-cong′ i (cong πˡ (punchIn-punchOut _)) ⟩
172
- punchOut {i = i} {πˡ (πʳ (punchIn i j))} _ ≡⟨ punchOut-cong i (inverseˡ π) ⟩
173
- punchOut {i = i} {punchIn i j} _ ≡⟨ punchOut-punchIn i ⟩
174
- j ∎
171
+ from (to j) ≡⟨⟩
172
+ punchOut {i = i} {πˡ (punchIn (πʳ i) (punchOut to-punchOut))} _ ≡⟨ punchOut-cong′ i (cong πˡ (punchIn-punchOut _)) ⟩
173
+ punchOut {i = i} {πˡ (πʳ (punchIn i j))} _ ≡⟨ punchOut-cong i (inverseˡ π) ⟩
174
+ punchOut {i = i} {punchIn i j} _ ≡⟨ punchOut-punchIn i ⟩
175
+ j ∎
175
176
176
177
inverseˡ′ : StrictlyInverseˡ _≡_ to from
177
178
inverseˡ′ j = begin
178
- to (from j) ≡⟨⟩
179
- punchOut {i = πʳ i} {πʳ (punchIn i (punchOut from-punchOut))} _ ≡⟨ punchOut-cong′ (πʳ i) (cong πʳ (punchIn-punchOut _)) ⟩
180
- punchOut {i = πʳ i} {πʳ (πˡ (punchIn (πʳ i) j))} _ ≡⟨ punchOut-cong (πʳ i) (inverseʳ π) ⟩
181
- punchOut {i = πʳ i} {punchIn (πʳ i) j} _ ≡⟨ punchOut-punchIn (πʳ i) ⟩
182
- j ∎
179
+ to (from j) ≡⟨⟩
180
+ punchOut {i = πʳ i} {πʳ (punchIn i (punchOut from-punchOut))} _ ≡⟨ punchOut-cong′ (πʳ i) (cong πʳ (punchIn-punchOut _)) ⟩
181
+ punchOut {i = πʳ i} {πʳ (πˡ (punchIn (πʳ i) j))} _ ≡⟨ punchOut-cong (πʳ i) (inverseʳ π) ⟩
182
+ punchOut {i = πʳ i} {punchIn (πʳ i) j} _ ≡⟨ punchOut-punchIn (πʳ i) ⟩
183
+ j ∎
183
184
184
185
------------------------------------------------------------------------
185
186
-- Lifting
@@ -228,23 +229,23 @@ insert {m} {n} i j π = permutation to from inverseˡ′ inverseʳ′
228
229
229
230
inverseʳ′ : StrictlyInverseʳ _≡_ to from
230
231
inverseʳ′ k with i ≟ k
231
- ... | yes i≡k rewrite proj₂ (dec-yes (j ≟ j) refl) = i≡k
232
+ ... | yes i≡k rewrite ≟-≡-refl j = i≡k
232
233
... | no i≢k
233
234
with j≢punchInⱼπʳpunchOuti≢k ← punchInᵢ≢i j (π ⟨$⟩ʳ punchOut i≢k) ∘ sym
234
- rewrite dec-no (j ≟ punchIn j (π ⟨$⟩ʳ punchOut i≢k)) j≢punchInⱼπʳpunchOuti≢k
235
+ rewrite ≟-≢ j≢punchInⱼπʳpunchOuti≢k
235
236
= begin
236
237
punchIn i (π ⟨$⟩ˡ punchOut j≢punchInⱼπʳpunchOuti≢k) ≡⟨ cong (λ l → punchIn i (π ⟨$⟩ˡ l)) (punchOut-cong j refl) ⟩
237
238
punchIn i (π ⟨$⟩ˡ punchOut (punchInᵢ≢i j (π ⟨$⟩ʳ punchOut i≢k) ∘ sym)) ≡⟨ cong (λ l → punchIn i (π ⟨$⟩ˡ l)) (punchOut-punchIn j) ⟩
238
- punchIn i (π ⟨$⟩ˡ (π ⟨$⟩ʳ punchOut i≢k)) ≡⟨ cong (punchIn i) (inverseˡ π) ⟩
239
- punchIn i (punchOut i≢k) ≡⟨ punchIn-punchOut i≢k ⟩
240
- k ∎
239
+ punchIn i (π ⟨$⟩ˡ (π ⟨$⟩ʳ punchOut i≢k)) ≡⟨ cong (punchIn i) (inverseˡ π) ⟩
240
+ punchIn i (punchOut i≢k) ≡⟨ punchIn-punchOut i≢k ⟩
241
+ k ∎
241
242
242
243
inverseˡ′ : StrictlyInverseˡ _≡_ to from
243
244
inverseˡ′ k with j ≟ k
244
- ... | yes j≡k rewrite proj₂ (dec-yes (i ≟ i) refl) = j≡k
245
+ ... | yes j≡k rewrite ≟-≡-refl i = j≡k
245
246
... | no j≢k
246
247
with i≢punchInᵢπˡpunchOutj≢k ← punchInᵢ≢i i (π ⟨$⟩ˡ punchOut j≢k) ∘ sym
247
- rewrite dec-no (i ≟ punchIn i (π ⟨$⟩ˡ punchOut j≢k)) i≢punchInᵢπˡpunchOutj≢k
248
+ rewrite ≟-≢ i≢punchInᵢπˡpunchOutj≢k
248
249
= begin
249
250
punchIn j (π ⟨$⟩ʳ punchOut i≢punchInᵢπˡpunchOutj≢k) ≡⟨ cong (λ l → punchIn j (π ⟨$⟩ʳ l)) (punchOut-cong i refl) ⟩
250
251
punchIn j (π ⟨$⟩ʳ punchOut (punchInᵢ≢i i (π ⟨$⟩ˡ punchOut j≢k) ∘ sym)) ≡⟨ cong (λ l → punchIn j (π ⟨$⟩ʳ l)) (punchOut-punchIn i) ⟩
@@ -339,12 +340,7 @@ insert-remove {m = m} {n = n} i π j with i ≟ j
339
340
π ⟨$⟩ʳ j ∎
340
341
341
342
remove-insert : ∀ i j (π : Permutation m n) → remove i (insert i j π) ≈ π
342
- remove-insert i j π k with i ≟ i
343
- ... | no i≢i = contradiction refl i≢i
344
- ... | yes _ = begin
345
- punchOut {i = j} _
346
- ≡⟨ punchOut-cong j (insert-punchIn i j π k) ⟩
347
- punchOut {i = j} (punchInᵢ≢i j (π ⟨$⟩ʳ k) ∘ sym)
348
- ≡⟨ punchOut-punchIn j ⟩
349
- π ⟨$⟩ʳ k
350
- ∎
343
+ remove-insert i j π k rewrite ≟-≡-refl i = begin
344
+ punchOut {i = j} _ ≡⟨ punchOut-cong j (insert-punchIn i j π k) ⟩
345
+ punchOut {i = j} (punchInᵢ≢i j (π ⟨$⟩ʳ k) ∘ sym) ≡⟨ punchOut-punchIn j ⟩
346
+ π ⟨$⟩ʳ k ∎
0 commit comments