CPSC 121: Models of Computation Instructor: Bob Woodham - - PowerPoint PPT Presentation

cpsc 121 models of computation
SMART_READER_LITE
LIVE PREVIEW

CPSC 121: Models of Computation Instructor: Bob Woodham - - PowerPoint PPT Presentation

CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2008/2009, Section 203 CPSC 121: Models of Computation Menu April 8, 2009 Topics: Example:


slide-1
SLIDE 1

CPSC 121: Models of Computation

Instructor: Bob Woodham woodham@cs.ubc.ca

Department of Computer Science University of British Columbia

Lecture Notes 2008/2009, Section 203

CPSC 121: Models of Computation

slide-2
SLIDE 2

Menu April 8, 2009

Topics: Example: NFA to DFA Conversion Final Reading List Learning Goals Summary The End! Reminders: On-line Quiz 12 deadline 5:00pm TODAY Teaching evaluation survey now available on-line — deadline 23:00 April 12 Review session (Steve): Thu April 9, 9:00, DMP 310 Review session (Bob): Thu April 16, 14:00, DMP 110 Final exam Friday, April 17, 7:00pm, SRC A READ the WebCT Vista course announcements board

CPSC 121: Models of Computation

slide-3
SLIDE 3

Recall: Decimal Number NFA

int dot real

S S

1

0−9 0−9 0−9 0−9

CPSC 121: Models of Computation

slide-4
SLIDE 4

Example 1: Build the DFA. . .

Construct the DFA corresponding to the decimal number NFA

{s ,s }

0 1

CPSC 121: Models of Computation

slide-5
SLIDE 5

Example 1: Build the DFA. . .

Construct the DFA corresponding to the decimal number NFA

s1 { ,int} {s ,s }

0 1

{s }

1

{ } 0−9

CPSC 121: Models of Computation

slide-6
SLIDE 6

Example 1: Build the DFA. . .

Construct the DFA corresponding to the decimal number NFA

s1 { ,int} {s ,s }

0 1

{s }

1

0−9 { } 0−9 else

CPSC 121: Models of Computation

slide-7
SLIDE 7

Example 1: Build the DFA. . .

Construct the DFA corresponding to the decimal number NFA

s1 { ,int} {s ,s }

0 1

{s }

1

0−9 { } {dot} 0−9 0−9 else else

CPSC 121: Models of Computation

slide-8
SLIDE 8

Example 1: Build the DFA. . .

Construct the DFA corresponding to the decimal number NFA

s1 { ,int} {s ,s }

0 1

{s }

1

0−9 { } {dot} {real} 0−9 0−9 0−9 else else else

CPSC 121: Models of Computation

slide-9
SLIDE 9

Example 1: Build the DFA. . .

Construct the DFA corresponding to the decimal number NFA

s1 { ,int} {s ,s }

0 1

{s }

1

0−9 { } {dot} {real} 0−9 0−9 0−9 0−9 else else else else

CPSC 121: Models of Computation

slide-10
SLIDE 10

Example 1: Build the DFA. . .

Construct the DFA corresponding to the decimal number NFA

s1 { ,int} {s ,s }

0 1

{s }

1

0−9 { } {dot} {real} else 0−9 0−9 0−9 0−9 else else else else

CPSC 121: Models of Computation

slide-11
SLIDE 11

Final Exam Coverage

1

Section 203 Lectures 1–36 — cumulative [slides] and [with notes] versions provided

2

Epp: Chapter 1 Chapter 2 Sections 3.1, 3.6, and 3.7 plus Theorem 3.4.1 and pages 159–163 Section 4.1 (purely as background reading) Sections 4.2–4.4 Sections 5.1–5.3 Section 7.1 and Section 7.2 (excluding “Application: Hash Functions” and “Properties of Exponential and Logarithmic Functions”) Section 12.1–12.2

3

Labs 0–8

CPSC 121: Models of Computation

