### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# Introduction to Computing Explorations in Language, Logic, and Machines CS 1120

UVA

GPA 3.71

### View Full Document

## 37

## 0

## Popular in Course

## Popular in ComputerScienence

This 67 page Class Notes was uploaded by Mrs. Carolyne Abbott on Monday September 21, 2015. The Class Notes belongs to CS 1120 at University of Virginia taught by Grigori Humphreys in Fall. Since its upload, it has received 37 views. For similar materials see /class/209641/cs-1120-university-of-virginia in ComputerScienence at University of Virginia.

## Reviews for Introduction to Computing Explorations in Language, Logic, and Machines

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/21/15

Class 26 Modeling Computing 532 2 cupJew How convincing is our Halting Problem proof denne mined x if new mined nuii iuuDrfuieveY 1 mined ennui ewsi EveYYthiriE we used Lei nieie it eweepi haits7 dues exist meiereiie haits7 ennui east in my me iteme exixi sndi mmienii DrScheme is oraneme a pmuf mat Scheme exise7 Solutions Optiuri 1 Pruve Ideaiized anemewuesexist em mime 3 s dine pendimi e winiid 7 DH iine m mi iine 25d 9e iine d s 1 35 n 19 in ad dimi e quotminim x Du iine esxs mi iine 3585 g iine d ummsnsesem s dine pendimi e quotmind a crashes iuies oniiein 2 Find Sume Simpier Cumputing mudei rDefine it DietiseiY rShuW that buried an be de ned in this mudei Modeling Computation Fur a mere cunvincing pieeif we need a mere precise but Simpie mudei ufwnat a Cumputer can do Anuiher ieasein we need a mudei e Cumpiexity reaiiy make sense With ut 157 new dei we knew What a Step is7 He ihey die Same ieii aH cumputem Modeling Computers 0 Input Without it we can t describe a problem 0 Output Without it we can t get an answer 0 Processing N ed some way of getting from the input to Camputing s normell done by Writing certain snbuls m paper We may me wmut suppose this pyer s awed ntu squares like a child s a lt m l book Alan Turing On Mamie nunbers With an applicatinn m the 0 Memory Emshemngyubem 1935 e doing Need to keep track of what we ar 5 i caught Simplest Input 0 oninteractive like punch cards and paper tape 0 Onedimensional just a single tape of values pointer to one square on tape lll l lllll l lll l l l l How long should the tape be In nitely long We are modeling a computer no buil ing one Our model should not have silly practical limitations like a real computer does surreyer m7 Mu mama l mommy m7 Mu mama V v A m w WWW 9 m i 390ku stings Modeling Processing Modelmg output 0 Evaluation Rules Given an input on our tape how do we 0 Blinking lights are 039 but hard to evalLate to produce the output model 0 What do we need 0 Output is what is written on the tape at the end of a computation Read what is on the tape at the current square Write into the current square Move the tape one scpare in either direction IIIDIDIIIIIDIDIIIDIDIDII email mm cm 99 Is that enougw to model a computer 11 39 12 i Comprte 53w Modeling Processing 0 Read write and move is not enough 0 We also need tn keep track of what we are doing How do we know whether tn read write or move at each step How do we know when we39re done 0 What do we need for this Finite State Machines mup lrr 5195 Hmmmmaybe we don t need those infinite tapes after all next input syrrbol is in state 2 How many states do we need not a not a pare paren not a 3m 1 2 paren m a 3 Daren ERRO R HALT 4 Finite State Machine 0 There are lots of things we can t compute with only a finite number of 0 Solutions In nite State Machine Hard to describe and draw Md an infinite tape to the Finite State Machine Turing s Explanation We have said that the calculable by nite means For the prsent 1 I shall only say that the justi cation lies in the fact g that the human memory is necssarily limitedquot wit ampnu Menu Environments Evaluation Rules mm my rm u m 2 i Comptie define nest lambda x X Eifbesstimteionmodel X ofevaluationtell gt nest 3 4 this 8 us how to evaluate Names Places Mutation A name is a place for storing a value define creates a new place cons creates two new places the car and the cdr set name expr changes the value in the place name to the value of expr setcar pairexpr changes the value in the car place ofpairto the value of ex r setcdr pair expr changes the value in the cdr place ofpairto the value of expr WWW mm mm a a msmmw mm mm a com Lambda and Places 0 lambda x also creates a new place named x The passed argument is put in that place gt define x 3 gt lambda x x 4 4 OW a H re these places different Location Location Location Places live in frames An environment is a pointer to a ame We start in the global environment Application creates a new frame All 39ames except the global frame have exactly one parent 39ame swarmml Mm mum 5 s a smart gabal mvumment Environments The global environment pulnts m the outermost frame gt define X 3 lt starts Wlth all Scheme prlmltlvES gabal mvumment Procedures gt de ne double lambda x x x swimmm Mm mum 1 a i smug How to Draw a Procedure Procedures A procedure needs both code and an environment gabal v We ll see w E t We draw procedures like this p Vn t r mE Cude Winter gt de ne double t xx lambda x x x pgrimef xx smipnr imimmu mm 9 atomquot guru mmmmmwm mm m atomquot chtnu New Rule Application Applloatlon 1 Construct a new 39ame parented by Old I s b d I the current environment P m e39 u smunon mo 6 2 Create places in F with the names of each parameter Apply Rule 239 compounds quotthe 3 Put the values ofthe parameters in those procedure is a com ound r c dure laces evaluate the body of the procedure with p each formal parameter replaced by the 439 set the current frame t F corresponding actual argument expression 5 EValualel 6 body value 6 Set the current frame to P 7 Discard F swimmm Mm mum u 12 Class 30 Vocational Skills x csxsu consummate hm mmmma mu Scqu 6129 HumvhveVS 391 camp TrickorTreat nirmwmmgu GhostintheMiddle Attack wrmk w rm new r rm mm 5 Meet w one e mum w 9 keaemm RHeltreer1 Who Invented the Internet intemetwork A collecuon of muluple neoworks netw orks The First intemet 1800 Sweden and Denmark Worned about Brltall v ll lvadll lg across shalt thew slgnallng telegraph networks 1801 Brltlsh attack Copenhagen network ansmt message to Sweden but they don t hel Denmark slgns treaty wmn Brltaln and stops ni mr39yrriz zu First Use of Internet 0 October 1969 First packets on the ARPANet from UCLA to Stanford Starts to send quotLOGINquot but it crashes on the G o 20 July 1969 Live video bw and audio transmitted from moon to Earth and to millions of televisions de worldWI The Modern Internet 0 Packet Switching Leonard KleinrockUCLA thinks he did Donald Davies and Paul Baran Edelcrantz s signalling network 1809 sort of 39d it 0 Internet Protocol Vint Cerf Bob Kahn 0 Vision Funding JCR Licklider Bob Taylor 0 Government Al Gore rst politician to promote Internet 1986 act to connect government networks to form Interagency Networkquot r Kahn and Cerf s Answer Al Gore was the first political leader to recognize the importance of th Internet and to promote and support its development No one person or even small group of persons exclusively quotInventedquot the Internet It is the result of ma ears of ongoing collaboration among people in government and the university community But as the two people who designed the basic architecture and the core protocols that make the Internet work we would like to acknowledge VP Gore39s Resident No other elected of cial to our knowledge has made a greater contribution over a longer period of time 10 man Govern ment and Networking Chappe wanted a commercial network novel methods that modliy established l39lablB often has the supportlt lr efforts are tstallylrsumoentm allow the new loeas to be rully explated Oaude unaboe 1524 Anyone performng unautho als from rlzed u so soragn one place to another Wlth the aid or telegraphlc maenlnes or by any other means Will be bunlsneo Wlth an lrrprlsol39lrnel39lt or ne rnontln to one year and a ne or 1000 to 10000 Francs The World Wide Web Memex Macnlne Vanneyar Bush As We May Tlnlnk LIFE 1945 Licklider and Taylor s Vision Available Wlmn one network will be fu cu s arrd services to whrdn rner counseling selecuve dlssemglrlanorl orrnrorrnanon rn your eld oalrzauon announcementof mural s ort and entertainmenteverlts 39lat tyou rrmeresls em lrr me later goLp wrll be clcuonarres enodopedas lndegtes catalogues edlung programs teadnrrrg proga rns tesurrg progarns programrmrrg rllca dat coherent you will be able o get along In one baslc langJa up to the point at which you choose a specialized langjage for is power or terseness 1 C RrLlelldevandRaheth laylavrihetamvuhev The World Wide Web 0 Tim BernersLee CERN Swilzerland 0 First web sener and client 1990 0 Established a common language for sharing information on computers 0 Lots of previous attempts Gopher WAIS Archie Xanadu etc as a ammunltatlan Deylcer Am 1965 n World Wide Web Success 0 World Wide Web succeeded because it was simple Dich t attempt to maintain lirks just a common way to name thin s Lh or e Loca l www d 5150 lnde SewCe Husmani File Path HyperTeXt Transfer Protocol HyperText Transfer Protocol A Apache Server an ES5UlrldEx html HTTP1 u Concene or le Clent Browser HTNL HyperText Markup Language mower oo Popular Web Site Strategy 1 Static Authored Web Site Weo Pvaqvamm er Content Producer Popular Web Site Strategy 2 Dynamic Web Applications Woo quvammevr Content Producer easy in 1987 quot name newnmmowwmemew Popular Web Site Strategy 2 Dynamic Web Applications Seed content and function no A Advantages 0 Users do most of the work 0 Ifyou re lucky they might even pay you for the privilege Disadvantages 0 Lose control over the content you might get sued for things your users do a 0 Have to know how to program a web eBay in 2005 application ll 39 d l39 39 m Com uter Science 3150 Fa 2005 Lecture 32 Dynmic w App cations 19 lull pM ml U V M m 39 39 mi quot6 userverPagei mime I e 39 DLiMMIES Google DUMMIES e 32 Dynamic Web Applica Vocational Skills Job listings at monstercom 2 Nov 2005 within 100 miles of Charlottesville SQL more than 1000 within 100 miles 80400K Python 20 within 100 miles 40150K HTM L 427 3050K Scheme 5 400K Loan Officers Mortgage Brokers All Experience Levels Needed A performance based incentive scheme including company carquot Salaw 400000year Note none for Scheme programming language 3150 Fall 2005 Lecture 32 Dynmic Web Applications 21 39939 Com uter Science m P mm HTML HyperText Markup Language 0 Language for controlling presentation of web pages 0 Uses formatting tags Enclosed between lt and gt 0 Not a universal programming language Proof no way to make an in nite loop c5150 Fall 2005 Lecture 32 Dynamic Web Applications 72 m Computer Suenqe M rm in l V HTML Grammar Excerpt Document lthtmlgt Header Body lthtmlgt Header ltheadgt HeadElements ltheadgt HeadElements H eadElement HeadElemenLi HeadElements HeadElement lttitlegt Element lttitlegt Body ltbodygt Elements ltbodygt Elementx Element Elements Elementx Element ltpgt Element ltpgt Make Element a paragraph Element ltcentergt Element ltcentergt Center Element horizontally 0n the page Element ltbgt Element ltbgt Display Element in bold What is a HTML interpreter Element Text 3150 Fall 2005 Lecture 32 Dynmic Web Applications 23 mi Compu Dynamic Web Sites Programs that run on the client s machine Java JavaScript Flash etc language must be supported by the client s browser so they are usually flaky and don t work for most visitors Used mostly to make annoying animations to make advertisements more noticeable Occasionally good reasons for this need a fancy interface on client side like Google Maps Programs that run on the web server Can be written in any language just need a way to connect the web server to the program Program generates regular HTML works for everyone c5150 Fall 2005 Lecture 32 Dynamic Web Applications 24 Dynamic Web Site Client Web Browser HTML nterpreterquot Dynamic Web Site FIle Server Read publlchtrrlhoorldesbro browsecgi A Sun Fall 2nns mm 32 Dynamlt we ADDIIKatmns 25 n 26 gm C mP 55 Processing a GEI39 Request wuyabmpymon prli it Hltl11gtRlde Listlth1gt form cglFleldStorageO print ltb3gtRldesOfferedltb3 9 to Client ride iable rides we 0 Python o A universal programming language Everything you can compute in Scheme you can compute in Python and vice versa Why should you believe this 0 Imperative Language Designed to support a programming where most of the work is done using assignment 0 ObjectOriented Language Built in support for classes that package data and procedures slsn Fall 2nns mm 32 Dynamlt we ADDIIKatmns 27 ll 23 if Cmnpor Learning New Languages Syntax Where the etc all go If you can understand a BNF grammar this is easy Semantics What does it mean Learning the evaluation rules Harder but most programming languages have very similar evaluation rules Style What are the idioms and customs of experienced programmers in that language Takes many years to learn Need it to be a professional Python programmer but not to make a useful program Python If Instruction if Expression tatements Evaluate Expression If it evaluates to true evaluate the Statements It is similar to if Expression begin Statements Differences Indenting and new lines matter Changing the indentation changes meaning of code Scheme anything that is not f Python anything that is not False None 0 and empty string or container A Sun Fall 2nns mm 32 Dynamlt we ADDIIKatmns 29 m an w mpvts sm z Class 33 0 Cookie Greg Hnwvhre li Why C are about Security Security Cun denuahty 7 Keepwng secres r vdettusev39s da Integnty 7 makng data rename samemmg yuu have 4m n a Li H rPhyswd key am atmunt7 7cm authunzed peuwe an mseVUmumW use Summmg yuu are Ava abmty erm ms vmtepvmt nqevpvmt 21 4mm ssthe Evan when mama Eariy Password Schemes Login Process mm igjziiam W m mm 5mm quota mmquot mmquot mm Password Problems 0 Need to store the passwords Dangerous to rely on database being cure Solve this today 0 Need to transmit password from user ost Dangerous to rely on Internet being 39 con dentia Solve this Friday First Try Encrypt Passwords Instead of storing password store password encrypted with secret K When user logs in encrypt entered password and corrpare to stored encrypted password may emrkuwxn Problem if K im39t so secret decryptK encryptK P P a i new 51er Hashing Many to one a ia l l b ues to a small number of hash es Eve l l r typical data see probability of Hgtlt n lN Where Nisthe u erofhash valuesaridri 0 N71 Ef cient W is easy to corrpute m Hchars Sioisal mod 10 Cryptographic Hash Functions Oneway Given h it is hard to nd x such that Hx h Call on resistance Given x it is hard to nd y s such that Hy HQ m i Compnu was Example One Way Function Input two 100 digit numbers x and y Output the middle 100 digiB Ofx y Given x and y it is easy to calculate y select middle 100 digils x y Givenfxy hard to nd x andy A Better Hash Function Hm encryth 0 o ka collision rsistance Given 6 it should be hard to findy x such ma Yes encryption is oneinone There is no such o A good hash function No ils output is as big as the message i2 3 Compler signage Actual Hashing Algorithms HaShEd Passwords 0 Based on cipher block chaining Start by encrypting 0 with the first block W quot 39 equot quotquot ep39 39 o SHA NIST95 512 bit blocks 160bit m hash o MDS Rivest92 512 bit blocks producs 128bit hash This is what we will use built in to PHP to inauwlasdate a Dictionary Attacks at least 86 of users are dumb 0 Try a list of common passwords All 14 letter war 5 Phone numbers license plates All of the above in reverse 0 Simple dictionary attacks retrieve most userselected passwords o Precompute Hx for all dictionary entries 5 Python Code emame as a salt sll lce they must be unlque usa Salt of the Earth The is the standard UNIX password scheme We use the us encryptedpass cryptth passwurd Salt 12 random blB Imam ne DESz 0 schemer39 2437 05525 0 LxL xquot 932 y DES m key salt ls an encrypuon algorlmm mat encrype m a way that depends on the salt How much harder is the offline dictionary attack 39 m i Compnu signage n Authenticating Users 0 User proves they are a worthwhile person by having a legitimate email addrss Not everyone who has an email address is worthwhile Its not too hard to snoop or intercept someone39s email 0 But provides much better authenticating than just the honor system Registering for Account 0 User enters email addrss 0 Sent an email with a temporary password md strrandom randth n 9999999 strrandom randth n 9999999 enema crypt crypt md strrandom randth D 99999 uses userTable treatster user email rrsmernes lasthame entmd smdMail smd email hmridesrbm ts v ginia edu Reset Password Your emsrene Smavame count has hem treated To login use m user i user w password entmd w From vKisterDmtess Eqi i mum serene Users and Passwords def treateUseVsel user email firstnamesr lasmamer Password r e selfdh WW 0 that r mam Dasswnrd es lastnamer Password 39 mm selfdh mmmil uer hetkPassandGelfr user Dassway r e u MSW o p ss avdFROM users WHERE user user enqud mm mm Dasswnrdr user return any raw 1 me use were meme AM new sue mew Cookies 0 HTTP is statelss ever requst is independent 0 Don39t want user to keep having to enter password ever time o A cookie is data that is stored on the brow er39s machine and s nt to the web server when a matching page is visited 3 cm sects U sing Coo kies 0 Look at the P88 provided code cookiespy 0 Cookie must be sent before any HTML is sent utilprintHeader dos 39 0 Be careful how you use cookies anyon can generate any data they want in a cookie Make SJI39e they can t be tampered with L58 md5 hash with secret to authenticate Don t reuse cookies easy to intercept them or o Proving you can rad an email account is steal them from disks use a counter that 039 900d enough 3910 aumen cate for changes every time a cookie is used 39 39 39 72 Problems Left 0 The database password is visible in plaintext in the Python code No way aroLnd this with UVa mysql server Anyone who can read UVa filesystem can access your database 0 The password is transmitted unenciypted over the Internet next class 2e i venture siege Lecture 4 Programming with Data Menu EVaMJaUOm Examp e Programming woo Data r uxsn mama 1 ny Gm mow juare 4 mung who mum you share mm mm huh y z w mum mmnm Anu mm I M mun mu mm mm l momma o J Emmwhm mum vautreAnn n o Nam rs Ways on Design Programs Than abuut mat you Want to do and m mat mu Cude 2 Than abuut mat you need to represent an meson yuur mde amund mat anch 5 better H39story of Scheme m GuYsze e ED39dESEHEd Stheme and treated the rst Sthane nteVDvebzv in Ms 4 Yea Dvulett Mme KENNY Stee e SDeU ed Java 1995 r Cnnmver T 73 a1 P anne 1957 Based on LISP John McCarthy 58 a Ca m us a d rMunzucnur rLasi few eaures m Cuurse LISP LOB of mod syuy Parenthesesquot LISt Processmg anguagequot Lots 32 wow mDuvtant rm In wnte a usouw smome pvooum W thuut mom Ma ki ng Lists Making a Pair gt cons 1 2 we 1 2 cons constructs a pair a aw s Splitting a Pair gt car onus 1 2 1 gt cdr cons 1 2 2 car extracts first part of a pair cdr extracts second part of a pair Why car and cd r 0 Original 19505 LISP on IBM 704 Stored cons pairs in memory registers car Contenls of the Addess part of the Register cdr Contenls of the Decrement part of the Register coulder 0 Doesn39t matter unless you have an IBM 704 0 Think ofthem as first and rest define first car we DvSheme may Big lenqu age alveadv de nes thesE but thev are rm Dav define rest cdr af standard Scheme 5mm MM Mummmm g a Comlmrg s gftx 6151mm MM Mummmm In a Comlmrg s gftx Pairs are fine but how do we make threesomes Triple A triple is just a pair where one of the parts is a pair de ne triple a b c cons a cons b 2 de ne t rst t car t de ne tsecond t car cdr t de ne tthird t cdr cdr t 2 i saw Quadruple A quadruple is a pair where the second part is a D39iple de ne quadruple a b c d cons a triple b c d de ne q rst q car q de ne q second q t rst cdr t de ne qthird t tsecond cdr t de ne qfourth t tthird cdr t Multuples o A quintuple is a pair where the second part is a quadruple o A sexmple is a pair where the second part is a quintuple o A septuple is a pair where the second part is a sextuple 0 An ocmple is group of octupi o A is a pair where the second part is a n I i anan Lists List cons Element List Lists List cons Element List A list is either a pair where the second part is a list or empty null A list is a pair where the second part is a list LISt quot its hard to Write l s A list is either 39 h th d t 39 l39 t One big problem how do was I or rrpagw ere esecon par IS a IS This only allows infinitely long lisls p unsaniimiuamn mammal 5 atom amniimiuamn mammal 5 Null List Examples gt null gt cons 1 null gt list null gt list cons 1 2 gt list cons 1null t 3 3 Camping Class 16 NPCompleteness How Did I Get Here Greg numpmeys WNW Menu 0 3SAT o omplexity class NPComplete o The Story so Far 0 Some NPComplete Problems mamm Mas Mama 2 iCmnpuue Problem Classes if P 2 NP Simulating Umverse 0013 Fmd Best ow How many Dmhle are in the m El 57 infinite How many Dmhlems are n p but not in the n Elass7 infinite How many Dmhlems at Sumng a aim np burn Klugn Sm leys mum 0a and 201 Problem Classes if P NP Simulating Umverse 0013 Fmd Best ow w many Dmhle Ha m5 are in the m El 57 infinite How many Dmhlems are n p but not inhe wtla 57 infinite Haw manvvmhlems Sumng o aveinNPhutnat niagn 7 Emmymm Mam quotForum a The 3SAT Problem 0 Input a sentence in propositional rammar where each clause is a disjunction of 3 names which may be d 0 Output Either a mapping from names to values that satisfies the input sentence or no way meaning there is no possible assignment that satisfies the input sentence mtg Clau Cl Em 52 3 SAT Example 2152 3152 y clauseZ m c 52 3152 i Z and lause laJs ml Clause lause Clause 2 3SAT avbv c A ua v b v d A ua v I v d A b v c v d a a true 1 false 0 false d false s i Cmmuuef 3SAT gt Smiley 0 Like 3stoneappIetower puzzle we convert every BSAT problem into a Smiley Puzzle problem 0 Transformation is more complicated but still polynomial time 0 So if we have a fast P solution to Smiley Puzzle we have a fast solution to BSAT also NP Complete 0 Cook and Levin proved that 3SAT was NP Complete 1971 e fake Seem to see new you know you went to o A problem is NPcomplete ifit is as hard as the hardst problem in NP 0 If 3SAT can be transformed into a different problem in polynomial time than that problem must also be NPcnmplete 0 Either all NPonmplete problems are tractable in P or none of them are a i amulet Problem Classes if P 2 NP Simulating Umverse 0013 Find Best em ew many preelen5 NP Cumplzte H are n tne at El 57 lnnnlte NatemeNPn Haw meWDmhlems 1 quot erelnpeetnet eesslsenne lntn wl 557 Sumng e P 7In mte Pop Quiz 0 What would we need to do to prove a problem is O n4 Flnd a preteeere tnat solves the preelern tnat ls 0m 0 What would we need to do to prove a problem is 9 n4 Prme that thee ls no preteeere tnet solves the emblem that ls f ter than ow mammal Meets momma 9 rmlyer same mammal Meets momma 1n rmlyer same Computer Science 0 Expanded De nition from Class 1 Study of information processes How to descrlbe lrlforrnauorl processes by de rllrlg proce ures How to predlct propeees about lrlforrnauorl processes How to elegantly and ef clendy lrnplernent lrlforrnauorl processes ln nardware and software wnat have we spent most of our erne on so far7 Where we ve been Where we re going n 39 Computer Science CS150 so far How to describe information processes by defining procedures 7 Programmng w 7 class 2 4 5 5 How to predict properties about information processes 7 Masuring work 5 o n complexlty classes 7 class 91011 12 1314 1515 How to elegantly and efficiently implement information processes in hardware and software 7 Class 3 rules of evaluation itn procedures lists recursion 7 8 9 1o 11 12 CS150 upcoming How to describe information processes by defining procedures 7 Programmng with mutauon objects databases networks How to predict properties about information processes 7 What are we counung wnen we measur w k7 7 Are there problem Whlch can39t be solved by procedures7 How to elegantly and efficiently implement information processes in hardware and software merit a Scheme interpreter 7 Not mucn in c5150 on nardware see cs2 7llow toimple 30 and C5333 Comp s Famous Computer Scientists o Ada rst computer scientist 0 Grace Hopper rst compiler 0 John Backus BNF Fortran 0 Tony Hoare Quicksort 0 Don Knuth Books 0 Bob Tarjan 0n MST Famous Computer Scientists 0 Bill Gets Did39l t invent Windows interface word processor PC etc mostly invented by Doug Englebart and XEROX Parc Business notion that people would pay for software for PCs Implemented a BASIC interpreter but didn t invent BASIC is a cmmgjmm is ComlmrrYl fc n55 NP Complete Problems NP Complete Problems Easy way to solve by trying all possible guesses given the yes39 answer quick in P way to check if it is right 7 Soluuon to puzzle see it it looks ri nt 7 Assignmene of values to names evaluate logical proposition in linear ume If given the no arswer no quick way to check if it is right 7 No soluuon can39t tell mere im39t one 7 No Way can39t tell thee isn39tone 3 i saw 5 Traveling Salesperson Problem Input a graph of cities and roads with distance connecting them and a minimum total distant Output either a path that visits ach with a cost less than the minimum or no 0 If given a path easy to check if it visits every city with less than minimum distance traveled Graph Map Coloring Problem Input a graph of nodes with edgs connecting them and a minimum number ofcolors Output either a coloring ofthe nodes such that no connected nods have the same color or no If given a coloring easy to check if it no connected nodes have the same color and the number of colors used 19 m i am Minesweeper Consistency Problem Input a position ofn squares in the game Minesweeper Output either a assignment of bombs tn squares or no 0 If given a bomb assignment easy to check if it is consistent Pegboard Problem smmmmvxm WU mm 2 a ram Pegboard Problem Input a con guration ofn pegs on a cracker barrel style pegboard Output ifthere is a sequence ofjumps that leaves a single peg output that sequence ofjumps Otherwise output false If given the sequence ofjumps easy On to check it is correct If not hard to knowi there is a solution Drug Discovery Problem In put a set of proteins a dsired 3D shape Output a sequence of proteins that produces the shape or impossible Caffeine If given a secpence easy not really to check if sequence has the right shape Note us Drug sales 200EWear Class 27 Universal 7 Turing Machines mva Turing Machine 1936 mm 7 khaiizisde 5 mm 7 ilzllailqlsde e Describing Finite State Machines imingmm lt thzhei was s m lt Sziex unxiiianwiex hiiizi zieMziiinShie s 2 mm 92mm wxibeeiemeni mime SieNamequotHi mi mien nmiimim 0F and M 0F am Example Turing Machine iie ltMnah iw pm I5Yrugimllli hRushmnainlqsnmgt m m 5 w Truslnihi ltltLLLYAgt ltL MAWLOgti hum Eriumerating Turing Machines New mat We ve decided huw m descrbe Turin mnines in T 023552375 T 7239683 ewen numbe er 1 T Winduww hmdq wall imzi hge Enumeration is Poweri39u We can sun TM s by ineir descriptiuri it e in drea worms 4 Efiritegers 7 E There is nu hupe DfWritirig pmgrans cu mmpute anytning in any set Winn a iarger cadnaiity rDuei this idea itiiiate yum Die quotWtiass m 92m 251w Universal Turing Machine p N umber Ompm ofTM Tape for ru nnln g I TMP Input on tape I Tape Can We make a Universal Turing Machine alsujus1 a numbeyi Yes 0 People have designed Universal Turing Machines with 4 symbols 7 states Marvin Minsky states 5 symbols 2 states Stephen Wolfram o No one knows what the smallst possible TM is a Manchester illuminated Unwevsal Turing Machine 9 fvum hth wwwvemsllltu cummanchesievmancheaev mm Church Turing Thesis 0 Any mechanical computation can be performed by a Turing Machine 0 There is a TM corresponding to ever decidable problem 0 We can simulate one step on any normal computer with a polynomial number ofsteps a TM If a problem is in P on a TM it is in P on an iMac CMS Cray Palm etc 9 But maybe not a quantum corrputer later class m 39 j Universal Language 0 Is Scheme as powerful as a Universal Turing Machine 0 Is a Universal Turing Machine as powerful as Scheme Complexity in Scheme SPECial Forms lfwehavelazyevalualiunand ircondde neenc iquot ilquot mquot o Primitives umbers infinitely many Boolea s t chtions and or etc 0 Evaluation Complexity Environments more than 2 of the eval code 12 A calculus Alonzo Church 1940 LISP was developed from A calculus not the other way round term variable l term term l term l A variable term 11 What is Calculus o In High School M x mm Power Rule M fg ma ng Sum Rule Calculus is a branch of mathematics that deals with limiis and the differentiation and integration of functions of one or more variabls Real De nition 0 A calculus is just a bunch of rules for manipulating symbols 0 People can give meaning to those symbols but that39s not part of the calculus 0 Differential calculus is a bunch of rules for manipulating symbols There is an interpretation of those s mbols corresponds with physics slopes etc Lambda Calculus 0 Rules for manipulating strings of symbols in the language term vanable l term term l term i Variable term 0 Humans can give meaning to those symbols in a way that corresponds in s compuiatlon 5 Is Why 0 Once we have precise and formal rules for manipulating symbols we can use it to reason with 0 Since we can interpret the symbols as reprsenting computations we can use it to reason about programs Evaluation Rules cxreduction renaming Ay Mgtu Av MUDMD where v does not occur in M reduction substimtion Mi1w BMHHN Lecture 9 of On and Off Groun s Sorting uxsn Mame in amew k 1 Greg Hrmv re li Menu I PS 2 Sorting I PS 3 Nut Just meant in review 5mm enema aiready Knuw 7 Wu m emiure new ideas rMutivate What is tunnnd MD in the tiass The main intu he p55 isleaning nut evaluan39on rDun39t dive up if Wu tan39t nd the answer in the bunk rDistuss with em slude P52 Question 3 mm is de ne nidnerrtard7 tardl tde gt tard1znk betber than de ne nidnerrtzd7 tardl tde gt tar and a m2 am tardrrznk amz PS Question 8 9 Predict new iung it wn take Identify ways in make it faster Muz mm week And iziev zizxxe Wu be Fozuxed an awzawuievmenmi pvedrd mm gun Wu Azke zid an awia We imam sun nidner Dussibienmds nuietards Can we do better de ne ndrbestrnand nuiertards mmmumbmrds 3 mm mm MUHiW39E3d5 artmm W aiming W find best ha nd define findbest hand lst if null cdr lst car ls t if higherhand car lst findbest hand cdr lst car lst findbesthand cdr lst Speaking Words of Wisdom let namel exprl name2 expr2 name3 expr3 body find best ha nd define Ifindbest hand lst if null cdr lst car st let I restbest findbesthand cdr lst 39 ig erhand car lst restbest car lst restbest de ne nsenl lst fsmpval findbest hand gig f a39 lsi insatl m lsi fsmpval define findbesthand lst insertl lambda handl handZ i igherhand handl handZ handl hand2 cd39 lst already Lsed fhe car as stopval car lst find best a nything define findbest anything cf lst insertl lambda c1 c2 if cf c1 c2 c1 c2 cdr lst car st define findbestanylhing cf lst insertl lambda c1 c2 if cf c1 c2 c1 c2 cdr lst car lst define findbest hand lst ndbest anything higherhand lst 2 E um How much work is find best anything Why not just time it no ampth small MM M n How much work is findbest anything de ne ndnbestnal39lydnll39lg cf lst ll39lserd lambda c1c2 0fcfc1c2c1c2 lst car lst Work to evaluate ndbest anything f Ist Evaluate insertl lambda c1 c2 Ist ate Is These don t dwend on the length Ufthe llst m We don t 32 about them Evaluate Work to evaluate insertl de ne lrlsertl f em smpval smpval r Ear lst Qnsenl f dr lst stcpval o How many times do we evaluate ffor a list of length n insertl is n Theta n if We double me lengln crane lls t We amount of work d approximately doubles requlre We Will see a more formal de l39lluol39l of e next class and a l A rnoul39ltofwork later misnr llmiuams M 5 atom amnllmiuams M 5 an ng Simple Sorting 0 We know how to ndbstanyming o How do we sort 0 Use ndbstanything tn nd the hat 0 Remove it from t e list 0 Repeat until the list is empty Simple Sort de ne sort cf Ist if null Ist Ist let best ndbestanything cf st cons best sort cf delete Ist best 3 i Cmnwuef smallmlmeg M n H Sorting Hands define sorthands Ist sort higherhand Ist Sorting de ne notestenwning tr ist inserti lambda t1 t2 rtrt1 2 t1 t2 lst car 50 de ne scrt t ist irnuirgt ist ist let rnost ndrtestrariy wirig tr ist tons must send delete stbest o How much work is sort 0 We measure work using orders of growth How does work grow with problem size sisaniimi Me Mr 15 m aming s de ne sort f ist or null7 lst ist Sorting let best ndrbestrarivmirig f lst COl iS est sort cf delete ist best 0 What grows n the number of elements in Ist o How much work are the pieces findbestanyihing is 9n delete is 9n o How many times does sort evaluate findbest anything and delete de ne sort cf lst null7 is l e Sorting t St t best ndsbest cf lst cons b sort cf delete ist best 0 n the number of elements in Ist o ndbestanything is n delete is n y times does sort evaluate nd best anything and delete E sort is nz lfwe double the iengdn of line list tine amount of v quadruples 5mm We M 2 merrmimmm 22 Comyu rth quot5 Timing Sort gt time sort lt reviriBto 100 opu urre 20 real one 20 g nine 0 gt u lt reviriBto 200 cpu one 80 ieai one so lC nine gt one sort lt reviriBto 400 0 gt time sort lt renneto 1500 cDu lime 6650 real lime 6650 gt lime 0 5mm We M m measured t Is our sort good enough Taks over 1 second in sort 1000length list How long would it lake in sort million items Ps3 4 N m m 2 nl Lindenmayer System Fractals 1M ls JDDEI quot JDDEI sanscmng mm was as many items Wlll lake munzumas as lung 1 mllllDrl seconds 11 days EDD Mllllm VISA cards n circulatan u would nae 2nunu years ca process a VISA h39msamm at this race as i equ L Systems L System CommandSequence CommandList Rewriting CommandList Command CommandList H Start F CommandLIst Rewrite Rule F a F 0R30 F F 0R 60 F F F Command RAngle Work like BNF replacement rule except ocummandsequence replace all ins1ances at once Command Why mm a better model for bluluglcal systems misnnllmiuams Saw 2 aromer Irma Smi llmlwm M 1 Level 0 Ve39 1 Start F Falrolmnnromsnnn Level 2 Level 3 F F omau F F omrau F F Lecture 8 Recursing Mm mum mummyquot Mommanu lam1 rm n an rt um Mom I mmymwm km s mg HWVVEVS Menu Recursive Procedues IMore GEB Chapter V n ibonacci Returns ARTNS Music arid Recursim De ning Recursive ProcecLIres 1 Be uptimistic e Assumevuutansuiveit rr M Dmbiem Think ortne simpiest versiun ortne pmbiem sonetnng you can aireaay soiye ans is tne base case 3 Cumbine them to soiye the pmbiem N Exarrple De ne ndtiusest guai nurnbes tnat eyaiuates co the nurnber in tne iist s nrkimexi znn iixi m um mu 2m 340 my Find Closest Nunber Be uptimstic A591 me you can aerne Find Best Match strategy mne neyy nurnber is better than the best Hiuri 1mm r u that rnas tne ciusest nurnber to guai trorn the iist ufnumbers vynat ifthere is one more nurnben Can you Write a tunaron that nds the ciusest nurnber to match trorn news nurnber and numbers7 nurnber Otherwise use the best matcn at the other numbes Optimistic Function de ne ndclosest goal nurrbers if lt abs goal car nunbers abs goa findclosest goal cd39 numbers 2 ar numbers findclosst goal cdr numbers Defining Recursive Procedures 2 Think of the simplest version of the problem something you can alrady solve If there is only one number that is the best match a iCmnpuut s The Base Case de ne ndclosest goal nunbers Same as befme de ne ndrtlusest geel nunbers lf 1 lmgth nurrbers tar numbes lf lt es 7 gbel tar numbers is 7 gbel ndtlusest gbel dr numbers Testlng tar nunbers ndtlusest gbel dr numbes gt findclosestnurrber 200 list 101 110120 201 340 588 20 1 gt findclosestnunber 0 list 1 gt findclosestnunber 0 list car eVpecS argument oi tvpe ltl39lol39lrempty llstgt glven 0 smmlmitmrel Hammers m remm s quot55 Seen Anything Like This de ne ndtestrmatzh semble tles EDlDr39EDNparamr r length tlles 1 lttnee ls pst bne tlle tar tlles tnet tlle ls the best matrn pltkrbetterrmatih o ewrse the best mettn ls semble eltne the rst tlle n tres tar tlles or the best mattn We WDuld nd fndrbestrmatzh tram lDDklrlg at tne rest brtne senble tlles Use pltktetter39matih dr tlles tb detemlne rmltn bne ls bette EDlCrtDmpa39at r EDlDr39mmpa39aLCr GEB Chapter V You could spend the rest of your life just studying things in thls chapter 25 pages Harm 0i 139 e Starks and Recursion r Theolo 7 Language Structure 7 Number Sequences Z E e c aos e Fractals PS3 7 uantum Electrodynamcs late lecture 7 DNA next to last lecture e Sarrlerlessrlrlrdlffererlme 2 i Campt s Fibonacci s Problem Filius Bonacci 1202 in Pisa Suppose a newlyrbom pair ofrabbits one male one female are put W a eld Rabbis mate at the age of one month so that at the end ofiB second month a female can produce another pair of rabbis Suppose that our rabbis never die and that the female always produces one new pair one male one female every month from the second month on How many pairs Wm there be li i one year7 Rabbits me htlv waw mts Suvmye ukPevsanelR KnalUFihanactifihnat html I i mower Fibonacci Numbers GEB p 135 These numbers are best defined recursively 7 F7L1F7L2 7Lgt2 F 1 otherwis Can We turn this into a Scheme procedure7 Nate sicP de nes no with mam u and nm e I rm base case Same function except rm nhm is undefined n esp version magnum Mm mm mam 5 a comquot Defining Recursive Procedures 5 de 3Retum5 1 Be optimistic Assume you can solve it If you could how would you solve a bigger problem 2 Think of the simplest version of the problem something you can already solve This is the base case 3 Combine them to solve the problem smmimi Mm mm mam Fibonacci Numbers in Scheme b n evaluats tn the nth Fibonacci number de ne b n if or n 1 n 2 1 base case b n 1 b n Z Fn71Fn72 ngt2 1 themse Fibo Results gt fibo 2 Why is this going gt fibo 3 wrong We could asin do this by gt flbo 4 hand 3 gt lm 10 To be conunded Monday answer is W SICP 12 gt fibo 100 Still working after 4 hours Recursive Transition Networks ORNATE NOUN 39 II Can we describe this Lsing Backus Naur Form Recursive Transition Networks ORNATE NOUN NOUN m ism s Recursive Transition Networks ORNATE NOUN guy m QWR gt fquot N m an ORNATE NOUN ORNATE NOU NOUN ARTICLE ADJECTIVE NOUN Recursive Transition Networks ORNATE NOUN 0 ORNATE NOUN ARTKQE ADJECTNE NOUN ORNATE NOUN ARTKQE ADJECTNE ADJECTIVE NOUN 6150 mm mm mm muw 2 a Comm 955 mmmimmmmm rm s quot55 Recursive Transition Networks ORNATE NOUN 1 Is ORNATE NOUN ARTKQE ADJECTNES NOUN ADJECTWES ADJECTNE ADJECT WES ADJECTWES Recursive Transition Networks ORNATE NOUN ORNATE NOUN onTARnaE ADJECTNES NOUN ADJECT WE ADJECHVES THE 7 OPTARTICLE OPTARTICLE ARTICLE 2 i saw 5 Recursive Transition Networks Usng extended BNF notation it m Mitts wJEIE VLEEQNQ E ORNATE NOUN ATE NOUN ARTICLE JADJEchE NOUN item is opuonal 0 or 10fthem itemquot 0 or more item VVHiCH riotauori is better7 More on Music Stacks z Hey Jude Verse V i2r Hey Jude Bridge m we Wu rei ire in hwiude m m ruin amt Emmi Mm mm New Emmi Mm mm New Verse Bridge HeVJude Verse VBBD VBBD Verse Verse Better Coda VBBD e Coda V rse Bridge Bridge Dadada ends on c F E St F Coda Music 0 Almost all music is like this RJshes and pops the listeners stack but doesn t go too far away from it Repeal similar patterrs in structured way Keeps coming back in Tonic and Enck on the Tonic 0 Any famous Battles song that doesn39t end Tonic A Day in the Life starts arr 6 ends arr E as Class 30 Greg Hnwvhre li Menu Lanbda 03mm Rewew Camputabmty n Tneury am Pracuce Leamng cu Cnunt mamm mm Viv Wm um rum 51m Mm mm new track mm Mummmmmsmmigiu 4mm havequot M m Don39t search for T search for if T a M Ly x a My x F a M A y y if a Apca pca Finding d1e Trud1 M 0 r7 aw x m mm in MN om mm mm 05 no mummy amm x7 MN 0 M77N2 M and and or andzkay ifxyF orzmay ifxTy Lambda Calculus is a Universal Computer Zl2l2lzlzlzlzlzlzlzlzlzlzlzlzlzlzlzlzlzl ReadWrite infinite Tape 7 Mutable Lists Finite State Machine 7 mbers m keep track at state Processing Way at making decision if 7 Way in keep going a El Fume style Machine Computability in Theory and Practice Intellectual Computability Discussion on TV Video a i MW are Ali G Multiplication Problem 0 Input a list on numbers with up to d digits each 0 Output the product ofthe 2 numbers Is it decida e Yes a straightforward algorithm solves it Is it tractable how much work Yes it using elementa multiplication techniques it is 0d2 Can real computers solve it 9 as 99 970298999029701 ssoaeeooaoaaAvod no on call What about C int main void Results from SunOS 5 E Value 999999999 Value 215752093 Value 115379273 Value 1462353861 intalig 999999999 printf Value dn alig a allg 99 a to l printf Value dn alig alig alig 99 printf Value dn alig alig alig 99 printf Value dn alig l munman m Mmmmmmhm 12 i to ku All G was Right Lambda Calculus is a Universal Computer 0 Theoryassums idealcomputers Z 392 I2 IZ IZ I2 IZ IZ IZ IZ IZ Z IZ IZ IZ IZ I2 392 IZ IZI Unlimited perfect memory I thimited finite time El y El 5 o ReadWrite infinite Tape 0 REI computers have 8 7 Mutable Lists El D Limited memory time Power outages aky quot Sm MMquot 7mm SlalselrlsatlthreZp track or state programming languages etc Processing There are many decidable problems we camot WW Bl Tamg dawn 0 olve with real computer the numbers do matter 39 av D eel 9mm 11 39 no gnawing What is 42 Meaning of Numbers 0 42nssquot is something who39s 42 successor is 43nssquot f0 o 42nssquot is something who39s predecessor is 41nssquot XL I I 0 Zero is special It has a successor cuarenta y dos o asquot but no predecesso 5 A Vn i Compnu Meaning of Numbers Meaning of Zero pred succ N Zero Zero a N a T succ pred N Zero succ Zero a a F succ pred succ N Zero pred succ Zero a T i Compnu Is this enough 0 Can we de ne add with pred succ Zero and Zero add a My if zero x y add pred x succ y Can we define lambda terms that behave like zero zero pred and succ Hint what if we had cons car and cdr i MW 5195 15 Numbers are Lists zero a null pred a cdr SUCCE Ax cons Fx Making Pairs de ne makepai x y lambda selector if selector x y de ne carof pair p p t de ne cdrof pair p p f 22 i Comonu trays cons and car cons and car cons E Axlykzzxy cons M N AxAyAzzxy M N a Bmum N gt BAzzMN cons a p AzzMN Ay x car 2 p T car cons M N 2 car AzzMN 2 App T AzzMN BAzzMN Ta BTMN a swam MN a 509 MN a BM 2a 3 MW strays cdr too My Null and null null EMT ca 392 Cd APIPF null Mlx ly lzf if c SMN null null am My M T c r AzzMN App F AzzMN B M nayMP BAzzMN F gt p39r BlMN z a inaugural Null and null Counting nullzkxT oznull nuEAxxAlezF 1200mm 2 E consF 1 392 null cons M N AxxkylzFAzzMN 320 st a BOLZZMNXAlezF F lm MN succ Ehmsonst u p F pred E hmer 2 m inmwqul 42 MyMz xy Myykxy0zzxykxyy mommy ozzmmyxwmwwymou Arlthmetlc xy xy ywozzxy xy yWOzzxyxy yMyOxzzxyxy ybryOxz whyy xyOxzzxnyy Oz Ky Ky 29r072nU 022WMyyhy022xybryybry02nyhy yhyOxzzxy MC mFX M MxyOxZZXy Way MXF Myylxyozzxybryyw02nybryyhy0uxybryy Myanmwywozzxybryyhy022xybryyhy0u mwywozzmw wmzzxnyyy MT a Bgtlzz Fnull F a BF Fnull n i cmng any Undecidable Problerrs v mm m m m MW Menu Rewew e Undendabllllv e Hdtm Pmblem Huw da we prme a prublem ls andecndable7 Amat da we da wnen faced wmn an undecldable prtblem7 Problem Classes if P NP Hal ng Problem De ne a pmcedure new dnat takes a pmcedure and an lnput evaluates ca M r dne prucedure wuuld termlnate an dnat npat and ea or lfwuuld nut termlnate de ne mal 7 pmcedure nnpao Informal Proof de ne r hal luu 0 1r ndm saVS ma aanad halts l duesn39t haltl bmed x a7 buned null pnfurever 1r ndm savs ma aanad duesnl ndt a halrsl Proof by Comradiction gnaw x ns nungenslcal 2 gnaw mat lfyuu have A and a ym can make X 3 gnaw dnat yuu can make A 4 Therefure B Rust nut eXlSt m 50mm Wean ma Mm lhe evzluzlmn rule My Undecidability Proof Evaluates to 23 Problem Input A procedure P and inputI Output true if evaluating PI would result in 23 false otherwise Evaluates to 2395 decidable Suppose we could de ne evaluatsto23 that decides it Then we could de ne halls define halts P I to23 if evaluates begin P I 23 t The only way it could run exaluate m 23 is if p I doesn t halt Note assqu p I amt produce f an arm Undecidability Proof Hello World Problem Input A procedure P and inputI Output true if evaluating PI would print out Hello Worldquot false otherwise Is HelloWorld decidable Suppose we could de ne helloworld that decides it Then we could de ne halis define halB P I if helloworld m a W 7 begin PI d h k print Hello World t f Easy Fix Be careful define whoopsie be in print hello worldquot loopforever gt halB whoopsie null t define halts P I if helloworld begin remove prints P I rint Hello World t f i um strays Proof by Contradiction 1 Show X is nonsensical 2 Show that ifyou have A and B you can make X 3 Show that you can make A 4 Therefore B must not exist X halls A a Scheme interpreter that follows the evaluation rules B helloworld From Paul Graham39s Undergraduau39on My friend Robertleamed a lot by wrmng network software wnen n Morris Internet Worm 1988 o P ngerd Hogam used to query user status Worm also attacked other progams 0 op EEI pLEhl 68732f pushl 6e69622f movl spr10 pushl 0 pushl 0 pushl r10 pushl 3 movl spap ch39nk quot isworm P I should evaluate m t o Worm infected several thousand computers 10 ofInternet in 1988 Worm Detection Problem Input A program P and inputI Output true ifevaluating P I would cause d a remote computer to be infecte Virus Detection Problem Input A program P and inputI Output true ifevaluating P I would cause a le on the host computer to be infected 5 i Compnu W35 Undecidability Proof Su pose we could de ne isworm Then define halB P I if isworm begin deworm P I wor de 1 an n is a Wcrm We know Wumrmde was exaluated and p Rust hall 0 The Wurmrcude would not exaluafE so u Rust not halt Can We malte a ewurm 7 Conclusion 0 AntiVirus programs cannot exist uTl e39AI lIOf Compute Virus Research and Defense PeterrSzor Symantec m i Compnu any I7 A cstsu Cam scxue m1 Umasxtvofwsm Cmu u t t Gveq Humvhveys Menu Review GDdEVS Thenrem Pmnfin Amman systems Computabihty Are ere some probiems that it is tmposstbie to Write a program to soive7 nprovabie then PM wouid be tncompiete PM cannot be complete and consistent GDdEIS Pmof w at does it mean for an axiomatic G This statement ofnumber theory system m be complete and consistent does not have any proof in the system f P 39 Derives all true If a were provabied1en PM wouid be ii iCOi iSstei it If G is u statemene and no faise statemene staru ng from a nite number of axioms o o no mechancai e mies twyotltw what does it mean for an axiomatic y m to be complete and consistent it means the axiomatic system is W eak ie is so Weak it cannot express This statement has no proof Why is an Inconsistent Axiomatic System less useful t a an Incomplete Axiomatic System quot WW some Inconsistent Axiomatic System Denves all true statements and some false and following mechanical inference rules erement e mm Once you an Wave one false 9 false Proof 0 A proof ofS in an axiomatic system is a sequence of strings TU T1 where The rst string is the axioms For all z from 1 tn n TW is the rsult of applying one ofthe inference ruls tn TM 7 TW is S o How much work is it to check a proof a i Mme Proof Checking Problem 0 Input an axiomatic system a set of axioms and infer ce ruls a statement S and a proofP containing n steps of S 0 Output true if P is a valid proofof S false otherwise How much work is a proofchecking procedure We can write a proofchecking procedure that is e n mmmms uneven camp1mm FiniteLength Proof Finding Problem 0 Input an axiomatic system a statement S n the maximum number of proof steps 0 Output A valid proof ofS with no more then n steps if there is one Ifthere is no proof of S with lt n steps nprnvahle At Worst We can try all possbie proofs How I inference rules 0 e n steps N r possible proofs much cheokrng each proof s e work So there is a pro but it mght not be the best one s a Camp acme Gmiruwlws uneven camp1mm m a Comyu tr Proof Finding Problem 0 Input an axiomatic system a statement S 0 Output IfS is true output a valid proof If S is not true output false How rruch work It is impossible It might take in nite workquot Go39del39s theorem says it cannot be done Computability n 2 i commie Algorithms vs Procedures o Proced u re 0 Algorith m A procedure that always terminates A precise mechanizable dscription ofa pmcss Computability o Decidable computable problems There is an alg 39 ess it doesn t mean w lg m ut there is o Undecidable proble There m doesn39t always termi o Is there an algorithm that solves a problem m tsolves the problem ke a photomosaic sorting drug discovery winning ch a orith ms The e is no algorithm that solves the prob em igwt be a procedure but it e IO i summer Are there any undecidable problems The ProofFinding Problem 0 Input an axiomatic system a statement S 0 Output IfS is true output a valid proof If S is not true output false mmmms maven camp1mm a some new Any others Hint how did We prove 3VSAT Was NP Complete once We knew Smiley Puz mswm mm WWW How would you prove a problem is undecidable zle Was7 5 a some Undecidable Problems 0 We can prove a problem is undecidable by showing that it is at last as hard as t e proof nding proble 0 Most famous The Halting Problem Input a procedue P described by a Scheme program and its input I u t true if executing P on Ihalls finishes execution false otherwi e Alan Turing 1912 1954 0 Codebrmker at Bletchley Park omputation now known as Tuing Machine After the w r Tried for and convicted of homosexLality Forced to undergo estrogen tre Corrrnitted wicide cyanide Halting Problem Examples gt halls lambda x x x 3 De ne a procedure halls that lak a t procedure and an input and evaluates to gt halls lambda x 39 th procedure would terminate on de ne f x fx f x that input and to f otherwi 27 f de ne halls procedure input Comping Halting Examples gt halls lambda x define fact n Can we de ne halts 0 We could fry for a really long time get 923 n 1 1 a n fact 39 n m something in work for simple examples 7 but could we solve the problem make it in work for all possible inpuls gt halls larrbda x define fact n if n 1 1 n fact n 1 fact x 0 0 Could we compute ndproof ifwe had halls f author975 Mow comp1mm swimx975 Mow comp1mm 22 lchealed a lillle herer l k nd We minim Another Proof define nd roof S ax39 rules If S isvaluafes to a proof of S d ne boned X Otherwise evaluates m f 39f hang boned nu if halls findproofexhaustive go39s forever S axioms rules findproofexhaustive S axioms rules If boned halls then if evaluales lo loopforever 0 It doesn39t hall Mere f ndprtufexhaustwe 5 axioms rules is a procedure ma mes all If boned doesn39t half then if evaluales to t possoo proofs snarling m the axioms that evaluates to a proof if it n ha s nds one and kews Working if it doesn t n 2a i L2an earninf gt5 Lecture 10 Quicker Sorting Menu ocompose and ntimes Measuring Work What 6 really means Quicker Sorting What does 6 really mean 0 0x it is no more than x work nd 0 x work scales as x tight bound 0 52x it is at least x work lower bound If 0x and 52x are true then x is true Meaning of 0 big Oh f 09x means There is a positive constant c such that cf lt M for all ac gt x0 mm mm mm mm a m s m is m mm o gac is an WW upper bound on f a 0 Examples x is 0 0 Yes e1wormne 10x is O x Yes E US works ne matter What we pick 2 X c gt x for big enoug x m n m rm m mm s E 2mm 4 Lower Bound 9 Omega f 09 and fac Qgac Examples xis 9 x 39 xis 0x means Yes pick 0 2 Yes pick 0 5 There is a positive constant c such that 10 is Qx 10 so x Yes pick 0 1 Yes pick 0 09 of 7 gt 9W Is x1 Q x 39 x2 is not 0 x for all ac gt 950 Yes Difference from o e this was lt smimmm New 1 a ames Tight Bound 6 I39heta 6 Examples 10 is 6 x 1 9 990 means Yes since 10 is Q x and 10 is 0x Doesn t matter that you choose different c values for each part they are independent 39 x2 isis not 6 x No since 6 is not 0 x 0 x isis note x2 No since 3 is not 2 x Sorting de ne sirnplersortcf lst de ne ndrbest cflst it null7 ist st insem let best ndrbest cflst iambdac1c2 cons 0fcfc1c2c1 2 est lst simplesott cf ca ism delete lst most simplesort is nz if we double the length of the list w e amount of work sort does approximately quadruples n Divide and Conquer sorting o simple sort nd the lowst in the list add it to the front of the result of sorting the list after deleting the lowst o Insertion sort insert the rst element of the list in the right place in the sorted rest of the list i emits insertsort de ne insertsort cf Ist if null Ist ull insertone cf car Ist insertsort cf cdr lst insertone define insertone cf el Ist if null Ist Ilst el if cf el car Ist cons el Ist cons car Ist insertone cf el cdr Ist 1 3 owner How much work is insertsort de ne memor cflst de ne Obsertone cf el lst l null7 lst 0f null7 lst null list el lnsertone cf lf cf el ca 50 car is Cons el lst l nsersor cf cdr lst any times cons car lst meone cf el cdr lst How m does Worst case insertsort evaluate irsertone Average case n times we fur each elemem inserlsort is 9012 insertone is 9n gt memor lt revmm 20 123456789 10 11 12 13 14 15 16 17 18 1920 Requlres 190 appllcauom of lt gt memor lt mm 20 123456789 10 11 12 13 14 15 16 17 18 1920 e ulres 19 applleauom of lt gt memor lt rename 20 0 11 16 1923263132323442455363648182 84 84 92 Requlres 104 appllcauom of lt 5 a CommlrrYl anew 6151mm noun mumWalk Is gt s mplesort lt mm 20 1 2 3 4 5 6 7 8 2o 910111213141516171819 Requlres 210 appllcanom of lt gt s mplesort lt renewals 20 44 16 18 19 20 23 82828889 3236515967697375 Requlres 210 appllcauom of lt simplesort vs insertsort 0 Both are nz worst case 0 Both are nz average case But insertsort is about twice as fast What does this tell us about 8 o inserBort is n best case Class 13 Quicksort Problems d a n Proced ures as 5m sim 5m Why are we spending so much time on sorting Raise i sen i is Dru iemmEi ieieiy it eveY writes their awn ode fur 5min Prateduvei provided hv all Malay languages 7mm F mmi m swim Art of Computer Hogramming Donald E Knuth Volume 11968 Fundamental Algorithms Volume 2 Semimrnerical Algorithms 7 Random numbers arithmetic Volume 3 Sorting an I Volume 4 Combinatoria available for testing Volume 5 Svntactic Algoritth estimated for 2010 Volume 6 7 piamed d Searching i Algorithms Partiallv uggexlim 2m mt to m vxl may ofznvevva in 7vva remitU 2 55 gn tznl m zlxo walh w 32 at if mu m vezllv 2 anti rude mu m insertsorttree 8log n 8n log Can we do better Making all those trees is a lot of work Can we divide the problem in two halves without making trees Quicksort 0 Sir C A R Tony Hoare 1952 Divide the problem in e Sorting aii eiements in the iist where c car iist el is true it is lt tie first element esgting aii other elemenm otis gt the rstelement Will this do better Comm stiri5 Quicksort define quicksort cf lst if null lst lst a end quicksort cf lter larrbda el cf el car lst dr lst list car lst quicksort cf lter lambda el not cf el car lst Cdr l5t de ne ddidmn Er lst lfQHJll lst at How much a work is qUiCKSOI t Eli i l Ma lambda el not fel Ear lst cur istgtgtgtgtgtgt What ifthe input list were sorted Worst Case nz What ifthe input list were random Expected n logZ n quiEkSD Er lter lambda el crai tar lst air at a i myan Comparing sorts gt testgmwlh insamwaa gt Etgrwth quitkstrt u 250 time 2n n 20 time 2d 7 m 7 me 7 u 4 540m tine 15534 123000 uma 353 1 3552 155 13 11a272 23233322 Eltim n n12EEIEIEItmE 251 n 4D1931192152332D25 4d Both are n 10gZ n Absolute time of quicksort much faster Good enough for VISA n 128000 time 35813 36 seconds to sort 128000 with quicksort n logZ n gt lung 4 I aaszmsmgagas 125mm lag 1250mm iSDSZSZ 5494914245 gt 12mm lag 12mm 35 3599 3 gt auuuuuuuu lag auuuuuuuu 41512 5 392225 5054130373 392000 seconds 4 5 days mama mu mmmwa a comma swag mamm Mm moleInn va m a Commth nu Are there any procedures more complex than simulating the universe 9013 Permuted Sorting o A possibly rally dumb way to sort Find all possible orderings of the list p mutations Check each permutation in order until you find one that is sorted 0 Example sort 3 1 2 All permutations 312321213231132 iss i issanem is anew isrsanem srsunem isrsanem 12 permute sort define permutesort cf Ist car filter lambda Ist issorted cf Ist allpermutations lst is sorted define issorted cf Ist or null Ist 1 length Ist and cf car Ist cadr Ist issorted cf cdr lst IO minute all permutations define allpermutatiors Ist flatone map lam if length Ist 1 list Ist The perrrutations of a are a ma lambda oneperm cons nth lst n oneperm allpermutations excepthth lst n intstzo length Ist gt ume permutersort lt randrintrlist 5 cpu ume i0led ume 1ogcume U gt ume permutersort lt randrintrlist 5 cpu nine 40 l eal me 40 gc time 0 5 29 39 4o 54 59 gt ume permutersort lt randrintrlist 7 cpu ume 261ieal ume 250 go time o 5 7 35 47 79 82 84 gt ume permutersort lt randrintrlist 8 cpu time 3585 real time 3586 gc me n 84 gt in me permutersort lt randrintrlist 9 Crashes unsanimm Mm vmlmm vmm 5 a Commth grunt maximum Mm vmlmm vmm Is How much de ne Permutersort cf lst work is her lambda est isrsorted7 of is all39Demutau ons lst permutesort 0 We evaluated is sorted once for each permutation of Is o How much work is is sorted n o How many permutations of the list are there Number of permutations map lam n if Gength lst 1 list lst map larrbda oneperm cons nth lst n oneperm leperrrutatlons excepmth lst n were Gength lst There are n lmgm lst values in the first map for each possible first element Then we call allperrrutations on the list without that element length 1 There are n n71 1 permutations I Hence there are n lists to check nnl n Are there any procedures more complex than simulating the universe 9013 Mavoe this is the Wrong quesuon Procedures and Problems 0 So far we have been talking about procedures how much work is permute sort 0 We can also talk about problems how c work is sorting o A pmhlem de nes a desired output for a given in ut A solutio 39 procedure for nding the correct output for all possible inputs on E o E m 3 a m m i emuqu The Sorting Problem 0 Input a list and a comparison function 0 Output a list such that the elements are the same elements as the input list but in order so that the comparison function evaluates to true for any adjacent pair of elements Problems and Procedures 0 If we know a procedure that is 8 n then we know the corresponding problem is 0 001 o The sorting pmhlem is 0 Mn since we know a procedure permute sort that solves it in 0 Is the sorting pmhlem 801 No we would need to prove there is no better pr c d 2 a com mom rm Mums 22 a Comping Problems and Procedures 0 Sorting problem is On log n We know a procecLIre quicksort that solves sorting in n log n sort ofquot does this bother vow o Is the sorting problem n log n this we need to pr ve there is no procedue that solves the sorting problem with time complexity better than 9n log Sorting problem is Qn logn 0 There are n possible orderings 0 Each comparison can eliminate at best 2 of them 0 So best possible sorting procedure is 91032 W o Stirling39s approximation n 9W So best possible sorting procecLIre is 900g m 001 10g mgr lm multizlrivtatmn r we addm logmrlngm lng Class 34 Computing with Photons From The HnKertoy Computer and other Madmnatons byA K Dewdney c5150 Computer Sctence ELIE University of Virginia Computer Science Greg Humphreys ChurchTuring Thesis 0 Church39s original 1935 Lambda calculus is equivalent to real world computers can compute any computable function 0 Turing39s version Every function which would naturally be regarded as computable can be computed by a Turing machinequot 0 Generalized version Any computation that can be done by an algorithm can be done by a mechanical computer All normalquotcomputers are equivalent in computing power Eu Turing Machines and Complexity 0 Stronger version Complexity classes P NP and NPcom ete are defined forTuring machine steps but apply identically to all normal computers 0 Today Abnormal Computers Mig tchange what is computable probably don39t Do change what a normal step is Normal Steps 0 Turing machine Read one square on tape follow one FSM transition rule write one square on tape move tape head one square 0 Lambda calculus One beta reduction 0 Your PC Execute one instruction What one instruction does varies Generalized Normal Steps 0 Require a constant amount of time 0 Perform a fixed amount of work Localized Cannot scale inde nitely with input size Abnormal Imaginary Computer 0 Accelerating TM Like a regular TM except the rst step takes 1 second second step takes V2 second third step takes 4 second nm step takes 12 second 0 Is the Accelerating TM more powerful than a regular TM If an algorithm is n on a regular TM what is it on this machine Can we solve undecidable problems with it s Quantum Mechanics for Dummies Deep deep theory of physcs Key features Manon Qum e Observaale quarmues do nor vay conunuously e Perms corrputauon lntefermoe e The outcome of a process depends on ALL posspie histories of that process e Makes e compurauon aponmually rrore poweful Emanglemerrt e Two oummrn systerrs may shae inforrnanon which CAWOT be aocessed li i my experiment performed on ermer one a one 7 Perms cryptography Regular Computing 0 Bit either 0 or 1 o Bits combine mgether to store stuff 0 Basic operations on that stuff Ad rrultiply compare read write Quantum Computing 0 Feynman 1982 o Subatomic particles are kind of like bits Spin39 up or down 0 But you can39t rally KNOW what their value is Wiihout changing the value 0 All we know is the probability that the particle i p or down 0 Particle is said to be in both states SLperposition Light behaves this way too Light behaves this way too CAN ANYONE TELL BECAUSE THE FIRST ME va EVERYONE TEN MINUTES ARE Is ALMAYS LATE W3 LLJAVS STUP row MY STA r 5mm L1KE mHV MEETINGF g ARE mm LATEV 4 15 r i 4 Q Class 22 Go39del s Theorem csxsa Gamma m 612 Hum Me 5 gmuzvm q f Y Menu PSS Mechanized Reasoning o Go39del39s Theorem 0 P85 0 Introducing Computability mummy mm mm 2 3 cm PSS How are commercial databass different from what you implemented for PSS UVa39s Integrated Systems Reject to convert all University information sy use an Oracle database was originally budgeted for 582 M39 ion starting in 1999 Actual cost is liker to be 100 Million htt mm w lnla edu is Real Databases 0 Atomic Transactions a transaction may involve many 0 Security limit readwrite access to tables enties and elck 0 Storage need to efficiently store data on disk provide backup mechanisms 0 Scale to support really big data iabls real databases do lots of clever things mummy mm mm a a comm amt smmmnmmimmzz WWW How big are big databases 0 Microsoft TerraSener Claimed biggest in 1998 Aerial photos of entire US 1 meter resolution Big Databases 0 Microsoft TerraSener 33 Terabytes claimed biggest in 1998 1 Terabyte 24 Bytes 1 Trillion Bytes 0 Google Maps Not so big but offers progamming interface 0 WalMart 285 Terabytes 2003 0 Stanford Linear Accelerator BaBar 500 Terabytes 30 KB per particle collision How much work 0 table select is 0n where n is the nu of entries in the le Is this true 2 000 0005 23 days How do expensive databases perform so much faster Would your tableselect work for WalMart If 1M entry table takes ls how long would it take WalMart to select from 285TB 2 Trillion ntries mber a a Camp P56 Make an adventure game programming with objects Many objects in our game have similar properties and behaviors so we use inheritance ms Mm m mm mm WWW 9 a com student mm mm Person Wmch mm m mobilerahiect Wmch mm quota Physicelrahiect Wmch mm m abject ms Mm m mm mm WWW Are there class hierarchies like this in the real world or just in fictional worlds like Charlottansville 2 3 Camping Microsolt Foundation Classes CButtm inherits from CWnd inherits from CObject A button is a kind of window is a kind of objectquot n Ratatiunpathlnterpnlamrf e 7 it Obea 1 EcenaSraphObye r E Nut at all uncommon re have class hierarchies like my Story So Far 0 Much of the course so far Getting comfortable with recursive definitions Learning to write a program to do almost anything PS 14 Learning more elegant ways of programming 56 Problem Classes if P 2 P sunme m cm is Umverse 0013 Find Best em rathers are 0 This Week circles What s fume ow Getting uncomfortable with recursive de nitions Sumng Lhderstanding why there are some thing no one 1 mllsys can write a program to do 35 smmmm mm mm 5 smmmm mm mm 5 a Comyu rrV s 5 Computability nu may Computer Science Mathematics 0 Computer Science Imperative Knowledge Are there wellde ned problems that cannot be solved by any procedure 0 Mathematics Declarative Knowledge true statements that cannot be proved 3 i emu s Mechanical Reasoning o Aristotle 350BC The Organon We can explain logical demction with rules of inference syllogisrrs Every B is A C is B Every human is mortal Gidel is human Godel is mortal More Mechanical Reasoning o Euclid 300BC Elements can reduce geometry to a few axioms and derive the rest by following rules 0 Newton 1687 Philosophiae NatJJralis Principia Mathematica We can reduce the ti ob39ecls incl uding planets to following axioms laws mechanically i Comping Mechanical Reasoning 0 Late 18005 many mathematicians working on codifying laws of rmsoningquot ge Boole Laws of Thought Augustus De Morgan Whitehead and RLssell mm Mm m mm mm WWW a town an All true statements about integers ms Mm m mm mm WWW a town Perfect Axiomatic System D 39 all true statements and no false statements starting item a nite number of a 39 and following mechanical inference rules incomplete enves some but not all true statements and no false statements starting from a nite number Inconsistent Axiomatic System Denves all true statements and some false and following mechanical inference rules Principia Mathematica 0 Whitehad and Russell 1910 1913 Three volumes 2000 pages 0 Attempted to axiomatize mathematical reasonin Define mathematical entities like nunbers using logic Derive mathematical truths by following mechanical rules of inference Claimed to be complete and consistent All true theorems could be derived x i Connquot Russell s Paradox 0 Some sets are not members of themselvs set of all people in this room 0 Some sets are members of themselvs set of all thin that are not in this room 0 S the set of all sets that are not members of themselves 0 Is S a member of itself Russell s Paradox o S set of all sets that are not members of themselves 0 Is S a member of itself If S is an element of S then S is a merrber of itself and should not be in S If S is not an element of S then S is not a merrber of itself and should be in S 5150mman mm WWW 21 a Comma surm mama mm mm m a comp Well that s not good 0 Principia Mathematica attempted to resolve this problem by banning self reference 0 Even set has a ty e The lowest type of set can contain only objects not sets e ne typ at can contain objects and sets of objects but not sets of sets Russell s Resolution Set Set Set x i x is an ObJECZ Set x i x is an Objeczor a Sezu s Setw Is S a member of itself No it is a Setquot so it can39t be a member of a Setquot m i um Epimenides type Paradoxes Epimenides a Cretan All Cretans are liarsquot Eubulides Paradox This statement is falsequot Socrates39 Paradox One thing I know is that I know nothingquot Russell s settypes can help With the set paradox but nutvvith these 41 Godel s Solution All consistent axiomatic formulations of number theory include undecidable propositions GEB p 17 undecidable cannot be proven either true or false inside the system i amnpw Kurt Godel 0 Born 1905 in Brno now Czech Republic then AustriaHungary o 1931 publishes Uber formal unentscheidbare quotA verwandter Systeme On Formally Undecidable Prepositions of Principia Mathematics and Related Systems mm Mm m mm mm WWW o 1939 es Vienna 0 Institute for everything was poisoned and refused to eat ms Mm m mm mm WWW Godel s Theorem In the Principia Mathematica system there are statements that cannot be proven either true or false Godel s Theorem In any interesting rigid system there are statements that cannot be proven either true or false as i Cmnwnu Godel s Theorem All logical systems of any complexity are incomplete there are statements that are true that cannot be proven within the system Proof General Idea Theorem In the Principia Mathematica system there are statements that cannot be proven either true or false Proof Find such a statement as ism saws God el s Statement G This statement of number theory does not have any proof in the system of Principia Mathematica G is unprovable but true Godel s Proof G This statement of number theory does not have any proof in the system of PM IfG were provable then PM would be inconsistent IfG is unprovable then PM would be incomplete PM cannot be complete and consistent 5150mman mm mmmm 3 a Commgjgfm ms MM 1 mm mm WWW m a Comlmrg fgrnu Finishing The Proof 0 Turn G into a statement in the Principia Mathematica system 0 Is PM powerful enough to express This statement of number theory does not have any proof in the system of PM How to express does not have any proof in the system of PM o What does it man to have a proof ofS in PM There is a secpence of steps that follow the inference rules that starts with the initial axioms and ends with S o What does it man to not have any proof ofS in PM re is no secpence of steps that follow the inference rules that s ris with the initial axioms wi 42 i umwwsgiw Lecture 5 Sugan PSl Thoughts C5150 Camputa39 Smence Umva39sxty alvxrglma Camputa39 Smence Menu 0 Implementing cons car cdr 0 PSI 0 List Recap z m quotmr t39t39e imss Do we need cons car cdr Scheme provides these as builtins Are they just syntactic sugar How come you taste so good de ne Dons a b lambda w if w a b de ne car pair pair t de ne 0dr pair pair f a e amgc a Comm 5 C5150 PS Grading Scale 1 Gold Star Excellent Work You got evervthlng I Wanted on this PS No Gold Stars on ps1 Green Star Better than good work Blue Star Good Work You got most things on this PS but some quot quot quot 393 Silver Star Some problems Make sure you understand the solutions on today39s slides 0 upper limit a Double Gold Star exceptional Worki Better tnan I expected anvone Wou d do i t r Tl lDle Gold star Better than I thought possible mmlemosalc to p51 7 QJadmple bid star You have broken published in a major purnali 7 ulntu le Gold star You deserve to Wav to make tne best nmrrepeatlng otornosalc on p51 or a proof tnat it l5 impossible anipillrfincllrrquot Question 2 2d 100 100 o ithout Evaluation Rules Qustion 2 was Evaimtion Ruie 31ppiication QUESSWDF a Evaluate all the subexpressions 0 Now you know the Evaluation Ruls you 100 ltprimitivegt 100 n answer QUEEN 2 W39thDUt any h Apply the value of the first sibexpression guessing to the values of all the other subexpressions Error 100 is not a procedure we only have apply rules for procedures 1 2h Evaluate not quotcookiesquot n n n n n n Evaluation Rule 3 Application If 0391 500k395 El StarVe a EvaILate all the subexpressions Evaluation Rule 4if Evaluate Exprssionu If ltPrimitive n0tgt CookieS39 The quotes really matter here It evalu t5t thf39 tre vafluEe 0f t la l Without them what would cookies evaluate to EXprSSIDn 395 e va we 0 Xprssmn b Apply the value of the rst subexpression to Otherwise the value of the if expression is the values of all th subex 39on the value of Expression not vgeevaluates to t if v is f otherwise it 1 ev I f SICP p 19 Evaluate not quotcookiesquot So not cookiesquot evaluates to f 9 II Defining not 2h not v evaluats tn 1 ifv is f If not makes lea sene Evaluation Rule 4if Evaluate Expression If otherWIse it evaluates to D f SICP 19 it evaluates to f the value of the if 39 39339 expression is the value of Expression Otherwise the value ofthe if exprssion is de ne nOt V If V f t the value of Expression2 Evaluate not quotcookisquot gt f So value of if is value of Expression2 DrScheme Languages 0 If you didn39t set the language correctly in DrSc eme you got different answers 0 The Beginning Studentquot has different evaluation rules The rules are more complex But they gave more people what they expected Comparing Languages Welcome m DvSthemE vevslan zus Language m Bgilr l 4 ml and Allimum gt XltDvlmltlve gt Welcome to DrScheme verslorl 205 Language ll rrrrrg am gt m prlmltlve operator must be applled ro argumene expected a en perenmeas before me pl lmlnve operator Flame gt lambda x x zoo mlrepnrr all emitted der rrrej rrarne pr e prlrvmve o erauorrparrr after arrow parelrmeasmrrounel somemlrrg else I ew s brighter rst try de ne prrgrrerr calm mlavZ ltgt lt a an calm as veen calm eentala12 hluemlmZ e alum ge a mlmZ ge Is this correct 1 brighter with style H de ne prrghrerv calm mlmZ gt geerea mlau getrgveen mlau geeplue alum geerea mlmZ getrgveen mlmZ geeplue mlarz Why is this better Is it right Is a brighter slightly better de ne prrgmerv calm mlmZ gt hvlqhtness calm hvlqhtness mlmZ de ne hvlqhtness calm geerea mlar qerqreen calm qezrhlue mlar Why is this better Is it right brighter my preference de ne prrgmerv calm mlmZ gt hvlqhtness calm hvlqhtness mlmZ de ne hvlqhtness calm 299 gamed tam 557 qerqreen calm in gel39hlue calm One of you almost did this 3 i cannula s closer color first try closer color with style qerme p elusepeulur sample eulurl calm lt aps 7 gelled gamed sampleaps 7 qetplue eulurl etrblue sampleabs7getrgreerlcolorl qetqreerrsample qetreq calm qetreq sample 7 getblue olol u s aps pl e sample ap 7 getrgreerlcolo getrgreensamplennn Code like this makes me want to weep You will meet people who think this is better They are wrong Wrong wrong wrong wrong wrong wrong 15 qerme losemolor sample eulurl olol Z lt aps 7 qetreq eulurl qetreq sample aps 7 qetplue eulurl getrblue sample aps 7 qetqreerr eulurl qetqreerr sample aps 7 getrred olol Z getrred sample an r getrblue culprz getrblue sample aps 7 getrgreerl culprz getrgreerl sample closer color slightly better closer color slightly better lt colorrdlstarlce sample eulurl colorrdlstarlce sample cum deflnecolorrdlstarlceolorl culprz aps aps aps tr eplpr getrred ED or2 r getrblue eulurl getrblue cum 7 getrgreerl eulurl getrgreerl olor2 lt colorrdlstarlce sample eulurl colorrdlstarlce sample cum deflnecolorrdlstarlceolorl culprz etrred eplp getrred calm r getrblue eulurl getrblue cum 7 getrgreerl eulurl getrgreerl olor2 square square closer color slightly better qerlrre losemolor sample ulurl calm lt Eulorrdlstarlce sample ulurl square colorrdlstarlces mpleepl a quare de neEulorrdlstarlcecolorl culprzrune rune 7 getrred eulurl getred olor2 run 7 qetplueeplprl getbluemlol ZD rurre r getrgreerl eulurl getrgreerl culprz closer color much better qerme losemolor sample eulurl cum lt colorrdlstarlce square sample eulurl Eolorrdlstarlce square sample culprz qerme colorrdlstancemn lampqa eulurl mm run 7 getrred eulurl getred olor2 run 7 getrblue eulurl getrblue olol Z run 7 getrgreerl eulurl q etrgreerl olor2 closer color my preference de ne exdsenee dn samp e mm mm lt LAadstanee samp e edwdn LAadstanee samp e u urz de ne LAErmstance e dn u urz 5W1 edxdnmstanee square RGEVIDVLAE edxdm RGEVIDVLAE u urz Z m LAB LAB de ne xvz m LAB u ur if Cf TWEDW mm s r d nurmrmLAE makercmur makercmur nand erEaHyrsmaH gamed cedar gewed mar 95 E147 hand erEaHyrsmaH getrgreen cedar anmereauyrsr au QELWUE ED EIVD de ne hand erEaHyrsmaH n rgt n n nuaaae de n 13 77E7 HMS116 21 Hm V m a Commquot we LAB de ne stmrturLAE u ur makeee dr 7 we getrgreen eder 6 5nd 7 getrred e dn getrgreen u ur 2mm 7 getrgreen u ur geemde cedar The Patented RGB RMS Method mu n 1 gt size1h Hunsluned cnmmsm e mndned cmthqerxwh mun vlt 1l39xlqtnqlhv39hlh Inseudeeveyyn tuvea butt eywerewm ga pate ta evaH Tn Wava a ufpatentsespedauy n su wave e m make them as ham m undevstand as made am e W

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

#### "I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

#### "Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.