CS 1502 Formal Methods in Computer Science Lecture

  • Slides: 35
Download presentation
CS 1502 Formal Methods in Computer Science Lecture Notes 1 Course Information Introduction to

CS 1502 Formal Methods in Computer Science Lecture Notes 1 Course Information Introduction to Logic Part 1

Content w 70% logic and proofs n n Pervades computer science, e. g. ,

Content w 70% logic and proofs n n Pervades computer science, e. g. , hardware circuit design, artificial intelligence, knowledge representation, database systems, programming languages, software engineering (design, verification, specification), … Will help you understand proofs in math, science, theoretical CS

Content w 30% Abstract models of computation n n Needed for hardware design, compilers,

Content w 30% Abstract models of computation n n Needed for hardware design, compilers, computational complexity analysis, … Interesting proofs; you will use what you learn in the first part of the course to understand them

Logistics w Prerequisites: n n CS 441 Discrete Structures for Computer Science CS 445

Logistics w Prerequisites: n n CS 441 Discrete Structures for Computer Science CS 445 Data Structures w Materials on course website, reachable from www. cs. pitt. edu/~wiebe n n Schedule of readings, homeworks, exams Lecture notes, available before class l Support for lectures; filled in in class

Logistics w The TA will go over exercises and answer questions in recitation. w

Logistics w The TA will go over exercises and answer questions in recitation. w He will also cover logistics of submitting homeworks, and will post solutions to the homework.

Logistics w Workload is steady throughout the course w 3 exams w Weekly homeworks

Logistics w Workload is steady throughout the course w 3 exams w Weekly homeworks (no projects) n n Many are graded electronically You can submit solutions as many times as you like Get feedback without having to wait for instructor grading Purpose is to help you master the material for the exams w Exams 90% Homework 10%

Logistics w Exams n Challenging, but not devious l All of the questions will

Logistics w Exams n Challenging, but not devious l All of the questions will be related to an example worked out in the text, a homework exercise, or a problem we did in class.

Logistics w Work is steady throughout the course w If you keep up, you

Logistics w Work is steady throughout the course w If you keep up, you will likely do OK w The work gets harder! w Please ask questions (lectures, recitations, office hours) n My office hours are T, TH 1: 30 -2: 30 and by appointment – just send mail to set up a time

Logistics w Do readings before lecture w Do the “you try it” exercises as

Logistics w Do readings before lecture w Do the “you try it” exercises as you read the logic text

Software with LPL Text Fitch w Named for Frederic Fitch w Construct formal proofs

Software with LPL Text Fitch w Named for Frederic Fitch w Construct formal proofs w Prove an argument is valid

Software with LPL Text Boole w Named for George Boole w w Construct truth

Software with LPL Text Boole w Named for George Boole w w Construct truth tables Verify a sentence is a tautology Verify two sentences are tautologically equivalent Prove an argument is valid

Software with the Text Tarski’s World w Named for Alfred Tarski w Construct sentences

Software with the Text Tarski’s World w Named for Alfred Tarski w Construct sentences in first-order logic w Determine if a sentence is true wrt a world w Create a world that shows that an argument is invalid

Software with Text Submit w Verify your solutions are correct (without instructor seeing) w

Software with Text Submit w Verify your solutions are correct (without instructor seeing) w Submit homework for final grading to TA (by due date)

More Notes on Homework w Many exercises will be submitted to the grade grinder

More Notes on Homework w Many exercises will be submitted to the grade grinder w Please request that your grade assessments be sent to the TA (not to me!) w You may submit your solutions as many times as you like, but please send your TA only a single report per assignment w Now, let’s look at the webpage and syllabus…

Introduction to Logic

Introduction to Logic

