{"id":16878930,"url":"https://github.com/dabacon/qsel","last_synced_at":"2025-03-22T07:32:09.367Z","repository":{"id":53929280,"uuid":"127537438","full_name":"dabacon/qsel","owner":"dabacon","description":"Quantum programming language putting entanglement and superposition front and center","archived":false,"fork":false,"pushed_at":"2023-02-26T20:44:17.000Z","size":15,"stargazers_count":42,"open_issues_count":0,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T09:22:18.742Z","etag":null,"topics":["a","esoteric-programming-language","programming-language","quantum-computing","qubits","superposition"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dabacon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-03-31T14:06:03.000Z","updated_at":"2025-03-05T19:13:17.000Z","dependencies_parsed_at":"2022-08-13T04:40:33.798Z","dependency_job_id":"981558f0-3920-4138-aaa2-04a64499606b","html_url":"https://github.com/dabacon/qsel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabacon%2Fqsel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabacon%2Fqsel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabacon%2Fqsel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabacon%2Fqsel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dabacon","download_url":"https://codeload.github.com/dabacon/qsel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244925175,"owners_count":20532873,"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","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":["a","esoteric-programming-language","programming-language","quantum-computing","qubits","superposition"],"created_at":"2024-10-13T15:52:10.372Z","updated_at":"2025-03-22T07:32:09.044Z","avatar_url":"https://github.com/dabacon.png","language":"Python","funding_links":[],"categories":["Abandoned projects"],"sub_categories":[],"readme":"# Quantum Super Entangled Language (qsel)\n\nWhat makes quantum computers more powerful than classical computers?  Ask \nany expert, or watch any public lecture on the subject and the answer\nis clear.  **Entanglement** and **Superposition** are what give quantum\ncomputers their power over classical computers.  If these two ideas\nare at the heart of the power of quantum computing, it therefore makes\nsense that any programing language for quantum computing should make \nthese two ideas front and center.  This is where **Quantum Super Entangled\nLanguage** (qsel) comes in.  It is a quantum programming language made\nentirely from superposition and entanglement.\n\n## Getting started\n\nThe qsel compiler is written in python because who needs strong typing\nwhen you are writing research code that will only ever be seen by yourself\nand maybe your graduate students. We recommend you work in a virtual \nenvironment and pip install the requirements listed in \n[requirements.txt](requirements.txt). Or don't. Yolo.  A sample program \nis provided in [example.qsel](example.qsel). To run this program simply\nrun the following from your command line\n```bash\npython run.py example.qsel\n```\nwhich should produce something like\n```\nMeasured 1 on qubit 0.\nMeasured 0 on qubit 1.\n```\nwhere your measurement results may be different.\n\n## The Language\n\nTypically quantum computers are described by the abstract quantum circuit\nmodel. In this model the circuits can create entanglement and superposition.\nHere we want to use entanglment and superposition to describe a quantum\ncomputation. So our first choice is easy. All of our tokens in the \nlanguage should be either ``entanglement`` or ``superposition``.\n\nA qsel program is specified by a series of lines in a text file.\nEach line corresponds to a single ``\u003ccommand\u003e``. The language is case\nsensitive and extremely sensitive to whitespace. This sensitivity is sort\nof like a qubit's sensitivity to dephasing.  For dephasing the issue comes\nfrom interacting with uncontrolled degrees of freedom. For qsel the\nwhitespace sensitivity comes interacting with a lazy programmer.\n\nBack to ``\u003ccommand\u003e``s. Commands are one of three types\n```\n\u003ccommand\u003e -\u003e \u003centaglement gate\u003e | \u003csuperposition gate\u003e | \u003cmeasurement\u003e\n```\nNow wait, you say, isn't measurement something beyond entanglement\nand superposition?  This is a philosophical and religious question.\nSubscribers to it being entanglement belong to the Church of the Higher\nHilbert Space. Those who believe it is superposition find themselves\nreading through the many books of the Many Worlds religion.\nWe don't believe that programming languages should take sides in \nreligion or philosophy debates, so we will call it ``\u003cmeasurement\u003e``,\nand you can substitute your personal preference as needed.\n\n### Qubits\n\nBefore we describe the three commands, we run into another problem.\nIf quantum computing is made entirely of entanglement in superposition,\nwhat about the actual objects of a quantum computer, the qubits?\nOne elegant thought is that maybe we should make the two computational\nbasis states of our qubit ``entanglement`` and ``superposition``?\nUnfortunately this solution appears to cause a recursion which the\nuniverse cannot handle. \n\u003e Religious aside: I think I may have generated some parallel universes\n\u003e in which this recursion seg faulted the universe. However if you are\n\u003e reading this, then you exist in one of the parallel universe branches\n\u003e were I didn't do this.  I guess I'd warn you not to do such \n\u003e experiments, but really I should just make sure you use superposition\n\u003e to make sure one of the parallel universes doesn't do the experiment.\n\u003e If your religion is not of the Many World's variety, however, your\n\u003e view on this may be different and we are very very lucky.\n\nThe important thing about qubits is that we need to be able to \ndistinguish one qubit from another qubit. Humans have invented\nan elegant solution to this problem. They *label* the qubits.\nSemi-modern humans found away around the problem of having as \nmany labels as objects, by noting that the *label* could be a \n*number*. Modern humans completed this journey by insisting that\nthe number be written in as a *binary* number so that machines\ncould understand it. With this insight concerning how to label \nqubits, we define a qubit id made out of one or more binary bits\n```\n\u003cqubit id\u003e := \u003cbit\u003e+\n```\nAnd our bits need to be made out of entanglement and superposition.\n```\n\u003cbit\u003e := (\u003csuperposition\u003e \u003csuperposition\u003e) | (\u003centanglement\u003e \u003centanglement\u003e)\n```\nNote that we do not make  the mistake of using a single \n``entanglement`` as the opposite  value of ``superposition``. \nEntanglement can only exist between two objects. From excellent\nsymmetry considerations, we also double the ``superposition``. \nFinally note some semantics, we interpret the bits as a binary \nstring, and compare their values based on this binary value.  So\n``\u003csuperposition\u003e \u003csuperposition\u003e \u003csuperposition\u003e superposion\u003e``\nis the same as ``\u003csuperposition\u003e \u003csuperposition\u003e``.\n\n### Commands\n\nWe now describe the quantum commands.\n\nThe superposition gate starts with a superposition op code (duh),\nfollowed by the id of the gate upon which to act.\n```\n\u003csuperposition gate\u003e := \u003csuperposition\u003e \u003csuperposition\u003e \u003cqubit id\u003e  \n```\nWhat are the semantics of this gate? This corresponds to the \nHadamard gate.  Because nothing says a modern compiler like using\na gate named after an dead mathematician who wrote down matrices.\nThis is the gate with matrix\n```\n[[1/sqrt{2},  1/sqrt{2}],\n [1/sqrt{2}, -1/sqrt{2}]]\n```\nin the computational basis.\n\nThe entanglement gate starts with an entanglment op code (duh),\nfollowed by the ids of the gates upon which to act. Unfortunately\nbecause we need to specify two qubits, we now need some way to\nkeep these qubits separated from each other.  Otherwise, as we all\nknow, the qubits interact via an exchange interaction. And it \nis certainly not possible to use exchange interactions only to \nbuild a quantum computer.  So how do we keep qubits separated?\nFor this I propose we create an odd kind of monster, a superposition\nentanglement divider (since each qubit is one of either type).\nOf course this could also be (by symmetry again) an entanglement\nsuperposition divider. So we define\n```\n\u003ccomma\u003e := \u003centanglement\u003e \u003csuperposition\u003e | \u003csuperposition\u003e \u003centanglement\u003e\n```\nThen we can define the entanglement gate\n```\n\u003centanglement gate\u003e := \u003centanglement\u003e \u003centanglement\u003e \u003cqubit id\u003e \u003ccomma\u003e \u003cqubit id\u003e\n```\nWhat are the semantics of this gate? This corresponds to the gate\nthat I need to make it, along with the Hamadard universal. \nLuckily, Kitaev is a time traveler, and he went to 2027 to \nfind out the answer and came back and delivered it to us in \n1997. This is the controlled-P gate, which is the diagonal gate\nin the computational basis with diagonal values\n```\ndiag(1, 1, 1, i)\n```\nThere is probably a potty joke here, but one has to have at least\nsome standards. The good thing is that we don't have to tell you\nwhich qubit is which because controlled-P is symmetric (technically:\nbi-urinal).\n\nWe next turn to the measurement gate. Measurement,\nlike we said, is something that, depending on your philosophical\nor religious leanings, is either superposition or measurement.\nSo, following the divider above, we define it as either, followed\nby the qubit upon which the measurement is done\n```\n\u003cmeasurement\u003e := (\u003centanglement\u003e \u003csuperposition\u003e | \u003csuperposition\u003e \u003centanglement\u003e) \u003cqubit id\u003e\n```\nMeasurement is done in the computational basis.\n\nFinally we need to define ``\u003csuperposition\u003e`` and ``\u003centanglement\u003e``.\nBut like we said, qsel is all about writing programs in superposition\nand entanglement.  So these are the words ``superposition`` and \n``entanglement``, respectively.\n\nOne final semantic meaning: we need to define the initial state.\nWe stick with the boring and state that every qubit used in the \nprogram starts in the computation 0 state.\n\n## Example\n\nA two qubit circuit. We want to apply Hadamard to the first and\nsecond qubit, then apply the controlled-P gate between the qubits,\nfinally apply a Hadmard to the second qubit, and measure both\nqubits. This is simply\n```\nsuperposition superposition superposition superposition\nsuperposition superposition entanglement entanglement\nentanglement entanglement superposition superposition entanglement superposition entanglement entanglement\nsuperposition superposition entanglement entanglement\nentanglement superposition superposition superposition\nentanglement superposition entanglement entanglement\n```\n\n## Creative Mode\n\nThere are some people who do not belive that entanglement and\nsuperposition are at the core of quantum computing.  For these\npeople, it seem that they would like to be able to use different\nprimitives.  To support this we have **creative mode**.  By \nsupplying two strings after the filename of the program, we \ncan use different symbols for ``superposition`` and ``entanglement``.\nFor example, if one wants to use the tab character for superposition\nand two tab characters for entanglement (again it would be an\nabsurdity to have only one symbol for entanglement), then one\ncould run\n```\npython run.py vacuum.qsel $'\\t' $'\\t\\t'\n```\nWe have supplied a program that is written in this form, called\n[vacuum.qsel](vacuum.qsel).  Please be aware that despite the name\nof this file, and the empty seeming content, executing this program \ndoes not cause us to transition into a new vacuum state for the universe.\nOr at least it hasn't yet.\n\n## FAQ\n\n**Q:** Wouldn't understanding the difference betwen quantum and classical\npolynomial time computing mean proving a major complexity theoretic \nbreakthrough like P not equal to PSPACE?\n\n**A:** Yes. Programming languages are regularly places where we present\nsuch proofs. Unlike posting these solutions on the arXiv, putting them\nin a programming language insures that only minds who can grok monads\ncan check the brilliance of the proof.\n\n**Q:** What abou contextuality? Isn't contextuality an important part of\nwhat powers quantum computers?\n\n**A:** Go ahead and ask me that question another time, when you can see\nthat I am busy or not busy.\n\n**Q:** Isn't entanglement a kind of superposition?\n\n**A:** This is refuted by the fact that such a programming language would\nrequire very inefficient unary encodings.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabacon%2Fqsel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabacon%2Fqsel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabacon%2Fqsel/lists"}