section ‹ Quantum mechanics basics›
theory Quantum
imports
Misc
Hilbert_Space_Tensor_Product.Hilbert_Space_Tensor_Product
"HOL-Library.Z2"
Jordan_Normal_Form.Matrix_Impl
Real_Impl.Real_Impl
"HOL-Library.Code_Target_Numeral"
begin
unbundle cblinfun_syntax
type_synonym ('a,'b) matrix = ‹ ('a ell2, 'b ell2) cblinfun›
subsection ‹ Basic quantum states›
subsubsection ‹ EPR pair›
definition "vector_β00 = vec_of_list [ 1/sqrt 2::complex, 0, 0, 1/sqrt 2 ]"
definition β00 :: ‹ (bit× bit) ell2› where [code del]: "β00 = basis_enum_of_vec vector_β00"
lemma vec_of_basis_enum_β00 [simp]: "vec_of_basis_enum β00 = vector_β00"
by (auto simp add: β00 _def vector_β00 _def )
lemma vec_of_ell2_β00 [simp, code]: "vec_of_ell2 β00 = vector_β00"
by (simp add: vec_of_ell2_def)
lemma norm_β00 [simp]: "norm β00 = 1"
by eval
subsubsection ‹ Ket plus›
definition "vector_ketplus = vec_of_list [ 1/sqrt 2::complex, 1/sqrt 2 ]"
definition ketplus :: ‹ bit ell2› ("|+⟩ " ) where [code del]: ‹ ketplus = basis_enum_of_vec vector_ketplus ›
lemma vec_of_basis_enum_ketplus[simp]: "vec_of_basis_enum ketplus = vector_ketplus"
by (auto simp add: ketplus_def vector_ketplus_def)
lemma vec_of_ell2_ketplus[simp, code]: "vec_of_ell2 ketplus = vector_ketplus"
by (simp add: vec_of_ell2_def)
subsection ‹ Basic quantum gates›
subsubsection ‹ Pauli X›
definition "matrix_pauliX = mat_of_rows_list 2 [ [0::complex, 1], [1, 0] ]"
definition pauliX :: ‹ (bit, bit) matrix› where [code del]: "pauliX = cblinfun_of_mat matrix_pauliX"
lemma mat_of_cblinfun_pauliX[simp, code]: "mat_of_cblinfun pauliX = matrix_pauliX"
by (auto simp add: pauliX_def matrix_pauliX_def cblinfun_of_mat_inverse)
derive (eq) ceq bit
instantiation bit :: ccompare begin
definition "CCOMPARE(bit) = Some (λb1 b2. case (b1, b2) of (0, 0) ==> order.Eq | (0, 1) ==> order.Lt | (1, 0) ==> order.Gt | (1, 1) ==> order.Eq)"
instance
by intro_classes(unfold_locales; auto simp add: ccompare_bit_def split!: bit.splits)
end
derive (dlist) set_impl bit
lemma pauliX_adjoint[simp]: "pauliX* = pauliX"
by eval
lemma pauliXX[simp]: "pauliX oC L pauliX = id_cblinfun"
by eval
subsubsection ‹ Pauli Z›
definition "matrix_pauliZ = mat_of_rows_list 2 [ [1::complex, 0], [0, -1] ]"
definition pauliZ :: ‹ (bit, bit) matrix› where [code del]: "pauliZ = cblinfun_of_mat matrix_pauliZ"
lemma mat_of_cblinfun_pauliZ[simp, code]: "mat_of_cblinfun pauliZ = matrix_pauliZ"
by (auto simp add: pauliZ_def matrix_pauliZ_def cblinfun_of_mat_inverse)
lemma pauliZ_adjoint[simp]: "pauliZ* = pauliZ"
by eval
lemma pauliZZ[simp]: "pauliZ oC L pauliZ = id_cblinfun"
by eval
subsubsection Hadamard
definition "matrix_hadamard = mat_of_rows_list 2 [ [1/sqrt 2::complex, 1/sqrt 2], [1/sqrt 2, -1/sqrt 2] ]"
definition hadamard :: ‹ (bit,bit) matrix› where [code del]: "hadamard = cblinfun_of_mat matrix_hadamard"
lemma mat_of_cblinfun_hadamard[simp, code]: "mat_of_cblinfun hadamard = matrix_hadamard"
by (auto simp add: hadamard_def matrix_hadamard_def cblinfun_of_mat_inverse)
lemma hada_adj[simp]: "hadamard* = hadamard"
by eval
subsubsection CNOT
definition "matrix_CNOT = mat_of_rows_list 4 [ [1::complex,0,0,0], [0,1,0,0], [0,0,0,1], [0,0,1,0] ]"
definition CNOT :: ‹ (bit*bit, bit*bit) matrix› where [code del]: "CNOT = cblinfun_of_mat matrix_CNOT"
lemma mat_of_cblinfun_CNOT[simp, code]: "mat_of_cblinfun CNOT = matrix_CNOT"
by (auto simp add: CNOT_def matrix_CNOT_def cblinfun_of_mat_inverse)
lemma CNOT_adj[simp]: "CNOT* = CNOT"
by eval
lemma cnot_apply[simp]: ‹ CNOT *V ket (i,j) = ket (i,j+i)›
apply (rule spec[where x=i], rule spec[where x=j])
by eval
subsubsection ‹ Qubit swap›
definition "matrix_Uswap = mat_of_rows_list 4 [ [1::complex, 0, 0, 0], [0,0,1,0], [0,1,0,0], [0,0,0,1] ]"
definition Uswap :: ‹ (bit× bit, bit× bit) matrix› where
[code del]: ‹ Uswap = cblinfun_of_mat matrix_Uswap›
lemma mat_of_cblinfun_Uswap[simp, code]: "mat_of_cblinfun Uswap = matrix_Uswap"
by (auto simp add: Uswap_def matrix_Uswap_def cblinfun_of_mat_inverse)
lemma dim_col_Uswap[simp]: "dim_col matrix_Uswap = 4"
unfolding matrix_Uswap_def by simp
lemma dim_row_Uswap[simp]: "dim_row matrix_Uswap = 4"
unfolding matrix_Uswap_def by simp
lemma Uswap_adjoint[simp]: "Uswap* = Uswap"
by eval
lemma Uswap_involution[simp]: "Uswap oC L Uswap = id_cblinfun"
by eval
lemma unitary_Uswap[simp]: "unitary Uswap"
unfolding unitary_def by simp
lemma Uswap_apply[simp]: ‹ Uswap *V s ⊗ s t = t ⊗ s s›
apply (rule clinear_equal_ket[where f=‹ λs. Uswap *V s ⊗ s t› , THEN fun_cong])
apply (auto simp add: cblinfun.add_right tensor_ell2_add1 tensor_ell2_scaleC1
cblinfun.scaleC_right tensor_ell2_add2 tensor_ell2_scaleC2
intro!: clinearI)[2 ]
apply (rule clinear_equal_ket[where f=‹ λt. Uswap *V _ ⊗ s t› , THEN fun_cong])
apply (auto simp add: cblinfun.add_right tensor_ell2_add1 tensor_ell2_scaleC1
cblinfun.scaleC_right tensor_ell2_add2 tensor_ell2_scaleC2
intro!: clinearI)[2 ]
apply (rule basis_enum_eq_vec_of_basis_enumI)
apply (simp add: mat_of_cblinfun_cblinfun_apply vec_of_basis_enum_ket tensor_ell2_ket)
by (case_tac i; case_tac ia; hypsubst_thin; normalization)
unbundle no cblinfun_syntax
end
Messung V0.5 in Prozent C=72 H=95 G=83
¤ Dauer der Verarbeitung: 0.4 Sekunden
¤
*© Formatika GbR, Deutschland
Wurzel
Suchen
NIST Cobol Testsuite
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.