Skip to content

Commit

Permalink
Fix Qsimpl hanging on goals with adjoint _ (#44)
Browse files Browse the repository at this point in the history
* Fix Q_db autorewrite hanging on trying to rewrite with statements of hermitian

* Bump opam and dune version numbers to 1.5.1
  • Loading branch information
wjbs authored Jul 29, 2024
1 parent ee147b9 commit ec1987d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
34 changes: 29 additions & 5 deletions Quantum.v
Original file line number Diff line number Diff line change
Expand Up @@ -1375,12 +1375,37 @@ Qed.
Lemma braket0_hermitian : hermitian ∣0⟩⟨0∣. Proof. lma. Qed.
Lemma braket1_hermitian : hermitian ∣1⟩⟨1∣. Proof. lma. Qed.


#[global] Hint Rewrite hadamard_hermitian σx_hermitian σy_hermitian σz_hermitian cnot_hermitian swap_hermitian braket1_hermitian braket0_hermitian control_adjoint phase_adjoint rotation_adjoint : Q_db.


(* Rewrite hangs on trying to rewrite hermitian, so we need to manually
expose the underlying equality. This was the cause of a bad bug
causing Qsimpl to hang. *)
(* #[global] Hint Rewrite hadamard_hermitian σx_hermitian σy_hermitian σz_hermitian cnot_hermitian swap_hermitian braket1_hermitian braket0_hermitian control_adjoint phase_adjoint rotation_adjoint : Q_db. *)

Local Ltac make_herm H :=
let T := type of H in
let T' := eval unfold hermitian in T in
exact (H : T').

Definition hadamard_hermitian_rw := ltac:(make_herm hadamard_hermitian).
Definition σx_hermitian_rw := ltac:(make_herm σx_hermitian).
Definition σy_hermitian_rw := ltac:(make_herm σy_hermitian).
Definition σz_hermitian_rw := ltac:(make_herm σz_hermitian).
Definition cnot_hermitian_rw := ltac:(make_herm cnot_hermitian).
Definition swap_hermitian_rw := ltac:(make_herm swap_hermitian).
Definition braket1_hermitian_rw := ltac:(make_herm braket1_hermitian).
Definition braket0_hermitian_rw := ltac:(make_herm braket0_hermitian).
Definition control_adjoint_rw := ltac:(make_herm control_adjoint).
Definition phase_adjoint_rw := ltac:(make_herm phase_adjoint).
Definition rotation_adjoint_rw := ltac:(make_herm rotation_adjoint).


#[global] Hint Rewrite hadamard_hermitian_rw
σx_hermitian_rw σy_hermitian_rw σz_hermitian_rw cnot_hermitian_rw
swap_hermitian_rw braket1_hermitian_rw braket0_hermitian_rw
control_adjoint_rw phase_adjoint_rw rotation_adjoint_rw : Q_db.

(* THESE ARE TO BE PHASED OUT *)
(* TODO: Is this true now that rewriting with
hermitian is known to be impossible? *)



Expand Down Expand Up @@ -1475,7 +1500,6 @@ Lemma braqubit1_sa : ∣1⟩⟨1∣† = ∣1⟩⟨1∣. Proof. lma. Qed.
*)

#[global] Hint Rewrite hadamard_sa σx_sa σy_sa σz_sa cnot_sa swap_sa braqubit1_sa braqubit0_sa control_adjoint phase_adjoint rotation_adjoint : Q_db.

(* Rather use control_adjoint :
#[global] Hint Rewrite control_sa using (autorewrite with M_db; reflexivity) : M_db. *)
Expand Down
2 changes: 1 addition & 1 deletion coq-quantumlib.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "1.5.0"
version: "1.5.1"
synopsis: "Coq library for reasoning about quantum programs"
description: """
inQWIRE's QuantumLib is a Coq library for reasoning
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(lang dune 2.8)
(name coq-quantumlib)
(version 1.5.0)
(version 1.5.1)
(using coq 0.2)

(generate_opam_files true)
Expand Down

0 comments on commit ec1987d

Please sign in to comment.