최근 수정 시각 : 2024-04-03 20:12:54

Q#

[include(틀:링크시 주의, 링크=Q\ 또는 # 또는 Q#)]
'''이론 컴퓨터 과학
{{{#!wiki style="display: inline-block; font-family:Times New Roman, serif;font-style:italic"'''
{{{#!wiki style="margin: 0 -10px -5px; min-height: calc(1.5em + 5px)"
{{{#!folding [ 펼치기 · 접기 ]
{{{#!wiki style="margin: -5px -1px -11px"
<colbgcolor=#aa3366> 이론
기본 대상 수학기초론{수리논리학(논리 연산) · 계산 가능성 이론 · 범주론 · 집합론} · 이산수학(그래프 이론) · 수치해석학 · 확률론통계학 · 선형대수학
다루는 대상과 주요 토픽
계산 가능성 이론 재귀함수 · 튜링 기계 · 람다 대수 · 처치-튜링 명제 · 바쁜 비버
오토마타 이론 FSM · 푸시다운 · 튜링 머신(폰노이만 구조) · 정규 표현식 · 콘웨이의 생명 게임
계산 복잡도 이론 점근 표기법 · 튜링 기계^고전, 양자, 비결정론적, 병렬 임의접근 기계^ · 알고리즘 · 자료구조 · 알고리즘 패러다임(그리디 알고리즘, 동적 계획법)
정보이론 데이터 압축(무손실 압축 포맷 · 손실 압축 포맷) · 채널 코딩(채널 용량) · 알고리즘 정보 이론(AIT) · 양자정보과학
프로그래밍 언어이론 프로그래밍 언어(함수형 언어 · 객체 지향 프로그래밍) · 메타 프로그래밍 · 형식언어 · 유형 이론 · 프로그래밍 언어 의미론 · 파싱 · 컴파일러 이론
주요 알고리즘 및 자료구조
기초 정렬 알고리즘 · 순서도 · 탐색 알고리즘
추상적 자료형 및 구현 배열^벡터^ · 리스트^연결 리스트^ · 셋(set)^레드-블랙 트리, B-트리^ · 우선순위 큐^, 피보나치 힙^
수학적 최적화 조합 최적화 외판원 순회 문제 · 담금질 기법 · 유전 알고리즘 · 기계학습
볼록 최적화 내부점 방법 · 경사하강법
선형계획법 심플렉스법
계산 수론 및 암호학 밀러-라빈 소수판별법 · Pollard-rho 알고리즘 · 쇼어 알고리즘 · LLL 알고리즘 · 해시(MD5 · 암호화폐 · 사전 공격(레인보우 테이블) · SHA) · 양자 암호
대칭키 암호화 방식 블록 암호 알고리즘(AES · ARIA · LEA · Camellia) · 스트림 암호 알고리즘(RC4)
공개키 암호화 방식 공개키 암호 알고리즘(타원 곡선 암호 · RSA) · 신원 기반 암호 알고리즘(SM9)
계산기하학 볼록 껍질 · 들로네 삼각분할 및 보로노이 도형^Fortune의 line-sweeping 알고리즘^ · 범위 탐색^vp-tree, R-tree^ · k-NN
그래프 이론 탐색^BFS, DFS, 다익스트라 알고리즘, A* 알고리즘^ · 에드몬드-카프 · 크루스칼 알고리즘 · 위상 정렬 · 네트워크 이론
정리
정지 문제대각선 논법 · 암달의 법칙 · P-NP 문제미해결 · 콜라츠 추측미해결
틀:이산수학 · 틀:수학기초론 · 틀:컴퓨터공학 }}}}}}}}}


파일:Microsoft 로고.svg파일:Microsoft 로고 화이트.svg
{{{#!wiki style="margin:0 -10px -5px; min-height:calc(1.5em + 5px); word-break:keep-all"
{{{#!folding [ 펼치기 · 접기 ]
{{{#!wiki style="margin:-6px -1px -11px"
<colbgcolor=#393939,#000><colcolor=#fff>제품군
하드​웨어Surface · Xbox · HoloLens · PixelSense · Zune · Pluton ·IVAS
소프트​웨어Windows · Office · Edge · Media Player · Hyper-V · Defender · Visual Studio Code · Visual Studio · Windows Terminal · PowerToys · Internet Explorer · MS-DOS · Windows Movie Maker · Autoruns · Clipchamp
서비스Microsoft Azure · OneDrive · Skype · MSN · Bing · Microsoft Copilot · LinkedIn · Cortana · 테이 · Xbox network · 정품 인증 · Microsoft Docs
관련 기술ASF · ASP · Blazor · COM · DCOM · DirectX · 파일 시스템(FAT · NTFS · ReFS) · MFC · .NET(.NET Core · .NET Standard · C# · F# · Visual Basic .NET · Windows Forms · WPF · UWP · .NET MAUI · ASP.NET · ML.NET) · OLE · # · Silverlight · Visual Basic · VBA · WASAPI · Windows 커널 · Windows 디자인 · Windows API · Windows Runtime(UWP · WinUI 3) · WMA · WMV · Xamarin · XNA · 하복 엔진 · SAMI · PowerShell · Windows Modern Standby
산하 계열사 및 사업부GitHub · .NET Foundation · Microsoft Gaming · LinkedIn
관련 인물빌 게이츠(은퇴) · 폴 앨런(은퇴) · 스티브 발머(퇴사) · 게이브 뉴웰(퇴사) · 마이크 이바라(퇴사)
사티아 나델라 · 필 스펜서 · 브래드 스미스
기타제니맥스 미디어 인수 · 액티비전 블리자드 인수 · 시작 메뉴 · 빌 게이츠의 굴욕
관련 틀365 제품군 · 하드웨어 제품군 · Surface 제품군 · Windows 제품군}}}}}}}}}

프로그래밍 사이트 선정 프로그래밍 언어 순위 목록
{{{#!wiki style="margin: 0 -10px -5px; word-break: keep-all"
{{{#!wiki style="display: inline-block; margin: 0 0 -5px; min-width: 25%"
{{{#!folding ⠀[ IEEE Spectrum 2023 ]⠀
{{{#!wiki style="margin:-6px -1px -10px"
<rowcolor=#fff> 스펙트럼 부문 상위 10개 프로그래밍 언어 직업 부문 상위 10개 프로그래밍 언어
1 Python 1 SQL
2 Java 2 Python
3 C++ 3 Java
4 C 4 JavaScript
5 JavaScript 5 C++
6 C# 6 C#
7 SQL 7 C
8 Go 8 HTML
9 TypeScript 9 Shell
10 HTML 10 SAS
}}}}}}}}}
⠀[ Stack Overflow 2023 ]⠀
||<tablewidth=100%><width=2000><-4><bgcolor=#FFA500><tablebgcolor=#fff,#222> 2023년 Stackoverflow 설문조사 기준 인기 상위 25개 프로그래밍 언어 ||
1 JavaScript 14 Rust
2 HTML, CSS 15 Kotlin
3 Python 16 Ruby
4 SQL 17 Lua
5 TypeScript 18 Dart
6 Bash 19 어셈블리어
7 Java 20 Swift
8 C# 21 R
9 C++ 22 Visual Basic
10 C 23 MATLAB
11 PHP 24 VBA
12 PowerShell 25 Groovy
13 Go
⠀[ TIOBE 2024 ]⠀
||<tablewidth=100%><width=2000><-4><bgcolor=deepskyblue><tablebgcolor=#fff,#222> 2024년 2월 기준 검색어 점유율 상위 20개 프로그래밍 언어 ||
1 Python 11 Fortran
2 C 12 Delphi / Object Pascal
3 C++ 13 MATLAB
4 Java 14 Assembly language
5 C# 15 Scratch
6 JavaScript 16 Swift
7 SQL 17 Kotlin
8 Go 18 Rust
9 Visual Basic 19 COBOL
10 PHP 20 Ruby
{{{#!wiki style="margin:0 -10px -5px; min-height: 26px"
{{{#!folding [ 21위 ~ 50위 펼치기 · 접기 ]
{{{#!wiki style="margin: -6px -1px -10px"
21 R 36 Transact-SQL
22 SAS 37 VBScript
23 Classic Visual Basic 38 Haskell
24 Prolog 39 TypeScript
25 Ada 40 Logo
26 Perl 41 Bash
27 (Visual) FoxPro 42 Scheme
28 Dart 43 Solidity
29 D 44 ABAP
30 F# 45 ML
31 Scala 46 X++
32 Objective-C 47 PL/SQL
33 Lua 48 GAMS
34 Julia 49 PowerShell
35 LISP 50 RPG
}}}}}}}}} ||
⠀[ PYPL 2024 ]⠀
||<tablewidth=100%><width=2000><-4><bgcolor=green><tablebgcolor=#fff,#222> 2024년 2월 기준 검색어 점유율 상위 20개 프로그래밍 언어 ||
1 Python 11 Rust
2 Java 12 Go
3 JavaScript 13 Kotlin
4 C/C++ 14 MATLAB
5 C# 15 Ada
6 R 16 Dart
7 PHP 17 Ruby
8 TypeScript 18 PowerShell
9 Swift 19 VBA
10 Objective-C 20 Lua
}}} ||
프로그래밍 언어 목록 · 분류 · 문법


1. 개요2. 역사3. 기능4. 특징
4.1. C#와의 비교4.2. F#와의 비교
5. 예제
5.1. 난수 생성기5.2. 그래프 색 지정 문제
6. 관련 문서7. 외부 링크

1. 개요

파일:QvK4uVpa8lr.jpg
Q#은 2017년에 발표된 양자컴퓨터의 양자 알고리즘을 개발하고 실행하기 위한 Microsoft의 오픈 소스 프로그래밍 언어이다.

2. 역사

2017년 9월 26일 Microsoft Ignite Keynote에서 Microsoft양자 컴퓨터를 위해 특별히 설계된 새로운 프로그래밍 언어를 출시할 것이라고 발표했다. 2017년 12월 11일에는 Microsoft는 .NET 프로젝트의 SDK인 Quantum Development Kit(QDK)의 일부로 Q#을 출시했다. 이후 Build 2019빌드에서 Microsoft는 Q# 컴파일러와 시뮬레이터를 포함한 Quantum Development Kit를 오픈소싱한다고 발표했다.

3. 기능

Q#의 주요 기능은 양자 알고리즘용 큐비트를 만들고 사용하는 기능이다. 결과적으로 Q#의 가장 두드러진 기능 중 일부는 각각 Controlled NOT 게이트 및 Hadamard 게이트를 통해 큐비트에 중첩 및 중첩제어를 도입 하는 기능과 Tofffoli Gates , Pauli X, Y, Z 게이트 등을 포함하는 기능이다.

결국 Q#과 함께 제공될 하드웨어 스택은 큐비트를 토폴로지 큐비트로 구현할 것으로 예상된다. 현재 Quantum Development Kit와 함께 제공되는 양자 시뮬레이터는 사용자 컴퓨터에서 최대 32큐비트를 처리하고 Azure에서는 최대 40큐비트를 처리할 수 있다.


Quantum Development Kit에서 제공하는 기능들은 다음과 같다.
  • Azure Quantum 서비스에 Qiskit[1] 및 Cirq 애플리케이션을 제출하는 Python 패키지
  • Q# 프로그래밍 언어 및 라이브러리
  • Jupyter Notebook에서 Q#을 실행하기 위한 IQ# 커널
  • Azure Quantum 서비스를 관리하고 Q# 애플리케이션을 제출하는 Azure CLI 확장
  • Q#을 포함하여 Python 및 .NET 언어용(C#, F#VB.NET) API
  • Visual Studio CodeVisual Studio용 확장

4. 특징

4.1. C#와의 비교

4.2. F#와의 비교

  • 변수는 let또는 mutable을 사용하여 선언
  • 1차 함수
  • open키워드를 사용하여 모듈 가져오기
  • 데이터 유형은 변수 이름 뒤에 선언
  • 범위 연산자 ..
  • for … in루프
  • 모든 작업/함수는 void가 아닌 빈 튜플 반환
  • 레코드 데이터 유형의 정의 (type대신 newtype 키워드 사용)

5. 예제

5.1. 난수 생성기

이 예제는 Microsoft의 공식 문서 중 연습-양자 난수 생성기 만들기에서 가져왔습니다.

namespace QuantumRNG {

    open Microsoft.Quantum.Canon;
    open Microsoft.Quantum.Intrinsic;
    open Microsoft.Quantum.Measurement;
    open Microsoft.Quantum.Math;
    open Microsoft.Quantum.Convert;

    operation GenerateRandomBit() : Result {
        // Allocate a qubit.
        use q = Qubit();
        // Put the qubit to superposition.
        H(q);
        // It now has a 50% chance of being measured 0 or 1.
        // Measure the qubit value.
        return M(q);
    }

    operation SampleRandomNumberInRange(max : Int) : Int {
        mutable output = 0; 
        repeat {
            mutable bits = []; 
            for idxBit in 1..BitSizeI(max) {
                set bits += [GenerateRandomBit()]; 
            }
            set output = ResultArrayAsInt(bits);
        } until (output <= max);
        return output;
    }

    @EntryPoint()
    operation SampleRandomNumber() : Int {
        let max = 50;
        Message($"Sampling a random number between 0 and {max}: ");
        return SampleRandomNumberInRange(max);
    }
}

5.2. 그래프 색 지정 문제

이 예제는 Microsoft의 공식 문서 중 연습 - Grover 알고리즘을 구현하여 그래프 색 지정 문제 해결에서 가져왔습니다.

namespace ExploringGroversSearchAlgorithm {
    open Microsoft.Quantum.Measurement;
    open Microsoft.Quantum.Math;
    open Microsoft.Quantum.Arrays;
    open Microsoft.Quantum.Canon;
    open Microsoft.Quantum.Convert;
    open Microsoft.Quantum.Diagnostics;
    open Microsoft.Quantum.Intrinsic;


    operation MarkColorEquality(c0 : Qubit[], c1 : Qubit[], target : Qubit) : Unit is Adj+Ctl {
        within {
            for (q0, q1) in Zipped(c0, c1) {
                CNOT(q0, q1);
            }
        } apply {
            (ControlledOnInt(0, X))(c1, target);
        }
    }


    operation MarkValidVertexColoring(
        edges : (Int, Int)[], 
        colorsRegister : Qubit[], 
        target : Qubit
    ) : Unit is Adj+Ctl {
        let nEdges = Length(edges);
        let colors = Chunks(2, colorsRegister);
        use conflictQubits = Qubit[nEdges];
        within {
            for ((start, end), conflictQubit) in Zipped(edges, conflictQubits) {
                MarkColorEquality(colors[start], colors[end], conflictQubit);
            }
        } apply {
            (ControlledOnInt(0, X))(conflictQubits, target);
        }
    }


    operation ApplyMarkingOracleAsPhaseOracle(
        markingOracle : ((Qubit[], Qubit) => Unit is Adj), 
        register : Qubit[]
    ) : Unit is Adj {
        use target = Qubit();
        within {
            X(target);
            H(target);
        } apply {
            markingOracle(register, target);
        }
    }


    operation RunGroversSearch(register : Qubit[], phaseOracle : ((Qubit[]) => Unit is Adj), iterations : Int) : Unit {
        ApplyToEach(H, register);
        
        for _ in 1 .. iterations {
            phaseOracle(register);
            within {
                ApplyToEachA(H, register);
                ApplyToEachA(X, register);
            } apply {
                Controlled Z(Most(register), Tail(register));
            }
        }
    }


    @EntryPoint()
    operation SolveGraphColoringProblem() : Unit {
        // Graph description: hardcoded from the example.
        let nVertices = 5;
        let edges = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3), (3, 4)];

        // Define the oracle that implements this graph coloring.
        let markingOracle = MarkValidVertexColoring(edges, _, _);
        let phaseOracle = ApplyMarkingOracleAsPhaseOracle(markingOracle, _);

        // Define the parameters of the search.
        
        // Each color is described using 2 bits (or qubits).
        let nQubits = 2 * nVertices;

        // The search space is all bit strings of length nQubits.
        let searchSpaceSize = 2 ^ (nQubits);

        // The number of solutions is the number of permutations of 4 colors (over the first four vertices) = 4!
        // multiplied by 3 colors that vertex 4 can take in each case.
        let nSolutions = 72;

        // The number of iterations can be computed using a formula.
        let nIterations = Round(PI() / 4.0 * Sqrt(IntAsDouble(searchSpaceSize) / IntAsDouble(nSolutions)));

        mutable answer = new Bool[nQubits];
        use (register, output) = (Qubit[nQubits], Qubit());
        mutable isCorrect = false;
        repeat {
            RunGroversSearch(register, phaseOracle, nIterations);
            let res = MultiM(register);
            // Check whether the result is correct.
            markingOracle(register, output);
            if (MResetZ(output) == One) {
                set isCorrect = true;
                set answer = ResultArrayAsBoolArray(res);
            }
            ResetAll(register);
        } until (isCorrect);
        // Convert the answer to readable format (actual graph coloring).
        let colorBits = Chunks(2, answer);
        Message("The resulting graph coloring:");
        for i in 0 .. nVertices - 1 {
            Message($"Vertex {i} - color {BoolArrayAsInt(colorBits[i])}");
        }
    }
}

6. 관련 문서

7. 외부 링크


[1] IBM에서 개발한 Python 기반 양자컴퓨팅 언어이다.