Commit 1213d469 by João Paulo Pizani Flor

### ℂ[_]

parent 8c38f88a
 ... ... @@ -19,15 +19,15 @@ data IsComb : Set where σ ω : IsComb %<*Circuit-predecl> \begin{code} data ℂ (G : Gates) : {s : IsComb} → Ix → Ix → Set data ℂ[_] (G : Gates) : {s : IsComb} → Ix → Ix → Set \end{code} % %<*Circuit-any> \AgdaTarget{C} \AgdaTarget{C[\_]} \begin{code} C : (G : Gates) → Ix → Ix → Set C G i o = ∀ {s} → ℂ G {s} i o C[_] : (G : Gates) → Ix → Ix → Set C[ G ] i o = ∀ {s} → ℂ[ G ] {s} i o \end{code} % ... ... @@ -37,15 +37,36 @@ infixr 5 _∥_ \end{code} %<*Circuit> \AgdaTarget{ℂ, Gate, DelayLoop, Plug, \_⟫\_, \_∥\_} \AgdaTarget{ℂ[\_], Gate, DelayLoop, Plug, \_⟫\_, \_∥\_} \begin{code} data ℂ G where Gate : ∀ g# → C G (|in| G g#) (|out| G g#) Plug : ∀ {i o} → i ⤪ o → C G i o data ℂ[_] G where Gate : ∀ g# → C[ G ] (|in| G g#) (|out| G g#) Plug : ∀ {i o} → i ⤪ o → C[ G ] i o _⟫_ : ∀ {i m o s} → ℂ G {s} i m → ℂ G {s} m o → ℂ G {s} i o _∥_ : ∀ {i₁ o₁ i₂ o₂ s} → ℂ G {s} i₁ o₁ → ℂ G {s} i₂ o₂ → ℂ G {s} (i₁ + i₂) (o₁ + o₂) _⟫_ : ∀ {i m o s} → ℂ[ G ] {s} i m → ℂ[ G ] {s} m o → ℂ[ G ] {s} i o _∥_ : ∀ {i₁ o₁ i₂ o₂ s} → ℂ[ G ] {s} i₁ o₁ → ℂ[ G ] {s} i₂ o₂ → ℂ[ G ] {s} (i₁ + i₂) (o₁ + o₂) DelayLoop : ∀ {i o l} → ℂ G {σ} (i + l) (o + l) → ℂ G {ω} i o DelayLoop : ∀ {i o l} → ℂ[ G ] {σ} (i + l) (o + l) → ℂ[ G ] {ω} i o \end{code} % \begin{code} module WithGates (G : Gates) where \end{code} %<*Circuit-with-gates> \begin{code} ℂ : {s : IsComb} → Ix → Ix → Set ℂ {s} = ℂ[ G ] {s} \end{code} % %<*Circuit-any-with-gates> \AgdaTarget{C} \begin{code} C : Ix → Ix → Set C = C[ G ] \end{code} %
 ... ... @@ -5,7 +5,7 @@ open import Data.Nat.Base using (_+_) open import PiWare.Interface using (Ix) open import PiWare.Plugs.Core using (_⤪_) open import PiWare.Circuit using (ℂ; σ; Gate; Plug; DelayLoop; _⟫_; _∥_) open import PiWare.Circuit using (ℂ[_]; σ; Gate; Plug; DelayLoop; _⟫_; _∥_) open import PiWare.Gates using (Gates) open Gates using (|in|; |out|) \end{code} ... ... @@ -21,7 +21,7 @@ TyGate G F = ∀ g# → F (|in| G g#) (|out| G g#) \begin{code} TyPlug Ty⟫ Ty∥ : (Ix → Ix → Set) → Set TyPlug Ty⟫ Ty∥ : (Ix → Ix → Set) → Set \end{code} %<*combinator-types-parameterized> \AgdaTarget{TyGate, TyPlug, Ty⟫, Ty∥} ... ... @@ -60,7 +60,7 @@ module _ {G : Gates} where %<*Circuit-combinational-cata> \AgdaTarget{cataℂσ} \begin{code} cataℂσ : ∀ {i o} → ℂ G {σ} i o → F i o cataℂσ : ∀ {i o} → ℂ[ G ] {σ} i o → F i o cataℂσ (Gate g) = GateA g cataℂσ (Plug f) = PlugA f cataℂσ (c₁ ⟫ c₂) = cataℂσ c₁ ⟫A cataℂσ c₂ ... ... @@ -92,7 +92,7 @@ module _ {G : Gates} where %<*Circuit-cata> \AgdaTarget{cataℂ} \begin{code} cataℂ : ∀ {i o} → ℂ G i o → F i o cataℂ : ∀ {i o} → ℂ[ G ] i o → F i o cataℂ (Gate g) = GateA g cataℂ (Plug f) = PlugA f cataℂ (DelayLoop c) = DelayLoopA (cataℂσ Fσ aσ c) ... ...
 ... ... @@ -11,7 +11,7 @@ open import Data.Nat.Properties.Simple using (+-right-identity) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; subst₂; cong) open import Data.IVec using (Vec₂; []₂; _∷₂_; replicate₂) open import PiWare.Circuit using (ℂ; σ; _⟫_; _∥_) open import PiWare.Circuit using (ℂ[_]; σ; _⟫_; _∥_) open import PiWare.Circuit.Algebra using (TyGate) open import PiWare.Plugs using (id⤨; nil⤨) open import PiWare.Patterns.Id using (adaptEqI) ... ... @@ -24,7 +24,7 @@ open import PiWare.Semantics.Simulation.Compliance A using (_⫉[_]_) %<*pars> \AgdaTarget{pars} \begin{code} pars : ∀ {n s G} {is os : Vec ℕ n} (cs : Vec₂ (ℂ G {s}) is os) → ℂ G {s} (sum is) (sum os) pars : ∀ {n s G} {is os : Vec ℕ n} (cs : Vec₂ (ℂ[ G ] {s}) is os) → ℂ[ G ] {s} (sum is) (sum os) pars {is = []} {[]} []₂ = nil⤨ pars {is = _ ∷ _} {_ ∷ _} (c ∷₂ cs) = c ∥ pars cs \end{code} ... ... @@ -43,8 +43,8 @@ pars {is = _ ∷ _} {_ ∷ _} (c ∷₂ cs) = c ∥ pars cs %<*parsN> \AgdaTarget{parsN} \begin{code} parsN : ∀ {k i o s G} → ℂ G {s} i o → ℂ G {s} (k * i) (k * o) parsN {k} {i} {o} {_} {G} c = subst₂ (ℂ G) (*-sum-replicate k i) (*-sum-replicate k o) (pars (replicate₂ {n = k} c)) parsN : ∀ {k i o s G} → ℂ[ G ] {s} i o → ℂ[ G ] {s} (k * i) (k * o) parsN {k} {i} {o} {_} {G} c = subst₂ ℂ[ G ] (*-sum-replicate k i) (*-sum-replicate k o) (pars (replicate₂ {n = k} c)) \end{code} % ... ... @@ -53,8 +53,8 @@ parsN {k} {i} {o} {_} {G} c = subst₂ (ℂ G) (*-sum-replicate k i) (*-sum-repl %<*seqs> \AgdaTarget{seqs} \begin{code} seqs : ∀ {n io s G} → Vec (ℂ G {s} io io) n → ℂ G {s} io io seqs {_} {io} {s} {G} = foldr (const (ℂ G {s} io io)) _⟫_ id⤨ seqs : ∀ {n io s G} → Vec (ℂ[ G ] {s} io io) n → ℂ[ G ] {s} io io seqs {_} {io} {s} {G} = foldr (const (ℂ[ G ] {s} io io)) _⟫_ id⤨ \end{code} % ... ... @@ -62,7 +62,7 @@ seqs {_} {io} {s} {G} = foldr (const (ℂ G {s} io io)) _⟫_ id⤨ %<*seqsN> \AgdaTarget{seqsN} \begin{code} seqsN : ∀ k {s io G} → ℂ G {s} io io → ℂ G {s} io io seqsN : ∀ k {s io G} → ℂ[ G ] {s} io io → ℂ[ G ] {s} io io seqsN k = seqs ∘′ replicate {n = k} \end{code} % ... ... @@ -71,7 +71,7 @@ seqsN k = seqs ∘′ replicate {n = k} %<*row> \AgdaTarget{row} \begin{code} row : ∀ {k a b c s G} → ℂ G {s} (a + b) (c + a) → ℂ G {s} (a + (k * b)) ((k * c) + a) row : ∀ {k a b c s G} → ℂ[ G ] {s} (a + b) (c + a) → ℂ[ G ] {s} (a + (k * b)) ((k * c) + a) row {zero} {a} {b} {c} _ = adaptEqI (sym (+-right-identity a)) id⤨ row {suc k} {a} {b} {c} f = ⊥ where postulate ⊥ : _ \end{code} ... ... @@ -80,7 +80,7 @@ row {suc k} {a} {b} {c} f = ⊥ where postulate ⊥ : _ %<*foldr-Circ> \begin{code} linear-reductor : ∀ n {k G} → ℂ G {σ} (k + k) k → ℂ G {σ} zero k → ℂ G {σ} (n * k) k linear-reductor : ∀ n {k G} → ℂ[ G ] {σ} (k + k) k → ℂ[ G ] {σ} zero k → ℂ[ G ] {σ} (n * k) k linear-reductor zero {_} _ e = e linear-reductor (suc n) {k} c e = id⤨ {k} ∥ (linear-reductor n) c e ⟫ c \end{code} ... ... @@ -88,7 +88,7 @@ linear-reductor (suc n) {k} c e = id⤨ {k} ∥ (linear-reductor n) c e ⟫ c \begin{code} postulate linear-reductor-spec : ∀ {n k G} {g : TyGate G W⟶W} (c : ℂ G {σ} (k + k) k) (e : ℂ G {σ} zero k) linear-reductor-spec : ∀ {n k G} {g : TyGate G W⟶W} (c : ℂ[ G ] {σ} (k + k) k) (e : ℂ[ G ] {σ} zero k) → linear-reductor n c e ⫉[ g ] foldr (const (W k)) (λ x y → ⟦ c ⟧[ g ] (x ++ y)) (⟦ e ⟧[ g ] []) ∘ (proj₁ ∘ group n k) \end{code}
 ... ... @@ -25,8 +25,9 @@ open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; open ≡-Reasoning using (begin_; _≡⟨_⟩_; _≡⟨⟩_; _∎) open import Data.CausalStream using (runᶜ′) open import PiWare.Gates.BoolTrio using () renaming (BoolTrio to B₃) open import PiWare.Circuit using (ℂ; C; Plug; DelayLoop; _⟫_; ω) open import PiWare.Circuit using (Plug; DelayLoop; _⟫_; ω) renaming (module WithGates to CircuitWithGates) open import PiWare.Gates.BoolTrio using (BoolTrio) open CircuitWithGates BoolTrio using (ℂ; C) open import PiWare.Atomic.Bool using (Atomic-Bool) open import PiWare.Patterns Atomic-Bool using (parsN) open import PiWare.Plugs using (eq⤨) ... ... @@ -49,7 +50,7 @@ open _⇕_ (⇕× ⦃ ⇕Bool ⦄ ⦃ ⇕Bool ⦄) using () renaming (⇓ to ⇓ %<*regn-distribute> \AgdaTarget{regn-distribute} \begin{code} regn-distribute : ∀ n → C B₃ (suc n) (n +⋎ n) regn-distribute : ∀ n → C (suc n) (n +⋎ n) regn-distribute n = Plug $tabulate (raise 1) ⋎ replicate {n = n} Fz \end{code} % ... ... @@ -79,7 +80,7 @@ regn-distribute n = Plug$ tabulate (raise 1) ⋎ replicate {n = n} Fz %<*regn-n+⋎n≡n*2> \AgdaTarget{regn-n+⋎n≡n*2} \begin{code} regn-n+⋎n≡n*2 : ∀ n → C B₃ (n +⋎ n) (n * 2)