2018-2019 icon indicating copy to clipboard operation
2018-2019 copied to clipboard

Lecture "Introduction to Computational Thinking", exercise 1

Open essepuntato opened this issue 6 years ago • 11 comments

What are all the possible sentences that can be produced by using the regular grammar introduced in Section "Historic hero: Noam Chomsky"?

essepuntato avatar Nov 11 '18 21:11 essepuntato

regular grammar <sentence> ::= "I" <sentence> ::= "you" <verb> ::= "write" <verb> ::= "read" Possible sentences: I write (terminal "I"+ non terminal <verb> in this case "write") I read (terminal "I"+ non terminal <verb> in this case "read") you write (terminal "You"+ non terminal <verb> in this case "write") you read (terminal "you"+ non terminal <verb> in this case "read")

MattiaSpadoni avatar Nov 12 '18 15:11 MattiaSpadoni

Regular grammar possible generic sentence: <non terminal> ::= "terminal" <non terminal> ::= "terminal" <non terminal>

i.e.

<sentence> ::= "I" <sentence> ::= "you" <verb> ::= "write" <verb> ::= "read"

possible example sentences

I write ("terminal" = "I" and <non terminal> = <verb>('write')) I read ("terminal" = "I" and <non terminal> = <verb>('read')) you write ("terminal" = "you" and <non terminal> = <verb>('write')) you read ("terminal" = "you" and <non terminal> = <verb>('read'))

ilsamoano avatar Nov 12 '18 15:11 ilsamoano

Regular grammar rules can be summarized in: <non-terminal> ::= "terminal" <non-terminal> ::= "terminal"

For example, in order to create a sentence, this could be the combination:

<sentence> ::= "I" <verb> <verb> ::= "eat" <verb> ::= "sleep"

Possible combinations: I eat (composed by the terminal "I" and the <non-terminal>/<verb> "eat") I sleep (composed by the terminal "I" and the <non-terminal>/<verb> "sleep")

VittoriaMoccia avatar Nov 13 '18 11:11 VittoriaMoccia

From regular grammar with production rules:

<sentence> ::= "I" <verb> <sentence> ::= "you" <verb> <verb> ::= "write" <verb> ::= "read"

Possible sentences:

I write ( <terminal> = "I"; <non-terminal>=<verb>("write")) I read( <terminal> = "I"; <non-terminal>=<verb>("read")) you write ( <terminal> = "you"; <non-terminal>=<verb>("write")) you read ( <terminal> = "you"; <non-terminal>=<verb>("read"))

delfimpandiani avatar Nov 13 '18 12:11 delfimpandiani

Forms of production: <non terminal> ::= "terminal" <non terminal> ::= "terminal" <non terminal>

For instance: <sentence> ::= "He" <verb> <sentence> ::= "She" <verb> <verb> ::= "runs" <verb> ::= "works"

Possible combinations: He runs ("terminal" = "He" and = <verb> "runs") He works ("terminal" = "He" and = <verb> "works") She runs ("terminal" = "She" and = <verb> "runs") She works ("terminal" = "She" and = <verb> "works")

tceron avatar Nov 13 '18 12:11 tceron

Form of production rules for regular grammar: <non-terminal>::="terminal" and <non-terminal>::="terminal" <non-terminal>

<sentence>::="I" <verb> <sentence>::="We" <verb>

<verb>::="cry" <verb>::="die"

I cry ("terminal" = I and <verb>, specifically <verb> = cry) I die ("terminal" = I and <verb>, specifically <verb> = die) We cry ("terminal" = We and <verb>, specifically <verb> = cry) We die ("terminal" = We and <verb>, specifically <verb> = die)

That allows me to create all the two-word sentences having as a terminal either the first person singular or the first person plural pronoun accompanied by either the (non-terminal part) <verb> "cry" or the <verb> "die", for a total of four combinations.

friendlynihilist avatar Nov 13 '18 12:11 friendlynihilist

<sentence>::= "I" <verb> <sentence>::= "They" <verb> <verb>::= "walk" <verb>::="fly"

I walk (terminal: "I", terminal: "walk", non-terminal: <verb> ) I fly (terminal: "I", terminal: "fly", non-terminal: <verb> ) They walk (terminal:"They", terminal: "walk", non-terminal: <verb> ) They fly (terminal:"they", terminal:"fly", non-terminal: <verb> )

Ioanna96 avatar Nov 13 '18 12:11 Ioanna96

 Possible sentences that can be produced by using the regular grammar:

<non terminal> ::= "terminal" <non terminal> ::= "terminal" 

Examples:

<sentence> ::= “I” <sentence> ::= “You” <verb> ::= “write” 
<verb>  ::= “read” 


Possible example sentences:

I write ("terminal" = "I" and  =  “write”)
I read ("terminal" = "I" and  = “read”)
You write ("terminal" = “You" and  =  “write”)
You read ("terminal" = “You" and  =  “read”)

lisasiurina avatar Nov 13 '18 12:11 lisasiurina

Form of production rules of regular grammars: non-terminal ::= "terminal" and <non-terminal> ::= "terminal" <non-terminal>.

i.e. <sentence> ::= "I" <verb> <sentence> ::= "we" <verb> <verb> ::= "run" <verb> ::= "walk"

Considering these non-terminal elements we can produce four possible sentences:

  1. I run - <pronoun> ::= "I" and <verb> ::= "run"
  2. I walk - <pronoun> ::= "I" and <verb> ::= "walk"
  3. we run - <pronoun> ::= "we" and <verb> ::= "run"
  4. we walk - <pronoun> ::= "we" and <verb> ::= "walk"

mchiaraf avatar Nov 13 '18 15:11 mchiaraf

A sentence can either contain "I" plus a verb or "You" plus a verb. There are two defined verbs: "write" and "read". Hence, four constellations are possible.

  1. I write
  2. I read
  3. You write
  4. You read

SeverinJB avatar Nov 13 '18 16:11 SeverinJB

@MattiaSpadoni and @ilsamoano and @lisasiurina

<sentence> ::= "I" <sentence> ::= "you"

There is something strange here... maybe you wanted to refer to <pronoun> instead of <sentence>?

essepuntato avatar Nov 16 '18 07:11 essepuntato