Lecture Notes for SWE 623 by Duminda Wijesekera

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Completeness and Expressiveness
Brief Introduction to Logic. Outline Historical View Propositional Logic : Syntax Propositional Logic : Semantics Satisfiability Natural Deduction : Proofs.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
Logic Use mathematical deduction to derive new knowledge.
Predicate Calculus Formal Methods in Verification of Computer Systems Jeremy Johnson.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
Knoweldge Representation & Reasoning
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 6 Limitations of propositional logic Introduction to predicate logic Symbols, terms and formulae, Parse.
1 First order theories. 2 Satisfiability The classic SAT problem: given a propositional formula , is  satisfiable ? Example:  Let x 1,x 2 be propositional.
The ACL2 Proof Assistant Formal Methods Jeremy Johnson.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
Propositional Logic Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma Guadalajara
CS344: Introduction to Artificial Intelligence Lecture: Herbrand’s Theorem Proving satisfiability of logic formulae using semantic trees (from Symbolic.
Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
1 Introduction to Abstract Mathematics Chapter 2: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 2.3.
CS6133 Software Specification and Verification
Of 38 lecture 13: propositional logic – part II. of 38 propositional logic Gentzen system PROP_G design to be simple syntax and vocabulary the same as.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
ARTIFICIAL INTELLIGENCE Lecture 2 Propositional Calculus.
An Introduction to Classical Logic (propositional and Predicate Logic)
Lecture 041 Predicate Calculus Learning outcomes Students are able to: 1. Evaluate predicate 2. Translate predicate into human language and vice versa.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
Predicate Calculus CS 270 Math Foundations of Computer Science Jeremy Johnson Presentation uses material from Huth and Ryan, Logic in Computer Science:
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Chapter 7. Propositional and Predicate Logic
2. The Logic of Compound Statements Summary
Introduction to Logic for Artificial Intelligence Lecture 2
Modal, Dynamic and Temporal Logics
CSE 311 Foundations of Computing I
Advanced Algorithms Analysis and Design
Knowledge Representation and Reasoning
Advanced Algorithms Analysis and Design
The Propositional Calculus
Proposition & Predicates
CS201: Data Structures and Discrete Mathematics I
CS201: Data Structures and Discrete Mathematics I
Logic Use mathematical deduction to derive new knowledge.
Natural deduction Gerhard Gentzen.
CSE 311: Foundations of Computing
CS 270 Math Foundations of CS
Principles of proof calculi Natural deduction
IS 2150 / TEL 2810 Introduction to Security
Back to “Serious” Topics…
MA/CSSE 474 More Math Review Theory of Computation
Computer Security: Art and Science, 2nd Edition
Logical Entailment Computational Logic Lecture 3
Chapter 7. Propositional and Predicate Logic
Search techniques.
CSNB234 ARTIFICIAL INTELLIGENCE
Computer Science cpsc322, Lecture 20
Formal Methods in software development
This Lecture Substitution model
Advanced Analysis of Algorithms
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
CS201: Data Structures and Discrete Mathematics I
ece 720 intelligent web: ontology and beyond
Program correctness Axiomatic semantics
Logical and Rule-Based Reasoning Part I
CS201: Data Structures and Discrete Mathematics I
IS 2150 / TEL 2810 Introduction to Security
Representations & Reasoning Systems (RRS) (2.2)
CS589 Principles of DB Systems Fall 2008 Lecture 4e: Logic (Model-theoretic view of a DB) Lois Delcambre
Presentation transcript:

Lecture Notes for SWE 623 by Duminda Wijesekera Classical Logic Lecture Notes for SWE 623 by Duminda Wijesekera SWE 623Classical Logic Duminda Wijesekera

Propositional and Predicate Logic Propositional Logic The study of statements and their connectivity structure. Predicate Logic The study of individuals and their properties. Study syntax and semantics for both. Propositional logic more abstract and hence less detailed than predicate logic. SWE 623Classical Logic Duminda Wijesekera

Propositional Logic: Syntax A collection of atomic propositional symbols. Say A = { ai : 0 < i }. A special atom _|_ for contradiction A collection of logical connectives. (and) ^, (or) v, ( not )  , (implies) => Inductively define propositions as: If X,Y are propositions, so are :– X ^ Y, X v Y, X => Y,  X. Examples: a1^a2, (a =>a2)v(a3^( a4)) are propositions. SWE 623Classical Logic Duminda Wijesekera

Propositional Logic: Semantics A model M of a propositional language consists of a collection of atoms, say B = { bi : 0 < i }, where _|_ is excluded from B, and a partial mapping M from A = { ai : 0 < i } to B = { bi : 0 < i }. If M(ai) e B, we say that ai is true in M. We write “ai is true in M” as M |= ai. (Read M satisfies ai). |= is referred to as the satisfaction relation. SWE 623Classical Logic Duminda Wijesekera

Propositional Semantics: Continued Extend M, and therefore the satisfaction relation to all propositions using the following inductive definition: M |= X ^ Y iff M |= X and M |= Y. M |= X v Y iff M |= X or M |= Y. M |= X => Y if M |= X then M |= Y. M |=  X, if it is not the case that M |= X. Notice usage of truth tables SWE 623Classical Logic Duminda Wijesekera

Propositional Logic: Example B = { a1, a3} where M given as M(a1) = a1 and M(a2) = a2 has the following properties. M |= a1 M |= a1 ^ a3 M |=  a2 M |= a2 => a4 M does not satisfy the following propositions. M |= a4 M |= a1 => a4 SWE 623Classical Logic Duminda Wijesekera

Propositional Logic: Proofs What formulas hold in all models ? I.e. can we check if a given proposition is true in all models without going through all possible models? Need proofs to answer this question. We use Natural Deduction proofs. Recommended: Read Ch 2 of Logic and Computation by L.C. Paulson. SWE 623Classical Logic Duminda Wijesekera

Natural Deduction for Prop. Logic Proofs are trees of formulae made by applying inference rules. An inference rule is of the form: A1 …… An B Here A1 ….. An are said to be premises (or antecedents) of the rule, and B is said to be the conclusion (consequent) of the rule. SWE 623Classical Logic Duminda Wijesekera

Natural Deduction for Prop. Logic Hence a proofs is a trees whose Root is the theorem to be proved, Branches are rules, and Leaves are the assumptions (axioms) of the proof. Example A1 A2 A3 C1 C2  Assumptions B1 B2  Applications of rules D  Theorem being proved There are introduction and elimination rules for each connective in Natural Deduction proof systems. SWE 623Classical Logic Duminda Wijesekera

Rules for Conjunction Introduction Elimination A B A ^ B A ^ B A ^ B SWE 623Classical Logic Duminda Wijesekera

Rules for Disjunction Introduction Elimination A B A v B A v B Elimination [A] [B] A v B C C C [X] denotes discharged assumption X. SWE 623Classical Logic Duminda Wijesekera

Rules for Implication Introduction Elimination (Modus Ponens) [A] B A => B A SWE 623Classical Logic Duminda Wijesekera

Rules for Negation  B interpreted as ( B => _|_). Hence we get the following rules from those of implication.  Introduction  Elimination [B]  B B _|_ _|_ ________  B Special Contradiction Rule:  B _|_ __________ B SWE 623Classical Logic Duminda Wijesekera

Propositional Proofs: Examples Prove: ( A ^ B ) => (A v B) Notice: The outermost connective is =>. Hence, the last step of the proof must be an implication introduction. That means, we must assume ( A ^ B ) and prove (A v B), and then discharge the assumption by using => introduction rule. In order to prove (A v B) from ( A ^ B ), we must use v –introduction, and hence must prove either A or B from ( A ^ B ). This plan forms a skeleton of a proof. SWE 623Classical Logic Duminda Wijesekera

Prop. Proof: Example Continued Prove: ( A ^ B ) => (A v B) [A ^ B ] A ^ elimination A v B v introduction ( A ^ B ) => (A v B) => introduction Proofs are analyzed backwards, I.e. start unraveling the logical structure of the conclusion and work backwards to the assumptions. Draw out a plan based on your analysis and write down the formal proof. SWE 623Classical Logic Duminda Wijesekera

Derived Rules These are rules derived from other rules. Example: A ^ B B ^ A Here is the derivation: A ^ B B ^ A B A ^ elimination B ^ A ^ introduction SWE 623Classical Logic Duminda Wijesekera

Soundness and Completeness A rule A1 …… An is said to be sound if for every B model in which all of A1 …… An are true, then so is B. I.e. if M |= A1 , …… , M |= An, then M |= B. A collection of rules are sound if all rules in the collection is sound. A collection of rules is complete if M |= A for all models M, then A is provable. I.e. there is a proof of A using the given set of rules. (Denoted |R-- A ) where R is the set of rules. SWE 623Classical Logic Duminda Wijesekera

Predicate Logic Language to describe properties of individuals. Thus, syntax is able to describe individuals, their properties (relationships) and functions. These are to be thought of as names of individuals, properties (relationships) and functions. Models are “incarnations” of these individuals, properties (relationships) and functions. More detailed than propositional logic. SWE 623Classical Logic Duminda Wijesekera

Predicate Logic: Syntax A collection of constants– say { ci : i >= 0 }. Constants are names for individuals. E.g.: 0, 1. Note: not all individuals in a model have names. A collection of variables– say { xi : i >= 0 }. Needed to generically refer to individuals. Think of them as standing in place of pronouns like it, she. A collection of function symbols- say { fi : i >= 0 }. May be of different arities, and may be typed. E.g.: +(x,y) A collection of predicate symbols- say { pi : i >= 0 }. May be of different arities. Encodes properties of individuals. E.g.: prime(x). SWE 623Classical Logic Duminda Wijesekera

Predicate Logic Recursive Definition of Terms Every variable is a term. Every constant is a term. If fi is an n-ary function symbol and t1, .., tn are terms, then fi(t1, .., tn) is a term. We use {ti : i <=0 } for the collection of terms. Examples: f(x, g(2, y)) is a term, where f, g are function symbols and x, y are variables. +( x, *(3,y)) is a term in arithmetic usually written as x + (3*y) SWE 623Classical Logic Duminda Wijesekera

Recursive Definition of Formulas If pi is an n-ary predicate symbol and t1, .., tn are terms, then pi(t1, .., tn ) is an atomic formula. If A and B are formulas, then so are: A ^ B, A v B,  A, A => B.  xi A(xi),  xi A(xi), where xi is a variable. ,  are referred to as the universal and existential quantifier, respectively. A formula that does not have either quantifier is said to be a quantifier free. SWE 623Classical Logic Duminda Wijesekera

Free and bound Variables In  x A(x), the variable x is said to be bound; meaning the name x plays no significant role. (compare with he, she, it) A variable x occurs bound in a formula if x or x is a part of it. More precisely, x occurs bound in: y A(y) or y A(y) if x and y are the same variable.  A if x occurs bound in A. A ^ B, A v B, A => B if x occurs bound in either A or B. SWE 623Classical Logic Duminda Wijesekera

Substitutions If A is a formula, t is a term and x is a variable, then A[t/x] is the formula obtained by substituting t for x in A. A[t1/x1, … tn/xn] is the formula resulting in simultaneously substituting x1, …xn by t1, …tn. Note: Simultaneous substitution Q(x,y)[x/y,y/x] yields Q(y,x) but iterated substitution Q(x,y)[x/y][y/x] yields Q(y,y). SWE 623Classical Logic Duminda Wijesekera

Substituting Terms for Variables In A[t/x], the free variables of t stand the danger of becoming bound in A. Hence, need a precise definition. If x is y then y A(y) [x/y] is y A(y). If not let z be a fresh variable (I.e. not in t, x) then (y A(y) )[t/x] is z (A(z/y) [t/x]). Similar definition for y A(y). Examples: y (y = 1) [y/y] is y (y = 1). Here x is y and t is x. y (y+1 > x) [2y+x/x] is z ((z+1>x)[2y+x/x] I.e. z (z+1>2y+x). Here t is (2y+x). SWE 623Classical Logic Duminda Wijesekera

Substituting Terms Continued ( A )[t/x] is  (A [t/x]) (A ^ B) [t/x] is (A[t/x] ^ B[t/x]) (A v B) [t/x] is (A[t/x] v B[t/x]) (A => B) [t/x] is (A[t/x] => B[t/x]) Pi(t1, .. tn) [t/x] is Pi(t1[t/x], .. tn[t/x]) for predicate symbol Pi. SWE 623Classical Logic Duminda Wijesekera

Predicate Logic: Semantics A model consists of A set (of individuals), say A = { ai : i >= 0 }. A set of total functions Fn = { fni : i >= 0 } on A. I.e. fni(aj) is some ak for every aj. A set of predicates Pr = { pri : i >= 0 } over A. Do not have to be total. Can have many arities. SWE 623Classical Logic Duminda Wijesekera

Interpreting Syntax Mapping from Syntax to Semantics: A mapping mCons : { ci : I >= 0 } to A={ai: i >= 0}. Need not be ONTO A. I.e. there could be unnamed individuals in the semantic domain. A mapping mFun : { fi : I >= 0 } to Fn={fni: i >= 0}. Need not be onto. I.e. there could be unnamed functions in the semantic domain. A mapping mPred: { pi : I >= 0 } to Pr={pri: i >= 0}. Need not be onto. I.e. there could be unnamed predicates in the semantic domain. SWE 623Classical Logic Duminda Wijesekera

Interpreting Formulas: naming We do not interpret formulas with free variables. In order to interpret quantified formulas, need to expand the syntax by adding a constant in the syntax for each unnamed individual in the model. I.e. for each ai for which there is no cj such that Fn(cj ) is ai, add a new constant Cai to the syntax. Now expand the definition of terms to include these new constants. Let newT = { Nti : i >= 0} be the collection of new terms so defined. SWE 623Classical Logic Duminda Wijesekera

Interpreting Formulas Let M be a model. We define M |= F for every quantified formula as follows. For every n-ary predicate symbol pi , and every sequence of new variable free terms Nt1, … Ntn define M |= pi(Nt1, … Ntn ) if and only if mPred(pi)(Nt1, … Ntn ). I.e. pi(Nt1, … Ntn ) is true in M if and only if its image under the map mPred holds with parameters Nt1, … Ntn . SWE 623Classical Logic Duminda Wijesekera

Interpreting Formulas: Continued For every formula A , M |= y A(y) if and only if M |= A(Nti) for every Nti e newT. For every formula A , M |=  y A(y) if and only if there is some Nti e newT satisfying M |= A(Nti). M |= A ^ B if M |= A and M |= B . M |= A v B if M |= A or M |= B. M |= A => B if when M |= A then M |= B. M |=  A if it is not the case that M |= A. SWE 623Classical Logic Duminda Wijesekera

Proof Rules for Predicate Logic Proof rules of introduction and elimination of ^, v, =>, and . New rules required for introduction and elimination of  and  quantifiers. SWE 623Classical Logic Duminda Wijesekera

Proof Rules for   Introduction  Elimination A(x) provided x is not free in the x A(x) assumptions of A  Elimination x A(x) A[t/x] SWE 623Classical Logic Duminda Wijesekera

Proof Rules for   Introduction A[t/x] xA(x)  Elimination [A] provided x is not free xA(x) B in B nor in the B assumptions of B apart from A SWE 623Classical Logic Duminda Wijesekera

An Example Proof Prove ((x A(x)) ^ B) => (x (A(x)^ B)) provided that x is not free in B. Plan: Since outer connective is =>, need to use => introduction at the last step. Hence can use (x A(x)) ^ B as an assumption for the steps above. Now in order to get x (A(x)^ B) using  introduction, we need to get A[t/x] )^ B. Can use ^ elimination to (x A(x)) ^ B and obtain B Can use x elimination to get A[t/x]. SWE 623Classical Logic Duminda Wijesekera

Example Proof x A(x) ^ B x A(x) ^ B x A(x) [A(t/x)] B A(t/x) ^ B The other direction of the proof appears in the handout page 32. SWE 623Classical Logic Duminda Wijesekera

Induction Rule [A(x)] A[0/x] A[x+1/x] A(x) Proviso: x is not free in the assumptions of A[x+1/x] apart from A(x). SWE 623Classical Logic Duminda Wijesekera

Equality Reasoning Rules for equality Reflexivity axiom: t = t. Symmetry rule: t = u . u = t Transitivity rule: s = t t = u . s = u Congruence laws for each function and predicate symbol, or substitution rules. SWE 623Classical Logic Duminda Wijesekera

Equality Reasoning: Continued Congruence Law for functions: t1 = u1 …. tn = un f(t1, …., tn) = f(u1, ….,un) Congruence Law for Predicates: p(t1, …., tn)  p(u1, ….,un) Substitution Rule: t = u S[t/x] = S[u/x] SWE 623Classical Logic Duminda Wijesekera

Equality Reasoning: An Example This example is from Page 37, of the Logic handout. x f(x,x) = x f(g(z), g(z)) = g(z) p(f(g(z), g(z))  p(g(z))  p(f(g(z), g(z))   p(g(z)) SWE 623Classical Logic Duminda Wijesekera

Logic: Suggested Exercises Go thorough all proofs and suggested exercises in the handout. Take the midterm and final exams from last semester and attempt the proofs. Go through the second homework from last semester. Reference: Chapter 2 of Logic and Computation by L.C. Paulson. SWE 623Classical Logic Duminda Wijesekera