Qx.Export.OpenQASM.Lowering (Qx - Quantum Computing Simulator v0.6.0)

View Source

Converts a parsed OpenQASM AST (see Qx.Export.OpenQASM.AST) into a %Qx.QuantumCircuit{}.

This stage performs:

  • Register tracking — accepts a single qubit/bit register; rejects multi-register programs with a typed error pointing at the second declaration.
  • Gate-name resolution — looks up each gate_call against a literal whitelist (@stdgate_table); unknown names raise Qx.QasmUnsupportedError. Per Iron Law 1, never converts caller input to atoms.
  • Decomposition — for tdg, sx, u1, u2, expands to one or more Qx instruction tuples. id is dropped.
  • Parameter evaluation — calls Qx.Export.OpenQASM.Expr.eval/2 to fold numeric expressions to floats.
  • Validation — qubit references must point at the declared register and stay in bounds; classical bits likewise.

Summary

Functions

Lowers a parsed AST into a %QuantumCircuit{}.

Functions

lower(arg)

@spec lower({:program, list()}) ::
  {:ok, Qx.QuantumCircuit.t()} | {:error, Exception.t()}

Lowers a parsed AST into a %QuantumCircuit{}.

Returns {:ok, circuit} or {:error, exception} where exception is one of Qx.QasmParseError, Qx.QasmUnsupportedError, Qx.QubitIndexError, Qx.ClassicalBitError.