Download presentation
Presentation is loading. Please wait.
Published byIris Sullivan Modified over 8 years ago
1
Week 14 - Friday
2
What did we talk about last time? Simplifying FSAs Quotient automata
4
P RINCE 1958 - 2016 His Royal Badness
5
A sociologist named McSnurd gave a talk about a community that has clubs with the following attributes: A person can belong to more than one club Each club is named after a person No two different clubs are named after the same person Every person has a club named after him or her A person may or may not belong to the club named after them ▪ If they do, that person is called sociable ▪ If they don't, that person is called unsociable Perhaps surprisingly, there is a club that contains all of the unsociable people Do you believe McSnurd's description?
6
Another sociologist named McSnuff described a similar community: As before, there is the same number of clubs as people, and each club is named after exactly one person However, a person can be a member of a club openly or secretly ▪ If a person is not openly a member of the club named after them, they are suspicious ▪ If a person is secretly a member of the club named after them, they are a spy Perhaps surprisingly, there is a club that contains all of the suspicious people Do you believe McSnuff's description? Do you know whether or not there is at least one spy in the community?
7
Prove that the following two automata are equivalent by finding their quotient automata s0s0 s0s0 s2s2 s2s2 s1s1 s1s1 0 1 1 s3s3 s3s3 0 0 1 1 0 s0's0' s0's0' s1's1' s1's1' s2's2' s2's2' 0, 1 0 1 s3's3' s3's3' 0 0 1 1
9
A context free language is one that can be described by a context free grammar Every regular language is context free, but there are context free languages that are not regular Classic examples: Strings of k 0's followed by k 1's Palindromes made up of a's and b's Legally nested parentheses All of these involve counting arbitrary numbers of characters Regular expressions can't count
10
Instead of using regular expressions, a context free language is often described with a grammar A grammar is a formal system of rewriting rules consisting of Terminals: symbols of the alphabet Non-terminals: symbols that produce other sequences of terminals and non-terminals Grammars often start with the non-terminal starting symbol S Any string that can be derived from S through some sequence of rule rewrites is a string in the language
11
The following is a grammar that produces the language of strings of 1s and 0s that end in a 1 S A1S A1 A ε | 1 | 0 | A1 | A0 This language is regular and is equivalent to (0 | 1)* 1 The following is a grammar that produces the language of a k b k where k ≥ 1 (which is not regular S AS A A ab | aAb
12
Write a grammar that legal nesting of parentheses and braces in Java Don't worry about the stuff that goes inside Write a grammar for legal mathematical expressions in Java using variables and integers, +, -, *, /, and parentheses Write a grammar that corresponds to the same language defined by the regular expression ab* (a | bb) (ba)*
13
As you know, regular languages can be expressed by regular expressions and finite state automata Thus, regular expressions are equal to FSAs in power Context free languages can be expressed by context free grammars There is also a class of automata called pushdown automata that correspond to context free languages
15
To make the PDA for the language 0 k 1 k, k ≥ 1, we have the following: In this case, the notation X/Y means that if X is on the top of the stack, replace it with Y The top of the stack is Z Notation is not well standardized for PDAs It's awkward keeping track of the stack s1s1 s1s1 s2s2 s2s2 s0s0 s0s0 0: Z/AZ 0: A/AA 1: A/ε 1: A/A 1: Z/Z
17
Noam Chomsky is a brilliant linguist who has recently focused mostly on political activism Remember that a grammar consists of terminals (alphabet symbols), non-terminals, production rules, and a start symbol He noted that grammars can be divided into four levels in terms of expressiveness: Type-0 (Unrestricted grammars) Type-1 (Context sensitive grammars) Type-2 (Context free grammars) Type-3 (Regular grammars)
18
Each grammar has rules for what is a legal production rule Let α, β, and γ be any combinations of terminals and non-terminals, where γ is non-empty 1. Unrestricted grammars α β (anything to anything) 2. Context-sensitive grammars αAβ αγβ (non-terminal in a particular context to anything) 3. Context-free grammars A γ (a single non-terminal to anything) 4. Regular grammars A a and A aB (a single non-terminal to a single terminal or a terminal and a single non-terminal on the right side)
19
Every kind of language has a particular kind of machine associated with it GrammarLanguagesAutomaton Production Rules Examples Type-0 Recursively enumerable Turing machine α βα β All languages, any computable functions Type-1 Context- sensitive Linear-bounded non- deterministic Turing machine αAβ αγβ Most natural human languages Type-2Context-free Non-deterministic pushdown automaton A γ Most programming languages Type-3RegularFinite state automaton A a and A aB Regular expressions
20
Each set of languages in the hierarchy strictly contains the sets beneath it Regular languages Can be accepted by nondeterministic or deterministic finite automata (or a read-0nly Turing machine) Are closed under union, intersection, complement, concatenation, and Kleene star Context-free languages Are defined by those languages accepted by nondeterministic pushdown automata Are closed under union, concatenation, and Kleene star (but not under intersection or complement) Deciding whether a string is in a context-free language can be determined in polynomial time Deciding whether a language is empty is decidable Context-sensitive languages Are very rarely used Are closed under union, intersection, complement, and Kleene star Deciding whether a string is in a context-sensitive language is a PSPACE-complete problem Recursively enumerable Context- sensitive Context-free Regular
21
A Turing machine is a mathematical model for computation It consists of a head, an infinitely long tape, a set of possible states, and an alphabet of characters that can be written on the tape A list of rules saying what it should write and should it move left or right given the current symbol and state 1011110000 A A
22
You can specify a Turing machine with a table giving its behavior for a specific configuration Turing's first example machine printed an infinite sequence of alternating 1s and 0s, separated by spaces: ConfigurationBehavior StateSymbolOperationResult State BBlankWrite 0, Move RightC CBlankMove RightE EBlankWrite 1, Move RightF FBlankMove RightB
23
If an algorithm exists, a Turing machine can perform that algorithm In essence, a Turing machine is the most powerful model we have of computation Power, in this sense, means the ability to compute some function, not the speed associated with its computation Do you own a Turing machine?
24
Given a Turing machine and input x, does it reach the halt state? As you know, there is no algorithm to determine this If you had a Turing machine that could solve the halting problem, it would cause a logical contradiction
25
Are two context-free languages the same? Is the intersection of two context-free languages empty? Is a context-free language equal to Σ * Is a context-free language a subset of another context-free language? Post correspondence problem: You have lists a 1, a 2, … a n and b 1, b 2, … b n, where a i and b j are strings of some alphabet Σ with at least 2 symbols Is there a value k ≥ 1 such that some sequence of k strings from the a list concatenated is equal to some sequence of k strings from the b list concatenated? Is a given statement of first-order logic provable from a starting set of axioms? Given a set of matrices, is there some sequence that they can be multiplied in (perhaps with repetitions) that will yield the zero matrix?
28
Review first third of the course
29
Review chapters 2 - 6 Finish Assignment 10 Due Monday before midnight
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.