slide-12
SLIDE 12

Final Exam Aides

The final exam is open book You may bring and access during the exam: any (reasonable) number of textbooks

  • ne binder or folder of notes

The binder or folder may contain any notes you like (e.g., handwritten notes, printouts of practice finals, midterms, recipes for chocolate cake, etc.) We recommend carefully organizing and thinking through the material beforehand In a timed situation, you’ll likely want to access your notes and books as infrequently as possible Finally, you may not have any other aides during the exam. (In particular, you may not use any electronic device such as a calculator)

CPSC 121: Models of Computation

slide-13
SLIDE 13

Learning Goals

1

Evaluate the truth of simple propositional logic statements using truth tables

2

Translate back and forth between simple natural language statements and propositional logic

3

Translate back and forth between propositional logic statements and combinational circuits built using standard logic gates (NOT, AND, OR, XOR, NAND, NOR)

4

Design combinational circuits based on propositional logic expressions and their equivalent logic circuits to solve real problems (e.g., a 7 segment LED numerical display)

5

Evaluate propositional logic as a model of computation for combinational circuits, identifying at least one explicit shortfall (e.g., timing based on gate delays, fan-out, wire length, instabilities, shared sub-circuits, etc.)

CPSC 121: Models of Computation

slide-14
SLIDE 14

Learning Goals (cont’d)

6

Translate back and forth between simple natural language statements and propositional logic, including conditionals and biconditionals

7

Evaluate the truth of simple propositional logic statements using truth tables, including conditionals and biconditionals

8

Given a propositional logic statement and a logical equivalence rule, apply the rule to create the equivalent statement

9

Transform propositional logic statements by application of logical equivalence rules in order to: — simplify complex statements — prove the logical equivalence of two statements — represent statements in a standard canonical form

CPSC 121: Models of Computation

slide-15
SLIDE 15

Learning Goals (cont’d)

10 Convert integers from octal or hexadecimal to binary and

back

11 Convert positive integers from decimal to binary

— by “repeated division” (octal/hex as intermediary)

12 Convert positive integers from binary to decimal 13 Take the 2’s complement of a fixed width binary number 14 Convert signed (either positive or negative) integers to

binary and back

15 Add and subtract fixed width, 2’s complement (signed)

binary integers

16 Convert decimal fractions (in positional notation) to binary

fractions (in positional notation) — by “repeated multiplication” (octal/hex as intermediary)

CPSC 121: Models of Computation

slide-16
SLIDE 16

Learning Goals (cont’d)

17 Critique different number representations describing their

strengths and weaknesses (finite representation, overflow, etc.). Representations include: positional notation (binary,

  • ctal, decimal, hexadecimal); binary coded decimal (BCD);

fixed-width, 2’s complement (signed) binary; IEEE 754 floating point (single and double precision)

18 Use truth tables to establish or refute the validity of a

proposed rule of inference

19 Given a rule of inference and propositional logic statements

that correspond to the rule’s premises, apply the rule to infer a new statement implied by the original statements

20 Explore the logical consequences of a set of propositional

statements by application of both equivalence and inference rules, especially in order to transform statements into a desired canonical form

CPSC 121: Models of Computation

slide-17
SLIDE 17

Learning Goals

1

Understand the definition of a predicate and its associated domain of discourse

2

Evaluate the truth of predicates applied to particular values

3

Understand what it means for a predicate to be universally quantified or existentially quantified

4

Show predicate logic statements are true by enumerating examples (i.e., all examples in the domain of discourse for a universally quantified statement or at least one example for an existentially quantified statement)

5

Show predicate logic statements are false by enumerating counterexamples (i.e., one counterexample for a universally quantified statement or all for an existentially quantified statement)

CPSC 121: Models of Computation

slide-18
SLIDE 18

Learning Goals (cont’d)

6

Translate between statements in formal predicate logic notation and equivalent statements in closely matching informal language (i.e., informal statements with clear and explicitly stated quantifiers)

