procedura di inferenza/deduzione
DESCRIPTION
Procedura di Inferenza/deduzione. Metodo automatico per derivare nuove frasi (formule) a partire da quelle già presenti nella base di conoscenza (KB) - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/1.jpg)
Procedura di Inferenza/deduzione
• Metodo automatico per derivare nuove frasi (formule) a partire da quelle già presenti nella base di conoscenza (KB)
• Corretta (“sound”) se per ogni formula derivata da KB usando la procedura di inferenza si ha che e’ una conseguenza logica di KB. Completa se vale anche il viceversa.
• Dimostrazione di : insieme di operazioni eseguite dalla procedura di inferenza (corretta) per derivare
• Teoria della dimostrazione (“proof theory”): è relativa ad un longuaggio di KR. Specifica un insieme di passi di ragionamento/inferenza che sono corretti
![Page 2: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/2.jpg)
Alcuni Linguaggi di KR
• Un linguaggio di KR deve essere conciso, espressivo (il più possibile), non ambiguo, indipendente dal contesto, efficace (esiste una procedura di inferenza corretta ed implementabile)
• Linguaggio naturale: espressivo, ma ambiguo, non conciso
• Linguaggio di programmazione: preciso, strutturato, ma poco espressivo
• Logica: precisa, concisa, expressiva
![Page 3: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/3.jpg)
Semantica• ciò che la formula asserisce sul mondo = significato della frase
• Dipende da una particolare interpretazione: Una formula è vera rispetto ad una interpretazione se ciò che rappresenta è vero nel mondo. Es: “il papa è in Olanda” … “il microfilm è nel lampadario”
• Principio di composizionalità: il significato di una formula è una funzione del significato delle sue parti (si per la logica)
• Formula valida (tautologia): vera per qualsiasi interpretazione (“piove o non piove”)
• Formula soddisfacibile: esiste una interpretazione per cui la formula è vera (insoddifacibile altrimenti).
• Tautologica soddisfacibile
![Page 4: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/4.jpg)
Modelli (logica proposizionale)• Un Modello per una F.B.F è una intepretazione
(associazione) dei simboli proposizionali di in valori di verità (V,F) per i quali è vero.
• Modello per “mondo” in cui è vero rispetto ad una certa interpretazione
• Esempio, modelli di “P not Q”: [F,F], [F,V], [V,F]
• Servono per definire il concetto (semantico) di conseguenza logica: Se l’insieme di tutti i modelli di una KB di F.B.F.sono anche modelli di allora è una conseguenza logica di KB
![Page 5: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/5.jpg)
Validity and satisfiability
A sentence is valid if it is true in all interpretatioms,e.g., True, A A, A A, (A (A B)) B
Validity is connected to inference via the Deduction Theorem:KB ╞ α if and only if (KB α) is valid
A sentence is satisfiable if it is true in some interpretatione.g., A B, C
A sentence is unsatisfiable if it is true in no interpretatione.g., AA
Satisfiability is connected to inference via the following:KB ╞ α if and only if (KB α) is unsatisfiable
–––
![Page 6: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/6.jpg)
Dimostrazioni e Inferenza (ragionamento deduttivo)
• Dimostrazione (derivazione) logica di una formula sequenza di applicazioni di regole di inferenza a partire dalle F.B.F. nella KB fino a generare il teorema
• Procedura di inferenza: procedura per costruire dimostrazioni logiche attraverso l’individuazione di appropriate sequenze di applicazioni di regole di inferenza
• Dimostrazioni semantiche non usano procedure di infernza, ma modelli (dimostriamo la conseguenza logica). Complessità temporale e spaziale esponenziale
![Page 7: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/7.jpg)
Altro Metodo Semantico
è una conseguenza logica di una KB consistente (soddisfacibile) se e solo se KB estesa con NOT è insoddifacibile (non ha modelli).
• Formulo il problema come CSP Booleano (SAT). Se trovo un modello per KB’, allora è soddisfacibile: non è una conseguenza logica di KB.
• Complessità esponenziale nel caso generale, polinomiale per 2SAT, e formule di HORN.
![Page 8: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/8.jpg)
Proof methods
• Proof methods divide into (roughly) two kinds:
– Application of inference rules• Legitimate (sound) generation of new sentences from old• Proof = a sequence of inference rule applications
Can use inference rules as operators in a standard search algorithm
• Typically require transformation of sentences into a normal form
– Model checking• truth table enumeration (always exponential in n)• improved backtracking, e.g., Davis--Putnam-Logemann-Loveland (DPLL)• heuristic search in model space (sound but incomplete)
e.g., min-conflicts-like hill-climbing algorithms
••
•»
•
•–
»
![Page 9: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/9.jpg)
Resolution
Conjunctive Normal Form (CNF) conjunction of disjunctions of literals
clausesE.g., (A B) (B C D)
• Resolution inference rule (for CNF):li … lk, m1 … mn
li … li-1 li+1 … lk m1 … mj-1 mj+1 ... mn
where li and mj are complementary literals.
Resolution is sound and complete for propositional logic
»•
•
![Page 10: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/10.jpg)
Resolution
Soundness of resolution inference rule:
(li … li-1 li+1 … lk) li
mj (m1 … mj-1 mj+1 ... mn)
(li … li-1 li+1 … lk) (m1 … mj-1 mj+1 ... mn)
![Page 11: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/11.jpg)
Conversion to CNF
B1,1 (P1,2 P2,1)β
1. Eliminate , replacing α β with (α β)(β α).(B1,1 (P1,2 P2,1)) ((P1,2 P2,1) B1,1)
2. Eliminate , replacing α β with α β.(B1,1 P1,2 P2,1) ((P1,2 P2,1) B1,1)
3. Move inwards using de Morgan's rules and double-negation:(B1,1 P1,2 P2,1) ((P1,2 P2,1) B1,1)
4. Apply distributivity law ( over ) and flatten:(B1,1 P1,2 P2,1) (P1,2 B1,1) (P2,1 B1,1)
–•
–•
–•
–
•
![Page 12: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/12.jpg)
Resolution algorithm
• Proof by contradiction, i.e., show KBα unsatisfiable
•
![Page 13: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/13.jpg)
Resolution example
• KB = (B1,1 (P1,2 P2,1)) B1,1 α = P1,2
•
![Page 14: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/14.jpg)
Forward and backward chaining
• Horn Form (restricted)KB = conjunction of Horn clauses
– Horn clause = • proposition symbol; or• (conjunction of symbols) symbol
– E.g., C (B A) (C D B)• Modus Ponens (for Horn Form): complete for Horn KBs
α1, … ,αn, α1 … αn ββ
• Can be used with forward chaining or backward chaining.• These algorithms are very natural and run in linear time
•••
–
–
![Page 15: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/15.jpg)
Forward chaining
• Idea: fire any rule whose premises are satisfied in the KB,– add its conclusion to the KB, until query is found
![Page 16: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/16.jpg)
Forward chaining algorithm
• Forward chaining is sound and complete for Horn KB
•
![Page 17: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/17.jpg)
Forward chaining example
![Page 18: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/18.jpg)
Forward chaining example
![Page 19: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/19.jpg)
Forward chaining example
![Page 20: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/20.jpg)
Forward chaining example
![Page 21: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/21.jpg)
Forward chaining example
![Page 22: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/22.jpg)
Forward chaining example
![Page 23: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/23.jpg)
Forward chaining example
![Page 24: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/24.jpg)
Forward chaining example
![Page 25: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/25.jpg)
Proof of completeness
• FC derives every atomic sentence that is entailed by KB
1. FC reaches a fixed point where no new atomic sentences are derived
2. Consider the final state as a model m, assigning true/false to symbols
3. Every clause in the original KB is true in m (if a1 … ak b is false in m FC has not reached fixed point)
4. Hence m is a model of KB5. If KB╞ q, q is true in every model of KB, including m
6.–
•1.2.
–
•
![Page 26: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/26.jpg)
Backward chaining
Idea: work backwards from the query q:to prove q by BC,
check if q is known already, orprove by BC all premises of some rule concluding q
Avoid loops: check if new subgoal is already on the goal stack
Avoid repeated work: check if new subgoal1. has already been proved true, or2. has already failed
3.
–
•
•
![Page 27: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/27.jpg)
Backward chaining example
![Page 28: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/28.jpg)
Backward chaining example
![Page 29: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/29.jpg)
Backward chaining example
![Page 30: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/30.jpg)
Backward chaining example
![Page 31: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/31.jpg)
Backward chaining example
![Page 32: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/32.jpg)
Backward chaining example
![Page 33: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/33.jpg)
Backward chaining example
![Page 34: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/34.jpg)
Backward chaining example
![Page 35: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/35.jpg)
Backward chaining example
![Page 36: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/36.jpg)
Backward chaining example
![Page 37: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/37.jpg)
Forward vs. backward chaining
• FC is data-driven, automatic, unconscious processing,– e.g., object recognition, routine decisions
• May do lots of work that is irrelevant to the goal
• BC is goal-driven, appropriate for problem-solving,– e.g., Where are my keys? –
• Complexity of BC can be much less than linear in size of KB
•–
–
![Page 38: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/38.jpg)
Efficient propositional inference
Two families of efficient algorithms for propositional inference (the work at semantic level):
Complete backtracking search algorithms
• DPLL algorithm (Davis, Putnam, Logemann, Loveland)
• Incomplete local search algorithms– WalkSAT algorithm
–
•
![Page 39: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/39.jpg)
The DPLL algorithm
Determine if an input propositional logic sentence (in CNF) is satisfiable.
Improvements over truth table enumeration:1. Early termination
A clause is true if any literal is true.A sentence is false if any clause is false.
2. Pure symbol heuristicPure symbol: always appears with the same "sign" in all clauses. e.g., In the three clauses (A B), (B C), (C A), A and B are pure, C is
impure. Make a pure symbol literal true.
3. Unit clause heuristicUnit clause: only one literal in the clauseThe only literal in a unit clause must be true.
•
•
![Page 40: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/40.jpg)
The DPLL algorithm
![Page 41: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/41.jpg)
The WalkSAT algorithm
• Incomplete, local search algorithm
• Evaluation function: The min-conflict heuristic of minimizing the number of unsatisfied clauses
• Balance between greediness and randomness
•
•
•
![Page 42: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/42.jpg)
The WalkSAT algorithm
![Page 43: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/43.jpg)
Hard satisfiability problems
• Median runtime for 100 satisfiable random 3-CNF sentences, n = 50
•
![Page 44: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/44.jpg)
Hard satisfiability problems
• Consider random 3-CNF sentences. e.g.,
(D B C) (B A C) (C B E) (E D B) (B E C)
m = number of clauses
n = number of symbols
– Hard problems seem to cluster near m/n = 4.3 (critical point)
–
•
•
![Page 45: Procedura di Inferenza/deduzione](https://reader034.vdocuments.net/reader034/viewer/2022051117/5681595b550346895dc6980a/html5/thumbnails/45.jpg)
Hard satisfiability problems