Sunteți pe pagina 1din 68

9.

Inferenta in Logica de Ordinul Intai

December 20, 2016


Cuprins

Reducere la inferenta in Logica Propozitionala

Metode de inferenta specifice FOL


Generalized Modus Ponens (GMP)
Forward chaining
Backward chaining
Resolutia
Conversie la CNF
Demonstratie prin resolutie
Reprezentare in FOL
Some students took French in spring 2001
Every student who takes French passes it.
Only one student took Greek in spring 2001.
The best score in Greek is always higher than the best score in
French.
Every person who buys a policy is smart.
No person buys an expensive policy.
There is an agent who sells policies only to people who are
not insured.
There is a barber who shaves all men in town who do not
shave themselves.
A person born in the UK, each of whose parents is a UK
citizen or a UK resident, is a UK citizen by birth.
A person born outside the UK, one of whose parents is a UK
citizen by birth, is a UK citizen by descent.
Politicians can fool some of the people all of the time, and
they can fool all of the people some of the time, but they
cant fool all of the people all of the time.
Predicate necesare
Takes(x,c,s) studentul x urmeaza cursul c in semestrul s
Passes(x,c,s) studentul x promoveaza cursul c in semestrul s
Score(x,c,s) nota obtinuta de studentul x in cursul c in semstrul s
x y x este mai mare decat y
F, G un anumit curs defranceza si unul de greaca
Buys(x,y,z) x cumpara y de la z
Sells(x,y,z) x vinde y lui z
Shaves(x,y) x barbiereste pe y
Born(x,c) persoana x este nascuta in tara c
Parent(x,y) x este parintele lui y
Citizen(x,c,r) x are cetatenia tarii c penrtu motivul r
Resident(x,c) x este rezident al tarii c
Fools(x,y,t) persoana x prosteste pe y la momentul t
Student(x), Person(x), Man(x), Barber(x), Expensive(x),
Agent(c), Insured(x), Smart(x), Politician(x): predicate
satisfacute de membrii catgeoriei corespunzatoare
Reprezentare
Some students took French in spring 2001

x Student(x) Takes(x, F , Spring 2001)


Reprezentare
Some students took French in spring 2001

x Student(x) Takes(x, F , Spring 2001)


Every student who takes French passes it.

x, s Student(x) Takes(x, F , s) Passes(x, F , s)


Reprezentare
Some students took French in spring 2001

x Student(x) Takes(x, F , Spring 2001)


Every student who takes French passes it.

x, s Student(x) Takes(x, F , s) Passes(x, F , s)


Only one student took Greek in spring 2001.

x Student(x)Takes(x, G , Spring 2001)y y 6= x Takes(y , G , Spring 2001)


Reprezentare
Some students took French in spring 2001

x Student(x) Takes(x, F , Spring 2001)


Every student who takes French passes it.

x, s Student(x) Takes(x, F , s) Passes(x, F , s)


Only one student took Greek in spring 2001.

x Student(x)Takes(x, G , Spring 2001)y y 6= x Takes(y , G , Spring 2001)


The best score in Greek is always higher than the best score in French.

s x y Score(x, G , s) > Score(y , F , s)


Reprezentare
Some students took French in spring 2001

x Student(x) Takes(x, F , Spring 2001)


Every student who takes French passes it.

x, s Student(x) Takes(x, F , s) Passes(x, F , s)


Only one student took Greek in spring 2001.

x Student(x)Takes(x, G , Spring 2001)y y 6= x Takes(y , G , Spring 2001)


The best score in Greek is always higher than the best score in French.

s x y Score(x, G , s) > Score(y , F , s)


Every person who buys a policy is smart.

x Person(x) (y , z Policy (y ) Buys(x, y , z)) Smart(x)


Reprezentare
Some students took French in spring 2001

x Student(x) Takes(x, F , Spring 2001)


Every student who takes French passes it.

x, s Student(x) Takes(x, F , s) Passes(x, F , s)


Only one student took Greek in spring 2001.

x Student(x)Takes(x, G , Spring 2001)y y 6= x Takes(y , G , Spring 2001)


The best score in Greek is always higher than the best score in French.

s x y Score(x, G , s) > Score(y , F , s)


Every person who buys a policy is smart.

x Person(x) (y , z Policy (y ) Buys(x, y , z)) Smart(x)


