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

Class 14

Class 14

Invariance Principle

Mohammad Mahmoody

October 12, 2017
Tweet

More Decks by Mohammad Mahmoody

Other Decks in Education

Transcript

  1. = , = → , → 0 = Binary Relation

    View State Machine View
  2. Reachable States A state is reachable if it appears in

    some execution. The execution of a state machine, = (, ⊆ × , 0 ∈ ) is a (possibly infinite) sequence of states, (0 , 1 , … , ) that: 1. 0 = 0 (it begins with the start state) 2. ∀ ∈ 0, 1, … , − 1 . → +1 ∈ (if and are consecutive states in the sequence, there is an edge → ∈ .
  3. Bishop Moves = , , ∈ ℕ } 0 =

    (0, 2) What states are reachable? = , → ′, ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = ± and ′ = ± }
  4. Preserved Invariant is a preserved invariant of = (, ⊆

    × , 0 ∈ ) if ∀ ∈ . ∧ ( → ) ∈ ⟹ ()
  5. = , ≔ ( > 3) Is a preserved invariant?

    = , , ∈ ℕ } 0 = (0, 2) = , → ′, ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = + and ′ = + } (up-right only bishops)
  6. Is a preserved invariant? = , , ∈ ℕ }

    = , ∶= ( = ) = , → ′, ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = + and ′ = + } (up-right only bishops)
  7. Is a preserved invariant? = , , ∈ ℕ }

    = , ∶= ( is even) = , → ′, ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = + and ′ = + } (up-right only bishops)
  8. = , , ∈ ℕ } = , → ′,

    ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = ± and ′ = ± } regular bishops What are preserved invariants for the Bishop machine? Any questions about definitions: state machine, execution, reachable, preserved invariant
  9. = , , ∈ ℕ } = , → ′,

    ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = ± and ′ = ± } regular bishops What are preserved invariants for the Bishop machine?
  10. = , , ∈ ℕ } ∶= ’s color =

    , → ′, ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = ± and ′ = ± } regular bishops
  11. = , , ∈ ℕ } = , → ′,

    ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = ± and ′ = ± } = (, ) ∶= + is even regular bishops
  12. Invariant Principle If a preserved invariant is true for the

    start state, it is true for all reachable states.
  13. = , , ∈ ℕ } = , → ′,

    ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = ± and ′ = ± } 0 = (0, 2) Prove never enters a state corresponding to a white square.
  14. = , , ∈ ℕ } = , → ′,

    ′ , , ′, ′ ∈ ℕ ∧ ∃ ∈ ℕ+ : ′ = ± and ′ = ± } 0 = (0, 2) Prove never enters a state where + is odd.
  15. Correctness of Slow Exponentiation ∷= ℕ × ℕ ∷= {

    , ⟶ , − 1 | ∀ ∈ ℕ, ∈ ℕ+} 0 ∷= (1, ) What preserved invariant would be useful? If we prove this to be invariant, at the end, 0 = means = . We will see more subtle aspects of this argument next time..
  16. Charge • PS6 will be posted by tomorrow, due next

    Friday • Read rest of Chapter 6