Basic Concepts of Formal Languages

Embed Size (px)

Citation preview

  • 7/31/2019 Basic Concepts of Formal Languages

    1/4

    Basic Concepts of Theory of Computation

    Alphabet or Vocabulary: - A finite, non-empty, ordered set of symbols or characters is called an

    alphabet. Alphabets are generally denoted by . Empty set or null set is not an alphabet.

    String or sentence or word: - A finite sequence of symbols from a given alphabet is called a string

    over that alphabet. String consisting of no symbols is called empty string and is denoted by .

    For example: - Let 1 ={ a, b, , z } and 2 ={ 0, 1, , 9 } are alphabets.

    1. abb is a string over alphabet 1.2. 123 is a string over alphabet 2.3. But ab12 is not a string over any of these alphabets.4. 3456 is also not a string over alphabet 2, because it is not finite.5. is a string over any alphabet.6. Set of natural numbers is not an alphabet because it is not finite.

    Unary Alphabet: - Alphabet containing only one symbol is called a unary alphabet.

    Unary Strings: - Strings over unary alphabet are called unary strings.

    Binary Alphabet: - Alphabet containing two symbols only is called a binary alphabet.

    Binary Strings: - Strings over binary alphabet are known as binary strings.

    Length of a String: - Length of a string is the number of symbols present in . Length of a string

    s denoted by ||

    For example: -

    1. {0, 1} is a binary alphabet.2. 00111, 1000, 1101111 are the binary strings over the binary alphabet {0, 1}.3. {1} is a unary alphabet.4. 1111 is a binary string over the alphabet {0, 1} and a unary string over the alphabet {1}.5. Length of 111 is 3.6. ||

    Concatenation: - Concatenation of string and string is a string . is a string obtained

    concatenating I copies of.

    For example: -

    1. If then , , , .2. Concatenation of and or concatenation of and will give i.e. is the identity

    for concatenation.

    3. , where n is any non-negative integer.Substring: - A string is said to be the substring of another string if for some and .

  • 7/31/2019 Basic Concepts of Formal Languages

    2/4

    Prefix: - A substring of string is called the prefix of if for some . If then is

    called proper prefix of.

    Suffix: - A substring of string is called the prefix of if for some . If then is

    called proper suffix of.

    For example: -

    1. , 0, 1, 01, 11 and 011 are the substrings of 011.2. , 0, 1, 01, 011 are prefixes of 011.3. , 0, 1, 01 are proper prefixes of 011.4. , 1, 11, 011 are suffixes of 011.5. , 1, 11 are proper suffixes of 011.

    Reverse of a string: - Reverse of a string =a1a2an is a string denoted by or anan-1a2a1

    Permutation of a string: - String is said to be the permutation of string if can be obtained by

    reordering the symbols of.

    For example: -

    1. 102 is a string.2. 210, 120, 012 are the permutations of the above string.

    Powers of an alphabet: -

    1. The set of all strings over an alphabet is denoted by *.2. + denotes the set *- .3. k denotes the set of all strings of length k present in *

    Note: - 0 = For example: -

    Let = {0, 1} be an alphabet

    1. * = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, }2. += {0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, }3. 1 = {0, 1}4. 2 = {00, 01, 10, 11}5. 3 = {000, 001, 010, 011, 100, 101, 110, 111}

    Alphabetically Smaller String: - A string is said to be alphabetically smaller than another string

    or is said to be alphabetically bigger than , where and are in *, if any of the following

    conditions is true.

    1. is proper prefix of.2. For some which is a prefix of both and , a and b are prefixes of and

    respectively where, a precedes b in .

  • 7/31/2019 Basic Concepts of Formal Languages

    3/4

    Alphabetically Ordered: - An ordered subset of* is said to be alphabetically ordered if is

    alphabetically smaller than whenever precedes .

    For example: -

    Let = {0, 1} be an alphabet.

    1. 01 is alphabetically smaller than 0110.2. 011011 is alphabetically smaller than 01110 because at 4th position 0 is preceded by 1

    in .

    3. {0, 00, 000, 001, 01, 010, 011, 1, 10, 100, 101, 11, 110, 111} is in alphabetical order.Canonically or Lexicographically Smaller String: - A string is said to be canonically smaller than

    another string or is said to be canonically bigger than , where and are in *, if any of the

    following conditions is true.

    1. is shorter in length than .2. and are identical in length then is alphabetically smaller than .

    Canonically Ordered: - An ordered subset of* is said to be canonically ordered if is canonically

    smaller than whenever precedes .

    For example: -

    Let = {0, 1} be an alphabet.

    1. 00 is canonically smaller than 0000.2. 0110 is canonically smaller than 100.3. 101 is canonically bigger than 100.4. {0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111} is in canonical order.

    Note: - Canonical order is same as the order in the truth table of a Boolean function.Language: - If is an alphabet which can be understood then any subset of * is said to be a

    anguage over or simply a language.

    For example: -

    Let = {0, 1} be an alphabet, then

    1. * is a language2. is a language3. {0, 00, 10, 111} is a language4. Empty set is a language

    Note: -

    Empty set and are the languages over every alphabet. because has no strings but latter has one string i.e. empty string .

  • 7/31/2019 Basic Concepts of Formal Languages

    4/4

    Union and Intersection of two Languages: - Since we know that language is a set therefore union

    of two languages is same as union of two sets. Similarly intersection of two languages is same as

    ntersection of two sets. Union of two languages L1 and L2 is denoted by L1L2. Their intersection is

    denoted by L1L2.

    Complementation of a Language: - Similarly complementation of a language is same as

    complementation o a set. Complementation of a language is denoted by .

    Difference of two Languages: - Similarly as above difference of two languages can be found out as

    we find the difference of two sets. Difference of two languages L1 and L2 is denoted by L1-L2.

    Composition of two languages: - Composition of two languages L1 and L2 is denoted by L1L2 and is

    defined as a language {xy : x is in L1 and y is in L2}.

    For example: -

    Let L1

    = {1, 0, 11, 001} and L2

    = {1, 0, 110, 111, 000} be two languages then

    1. L1L2 = {1, 0, 11, 001, 110, 111, 000}2. L1L2 = {1, 0}3. L1 L2 = {11, 001}4. L2-L1 = {110, 111, 000}5. 1 = {, 00, 01, 10, 000, 010, 011, 100, 101, }6. L1L2 = {11, 10, 1110, 1111, 1000, 01, 00, 0110, 0111, 0000, 111, 110, 11110, 11111,

    11000, 0011, 0010, 001110, 001111, 001000}

    Liis used to denote the composition of L with itself i times, where i > 0. L

    0=

    Kleene Closure of a Language L: - The set L0UL

    1UL

    2UL

    3 is called Kleene closure or just the closure

    of L. This set is denoted by L*.

    Positive Closure of a Language L: - The set L1L

    2L

    3 is called the positive closure of L. This set is

    denoted by L+.

    Li is the set of those strings that can be obtained by concatenating I strings from L and L* is the setof all those strings that can be obtained by concatenating any number of strings from L.

    For example: -

    Let L1 = {, 0, 1} and L2 = {01, 11} be two languages.

    1. L12 = {, 0, 1, 00, 01, 10, 11}2. L23 = {010101, 010111, 011101, 011111, 110101, 110111, 111101, 111111}

    Formal Language: - A language that can be defined by a formal system (i.e. a system that has finite

    number of axioms and a finite number of rules) is said to be a formal language.