No person buys an expensive policy.

x, y , z Person(x) Policy (y ) Expensive(y ) Buys(x, y , z)


Reprezentare
Some students took French in spring 2001

x Student(x) Takes(x, F , Spring 2001)


Every student who takes French passes it.

x, s Student(x) Takes(x, F , s) Passes(x, F , s)


Only one student took Greek in spring 2001.

x Student(x)Takes(x, G , Spring 2001)y y 6= x Takes(y , G , Spring 2001)


The best score in Greek is always higher than the best score in French.

s x y Score(x, G , s) > Score(y , F , s)


Every person who buys a policy is smart.

x Person(x) (y , z Policy (y ) Buys(x, y , z)) Smart(x)


No person buys an expensive policy.

x, y , z Person(x) Policy (y ) Expensive(y ) Buys(x, y , z)


There is an agent who sells policies only to people who are not insured.

x Agent(x) y , z Policy (y ) Sells(x, y , z) Person(z) Insured(z))


There is a barber who shaves all men in town who do not shave
themselves.
x Barber (x) (y Man(y ) Shaves(y , y ) Shaves(x, y ))
There is a barber who shaves all men in town who do not shave
themselves.
x Barber (x) (y Man(y ) Shaves(y , y ) Shaves(x, y ))
A person born in the UK, each of whose parents is a UK citizen or a UK
resident, is a UK citizen by birth.
x Person(x) Born(x, UK ) (y Parent(y , x)
( (r Citizen(y , UK , r )) Resident(y , UK ))) Citizen(x, UK , Birth)
There is a barber who shaves all men in town who do not shave
themselves.
x Barber (x) (y Man(y ) Shaves(y , y ) Shaves(x, y ))
A person born in the UK, each of whose parents is a UK citizen or a UK
resident, is a UK citizen by birth.
x Person(x) Born(x, UK ) (y Parent(y , x)
( (r Citizen(y , UK , r )) Resident(y , UK ))) Citizen(x, UK , Birth)
A person born outside the UK, one of whose parents is a UK citizen by
birth, is a UK citizen by descent.
x Person(x) Born(x, UK ) (y Parent(y , x) Citizen(y , UK , Birth))
Citizen(x, UK , Descent)
There is a barber who shaves all men in town who do not shave
themselves.
x Barber (x) (y Man(y ) Shaves(y , y ) Shaves(x, y ))
A person born in the UK, each of whose parents is a UK citizen or a UK
resident, is a UK citizen by birth.
x Person(x) Born(x, UK ) (y Parent(y , x)
( (r Citizen(y , UK , r )) Resident(y , UK ))) Citizen(x, UK , Birth)
A person born outside the UK, one of whose parents is a UK citizen by
birth, is a UK citizen by descent.
x Person(x) Born(x, UK ) (y Parent(y , x) Citizen(y , UK , Birth))
Citizen(x, UK , Descent)
Politicians can fool some of the people all of the time, and they can fool
all of the people some of the time, but they cant fool all of the people all
of the time.
x Politician(x)
y t Person(y ) Fools(x, y , t))
t y Person(y ) Fools(x, y , t))
(t y Person(y ) Fools(x, y , t))
There is a barber who shaves all men in town who do not shave
themselves.
x Barber (x) (y Man(y ) Shaves(y , y ) Shaves(x, y ))
A person born in the UK, each of whose parents is a UK citizen or a UK
resident, is a UK citizen by birth.
x Person(x) Born(x, UK ) (y Parent(y , x)
( (r Citizen(y , UK , r )) Resident(y , UK ))) Citizen(x, UK , Birth)
A person born outside the UK, one of whose parents is a UK citizen by
birth, is a UK citizen by descent.
x Person(x) Born(x, UK ) (y Parent(y , x) Citizen(y , UK , Birth))
Citizen(x, UK , Descent)
Politicians can fool some of the people all of the time, and they can fool
all of the people some of the time, but they cant fool all of the people all
of the time.
x Politician(x)
y t Person(y ) Fools(x, y , t))
t y Person(y ) Fools(x, y , t))
(t y Person(y ) Fools(x, y , t))
All globlins are taller than all gnomes.

x, y Goblin(x) Gnome(y ) Height(x) > Height(y )


demonstratie: Matusa Agatha

1. Someone who lives in Dreadbury Mansion killed Aunt Agatha.


