cl-quantum/examples/bell.lisp
2024-12-19 12:25:23 -08:00

31 lines
776 B
Common Lisp

;;;; Example Bell state creation circuits
(in-package :cl-quantum/examples)
(defun make-bell-phi+-circuit (bits)
"Return a circuit that makes a Bell phi+ state. That is |00>+|11>."
(with-build-circuit bits
(:h 0)
(:cnot 1 0)))
(defun make-bell-phi--circuit (bits)
"Return a circuit that makes a Bell phi- state. That is |00>-|11>."
(with-build-circuit bits
(:h 0)
(:cnot 1 0)
(:z 1)))
(defun make-bell-psi+-circuit (bits)
"Return a circuit that makes a Bell psi+ state. That is |01>+|10>."
(with-build-circuit bits
(:x 1)
(:h 0)
(:cnot 1 0)))
(defun make-bell-psi--circuit (bits)
"Return a circuit that makes a Bell psi- state. That is |01>-|10>."
(with-build-circuit bits
(:x 1)
(:h 0)
(:cnot 1 0)
(:z 1)))