aboutsummaryrefslogtreecommitdiff
path: root/Data/Circuit.agda
blob: 77d6b7246cc3a23cb28b87b7e2ab32f428bcfd60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{-# OPTIONS --without-K --safe #-}

open import Level using (Level)

module Data.Circuit { : Level} where

open import Data.Circuit.Gate using (Gates)

import Data.List as List
import Data.Hypergraph {} Gates as Hypergraph

open import Data.Fin using (Fin)
open import Data.Nat using ()
open import Data.List.Relation.Binary.Permutation.Setoid.Properties using (map⁺)
open import Function using (Func; _⟶ₛ_; _∘_)
open import Relation.Binary using (Setoid)

open Func

open Hypergraph using (Multiset∘Edgeₛ)
open Hypergraph
  using (_≈_ ; mk≈ ; module Edge)
  renaming
    ( Hypergraph to Circuit
    ; Hypergraphₛ to Circuitₛ
    ; mkHypergraph to mkCircuit
    ; mkHypergraphₛ to mkCircuitₛ
    )
  public
open List using ([])

map : {n m : }  (Fin n  Fin m)  Circuit n  Circuit m
map f (mkCircuit edges) = mkCircuit (List.map (Edge.map f) edges)

discrete : (n : )  Circuit n
discrete n = mkCircuit []

open Edge using (Edgeₛ)

mapₛ : {n m : }  (Fin n  Fin m)  Circuitₛ n ⟶ₛ Circuitₛ m
mapₛ f .to = map f
mapₛ {n} {m} f .cong (mk≈ x≈y) = mk≈ (map⁺ (Edgeₛ n) (Edgeₛ m) (cong (Edge.mapₛ f)) x≈y)