compiling-to-categories / concat

Compiling to Categories
http://conal.net/papers/compiling-to-categories
BSD 3-Clause "New" or "Revised" License
431 stars 49 forks source link

Constructing a graph of RLC circuit elements and transforming to an affine relation between inputs and outputs. #57

Open faezs opened 4 years ago

faezs commented 4 years ago

Hi Conal,

This is more of a general design guideline question than an issue, but I don't know of a more appropriate forum so I'm asking here.

I've been trying to implement the formalism of cospan composition following along with https://arxiv.org/abs/1707.08321 to construct a "blackbox functor" semantics that maps a labelled graph of circuit elements (passive linear + current and voltage sources) to the affine map between inputs and outputs attached to the terminals.

Probably due to my inadequacy in both haskell and CT, I've taken several routes such as trying to construct the hypergraph category LCirc (symmetric monoidal with a frobenius algebra) myself but going by the SMT example I'm now thinking it might be more appropriate to use the primitives you export in the Circuit module to do the construction.

What I would appreciate your guidance on is the process of giving the mapping from this circuit representation to an affine map the semantics dictated by Kirchoff's laws - if I were to naively just construct a Sum type for the set of circuit elements and declare a GenBuses instance for them and write an evaluator that has similar constraints on the domain as the ones you choose in the SMT module, how would I go from (RLC :> RLC) -> Affine R RLC RLC?

And thank you so much for your work, it has been mind-bending and invigorating in the best ways!