SlideShare a Scribd company logo
http://www.free-powerpoint-templates-design.com
Discrete Structure
Support Workshop for Proficiency Exam CS Program 2024
Workshop Agenda
• Deterministic Finite State Automata
• Regular Expressions
• Context Free Grammar
• ProofTechniques and their Structures
• (direct proof, proof by contradiction, and induction)
• Recurrence Relations
• ModularArithmetic-based Computations
• Recursion and its use
Deterministic Finite State Automata(DFA)
Deterministic Finite State Automata(DFA)
An informal definition :
• A diagram with a finite number of states represented by circles
• An arrow points to one of the states, the unique start state
• Double circles mark any number of the states as accepting states
• For every state, for every symbol in ∑ , there is exactly one arrow labeled with
that symbol going to another state (or back to the same state)
DFAs Define Languages
• Given any string over ∑ , a DFA can read the string and follow its state-to-
state transitions
• At the end of the string, if it is in an accepting state, we say it accepts the
string
• Otherwise it rejects
• The language defined by a DFA is the set of strings in ∑* that it accepts
The 5-Tuple • Q is the set of states
• Drawn as circles in the diagram
• We often refer to individual states as qi
• The definition requires at least one: q0,
the start state
• ∑ is the alphabet (that is, a finite set of
symbols)
A DFAM is a 5-tuple M = (Q, ∑,δ, q0, F), :
where Qis the finite set of states∑ is the
alphabet (that is, a finite set of symbols)
δ ∈ (Q× ∑ →Q) is the transition function
q0 ∈ Q is the start state
F≤Q is the set of accepting states
introductory Discrete structure workshop.pptx
Regular Languages
Example
introductory Discrete structure workshop.pptx
introductory Discrete structure workshop.pptx
Regular Expressions
Regular Expressions
A regular expression (RE) describes a language. It uses the
three regular operations.
•These are called union/or, concatenation and star.
• Brackets ( and ) are used for grouping, just as in normal
math.
Union/or
• The symbol + means union or or.
• Example: 0 + 1 means either a zero or a one.
concatenation
• The concatenation of two REs is obtained by writing the one
after the other.
• (0 + 1) 0 corresponds to {00, 10}.
• (0 + 1) (0 + ε) corresponds to {00, 0, 10, 1}.
star
• The symbol ∗ means zero or more copies
• a ∗ corresponds to any string of a’s: {ε, a, aa, aaa, . . .}
• (0 + 1) ∗ corresponds to all binary strings
Example
•An RE for the language of all binary strings of length at
least 2 that begin and end in the same symbol.
0(0 + 1) ∗0 + 1(0 + 1) ∗1
•Note precedence of regular operators: star always refers
to smallest piece it can, or to largest piece it can.
Example
•Consider the regular expression ((0 + 1) ∗1 + ε) (00) ∗ 00
• This RE is for the set of all binary strings that end with an
even nonzero number of 0’s.
•Note that different language to: (0 + 1) ∗ (00) ∗ 00
Regular Operators for Languages
• If one forms RE by the or of REs R and S, then result is union of R
and S.
• If one forms RE by the concatenation of REs R and S, then the
result is all strings that can be formed by taking one string from R
and one string from S and concatenating.
• If one forms RE by taking the star of RE R, then the result is all
strings that can be formed by taking any number of strings from
the language of R (possibly the same, possibly different), and
concatenating.
Regular Operators Example
If language L is {ma, pa} and language M is {be, bop}, then
• L +M is {ma, pa, be, bop};
•LM is {mabe, mabop, pabe, pabop}; and
• L ∗ is {ε, ma, pa, mama, . . . , pamamapa, . . .}.
Notation: If Σ is some alphabet, thenΣ ∗ is the set of all
strings using that alphabet.
Practice
Give an RE for each of the following three languages:
1. All binary strings with at least one 0
2.All binary strings with at most one 0
3.All binary strings starting and ending with 0
Solution
1.(0 + 1) ∗0(0 + 1) ∗
2.1 ∗ + 1 ∗01 ∗
3. 0(0 + 1) ∗0 + 0
In each case several answers are possible.
Context-Free Grammar
22
Informal Comments
• A context-free grammar is a notation for describing languages.
• It is more powerful than finite automata or RE’s, but still cannot define all
possible languages.
• Useful for nested structures, e.g., parentheses in programming languages.
23
Informal Comments – (2)
• Basic idea is to use “variables” to stand for sets of strings
(i.e., languages).
• These variables are defined recursively, in terms of one
another.
• Recursive rules (“productions”) involve only
concatenation.
• Alternative rules for a variable allow union.
24
Example: CFG for { 0n1n | n > 1}
• Productions:
S -> 01
S -> 0S1
• Basis: 01 is in the language.
• Induction: if w is in the language, then so is 0w1.
25
CFG Formalism
•Terminals = symbols of the alphabet of the language being
defined.
•Variables = nonterminals = a finite set of other symbols,
each of which represents a language.
•Start symbol = the variable whose language is the one
being defined.
26
Productions
• A production has the form variable -> string of variables and
terminals.
• Convention:
• A, B, C,… are variables.
• a, b, c,… are terminals.
• …, X,Y, Z are either terminals or variables.
• …, w, x, y, z are strings of terminals only.
• , , ,… are strings of terminals and/or variables.
27
Example: Formal CFG
•Here is a formal CFG for { 0n1n | n > 1}.
•Terminals = {0, 1}.
•Variables = {S}.
•Start symbol = S.
•Productions =
S -> 01
S -> 0S1
28
Derivations – Intuition
•We derive strings in the language of a CFG by starting
with the start symbol, and repeatedly replacing some
variableA by the right side of one of its productions.
•That is, the “productions for A” are those that haveA
on the left side of the ->.
29
Derivations – Formalism
•We say A =>  ifA ->  is a production.
•Example: S -> 01; S -> 0S1.
•S => 0S1 => 00S11 => 000111.
30
Iterated Derivation
•=>* means “zero or more derivation steps.”
•Basis:  =>*  for any string .
•Induction: if  =>*  and  => , then  =>* .
31
Example: Iterated Derivation
• S -> 01; S -> 0S1.
• S => 0S1 => 00S11 => 000111.
• So S =>* S; S =>* 0S1; S =>* 00S11; S =>* 000111.

More Related Content

PDF
Chapter2CDpdf__2021_11_26_09_19_08.pdf
DrIsikoIsaac
 
PPTX
[Compilers23] Lexical Analysis – Scanning Part I.pptx
nourelhudaawny
 
PPT
Formal Languages and regular langugaes IN FLAG
interestingfacts10
 
PPTX
Unit2 Toc.pptx
viswanath kani
 
PPTX
Chapter 4_Regular Expressions in Automata.pptx
KrishnenduRarhi
 
PDF
Syntax Analyzer.pdf
kenilpatel65
 
PPTX
Chapter One - Introduction to automata and complexity theory
biniyamtiktok
 
PPT
context free language
khush_boo31
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
DrIsikoIsaac
 
[Compilers23] Lexical Analysis – Scanning Part I.pptx
nourelhudaawny
 
Formal Languages and regular langugaes IN FLAG
interestingfacts10
 
Unit2 Toc.pptx
viswanath kani
 
Chapter 4_Regular Expressions in Automata.pptx
KrishnenduRarhi
 
Syntax Analyzer.pdf
kenilpatel65
 
Chapter One - Introduction to automata and complexity theory
biniyamtiktok
 
context free language
khush_boo31
 

Similar to introductory Discrete structure workshop.pptx (20)

PDF
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
TONY562
 
PPTX
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
PPTX
9781284077247_PPTx_CH01.pptx
mainakmail2585
 
PDF
Lexical analysis Compiler design pdf to read
shubhamsingaal
 
PDF
Lexical analysis compiler design to read and study
shubhamsingaal
 
PPTX
Regular expression (compiler)
ReachLocal Services India
 
PPT
Compiler Design in Engineering for Designing
Adityaverma750841
 
PPTX
Module 1 TOC.pptx
MohitJain21BCE1523
 
PPTX
Regular Expression to Finite Automata
Archana Gopinath
 
PPTX
Lecture 02 lexical analysis
Iffat Anjum
 
PPTX
Regular expression (compiler)
Jagjit Wilku
 
PPTX
Context Free Grammar
Akhil Kaushik
 
PPTX
Regular Expressions here we have .pptx
arslanahmadkhan295
 
PPT
Theory of computing
Ranjan Kumar
 
PPTX
Chapter Two - Regular Expression and Regular languages.pptx
biniyamtiktok
 
PDF
Lexicalanalyzer
Royalzig Luxury Furniture
 
PDF
Lexicalanalyzer
Royalzig Luxury Furniture
 
PDF
Lexical
baran19901990
 
PPT
compiler Design course material chapter 2
gadisaAdamu
 
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
TONY562
 
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
9781284077247_PPTx_CH01.pptx
mainakmail2585
 
Lexical analysis Compiler design pdf to read
shubhamsingaal
 
Lexical analysis compiler design to read and study
shubhamsingaal
 
Regular expression (compiler)
ReachLocal Services India
 
Compiler Design in Engineering for Designing
Adityaverma750841
 
Module 1 TOC.pptx
MohitJain21BCE1523
 
Regular Expression to Finite Automata
Archana Gopinath
 
Lecture 02 lexical analysis
Iffat Anjum
 
Regular expression (compiler)
Jagjit Wilku
 
Context Free Grammar
Akhil Kaushik
 
Regular Expressions here we have .pptx
arslanahmadkhan295
 
Theory of computing
Ranjan Kumar
 
Chapter Two - Regular Expression and Regular languages.pptx
biniyamtiktok
 
Lexicalanalyzer
Royalzig Luxury Furniture
 
Lexicalanalyzer
Royalzig Luxury Furniture
 
Lexical
baran19901990
 
compiler Design course material chapter 2
gadisaAdamu
 
Ad

Recently uploaded (20)

PPT
Real Life Application of Set theory, Relations and Functions
manavparmar205
 
PPTX
INFO8116 - Week 10 - Slides.pptx big data architecture
guddipatel10
 
PPTX
Data Security Breach: Immediate Action Plan
varmabhuvan266
 
PPTX
Introduction to Data Analytics and Data Science
KavithaCIT
 
PPTX
lecture 13 mind test academy it skills.pptx
ggesjmrasoolpark
 
PPTX
Multiscale Segmentation of Survey Respondents: Seeing the Trees and the Fores...
Sione Palu
 
PPTX
Data-Driven Machine Learning for Rail Infrastructure Health Monitoring
Sione Palu
 
PDF
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
PDF
Chad Readey - An Independent Thinker
Chad Readey
 
PPTX
Future_of_AI_Presentation for everyone.pptx
boranamanju07
 
PPTX
Complete_STATA_Introduction_Beginner.pptx
mbayekebe
 
PPTX
Introduction to Biostatistics Presentation.pptx
AtemJoshua
 
PDF
TIC ACTIVIDAD 1geeeeeeeeeeeeeeeeeeeeeeeeeeeeeer3.pdf
Thais Ruiz
 
PPTX
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
PDF
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
PPTX
White Blue Simple Modern Enhancing Sales Strategy Presentation_20250724_21093...
RamNeymarjr
 
PDF
Technical Writing Module-I Complete Notes.pdf
VedprakashArya13
 
PPTX
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
PPTX
Web dev -ppt that helps us understand web technology
shubhragoyal12
 
PPTX
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
Real Life Application of Set theory, Relations and Functions
manavparmar205
 
INFO8116 - Week 10 - Slides.pptx big data architecture
guddipatel10
 
Data Security Breach: Immediate Action Plan
varmabhuvan266
 
Introduction to Data Analytics and Data Science
KavithaCIT
 
lecture 13 mind test academy it skills.pptx
ggesjmrasoolpark
 
Multiscale Segmentation of Survey Respondents: Seeing the Trees and the Fores...
Sione Palu
 
Data-Driven Machine Learning for Rail Infrastructure Health Monitoring
Sione Palu
 
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
Chad Readey - An Independent Thinker
Chad Readey
 
Future_of_AI_Presentation for everyone.pptx
boranamanju07
 
Complete_STATA_Introduction_Beginner.pptx
mbayekebe
 
Introduction to Biostatistics Presentation.pptx
AtemJoshua
 
TIC ACTIVIDAD 1geeeeeeeeeeeeeeeeeeeeeeeeeeeeeer3.pdf
Thais Ruiz
 
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
White Blue Simple Modern Enhancing Sales Strategy Presentation_20250724_21093...
RamNeymarjr
 
Technical Writing Module-I Complete Notes.pdf
VedprakashArya13
 
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
Web dev -ppt that helps us understand web technology
shubhragoyal12
 
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
Ad

introductory Discrete structure workshop.pptx

  • 2. Workshop Agenda • Deterministic Finite State Automata • Regular Expressions • Context Free Grammar • ProofTechniques and their Structures • (direct proof, proof by contradiction, and induction) • Recurrence Relations • ModularArithmetic-based Computations • Recursion and its use
  • 4. Deterministic Finite State Automata(DFA) An informal definition : • A diagram with a finite number of states represented by circles • An arrow points to one of the states, the unique start state • Double circles mark any number of the states as accepting states • For every state, for every symbol in ∑ , there is exactly one arrow labeled with that symbol going to another state (or back to the same state)
  • 5. DFAs Define Languages • Given any string over ∑ , a DFA can read the string and follow its state-to- state transitions • At the end of the string, if it is in an accepting state, we say it accepts the string • Otherwise it rejects • The language defined by a DFA is the set of strings in ∑* that it accepts
  • 6. The 5-Tuple • Q is the set of states • Drawn as circles in the diagram • We often refer to individual states as qi • The definition requires at least one: q0, the start state • ∑ is the alphabet (that is, a finite set of symbols) A DFAM is a 5-tuple M = (Q, ∑,δ, q0, F), : where Qis the finite set of states∑ is the alphabet (that is, a finite set of symbols) δ ∈ (Q× ∑ →Q) is the transition function q0 ∈ Q is the start state F≤Q is the set of accepting states
  • 13. Regular Expressions A regular expression (RE) describes a language. It uses the three regular operations. •These are called union/or, concatenation and star. • Brackets ( and ) are used for grouping, just as in normal math.
  • 14. Union/or • The symbol + means union or or. • Example: 0 + 1 means either a zero or a one. concatenation • The concatenation of two REs is obtained by writing the one after the other. • (0 + 1) 0 corresponds to {00, 10}. • (0 + 1) (0 + ε) corresponds to {00, 0, 10, 1}. star • The symbol ∗ means zero or more copies • a ∗ corresponds to any string of a’s: {ε, a, aa, aaa, . . .} • (0 + 1) ∗ corresponds to all binary strings
  • 15. Example •An RE for the language of all binary strings of length at least 2 that begin and end in the same symbol. 0(0 + 1) ∗0 + 1(0 + 1) ∗1 •Note precedence of regular operators: star always refers to smallest piece it can, or to largest piece it can.
  • 16. Example •Consider the regular expression ((0 + 1) ∗1 + ε) (00) ∗ 00 • This RE is for the set of all binary strings that end with an even nonzero number of 0’s. •Note that different language to: (0 + 1) ∗ (00) ∗ 00
  • 17. Regular Operators for Languages • If one forms RE by the or of REs R and S, then result is union of R and S. • If one forms RE by the concatenation of REs R and S, then the result is all strings that can be formed by taking one string from R and one string from S and concatenating. • If one forms RE by taking the star of RE R, then the result is all strings that can be formed by taking any number of strings from the language of R (possibly the same, possibly different), and concatenating.
  • 18. Regular Operators Example If language L is {ma, pa} and language M is {be, bop}, then • L +M is {ma, pa, be, bop}; •LM is {mabe, mabop, pabe, pabop}; and • L ∗ is {ε, ma, pa, mama, . . . , pamamapa, . . .}. Notation: If Σ is some alphabet, thenΣ ∗ is the set of all strings using that alphabet.
  • 19. Practice Give an RE for each of the following three languages: 1. All binary strings with at least one 0 2.All binary strings with at most one 0 3.All binary strings starting and ending with 0
  • 20. Solution 1.(0 + 1) ∗0(0 + 1) ∗ 2.1 ∗ + 1 ∗01 ∗ 3. 0(0 + 1) ∗0 + 0 In each case several answers are possible.
  • 22. 22 Informal Comments • A context-free grammar is a notation for describing languages. • It is more powerful than finite automata or RE’s, but still cannot define all possible languages. • Useful for nested structures, e.g., parentheses in programming languages.
  • 23. 23 Informal Comments – (2) • Basic idea is to use “variables” to stand for sets of strings (i.e., languages). • These variables are defined recursively, in terms of one another. • Recursive rules (“productions”) involve only concatenation. • Alternative rules for a variable allow union.
  • 24. 24 Example: CFG for { 0n1n | n > 1} • Productions: S -> 01 S -> 0S1 • Basis: 01 is in the language. • Induction: if w is in the language, then so is 0w1.
  • 25. 25 CFG Formalism •Terminals = symbols of the alphabet of the language being defined. •Variables = nonterminals = a finite set of other symbols, each of which represents a language. •Start symbol = the variable whose language is the one being defined.
  • 26. 26 Productions • A production has the form variable -> string of variables and terminals. • Convention: • A, B, C,… are variables. • a, b, c,… are terminals. • …, X,Y, Z are either terminals or variables. • …, w, x, y, z are strings of terminals only. • , , ,… are strings of terminals and/or variables.
  • 27. 27 Example: Formal CFG •Here is a formal CFG for { 0n1n | n > 1}. •Terminals = {0, 1}. •Variables = {S}. •Start symbol = S. •Productions = S -> 01 S -> 0S1
  • 28. 28 Derivations – Intuition •We derive strings in the language of a CFG by starting with the start symbol, and repeatedly replacing some variableA by the right side of one of its productions. •That is, the “productions for A” are those that haveA on the left side of the ->.
  • 29. 29 Derivations – Formalism •We say A =>  ifA ->  is a production. •Example: S -> 01; S -> 0S1. •S => 0S1 => 00S11 => 000111.
  • 30. 30 Iterated Derivation •=>* means “zero or more derivation steps.” •Basis:  =>*  for any string . •Induction: if  =>*  and  => , then  =>* .
  • 31. 31 Example: Iterated Derivation • S -> 01; S -> 0S1. • S => 0S1 => 00S11 => 000111. • So S =>* S; S =>* 0S1; S =>* 00S11; S =>* 000111.