Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.

Similar presentations


Presentation on theme: "1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages."— Presentation transcript:

1 1 Languages

2 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages

3 3 Alphabets and Strings We will use small alphabets: Strings

4 4 String Operations Concatenation

5 5 Reverse

6 6 String Length Length: Examples:

7 7 Recursive Definition of Length For any letter: For any string : Example:

8 8 Length of Concatenation Example:

9 9 Proof of Concatenation Length Claim: Proof: By induction on the length Induction basis: From definition of length:

10 10 Inductive hypothesis: for Inductive step: we will prove for

11 11 Inductive Step Write, where From definition of length: From inductive hypothesis: Thus:

12 12 Empty String A string with no letters: Observations:

13 13 Substring Substring of string: a subsequence of consecutive characters String Substring

14 14 Prefix and Suffix Prefixes Suffixes prefix suffix

15 15 Another Operation Example: Definition:

16 16 The * Operation : the set of all possible strings from alphabet

17 17 The + Operation : the set of all possible strings from alphabet except

18 18 Language A language is any subset of Example: Languages:

19 19 Another Example An infinite language

20 20 Operations on Languages The usual set operations Complement:

21 21 Reverse Definition: Examples:

22 22 Concatenation Definition: Example:

23 23 Another Operation Definition: Special case:

24 24 More Examples

25 25 Star-Closure (Kleene *) Definition: Example:

26 26 Positive Closure Definition:

27 27 Finite Automata

28 28 Finite Automaton Input String Output String Finite Automaton

29 29 Finite Accepter Input “Accept” or “Reject” String Finite Automaton Output

30 30 Transition Graph initial state final state “accept” state transition Abba -Finite Accepter

31 31 Initial Configuration Input String

32 32 Reading the Input

33 33

34 34

35 35

36 36 Output: “accept” Input finished

37 37 Rejection

38 38

39 39

40 40

41 41 Output: “reject” Input finished

42 42 Another Example

43 43

44 44

45 45

46 46 Output: “accept” Input finished

47 47 Rejection

48 48

49 49

50 50

51 51 Output: “reject” Input finished

52 52 Formalities Deterministic Finite Accepter (DFA) : set of states : input alphabet : transition function : initial state : set of final states

53 53 Input Alphabet

54 54 Set of States

55 55 Initial State

56 56 Set of Final States

57 57 Transition Function

58 58

59 59

60 60

61 61 Transition Function

62 62 Extended Transition Function

63 63

64 64

65 65

66 66 Observation: There is a walk from to with label

67 67 Recursive Definition

68 68

69 69 Languages Accepted by DFAs Take DFA Definition: The language contains all input strings accepted by = { strings that drive to a final state}

70 70 Example accept

71 71 Another Example accept

72 72 Formally For a DFA Language accepted by : alphabet transition function initial state final states

73 73 Observation Language accepted by : Language rejected by :

74 74 More Examples accept trap state

75 75 = { all substrings with prefix } accept

76 76 = { all strings without substring }

77 77 Regular Languages A language is regular if there is a DFA such that All regular languages form a language family

78 78 Example The language is regular:


Download ppt "1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages."

Similar presentations


Ads by Google