Chapter 6: Recursion and Induction Flashcards
Recursively define a list
base: []
step: s:l
what is Lists_s
The set of all lists over set S
How is an operation defined on a list
Define base case, Define step case
Give the general structure of a proof by induction on lists
Base case: prove the statement for the case where all occurrences of l have been replaced with []
Ind Hypothesis: given statement holds for list l
Step case: prove the statement for the case where all occurrences of l have been replaced by s:l using the induction hypothesis
What is a full binary tree
Full: 0 children or most
Binary: at most two children
Tree: recursive data type made from nodes and edges
Give the recursive definition of a full binary tree
for every element s of S there is a tree s which is a node labelled s
For two given trees t, t’ labelled over S and an s in S there is a Tree_s(t, t’)
How do we define operations on trees?
Define what happens to Tree s
Define what happens to Tree_s(t, t’)
Describe a proof by induction on trees
Base: show the statement holds for Tree s
Ind hypothesis: The statement holds for Tree t and Tree t’
Step case: show the statement holds for Tree_s(t, t’)
Give the recursive definition of an ordered binary tree
Base: Tree_s is ordered for all s in N Step: Trees_s(t, t') is ordered if: for every m in Labels(t) m <= s for every m' in Labels(t') s <= m' t and t' are ordered
Give the recursive definition of a string
Base: elipson is a string
Step: if s is in S and w is a string, then ws is a string
Give the recursive definition of logical propositions
Base: for every prop var Z, Z is a proposition
Step: if A and B are propositions:
not A, A and B, A or B, A implies B are propositions
Describe a proof by induction for propositions
Base case: show the statement holds for every propositional variable
Ind Hypothesis: assume the statement holds for A and B
Step case: Show that given the Ind Hyp, the statement holds for not A, A and B, A or B, A implies B
What are the base and step cases for regex?
Base: elipson, alphabet
Step: +, |, *
What are the base and step cases for a grammar?
Base: provided by start symbol
Step: provided by each production rule
What are the base and step cases of a parse tree?
Base: the tree corresponding to one node labelled S
Step: if R -> Y is a rule of the grammar and there is a leaf labelled R, add children to that leaf one for every symbol in Y