Introduction - Stanford Universitylogic.stanford.edu/classes/cs157/2011/lectures/lecture01.pdf ·...
Transcript of Introduction - Stanford Universitylogic.stanford.edu/classes/cs157/2011/lectures/lecture01.pdf ·...
-
1
Introduction
Computational Logic Lecture 1
Michael Genesereth Autumn 2011
2
Computational Logic
q(b,c)p(a,b)
∀x.∀y.(p(x,y) ⇒ q(x,y))
∃x.p(x,d)
¬p(b,d)
p(c,b)∨ p(c,d)
-
2
3
Mathematics
Group Axioms���
Theorem
Tasks:Proof CheckingProof Generation
(x × y) × z = x × (y × z)x × e = xe × x = xx × x −1 = e
x −1 × x = e
4
Some Successes
Various Theorems4 color theorem (Appel and Haken)the limit of a sum is the sum of the limitsthe Bolzano-Weierstrass Theoremthe Fundamental Theorem of calculusEuler's identityGauss' law of quadratic reciprocitythe undecidability of the halting problemGodel's incompleteness theorem (Shankar)
Other Thousands of Problems for Theorem Provers (TPTP) CADE ATP Systems Competition (CASC)
-
3
5
Software Engineering
Program
Partial Specification:
Tasks:Program VerificationProof of TerminationComplexity AnalysisPartial Evaluation
sorter L M
€
∀i.∀j.(i < j⇒ Mi < Mj )
6
Hardware Engineering
Circuit: Premises:
Conclusion:
x ∧ y ⇒ ¬c
Applications:SimulationConfigurationDiagnosisTest Generation
o⇔ (x ∧ ¬y)∨ (¬x∧ y)a⇔ z ∧ ob⇔ x ∧ ys⇔ (o∧ ¬z)∨ (¬o∧ z)c⇔ a ∨b
xy
z
s
c
o
a
b
-
4
7
Constraint Satisfaction Systems
8
Database Tables
Queriesquery(X,Z) :- parent(X,Y) & parent(Y,Z)
Constraintsillegal :- parent(X,X)illegal :- parent(X,Y) & parent(Y,X)
Deductive Database Systems
parentart bobart beabea coe
parent(art,bob)parent(art,bea)parent(bob,coe)
-
5
9
Data Integration
Side-by-sideComparison
Infomaster
Manufacturer 1Manufacturer 2
General Data
IntegratedSearch
Product analysis
SatisfactionRatings
Supplier 1Supplier 2
Supplier 3Supplier 4
10
Logical Spreadsheets
-
6
11
Examples of Non-Functional ConstraintsScheduling
–Start times must be before end times–Room 104 may not be scheduled after 5:00 pm–Only senior managers can reserve the third floorconference room
Travel Reservations–The number of lap infants in a group on a flightmust not exceed the number of adults.
Academic Programs–Students must take at least 2 math courses
12
Regulations and Business Rules
Using the language of logic, it is possible to definenew relations.
Office mates are people who share an office.
officemate(X,Y) :- office(X,Z) ∧ office(Y,Z)
This includes the property of legality / illegality.
Managers and subordinates may not be office mates.
illegal :- manages(X,Y) ∧ officemate(X,Y)
-
7
13
Michigan Lease Termination ClauseThe University may terminate this lease when the Lessee, havingmade application and executed this lease in advance ofenrollment, is not eligible to enroll or fails to enroll in theUniversity or leaves the University at any time prior to theexpiration of this lease, or for violation of any provisions of thislease, or for violation of any University regulation relative toresident Halls, or for health reasons, by providing the studentwith written notice of this termination 30 days prior to theeffective data of termination; unless life, limb, or property wouldbe jeopardized, the Lessee engages in the sales of purchase ofcontrolled substances in violation of federal, state or local law, orthe Lessee is no longer enrolled as a student, or the Lesseeengages in the use or possession of firearms, explosives,inflammable liquids, fireworks, or other dangerous weaponswithin the building, or turns in a false alarm, in which cases amaximum of 24 hours notice would be sufficient.
14
Logical VersionA ⇐ A1 ∧ A2 ∧¬BA ⇐ A4 ∧¬BA ⇐ A5 ∧¬BA ⇐ A6 ∧¬BA ⇐ A7 ∧¬B
B ⇐ B1B ⇐ B2B ⇐ B3B ⇐ B4B ⇐ B5
-
8
15
Elements
16
Formal Mathematics
Algebra1. Formal language for encoding information2. Legal transformations3. Automation
Logic1. Formal language for encoding information2. Legal transformations3. Automation
-
9
17
Algebra Problem
Xavier is three times as old as Yolanda. Xavier's ageand Yolanda's age add up to twelve. How old areXavier and Yolanda?
18
Algebra Solution
Xavier is three times as old as Yolanda. Xavier's ageand Yolanda's age add up to twelve. How old areXavier and Yolanda?
Automation: Saint, Sin, Reduce, Macsyma,Mathematica
x − 3y = 0x + y = 12−4y = −12
y = 3x = 9
-
10
19
Logic Problem
If Mary loves Pat, then Mary loves Quincy. If it isMonday, then Mary loves Pat or Quincy. If it isMonday, does Mary love Quincy?
If it is Monday, does Mary love Pat?
Mary loves only one person at a time. If it isMonday, does Mary love Pat?
20
FormalizationSimple Sentences: Mary loves Pat. Mary loves Quincy. It is Monday.
Premises: If Mary loves pat, Mary loves Quincy. If it Monday, Mary loves Pat or Quincy. Mary loves one person at a time.
Questions: Does Mary love Pat? Does Mary love Qunicy?
p⇒ qm⇒ p∨ q
p∧ q⇒
⇒ p⇒ q
pqm
-
11
21
Rule of Inference
Propositional Resolution
NB: If pi is the same as sj, it is okay to drop the twosymbols, with the proviso that only one such pairmay be dropped.
NB: If a constant is repeated on the left or the right,all but one of the occurrences can be deleted.
p1 ∧ ...∧ pk ⇒ q1 ∨ ...∨ qlr1 ∧ ...∧ rm ⇒ s1 ∨ ...∨ sn
p1 ∧ ...∧ pk ∧ r1 ∧ ...∧ rm ⇒ q1 ∨ ...∨ ql ∨ s1 ∨ ...∨ sn
22
Examples
p ⇒ q⇒ p⇒ q
p ⇒ qq ⇒p ⇒
p ⇒ qq ⇒ rp ⇒ r
-
12
23
Logic Problem Revisited
p ⇒ qm ⇒ p∨qm ⇒ q ∨qm ⇒ q
If Mary loves Pat, then Mary loves Quincy. If it isMonday, then Mary loves Pat or Quincy. If it isMonday, does Mary love Quincy?
24
Logic Problem Concluded
m ⇒ qp∧ q ⇒m ∧ p ⇒
Mary loves only one person at a time. If it isMonday, does Mary love Pat?
-
13
25
Automated Reasoning
26
Logic TechnologyLanguages Knowledge Interchange Format (KIF) - ANSI Common Logic - W3C
Some Popular Automated Reasoning SystemsOtter / Snark / Vampire / …PTTP / Epilog
Knowledge Bases Definitions (Bachelor is an unmarried adult male.) Physical Laws (e.g. PV=nRT) Laws (e.g. 1040 necessary if earnings > $10,000.)
-
14
27
Study Guide
28
Multiple Logics
Propositional Logic
If it is raining, the ground is wet.
Relational LogicIf x is a parent of y, then y is a child of x.
Modal LogicJohn believes that all men are mortal.
-
15
29
Common Topics
Common TopicsSyntax - expressions in the languageSemantics - meaning of expressionsComputational Matters
Contrasts Expressiveness - operators, variables, terms, ... Computational Hierarchy - polynomial? decidable? Tradeoffs - expressiveness versus computability
30
Meta
We will frequently write sentences about sentences.
Sentence: When it rains, it pours.Metasentence: That sentence contains two verbs.
We will frequently prove things about proofs.
Proofs: formalMetaproofs: informal
-
16
31
Mike took it twice!
32
http://cs157.stanford.edu