{"id":19717328,"url":"https://github.com/malhotrapulak/starq","last_synced_at":"2026-03-03T07:33:45.533Z","repository":{"id":131150726,"uuid":"561676396","full_name":"MalhotraPulak/StarQ","owner":"MalhotraPulak","description":"Minimal and Accessible Quantum Circuit DSL","archived":false,"fork":false,"pushed_at":"2023-01-21T10:30:10.000Z","size":222,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T22:49:43.855Z","etag":null,"topics":["quantum-computing","racket"],"latest_commit_sha":null,"homepage":"","language":"Racket","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MalhotraPulak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-04T08:29:14.000Z","updated_at":"2024-03-14T10:02:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"672792a3-f0a4-4455-80a7-d895719273fb","html_url":"https://github.com/MalhotraPulak/StarQ","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MalhotraPulak/StarQ","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MalhotraPulak%2FStarQ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MalhotraPulak%2FStarQ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MalhotraPulak%2FStarQ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MalhotraPulak%2FStarQ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MalhotraPulak","download_url":"https://codeload.github.com/MalhotraPulak/StarQ/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MalhotraPulak%2FStarQ/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285914727,"owners_count":27252968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-23T02:00:06.149Z","response_time":135,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["quantum-computing","racket"],"created_at":"2024-11-11T22:46:35.236Z","updated_at":"2025-11-23T07:02:15.001Z","avatar_url":"https://github.com/MalhotraPulak.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StarQ: A Minimal and Accessible Quantum Circuit Representation DSL\n\n### Want Grover search (for 3 qubits) in 6 LOC?? Then try *StarQ*\n```rust\n(ccz 3 (H 2) (Toffoli) (H 2))\n(hx 3 (H) (X))\n\n(oracle 3 (X 0) (ccz) (X 0))\n(diffusion 3 (hx) (ccz) (! (hx)))\n\n(shift 3 (oracle) (diffusion))\n\n(grover 3 (H) (repeat (shift) 2))\n```\n![image](https://user-images.githubusercontent.com/56169176/204645916-038e2925-b811-4332-8f3a-af9d01d596d7.png)\n\n\n\n### To Run\nTo get cQASM for a given StarQ file\n```bash\nracket cli.rkt --file \u003cfilename\u003e\n```\nWe have a suite of 25 different tests which cover all the functionality of the language. \u003cbr/\u003e\nTo run tests:\n```bash\nraco test tester.rkt\n```\n\u003cbr/\u003e\nWe have provided code samples along with expected outputs for `Grover Search`, `Quantum Fourier Transform`, `Quantum Teleportation` and `Quantum Classification` in the tests folder itself.\n\n### Interpreter Design\n\nWe followed Test Driven Development and have a suite of 25 tests.\n\nOur interpreter is a transpiler that evaluates to cQasm. We have extensively used `eopl` data structures and recursive descent parsing to write succinct and concise code.\n\nAST datatype:\n```racket\n(define-datatype\n ast\n ast?\n [run-circuit (circuit-name symbol?)]\n [circuit-def (circuit-name symbol?) (qubit number?) (circuit-body (list-of circuit-body-item?))])\n\n(define-datatype circuit-body-item\n                 circuit-body-item?\n                 [chops (circuit circuit-body-item?) (count number?)]\n                 [shift (circuit circuit-body-item?) (count number?)]\n                 [repeat (circuit circuit-body-item?) (count number?)]\n                 [uncompute (circuit circuit-body-item?)]\n                 [circuit-call (circuit-name symbol?) (gate-args list?)]\n                 [moment (circuits (list-of circuit-body-item?))])\n```\nOnce we convert AST into cQASM we store it in a qasm datatype:\n```racket\n(define-datatype qasm\n                 qasm?\n                 [instr (name symbol?) (constant false-or-number?) (args (list-of number?))]\n                 [instr-parallel (instrs (list-of qasm?))]\n                 [instr-label (label symbol?) (count number?)])\n```\nWe maintain all the inbuilt gates and their properties in an encapsulated match function:\nEach entry corresponds to `(arity constants uncompute)`\n```racket\n(define (fundamental-gate? name)\n  (match name\n    ['X '(1 #f X)]\n    ['Y '(1 #f Y)]\n    ['Z '(1 #f Z)]\n    ['H '(1 #f H)]\n    ['I '(1 #f I)]\n    ['S '(1 #f Sdag)]\n    ['Sdag '(1 #f S)]\n    ['T '(1 #f Tdag)]\n    ['Tdag '(1 #f T)]\n    ['CNOT '(2 #f CNOT)]\n    ['SWAP '(2 #f SWAP)]\n    ['CZ '(2 #f CZ)]\n    ['CX '(2 #f CX)]\n    ;; special uncompute\n    ['Rx '(1 1 Rxdag)]\n    ['Ry '(1 1 Rydag)]\n    ['Rz '(1 1 Rzdag)]\n    ['CR '(2 1 CRdag)]\n    ['CRk '(2 1 CRkdag)]\n    ;; special uncompute ends\n    ['Toffoli '(3 #f Toffoli)]\n    ;; invalid uncomputes\n    ['measure_z '(1 #f #f)]\n    ['measure_y '(1 #f #f)]\n    ['measure_x '(1 #f #f)]\n    [else #f]))\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalhotrapulak%2Fstarq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalhotrapulak%2Fstarq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalhotrapulak%2Fstarq/lists"}