2. Agatha, the butler, and Charles live in Dreadbury Mansion,
and are the only people who live therein.
3. A killer always hates his victim, and is never richer than his
victim.
4. Charles hates no one that Aunt Agatha hates.
5. Agatha hates everyone except the butler.
6. The butler hates everyone not richer than Aunt Agatha.
7. The butler hates everyone Aunt Agatha hates.
8. No one hates everyone.
9. Agatha is not the butler.
1. Someone who lives in Dreadbury Mansion killed Aunt Agatha.
x livesin(x, DM) kills(x, Agatha)
2. Agatha, the butler, and Charles live in Dreadbury Mansion, and are the
only people who live therein.
livesin(Agatha, DM) lives(Thebutler , DM) lives(Charles, DM)
x livesin(x, DM) x = Agatha x = Thebutler x = Charles)
3. A killer always hates his victim, and is never richer than his victim.
x, y kills(x, y ) hates(x, y ) richer (x, y ))
4. Charles hates no one that Aunt Agatha hates
x hates(Agatha, y ) hates(Charles, y )
5. Agatha hates everyone except the butler.
x hates(Agatha, x) x = Thebutler
6. The butler hates everyone not richer than Aunt Agatha.
x, y richer (x, Agatha) hates(Thebutler , x)
7. The butler hates everyone Aunt Agatha hates.
xhates(Agatha, x) hates(Thebutler , x))
8. No one hates everyone xy hates(x, y )
9. Agatha is not the butler Agatha 6= Thebutler
Scurt istoric

450b.c. Stoics propositional logic, inference (maybe)


