Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I....

29
Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 1 CMPUT 272 CMPUT 272 Formal Systems Logic Formal Systems Logic in CS in CS I. E. Leonard University of Alberta http://www.cs.ualberta.ca/~isaac/ cmput272/f03

Transcript of Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I....

Page 1: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 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

Page 2: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 2

TodayTodayTodayToday

Chapter 3.1

All

imag

es

are

cop

yri

gh

ted

to t

heir

resp

ect

ive c

op

yri

gh

t h

old

ers

an

d r

ep

rod

uce

d h

ere

for

aca

dem

ic p

urp

ose

s u

nd

er

the c

on

dit

ion

of

“fair

usi

ng

”.

Page 3: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 3

AnnouncementsAnnouncementsAnnouncementsAnnouncements

Assignment 1 is due today

Solutions will be up on the webpage soon More excitement : Assignment 2 is coming to a webpage near you (today)

Due on Oct 9, 2003 (approx. 10 days!)

Page 4: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 4

Class PollClass PollClass PollClass Poll

Who thinks assignment 1 was:Too difficult ?Too easy ?

Who thinks we are covering the material:

Too fast ?Too slowly ? Just the right pace ?

Page 5: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 5

Test DrivingTest DrivingTest DrivingTest Driving

Acquired the first-order predicate calculus mechanism over the last N lectures

Time to try them out

Chapter 3 is an interesting track

Page 6: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 6

Questions?Questions?Questions?Questions?

Page 7: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 7

Sneak-preview : SetsSneak-preview : SetsSneak-preview : SetsSneak-preview : Sets

What is a set?A collection of elements:

Order is irrelevantNo repetitionsCan be infiniteCan be empty

Examples:{Angela, Belinda, Jean}{0,1,2,3,…}

Page 8: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 8

Operations on setsOperations on setsOperations on setsOperations on sets

S is a setMembership:

xSx is an element of S Angela{Angela, Belinda, Jean}

Subset:S1 S

Set S1 is a subset of set S

All elements of S1 are elements of S{Angela,Belinda} {Angela, Belinda, Jean}

Page 9: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 9

Operations on setsOperations on setsOperations on setsOperations on sets

S, S1 are setsEquality:

S = S1

iff they have the same elements

Difference:S \ S1

is a set of all elements that belong to S but NOT to S1 {Angela, Belinda, Jean} \ {Angela,Dana} = {Belinda, Jean}

Page 10: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 10

Operations on setsOperations on setsOperations on setsOperations on sets

S, S1 are sets

Intersection:S S1

is a set of all elements that belong to both {Angela, Belinda, Jean} {Angela,Dana} = {Angela}

Union:S S1

is a set of all elements that belong to either {Angela, Belinda, Jean} {Angela,Dana} = {Angela,Belinda,Jean,Dana}

Page 11: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 11

Questions?Questions?Questions?Questions?

Page 12: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 12

NumbersNumbersNumbersNumbers

We will work with numbers for the next little whileR is the set of all real numbers

0, 1, -5.27, Pi, …

Q is the set of rational numbers0, 1, -5.27, …

Z is the set of integer numbers0, 1, -1, 2, …

N is the set of natural numbers0, 1, 2, …

Page 13: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 13

NotesNotesNotesNotes

The following inclusions holdN Z Q R

Note that the inclusions are actually proper:

N Z Q R

Algebraic operations (+, -, *, /, etc.) are defined on all of these sets

Order relations are also defined:Any two numbers are comparable (<, >, =)

Page 14: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 14

Numbers in Predicate Numbers in Predicate LogicLogic

Numbers in Predicate Numbers in Predicate LogicLogic

Our interpretations will set the domain set to R (or sometimes N, Z, Q)We will use functional symbols:

+, *, -, /, etc.nN [n+1N]Domain set is RFor every natural number n, n+1 is a natural number as well

We will also use operator notation for predicates <, >, = :

nN [n < n+1]Domain set is RFor every natural number n < n+1

Page 15: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 15

PremisesPremisesPremisesPremises

One can define a system of predicate logic statements that describe all foundational properties of numbers

Axioms

Axiomatic introduction of real numbers, integers, etc.We won’t do it at this moment

Non-trivial

Nevertheless we will use these “imaginary” premises to prove other statements

Page 16: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 16

Proving StatementsProving StatementsProving StatementsProving Statements

From now we will be proving statements

TheoremsPropositionsCorollariesLemmas

They are statements in predicate logicWe will be showing that they are logically implied by the system of premises (axioms)

Page 17: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 17

Odd / EvenOdd / EvenOdd / EvenOdd / Even

Define predicate even(n):n is an even integer iffExists an integer k such that n=2knZ [even(n) kZ [n=2k]]

Define predicate odd(n):n is an even integer iffExists an integer k such that n=2k+1nZ [odd(n) kZ [n=2k+1]]

Page 18: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 18

