dakk / qlasskit

A python-to-quantum compiler
https://dakk.github.io/qlasskit/
Apache License 2.0
56 stars 11 forks source link

Evaluate constant expressions on compilation step #35

Closed dakk closed 3 months ago

dakk commented 6 months ago

When qlasskit parses expressions containing constants, the boolean form containing the constant is created and then optimized (if possible). A smarter approach would be to evaluate constant expression during ast2logic parsing.

This could be performed by calling eval if tleft and tright are ast.Constant in a binop. But we also need to evalute op(const).

Test case:

Since ast2ast is getting bigger, we can separate it to different rewriters, so we can simplify the file, and have a prioritization of certain optimizations.