mirror of
https://github.com/Smaug123/agdaproofs
synced 2025-10-18 09:48:38 +00:00
Progress towards UFDs (#88)
This commit is contained in:
37
Lists/Map/Map.agda
Normal file
37
Lists/Map/Map.agda
Normal file
@@ -0,0 +1,37 @@
|
||||
{-# OPTIONS --safe --warning=error --without-K #-}
|
||||
|
||||
open import LogicalFormulae
|
||||
open import Functions
|
||||
open import Lists.Definition
|
||||
open import Lists.Fold.Fold
|
||||
open import Lists.Length
|
||||
|
||||
module Lists.Map.Map where
|
||||
|
||||
map : {a b : _} {A : Set a} {B : Set b} (f : A → B) → List A → List B
|
||||
map f [] = []
|
||||
map f (x :: list) = (f x) :: (map f list)
|
||||
|
||||
map' : {a b : _} {A : Set a} {B : Set b} (f : A → B) → List A → List B
|
||||
map' f = fold (λ a → (f a) ::_ ) []
|
||||
|
||||
map=map' : {a b : _} {A : Set a} {B : Set b} (f : A → B) → (l : List A) → (map f l ≡ map' f l)
|
||||
map=map' f [] = refl
|
||||
map=map' f (x :: l) with map=map' f l
|
||||
... | bl = applyEquality (f x ::_) bl
|
||||
|
||||
mapId : {a : _} {A : Set a} (l : List A) → map id l ≡ l
|
||||
mapId [] = refl
|
||||
mapId (x :: l) rewrite mapId l = refl
|
||||
|
||||
mapMap : {a b c : _} {A : Set a} {B : Set b} {C : Set c} → (l : List A) → {f : A → B} {g : B → C} → map g (map f l) ≡ map (g ∘ f) l
|
||||
mapMap [] = refl
|
||||
mapMap (x :: l) {f = f} {g} rewrite mapMap l {f} {g} = refl
|
||||
|
||||
mapExtension : {a b : _} {A : Set a} {B : Set b} (l : List A) (f g : A → B) → ({x : A} → (f x ≡ g x)) → map f l ≡ map g l
|
||||
mapExtension [] f g pr = refl
|
||||
mapExtension (x :: l) f g pr rewrite mapExtension l f g pr | pr {x} = refl
|
||||
|
||||
lengthMap : {a b : _} {A : Set a} {B : Set b} → (l : List A) → {f : A → B} → length l ≡ length (map f l)
|
||||
lengthMap [] {f} = refl
|
||||
lengthMap (x :: l) {f} rewrite lengthMap l {f} = refl
|
Reference in New Issue
Block a user