Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish implementing OpenQASM parser #73

Open
boschmitt opened this issue May 13, 2020 · 5 comments
Open

Finish implementing OpenQASM parser #73

boschmitt opened this issue May 13, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@boschmitt
Copy link
Owner

No description provided.

@boschmitt boschmitt added the enhancement New feature or request label May 13, 2020
@boschmitt boschmitt added this to the Beta milestone May 13, 2020
@boschmitt boschmitt removed this from the Beta milestone Apr 6, 2021
@Roland-djee
Copy link

Hi @boschmitt , I'd be happy to use that functionality. Any updates on this ?

@boschmitt
Copy link
Owner Author

Hi @Roland-djee.

There is already some limited support for OpenQASM 2.0.

I suppose the further support would require bigger architectural changes to tweedledum, i.e., possibly creating a AST and a global context capable of handling various circuits inside a bigger program. Also, there is the newer OpenQASM 3.0 version that is still in development phase.

@Roland-djee
Copy link

Yes, concretely, I would like to use the Exorcism implementation. However, it requires input esops as strings (unless I missed something) which can be produced by traversing an AST of some sort. I was wondering if there were already such a functionality for OpenQASM format.

@boschmitt
Copy link
Owner Author

exorcism works form an ESOP defined as a vector of cubes or from a truth table.

If you have a function: f(abc) = a!c ⊕ abc, then your ESOP will be [Cube(‘1-0’), Cube(‘111’)]
(Note that ‘b’ does not appear in the first cube, hence the use of ‘-‘)

For example (from python):

from tweedledum.classical import TruthTable, Cube, create_from_cubes, exorcism

esop = [Cube('101'), Cube('100'), Cube('011'), Cube('001'), Cube('000')]
opt_esop = exorcism(esop, 3)
for cube in opt_esop:
    print(cube.to_string(3))

# Create a TruthTable from the orginal ESOP:
tt_esop = TruthTable(3)
create_from_cubes(tt_esop, esop, True)

# Create a TruthTable from the optimized orginal ESOP:
tt_opt_esop = TruthTable(3)
create_from_cubes(tt_opt_esop, opt_esop, True)

# Make sure they are the same
print(tt_esop == tt_opt_esop)

# Now, from a function TruthTable do exorcism (it will extract a PKRM and then do exorcism)
opt_esop_2 = exorcism(tt_opt_esop)
for cube in opt_esop_2:
    print(cube.to_string(3))

@Roland-djee
Copy link

Roland-djee commented Nov 15, 2021

Hi @boschmitt thanks. Yes, I am aware of this. I am just scratching my head around how to parse structures (ie. circuits) to generate these vectors of cubes. It looks like there is no other way than an AST of some sort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants