| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Application of substitutions to lists, along with various lemmas |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- This module illustrates how Data.Fin.Substitution.Lemmas.AppLemmas |
| 8 |
-- can be used. |
| 9 |
|
| 10 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 11 |
|
| 12 |
open import Data.Fin.Substitution.Lemmas using (Lemmas₄; AppLemmas) |
| 13 |
open import Data.Nat.Base using (ℕ) |
| 14 |
|
| 15 |
module Data.Fin.Substitution.List {ℓ} {T : ℕ → Set ℓ} (lemmas₄ : Lemmas₄ T) where |
| 16 |
|
| 17 |
open import Data.List.Base using (List; map) |
| 18 |
open import Data.List.Properties using (map-id; map-cong; map-∘) |
| 19 |
open import Data.Fin.Substitution using (Sub) |
| 20 |
import Function.Base as Fun |
| 21 |
open import Relation.Binary.PropositionalEquality.Properties |
| 22 |
using (module ≡-Reasoning) |
| 23 |
|
| 24 |
private |
| 25 |
variable |
| 26 |
m n : ℕ |
| 27 |
|
| 28 |
ListT : ℕ → Set ℓ |
| 29 |
ListT = List Fun.∘ T |
| 30 |
|
| 31 |
open module L = Lemmas₄ lemmas₄ using (_/_; id; _⊙_) |
| 32 |
|
| 33 |
------------------------------------------------------------------------ |
| 34 |
-- Listwise application of a substitution, plus lemmas about it |
| 35 |
|
| 36 |
infixl 8 _//_ |
| 37 |
|
| 38 |
_//_ : ListT m → Sub T m n → ListT n |
| 39 |
ts // ρ = map (λ σ → σ / ρ) ts |
| 40 |
|
| 41 |
appLemmas : AppLemmas ListT T |
| 42 |
appLemmas = record |
| 43 |
{ application = record { _/_ = _//_ } |
| 44 |
; lemmas₄ = lemmas₄ |
| 45 |
; id-vanishes = λ ts → begin |
| 46 |
ts // id ≡⟨ map-cong L.id-vanishes ts ⟩ |
| 47 |
map Fun.id ts ≡⟨ map-id ts ⟩ |
| 48 |
ts ∎ |
| 49 |
; /-⊙ = λ {_ _ _ ρ₁ ρ₂} ts → begin |
| 50 |
ts // ρ₁ ⊙ ρ₂ ≡⟨ map-cong L./-⊙ ts ⟩ |
| 51 |
map (λ σ → σ / ρ₁ / ρ₂) ts ≡⟨ map-∘ ts ⟩ |
| 52 |
ts // ρ₁ // ρ₂ ∎ |
| 53 |
} where open ≡-Reasoning |
| 54 |
|
| 55 |
open AppLemmas appLemmas public |
| 56 |
hiding (_/_) renaming (_/✶_ to _//✶_) |