322b.c. Aristotle syllogisms (inference rules), quantifiers
1565 Cardano probability theory (propositional logic + uncertainty
1847 Boole propositional logic (again)
1879 Frege first-order logic
1922 Wittgenstein proof by truth tables
1930 Godel complete algorithm for FOL
1930 Herbrand complete algorithm for FOL (reduce to propositiona
1931 Godel complete algorithm for arithmetic
1960 Davis/Putnam practical algorithm for propositional logic
1965 Robinson practical algorithm for FOLresolution
Universal instantiation (UI)

Fiecare instantiere a unei propozitii ce foloseste cuantificatorul


universal este determinata (entailed) de propozitie

v
SUBST ({v /g }, )

pentru fiecare variabila v si termen ground (complet instantiat) g


E.g., x King (x) Greedy (x) = Evil (x) determina

King (John) Greedy (John) = Evil (John)


King (Richard) Greedy (Richard) = Evil (Richard)
King (Father (John)) Greedy (Father (John)) = Evil (Father (John))
Existential instantiation (EI)

Pentru fiecare , variabila v , si constanta k care nu apare nicaieri


altundeva in baza de cunostinte

v
SUBST ({v /k}, )

E.g., x Crown(x) OnHead (x, John) determina

Crown(C1 ) OnHead (C1 , John)

daca C1 este un nou simbol constant, numit constanta Skolem


Instantierea existentiala contd.

UI poate fi aplicata de mai multe ori pentru a adauga noi


propozitii
noua KB este echivalenta cu cea veche

EI poate fi aplicata o data pentru a inlocui propozitia


existentiala
noua KB nu este e echivalenta cu cea veche, dar
este satisfiabila doar daca baza de cunostinte veche este
satisfiabila
Reducere la inferenta in Logica Propozitionala
Presupunem ca in KB avem doar:

x King (x) Greedy (x) = Evil (x)


King (John)
Greedy (John)
Brother (Richard, John)

Daca instantiem propozitiile care includ cuantificatorul universal


in toate modurile posibile, avem

King (John) Greedy (John) = Evil (John)


King (Richard) Greedy (Richard) = Evil (Richard)
King (John)
Greedy (John)
Brother (Richard, John)

Noua KB este propozitionalizata (exprimata in logica


propozitionala): cu urmatoarele simboluri propozitii
King (John), Greedy (John), Evil (John), King (Richard) etc
Reducere contd.
Afirmatie: o propozitie ground este determinata(entailed) de
noua KB daca si numai daca este determinata si de KB
originala
Afirmatie: orice baza de cunostinte KB FOL poate fi
propozitionalizata in asa fel incat sa se pastreze relatia de
entailment
Reducere contd.
Afirmatie: o propozitie ground este determinata(entailed) de
noua KB daca si numai daca este determinata si de KB
originala
Afirmatie: orice baza de cunostinte KB FOL poate fi
propozitionalizata in asa fel incat sa se pastreze relatia de
entailment
Idee: propozitionalizarea KB si interogarea lor folosind
rezolutia
Problema: simbolurile de tip functii care pot avea o infinitate
de termeni complet instantiati (ground): ex.,
Father (Father (Father (John)))
Reducere contd.
Afirmatie: o propozitie ground este determinata(entailed) de
noua KB daca si numai daca este determinata si de KB
originala
Afirmatie: orice baza de cunostinte KB FOL poate fi
propozitionalizata in asa fel incat sa se pastreze relatia de
entailment
Idee: propozitionalizarea KB si interogarea lor folosind
rezolutia
Problema: simbolurile de tip functii care pot avea o infinitate
de termeni complet instantiati (ground): ex.,
Father (Father (Father (John)))
Teorema: Herbrand (1930). daca o propozitie este
determinata de o baza de cunostinte KB FOL, atunci ea este
determinata de un subset finit a bazei de cunostinte
propozitionalizate
Reducere contd.

Idee: For n = 0 to do
creaza KB propozitionalizat instantiind cu termeni de adancime n
verifica daca este determinat de KB

Problema: functioneaza daca este entailed, merge in ciclu


infinit daca nu este entailed
Teorema: Turing (1936), Church (1936), entailment in FOL
este semidecidabil
Probleme cu propozitionalizarea

Propozitionalizarea poate duce la generarea multor propozitii


irelevante
x King (x) Greedy (x) = Evil (x)
King (John)
y Greedy (y )
Brother (Richard, John)

este evident Evil (John), dar propozitionalizarea produce si


fapte precum Greedy (Richard) care sunt irelevante
daca avem p predicate cu aritate k si n constante, vor fi p nk
instantiatieri
Cu simboluri de tip functii, numarul creste foarte mult
Metode de inferenta specifice FOL - Unificarea

Se poate gasi inferenta imediat ce se gaseste o substitutie astfel


incat King (x) si Greedy (x) sa se suprapuna peste King (John) si
Greedy (y )
Unificarea returneaza un unificator : = {x/John, y /John}
UNIFY (p, q) = unde SUBST (, p) = SUBST (, q)

p q
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y , OJ)
Knows(John, x) Knows(y , Mother (y ))
Knows(John, x) Knows(x, OJ)
Metode de inferenta specifice FOL - Unificarea

Se poate gasi inferenta imediat ce se gaseste o substitutie astfel


incat King (x) si Greedy (x) sa se suprapuna peste King (John) si
Greedy (y )
Unificarea returneaza un unificator : = {x/John, y /John}
UNIFY (p, q) = unde SUBST (, p) = SUBST (, q)

p q
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y , OJ) {x/OJ, y /John}
Knows(John, x) Knows(y , Mother (y ))
Knows(John, x) Knows(x, OJ)
Metode de inferenta specifice FOL - Unificarea

Se poate gasi inferenta imediat ce se gaseste o substitutie astfel


incat King (x) si Greedy (x) sa se suprapuna peste King (John) si
Greedy (y )
Unificarea returneaza un unificator : = {x/John, y /John}
UNIFY (p, q) = unde SUBST (, p) = SUBST (, q)

p q
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y , OJ)
Knows(John, x) Knows(y , Mother (y )) {y /John, x/Mother (John)}
Knows(John, x) Knows(x, OJ)
Metode de inferenta specifice FOL - Unificarea

Se poate gasi inferenta imediat ce se gaseste o substitutie astfel


incat King (x) si Greedy (x) sa se suprapuna peste King (John) si
Greedy (y )
Unificarea returneaza un unificator : = {x/John, y /John}
UNIFY (p, q) = unde SUBST (, p) = SUBST (, q)

p q
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y , OJ)
Knows(John, x) Knows(y , Mother (y ))
Knows(John, x) Knows(x, OJ) fail
Standardizing apart eliminarea variabilelor care se suprapun, ex.
Knows(z17 , OJ)
Generalized Modus Ponens (GMP)

p1 , p2 , , ... pn , (p1 p2 ... pn q)


SUBST (, q)
unde SUBST (, pi ) = SUBST (theta, pi ) pentru orice i

p1 este King (John) p1 este King (x)



p2 este Greedy (y ) p2 este Greedy (x)
este {x/John, y /John} q este Evil (x)
SUBST (, q) este Evil (John)

!!! GMP utilizeaza KB cu definite clauses adica disjunctie de


literali cu exact un literal pozitiv. Toate variabilele sunt
quantificate cu quantificatorul universal
Exemplu baza de cunostinte

The law says that it is a crime for an American to sell weapons to


hostile nations. The country Nono, an enemy of America, has
some missiles, and all of its missiles were sold to it by Colonel
West, who is American.
Prove that Col. West is a criminal
Exemplu baza de cunostinte contd.

it is a crime for an American to sell weapons to hostile nations:


American(x) Weapon(y ) Sells(x, y , z) Hostile(z)
Criminal (x)
Exemplu baza de cunostinte contd.

it is a crime for an American to sell weapons to hostile nations:


American(x) Weapon(y ) Sells(x, y , z) Hostile(z)
Criminal (x)
Nono has some missiles, i.e., x Owns(Nono, x) Missile(x)
(prin EI avem): Owns(Nono, M1 ) and Missile(M1 )
Exemplu baza de cunostinte contd.

it is a crime for an American to sell weapons to hostile nations:


American(x) Weapon(y ) Sells(x, y , z) Hostile(z)
Criminal (x)
Nono has some missiles, i.e., x Owns(Nono, x) Missile(x)
(prin EI avem): Owns(Nono, M1 ) and Missile(M1 )
all of its missiles were sold to it by Colonel West
Missile(x) Owns(Nono, x) Sells(West, x, Nono)
Exemplu baza de cunostinte contd.

it is a crime for an American to sell weapons to hostile nations:


American(x) Weapon(y ) Sells(x, y , z) Hostile(z)
Criminal (x)
Nono has some missiles, i.e., x Owns(Nono, x) Missile(x)
(prin EI avem): Owns(Nono, M1 ) and Missile(M1 )
all of its missiles were sold to it by Colonel West
Missile(x) Owns(Nono, x) Sells(West, x, Nono)
Missiles are weapons: Missile(x) Weapon(x)
Exemplu baza de cunostinte contd.

it is a crime for an American to sell weapons to hostile nations:


American(x) Weapon(y ) Sells(x, y , z) Hostile(z)
Criminal (x)
Nono has some missiles, i.e., x Owns(Nono, x) Missile(x)
(prin EI avem): Owns(Nono, M1 ) and Missile(M1 )
all of its missiles were sold to it by Colonel West
Missile(x) Owns(Nono, x) Sells(West, x, Nono)
Missiles are weapons: Missile(x) Weapon(x)
An enemy of America counts as hostile:
Enemy (x, America) Hostile(x)
Exemplu baza de cunostinte contd.

it is a crime for an American to sell weapons to hostile nations:


American(x) Weapon(y ) Sells(x, y , z) Hostile(z)
Criminal (x)
Nono has some missiles, i.e., x Owns(Nono, x) Missile(x)
(prin EI avem): Owns(Nono, M1 ) and Missile(M1 )
all of its missiles were sold to it by Colonel West
Missile(x) Owns(Nono, x) Sells(West, x, Nono)
Missiles are weapons: Missile(x) Weapon(x)
An enemy of America counts as hostile:
Enemy (x, America) Hostile(x)
West, who is American American(West)
Exemplu baza de cunostinte contd.

it is a crime for an American to sell weapons to hostile nations:


American(x) Weapon(y ) Sells(x, y , z) Hostile(z)
Criminal (x)
Nono has some missiles, i.e., x Owns(Nono, x) Missile(x)
(prin EI avem): Owns(Nono, M1 ) and Missile(M1 )
all of its missiles were sold to it by Colonel West
Missile(x) Owns(Nono, x) Sells(West, x, Nono)
Missiles are weapons: Missile(x) Weapon(x)
An enemy of America counts as hostile:
Enemy (x, America) Hostile(x)
West, who is American American(West)
The country Nono, an enemy of America
Enemy (Nono, America)
Forward chaining algorithm
Demonstratie Forward chaining

American(West) Missile(M1) Owns(Nono,M1) Enemy(Nono,America)


Demonstratie Forward chaining

Weapon(M1) Sells(West,M1,Nono) Hostile(Nono)

