CQCL / lambeq

A high-level Python library for Quantum Natural Language Processing
https://docs.quantinuum.com/lambeq/
Apache License 2.0
455 stars 111 forks source link

Improve RemoveCupsRewriter #141

Open dimkart opened 6 months ago

dimkart commented 6 months ago

Description

Some of the syntax-based diagrams in lambeq, such as pregroup diagrams, include cups that indicate syntactic interactions between the words in the sentence. For example, in the diagram:

John       gave      Mary    a    flower                                                                                            
────  ─────────────  ────  ─────  ──────
 n    n.r·s·n.l·n.l   n    n·n.l    n
 ╰─────╯  │  │   ╰────╯    │  ╰─────╯
          │  ╰─────────────╯

cups are indicated by ╰─╯ links. These operations are expensive, since they introduce post-selections which increase exponentially the number of the required circuit executions. lambeq addresses this problem with RemoveCupsRewriter, which attempts to remove as many cups as possible while retaining the same connections as the original diagram.

The goal of this task is to improve RemoveCupsRewriter, or to create a new rewriter class, so that the new implementation:

  1. is more effective than the old one concerning the number of cups removed from a diagram
  2. keeps the rewriting speed in acceptable ranges

Notes

References