Declarative Knowledge Processing 1. Introduction Outline 1. Introduction 2. Syntax Declarative Knowledge Processing Additional material: Propositional Logic 3. Semantics 4. Reasoning Problems 4.1 SAT, the satisfiability problem 4.2 Other reasoning problems Magdalena Ortiz 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and their complexity 5.2 Complexity of Reasoning Knowledge Base Systems Group Institute of Information Systems [email protected] 6. SAT in the real world WS 2012/2013 1/24 Declarative Knowledge Processing 1. Introduction 3/24 Declarative Knowledge Processing Propositional logic 1. Introduction Modeling problems in Propositional Logic as a formalisms for declarative knowledge processing We start with classical propositional logic, the simplest possible logic Propositional logic is the simples and most basic logic. Recall that, for each formalism, we study: We use propositional symbols (aka Boolean variables) to represent propositions, i.e., possible facts that are either true or false. 1 Background and motivation 2 The syntax and semantics of the formalism 3 Main reasoning problems 4 Reasoning techniques and algorithms 5 Computational complexity and implementation of reasoners p r u w 2/24 Paul is outside It is raining Paul has an umbrella Paul is wet overheat1 valveOpen1 alarm Engine 1 is overheated The safety valve of engine 1 is open The alarm is activated 4/24 Declarative Knowledge Processing 1. Introduction Declarative Knowledge Processing Modeling problems in Propositional Logic Syntax of Propositional Logic Boolean combinations of these symbols allow us to build more complex statements p ∧ r ∧ ¬u, 2. Syntax We start form a countable set V of propositional variables (or simply propositions) p ∧ r ∧ ¬u → w Propositional formulas are defined inductively overheat1 ∧ (¬valveOpen1 ∨ ¬alarm) • Every p ∈ V is a formula We can infer properties of the described domain by reasoning about these statements • > (verum, top) and ⊥ (falsum, bottom) are formulas • If φ1 and φ2 are formulas, then so are Is Paul wet? (¬φ1 ) (φ1 ∧ φ2 ) (φ1 ∨ φ2 ) negation conjunction disjunction Is the system safe? We can use (φ1 → φ2 ) as a shortcut for (¬φ1 ∨ φ2 ) and (φ1 ↔ φ2 ) as a shortcut for (φ1 → φ2 ) ∧ (φ2 → φ1 ) Recall: p r Paul is outside it is raining u w Paul has an umbrella Paul is wet 7/24 5/24 Declarative Knowledge Processing 2. Syntax Declarative Knowledge Processing Outline 3. Semantics Outline 1. Introduction 1. Introduction 2. Syntax 2. Syntax 3. Semantics 3. Semantics 4. Reasoning Problems 4.1 SAT, the satisfiability problem 4.2 Other reasoning problems 4. Reasoning Problems 4.1 SAT, the satisfiability problem 4.2 Other reasoning problems 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and their complexity 5.2 Complexity of Reasoning 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and their complexity 5.2 Complexity of Reasoning 6. SAT in the real world 6. SAT in the real world 6/24 8/24 Declarative Knowledge Processing 3. Semantics Declarative Knowledge Processing Interpretations 3. Semantics Models, Logical Implication We consider two truth values: true and false A interpretation (aka truth assignment) is a mapping I that assigns either true or false to each propositional variable, i.e., An interpretation I is a model of a formula φ if I(φ) = true. In this case we write I |= φ For a set of formulas Γ (aka theory), we say I is a model of Γ if I(φ) = true for every φ ∈ Γ I : V 7→ {true, false}, We say that a formula φ follows from a theory Γ, if every model of Γ is a model of φ. In this case we write and such that I(>) = true and I(⊥) = false. Γ |= φ An interpretation I is inductively extended to all formulas (next slide) Questions: • What can we say about Γ |= φ if φ ∈ Γ? • What is the intuitive meaning of ∅ |= φ? Once we fix an interpretation (i.e., values for the propositional variables), the value of all formulas is unambiguously determined We write |= φ instead of ∅ |= φ, and say that φ is valid (true in all interpretations) 9/24 Declarative Knowledge Processing 3. Semantics Declarative Knowledge Processing Interpretations (ctd.) true = false true I(φ ∧ ψ)= false true I(φ ∨ ψ)= false 4. Reasoning Problems Outline Given an interpretation I, the semantics of formulas is inductively defined as follows: I(¬φ) 11/24 if I(φ) = false, otherwise. 1. Introduction 2. Syntax 3. Semantics if I(φ) = true and I(ψ) = true, otherwise. 4. Reasoning Problems 4.1 SAT, the satisfiability problem 4.2 Other reasoning problems if I(φ) = true or I(ψ) = true, otherwise. Questions: • What is the meaning of the defined connectives → and ↔? • Given a formula φ, does the value of φ in I depend on all the propositional symbols in V? Why? 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and their complexity 5.2 Complexity of Reasoning Exercises: You should be able to determine the semantics (truth value) of any given formula in any given interpretation 6. SAT in the real world 10/24 12/24 Declarative Knowledge Processing 4. Reasoning Problems 4.1 SAT, the satisfiability problem SAT, the satisfiability problem Declarative Knowledge Processing 5. Reasoning in Propositional Logic Outline The most important reasoning problem in Propositional Logic is the satisfiability problem 1. Introduction 2. Syntax Formula satisfiability A formula φ is satisfiable if there exists a model for φ 3. Semantics SAT, the satisfiability problem 4. Reasoning Problems 4.1 SAT, the satisfiability problem 4.2 Other reasoning problems Input: A formula φ Question: Is φ satisfiable? 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and their complexity 5.2 Complexity of Reasoning SAT is a decision problem, i.e., the answer is either yes or no 6. SAT in the real world We call UNSAT the complementary problem, i.e., to decide if φ is not satisfiable 13/24 Declarative Knowledge Processing 4. Reasoning Problems 4.2 Other reasoning problems 15/24 Declarative Knowledge Processing Other Reasoning Problems 5. Reasoning in Propositional Logic Solving different Reasoning Problems We have mentioned different reasoning problems Validity Problem Modelhood Satisfiability Validity Logical Consequence Input: A formula φ Question: Does |= φ hold? Logical Consequence Input: A theory Γ, a formula φ Question: Does Γ |= φ hold? Input I, φ φ φ Γ, φ Question Does I |= φ? Is there some I such that I |= φ? Does I |= φ for every I? Does I |= φ for every model I of Γ? Questions: • How do we solve modelhood? (it’s very easy!) • Why do the other problems seem to be harder? • Do we need an algorithm for each problem? Modelhood (aka satisfaction) Input: An interpretation I, a formula φ Question: Does I |= φ hold? Validity and logical consequence can be reduced to UNSAT. Note: These are all decision problems, but there are other reasoning problems that are not decision problems (finding a model, counting models, etc.) 14/24 Hence, an algorithm for (UN)SAT suffices. 16/24 Declarative Knowledge Processing 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and complexity A non-deterministic algorithm for SAT Declarative Knowledge Processing 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and complexity A deterministic algorithm for SAT Assume we have an algorithm selectProp(φ) that returns a propositional variable occurring in φ. Assume we have an algorithm models(I, φ) that decides modelhood. Let φ be a given propositional formula, and let {p1 , . . . , pn } be the set of all propositional variables in φ. Then SAT(φ) decides the satisfiability of φ: We denote by φ[p/>] (resp. φ[p/⊥]) the result of replacing in φ each instance of the propositional letter p by > (resp. ⊥) and simplifying the resulting formula. Algorithm SAT(φ) Algorithm SAT(φ) 1 guess an assignment I : {p1 , . . . , pn } 7→ {true, false}; 2 return models(I, φ); Soundness is trivial: if SAT(φ) says yes, then φ has a model I. Completeness is also trivial: if there is a model for φ, then there is a way to guess an interpretation I such that models(I, φ) says yes, and hence SAT(φ) says yes. 1 if φ == > then return true; 2 if φ == ⊥ then return false; 3 p := selectProp(φ); 4 return (SAT(φ[p/>]) OR SAT(φ[p/⊥])) ; Exercises: Can you explain why the algorithm is it sound and complete? Why does it terminate? How much time and space does it require? 17/24 Declarative Knowledge Processing 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and complexity A non-deterministic algorithm for SAT - complexity 19/24 Declarative Knowledge Processing 5. Reasoning in Propositional Logic 5.2 Complexity of Reasoning Complexity of SAT From the non-deterministic algorithm we discussed, we can infer: It is not hard to show that models(I, φ) can be run in time polynomial (linear) in the size of φ Theorem. SAT is in NP Storing a guessed interpretation I needs only polynomial (linear) space Proof sketch: there is a non-deterministic algorithm for SAT that runs in polynomial time Is this optimal, or can we solve SAT more efficiently? Hence, SAT(φ) needs only polynomial time Theorem [Cook 70, Levin 71]. SAT is NP-hard However, in practice, we can not really guess the right interpretation! Proof sketch: For any non-deterministic polynomial time Turing machine M and input word w, we can build in polynomial time a formula φM,w such φM,w is satisfiable iff M has an accepting run on w. If n propositional variables occur in φ, then there are 2n possible interpretations that have to be tested! 18/24 20/24 Declarative Knowledge Processing 5. Reasoning in Propositional Logic 5.2 Complexity of Reasoning Declarative Knowledge Processing Complexity of reasoning in propositional logic 6. SAT in the real world SAT Solvers and applications Nowadays there are many SAT solvers available From the two theorems above, it follows that: e.g., MiniSAT, Chaff, HyperSAT, WalkSAT, precosat, LySAT, SATzilla, ManySAT . . . Corollary. SAT is in NP-complete Although they all need exponential time in the worst case (why?), some of them can efficiently handle huge formulas with thousands of propositional variables We can also easily infer that: Many of them work on formulas in clausal form, aka Conjunctive Normal Form (CNF) The validity problem is coNP-complete The logical implication problem is coNP-complete Question: • What can you say about the complexity of the modelhood problem? Many SAT solvers employ optimized versions of the famous Davis-Putnam-Logemann-Loveland algorithm (DPLL) There is an international SAT Competition and a SAT Race every year, see http://www.satcompetition.org/ 21/24 Declarative Knowledge Processing 6. SAT in the real world 23/24 Declarative Knowledge Processing Outline 6. SAT in the real world SAT Solvers and applications (ctd.) SAT solvers can be applied for solving any NP-complete problem 1. Introduction They are employed in a huge range of fields 2. Syntax See Marques-Silva, Practical Applications of Boolean Satisfiability, WODES’08: • • • • • • • • 3. Semantics 4. Reasoning Problems 4.1 SAT, the satisfiability problem 4.2 Other reasoning problems 5. Reasoning in Propositional Logic 5.1 SAT Algorithms and their complexity 5.2 Complexity of Reasoning Noise prediction in integrated circuits Termination analysis in term-rewriting systems Model-checking of finite state systems Design debugging AI planning Package management in software distributions Software model-checking and testing Haplotype inference in bioinformatics SAT solving is an extremely active and large research field, with hundreds of researchers, thousands of publications, own conferences and journals 6. SAT in the real world See, e.g., http://www.satlive.org/, http://www.lri.fr/SAT2011 22/24 24/24
© Copyright 2026 Paperzz