Examples circle(a) small(a) All x All y ((cube(x) ^ tet(y)) (leftof(x, y) ^ frontof(x,

Examples circle(a) small(a) All x All y ((cube(x) ^ tet(y)) (leftof(x, y) ^ frontof(x, a))) feed(max, scruffy) All x All y ((pet(x, y) ^ hungry(y)) feed(x, y))

Logic w A simple grammar. Each sentence has a single interpretation (unlike English!) w

Logic w A simple grammar. Each sentence has a single interpretation (unlike English!) w Used to describe a world, which we define. w Once we define the world, we can say what things names refer to, and whether a logical sentence is true or false.

Names w Constants are used to name existing objects a, b, c, d, e,

Names w Constants are used to name existing objects a, b, c, d, e, f l max, claire, carl l w No constant can name more than one object w An object can have more than one name or no name at all

Predicates w A property possessed by an object Shape (e. g. , Tet, Cube)

Predicates w A property possessed by an object Shape (e. g. , Tet, Cube) l Size (e. g. , Small, Large) l w A relationship among objects Shape relationship (e. g. , Same. Shape) l Size relationship (e. g. , Smaller) l Positional relationship (e. g. , Between, Left. Of) l Equality = l

Quick Example w Ackermann’s sentences and world in Tarski w Properties: n Cube, Tet

Quick Example w Ackermann’s sentences and world in Tarski w Properties: n Cube, Tet (4 faces), Dodec (12 faces), Medium w Relations n Backof, Leftof w (Click verify, and you see that one of the sentences is false about the world)

Predicates w Each predicate has a fixed number of arguments or “arity”. This is

Predicates w Each predicate has a fixed number of arguments or “arity”. This is the number of constants the predicate needs to form a sentence. w In English, OK, but not in logic: n n Susanna is taller than Dimitri and Jerome

Predicates w Predicates must be “determinate” w Suppose p is an n-ary predicate. w

Predicates w Predicates must be “determinate” w Suppose p is an n-ary predicate. w For every n-tuple <o 1, o 2, …, o. N> of objects, p(o 1, o 2, …, o. N) is true or false (not kind of true). w What’s an n-tuple? w An n-tuple is a collection of n objects where order matters. Duplicates are allowed. In contrast, sets may not have duplicates, and the members of sets are not ordered.

Atomic Sentences (so far) w A sentence formed by a single predicate followed by

Atomic Sentences (so far) w A sentence formed by a single predicate followed by one or more names Max is tall l e is larger than b l e is identical to a l Tall(max) Larger(e, b) e=a w A sentence expresses a claim that is either true or false

Atomic Sentences (so far) w Predicate(arg 1, arg 2, …, argn) l l l

Atomic Sentences (so far) w Predicate(arg 1, arg 2, …, argn) l l l Predicates have names beginning with an uppercase letter or are represented by an operator symbol The number of arguments is called the predicate’s arity The order of the arguments is important Larger(e, c) – e is larger than c Larger(c, e) – c is larger than e Between(a, b, e) – a is between b and e Between(b, a, e) – b is between a and e w =(a, b) l l a and b are identical Usually, written in infix form a = b

Function Symbols w A function is used to express complex names (a reference to

Function Symbols w A function is used to express complex names (a reference to an individual without using a name) l l father(b) – b’s father Used in a sentence: Tall(father(b)) password(c) – c’s password Used in a sentence: Long(password(c)) w A function may be nested l l father(max)) Used in a sentence: Short(father(max))) w Can’t nest predicates l Tall(max)) * not a legal sentence*

Functional Expressions w Function(arg 1, arg 2, …, argn) Function names begin with a

Functional Expressions w Function(arg 1, arg 2, …, argn) Function names begin with a lowercase letter or are expressed with a symbol l father(max) Max’s father l father(mother(max)) Max’s mother’s father l youngest. Child(max, ann) Max and Ann’s youngest child l *(5, +(2, 4)) 30 l

Atomic Sentences (so far) w A sentence formed by a single predicate followed by

Atomic Sentences (so far) w A sentence formed by a single predicate followed by one or more terms w A term is either a constant or a functional expression

Example Atomic Sentences (which are functions and which are predicates? ) Predicate(term 1, term

Example Atomic Sentences (which are functions and which are predicates? ) Predicate(term 1, term 2, …, term-n) Happy(bossof(sally)) Father(bill) Tall(father. Of(mother. Of(sally))) Happier(mother. Of(bill), bossof(father. Of(max))) Fake(santa(ross. Park. Mall))) Real(santa(robinson. Town. Center)))

Connectives Apply to sentences to create more complex sentences. w Not w And, Or

Connectives Apply to sentences to create more complex sentences. w Not w And, Or w Material Conditional w Biconditional ,

Examples w Larger(e, c) e is not larger than c w Cube(b) Large(b) b

Examples w Larger(e, c) e is not larger than c w Cube(b) Large(b) b is a cube or b is large w Same. Row(e, c) Back. Of(e, b) e and c are in the same row and e is in back of b

First Order Logic w Names w Predicates w Functions w Connectives Are there more?

First Order Logic w Names w Predicates w Functions w Connectives Are there more?

Example FOL

Example FOL

Translation w Brando is Nancy’s favorite actor. w brando = favorite. Actor(nancy) w Nancy’s

Translation w Brando is Nancy’s favorite actor. w brando = favorite. Actor(nancy) w Nancy’s favorite actor is better than Max’s favorite actor. w Better. Actor(favorite. Actor(nancy), favorite. Actor(max)) w Sean is his own favorite actor. w sean = favorite. Actor(sean) w Brando is someone’s favorite actor. w x(brando = favorite. Actor(x))

Quantifiers and Variables w For every x n x (man(x) mortal(x)) w There exists

Quantifiers and Variables w For every x n x (man(x) mortal(x)) w There exists y n x x(brando = favorite. Actor(x)) y

First Order Logic w Names w Predicates w Functions w Connectives w Quantifiers and

First Order Logic w Names w Predicates w Functions w Connectives w Quantifiers and variables Revised List