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 /BFF.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 'BFF.agda')
-rw-r--r-- | BFF.agda | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -11,7 +11,11 @@ open Category.Functor.RawFunctor {Level.zero} Data.Maybe.functor using (_<$>_) open import Data.List using (List ; [] ; _∷_ ; map ; length) open import Data.Vec using (Vec ; toList ; fromList ; tabulate ; allFin) renaming (lookup to lookupV ; map to mapV ; [] to []V ; _∷_ to _∷V_) open import Function using (id ; _∘_ ; flip) -open import Relation.Binary using (DecSetoid ; module DecSetoid) +open import Function.Equality using (_⟶_ ; _⟨$⟩_) +open import Function.Injection using (module Injection) renaming (Injection to _↪_) +open import Relation.Binary using (Setoid ; DecSetoid ; module DecSetoid) +open import Relation.Binary.PropositionalEquality using () renaming (setoid to EqSetoid) +open Injection using (to) open import FinMap open import Generic using (mapMV) @@ -41,3 +45,19 @@ module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where h = assoc t′ v h′ = (flip union g′) <$> h in h′ >>= flip mapMV s′ ∘ flip lookupV + +module PartialVecBFF (A : DecSetoid ℓ₀ ℓ₀) where + open FreeTheorems.PartialVecVec public using (get-type) + open module A = DecSetoid A using (Carrier) renaming (_≟_ to deq) + open CheckInsert A + + open VecBFF A public using (assoc ; enumerate ; denumerate) + + bff : {I : Setoid ℓ₀ ℓ₀} {gl₁ : I ↪ (EqSetoid ℕ)} {gl₂ : I ⟶ EqSetoid ℕ} → get-type gl₁ gl₂ → ({i : Setoid.Carrier I} → Vec Carrier (to gl₁ ⟨$⟩ i) → Vec Carrier (gl₂ ⟨$⟩ i) → Maybe (Vec Carrier (to gl₁ ⟨$⟩ i))) + bff get s v = let s′ = enumerate s + t′ = get s′ + g = fromFunc (denumerate s) + g′ = delete-many t′ g + h = assoc t′ v + h′ = (flip union g′) <$> h + in h′ >>= flip mapMV s′ ∘ flip lookupV |