Computation 정의하기

Pyro·2021년 10월 2일
0

계산이론

목록 보기
4/5

computation 이란, 요구사항인 function 을 컴퓨터가 실제로 수행할 수 있도록 만든 구현체이다.
computation 을 구현하려면 다음 2가지 중에 하나를 하면 된다.

  1. Circuit 을 구현한다. == 빵판에 납땜 가능한 회로도를 작성한다.
  2. 알고리즘을 구현한다. == 프로그램을 코드로 작성한다.

Circuit 이라 하면 AND / OR / NOT 게이트를 가진 Boolean circuit 을 말한다.
프로그램 또한 AND / OR / NOT 연산자로 이루어진 AON-CIRC 프로그램을 말한다.

재밌는 점은 NAND 한개만 있으면, AND / OR / NOT 3가지를 전부 표현 가능하다는 점이다.
그러므로 NAND Circuit 회로도를 작성하거나,
NAND-CIR 프로그램을 코드로 작성하는게 computation 을 구현하는 가장 일반적인 방법이라 할 수 있다.

또한, Circuit 을 구현하는데 필요한 gate 의 숫자와, 프로그램을 구현하는데 필요한 코드 줄 수가 동일하다.

아래 증명은 Circuit 이나 프로그램이나, 그게 그거라는 것을 증명으로 보인 것이다.

Definition (Boolean Circuits)

n,m,sNn,m,s \in \mathbb{N} and msm \leq s
DAG : directed acyclic graph
A Boolean circuit with s gates, n inputs, and m outputs
is a labeled DAG G=(V,E)G=(V,E) with s+ns+n vertices.
size of a Boolean circuit = number of gates = s

Definition (Computation)

f:{0,1}n{0,1}mf:\{0,1\}^n \rightarrow \{0,1\}^m is a function.

CC is a Boolean circuit with nn inputs and mm outputs.
PP is a AON-CIRC program of s lines with n inputs and m outputs.

CC computes ff if C(x)=f(x)C(x)=f(x) for x{0,1}n\forall x\in \{0,1\}^n
PP computes ff if P(x)=f(x)P(x) = f(x) for x{0,1}n\forall x\in \{0,1\}^n

Theorem 3.9 (Equivalence of circuits and programs)

n,m,sNn,m,s \in \mathbb{N} and msm \leq s
f:{0,1}n{0,1}mf:\{0,1\}^n \rightarrow \{0,1\}^m
CC: Boolean circuit with ss gates, nn inputs and mm outputs
PP: AON-CIRC program of ss lines with nn inputs and mm outputs

f is computable by CC     \iff f is computable by PP

Proof

(i) f is computable by CC \Rightarrow f is computable by PP
pf
If operator of ii-th of P has the form "foo = AND(bar,blah)"
then the ii-th gate in the circuit will be an AND gate
that is connected to gates jj and kk
where jj and kk correspond to the last lines before ii
where the variables "bar" and "blah" were written to.

If either "bar" or "blah" is an input variable then we connect the gate to the corresponding input vertex instead.
If "foo" is an output variable, then we add the same label to the corresponding gate to mark it as an output gate.
Do the same for OR and NOT operation.
\therefore P(x)=C(x)P(x) = C(x) for x{0,1}n\forall x\in \{0,1\}^n.

(ii) f is computable by CC \Leftarrow f is computable by PP
pf
v0,,vs1v_0,\ldots,v_{s-1} : sorted the gates according to a topological order.
Create program PP of ss lines as follows. \medskip
If viv_i is an AND gate with in-neighbors vj,vkv_j,v_k,
then we will add a line to PP of the form "outputioutput_i = AND(inputjinput_j, inputkinput_k)"
Because we work in topological ordering, we are guaranteed that the in-neighbors vjv_j and vkv_k correspond to variables that have already been assigned a value.

Do the same for OR and NOT gates.
\therefore C(x)=P(x)C(x) = P(x) for x{0,1}n\forall x\in \{0,1\}^n.

Theorem 3.10

AND, OR, and NOT can be computed only by composing NAND functions.

NAND(a,b)=NOT(AND(a,b))={0a=b=11otherwiseNAND(a,b) = NOT(AND(a,b)) = \begin{cases} 0 & a=b=1 \\ 1 & \text{otherwise} \end{cases}

Proof

NOT(a) = NOT(AND(a,a)) = NAND(a,a)
AND(a,b) = NOT(NOT(AND(a,b))) = NOT(NAND(a,b))
OR(a,b) = NOT(AND(NOT(a),NOT(b)))

Theorem 3.17 (NAND circuits and program equivalence)

n,m,sNn,m,s \in \mathbb{N} and msm \leq s
f:{0,1}n{0,1}mf:\{0,1\}^n \rightarrow \{0,1\}^m
CC: NAND circuit with ss gates, nn inputs and mm outputs
PP: NAND-CIRC program of ss lines with nn inputs and mm outputs
f is computable by CC     \iff f is computable by PP

Proof

From Theorem 3.9,
f is computable by Boolean circuit     \iff f is computable by AON-CIRC program

From Theorem 3.10,
f is computable by NAND circuit     \iff f is computable by Boolean circuit
f is computable by NAND program     \iff f is computable by AON-CIRC program

\therefore f is computable by NAND circuit     \iff f is computable by NAND program.

profile
dreams of chronic and sustained passion

0개의 댓글