CS 250 Solutions for Homework 5 Spring 2012
March 18, 2012
4.6.2 Lets prove that x : y : z : x (y + z ) = (x y ) + (x z ) by induction on x, letting y and z be arbitrary.
Base case: x = 0
We want to prove 0 (y + z ) = 0 y + 0 z . By denition of multiplica

CS 250 Solutions for Homework 5 Spring 2012
April 1, 2012
9.1.3
(a) The dierent trees that can be constructed with 6 nodes is shown in Figure 1. Since there are 6 nodes,
the maximum degree of a node in the tree is 5. So, to construct all the possible grap

CS 250 Solutions for Homework 7 Spring 2012
April 16, 2012
9.9.1 Please refer to Figure 1 to understand the layout of the graph.
Figure 1: Graph)
Uniform Cost Search
We represent the open queue as q . In cfw_(a, b), v , (a, b) denotes the node (a, b) and

CS 250 Solutions for Homework 4 Spring 2012
March 11, 2012
3.5.1 (a) Any period of 28 consecutive years in the Julian calendar contains exactly seven leap years and 21
ordinary years. The total number of days is 7*366 + 21*365, which we can easily see is

3 /12/12
HW #5 for CMPSCI 250, Spring 2012
CMPSCI 250: Introduction to Computation
David Mix Barrington
Spring, 2012
Homework Assignment #5
Posted Saturday 10 March 2012
Due on paper in lecture, Friday 16 March 2012.
There are seven questions for 60 total

2/5/12
HW #2 for CMPSCI 250, Spring 2012
CMPSCI 250: Introduction to
Computation
David Mix Barrington
Spring, 2012
Homework Assignment #2
Posted Thursday 2 February 2012
Due on paper in lecture, Wednesday 15 February 2011.
There are twelve questions for 6

2 /21/12
HW #2 for CMPSCI 250, Spring 2012
CMPSCI 250: Introduction to
Computation
David Mix Barrington
Spring, 2012
Homework Assignment #2
Posted Wednesday 15 February 2012
Due on paper in lecture, Friday 24 February 2012.
There are eight questions for 6

CS 250 Solutions for Homework 3 Spring 2012
February 26, 2012
2.8.3 For a relation to be partial order, it should satisfy the properties of being reexive, antisymmetric and
transitive. For a relation to be an equivalence relation, it should satisfy the pr

CMPSCI 250 Spring 2016: Solutions to Discussion #3
David Mix Barrington, 5 February 2016
1) "There is a dog a such that for all dogs b, there exists a dog c such that
a is not a terrier and if b is a terrier, a is sillier than b and b is sillier
than c

CMPSCI 250 Spring 2016: Solution to Discussion #5
Our first task was to prove the following, where Ss type is
finite set of naturals and the other variables type is natural:
forall S: (forall x: (x in S) > P(x) > (exists y: P(y) and (y not in S)
Using Ge

CMPSCI 250 Syllabus, Spring 2014
2/5/14 11:20 PM
CMPSCI 250: Spring 2014
Syllabus and Course Schedule
Prof. David Mix Barrington
Reading assignments are from Barrington: A Mathematical Foundation for Computer Science (draft),
available at cost from Collec

CMPSCI 250: Introduction to
Computation
Lecture #35: -NFAs From Regular Expressions
David Mix Barrington
18 April 2014
-NFAs From Regular Expressions
Review: Parts of Kleenes Theorem
Review: Induction on Regular Expressions
A Normal Form for -NFAs
The

CMPSCI 250: Introduction to
Computation
Lecture #36: State Elimination
David Mix Barrington
23 April 2014
State Elimination
Kleenes Theorem Overview
Another New Model: The r.e.-NFA
Overview of the Construction
Eliminating a State
Example: The Languag

CMPSCI 250: Introduction to
Computation
Lecture #24: General Search, DFS, and BFS
David Mix Barrington
2 November 2015
General Search, DFS, and BFS
Four Examples of Search Problems
State Spaces, Search, and Optimization
The Generic Search Algorithm
Wh

CMPSCI 250: Introduction to
Computation
Lecture #37: Two-Way Automata and Turing Machines
David Mix Barrington
25 April 2014
2WDFAs and Turing Machines
Enhancing a DFAs Abilities
Denition and Semantics of 2WDFAs
Why 2WDFAs Have Regular Languages
(Sketc

CMPSCI 250: Introduction to
Computation
Lecture #34: Killing -Moves: -NFAs to NFAs
David Mix Barrington
16 April 2014
Killing -Moves: -NFAs to NFAs
(last ve slides of Lecture #33)
Review: Kleenes Theorem Overview
The Construction
A Three-State Example

CMPSCI 250: Introduction to
Computation
Lecture #31: What DFAs Can and Cant Do
David Mix Barrington
9 April 2014
What DFAs Can and Cant Do
Deterministic Finite Automata
Formal Denition of DFAs
Examples of DFAs
DFAs in Java
Characterizing Strings With

CMPSCI 250: Introduction to
Computation
Lecture #30: Properties of the Regular Languages
David Mix Barrington
7 April 2014
Properties of Regular Languages
Induction on Regular Expressions
The Ones Complement Operation
Proving Our Function Correct
The

CMPSCI 250: Introduction to
Computation
Lecture #29: Proving Regular Language Identities
David Mix Barrington
4 April 2014
Regular Language Identities
Regular Language Identities
The Semiring Axioms Again
Identities Involving Union and Concatenation
P

CMPSCI 250 Spring 2016
: Solutions for Discussion #6
(a) Let S(n) be the sum for i from 1 to n of i^2. Prove that for any
natural number n, S(n) = n(n+1)(2n+1)/6.
Proof: Induction on all naturals n.
Base Case: n = 0. S(n) = 0 because the sum is empty,

CMPSCI 250 Spring 2016: Solutions to Discussion #8
public int size( )
cfw_/ returns number of nodes in calling expression's tree
if (getIsLeaf( ) return 1;
if (getOperator( ) = NOT) return 1 + getLeft( ).size( );
return 1 + getLeft( ).size( ) + getRi

CMPSCI 250: Introduction to
Computation
Lecture #18: Variations on Induction for Naturals
David Mix Barrington
19 October 2015
Variations on Induction
Not Starting at Zero
Justifying the Start Anywhere Rule
Induction on the Odds or the Evens
Strong In

CMPSCI 250: Introduction to
Computation
Lecture #19: Proving the Basic Facts of Arithmetic
David Mix Barrington
21 October 2015
Proving the Facts of Arithmetic
The Semiring of the Naturals
The Denitions of Addition and Multiplication
A Warmup: x: 0 + x

CMPSCI 250: Introduction to
Computation
Lecture #17: Proof by Induction for Naturals
David Mix Barrington
18 October 2015
Proof by Induction for Naturals
Induction as a Proof Rule
Example: Sum of First k Odd Numbers is k
Common Features of Inductive Pr

CMPSCI 250: Introduction to
Computation
Lecture #16: Recursive Denition
David Mix Barrington
14 October 2015
Recursive Denition
The Peano Axioms for the Naturals
Pseudo-Java for the Naturals
Forms of the Fifth Peano Axiom
Recursion and the Fifth Axiom

CMPSCI 250 Spring 2016: Solutions to Discussion #7
(a) Let P(n) be F(n) and F(n+1) are relatively prime.
Base: F(1) = 1, F(2) = 1, 1 and 1 are relatively prime.
Inductive step: P(n) > P(n+1). I have three proofs of the IS.
Proof 1: Here we choose to prov

CMPSCI 250 Spring 2016 Discussion #2 Solutions:
Question 1: Premises are:
(I) c -> p
(II) p -> not (b or c)
(III) (not b) -> (p and k)
(IV) (not c) -> (b and not k)
Assume c. for Proof by Cases
p MP, I
not (b or c) MP, II
not b and not c DeMorgan
not c Ri

CMPSCI 250: Introduction to
Computation
Lecture #25: DFS and BFS on Graphs
David Mix Barrington
4 November 2015
DFS and BFS on Graphs
Storing the Entire Search Space
The DFS Tree of a Undirected Graph
The DFS Tree of a Directed Graph
Four Kinds of Edg

CMPSCI 250: Introduction to
Computation
Lecture #26: Uniform-Cost and A* Search
David Mix Barrington
6 November 2015
BFS Trees of Directed Graphs
In a BFS of a directed graph, the BFS tree will
arrange the nodes into levels, based on their
shortest-path

CMPSCI 250: Introduction to
Computation
Lecture #27: Games and Adversary Search
David Mix Barrington
9 November 2015
Games and Adversary Search
Modeling Two-Player Games
When There is a Game Tree
The Determinacy Theorem
Searching a Game Tree
Examples

CMPSCI 250 Spring 2016 Discussion #4 Solutions
1) Goal is to prove that h is onto, which means:
for all z: exists x: h(x) = z
We let c be an arbitrary element of Z.
Since g is onto, we have:
for all z: exists y: g(y) = z
which by Specification gives us
ex