Introduction to Propositional Logic
1
Comment on Posted Notes
I shall from time to time be posting notes on topics we cover. These notes are
not to be considered a substitute for the textbook or for a
Homework 2.3
2.
a) no
b) yes
c) no
4.
a) domain: Z (or: Z+ cfw_0, or: N)
range: n Z|0n9
b) domain: Z+
range: cfw_nN|2n
c) domain: cfw_0,1
range: N
d) domain: cfw_0,1
range: N
6.
a) Z+ X Z+
b) Z+
c) cf
Assignments 2.1 and 2.2
2.1
2)
a)cfw_3n|nNn4
b) cfw_xZ| |x|3
c) cfw_x|x is a letter m x p
4)
a) second set is a subset of the first
b) second set is a subset of the first
c) neither is a subset of the
1.7 and 1.8 Assignments
1.7
4)
x = 2k, y would be the inverse
x+y=0
y = -x = -2k
12)
rational * irrational -> irrational
Proof by contradiction: Assume rational * irrational -> rational
a/b * x = m/n
Assignments
Here is to be found a list of problems to be done for homework. All these
problems are problems taken from Rosen exercises. Numbers such as 4.3
refer to sections in the 7th edition of Rose
Approximate Traveling Salesman
Another NP-complete problem that can be solved by a 2-approximation algorithm is traveling
salesman. The traveling salesman problem is given a complete graph with nonneg
Clique
The next NP-complete problem we will explore is a graph problem known as clique.
For an undirected graph G, a clique is a subset of vertices that form a complete
subgraph (i.e. a subset of vert
In order to show that a new problem is also NP-complete, we will construct a (polynomial
time) reduction from an instance of a known NP-complete problem (e.g. circuit satisfiability) to
an instance of
An augmenting path is a simple path from s t in the residual network. In other
words it is an entire path which can admit additional flow from the source to the sink
(all edges along the path have res
While there is no efficient way of finding the optimal solution to several of them, e.g. traveling
salesman, there are ways to efficiently findapproximate solutions. It is interesting that while we
ma
Often we assume that all (well-posed) problems are computable, even if not efficiently. However
in 1936 Alan Turing proved a problem that is uncomputable known as the Halting Problem.
Halting Problem
Another graph problem that can be shown to be NP-complete is vertex cover. A vertex
cover is a subset of vertices that touch all the edges in an undirected graph.
Given an undirected graph G, find the
Traveling Salesman
One of the most famous (and most studied) NP-complete problem is known as
the traveling salesman. The name is derived from the problem that a salesman must
visit each of n cities (i
3-CNF Satisfiability
If the Boolean expression consists of exactly 3 OR'ed variables per clause with all the clauses
being AND'ed, then the expression is said to be in 3-CNF form (conjunctive normal f
NP Completeness
Complexity theory is a field that investigates the run-time of decision problems, i.e. problems
that return true/false as the answer. While many of the problems we have looked at
are o
In analyzing an algorithm, we are generally interested in its growth as N increases, rather than an
exact number of steps. Big-O refers to characterizing the growth of the exact cost T(n) of an
algori
The call stack
In order to understand what happens when an exception is thrown we first need to fully examine
how method calls are handled when the program is executed. Each call to a method creates a
A binary search tree is a tree in which each node stores a key/value pair. The keys are ordered,
meaning that for any pair of keys a and b, it is possible to determine whether a<b, a>b, or a=b.
Each n
General rules:
1. a program statement that is not a method call: 1 step
2. loop executing n iterations: n * m, where m is the cost of a single loop iteration
(NOTE: m may be a function of which loop i
When searching/inserting/removing an element from a hash table, the object's hash code is first
mapped to a hash bucket, which is simply an index into the array used to represent the hash
table. The h
Deletion
Deleting a key/value pair from the tree is more complicated than inserting. If the deleted key is
in a leaf node of the tree, then there is no problem; we can just delete the node containing
As a finite series:
1 + 2 + 3 + . + N-2 + N-1
The sum of this series can be found by adding the first and last elements (1+( N-1)
= N), the second and next-to-last elements (2+( N-2) = N), and so fort
Recursion works by dividing a large problem into one or more smaller problems, and then
extending the solution to the smaller problem(s) into a solution for the large problem. For this
approach to wor
Idealized Hash Table
Before getting into the details of real hash tables, let's first consider an idealized hash table that
has guaranteed worst case running time of O(1) for insert, delete, and find.
Designing a Hash Function
A hash function is a method that inspects the contents of an object and returns an integer value
such that
1. Objects with identical contents will return the same hash code
2
A linked list is a data structure for storing a sequence of element values. Each value is stored in
one node in the linked list. The nodes form a chain: each node contains a reference to the node
cont
Bubble sort is an extremely simple sorting algorithm. We will see later in the course that it is not
an efficient sorting algorithm. However, it is easy to understand and implement.
Here is the pseudo
In the following method, let the problem size N be rowsCols, which is the number of rows and
columns in the square two-dimensional array matrix.
public static boolean isUpperTriangular(double[][] matr