sept 4, 2003© vadim bulitko - cmput 272, fall 2003, uofa1 cmput 272 formal systems & logic in...
Post on 15-Jan-2016
239 views
TRANSCRIPT
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 1
CMPUT 272CMPUT 272Formal Systems & Logic in Formal Systems & Logic in
CSCS
CMPUT 272CMPUT 272Formal Systems & Logic in Formal Systems & Logic in
CSCS
I. E. LeonardUniversity of Alberta
http://www.cs.ualberta.ca/~isaac/cmput272/f03
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 2
TodayTodayTodayToday
Organizational details
Purpose of the course
Material coverage
Section 1.1 of the text
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 3
Internet ResourcesInternet ResourcesInternet ResourcesInternet Resources
Course webpage: http://ugweb.cs.ualberta.ca/~c272/
Class webpage:http://www.cs.ualberta.ca/~isaac/
cmput272/f03
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 4
LecturesLecturesLecturesLectures
Instructor: I. E. Leonard
Time: Tues Thurs 9:30 – 10:50
Place: CSC B 10
Text: S.Epp. “Discrete Math. &
App.”
Attendance: strongly encouraged,
limited slide coverage,
read the text before class
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 5
TextbookTextbookTextbookTextbook
Attending the lectures is not a substitute for reading the text
Lectures merely highlight some examples
Read the text and do as many exercises as humanly possible
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 6
SlidesSlidesSlidesSlides
To refresh a lecture (e.g., while preparing for an exam) consult the slides and the text!!!
The slides are on the web (posted after each lecture)
NO substitute for the textbook!!!
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 7
Office HoursOffice HoursOffice HoursOffice Hours
Instructor: I. E. Leonard
Time: See Schedule on
Webpage
Place: Athabasca 323
Attendance: encouraged whenever
you have questions
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 8
SeminarsSeminarsSeminarsSeminars
Instructors: I. E. Leonard
Time: Monday 3:00 – 3:50
Place: CAB 265
Purpose: - interactive environment- answers to your
questions/problems
- more practice in problem solving
Attendance: beneficial to you
Start: Monday, Sept 8th
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 9
LabsLabsLabsLabs
Instructors: TAs: See the Schedule
for times and places
Purpose: 1-on-1 interaction with
TA’s
Start: Week of Sept 8th
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 10
Marking SchemeMarking SchemeMarking SchemeMarking Scheme
6 assignments 24%
2 Midterms: 36%
1 Final Exam: 40%
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 11
In-Class ParticipationIn-Class ParticipationIn-Class ParticipationIn-Class Participation
As far as is possible the class will be an
interactive problem solving session
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 12
AssignmentsAssignmentsAssignmentsAssignments
Each of the 6 assignments will count : 4%
Each will consist of problems taken from the text
All problems will be marked
Solutions will be published on the web
There will be about 2 weeks per assignment
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 13
AssignmentsAssignmentsAssignmentsAssignments
No late assignments will be acceptedCan consult classmates, TA, instructor, etc.The first assignment is out TODAYAvailable on the course webpageDue : Thursday, Sept 25th All assignments are due in class (at the beginning of class) on the due date
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 14
ExamsExamsExamsExams
Midterm examination I:In-class : 50 minutesThursday, October 9th
Midterm examination II:In-class : 50 minutesThursday, November 6th
Final exam:Tuesday, December 9th
Both comprehensive!Both open book!
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 15
Teaching Assistants Teaching Assistants (TA)(TA)
Teaching Assistants Teaching Assistants (TA)(TA)
TAs:Are busy studentshave other things to do in life…may not necessarily be thrilled about marking
It is in YOUR best interest:To make your assignment/exam as clear as possible:
Write legibly or typeExplain all assumptions, notation, etc.Credit ALL collaboration, reference materials
To ensure the entire package gets to TA (staple, write your name, Unix ID, etc.) See course outline!
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 16
Collaboration - Collaboration - AssignmentsAssignments
Collaboration - Collaboration - AssignmentsAssignments
YES! You are encouraged to discuss problems in the assignments and solution ideas
Nevertheless, each assignment handed in must be done by the person submitting it
No labor division:“You do half of the problems and I’ll do half…”
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 17
AcknowledgementsAcknowledgementsAcknowledgementsAcknowledgementsAll discussions, hints, TA’s help, office hours, internet material, etc. must be properly acknowledged
Examples:
"I discussed problem 3.43 with my classmates P. Brosnan and R. Crowe. On problem 3.49 I received an office-hour consultation from my instructor Y.F. Chow. Additionally I used sources [1] and [2] for problem 3.78.
[1] A.Jolie. "Fast Numeric Methods for Curvature Approximation", Journal of Geeky Gamers, volume 36, issue C, June 2001.
[2] F.Oz. "On Using the Force as a Theorem Proving Technique", Jedi Archives, volume 666, number 34, May 2002."
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 18
Collaboration - ExamsCollaboration - ExamsCollaboration - ExamsCollaboration - Exams
Absolutely NO collaboration on:MidtermsFinal exam
Counter-measures include:Tight surveillance (proctor)ID checkingUnannounced other means…
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 19
ProsecutionProsecutionProsecutionProsecutionAny detected case of academic dishonesty will be automatically passed to the office of the Dean after the student is confronted
The violator(s) will go there for a friendly chat with the associate dean
Recent cases:Failure in the course3 months – 1 year student status suspensionMay jeopardize one’s student visa statusPermanently goes on the student’s record
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 20
Some ArithmeticSome ArithmeticSome ArithmeticSome Arithmetic
Suppose you are running late and the due date is near…
… and suppose you copy it from a friend:We will most likely detect itYou will lose 100% of the final markYour friend will be prosecuted as wellPlus: suspension, possible deportation, etc.
The choice is always yours…
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 21
Questions?Questions?Questions?Questions?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 22
Why This Course?Why This Course?Why This Course?Why This Course?
Relation to real life:
Algorithm correctness ~ programming, reverse-
engineering, debugging
Propositional logic ~ hardware (including VLSI)
design
Sets/relations ~ databases (Oracle, MS Access, etc.)
Predicate logic ~ Artificial Intelligence, compilers
Proofs ~ Artificial Intelligence, VLSI, compilers,
theoretical physics/chemistry
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 23
Why This Course?Why This Course?Why This Course?Why This Course?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 24
Code CorrectnessCode CorrectnessCode CorrectnessCode Correctness
Millions of programmers code away daily…How do we know if their code works?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 25
ImportanceImportanceImportanceImportanceUSS Yorktown, a guided-missile cruiser --- the first to be outfitted with Smart Ship technology09/97: suffered a widespread system failure off the coast of Virginia. After a crew member mistakenly entered a zero into the data field of an application, the computer system proceeded to divide another quantity by that zero. The operation caused a buffer overflow, in which data leak from a temporary storage space in memory, and the error eventually brought down the ship's propulsion system. The result: the Yorktown was dead in the water for more than two hours.
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 26
More Software Bugs…More Software Bugs…More Software Bugs…More Software Bugs…On June 4, 1996, the maiden flight of the European Ariane 5 launcher crashed about 40 seconds after takeoff. Media reports indicated that the amount lost was half a billion dollars -- uninsured.
The exception was due to a floating-point error: a conversion from a 64-bit integer to a 16-bit signed integer, which should only have been applied to a number less than 2^15, was erroneously applied to a greater number, representing the "horizontal bias" of the flight.
There was no explicit exception handler to catch the exception, so it followed the usual fate of uncaught exceptions and crashed the entire software, hence the on-board computers, hence the mission.
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 27
Where is CMPUT 272 ?Where is CMPUT 272 ?Where is CMPUT 272 ?Where is CMPUT 272 ?
How do we find such bugs in software?
TracingDebug statementsTest casesMany software testers working in parallel…
All of that had been employed in the previous casesYet the disasters occurred…
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 28
C272 : Program C272 : Program CorrectnessCorrectness
C272 : Program C272 : Program CorrectnessCorrectness
Logic : provides a means to prove correctness of software
Sometimes it can be semi-automated
Can also verify a provided correctness proof
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 29
Argument #1Argument #1Argument #1Argument #1
All men are mortalSocrates is a man
Therefore, Socrates is mortal
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 30
Argument #2Argument #2Argument #2Argument #2
Nothing is better than a 9
A sandwich is better than nothing
Therefore, a sandwich is better than a 9
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 31
ValidityValidityValidityValidity
An argument is valid if and only if given that its premises hold its conclusion also holds
So…Socrates argument: Valid or Invalid?Sandwich argument: Valid or Invalid?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 32
How can we tell ?How can we tell ?How can we tell ?How can we tell ?
Common sense?Voting?Authority?What is valid argument anyway?Who cares?
???
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 33
CMPUT 272CMPUT 272CMPUT 272CMPUT 272
Logic : a formal way to assess the validity of an argument
Can prove theorems in a semi-automatic fashion
Can verify a given proof that an argument is valid
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 34
Material CoverageMaterial CoverageMaterial CoverageMaterial Coverage
Chapter 1: propositional calculusChapter 2: 1st order predicate calculusChapter 3: number theoryChapter 4: mathematical inductionChapter 5: set theoryChapter 6: counting / probabilitiesChapter 7: functionsChapter 10: relations (not the kind)
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 35
Questions?Questions?Questions?Questions?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 36
What is the name of this What is the name of this man?man?
What is the name of this What is the name of this man?man?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 37
Arguments in PuzzlesArguments in PuzzlesArguments in PuzzlesArguments in Puzzles
The Island of Knights and Knaves
Never lie
Always lie
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 38
Example #1Example #1Example #1Example #1
You meet two people: A, BA says:
I am a Knave or B is a Knight.
Who is A?
Who is B?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 39
SolutionSolutionSolutionSolutionThe original statement can be written as:S = X or YX = “A is a Knave”Y = “B is a Knight”Suppose A is a KnaveThen S must be false since A said itThen both X and Y are falseIf X is false then A is not a KnaveContradiction : A cannot be a Knave and not a Knave !So A must be a KnightSo S is true and X is not trueThus, to keep S true Y must be trueSo B is a Knight too
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 40
How about…How about…How about…How about…
You meet just one guy : A
A says:“I’m a Knave!”
Who is A?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 41
Features Of An Features Of An ArgumentArgument
Features Of An Features Of An ArgumentArgument
arguments involve things or objectsthings have propertiesarguments consist of statements.statements may be composedan argument starts with assumptions which create a context.each step yields another statement which is true, within its context.arguments may contain sub-argumentsit is absurd for a statement to be both true and false.
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 42
FormalizationFormalizationFormalizationFormalization
Why formalize?
to remove ambiguity
to represent facts on a computer and use it for proving, proof-checking, etc.
to detect unsound reasoning in arguments
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 43
Graphically…Graphically…Graphically…Graphically…
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 44
LogicLogicLogicLogic
Mathematical logic is a tool for dealing with formal reasoningIn a nutshell:
Logic does:Assess if an argument is valid/invalid
Logic does not directly:Assess the truth of atomic statements
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 45
DifferencesDifferencesDifferencesDifferences
Logic can deduce that:Edmonton is in Canada
given these facts:Edmonton is in AlbertaAlberta is a part of Canada
and the definitions of:‘to be a part of’‘to be in’
Logic knows nothing of whether these facts actually hold in real life!
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 46
Questions?Questions?Questions?Questions?
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 47
Propositional Calculus Propositional Calculus (Ch (Ch 1.)1.)
Propositional Calculus Propositional Calculus (Ch (Ch 1.)1.)
Simplest kind of mathematical logic
Dealing with:
Propositions: X,P,Q,…each can be true or falseExamples: P=“I’m a knave”
Q=“He is a knight”
Connectives: &, v, , , ~, …connect propositions: X v Y
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 48
ConnectivesConnectivesConnectivesConnectives
Different notation is in useWe will use the common math notation:
~ notV or (non-exclusive!)
& , and
implies (if … then …) if and only if for all exists
See the reverse of the text’s front cover
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 49
FormulaeFormulaeFormulaeFormulae
A statement/proposition: true or false
Atomic: P, Q, X, Y, …
Unit Formula: P, ~P, (formula), …
Conjunctive: P & Q, P & ~Q, …
Disjunctive: P v Q, P v (P & X),…
Conditional: P Q
Biconditional: P Q
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 50
Determining Truth of A Determining Truth of A FormulaFormula
Determining Truth of A Determining Truth of A FormulaFormula
Atomic formulae: given
Compound formulae: via meaning ofthe connectives
Suppose: P is trueQ is false
How about: (P v Q)
Truth tables
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 51
Truth TablesTruth TablesTruth TablesTruth Tables
Suppose: P is falseQ is falseX is true
How about:P & Q & XP v Q & XP & Q v X
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 52
PrecedencePrecedencePrecedencePrecedence
~ highest&v, lowest
Avoid confusion - use ‘(‘ and ‘)’:P & Q v X(P & Q) v X
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 53
ParenthesizingParenthesizingParenthesizingParenthesizing
Parenthesize & build truth tablesSimilar to arithmetic:
3*5+7 = (3*5)+7 but NOT 3*(5+7)A&B v C = (A&B) v C but NOT A&(B v C)
So start with sub-formulae with highest-precedence connectives and work your way out
Let’s do the knave & knight problem in T T
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 54
T T for K&KT T for K&KT T for K&KT T for K&K
S = X or YX = “A is a Knave”Y = “B is a Knight”
A B S X Y X v YAbsurd------------------------------------------------------------------------------Knave Knave false true false true yesKnave Knight false true true true yesKnight Knave true false false false yesKnight Knight true false true true no
Sept 4, 2003 © Vadim Bulitko - CMPUT 272, Fall 2003, UofA 55
Questions?Questions?Questions?Questions?