# A Qubit DSL?

**URL:** https://discourse.julialang.org/t/a-qubit-dsl/8599
**Category:** Quantum
**Created:** [January 25, 2018, 6:37pm UTC](https://discourse.julialang.org/t/a-qubit-dsl/8599 "2018-01-25T18:37:05Z")
**Posts on this page:** 1
**Showing post:** 26

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [February 16, 2018, 6:26pm UTC](https://discourse.julialang.org/t/a-qubit-dsl/8599/26 "2018-02-16T18:26:35Z")

</div>

I do agree that it would be really nice to have `|ψ⟩` et cetera lower to something, but I am certainly quite biased on that matter as my background is primarily in quantum field theory. I do think that having `⟨args...⟩` lower to, for example `vev(args...)` would also be useful in contexts other than quantum mechanics.

I do think that if this gets done the lowering rules should be pretty general. Bear in mind that in the general case the Hilbert space is not required to be finite dimensional or even separable, so I don’t think we should assume that kets can be represented as a Julia `AbstractVector` (which always have a finite, integer length).

My suggestion would be

- `|args...⟩` lower to `ket(args...)`
- `⟨args...|` lowers to `bra(args...)`
- `⟨bra_args...|ket_args...⟩` lowers to `braket(tuple(bra_args...), tuple(ket_args...))`
- `⟨bra_args...|O|ket_args...⟩` lowers to `braket(tuple(bra_args...), O, tuple(ket_args...))`
- `⟨args...⟩` lowers to `vev(args...)`

and that, with the possible exception of `vev`, that none of these functions be defined in `Base`. That would allow package developers to assign them as needed and not have any constraints on what the underlying data structures are called. One objection I anticipate is that this might be considered encouraging type piracy, and I’m not sure I have a good defense for that.

---

_[View the full topic](https://discourse.julialang.org/t/a-qubit-dsl/8599)._
