diff options
author | Helmut Grohne <grohne@cs.uni-bonn.de> | 2014-01-28 15:15:12 +0100 |
---|---|---|
committer | Helmut Grohne <grohne@cs.uni-bonn.de> | 2014-01-28 15:15:12 +0100 |
commit | 1c3da162d500cfe885fa21b4d75847c4bcbb2aa1 (patch) | |
tree | 75af4c2ff1fc049ea0a0b02b2104c16a93ab3d6a /FreeTheorems.agda | |
parent | b0eb7ada208d33eb82ec27cb7d40b9fa59646c92 (diff) | |
download | bidiragda-1c3da162d500cfe885fa21b4d75847c4bcbb2aa1.tar.gz |
define bff on a partial getlen
The representation chosen is to give both an injection gl₁ and a
function gl₂ (formerly getlen), such that by choosing a non-identity for
gl₁ partiality of getlen can be expressed. An alternative would have
been to allow getlen to return a Maybe ℕ and have get return
maybe (Vec A) ⊤ (getlen n)
thus sending all inputs for which getlen yields nothing to tt. It seems
that while there is no way to obtain a such a getlen predicate from an
arbitrary index Setoid I, it should be possible to manufacture a Setoid
from a predicate. Thanks to Stefan Mehner for the insightful discussion.
Diffstat (limited to 'FreeTheorems.agda')
-rw-r--r-- | FreeTheorems.agda | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/FreeTheorems.agda b/FreeTheorems.agda index f37cada..aacb95a 100644 --- a/FreeTheorems.agda +++ b/FreeTheorems.agda @@ -1,10 +1,15 @@ module FreeTheorems where +open import Level using () renaming (zero to ℓ₀) open import Data.Nat using (ℕ) open import Data.List using (List ; map) open import Data.Vec using (Vec) renaming (map to mapV) open import Function using (_∘_) -open import Relation.Binary.PropositionalEquality using (_≗_) +open import Function.Equality using (_⟶_ ; _⟨$⟩_) +open import Function.Injection using (module Injection) renaming (Injection to _↪_) +open import Relation.Binary.PropositionalEquality using (_≗_ ; cong) renaming (setoid to EqSetoid) +open import Relation.Binary using (Setoid) +open Injection using (to) module ListList where get-type : Set₁ @@ -17,5 +22,23 @@ module VecVec where get-type : (ℕ → ℕ) → Set₁ get-type getlen = {A : Set} {n : ℕ} → Vec A n → Vec A (getlen n) + free-theorem-type : Set₁ + free-theorem-type = {getlen : ℕ → ℕ} → (get : get-type getlen) → {α β : Set} → (f : α → β) → {n : ℕ} → get {_} {n} ∘ mapV f ≗ mapV f ∘ get + + postulate + free-theorem : free-theorem-type + +module PartialVecVec where + get-type : {I : Setoid ℓ₀ ℓ₀} → (I ↪ (EqSetoid ℕ)) → (I ⟶ (EqSetoid ℕ)) → Set₁ + get-type {I} gl₁ gl₂ = {A : Set} {i : Setoid.Carrier I} → Vec A (to gl₁ ⟨$⟩ i) → Vec A (gl₂ ⟨$⟩ i) + postulate - free-theorem : {getlen : ℕ → ℕ} → (get : get-type getlen) → {α β : Set} → (f : α → β) → {n : ℕ} → get {_} {n} ∘ mapV f ≗ mapV f ∘ get + free-theorem : {I : Setoid ℓ₀ ℓ₀} → (gl₁ : I ↪ (EqSetoid ℕ)) → (gl₂ : I ⟶ (EqSetoid ℕ)) (get : get-type gl₁ gl₂) → {α β : Set} → (f : α → β) → {i : Setoid.Carrier I} → get {_} {i} ∘ mapV f ≗ mapV f ∘ get + + open VecVec using () renaming (free-theorem-type to VecVec-free-theorem-type) + + ≡-to-Π : {A B : Set} → (A → B) → EqSetoid A ⟶ EqSetoid B + ≡-to-Π f = record { _⟨$⟩_ = f; cong = cong f } + + VecVec-free-theorem : VecVec-free-theorem-type + VecVec-free-theorem {getlen} get = free-theorem Function.Injection.id (≡-to-Π getlen) get |