Languages
Languages A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet:
Alphabets and Strings We will use small alphabets: Strings
String Operations Concatenation
Reverse
String Length Length: Examples:
Recursive Definition of Length For any letter: For any string : Example:
Length of Concatenation Example:
Proof of Concatenation Length Claim: Proof: By induction on the length Induction basis: From definition of length:
Inductive hypothesis: for Inductive step: we will prove
Inductive Step Write , where From definition of length: From inductive hypothesis: Thus:
Empty String A string with no letters: Observations:
Substring Substring of string: a subsequence of consecutive characters
Prefix and Suffix Prefixes Suffixes prefix suffix
Another Operation Example: Definition:
The * Operation : the set of all possible strings from alphabet
The + Operation : the set of all possible strings from alphabet except
Language A language is any subset of Example: Languages:
Another Example An infinite language
Operations on Languages The usual set operations Complement:
Reverse Definition: Examples:
Concatenation Definition: Example:
Another Operation Definition: Special case:
More Examples
Star-Closure (Kleene *) Definition: Example:
Positive Closure Definition:
Finite Automata
Finite Automaton Input String Output Finite Automaton String
Finite Accepter Input String Output “Accept” or Finite “Reject” Automaton
Transition Graph Abba -Finite Accepter initial state final state
Initial Configuration Input String
Reading the Input
Input finished Output: “accept”
Rejection
Input finished Output: “reject”
Another Example
Input finished Output: “accept”
Rejection
Input finished Output: “reject”
Formalities Deterministic Finite Accepter (DFA) : set of states : input alphabet : transition function : initial state : set of final states
Input Alphabet
Set of States
Initial State
Set of Final States
Transition Function
Transition Function
Extended Transition Function
Observation: There is a walk from to with label
Recursive Definition
Languages Accepted by DFAs Take DFA Definition: The language contains all input strings accepted by = { strings that drive to a final state}
Example accept
Another Example accept accept accept
Formally For a DFA Language accepted by : alphabet transition function initial state final states
Observation Language accepted by : Language rejected by :
More Examples trap state accept
= { all substrings with prefix } accept
= { all strings without substring }
Regular Languages A language is regular if there is a DFA such that All regular languages form a language family
Example The language is regular: