There seems to be continued problems with the application of rewrite rules, though it is less clear exactly what rules are causing problems as I can't replicate the issue in the editor - they emerge from hsimplify. Specifically I find if I apply zx.hsimplify.hpivot_simp(circle, quiet=True) to the graph derived from the json below I arrive at a very different matrix, which shouldn't be possible. I am also of the opinion that something is off with the scalars but I can't quite tell if this is related to the errors in the transformations.
![image](https://user-images.githubusercontent.com/13621329/89124506-c9fbc900-d4d7-11ea-9a47-41290e46a889.png)
circle_json = '{"wire_vertices": {"b0": {"annotation": {"boundary": true, "coord": [10.37171875, -1.8646875], "input": false, "output": true}}, "b1": {"annotation": {"boundary": true, "coord": [11.04171875, -4.8796875], "input": false, "output": true}}, "b2": {"annotation": {"boundary": true, "coord": [-0.23828125, -1.2296874999999998], "input": true, "output": false}}, "b3": {"annotation": {"boundary": true, "coord": [-0.23828125, -4.7796875], "input": true, "output": false}}}, "node_vertices": {"v0": {"annotation": {"coord": [1.45171875, -0.12468749999999984]}, "data": {"type": "X"}}, "v1": {"annotation": {"coord": [1.51171875, -1.7046875]}, "data": {"type": "Z"}}, "v2": {"annotation": {"coord": [1.53671875, -4.6546875]}, "data": {"type": "Z"}}, "v3": {"annotation": {"coord": [1.6867187499999998, -3.0046875]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v4": {"annotation": {"coord": [3.0267187499999997, -0.024687500000000195]}, "data": {"type": "X"}}, "v5": {"annotation": {"coord": [2.50171875, -0.7246874999999999]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v6": {"annotation": {"coord": [2.42671875, -4.8496875]}, "data": {"type": "Z"}}, "v7": {"annotation": {"coord": [3.80171875, -4.7496875]}, "data": {"type": "Z"}}, "v8": {"annotation": {"coord": [2.17671875, -1.9996874999999998]}, "data": {"type": "Z"}}, "v9": {"annotation": {"coord": [3.22671875, -2.0246874999999998]}, "data": {"type": "Z"}}, "v10": {"annotation": {"coord": [2.7017187500000004, -2.049687499999999]}, "data": {"type": "X"}}, "v11": {"annotation": {"coord": [3.00171875, -4.8246875]}, "data": {"type": "X"}}, "v12": {"annotation": {"coord": [3.85171875, -0.09968749999999993]}, "data": {"type": "Z"}}, "v13": {"annotation": {"coord": [5.50171875, -0.024687500000000195]}, "data": {"type": "Z"}}, "v14": {"annotation": {"coord": [5.461718750000001, -1.9496875]}, "data": {"type": "Z"}}, "v15": {"annotation": {"coord": [4.83671875, -4.8746875]}, "data": {"type": "Z"}}, "v16": {"annotation": {"coord": [6.421718749999999, -1.9346875]}, "data": {"type": "Z"}}, "v17": {"annotation": {"coord": [6.356718749999999, -5.0996875]}, "data": {"type": "Z"}}, "v18": {"annotation": {"coord": [4.51171875, -2.049687499999999]}, "data": {"type": "X", "value": "\\pi"}}, "v19": {"annotation": {"coord": [5.956718750000001, -2.0096875]}, "data": {"type": "X", "value": "\\pi"}}, "v20": {"annotation": {"coord": [4.34671875, -5.0046875]}, "data": {"type": "X", "value": "\\pi"}}, "v21": {"annotation": {"coord": [5.611718749999999, -4.9496875]}, "data": {"type": "X", "value": "\\pi"}}, "v22": {"annotation": {"coord": [5.73171875, -3.6996874999999996]}, "data": {"type": "Z"}}, "v23": {"annotation": {"coord": [6.956718750000001, -3.4346875]}, "data": {"type": "Z"}}, "v24": {"annotation": {"coord": [5.26171875, -3.2996875]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v25": {"annotation": {"coord": [6.28171875, -3.3346875000000002]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v26": {"annotation": {"coord": [0.88671875, -1.3546874999999998]}, "data": {"type": "X", "value": "\\pi"}}, "v27": {"annotation": {"coord": [0.81171875, -4.7546875]}, "data": {"type": "X", "value": "\\pi"}}, "v28": {"annotation": {"coord": [2.87671875, -1.0496875]}, "data": {"type": "hadamard", "is_edge": "false", "value": "3\\pi/2"}}, "v29": {"annotation": {"coord": [3.4017187499999997, -0.9646875000000001]}, "data": {"type": "hadamard", "is_edge": "false", "value": "3\\pi/2"}}, "v30": {"annotation": {"coord": [3.87671875, -0.9996874999999998]}, "data": {"type": "hadamard", "is_edge": "false", "value": "3\\pi/2"}}, "v31": {"annotation": {"coord": [2.5767187500000004, -3.9496874999999996]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi/2"}}, "v32": {"annotation": {"coord": [3.1517187499999997, -3.6746875]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi/2"}}, "v33": {"annotation": {"coord": [3.87671875, -3.7496875000000003]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi/2"}}, "v34": {"annotation": {"coord": [3.05171875, -1.5496875]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v35": {"annotation": {"coord": [3.12671875, -4.2496875]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v36": {"annotation": {"coord": [2.03671875, -4.7046875]}, "data": {"type": "X", "value": "\\pi"}}, "v37": {"annotation": {"coord": [2.08671875, -1.6546875]}, "data": {"type": "X", "value": "\\pi"}}, "v38": {"annotation": {"coord": [6.989375, -1.754375]}, "data": {"type": "X", "value": "\\pi"}}, "v39": {"annotation": {"coord": [8.269375, -1.5743749999999999]}, "data": {"type": "X", "value": "\\pi"}}, "v40": {"annotation": {"coord": [7.789375, -5.374375]}, "data": {"type": "X", "value": "\\pi"}}, "v41": {"annotation": {"coord": [8.969375, -5.354375]}, "data": {"type": "X", "value": "\\pi"}}, "v42": {"annotation": {"coord": [9.689375, -5.194375]}, "data": {"type": "X"}}, "v43": {"annotation": {"coord": [7.089375, -5.234375]}, "data": {"type": "Z"}}, "v44": {"annotation": {"coord": [8.309375, -5.394375]}, "data": {"type": "Z"}}, "v45": {"annotation": {"coord": [8.969375, -1.854375]}, "data": {"type": "Z"}}, "v46": {"annotation": {"coord": [7.649374999999999, -1.5543749999999998]}, "data": {"type": "Z"}}, "v47": {"annotation": {"coord": [9.029375, 0.18562499999999993]}, "data": {"type": "Z"}}, "v48": {"annotation": {"coord": [8.449375, 0.34562500000000007]}, "data": {"type": "X"}}, "v49": {"annotation": {"coord": [7.349375, 0.6456249999999999]}, "data": {"type": "X"}}, "v50": {"annotation": {"coord": [6.669375, 0.6256250000000001]}, "data": {"type": "X"}}, "v51": {"annotation": {"coord": [5.909375, 0.8656250000000001]}, "data": {"type": "X"}}, "v52": {"annotation": {"coord": [4.549375, 0.22562499999999996]}, "data": {"type": "Z"}}, "v53": {"annotation": {"coord": [7.809374999999999, -3.6743750000000004]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v54": {"annotation": {"coord": [8.569375, -3.5943750000000003]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v55": {"annotation": {"coord": [7.149374999999999, -0.6543749999999999]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}, "v56": {"annotation": {"coord": [7.909375000000001, -0.5543749999999998]}, "data": {"type": "hadamard", "is_edge": "false", "value": "\\pi"}}}, "undir_edges": {"e0": {"src": "v0", "tgt": "v4"}, "e1": {"src": "v1", "tgt": "v3"}, "e2": {"src": "v1", "tgt": "v26"}, "e3": {"src": "v1", "tgt": "v37"}, "e4": {"src": "v2", "tgt": "v3"}, "e5": {"src": "v2", "tgt": "v27"}, "e6": {"src": "v2", "tgt": "v36"}, "e7": {"src": "v3", "tgt": "v5"}, "e8": {"src": "v4", "tgt": "v5"}, "e9": {"src": "v4", "tgt": "v12"}, "e10": {"src": "v6", "tgt": "v11"}, "e11": {"src": "v6", "tgt": "v31"}, "e12": {"src": "v6", "tgt": "v36"}, "e13": {"src": "v7", "tgt": "v11"}, "e14": {"src": "v7", "tgt": "v20"}, "e15": {"src": "v7", "tgt": "v33"}, "e16": {"src": "v8", "tgt": "v10"}, "e17": {"src": "v8", "tgt": "v28"}, "e18": {"src": "v8", "tgt": "v37"}, "e19": {"src": "v9", "tgt": "v10"}, "e20": {"src": "v9", "tgt": "v30"}, "e21": {"src": "v9", "tgt": "v18"}, "e22": {"src": "v10", "tgt": "v34"}, "e23": {"src": "v11", "tgt": "v35"}, "e24": {"src": "v12", "tgt": "v28"}, "e25": {"src": "v12", "tgt": "v29"}, "e26": {"src": "v12", "tgt": "v30"}, "e27": {"src": "v12", "tgt": "v52"}, "e28": {"src": "v13", "tgt": "v24"}, "e29": {"src": "v13", "tgt": "v25"}, "e30": {"src": "v13", "tgt": "v31"}, "e31": {"src": "v13", "tgt": "v32"}, "e32": {"src": "v13", "tgt": "v33"}, "e33": {"src": "v13", "tgt": "v52"}, "e34": {"src": "v14", "tgt": "v24"}, "e35": {"src": "v14", "tgt": "v18"}, "e36": {"src": "v14", "tgt": "v19"}, "e37": {"src": "v15", "tgt": "v24"}, "e38": {"src": "v15", "tgt": "v20"}, "e39": {"src": "v15", "tgt": "v21"}, "e40": {"src": "v16", "tgt": "v25"}, "e41": {"src": "v16", "tgt": "v19"}, "e42": {"src": "v16", "tgt": "v38"}, "e43": {"src": "v17", "tgt": "v25"}, "e44": {"src": "v17", "tgt": "v21"}, "e45": {"src": "v17", "tgt": "v43"}, "e46": {"src": "v22", "tgt": "v24"}, "e47": {"src": "v23", "tgt": "v25"}, "e48": {"src": "v26", "tgt": "b2"}, "e49": {"src": "v27", "tgt": "b3"}, "e50": {"src": "v29", "tgt": "v34"}, "e51": {"src": "v32", "tgt": "v35"}, "e52": {"src": "v38", "tgt": "v46"}, "e53": {"src": "v39", "tgt": "v46"}, "e54": {"src": "v39", "tgt": "v45"}, "e55": {"src": "v40", "tgt": "v44"}, "e56": {"src": "v40", "tgt": "v43"}, "e57": {"src": "v41", "tgt": "v42"}, "e58": {"src": "v41", "tgt": "v44"}, "e59": {"src": "v42", "tgt": "b1"}, "e60": {"src": "v42", "tgt": "v47"}, "e61": {"src": "v43", "tgt": "v53"}, "e62": {"src": "v44", "tgt": "v54"}, "e63": {"src": "v45", "tgt": "b0"}, "e64": {"src": "v45", "tgt": "v54"}, "e65": {"src": "v46", "tgt": "v53"}, "e66": {"src": "v47", "tgt": "v48"}, "e67": {"src": "v48", "tgt": "v49"}, "e68": {"src": "v48", "tgt": "v56"}, "e69": {"src": "v49", "tgt": "v50"}, "e70": {"src": "v49", "tgt": "v55"}, "e71": {"src": "v50", "tgt": "v52"}, "e72": {"src": "v50", "tgt": "v51"}, "e73": {"src": "v53", "tgt": "v55"}, "e74": {"src": "v54", "tgt": "v56"}}}'