Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 21

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Class 21

Review

Avatar for Mohammad Mahmoody

Mohammad Mahmoody

November 07, 2017
Tweet

More Decks by Mohammad Mahmoody

Other Decks in Education

Transcript

  1. Plan Today: review! • State Machine and Invariance  Program

    correctness and Termination • Recursive Defenitions  Structural Induction • Infinite Sets and Cardinalities
  2. State Machine and Invariants • State Machine: M = ,

    ⊆ × , 0 ∈ • is a preserved invariant if ∀ ∈ . ∧ ( → ) ∈ ⟹ () • Invariant Principle: If is preserved invariant and (0 ) is true  it is true for all reachable states.
  3. Program Correctness • To prove a program P outputs “correctly”

    : 1. Model it as a state machine M 2. Show it eventually terminates 3. Show partial correctness (if it ends  it is correct) a) Find a “good” preserved invariant P for M b) Show ()=true for final state q implies correct output c) Show 0 =true for start state
  4. Recursive Data Types • To define recursive data type –

    Base case(s) that specify some elements are in – Constructor case(s) that specify how to construct new data element ∈ from previously constructed 1 , 2 , … ∈ • To define (new) operators on we again use base and constructor cases!
  5. Structural Induction Goal: To prove for all elements in data

    type 1. Prove for all base cases ∈ 2. Prove 1 ∧ (2 ) ⇒ for all constructable from 1 , 2 15
  6. Infinite Sets and Cardinalities A set is countably infinite iff

    there is a bijection between and ℕ. is infinite, if there is no bijection between and any ℕ . Equivalent : ℕ ≤ || : there is a surjective function from to ℕ is Countable : ≤ |ℕ| : there is a surjective function from ℕ to . A set is uncountable iff it is not countable.
  7. Infinite Sets and Cardinalities • Set of all English words…

    is finite. • Set of all words using English letters… is an infinite set. It includes all the finite sequences of a,b, which by interpreting = 0, = 1 we get all the natural numbers written in binary (and a lot more). So there is a surjective function from this set to ℕ.
  8. Infinite Sets and Cardinalities • We know (ℕ) is uncountable

    (Cantor’s theorem) and that ℕ = 0,1 = |ℝ| • To show is uncountable, prove that ≥ || for an uncountable set. • Example: 0,2 , 1,2 , .