cs3102 theory of
play

CS3102 Theory of Computation Warm up: Is this function computable - PowerPoint PPT Presentation

CS3102 Theory of Computation Warm up: Is this function computable with a NAND-Circuit? = 1 if UVA wins against ND tonight 0 otherwise Logistics Quiz 3 out Due Thursday Exercise 3 is out Last exercise


  1. CS3102 Theory of Computation Warm up: Is this function computable with a NAND-Circuit? 𝑔 𝑏 = 1 if UVA wins against ND tonight 0 otherwise

  2. Logistics β€’ Quiz 3 out – Due Thursday β€’ Exercise 3 is out – Last exercise before midterm 2

  3. Last Time β€’ Showing that NAND/AON can compute any finite function β€’ Started showing how we could have a function that simulates programs 3

  4. How are programs run? β€’ Have a table of variables β€’ Execute code in sequence β€’ Update values in table β€’ Return a value from the table 4

  5. Programs as Bits β€’ To evaluate a program with another program, we need to convert the first program into bits 1. Number each variable (first n go to input, last m to outputs) 2. Represent each line as 3 numbers (outvar, in1, in2) 3. Represent program as (n,m,[Lines]) Variable Number a 0 (2,0,0) b 1 (3,1,1) temp1 2 (4,2,3) temp2 3 (2,1,[(2,0,0),(3,1,1),(4,2,3)]) return 4 5

  6. XOR to bits Variable Number π‘œ = 𝑛 = 𝑑 = Total bits = 6

  7. XOR to bits Variable Number a 0 b 1 u 2 π‘œ = 2 v 3 𝑛 = 1 w 4 𝑑 = 4 return 5 Total bits = 3 [numbers per line] β‹… 3 [bits per number] β‹… 4[lines] + 6 [length of π‘œ + 𝑛 ] 7

  8. How big is this? 1. Number each variable ⌈log 2 3π‘‘βŒ‰ bits each 2. Represent each line as 3 numbers (outvar, in1, in2) 3𝑑 β‹… ⌈log 2 3π‘‘βŒ‰ bits 3. Represent program as (n,m,[Lines]) 2⌈log 2 π‘‘βŒ‰ bits 𝑇 𝑑 ≀ 4π‘‘βŒˆlog 2 3π‘‘βŒ‰ β„“ = ⌈log 2 3π‘‘βŒ‰ 8

  9. Defining EVAL πΉπ‘Šπ΅π‘€ 𝑑,π‘œ,𝑛 : 0,1 𝑇 𝑑 +π‘œ β†’ 0,1 𝑛 Input: bit string representing a program (first 𝑇(𝑑) bits) plus input values (remaining π‘œ bits) Output: the result of running the represented program on the provided input, or 𝑛 0's if there's a "compile error" 9

  10. π‘œ = 2 Defining the EVAL function 𝑛 = 1 Variable Value Representation: 0 (2, 0, 1), (3, 0, 2), (4, 1, 2), 1 (5, 3, 4) 2 Input: 0, 1 3 4 5 10

  11. Psuedocode for EVAL π‘ˆ β€’ Table π‘ˆ : – holds variables and their values β€’ π»πΉπ‘ˆ(π‘ˆ, 𝑗) – Returns the bit of π‘ˆ associated with variable 𝑗 β€’ π‘‰π‘„πΈπ΅π‘ˆπΉ(π‘ˆ, 𝑗, 𝑐) – Returns a new table such that variable 𝑗 's value has been changed to 𝑐 11

  12. Psuedocode for EVAL β€’ Input: Let π‘ˆ be table of size 𝑒 Numbers π‘œ , 𝑛 , 𝑑 , 𝑒 For 𝑗 in range( π‘œ ): – representing the number of π‘ˆ = UPDATE( π‘ˆ , 𝑗 , 𝑦[𝑗] ) inputs, outputs, variables, For ( 𝑗 , π‘˜ , 𝑙 ) in 𝑀 : and lines respectively 𝑏 = GET( π‘ˆ , π‘˜ ) 𝑀 , a list of triples – 𝑐 = GET( π‘ˆ , 𝑙 ) representing the program π‘ˆ = UPDATE( π‘ˆ , 𝑗 , NAND( 𝑏 , 𝑐 )) A string 𝑦 to be given as input – For 𝑗 in range( 𝑛 ): to the program 𝑍 [ 𝑗 ] = GET( π‘ˆ , 𝑒 βˆ’ 𝑛 + 𝑗 ) β€’ Output: Return 𝑍 – Evaluation of the program represented by 𝑀 when run on input 𝑦 12

  13. EVAL in NAND β€’ Next we implement πΉπ‘Šπ΅π‘€ 𝑑,π‘œ,𝑛 using NAND 13

  14. π»πΉπ‘ˆ(π‘ˆ, 𝑗) β€’ Get the bit at β€œrow” 𝑗 of π‘ˆ β€’ Look familiar? β€’ How many gates to implement? 14

  15. UPDATE π‘‰π‘„πΈπ΅π‘ˆπΉ β„“ : 0,1 𝑑 β„“ +β„“+1 β†’ 0,1 2 β„“ β€’ To change index 𝑗 of table π‘ˆ to bit 𝑐 β€’ For every index except 𝑗 , return the same value β€’ For index 𝑗 , return b instead β€’ Define 𝐹𝑅𝑉𝐡𝑀 π‘˜ : 0,1 β„“ β†’ {0,1} which returns 1 if the input binary number is equal to j Note: 𝐹𝑅𝑉𝐡𝑀 π‘˜ can be done in 𝑑 β‹… β„“ gates 15

  16. UPDATE pseudocode For π‘˜ in range( 2 β„“ ): 𝑏 = 𝐹𝑅𝑉𝐡𝑀𝑇 π‘˜ (𝑗) Runs 2 β„“ times π‘œπ‘“π‘₯π‘ˆ[π‘˜ ] = 𝐽𝐺(𝑏, 𝑐, π‘ˆ[π‘˜]) Return π‘œπ‘“π‘₯π‘ˆ 16

  17. Conclusion β€’ What we know: – We can compute any finite function with circuits – We can compute a function to evaluate programs of a certain size β€’ Big question: – How expensive are functions? – Some are more expensive than others, how big could they get? – If I wanted to be able to evaluate a program for any function 0,1 π‘œ β†’ {0,1} , how big would the eval circuit need to be? 17

  18. Complexity β€’ The "complexity" of a function: – Measure of the resources required to compute that function β€’ Complexity Class: – A set of functions defined by a complexity measure 18

  19. Categorizing Functions by Circuit Size β€’ No functions require more than 𝑑𝑛2 π‘œ gates – Proved last class β€’ Some functions require much less – E.g. IF β€’ Observation: some functions are more "complicated" than others! β€’ Idea: categorize functions by resources required to implement them using a particular computing model 19

  20. SIZE β€’ π‘‡π½π‘ŽπΉ(𝑑) : The set of all functions that can be implemented by a circuit of at most s NAND gates π‘‡π½π‘ŽπΉ(1000𝑛2 π‘œ ) Contains all functions 𝑔: 0,1 π‘œ β†’ 0,1 𝑛 β€’ TCS also uses: – π‘‡π½π‘ŽπΉ π‘œ,𝑛 𝑑 :The set of all π‘œ -input, 𝑛 -output functions that can be implemented with at most 𝑑 NAND gates – π‘‡π½π‘ŽπΉ π‘œ 𝑑 : The set of all π‘œ -input, 1 -output functions that can be implemented with at most 𝑑 NAND gates 20

  21. Comparing Classes If 𝑦 ≀ 𝑧 , then π‘‡π½π‘ŽπΉ 𝑑 βŠ† π‘‡π½π‘ŽπΉ(𝑧) 21

  22. Theorem β€’ Let π‘‡π½π‘ŽπΉ 𝐡𝑃𝑂 𝑑 represent the set of all functions that can be computed using at most 𝑑 AND/OR/NOT gates π‘‡π½π‘ŽπΉ 𝑑 2 βŠ† π‘‡π½π‘ŽπΉ 𝐡𝑃𝑂 𝑑 βŠ† π‘‡π½π‘ŽπΉ 3𝑑 22

  23. Proof π‘‡π½π‘ŽπΉ 𝑑 2 βŠ† π‘‡π½π‘ŽπΉ 𝐡𝑃𝑂 𝑑 βŠ† π‘‡π½π‘ŽπΉ 3𝑑 23

  24. O, Ξ©, Θ β€’ Groups functions together β€’ Each uses a function as a bound for other functions β€’ O (Big-Oh): – O(f(n)) = the set of all functions "asymptotically upper-bounded" by f β€’ Ξ© (Big -Omega): – Ξ©(f(n)) = the set of all functions "asymptotically lower-bounded" by f β€’ Θ (Big -Theta): – Θ(f(n)) = the set of all functions "asymptotically tight -bounded" by f 24

  25. 25

  26. Definitions β€’ 𝑃(𝑕 π‘œ ) β€’ At most within constant of 𝑕 for large π‘œ β€’ {𝑔: ℝ β†’ ℝ|βˆƒ constants 𝑑, π‘œ 0 > 0 s.t. βˆ€π‘œ > π‘œ 0 , 𝑔 π‘œ ≀ 𝑑 β‹… 𝑕(π‘œ)} β€’ Ξ©(𝑕 π‘œ ) β€’ At least within constant of 𝑕 for large π‘œ β€’ {𝑔: ℝ β†’ ℝ|βˆƒ constants 𝑑, π‘œ 0 > 0 s.t. βˆ€π‘œ > π‘œ 0 , 𝑔 π‘œ β‰₯ 𝑑 β‹… 𝑕(π‘œ)} β€’ Θ 𝑕 π‘œ β€’ β€œ Tightly ” within constant of 𝑕 for large π‘œ β€’ Ξ© 𝑕 π‘œ ∩ 𝑃(𝑕 π‘œ ) 26

  27. Showing Big-Oh β€’ To show: π‘œ log π‘œ ∈ 𝑃 π‘œ 2 27

  28. Showing Big-Omega β€’ To Show: 2 π‘œ ∈ Ξ© π‘œ 2 28

  29. Showing Big-Theta β€’ To Show: log 𝑦 π‘œ = Θ log 𝑧 π‘œ 29

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend