@@ -11,9 +11,11 @@ module Data.Fin.Permutation where
1111open import Data.Bool.Base using (true; false)
1212open import Data.Fin.Base using (Fin; suc; cast; opposite; punchIn; punchOut)
1313open 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′)
1719import Data.Fin.Permutation.Components as PC
1820open import Data.Nat.Base using (ℕ; suc; zero; 2+)
1921open import Data.Product.Base using (_,_; proj₂)
@@ -26,9 +28,8 @@ open import Function.Properties.Inverse using (↔⇒↣)
2628open import Function.Base using (_∘_; _∘′_)
2729open import Level using (0ℓ)
2830open 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)
3233open import Relation.Binary.PropositionalEquality.Core
3334 using (_≡_; _≢_; refl; sym; trans; subst; cong; cong₂)
3435open import Relation.Binary.PropositionalEquality.Properties
@@ -167,19 +168,19 @@ remove {m} {n} i π = permutation to from inverseˡ′ inverseʳ′
167168
168169 inverseʳ′ : StrictlyInverseʳ _≡_ to from
169170 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 ∎
175176
176177 inverseˡ′ : StrictlyInverseˡ _≡_ to from
177178 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 ∎
183184
184185------------------------------------------------------------------------
185186-- Lifting
@@ -228,23 +229,23 @@ insert {m} {n} i j π = permutation to from inverseˡ′ inverseʳ′
228229
229230 inverseʳ′ : StrictlyInverseʳ _≡_ to from
230231 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
232233 ... | no i≢k
233234 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
235236 = begin
236237 punchIn i (π ⟨$⟩ˡ punchOut j≢punchInⱼπʳpunchOuti≢k) ≡⟨ cong (λ l → punchIn i (π ⟨$⟩ˡ l)) (punchOut-cong j refl) ⟩
237238 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 ∎
241242
242243 inverseˡ′ : StrictlyInverseˡ _≡_ to from
243244 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
245246 ... | no j≢k
246247 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
248249 = begin
249250 punchIn j (π ⟨$⟩ʳ punchOut i≢punchInᵢπˡpunchOutj≢k) ≡⟨ cong (λ l → punchIn j (π ⟨$⟩ʳ l)) (punchOut-cong i refl) ⟩
250251 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
339340 π ⟨$⟩ʳ j ∎
340341
341342remove-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