Formal Logic - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Formal Logic

Description:

symbols, sentences, well formed formula. Predicate Calculus ... Well Formed Formula or Legal Sentences are defined as: A simple proposition is a formula ... – PowerPoint PPT presentation

Number of Views:200
Avg rating:3.0/5.0
Slides: 31
Provided by: TDH3
Category:

less

Transcript and Presenter's Notes

Title: Formal Logic


1
Formal Logic
  • Representation Inference
  • As a knowledge representation mechanism
  • As state space search in And/Or graphs
  • As a formalism for heuristic rules
  • Propositional Calculus
  • propositions, connectives
  • symbols, sentences, well formed formula
  • Predicate Calculus
  • predicates, constants, variables, functions,
  • clauses, connectives, qualifiers

2
Propositional Logic
  • Propositions are statements about the world
  • Propositions can either be true or false
  • Simple propositions copper is a metal true
  • wood is a metal false
  • viviane is nice true
  • Logical connectives
  • And ? conjunction
  • Or V disjunction
  • Not negation
  • If ... Then ... ? implication
  • ? equivalence

3
Propositional Calculus
  • The symbols of the propositional calculus are
  • Propositional symbols P, Q, R, ...
  • Thruth symbols true, false
  • Connectives Not, And, Or, ?, ?
  • Well Formed Formula or Legal Sentences are
    defined as
  • A simple proposition is a formula
  • If P is a formula then Not (P) is a formula
  • If P and Q are formula then
  • (P And Q) (P Or Q) (P ? Q) (P?Q)
  • are formula

4
Propositional Calculus
  • An Interpretation of a set of propositions is
    the assignment of a truth value (T or F) to each
    propositional symbol
  • The interpretation or thruth value of a sentence
    is defined by the Thruth Tables for the
    connectives

5
Proving Equivalences
  • Not(Not(P))?P
  • (POrQ)?(Not(P)gtQ)
  • (PgtQ)?(Not(Q)gtNot(P)) contraposition
  • Not(POrQ)?(Not(P)AndNot(Q)) de Morgan
  • Not(PAndQ)?(Not(P)OrNot(Q))
  • (PAndQ)?(QAndP) commutative
  • ((PAndQ)AndR)?(PAnd(QAndR)) associative
  • (POr(QAndR))?(POrQ)And(POrR) distributive

6
A Proof (Not(P)OrQ)?(PgtQ)
7
Legal Inference
  • Modus Ponens If P Then Q
  • P Q
  • If (Bill has cancer) Then (Bill feels bad)
  • Bill has cancer)
  • Bill feels bad
  • ModusTollens If P Then Q
  • Not Q
  • Not P
  • If (Bill has cancer) Then (Bill feels bad)
  • Not (Bill feels bad)
  • Not (Bill has cancer)

8
Illegal inference
  • Abduction If P Then Q
  • !!! not legal Q
  • offers explanation P
  • If (Bill has cancer) Then (Bill feels bad)
  • Bill feels bad
  • Bill has cancer

9
Proving Assertions
  • today is Saturday P
  • the current season is fall Q
  • If (today is Saturday) If (P And Q)
  • And (the current season is fall) Then R
  • Then (there is a football game)
  • there is a football game R is proven

10
Predicate Calculus Symbols
  • Symbols
  • Thruth Symbols true, false
  • Constant Symbols 5, pipe-1, helen
  • Variable Symbols X, Person, Day
  • Function Symbols sin, father !arity
  • Terms helen saturday
  • Person X
  • times(2,5) father(helen)
  • times(X,5) father(Person)
  • Predicate Symbols likes, part-of, free !arity

11
Predicate Calculus Sentences
  • Propositions or Atomic Sentences
    likes(helen,bart) likes(helen,father(bart))
  • likes(Person,bart) likes(helen,father(X))
  • on (block-1,block-2) on (X,Y)
  • Connectives Not, And, Or, ?, ?
  • Variable Quantifiers ???universal quantification
  • ? existencial quantification
  • Sentences
  • likes(helen,bart) likes(bart,(father(helen)))
  • ??X likes(X,ice-cream) ?Y likes(Y,bart)
  • ?X ?Y likes(X,Y) ? likes(X,(father(Y)))

12
Predicate Calculus Semantics
  • An Interpretation of a set of predicate calculus
    sentences is an assignment of the entities in a
    domain of discourse to each constant, variable,
    predicate, and function symbol
  • The thruth value of an atomic sentence is
    determined by the interpretation, for non-atomic
    sentences the Thruth Tables are used for the
    connectives, and in addition
  • the value of ??X ltsentencegt is T if ltsentencegt
    is T for all possible assignments to X
  • the value of ??X ltsentencegt is T if there is an
    assignment to X for which ltsentencegt is T