American(West) Missile(M1) Owns(Nono,M1) Enemy(Nono,America)


Demonstratie Forward chaining

Criminal(West)

Weapon(M1) Sells(West,M1,Nono) Hostile(Nono)

American(West) Missile(M1) Owns(Nono,M1) Enemy(Nono,America)


Proprietati ale forward chaining

Sound si complet pentru first-order definite clauses


Datalog = first-order definite clauses + fara functii (ex. West KB)
E posibil sa nu se terminte daca propozitia nu este entailed
De neevitat: entailment cu definite clauses este semidecidabil
Eficienta algoritmului de inlantuire inainte

Surse de ineficienta:
gasirea tuturor unificatorilor pentru unificarea premiselor
regulilor cu fapte din KB
reverificarea fiecarei reguli pentru satisfacerea premiselor
generarea faptelor irelevante
Algoritmul rete. Production system - actualizare eficienta a KB
Backward chaining algorithm
Demonstratie Backward chaining

Criminal(West)
Demonstratie Backward chaining

Criminal(West) {x/West}

American(x) Weapon(y) Sells(x,y,z) Hostile(z)


Demonstratie Backward chaining

Criminal(West) {x/West}

American(West) Weapon(y) Sells(x,y,z) Hostile(z)


{}
Demonstratie Backward chaining

Criminal(West) {x/West}

American(West) Weapon(y) Sells(West,M1,z)


Sells(x,y,z) Hostile(Nono)
Hostile(z)
{}

Missile(y)
Demonstratie Backward chaining

Criminal(West) {x/West, y/M1}

American(West) Weapon(y) Sells(West,M1,z)


Sells(x,y,z) Hostile(Nono)
Hostile(z)
{}

Missile(y)
{ y/M1 }
Demonstratie Backward chaining

Criminal(West) {x/West, y/M1, z/Nono}

American(West) Weapon(y) Sells(West,M1,z) Hostile(z)


{} { z/Nono }

Missile(y) Missile(M1) Owns(Nono,M1)


{ y/M1 }
Demonstratie Backward chaining

Criminal(West) {x/West, y/M1, z/Nono}

American(West) Weapon(y) Sells(West,M1,z) Hostile(Nono)


{} { z/Nono }

Missile(y) Missile(M1) Owns(Nono,M1) Enemy(Nono,America)


{ y/M1 } {} {} {}
Proprietati ale backward chaining

Cautare in adancime: spatiu liniar cu dimensiunea demonstratiei


Incomplet datorita buclelor infinite si repetarii subgolurilor
Utilizat in programarea logica
Sistem Prolog
la baza: Backward chaining cu Horn clauses (definite clauses si
interogari)
Program = set of clauses = head :- literal1 , . . . literaln .

criminal(X) :- american(X), weapon(Y), sells(X,Y,Z),


hostile(Z).
Efficient unification by open coding
Efficient retrieval of matching clauses by direct linking
Depth-first, left-to-right backward chaining
Built-in predicates for arithmetic etc., e.g., X is Y*Z+3
Closed-world assumption (negation as failure)
e.g., given alive(X) :- not dead(X).
alive(joe) succeeds if dead(joe) fails
Resolution

Resolution + Refutation = Algoritm complet de inferenta