7

Construct predicate logic statements to capture the relationships between properties of various objects both real-world like and computing related

8

Determine the negation of any quantified statement, including multiply quantified statements, using generalized De Morgan

9

Given a quantified statement and a logical equivalence rule, apply the rule to create an equivalent statement

CPSC 121: Models of Computation

slide-19
SLIDE 19

Learning Goals (cont’d)

10 Apply additional rules of inference for quantified

statements including universal instantiation, universal generalizarion, existential instantiation, existential generalization, universal modus ponens, universal modus tollens, and universal transitivity

11 Prove (or disprove) conjectures involving quantified

statements using basic proof techniques, both direct and indirect, including proof by contradiction and proof by contrapositive

CPSC 121: Models of Computation

slide-20
SLIDE 20

Learning Goals

1

Understand the following basic proof strategies: constructive/nonconstructive proofs of existence (“witness”) disproof by counterexample exhaustive proof generalizing from the generic particular (“WLOG”) direct proof (“antecedent assumption”) proof by contradiction proof by contrapositive proof by cases well enough to identify the strategy when it is encountered in a given proof and well enough to apply it as a strategy in a novel proof

CPSC 121: Models of Computation

slide-21
SLIDE 21

Learning Goals (cont’d)

2

Devise and attempt multiple different, appropriate proof strategies for a given theorem – including all those listed above – that use definitions, premises, logical equivalences, rules of inference and rules of inference for quantified variables

3

Prove theorems requiring only simple insights beyond choice of proof strategy or for which the necessary insight is given as a hint/suggestion

CPSC 121: Models of Computation

slide-22
SLIDE 22

Learning Goals

1

To design and analyze simple sequential circuits: circuits that perform sequences of steps and remember information from previous steps

2

To define a finite state machine (FSM) (aka a Deterministic Finite State Automaton (DFA)) both in terms of a state transition diagram and a state transition table

3

To implement any specific FSM (of modest complexity) as a sequential circuit

4

To specify the overall architecture of a (Von Neumann) stored program computer – an architecture that instantiates the principle that both program and data are bits (i.e., state) loaded and stored in (common) memory

5

To interpret the (Von Neumann) stored program computer as a “universal” FSM (i.e., as a FSM that can implement any other FSM via changes to the program and data)

CPSC 121: Models of Computation

slide-23
SLIDE 23

Learning Goals (cont’d)

6

To analyze the (TKGate simulated) operation of a specific simple computer design. This includes understanding the basic fetch-decode-execute instruction cycle and the data flow to/from the arithmetic logic unit (ALU), the main memory, the Instruction Register (IR) and the Program Counter (PC) under control of the microController

7

To run a provided program on the (TKGate simulated) simple computer. To test the behaviour of the program by monitoring values displayed in key registers during program execution. To modify the provided program to achieve other specified functionality

CPSC 121: Models of Computation

slide-24
SLIDE 24

Learning Goals (cont’d)

8

To complete CPSC 121’s “bottom up” treatment of circuits: switch→logic gate→combinational circuit →sequential circuit →FSM→ simple computer demonstrating that:

1

We can specify each one of these stages completely, both formally (i.e., as theory) and practically (i.e., as a constructive implementation)

2

There are no significant gaps between stages (i.e., we can build each successive stage using elements from the previous stage)

CPSC 121: Models of Computation

slide-25
SLIDE 25

Learning Goals

1

Recognize mathematical induction as a proof technique for statements universally quantified over the positive integers, Z+

2

Given a theorem to prove expressed in terms of a variable, n, universally quantified over Z+, write out the skeleton of an inductive proof including: the base case(s) that need to be proved, the induction hypothesis, and the inductive step that needs to be proved

3

Complete all the steps of a formal proof by induction using either regular (weak) or strong induction, as needed

4

Critique formal inductive proofs to determine whether they are valid or where the error(s) lie if they are invalid