13
First Order Predicate Calculus
  • First Order Predicate Calculus allows quantified
    variables to refer to objects in the domain of
    discourse and NOT to predicates or functions
  • If it does not rain tomorrow, tom will go to the
    sea.
  • weather(rain,tomorrow)?go(tom,sea)
  • All basketball players are tall.
  • ?X (basketball-player(X)?tall(X))
  • Some people like anchovies.
  • ?X (person(X) ? likes(X,anchovies))
  • Nobody likes taxes.
  • ?X(likes(X,taxes))
  • Most natural language sentences can be written
    as first order predicate calculus sentences

14
Predicate Calculus Example
  • Given mother(eve,abel)
  • mother(eve,cain)
  • father(adam,abel)
  • father(adam,cain)
  • ? X ? Y father(X,Y) V mother(X,Y) ??parent(X,Y)
  • ? X ?Y ??Z parent(Z,X) ? parent(Z,Y) ?
    sibling(X,Y)
  • Inferred parent(eve,abel)
  • parent(eve,cain)
  • parent(adam,abel)
  • parent(adam,cain)
  • sibling(abel,cain)
  • sibling(cain,abel)
  • sibling(cain,cain) !!! logic is all form
  • sibling(abel,abel) no meaning

15
Inference Rules
  • Modus Ponens P ? Q
  • P
  • Q
  • Modus Tolens P ? Q
  • Not(Q)
  • Not(P)
  • Universal ?X P(X)
  • Instantiation a is from the domain of X
  • P(a)

16
Inference Example
  • Given (1) ?X man(X)?mortal(X)
  • (2) man(bill)
  • Inferred
  • (3) man(bill)?mortal(bill) from (1) and (2) with
    UI
  • (4) mortal(bill) from (3) and (2) with MP

17
Pattern Matching and Unification
  • Unification is an algorithm for determining the
    substitutions needed to make expressions match
  • Example match foo(X,a,goo(Y)) with
  • foo(X,b,foo(Y)) no match
  • foo(X,Y) no match
  • moo(X,a,goo(Y)) no match
  • foo(fred,a,goo(Z)) fred/X, Z/Y
  • foo(W,a,goo(jack)) W/X, jack/Y)
  • foo(Z,a,goo(moo(Z))) Z/X, moo(Z)/Y

18
Pattern Matching Algorithm
  • (1) Constant/Constant Matches only when
    identical
  • (2) Constant/Variable Matches
  • a. unbound variable variable becomes bound to
    constant
  • b. bound variable refer to (1)
  • (3) Variable/Variable Matches
  • a. two unbound variables always match !also in
    future
  • b. bound/unbound variable refer to (2) a.
  • c. two bound variables refer to (1)
  • (4) Expression/Expression Matches
  • only when function or predicate names and
    arities identical
  • then match arguments one by one
  • The scope of a variable is one sentence. Once a
    variable is bound, future unifications and
    inferences must take this binding into account

19
Logic Inference as State Space Search
  • A set of proposition or predicate calculus
    sentences form a AND/OR or Hypergraph
  • And nodes indicate problem decomposition, all
    subproblems must be solved (proved true)
  • Or nodes indicate alternative problem-solving
    strategies, solving one (prove it to be true) is
    enough
  • Both goal and data directed search is possible
  • To implement it, extra bookkeeping in the
    algorithm is necessary

20
And/Or Graphs
  • a
  • b
  • c
  • a ? b ? d
  • a ? c ? e
  • b ? d ? f
  • f ? g
  • a ? e ? h
  • b V z ? y
  • y ? z ? g

