Open samuelgruetter opened 3 years ago
I've been leaving the states unreduced e.g.
Definition Delay'{x : type}(init: denote_type x): Circuit _ [x] x :=
I don't see this as an issue, but perhaps you have something in mind?
A heavy handed alternative could be to have a syntax Expr
without the state typing, and then a realise_state: UExpr i o -> Expr state i o
function to generate it.
Another alternative could be to bifurcate the state and variable types, so that state-unit absorbs and the variable-unit doesn't. Since the state of an expression is created from these known state-units, and a variable-unit wouldnt reduce (like the other non-unit types), the state type wouldn't need rewriting to reduce in the case of unknown variable types.
I attempted to resolve this in some experiments here in case it's helpful; I used typeclasses to automatically find state-type-conversion functions (as opposed to proofs, to avoid issues with opaque terms in computation).
While trying to write some circuit combinator over abstract input/output/state types, I noted that we sometimes need to insert casts. For instance:
If I omit the line
cast_circuit_state absorb_Unit_r
, I get a typechecking error saying that the term has typeCircuit (x ++ [] ++ []) [x] x
while it is expected to have typeCircuit x [x] x
(cannot unifyx ++ [] ++ []
andx
).Is there a better way to deal with such errors?