Presentation is loading. Please wait.

Presentation is loading. Please wait.

Silq: A High-level Quantum Programming Language

Similar presentations


Presentation on theme: "Silq: A High-level Quantum Programming Language"— Presentation transcript:

1 Silq: A High-level Quantum Programming Language
Benjamin Bichsel Maximilian Baader Timon Gehr Martin Vechev

2 Quantum Programming Languages
Existing languages: Describe circuits Silq: Describes high-level operations Qiskit Quipper Reduce & simplify code Static safety / Prevent errors Q# ProjectQ QWire Safe automatic uncomputation More intuitive semantics Downstream applications: Simulation Compilation Teaching Discovery of new algorithms LIQ𝑈𝑖|〉 QASM Forest Downstream applications Physicality Source of icons:

3 Quantum Programming Languages
Teaser, especially regarding hackathon Comparison on Microsoft’s Q# coding contests, see

4 Goals of this Lecture Learn Silq’s language concepts
Discuss & compare languages Try out Silq Report issues Source of icons:

5 Background (minimal) Concept Explanation State of quantum bit
𝜑= 𝛾 𝛾 for 𝛾 0 , 𝛾 1 ∈ℂ (Computational) basis states 0 , 1 , but not No-cloning theorem Impossible: φ⟼φ⊗φ

6 Basic Features of Silq if x { // controlled on x,
  y:=H(y); // apply H to y }

7 Grover’s Algorithm - Recap
𝑓: − 2 𝑛−1 ,…, 2 𝑛−1 −1 → 0,1 𝑓 𝑤 ∗ =1 𝑓 𝑣 =0 for all 𝑣≠ 𝑤 ∗

8 Grover’s Algorithm in Silq

9 Grover’s Algorithm in Silq
Time

10 Grover’s Algorithm in Silq

11 Grover’s Algorithm in Silq
Signature of grover

12 Grover’s Algorithm in Silq
First argument: generic parameter n: Parametrizes input length of f

13 Grover’s Algorithm in Silq
Type Classical or Quantum? B Classical / Quantum int[n] / uint[n] ℕ, ℤ, ℚ, ℝ Classical Generic parameters !N: classical natural numbers of arbitrary size !: classically known, in basis state. Can manipulate classically Classical->quantum but not vice versa

14 Grover’s Algorithm in Silq

15 Grover’s Algorithm in Silq
𝑔 classical bijection Function Semantics Qfree? X 𝑣=0 1 𝛾 𝑣 𝑣 ↦ 𝑣=0 1 𝛾 𝑣 1−𝑣 Qfree General (non-classical) 𝑣 𝛾 𝑣 𝑣 ↦ 𝑣 𝛾 𝑣 𝑔( 𝑣 ) H 𝑣=0 1 𝛾 𝑣 𝑣 ↦ 𝑣=0 1 𝛾 𝑣 (−1) 𝑣 1 Not Qfree

16 Grover’s Algorithm in Silq
y:=f(x); 𝑣 𝛾 𝑣 𝜑 𝑣 𝑣 𝑥 ⟼ 𝑣 𝛾 𝑣 𝜑 𝑣 𝑣 𝑥 𝑓(𝑣) 𝑦 qfree with 𝑔 𝑣 = 𝑣,𝑓(𝑣) Only const parameters are accessible after call Other parameters are consumed.

17 Grover’s Algorithm in Silq

18 Grover’s Algorithm in Silq

19 Automatic Uncomputation
if f(cand) {   phase(𝜋); } 𝑣≠ 𝑤 ∗ 𝑛 𝑣 cand tmp − 𝑛 𝑤 ∗ cand tmp implicit measurement Pitfalls: Forget Attempt to uncompute non-uncomputable Use wrong operations Use wrong/consumed variables 𝑣≠ 𝑤 ∗ 𝑛 𝑣 cand tmp 𝑛 𝑤 ∗ cand tmp

20 Automatic Uncomputation
const if f(cand) {   phase(𝜋); } 𝑣≠ 𝑤 ∗ 𝑛 𝑣 cand tmp − 𝑛 𝑤 ∗ cand tmp qfree

21 Live Coding

22 Summary of Type Annotations
Documentation on mfree const classical qfree Source of icons:

23 Downstream Applications
Simulation Compilation Research Teaching Source of icons:

24 Try Silq Yourself! Install Try examples Follow instructions on
Try examples Try to solve tasks / run solutions from Source of icons:

25 Bachelor/Master thesis
Interested in Silq? Ask & Complain! In person or via Slack channel Contact us! Bachelor/Master thesis Research projects PhD Benjamin Bichsel Max Baader Timon Gehr Prof. Martin Vechev (ETH Zürich) Source of icons:

26 Invalid Programs From Live Coding
The following slides are here for completeness.

27 Preventing Errors- Use Consumed
def useConsumed(x:𝔹){ y := H(x); return (x,y); // undefined identifier x } def duplicateConst(const x:𝔹){ y := H(x); return (x,y); // no error }

28 Preventing Errors- Implicit Measurements
def implicitMeas[n:!ℕ](x:uint[n]){ y := x % 2; return y; } // parameter 'x' is not consumed def unconsumedConst[n:!ℕ](const x:uint[n]){ y := x % 2; return y; } // no error

29 Preventing Errors- Conditional Measurements
def condMeas(const c:𝔹,x:𝔹){ if c{ x:= measure(x); } return x; } // cannot call function 'measure[𝔹]' in 'mfree' context def classCondMeas(const c:!𝔹,x:𝔹){ if c{ x:= measure(x):𝔹; } return x; } // no error

30 Preventing Errors- Reverse Measurements
def revMeas(){ return reverse(measure); } // reversed function must be mfree

31 Preventing Errors- Invalid Uncomputation
def nonConst(y:𝔹){ if X(y) { // X consumes y phase(π); } } // non-'lifted' quantum expression must be consumed def signFlipOf0(const y:𝔹){ if X(y) { // X consumes a copy of y phase(π); } } // no error

32 Preventing Errors- Invalid Uncomputation
def nonQfree(const y:𝔹,z:𝔹){ if H(y) { z := X(z); } return z; } // non-'lifted' quantum expression must be consumed


Download ppt "Silq: A High-level Quantum Programming Language"

Similar presentations


Ads by Google