historical what is a grammar? a language?€¦ · ... v in the following manner: ... motivation...
TRANSCRIPT
language
OxfordEnglishDictionary
Languageisthemethodof‘human’communication,eitherspokenorwritten,consistingoftheuseof‘words’inanagreedway.
Languageisthestyleorfacultyofexpression
Languageisthesystemofsymbolsandrulesforwritingalgorithms
underlyinglanguageisthenotionofasentence
The happy li*le boy ran quickly
<DET> <ADJ> <ADJ> <NOUN> <VERB> <ADVerb>
<ADJPHRASE> <NOUNPHRASE> <VERBPHRASE>
<NOUNPHRASE>
<SENTENCE>
parsetree
The happy li*le boy ran quickly
<DET> <ADJ> <ADJ> <NOUN> <NOUN> <ADVerb>
<ADJPHRASE> <NOUNPHRASE> <VERBPHRASE>
<NOUNPHRASE>
<SENTENCE>
werecognizepartsofasentence
relationshipsbetweenparts(ofthesentence):
a<SENTENCE>isa<NOUNPHRASE>followedbya<VERB
a<NOUNPHRASE>isa<ADJPHRASE>followedbya<NOUNPHRASE>
a<ADJPHRASE>isa<DET>followedbya<ADJective>
a<NOUNPHRASE>isan<ADJective>followedbya<NOUN>
a<VERBPHRASE>isa<VERB>followedbya<ADVerb>
boyisa<NOUN>andranisa<VERB>
entities:
thingslike<SENTENCE><NOUNPHRASE>
thingslikethe,li*le,boy,quickly
relationshipsspecifyrules
<SENTENCE> <NOUNPHRASE><VERB>
<NOUNPHRASE> <ADJPHRASE><NOUNPHRASE>
<ADJPHRASE> <DET><ADJective>
<NOUNPHRASE> <ADJective><NOUN>
<VERBPHRASE> <VERB><ADVerb>
<NOUN>boy
<VERB> ran
vocabularyoralphabetsymbols• TERMINAL
• NONTERMINAL
entities• stringsofsymbolsjuxtapositionedtogether
sentence• stringmadeupofterminalvocabularysymbols
production• RULESmadeupofstringsexpressingarelationship
betweentwosuchentitiesandexpressedasa→b
initialstringorseedmadeupofvocabularyelements
grammar
Buildingblocks
producedfrom
Thelanguage,L,ofagrammar,G,isthesetofallsentences(i.e.,withoutnon‐terminals)thatareproducedfromtheinitialstring
L(G)={sentence|initial‐string⇒*sentence}
language
ruleapplication
Aruleisapplicable
tothecurrentstringwhichiseithertheinitialstringorastringproducedfromtheinitialstring
whenever
thelefthandsideoftherule‘occurs’intheobject
inwhichcase
itcanbereplacedbytherighthandsideoftheruleunderruleapplication
formal definition
GrammarG=(N,T,P,S)
seed
production
terminal
terminal
seedbelongstotheuniverseofstringsmadeofsymbolsinNandT
P(roduction)containrulesoftheforma→bwhereaandbbelongtotheuniverseofstringsmadeofsymbolsinT(erminal)andN(onterminal)whereacannotbeempty.
vocabularyanduniverse
VOCABULARYisalimitedsetofsymbolsnotwoofwhicharesimilaroridentical
IfwearegivenasetofsymbolsV,thenwecancreateasetV*calledtheUNIVERSE(orLEASTSET)ofVinthefollowingmanner:
TheemptystringeisinV*.
EverysymbolinVisinV*.
IfaandbarestringsinV*,sotooistheirjuxtaposition(concatenation)abinV*
V*isclosedunderconcatenation
WedenotethesetV*–{e}byV+.
Foranyproductiona→b,wehavea∈V+andb∈V*
exampleofagrammar
G=(N={S},T={0,1},P={S→0S1,S→01},S)
Whatcanwedowiththisgrammar?
FromSbyapplyingruleS→0S1weget0S1Thatis,substitutetheoccurrenceofthelefthandsideofthecurrentruleinthecurrentstringbytherighthandside.Thatis,S⇒0S1
ByapplyingruleS→0S1againweget00S11.Thatis,S⇒0S1⇒00S11.Or,S⇒*00S11
IfweapplyruleS→01wegetS⇒0S1⇒00S11⇒000111
typesofgrammars
PHRASESTRUCTUREGRAMMARSproductionsoftheformα→β
CONTEXTSENSITIVEGRAMMARSproductionsoftheformα1Aα2→β1Bβ2equivalently,|α|≤|β|
CONTEXTFREEGRAMMARSproductionsoftheformA→βwhereAisasinglevariable
REGULARGRAMMARSproductionsoftheformA→aBorA→awhereAisasinglevariable
acfgexample
G=(
N={S,A,B}, non‐terminals
T={a,b}, terminals
P={S→aB,S→bA, productionsA→a,A→aS,A→bAA,B→b,B→bS,B→aBB},
S) seed
WhatisthelanguageL(G)?
Allstringswithequalnumbersofa’sandb’s.
grammars,proceduresandalgorithms
Notethatifwecanrecognizewhetherasentenceisinalanguagethenwecanalwaysgeneratethelanguagesimplybygeneratingeachelementintheuniverseandcheckingwhethertheelementisinthelanguage
example:
givenanintegeri>1,isitprime?
1. setjto2
2. ifj≥i,thenhalt.iisprime.
3. ifi/jisaninteger,thenhalt.iisnotprime.
4. setjtoj+1andgoto2.
anotherexample:
givenanintegeri>1,isthereaperfectintegergreaterthani?
1. setk=i
2. setk=k+1,sum=0,j=1
3. ifj<k,goto6
4. ifsum|k,goto2
5. Halt.Thereisaperfectinteger.
6. ifk/jisnotaninteger,goto8.
7. setsum=sum+j
8. setjtoj+1andgoto3.
recursivelyenumerableandrecursive
Asetisrecursivelyenumerable(r.e)ifitcanbegeneratedbyaprocedure
Anotherwayoflookingatthisisthatthereisa1‐1correspondencebetweenelementsofthesetandthenaturalnumbers.Inotherwords,wecan“index”theelementsoftheset
Asetisrecursiveifitcanbegeneratedbyanalgorithm
Languagesofgrammarsarerecursivelyenumerable
pslarerecursivelyenumerablecsl,cfl,rlarerecursive
Equivalently,asetthatisrecursivelyenumerableisthelanguageofsomegrammar
noamchomsky-syntacticstructures
“thesearchforrigorousformulationinlinguisticshasamuchmoreseriousmotivationthanmereconcernforlogicalnicetiesorthedesireto
purifywell‐establishedmethodsforlanguageanalysis
preciselyconstructedmodelsforlinguisticstructurecanplayanimportantrole,bothnegativeandpositive,intheprocessof
discoveryitself
bypushingaprecisebutinadequateformulationtoanunacceptableconclusion,wecanoftenexposetheexactsourceofthisinadequacy
and,consequently,gainadeeperunderstandingofthelinguisticdata”