Full first-order version:
1 k , m1 mn
SUBST (, 1 ... i 1 i +1 ... k m1 ... mj1 mj+1 ...

unde UNIFY (i , mj ) = .
Exemplu
Rich(x) Unhappy (x)
Rich(Ken)

rezulta Unhappy (Ken) cu = {x/Ken}

demonstratia prin resolutie KB |= daca CNF (KB ) este


nesatisfiabila
Conversie la CNF

Everyone who loves all animals is loved by someone:


x [y Animal (y ) = Loves(x, y )] = [y Loves(y , x)]
1. Eliminarea biconditionalelor (echivalente) si implicatii

x [y Animal (y ) Loves(x, y )] [y Loves(y , x)]

2. Mutare in interior a : x p x p, x p x p:

x[y (Animal (y ) Loves(x, y ))] [y Loves(y , x)]


x[y Animal (y ) Loves(x, y )] [y Loves(y , x)]
x[y Animal (y ) Loves(x, y )] [y Loves(y , x)]
Conversie la CNF contd.
3. Standardizare variabile: fiecare cuantificator trebuie sa
utilizeze o alta variabila
x [y Animal (y ) Loves(x, y )] [z Loves(z, x)]

4. Skolemizare: fiecare variabila existentiala este inlocuita cu o


functie Skolem a fiecarei variabile universale care o contine pe
cea existentiala
x [Animal (F (x)) Loves(x, F (x))] Loves(G (x), x)

5. Eliminarea cuantificatorilor universali


[Animal (F (x)) Loves(x, F (x))] Loves(G (x), x)

6. Distributia peste :
[Animal (F (x))Loves(G (x), x)][Loves(x, F (x))Loves(G (x), x)]
Resolution proof: definite clauses

American(x) Weapon(y) Sells(x,y,z) Hostile(z) Criminal(x) Criminal(West)

>

>

>

>
L

L
American(West) American(West) Weapon(y) Sells(West,y,z) Hostile(z)

>

>

>
L

L
Missile(x) Weapon(x) Weapon(y) Sells(West,y,z) Hostile(z)

>

>

>
L

L
Missile(M1) Missile(y) Sells(West,y,z) Hostile(z)

>

>
L

L
Missile(x) Owns(Nono,x) Sells(West,x,Nono) Sells(West,M1,z) Hostile(z)
>

>

>
L

L
Missile(M1) Missile(M1) Owns(Nono,M1) Hostile(Nono)

>

>
L

L
Owns(Nono,M1) Owns(Nono,M1) Hostile(Nono)

>
L

L
Enemy(x,America) Hostile(x) Hostile(Nono)
>
L

Enemy(Nono,America) Enemy(Nono,America)
Resolution proof: Curiosity killed the cat

Everyone who loves all animals is loved by someone. Anyone who


kills an animal is loved by no one. Jack loves all animals. Either
Jack or Curiosity killed the cat, who is named Tuna. Did Curiosity
kill the cat?
Cat(Tuna) Cat(x) Animal(x) Kills(Jack,Tuna} Kills(Curiosity,Tuna) Kills(Curiosity,Tuna)
>

>
L

L
Animal(Tuna) Loves(y,x) Animal(z) Kills(x,z) Kills(Jack,Tuna)
>

>
L

Loves(y,x) Kills(x,Tuna) Loves(F(x),x) Loves(G(x),x) Animal (x) Loves(Jack,x)


>

>

>
L

L
Loves(y,Jack) Animal(F(Jack)) Loves(G(Jack),Jack) Animal(F(x)) Loves(G(x),x)

>

>
L

Loves(G(Jack),Jack)
Resolutia - demonstratie in Prover9
10 lives(A) agatha = A butler = A charles = A
11 lives(c1)
15 -killed(A,B) -richer(A,B)
16 richer(A,agatha) hates(butler,A)
17 killed(c1,agatha)
18 butler = A hates(agatha,A)
19 agatha != butler
20 butler != agatha.
21 -killed(agatha,agatha) %negarea a ceea ce vrem sa dem
22 -hates(A,f1(A))
23 -hates(agatha,A) -hates(charles,A)
24 -killed(A,B) hates(A,B)
25 -hates(agatha,A) hates(butler,A)
26 agatha = c1 butler = c1 charles = c1. [resolve(10,a,11,a)].
27 c1 = agatha c1 = butler c1 = charles. [copy(26),flip(a),flip(b),flip(c)].
30 -killed(A,agatha) hates(butler,A). [resolve(15,b,16,a)].
32 hates(c1,agatha). [resolve(24,a,17,a)].
35 -hates(agatha,f1(butler)). [ur(25,b,22,a)].
38 -killed(f1(butler),agatha). [ur(30,b,22,a)].
41 f1(butler) = butler. [resolve(35,a,18,b),flip(a)].
42 -killed(butler,agatha). [38, 41]....
43 c1 = agatha c1 = butler hates(charles,agatha). [para(27(c,1),32(a,1))].
Resolutia - demonstratie in Prover9
10 lives(A) agatha = A butler = A charles = A
11 lives(c1)
15 -killed(A,B) -richer(A,B)
16 richer(A,agatha) hates(butler,A)
17 killed(c1,agatha)
18 butler = A hates(agatha,A)
19 agatha != butler
20 butler != agatha.
21 -killed(agatha,agatha) %negarea a ceea ce vrem sa dem
22 -hates(A,f1(A))
23 -hates(agatha,A) -hates(charles,A)
24 -killed(A,B) hates(A,B)
25 -hates(agatha,A) hates(butler,A)
26 agatha = c1 butler = c1 charles = c1. [resolve(10,a,11,a)].
27 c1 = agatha c1 = butler c1 = charles. [copy(26),flip(a),flip(b),flip(c)].
30 -killed(A,agatha) hates(butler,A). [resolve(15,b,16,a)].
32 hates(c1,agatha). [resolve(24,a,17,a)].
35 -hates(agatha,f1(butler)). [ur(25,b,22,a)].
38 -killed(f1(butler),agatha). [ur(30,b,22,a)].
41 f1(butler) = butler. [resolve(35,a,18,b),flip(a)].
42 -killed(butler,agatha). [38, 41]....
43 c1 = agatha c1 = butler hates(charles,agatha). [para(27(c,1),32(a,1))].
Resolutia - demonstratie in Prover9
10 lives(A) agatha = A butler = A charles = A
11 lives(c1)
15 -killed(A,B) -richer(A,B)
16 richer(A,agatha) hates(butler,A)
17 killed(c1,agatha)
18 butler = A hates(agatha,A)
19 agatha != butler
20 butler != agatha.
21 -killed(agatha,agatha) %negarea a ceea ce vrem sa dem
22 -hates(A,f1(A))
23 -hates(agatha,A) -hates(charles,A)
24 -killed(A,B) hates(A,B)
25 -hates(agatha,A) hates(butler,A)
26 agatha = c1 butler = c1 charles = c1. [resolve(10,a,11,a)].
27 c1 = agatha c1 = butler c1 = charles. [copy(26),flip(a),flip(b),flip(c)].
30 -killed(A,agatha) hates(butler,A). [resolve(15,b,16,a)].
32 hates(c1,agatha). [resolve(24,a,17,a)].
35 -hates(agatha,f1(butler)). [ur(25,b,22,a)].
38 -killed(f1(butler),agatha). [ur(30,b,22,a)].
41 f1(butler) = butler. [resolve(35,a,18,b),flip(a)].
42 -killed(butler,agatha). [38, 41]....
43 c1 = agatha c1 = butler hates(charles,agatha). [para(27(c,1),32(a,1))].
10 lives(A) agatha = A butler = A charles = A
11 lives(c1)
15 -killed(A,B) -richer(A,B)
16 richer(A,agatha) hates(butler,A)
17 killed(c1,agatha)
18 butler = A hates(agatha,A)
19 agatha != butler
20 butler != agatha.
21 -killed(agatha,agatha) %negarea a ceea ce vrem sa dem
22 -hates(A,f1(A))
23 -hates(agatha,A) -hates(charles,A)
24 -killed(A,B) hates(A,B)
25 -hates(agatha,A) hates(butler,A)
26 agatha = c1 butler = c1 charles = c1. [resolve(10,a,11,a)].
27 c1 = agatha c1 = butler c1 = charles. [copy(26),flip(a),flip(b),flip(c)].
30 -killed(A,agatha) hates(butler,A). [resolve(15,b,16,a)].
32 hates(c1,agatha). [resolve(24,a,17,a)].
35 -hates(agatha,f1(butler)). [ur(25,b,22,a)].
38 -killed(f1(butler),agatha). [ur(30,b,22,a)].
41 f1(butler) = butler. [resolve(35,a,18,b),flip(a)].
42 -killed(butler,agatha). [38, 41]
43 c1 = agatha c1 = butler hates(charles,agatha). [para(27(c,1),32(a,1))].
47 c1 = agatha c1 = butler -hates(agatha,agatha). [resolve(43,c,23,b)].
48 c1 = agatha c1 = butler. [resolve(47,c,18,b),].
49 c1 = agatha. [para(48(b,1),17(a,1))].
52 $F. [brewrite(17),rewrite([49(1)]))].
Resolution-based theorem prover

Software pt capsula Orion NASA - verificat cu demonstrator


Hardware design
Software verification
Rezumat

Reducere la inferenta in Logica Propozitionala

Metode de inferenta specifice FOL


Generalized Modus Ponens (GMP)
Forward chaining
Backward chaining
Resolutia
Conversie la CNF
Demonstratie prin resolutie

S-ar putea să vă placă și