ExamplesExamplesExamplesExamples

Odd / even ?3114

-95*2(a+b)2 if a,b are evenn*(n+1) if n is even560

n+1 if n is oddn*(n-1) + 3sqrt(74)3.14

Page 19: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 19

Questions?Questions?Questions?Questions?

Page 20: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 20

Prime / CompositePrime / CompositePrime / CompositePrime / Composite

Define predicate prime(n):n is a prime number iffn>1 and for any its positive integer factors r and s one of them is 1nZ [prime(n) n>1 & r,sN [n=rs r=1 v s=1]]

Define predicate composite(n):n is a composite integer iffn is not prime and not equal to 1nZ [composite(n) n>1 & ~prime(n)]

Page 21: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 21

Text’s Definition (p. Text’s Definition (p. 115)115)

Text’s Definition (p. Text’s Definition (p. 115)115)

The text suggests another predicate logic definition of prime(n) :

“If n is an integer that is greater than 1 then:prime(n) r,sN [n=rs r=1 v s=1]”

Compare it to ours (previous slide):nZ [prime(n) n>1 & r,sN [n=rs r=1 v s=1]]

Differences?Is 1 a prime?Is -5 a prime?

We will use our We will use our definition.definition.

Equivalent to text’s Equivalent to text’s English definition.English definition.

Different from their Different from their formal definition.formal definition.

We will use our We will use our definition.definition.

Equivalent to text’s Equivalent to text’s English definition.English definition.

Different from their Different from their formal definition.formal definition.

Page 22: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 22

Prime / composite?Prime / composite?Prime / composite?Prime / composite?341-503.14725

(2a+8k)3

p-1 where p is a primep+1 where p is a prime188198812920607963838697239461650439807163563379417382700763356422988859715234665485319060606504743045317388011303396716199692321205734031879550656996221305168759307650257059

Page 23: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 23

Who wants to pocket Who wants to pocket US$15KUS$15K today?today?

Who wants to pocket Who wants to pocket US$15KUS$15K today?today?

Excellent!Then just find non-trivial natural factors of:

3107418240490043721350750035888567930037346022842727545720161948823206440518081504556346829671723286782437916272838033415471073108501919548529007337724822783525742386454014691736602477652346609

E-mail them to me in the text format:I will send you a check for US$15K…

Page 24: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 24

Difficulty of FactoringDifficulty of FactoringDifficulty of FactoringDifficulty of Factoring

Suppose someone gives you a number n and asks to find factors of itIntegers r and s such that rs=nHow would you do it?

Can try all integers from 1 to nCan try all integers from 1 to sqrt(n)Can try all primes from 1 to sqrt(n)

Running time: exponential in the number of digits of n

Page 25: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 25

Recent AchievementsRecent AchievementsRecent AchievementsRecent Achievements

On August 22, 1999, a group of researchers completed the factorization of the 155 digit RSA Challenge Number.

Sieving: 35.7 CPU-years in total on... 160 175-400 MHz SGI and Sun workstations 8 250 MHz SGI Origin 2000 processors 120 300-450 MHz Pentium II PCs 4 500 MHz Digital/Compaq boxes

This CPU-effort is estimated to be equivalent to approximately 8,000 MIPS yearsCalendar time for the sieving was 3.7 months.

Page 26: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 26

ApplicationsApplicationsApplicationsApplications

Very large integers n are very difficult to factor (i.e., find r and s such that rs=n)

However, once you know one factor it is easy to find the other (just divide)

Security codes, encryption, etc. are based on some of these properties:

BanksWeb (credit cards, passwords, etc.)MilitaryEtc.

Page 27: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 27

Quantum ComputingQuantum ComputingQuantum ComputingQuantum ComputingIn the early 90s Peter Shor of ATT Labs devised a factoring algorithm:

Factors numbers in polynomial timeMuch faster than conventional algorithms

So how come I haven’t collected the $15K myself?The algorithm is fast on quantum computers onlyWhere can I buy a quantum computer?

State-of-the-art : IBM quantumly factored 15 into 5 and 3 in Dec 2001

Page 28: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 28

Further InformationFurther InformationFurther InformationFurther Information

A light non-conventional computing survey:Molecular, quantum, microfluidics, swarm, etc.

http://www.cs.ualberta.ca/~bulitko/ircl/applications/dmai/ Under ‘Issues/Challenges’ in the menuCan download software simulators of quantum computers, follow the links to IBM research, etc.

The RSA Challenge (up to US$200,000)http://www.rsasecurity.com/rsalabs/challenges/factoring/numbers.html

Page 29: Sept 23, 2003© Vadim Bulitko : CMPUT 272, Fall 2003, UofA1 CMPUT 272 Formal Systems Logic in CS I. E. Leonard University of Alberta isaac/cmput272/f03.

Sept 23, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 29

Questions?Questions?Questions?Questions?