Outline• MathematicalNotation
– Sets– SequencesandTuples– FunctionsandRelations– Graphs– StringsandLanguages(notcoveredpreviously)– BooleanLogic
• ProofsandTypesofProofs– Construction– Contradiction– Induction
1
FromSipserChapter0
9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Sets• Asetisagroupofobjects,orderdoesnotmatter– Theobjectsarecalledelementsormembers– Examples:
• {1,3,5},{1,3,5,…},or{x|x∈Zandxmod2≠0}
– Youshouldknowtheseoperators/concepts• Subset(A⊂BorA⊆B)• Cardinality:Numberelementsinset(|A|)• Intersection(∩)andUnion(∪),ComplementĀ• VennDiagrams:canbeusedtovisualizesets
2 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
SetsII
• PowerSet:Allpossiblesubsetsofaset– IfA={0,1}thenwhatisP(A)?– Ingeneral,whatisthecardinalityofP(B)?
3 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
SetsII
• PowerSet:Setofallpossiblesubsetsofaset– IfA={0,1}thenwhatisP(A)?
• P(A)={,{0},{1},{0,1}}– Ingeneral,whatisthecardinalityofP(B)?
• Numberofthepossibilebinarystringswith|B|bits|P(B)|=2|B|.
4
;<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
SequencesandTuples
• Asequenceisalistofobjects,ordermatters– Example:(1,3,5)or(5,3,1)
• Inthiscoursewewillusetermtupleinstead– (1,3,5)isa3-tupleandak-tuplehaskelements
5 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
SequencesandTuplesII
• Cartesianproduct(x)isanoperationonsetsbutyieldsasetoftuples– Example:ifA={1,2}andB={x,y,z}
• AxB={(1,x),(1,y),(1,z),(2,x),(2,y),(2,z)}– IfwehaveksetsA1,A2,…,Ak,wecantaketheCartesianproductA1x A2… x Akwhichisthesetofallk-tuples(a1,a2,…,ak)whereai∈Ai
– WecantakeCartesianproductofasetwithitself• AkrepresentsAxAxA…xAwheretherearekA’s.
– ThesetZ2representsZxZallpairsofintegers,whichcanbewrittenas{(a,b)|a∈Zandb∈Z}
6 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
FunctionsandRelations
• Afunctionmapsaninputtoa(single)output– f(a)=b,fmapsatob
• Thesetofpossibleinputsisthedomainandthesetofpossibleoutputsistherange– f:D→R– Example1:fortheabsfunction,ifD=Z,whatisR?– Example2:sumfunction
• CansayZxZ→Z
• Functionscanbedescribedusingtables– Example:Describef(x)=2xforD={1,2,3,4}
7 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Relations• Apredicateisafunctionwithrange{True,False}
– Example:even(4)=True• A(k-ary)relationisapredicatewhosedomainisasetofk-tuplesAxAxA…xA– Ifk=2thenbinaryrelation(e.g.,=,<,...)
• Relationsmayhave3keyproperties:– reflexive,symmetric,transitive– Abinaryrelationisanequivalencerelationifithasall3– Try=,<,friend
8 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Graphs
• AgraphisasetofverticesVandedgesE– G=(V,E)andcanusethistodescribeagraph
9
A
B
C
D
V = {A, B, C, D} E = {(A,B), (A,C), (C,D), (A,D), (B,C)}
9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
GraphsII
• Definitions:– Thedegreeofavertexisthenumberofedgestouchingit
– Apathisasequenceofnodesconnectedbyedges– Asimplepathdoesnotrepeatnodes– Apathisacycleifitstartsandendsatsamenode– Asimplecyclerepeatsonlyfirstandlastnode– Agraphisatreeifitisconnectedandhasnosimplecycles
10 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
StringsandLanguages
• Thisisveryimportantforthiscourse• Analphabetisanynon-emptyfiniteset
– Membersofthealphabetarealphabetsymbols– ∑1={0,1}– ∑2={a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}– ∑3={0,1,a,b,c}
• Astringoveranalphabetisafinitesequenceofsymbolsfromthealphabet– 0100isastringfrom∑1andcatisastringfrom∑2
11 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
StringsandLanguagesII
• Thelengthofastringw,|w|isitsnumberofsymbols
• Theemptystring,ε,haslength0• Ifwhaslengthnthenitcanbewrittenasw1w2…wn,wherewi∈∑
• Stringscanbeconcatenated– abisstringaconcatenatedwithstringb– astringxcanbeconcatenatedwithitselfktimes
• Thisiswrittenasxk
• Alanguageisasetofstrings
12 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
BooleanLogic
• BooleanlogicisamathematicalsystembuiltaroundTrue(or1)andFalse(or0)
• Belowarethebooleanoperators,whichcanbedefinedbyatruthtable– ∧(and/conjunction) 1∧1=1;else0– ∨(inclusiveor/disjunctions)0∨0=0;else1– ¬(not) ¬1=0and¬0=1– →(implication) 1→0=0;else1– ↔(equality) 1↔1=1;0↔0=1
• Canproveequalityusingtruthtables– DeMorgan’slawandDistributivelaw
13 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Proofs
• Proofsareabigpartofthisclass– Aproofisaconvincinglogicalargument
• Proofsinthisclassneedtobeclear,formalbutnotexcessively
– Thelevelofformalismofthebookisagreatguideline!
– TypesofProofs• A⇔BmeansAifandonlyifB
– ProveA⇒BandproveB⇒A• Proofbycounterexample(provefalseviaanexample)• Proofbyconstruction(mainprooftechniquewewilluse)• Proofbycontradiction• Proofbyinduction
14 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Proofs:Example1• ProveforeverygraphGsumofdegreesofallnodesiseven
– Takeaminutetoproveitoratleastconvinceyourselfitistrue– Thisisaproofbyinduction
• Theirinformalreasoning:everyedgeyouaddtouchestwoverticesandincreasesthedegreeofbothoftheseby1(i.e.,youkeepadding2)
• SeeExample0.19p18andTheorem0.21p20– Aproofbyinductionmeansshowing1)itistrueforsomebasecaseandthen2)iftrueforanynthenitistrueforn+1
• Sospendaminuteformulatingtheproofbyinduction• Basecase:0edgesinGmeanssum-degrees=0,iseven• Inductionstep:ifsum-degreesevenwithnedgesthenshowevenwithn+1edges
– Whenyouaddanedge,itisbydefinitionbetweentwovertices(butcanbethesame).Eachvertexthenhasitsdegreeincreaseby1,or2overall
– evennumber+2=even(wewillacceptthatfornow)
15 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Proofs:Example2ForanytwosetsAandB,(Theorem0.20,p20)
– Weprovesetsareequalbyshowingthattheyhavethesameelements
– Whatprooftechniquetouse?Anyideas?– Proveineachdirection:
• Firstproveforwarddirectionthenbackwarddirections– Showifelementxisinoneofthesetsthenitisintheother
• Wewilldoinwords,butnotasinformalasitsoundssincewearereallyusingformaldefinitionsofeachoperator
16
(A [B) = A \ B<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Proof:Example2• • Forwarddirection(LHSàRHS):
– Assumex∈– Thenxisnotin(A∪B)[defn.ofcomplement]– ThenxisnotinAandxisnotinB[defn.ofunion]– SoxisinĀandxisinandhenceisinRHS
• Backwarddirection(RHSàLHS)– Assumex∈– Sox∈Āandx∈ [defn.ofintersection]– Sox∉Aandx∉B [defn.ofcomplement]– Soxnotinunion(A∪B) [defn.ofunion]– Soxmustbeitscomplement[defn.ofcomplement]
• Sowearedone!17
(A [B) = A \ B<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
(A [B)<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
B<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
B<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
A \ B<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Proofs:Example3
• Foreveryevennumbern>2,thereisa3-regulargraphwithnnodes(Theorem0.22,p21)– Agraphisk-regularifeverynodehasdegreek
• Wewilluseaproofbyconstruction– Manytheoremssaythataspecifictypeofobjectexists.Onewaytoproveitexistsisbyconstructingit.
– Maysoundweird,butthisisbyfarthemostcommonprooftechniquewewilluseinthiscourse
• Wemaybeaskedtoshowthatsomepropertyistrue.Wemayneedtoconstructamodelwhichmakesitclearthatthispropertyistrue
18 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Proof:Example3continued
• Canyouconstructsuchagraphforn=4,6,8?– Trynow.– Ifyouseeapattern,thengeneralizeitandthatistheproof.
– Hint:placethenodesintoacircle• Solution:
– Placethenodesinacircleandthenconnecteachnodetotheonesnexttoit,whichgivesusa2-regulargraph.
– Thenconnecteachnodetotheoneoppositeitandyouaredone.Thisisguaranteedtoworkbecauseifthenumberofnodesiseven,theoppositenodewillalwaysgethitexactlyonce.
• Thetextdescribesitmoreformally.• Notethatifitwasodd,thiswouldnotwork.
19 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Proof:Example4
JackseesJill,whohascomeinfromoutside.SinceJillisnotwetheconcludesitisnotraining(Ex0.23,p22)
– Thisisaproofbycontradiction.• Toproveatheoremtruebycontradiction,assumeitisfalseandshowthatleadstoacontradiction
• Inthiscase,thattranslatestoassumeitisrainingandlookforcontradiction
– IfweknowthatifitwererainingthenJillwouldbewet,wehaveacontradictionbecauseJillisnotwet.
– Thatistheprocess,althoughnotaverygoodexample(whatifshelefttheumbrellaatthedoor!)
– Thiscaseisperhapsabitconfusing.Letsgotoamoremathematicalexample…
20 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
ProveSquareRootof2Irrational
• Proofbycontradiction,assumeitisrational– Rationalnumberscanbewrittenasm/nforintegerm,n– Assumewithnolossofgeneralitywereducethefraction
• Thismeansthatmandncannotbothbeeven– Ifso,2goesintobothsoreduceit
– Thendosomemath
• n=m• 2n2=m2• Thismeansthatm2isevenandthusmmustbeeven
– Sinceoddxoddisodd
21
p2 = m/n
<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
np2 = m
<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
ProveSquareRootof2Irrational
• So2n2=m2andmiseven• Anyoddnumbercanbewrittenas2kforsomeintegerk,so:
– 2n2=(2k)2=4k2Thendividebothsidesby2– n2=2k2– Butnowwecansaythatn2isevenandhencenmustbeeven
• Wejustshowedthatmandnmustbothbeeven,butsincewestartedwithareducedfraction,thatisacontradiction.– Thusitcannotbetruethat√�2 isrational
22
p2
<latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit><latexit sha1_base64="(null)">(null)</latexit>
9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani
AnotherProofbyInductionExample
• Provethatn2≥2nforalln2,3,…• Basecase(n=2):22≥2x2?Yes.• Assumetrueforn=mandthenshowitmustalsobetrueforn=m+1– Sowestartwithm2≥2mandassumeitistrue– wemustshowthatthisrequires(m+1)2≥2(m+1)
• Rewritingweget:m2+2m+1≥2m+2• Simplifyingabitweget:m2≥1.• So,weneedtoshowthatm2≥1giventhatm2≥2m
– If2m≥1,thenwearedone.Isit?– Yes,sincemitself≥2
23 9/5/19 Theory of Computation - Fall'19
Lorenzo De Stefani