Logic and Natural Language - PowerPoint PPT Presentation

1 / 61
About This Presentation
Title:

Logic and Natural Language

Description:

Colorless green ideas sleep furiously - Noam Chomsky. Sentences ('well formed formulas' ... all cars require oil to run. some houses have decks. FOL variables ... – PowerPoint PPT presentation

Number of Views:165
Avg rating:3.0/5.0
Slides: 62
Provided by: willie4
Category:

less

Transcript and Presenter's Notes

Title: Logic and Natural Language


1
Logic and Natural Language
  • By Willie Milnor
  • LSDIS Lab
  • University of Georgia

2
Outline
  • Logic
  • Propositional Logic
  • First-order Logic
  • Logic Programming
  • Natural Language

3
Logic is a Formal Language
  • Syntax
  • what is allowed - expressions
  • Semantics
  • what expressions mean
  • Proof system
  • derive new expressions/semantics
  • reveal something new about the word

4
Inferences from Proofs
  • Agent reasoning
  • given multiple percepts
  • wet umbrella, muddy tracks, pitter-patter on roof
  • make conclusions about the world
  • Effect of an action
  • current state of the world
  • knowledge about the action
  • next state of the world?

5
Propositional Logic
  • Syntax
  • Colorless green ideas sleep furiously
  • - Noam Chomsky
  • Sentences (well formed formulas)
  • true and false
  • propositional variables P, Q
  • sentential operators
  • F ? ?, F ? ?, F, (F), F ? ?, F ? ?

6
Propositional Logic
  • Semantics
  • truth value t, f
  • true t
  • false f
  • Interpretation
  • assignment of truth values
  • holds(F, i)
  • fails(F, i)

7
Propositional Logic
  • Semantics
  • Rules
  • holds(true, i) for all i
  • fails(false, i) for all i
  • holds(P, i) iff i(P) t
  • fails(P, i) iff i(P) f
  • holds(P and Q, i) iff holds(P, i) and holds(Q, i)
  • ...

8
Propositional Logic
  • valid
  • t in all interpretations
  • ex raining or not raining
  • satisfiable
  • t in at least one interpretation
  • ex raining implies thunder
  • Unsatisfiable
  • f in all interpretations
  • ex raining and not raining

9
Satisfiability
  • find an interpretation where the sentence is true
    - holds(S,i)
  • constraint satisfaction
  • assignment of variables where constraints hold
  • methods
  • brute force
  • hueristics
  • constraint propagation

10
Satisfiability
  • Example
  • given KB
  • P ? Q
  • Q ? S
  • P
  • S?
  • n propositional variables 2n interpretations
  • 8 interpretations in the example
  • 4 variables 16 interpretations

11
Entailment
  • A KB entails S iff S is true in every
    interpretations that makes KB true
  • S follows from KB

1
12
Entailment
  • Computation
  • enumerate all interpretations
  • find those in which KB is true
  • check against S
  • O(2n) time
  • Use a proof

13
Proof
  • Given a knowledge base
  • Sequence of premises (known facts)
  • Apply inference rules to premises
  • new sentences
  • Finished when S is inferred
  • sound KB can prove any S it entails
  • complete KB entails any S that it can prove

14
Natural Deductions
  • modus
  • ponens
  • a ? b
  • a
  • _______________________
  • b
  • And-
  • introduction
  • a
  • b
  • _______________________
  • a ? b

modus tolens a ? b b _______________________
a
And- elimination a ? b _______________________ a

15
Natural Deductions
  • proof checkers for Natural Deduction
  • what conclusions the system should find from what
    premises
  • sound but not complete
  • many inference rules large branching factor

16
Conjunctive Normal Form
  • sentence conjunction of clauses
  • clause disjunction of literals
  • literal variable or negation thereof
  • example (P ? Q) ? (R ? S) ? (Q ? S)
  • conversion
  • eliminate ?, ?
  • move into clauses
  • distribute ? over ?
  • O(2n) space

17
Propositional Resolution
  • resolution rule (sound and complete)
  • a ? b
  • b ? y
  • _____________________
  • a ? y
  • resolution refutation (sound and complete)
  • convert all sentences to CNF
  • negate desired conclusion
  • apply resolution rule
  • conclusion is entailed if the contradiction is
    derived

18
First-Order Logic
  • PL has facts true or false
  • what about groups of things?
  • all cars require oil to run
  • some houses have decks
  • FOL variables refer to quantifiable things

19
First-Order Logic
  • Syntax
  • terms
  • constant symbols square, dog
  • variables x,y
  • function symbol with 1 terms
  • sentence
  • predicate symbol
  • t1 t
  • quantifiers for all, there exists
  • closure over sentential operators

20
First-Order Logic Interpretations
  • set of objects
  • universe or domain of discourse
  • constants map to elements
  • predicates map to relations
  • functions map to functions
  • binary relation

21
First-Order Logic Interpretations
  • Holds
  • relation P
  • terms t1,,tn
  • interpretation I
  • holds (P(t1,,tn), I) iff ltI(t1),, I(tn)gt
    belongs to I(P)
  • Equality
  • holds(t1 t2, I) iff I(t1) is the same object as
    I(t2)

22
Entailment
  • A KB entails S iff holds(KB, I) implies holds(S,
    I)
  • Computing entailment is impossible
  • infinitely many interpretations
  • holds(S, I) may be impossible because of
    quantifiers
  • for all in an infinite universe
  • Proofs
  • S is entailed by KB implies that there is a
    finite proof of S from KB

23
Proofs
  • Axiomitization
  • Want to prove holds(S, I1) for some
    interpretations I1
  • Set of sentences, axioms, as a KB
  • holds(KB, I1) and holds(S, I1)
  • axioms may be too weak
  • holds(KB, I2) and fails(S, I2),
  • KB does not entail S
  • Add an axiom to KB so that
  • holds(KB, I2) and holds(S, I2)
  • but, holds(KB, I3) and fails(S, I3)

24
First-Order Resolution
  • for all x, P(x) ? Q(x)
  • P(A)
  • ________________________________________________
  • Q(A)
  • for all x, P(x) ? Q(x)
  • P(A)
  • ________________________________________________
  • Q(A)
  • for all x, P(A) ? Q(A)
  • P(A)
  • _________________________________________________
  • Q(A)
  • Syllogism
  • Equivalence by
  • definition of
  • implication
  • Substitute A for x

25
First-Order Resolution
  • Convert to clausal form
  • Substitutions
  • v1/t1,,vn/tn
  • substitute each variable vi with term ti
  • Unification
  • find substitution to make two expressions match
  • expressions e1 and e2 are unifiable if there
    exists a substitution s such that e1s e2s

26
Substitution
  • P(x, f(y), B) an atomic sentence

1
27
Unification
  • Let e1 x and e2 y, unifier s

1
28
Most General Unifier (MGU)
  • G is a MGU iff for all unifiers S, there exists a
    unifier s such that the result of applying G
    followed by s to e1 is the same result as
    applying S to e1, and the same for e2
  • All other unifiers can be expressed as an extra
    substitution added on to the MGU
  • MGU for P(x) and P(A) is A

29
First-Order Resolution
  • Given a ? F, ? ? ß, and MGU(F, ?) ?
  • Conclude (a ? ß) ?
  • P(x) ? Q(x,y)
  • P(A) ? R(B,z)
  • ___________________________________________
  • (Q(x,y) ? R(B,z))?
  • Q(A,y) ? R(B,Z)

T x/A
30
Proving Validity
  • Valid sentence is always true
  • derivable from nothing
  • entailed by the empty set of sentences
  • Proof by resolution refutation
  • Negate the sentence
  • derive a contradiction
  • Example
  • syllogism (P(x) ? Q(x)) ? (P(A) ? Q(A))
  • negated clausal form ( P(x) ? Q(x)) ? P(A) ?
    Q(A)

31
Proving Validity
  • Proof

1
32
Completeness and Decidability
  • complete
  • If KB entails S, then KB can prove S
  • Godels Completeness Theorem
  • There exists a complete proof system for FOL
  • Robinsons Completeness Theorem
  • Resolution refutation is a complete proof system
    for FOL
  • FOL is semi-decidable
  • If there is a proof, we will halt with it
  • If not, we may never halt

1
33
Rules and Programming
  • How to compute what is true
  • (Parent(x,y) ? Parent(y,z)) ? Grandparent (x,z)
  • Find grandparents given parents
  • Find parents given grandparents
  • Rule-Based systems
  • Logic Programming
  • x ? y ? z
  • z is consequent
  • x and y are antecedents
  • z - x, y

34
Horn Clauses
  • A clause with at most one positive literal
  • Rule
  • exactly one positive literal
  • one or more negative literals
  • Fact
  • exactly one positive literal
  • no negative literals
  • Consistency constraint
  • no positive literals

35
Inference Backchaining
  • Prove C
  • Push C and Ans literal on stack
  • Repeat
  • Pop literal L
  • Choose a consequent to unify with L
  • Push antecedents onto stack
  • Apply unifier to entire stack
  • If no match, fail and backup to last choice
  • Just like resolution

36
Example KB
  • Father(A,B)
  • Mother(B,C)
  • GrandP(?x,?z) - Parent(?x,?y), Parent(?y,?z)
  • Parent(?x,?y) - Father(?x,?y)
  • Parent(?x,?y) - Mother(?x,?y)
  • Prove
  • GrandP(A,?w), Ans(?w)

1
37
Sentence Order
  • parent(A,B)
  • parent(B,C)
  • ancestor(?x,?z) - ancestor(?x,?y), parent(?x,?z)
  • ancestor(?x,?y) - parent(?x,?y)
  • Prove ancestor(?x,C), Ans(?x)
  • Infinite loop!

1
38
Negation
  • No!
  • Illegal
  • P ? Q ? R
  • same as P ? Q ? R
  • not Horn
  • Closed world assumption
  • We know everything there is to know about our
    world
  • Anything we dont know is false
  • Use failure to prove as a negation

39
Natural Language
  • Applications
  • DB interfaces
  • Automated customer service
  • Grammar checking
  • Web search
  • Document translation

40
Natural Language
  • Speech recognition
  • sound frequency
  • Syntactic analysis
  • grammar
  • Semantics analysis
  • meaning
  • Pragmatics
  • context of utterance
  • connect meaning with general knowledge

41
Syntax
  • Grammar the legal structures
  • Parsing finding legal structures of a sentence
  • Parse tree

S
NP
VP
V
V
N
Art
N
threw
Haines
1
the
frisbee
42
Grammar
  • Rewrite rules
  • S ? NP VP
  • NP ? Name
  • NP ? Art N
  • Name ? Haines
  • Art ? the
  • N ? frisbee
  • Legal sentence
  • A sentence is legal if, starting at S, we can
    find a sequence of rewrite rules that generate
    the sentence

43
Types of Grammar
  • Grammar type hierarchy ordered by generality
  • A, B are non-terminals
  • x is a string of terminals
  • a, ß, ? are strings of terminals and
    non-terminals
  • Regular grammars
  • A ? x, A ? BC, A ? xB
  • Context-free grammars
  • A ? ?
  • Context-sensitive grammars
  • a A ß ? a ? ß

44
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
1
45
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
Pronoun
1
46
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
Pronoun
Haines
1
47
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
Name
1
48
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
Name
Haines
1
49
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
Name
Verb
NP
Haines
1
50
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
Name
Verb
NP
Haines
threw
Article
Noun
1
51
Top Down Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
NP
VP
Name
Verb
NP
Haines
threw
Article
Noun
frisbee
the
1
52
Top Down Parsing
  • Problems
  • Left-recursive rules
  • NP ? NP PP
  • Rules are selected without input check
  • Repeated sub-tree parsing

53
Bottom Up Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

Haines
threw
the
frisbee
1
54
Bottom Up Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

Name
Verb
Article
Noun
Haines
threw
the
frisbee
1
55
Bottom Up Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

NP
VP
NP
Name
Verb
Article
Noun
Haines
threw
the
frisbee
1
56
Bottom Up Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
VP
NP
VP
NP
Name
Verb
Article
Noun
Haines
threw
the
frisbee
1
57
Bottom Up Parsing
  • Haines threw the frisbee
  • S ? NP VP
  • S ? S Conjunction S
  • NP ? Pronoun
  • NP ? Name
  • NP ? Article Noun
  • NP ? Number
  • NP ? NP PP
  • VP ? Verb
  • VP ? Verb VP
  • VP ? Verb Adj
  • VP ? VP PP
  • PP ? Prep VP

S
S
VP
NP
VP
NP
Name
Verb
Article
Noun
Haines
threw
the
frisbee
1
58
Semantics
  • Meaning
  • independent of structure
  • John broke the lamp
  • The lamp was broken by John
  • No consideration of context

59
Semantics
  • The semantics of a constituent is the semantics
    of its constituents
  • (S ?pred) - (NP ?subj) (VP ?subj ?pred)
  • (VP ?subj ?pred) - (Verb ?subj ?obj ?pred) (NP
    ?obj)
  • (NP ?sem) - (Name ?sem)
  • Lexicon gives the semantics of the words
  • (Verb ?x ?y (hit ?x ?y)) - hit
  • (Name ?John) - John
  • (Name ?Harry) - Harry
  • John hit Harry
  • (backchain (S ?sem))
  • ?sem (hit John Harry)

60
Conclusion
61
References
  • 1 MIT Artificial Intelligence Course 6.034,
    Spring 2003
Write a Comment
User Comments (0)
About PowerShow.com