okay thank you all for coming my name is
Anna I'm a freelance JavaScript
developer from Berlin but my background
is actually in computational linguistics
computational linguistics is the science
of looking at natural language so the
stuff that we humans speak in a
mathematical way trying to find patterns
and rules to do awesome stuff with it
and this is what inspired this talk yeah
I want to talk about something called
the algorithmic beauty of plants so when
people talk about mathematical aspects
of plants and the beauty of nature you
usually see those kind of images show up
circular shapes with easily recognizable
repeating patterns sometimes you even
see if you not see spiral drawn on top
of it to indicate the goal of national
somewhere in the plant whether this is
true or not but this is what people
usually talk about however in this talk
I would like to give you another
approach to seeing the mathematical and
algorithmic a beauty of plants and this
approach actually starts with the human
language so a common thing between
people of all cultures in the world is
that they use language to communicate
while those languages vary wildly widely
there seems to be a common feature
connecting them so humans speak to each
other using languages they have
different structures different words but
there are some similarities and this is
what linguistics is about so to give you
an introduction to how we linguist look
at language I say let's have a look at a
couple of English sentences and see if
we can find out what makes them
sentences so look at this sentence it's
called marika reviewed peters pull
request that sounds like a wonderful
english sentence to us however if we
rearrange the word pull request marika
peters reviewed doesn't sound like an
english language so if you
have another native language than
English or German maybe a non-european
language this word structure might make
sense to you but for English and German
speakers it usually doesn't
so another sentence that isn't really a
sentence is something like jessica talks
about there's something missing in the
english language so our brain gives us
this kind of error message when we
listen to that and you laugh with error
message but actually we can observe
something like this
so when linguist try to figure out what
makes the sentence grammatical for
speakers they have a couple of
techniques techniques to check that one
technique uses eye tracking so when we
read a sentence like this the test
subjects eyes go back to the front of
the sentence furiously looking for that
missing information you even can put on
an EKG to measure the brain waves and
you see that there's a spike in it when
a sentence is ungrammatical so this is
really interesting
the first sentence had a word order that
we perceived as non grammatical this
sentence seems to be missing a word but
then there are sentences where our brain
doesn't throw an error message in a
grammatical way for example this
sentence colorless green ideas sleep
furiously it is a perfectly valid
English sentence but it doesn't make any
sense
so we laugh about that but we don't get
that error message thrown so there seem
to be some rules that we can break and
still maintain an English sentence and
some that we can't and we want to figure
out what is it that makes a sentence a
valid English sentence in that case the
fun thing is its grammar some of you had
grammar studies in in school and they
were taught some basics about their
native language some didn't in
linguistics a grammars just a set of
structural rules that tell us how a
sentence a phrase so sometimes in the
word may be composed so it has nothing
to do with so called press
prescriptive grammar where we say what
rules make a nice sentence and if you
say that you're teachable if you say the
other one your teacher will say it's
wrong but really just figuring out what
throws the error messages in our brain
and what doesn't um
grammar has always been a part of
learning a language so even 100 years
ago when people were studying different
languages they looked at the grammar
they looked at the word order to figure
out what is a good sentence and what not
looking at grammar and languages from a
mathematical angle actually started
happening in the 50s so for our approach
right now we just agree that the grammar
is a set of rules how words may be put
together
not nice sentences not educated
sentences but just valid sentences when
I started started in the 50s that
actually started mainly with this person
it's called Noam Chomsky he used to be
very important theoretical ingres
nowadays he switched to politics and
philosophy but he laid the groundwork
for all mathematical approaches to
languages it went this far that we
actually call this kind of grammar
Chomsky grandma or Chomsky systems and
in a very short summary he says so the
grandma is a type of rewriting system
that contains rules that tell us how
words may be put together to form a
sentence so what is a rewrite system it
might sound complicated but it's
actually just search and replace symbols
now we for example have rules like this
it's an s and Aaron in a in a B and that
just means every occurrence of the
symbol on the left hand side is the
error so the S is replaced with a and B
not the other way around
yes it's written here yeah you may be
using already those kind of rewrite
systems if you use Auto format as like
prettier that replace every double quote
with single quotes or the other way
around this is just a rewrite rule
more complex rule would be the second
one so only if the symbol a appears to
the left of B replace it with C or even
the third one if a and B appear together
replace them with C and this is just
this is how a rewrite rule works it's
simple replace one thing with another
according to some logic and with us we
already can build as a grandma for human
language so this is a simple sentence it
works nobody gets an error message
thrown jessica talks and we have two
types of words in this sentence one is
called a noun
jessica is a noun it's the word that
identifies a person an animal a place a
thing or an idea um the other thing is
talks and this is a verb and the verb is
one of the main parts of any sentence or
any language you have you will always
find verbs in languages they're like
functions i Jessica talks talking is
kind of a function of the object Jessica
and they really tied the information
together that we're having hmm like a
real real sentence or a question cannot
work without a work they of course some
exceptions but in general the verb is
the important thing this is how
important these action parts of speech
are the verb signals an action and a
chorus or state of being whether mental
physical and mechanical
somehow there's an activity expressed so
a simple rule for English sentence would
be a sentence is a noun followed by a
verb so we would have a rewrite rule
like this so have signed a symbol for a
sentence I could replace them with noun
and verb and this allows us some simple
sentences like Jessica talks or
Florencia tenses but we reached the
borders of our grammar pretty fast with
just the dog barks or Florencia dances
with a broomstick and in linguistics we
call that grammar not expressive enough
so we need to add more
to form a complete grammar so when we
have a sentence like Jessica talks about
machine learning we again see more nouns
we see the verb that we had before and
we have a new word about which we call a
preposition this is the word word form
that links nouns pronouns and phrases
together in a sentence so to create a
new meaning so we remember this rule and
now sending us a noun and a verb we say
okay that's not enough so now we can
come up with something more expressive
now the word phrases come into that
corner phrases are just groups of words
that form a specific unit in a sentence
so noun phrase it's not just now like
Jessica can also be noun in an article
like the dog and the verb phrase is not
just the verb but all the information
that belongs to it so talks about
machine learning there are some elements
to form a grammars that we use so called
non-terminal systems symbols like noun
verb and prepositional word forms
terminal systems that are symbols that
are actual words in a set of rules when
we have a couple of rules we can use
them one after the other so we start
with the s we expanded to noun phrase
and verb phrase we expanded to noun and
verb phrase and so on you see that
there's a kind of tree structure
emerging from it and non-terminal
systems just appear in the inner notes
and the terminal symbols and we'll learn
that at one point other leaves of the
tree and this is a simple grammar
applying the productions you can see on
the right hand side how that works and
with that very simple grammar we can
actually already form quite a lot of
sentences so the children talk about
jessica is developed sentence in just
our four to six row grammar
children sing with joy children sing etc
and now the cool thing of grammars comes
into play we have we can generate
sentences with it
and if we write our grammar in a
specific way we can have an infinite
amount of sentences with just a finite
set of rules which is pretty cool so if
we just add something that we call
adjectives so the children sing the big
children sing the big funny children
sing the big funny lovely children
seeing you can see that we can create an
infinite amount of sentences just by
adding the rule that we allow adjectives
now and this is cool because we somehow
seem to be able to harness an Internet
group of sentences was just a few rules
this was a very quick run-through how
formal grammars for natural languages
work so they get the idea and the
knowledge that you need for the nice
things with a plant just a heads up if
we ever are interested in that you will
see that these small grammars are just
not expressive enough these were
so-called regular grammars but there is
something called context-free grammars
or context-sensitive grammars allow for
more complex sentences that might escape
the simple rule set so now to this to
the plants there's another lovely person
called OST Linda Mya it's actually a
theoretical biologist and there's a nice
origin story how all this works together
he was teaching at a university and he
was working on describing the growth of
algae actually so the plants in the
water and it was thinking a lot about
that and he was passing a room where
they were teaching theoretical computer
science and talking about the language
of grandma's so what kind of set of
sentences is a specific grandma
producing and in theoretical computer
science it's denoted with L G and he
just heard oh they're talking about L GL
dude
seems to be something that's my interest
because I'm looking at those plans and
he went into the class not knowing that
he was mistaken but from that class he
was watching learning about grammars and
rules it was actually able to develop a
theory based on that to describe plant
growth so these systems that he
developed are so-called L systems or
Lindenmayer systems and they describe
the behavior of plant cells to model the
growth process of plant development it
started with the algae but later it was
more complex organisms and when you look
at those plants you see that there's
some kind of structure to it some kind
of rule it's not just based in the wild
and its tree and having a grimmer gives
us actually the possibility to describe
something like this this is a simple
plant it grows and when we watch the
different stages of the plant growth we
actually see that there's some sort of
system for it there's also some sorts of
repeating elements so we have a size one
leaf somewhere we have a stem we have a
size two leaf or a size three leaf so
from the first of the second plan
besides one leaf has been replaced by
two sides one leaves the second one the
two sides of one leaves have been
replaced by a stem and the two sides one
leaves so we can actually already see
that there's some kind of rewriting
could be going on when we talk about
linear systems we have two main elements
of our grammar so first we had those
terminal symbols and non-terminal
symbols and then let my assistants we
just have an axiom it's kind of the seed
of the plant so the starting word
so to speak and replacement rules that
describe how our plants grow and and the
linguistics grammar we applied one rule
after the other and then from our
systems the rules are actually applied
altogether so on our first step we have
our seed our s and we have a rule that
says replace the S with L and s okay we
do that and then we have an L that says
replace it with SS R and we have an S
again so now the rule for the s and the
L will apply as well every stage of rule
application is actually a different
plant and as developed plant so first we
have the seat then we have one leaf and
we have a couple of leaves and then in
the end we have a tree and you see if
you write the rules the right way the
words the trees can be pretty big pretty
soon so to summarize it's a rewrite
system we have the seat in the beginning
all rules applied at once and every step
is a relative word or plant and the
final result we can actually translate
into a visual here's the comparison to
the Chomsky gamez we have a root with a
non-terminal we apply our rules and in
the end we have a valid sentence we
don't really need to translate it into
something visual unless we want to print
it on the screen our brain is
translating it to actual phonemes and
words in our mouth but with the
Lindenmayer systems we can actually
translate it into anything we want and
an easy way to start with this is
something called turtle graphics
I love turtle graphics as an explanation
because just imagine there's a turtle
and in its mouth is a pen and the turtle
walks over a sheet of paper according to
some rules so we have if we have a word
like this guess what mean draw straight
line L what mean turn left our word mean
turn right so we start here supposed to
draw a straight line then there's a turn
left another straight line
turn right another turn right a straight
line turn left straight line this is
turtle graphics and we can use them to
visualize our
plant words so we start with the seed
have the set of rules and then we
translate the symbols with the meaning
into something else I kind of put two
stalks together so I apologize for the
repeating slides but this is again
symbols with the meaning translated into
turtle graphics so now we have a couple
of iterations where we use our rule sets
to create new stages so the first thing
the axiom is just a straight line it's a
valid word if we have our rule applied
one it's a very big rule we can see the
little triangle that we just had with a
turtle but even the second iteration
already shows us sorry I guess like a
fractal structure so all parts all
straight lines are replaced with that
little triangle and grow and grow and
grow turtle graphics is one thing wake
translated to the other thing it's
basically whatever you want so the
biggest picture I think is surrender
tonight in a frame which is a 3d library
that you can use in VR settings the
upper right is just plain canvas and the
lower right is three JIS they actually
use the same grammar some with different
starting seeds but this is about it so
you can do quite interesting stuff with
it so for a more complex example which I
don't expect you to fully understand by
the code we only just have two rules but
one rule is pretty long the X is just a
placeholder to be used in other rules so
you can see that our plans our words
will be getting bigger and bigger and
bigger with every step and we can yeah
actually see what's happening with that
kind of rule so now it's praying time
because I have to change my settings so
this is one of the trees rendered in
three.js as I said but here is a simple
small tree that uses the grandma that I
just showed you
it's rendered on on canvas so our rules
are actually just translated into canvas
operations so the rotation the saving or
restoring what's just actually drawing a
path to somewhere here we have three
iterations right now and let's see what
happens if we apply the rule just one
more time so once the read this is
actually five iterations now you can see
that the word is enormous just by
applying those two rules five times and
we can actually see a tree that has been
growing here c6 crushes the browser
no but it's getting too big for the tool
tool to see you see and this is so
there's no really complex operations
involved that you need to describe how
to render this tree is just set of two
rules and some translation into
something to visualize it and I find
that is pretty cool this library is
actually not developed by me but by a
person called Tom prover who was I think
was part of his master thesis he's not
here today but he's from Berlin so check
him out if you're interested
so going back to my displays so although
this was a very complex thing for some
of you to understand probably it's even
not enough not expressive enough just as
simple grammars were not expressive
enough for our natural language we need
to keep be more expressive for more
complex systems so for example there's
some kind of randomness involved
sometimes like depending on whether
there's a bird sitting on a tree when
it's trying to gross or not a tree can
be growing in another direction
depending where the Sun is coming from
parts of the tree actually need
different rules than other parts of the
tree so we have something called
so hashtag l-systems parametric
l-systems etc is very fun to play around
with that if you're interested and
that's it
thank you for your attention if you want
to look at anything from that these are
the search and in terms that might be
interesting for you and let me know if
you want to talk about it I like talking
about languages
[Applause]
[Music]