CPSC 121: Models of Computation

slide-26
SLIDE 26

Learning Goals

1

Define basic set operations: union, intersection, complement, and set difference

2

Define logical operations on sets: subset, proper subset and set equality (in terms of predicate logic and set membership, e.g., x ∈ X)

3

Translate between sets represented explicitly, possibly using ellipses “. . . ”, e.g., {4, 6, 8, . . . }, and using “set builder” notation, e.g., {x ∈ Z+ | x2 > 10 ∧ x is even}

4

Compute union, intersection, complement, set difference, subset and set equality operations on sets expressed explicitly, expressed using set builder notation, or expressed as a combination of these and set operations

5

Interpret the empty set (symbol { } or ∅), including the fact that the empty set has no members and that it is a subset

  • f any set

CPSC 121: Models of Computation

slide-27
SLIDE 27

Learning Goals (cont’d)

6

Define an n-tuple

7

Define the power set and Cartesian product operations

  • ne sets in terms of predicate logic and set

membership/subset relations

8

Compute the power set, Cartesian product, and cardinality

  • perations on sets expressed in any of the set notations

considered

9

Apply proof techniques learned earlier to proofs involving sets

CPSC 121: Models of Computation

slide-28
SLIDE 28

Learning Goals

1

Define the terms domain, codomain, range, image, and pre-image

2

Use appropriate function syntax to relate these terms, e.g., f : A → B indicates that f is a function mapping domain A to codomain B

3

Determine whether f : A → B is a function given a definition of f as an equation or as a bipartite graph (i.e., arrow diagram)

4

Define the terms injective (one-to-one), surjective (onto), bijective (one-to-one correspondence) and inverse

5

Determine whether a given function is injective, surjective, and/or bijective

6

Apply proof techniques learned earlier to proofs about the properties (e.g., injectiveness, surjectiveness, bijectiveness, and function-ness) of functions and their inverses

CPSC 121: Models of Computation

slide-29
SLIDE 29

Learning Goals

1

Specify a DFA formally as a 5-tuple defined using set and function notation

2

Define regular expressions and their associated regular language

3

Identify the regular language recognized by a particular DFA

4

Build a DFA to recognize a particular regular language

5

Connect the graphical (state transition diagram) and formal (5-tuple) representations of DFAs and illustrate how each part works

6

Use the formalisms that we’ve learned (especially power sets and set union) to illustrate that a nondeterministic finite state automaton (NFA) is no more powerful than a deterministic finite state automaton (DFA)

CPSC 121: Models of Computation

slide-30
SLIDE 30

Think Big!

I have encouraged you to “think big”: Be curious Be academically adventurous (explore new ideas/topics/areas) Be tolerant/resilient to failure (but learn from your mistakes and the mistakes of others) develop your discernment (i.e., noticing) skills

CPSC 121: Models of Computation

slide-31
SLIDE 31

Four “Big Ideas” of Computer Science

Big Idea #1: Finite State Machines (FSMs) Big Idea #2: Turing Machines Big Idea #3: Computability Big Idea #4: Universality

CPSC 121: Models of Computation

slide-32
SLIDE 32

Models of Computation: Summary

Formal models (computability, Turing Machines, Universality) provide the basis for modern computer science: Fundamental limits (on what can not be done, even given plenty of memory and time) Fundamental equivalence of computation models Representation of algorithms as data, rather than as machinery Programs, Software, Interpreters, Compilers, ... There remain many practical issues to deal with: Cost: memory size, time performance, power consumption Programmability

CPSC 121: Models of Computation

slide-33
SLIDE 33

Thanks!

You have learned a lot! Be proud of what you have, and can, accomplish I had fun (and I hope most of you did too)! Feedback always is very welcome. I particularly like to hear from students 3–5 years down the road (after graduation) Special thanks to: Gwen Echlin My (few) after class, email and office hour “regulars”

CPSC 121: Models of Computation