diff options
author | Helmut Grohne <grohne@cs.uni-bonn.de> | 2014-01-30 14:01:10 +0100 |
---|---|---|
committer | Helmut Grohne <grohne@cs.uni-bonn.de> | 2014-01-30 14:01:10 +0100 |
commit | 934f2003d4f47c2af3a91cd827d75caeded7ec7a (patch) | |
tree | 903a3a699f6f64da08a60a1f54dc345057214779 /BFF.agda | |
parent | 1c3da162d500cfe885fa21b4d75847c4bcbb2aa1 (diff) | |
download | bidiragda-934f2003d4f47c2af3a91cd827d75caeded7ec7a.tar.gz |
express VecBFF via PartialVecBFF
Diffstat (limited to 'BFF.agda')
-rw-r--r-- | BFF.agda | 28 |
1 files changed, 11 insertions, 17 deletions
@@ -12,18 +12,18 @@ 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 Function.Equality using (_⟶_ ; _⟨$⟩_) -open import Function.Injection using (module Injection) renaming (Injection to _↪_) +open import Function.Injection using (module Injection) renaming (Injection to _↪_ ; id to id↪) open import Relation.Binary using (Setoid ; DecSetoid ; module DecSetoid) -open import Relation.Binary.PropositionalEquality using () renaming (setoid to EqSetoid) +open import Relation.Binary.PropositionalEquality using (cong) renaming (setoid to EqSetoid) open Injection using (to) open import FinMap -open import Generic using (mapMV) +open import Generic using (mapMV ; ≡-to-Π) import CheckInsert import FreeTheorems -module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where - open FreeTheorems.VecVec public using (get-type) +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 @@ -37,7 +37,7 @@ module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where denumerate : {n : ℕ} → Vec Carrier n → Fin n → Carrier denumerate = flip lookupV - bff : {getlen : ℕ → ℕ} → (get-type getlen) → ({n : ℕ} → Vec Carrier n → Vec Carrier (getlen n) → Maybe (Vec Carrier n)) + 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) @@ -46,18 +46,12 @@ module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where h′ = (flip union g′) <$> h in h′ >>= flip mapMV s′ ∘ flip lookupV -module PartialVecBFF (A : DecSetoid ℓ₀ ℓ₀) where - open FreeTheorems.PartialVecVec public using (get-type) +module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where + open FreeTheorems.VecVec 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) + open PartialVecBFF 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 + bff : {getlen : ℕ → ℕ} → (get-type getlen) → ({n : ℕ} → Vec Carrier n → Vec Carrier (getlen n) → Maybe (Vec Carrier n)) + bff {getlen} get s v = PartialVecBFF.bff A {_} {id↪} {≡-to-Π getlen} get {_} s v |