Docsity

system programming introduction, Slides of Introduction to Computing

Partial preview of the text

Download system programming introduction and more Slides Introduction to Computing in PDF only on Docsity!

System Programming

Lecture #2,

Language Representation

2

  • Human Languages
  • Programming Languages
  • Formal Languages

Languages

4

C, Java, Python, Prolog, Pascal,...

When is a program:

  1. syntactically correct?

  2. compilable?

  3. free from fatal exceptions at runtime?

  4. free from deadlock or infinite loops?

  5. a correct implementation of its

specification?

Programming Languages

Formal Languages Definition ---

Study of “strings of symbols,” including their

 descriptions, properties,

 generations, recognitions,

 compiling, applications, … Strings of symbols include those of

 natural languages,  computer languages,  discrete signals, …

Language Definition

Dr. Gouda

Language Definition

Dr. Gouda

Strings

 The empty string will be denoted by e

 Examples

A string over alphabet S is a finite sequence

of symbols in S.

abfbz is a string over S 1 = {a, b, c, d, …, z} 9021 is a string over S 2 = {0, 1, …, 9} ab#bc is a string over S 3 = {a, b, …, z, #} ))()(() is a string over S 4 = {(, )}

Languages

 Languages can be used to describe problems

with “yes/no” answers, for example:

A language is a set of strings over an alphabet.

L 1 = The set of all strings over S 1 that contain the substring “fool” L 2 = The set of all strings over S 2 that are divisible by 7 = {7, 14, 21, …} L 3 = The set of all strings of the form s#s where s is any string over {a, b, …, z} L 4 = The set of all strings over S 4 where every ( can be matched with a subsequent )

EXAMPLE 1 The language defined by the expression aba language (aba) = {aa aba abba abbba abbbba ...}**

EXAMPLE 2 The language of the expression ab language(ab) = {λ a b aa ab bb aaa aab abb bbb aaaa ...} we should be very careful to observe that ab ≠ (ab)***

EXAMPLE 3 Consider the language T defined over the alphabet Σ = {a, b, c} T = {a c ab cb abb cbb abbb cbbb abbbb cbbbb ...} T = language ((a + c)b) = language (either a or c then some b's)*

EXAMPLES 1- Consider a finite language L that contains all the strings of a's and b's of length exactly three. L = {aaa aab aba abb baa bab bba bbb} we may write L = language ((a + b)(a + b)(a + b)) or for short, L = language ((a + b)^3 ) 2- The set of all possible strings of a's and b's of any length whatsoever we could write, (a + b)*

3- We can describe all words that begin with the letter a simply as: a(a + b) 4- All words that begin with an a and end with a b can be defined by the expression a(a + b)b = a (arbitrary string) b**

Definition

 For primitive regular expressions:

L( ∅ ) = ∅

L(λ ) = {λ}

L(a) = {a}