g
f
h
x
y
d
e
a
z
b
c
21
The Dog Example
  • Fred is a collie collie(fred)
  • Sam is Fred's master master(fred,Sam)
  • the day is saterday day(Saturday)
  • it is cold on Saturday warm(Saturday)
  • Fred is trained trained(Fred)
  • Spaniels are good-dogs and so are trained collies
  • ?X (spaniel(X) V (collie(X) ? trained(X))
    ?gooddog(X)
  • A good dog will be with his master
  • ?X,Y,Z (gooddog(X) ? master(X,Y) ? location (Y,Z)
    ? location(X,Z))
  • If it is Saturday and warm then Sam is at the
    park
  • day(Saturday) ??warm(Saturday) ?
    location(Sam,park)
  • If it is Saturday and not warm then Sam is at the
    museum
  • day(Saturday) ??warm(Saturday) ?
    location(Sam,museum)

22
The Financial Advisor
  • individuals with inadequate savings should
    increase the amount saved, regardless their
    income
  • individuals with adequate savings and adequate
    income should consider investment in stock market
  • individuals with lower income but with adequate
    savings should consider to split their surplus
    income between savings and stock
  • with
  • adequate savings 5000 per dependent
  • minsavings(X) 5000 X
  • adequate income 15000 4000 per dependent
  • minincome(X) 15000 (4000 X)

23
A Logic System for the Financial Advisor
  • savings_account(inadequate) ? investment(savings)
  • savings_account(adequate) ? income(adequate) ?
    investment(stock)
  • savings_account(adequate) ? income(inadequate) ?
    investment(combination)
  • ?X amount_saved(X) ? ?Y (dependents(Y) ?
    greater(X,minsavings(Y))) ? savings_account(adequa
    te)
  • ?X amount_saved(X) ? ?Y (dependents(Y) ?
    greater(X,minsavings(Y))) ? savings_account(inade
    quate)
  • ?X earnings(X, steady) ? ?Y (dependents(Y) ?
    greater(X,minincome(Y))) ? income(adequate)
  • ?X earnings(X, steady) ? ?Y (dependents(Y) ?
    greater(X,minincome(Y))) ? income(inadequate)
  • ?X earnings(X, unsteady) ? income(inadequate)
  • amount_saved(22000)
  • earnings(25000,steady)
  • dependents(3)

24
Alternative Styles for Rules
  • P ? Q Q ? P
  • If premise Then conclusion Q If P
  • If condition Then action Q - P
  • If antecedent Then consequent Q When P
  • Sometimes constrained to
  • no disjunction in the premise
  • no negation in the conclusion
  • no disjunction in the conclusion
  • When variable quantifiers are omitted
  • variables that appear on both sides of the rule
    are universally quantified.
  • variables that appear in the premise of the rule
    only are existentially quantified

25
Prolog A family example
  • parent(michel, nina)
  • No.1 yes No more solutions
  • parent(michel, X)
  • No.1 X emma
  • No.2 X nina No more solutions
  • parent(X, nina)
  • No.1 X viviane
  • No.2 X michel No more solutions
  • parent(X, Y)
  • No.1 X viviane, Y nina
  • No.2 X viviane, Y emma
  • No.3 X maria, Y michel
  • No.4 X julia, Y viviane
  • No.5 X michel, Y emma
  • No.6 X michel, Y nina
  • No.7 X jozef, Y michel
  • parent( X, Y)- mother( X, Y).
  • parent( X, Y)- father( X, Y).
  • mother( viviane, nina).
  • mother( viviane, emma).
  • father( michel, emma).
  • father( michel, nina).
  • father( jozef, michel).
  • mother( maria, michel).
  • father( jules, viviane).
  • mother( julia, viviane).

26
Prolog A family example (2)
  • grandparent(jozef, Y)
  • No.1 Y emma
  • No.2 Y nina
  • No more solutions
  • grandparent(X, nina)
  • No.1 X maria
  • No.2 X julia
  • No.3 X jozef
  • No.4 X jules
  • No more solutions
  • parent( X, Y)- mother( X, Y).
  • parent( X, Y)- father( X, Y).
  • mother( viviane, nina).
  • mother( viviane, emma).
  • father( michel, emma).
  • father( michel, nina).
  • father( jozef, michel).
  • mother( maria, michel).
  • father( jules, viviane).
  • mother( julia, viviane).
  • grandparent( X, Y)- parent( X, Z), parent( Z,
    Y).

27
Prolog The dog example
  • location(fred, L)
  • No.1 L park
  • No more solutions
  • location(billie, L)
  • No.1 L home
  • No more solutions
  • collie( fred).
  • master( fred, sam).
  • today( saturday).
  • warm( saturday).
  • trained( fred).
  • spaniel( billie).
  • master( billie, viviane).
  • location( viviane, home).
  • location( sam, park)- today( saturday), warm(
    saturday).
  • location( sam, museum)- today( saturday), not
    warm( saturday).
  • gooddog( X)- collie( X), trained( X).
  • gooddog( X)- spaniel( X).
  • location( D, P)- gooddog( D), master( D, X),
    location( X, P).

28
Prolog The advisor example
  • investment(savings)- saving_account(inadequate).
  • investment(stock)- saving_account(adequate),
    income(adequate).
  • investment(combination)- saving_account(adequate)
    ,

  • income(inadequate).
  • income(inadequate)- earnings( X, unsteady).
  • income(adequate)- earnings( X, steady),
    dependents( Y),
  • X gt (15000
    (4000 Y)).
  • income(inadequate)- earnings( X, steady),
    dependents( Y),
  • X lt (15000
    (4000 Y)).
  • saving_account(adequate)- amount_saved( X),
    dependents( Y),
  • X gt
    (5000 Y).
  • saving_account(inadequate)- amount_saved( X),
    dependents( Y),

  • X lt (5000 Y).

29
Prolog The advisor example (cont)
  • amount_saved(22000).
  • earnings(25000, steady).
  • dependents(3).
  • amount_saved(22000).
  • earnings(25000, steady).
  • dependents(8).
  • amount_saved(22000).
  • earnings(30000, steady).
  • dependents(2).
  • investment(X)
  • No.1 X combination
  • No more solutions
  • investment(X)
  • No.1 X savings
  • No more solutions
  • investment(X)
  • No.1 X stock
  • No more solutions

30
Control and Implementation of State Space Search
  • General (Abstract) Search Algorithms
  • Pattern Directed Search
  • implements search in And/Or graphs
  • separates problem solving knowledge from
    implementation and control
  • Production Systems
  • implements search
  • models human problem solving
  • separates knowledge and control
  • separates general static problem solving
    knowledge from case data in working memory
Write a Comment
User Comments (0)
About PowerShow.com