Document not found! Please try again

Logical Foundations for Rule-Based Systems - AGH

19 downloads 0 Views 61KB Size Report
14.3 Verification of Indeterminism: a Prolog Code . . . . . . . . 257. 15 Reduction of Rule-Based Systems. 259. 15.1 Generation of Minimal Forms of Tabular ...
Logical Foundations for Rule-Based Systems Antoni Ligza Krakw 2004

KU 0146 pozycja wydawnictw naukowych Akademii Grniczo-Hutniczej im. Stanisawa Staszica w Krakowie

Wydawnictwa AGH, Krakw 2005 ISBN 83–89388–37–5 Redaktor Naczelny Uczelnianych Wydawnictw Naukowo-Dydaktycznych Jan Sas Z-ca Redaktora Naczelnego Beata Barszczewska-Wojda Komitet Naukowy UWND AGH: Janusz Kowal (przewodniczcy), Tadeusz Banaszewski, Bogdan Choczewski, Zdzisaw Ciciwa, Edward Fra, Ryszard Uberman Recenzent prof. dr hab. in. Tomasz Szmuc

Redakcja Magorzata Koch Redakcja techniczna Beata Barszczewska-Wojda Projekt okadki i stron tytuowych Wojciech J. Steifer

Ukad typograficzny i skad komputerowy systemem TEX Jacek Kmiecik, preTEXt, http://www.pretext.com.pl

Redakcja Uczelnianych Wydawnictw Naukowo-Dydaktycznych AGH al. Mickiewicza 30, 30–059 Krakw tel. (0-12) 617-32-28, tel./fax (0-12) 636-40-38 e-mail: [email protected] http://www.WydawnictwoAGH.pl

Contents Preface

v

Acknowledgment

I

xiii

Logical Foundations of Rule-Based Systems

1 Propositional Logic 1.1 Alphabet of Propositional Calculus . . . . . . . . . . . 1.2 Syntax of Propositional Logic . . . . . . . . . . . . . . 1.3 Semantics of Propositional Logic . . . . . . . . . . . . 1.4 Rules for Transforming Propositional Formulae . . . . 1.5 Applications . . . . . . . . . . . . . . . . . . . . . . . . 1.6 Normal Forms and Special Forms of Formulae . . . . . 1.6.1 Minterms: Simple Conjunctive Formulae . . . . 1.6.2 Maxterms, Clauses and Rules . . . . . . . . . . 1.6.3 Conjunctive Normal Form . . . . . . . . . . . . 1.6.4 Disjunctive Normal Form . . . . . . . . . . . . 1.6.5 Transformation of a Formula into CNF/DNF . 1.6.6 Example . . . . . . . . . . . . . . . . . . . . . . 1.7 Logical Consequence and Deduction . . . . . . . . . . 1.8 Inference Modes: Deduction, Abduction and Induction 1.8.1 Deduction Rules for Propositional Logic . . . . 1.8.2 Resolution Rule . . . . . . . . . . . . . . . . . . 1.8.3 Dual Resolution Rule . . . . . . . . . . . . . . 1.9 Abduction and Induction . . . . . . . . . . . . . . . . 1.9.1 Abduction . . . . . . . . . . . . . . . . . . . . . 1.9.2 Induction . . . . . . . . . . . . . . . . . . . . . 1

7 . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

9 9 10 12 16 17 19 19 21 23 25 27 28 30 31 33 35 37 41 41 43

2

CONTENTS 1.9.3

Deduction, Abduction and Induction — lationship . . . . . . . . . . . . . . . . . 1.10 Generic Tasks of Propositional Logic . . . . . . 1.10.1 Theorem Proving . . . . . . . . . . . . . 1.10.2 Tautology or Completeness Verification 1.10.3 Minimization of Propositional Formulae 2 Predicate Calculus 2.1 Alphabet and Notation . . . . . . . . . . 2.1.1 The Role of Variables . . . . . . 2.1.2 Function and Predicate Symbols 2.2 Terms in First-Order Logic . . . . . . . 2.2.1 Applications of Terms . . . . . . 2.3 Formulae . . . . . . . . . . . . . . . . . 2.4 Special Forms of Formulae . . . . . . . . 2.5 Semantics of First-Order Logic . . . . . 2.5.1 Herbrand Interpretation . . . . .

Mutual Re. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

44 45 45 46 46

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

49 50 50 51 52 53 54 57 59 63

3 Attribute Logic 3.1 Alphabet and Notation . . . . . . . . . . . . 3.1.1 The Role of Variables . . . . . . . . 3.2 Atomic Formulae . . . . . . . . . . . . . . . 3.3 Formulae in Attribute Logic . . . . . . . . . 3.4 Semantics of Attribute Logic . . . . . . . . 3.5 Issues Specific to Attribute-Based Logic . . 3.5.1 Internal Conjunction . . . . . . . . . 3.5.2 Internal Disjunction . . . . . . . . . 3.5.3 Explicit and Implicit Negation . . . 3.6 Inference Rules Specific to Attributive Logic

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

67 68 70 70 72 74 77 77 78 78 79

. . . . . .

83 83 83 86 87 89 90

4 Resolution 4.1 Substitution and Unification . . . 4.1.1 Substitutions . . . . . . . 4.1.2 Unification . . . . . . . . 4.1.3 Algorithm for Unification 4.2 Clausal Form . . . . . . . . . . . 4.3 Resolution Rule . . . . . . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

3

CONTENTS 5 Dual Resolution 5.1 Minterm Form . . . . . . . . . . . . . 5.2 Introduction to Dual Resolution . . . 5.3 Dual Resolution Rule . . . . . . . . . . 5.4 BD-Derivation . . . . . . . . . . . . . 5.5 Properties of BD-Resolution . . . . . . 5.5.1 Soundness of BD-Resolution . . 5.5.2 Completeness of BD-Resolution 5.6 Generalized Dual Resolution Rule . . .

II

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

Principles of Rule-Based Systems

. . . . . . . .

93 93 95 97 99 100 101 103 108

111

6 Basic Structure of Rule-Based Systems 113 6.1 Basic Concepts in Rule-Based Systems . . . . . . . . . . . . . 114 7 Rule-Based Systems in Propositional Logic 7.1 Notation for Propositional Rule-Based Systems . . . . . . . 7.2 Basic Propositional Rules . . . . . . . . . . . . . . . . . . . 7.3 Propositional Rules with Complex Precondition Formulae . 7.4 Activation of Rules . . . . . . . . . . . . . . . . . . . . . . . 7.5 Deducibility and Transitive Closure of Fact Knowledge Base 7.6 Various Forms of Propositional Rule-Based Systems . . . . 7.6.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . 7.6.2 Binary Decision Tables . . . . . . . . . . . . . . . . . 7.6.3 Binary Decision Lists . . . . . . . . . . . . . . . . . 7.6.4 Binary Decision Rules with Control Statements . . . 7.6.5 Binary Decision Trees . . . . . . . . . . . . . . . . . 7.6.6 Binary Decision Diagrams . . . . . . . . . . . . . . . 7.7 Dynamic and Non-Monotonic Systems . . . . . . . . . . . .

121 . 122 . 123 . 124 . 126 . 127 . 131 . 134 . 135 . 139 . 142 . 144 . 150 . 156

8 Rule-Based Systems in Attributive Logic 159 8.1 Attributive Decision Tables . . . . . . . . . . . . . . . . . . . 161 8.1.1 Basic Attributive Decision Tables . . . . . . . . . . . . 161 8.1.2 Information Systems . . . . . . . . . . . . . . . . . . . 162 8.1.3 Attributive Decision Tables with Atomic Values of Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . 165 8.1.4 Example: Opticians Decision Table . . . . . . . . . . . 166 8.2 Extended Attributive Decision Systems . . . . . . . . . . . . 167 8.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

4

CONTENTS 8.4

Attributive Rule-Based Systems . . . . . . 8.4.1 Rule Format . . . . . . . . . . . . 8.4.2 Rule Firing . . . . . . . . . . . . . Extended Tabular Trees . . . . . . . . . . 8.5.1 Cells . . . . . . . . . . . . . . . . . 8.5.2 Rules . . . . . . . . . . . . . . . . 8.5.3 XT — Extended Table . . . . . . . 8.5.4 Connections and Their Properties Example: Thermostat . . . . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

172 172 174 175 176 176 178 179 181

9 Rule-Based Systems in First-Order Logic 9.1 Basic Form of Rules . . . . . . . . . . . . 9.2 FOPC Rule-Base Example: Thermostat . 9.3 Extended Form of FOPC Rules . . . . . . 9.4 Further Extensions in Rule Format . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

189 189 190 192 195

. . . . . .

199 200 200 203 204 206 207

. . . . . . . . . . . .

211 213 216 217 218 220 221 222 222 223 223 224 226

8.5

8.6

10 Inference Control in Rule-Based Systems 10.1 Problem Statement . . . . . . . . . . . . . . . . 10.1.1 Basic Problem Formulation . . . . . . . 10.1.2 Advanced Problem Formulation . . . . . 10.2 Rule Interpretation Algorithm . . . . . . . . . . 10.3 Inference Control at the Rules Level: Advanced 10.3.1 A Simple Linear Strategy . . . . . . . . 11 Logic Programming and Prolog 11.1 Introductory Example . . . . . . . . . . . . 11.2 Prolog Syntax . . . . . . . . . . . . . . . 11.3 Unification in Prolog . . . . . . . . . . . . 11.4 Resolution in Prolog . . . . . . . . . . . . 11.5 Prolog Inference Strategy . . . . . . . . . 11.6 Inference Control and Negation in Prolog 11.6.1 The cut Predicate . . . . . . . . . . 11.6.2 The fail Predicate . . . . . . . . . . 11.6.3 The not Predicate . . . . . . . . . . 11.7 Dynamic Global Memory in Prolog . . . . 11.8 Lists in Prolog . . . . . . . . . . . . . . . 11.9 Rule Interpreters in Prolog . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . Problem . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . .

. . . . . . . . . . . .

. . . . . .

. . . . . . . . . . . .

5

CONTENTS

III

Verification of Rule-Based Systems

231

12 Principles of Verification of Rule-Based Systems 233 12.1 Validation, Verification, Testing and Optimization of RuleBased Systems . . . . . . . . . . . . . . . . . . . . . . . . . . 234 12.2 Verification: from General Requirements to Verifiable Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 12.3 Taxonomies of Verifiable Features . . . . . . . . . . . . . . . . 237 12.3.1 Verification of RBS: a Short Review . . . . . . . . . . 237 12.3.2 Functional Quality Assignment . . . . . . . . . . . . . 239 12.4 A Taxonomy of Verifiable Characteristics . . . . . . . . . . . 240 13 Analysis of Redundancy 13.1 Redundancy of Knowledge Representation . . . . . . . . 13.2 Subsumption . . . . . . . . . . . . . . . . . . . . . . . . 13.2.1 Subsumption in First Order Logic . . . . . . . . 13.2.2 Subsumption in Tabular Systems . . . . . . . . . 13.3 Verification of Subsumption in XTT — a Prolog Code

. . . . .

. . . . .

. . . . .

243 243 246 246 247 248

14 Analysis of Indeterminism and Inconsistency 14.1 Indeterminism and Inconsistency of Rules . . . 14.2 Consistency Analysis . . . . . . . . . . . . . . . 14.2.1 Determinism . . . . . . . . . . . . . . . 14.2.2 Conflict and Inconsistency . . . . . . . . 14.3 Verification of Indeterminism: a Prolog Code

. . . . .

. . . . .

. . . . .

253 253 255 255 256 257

15 Reduction of Rule-Based Systems 15.1 Generation of Minimal Forms of Tabular Rule-Based Systems 15.1.1 Total and Partial Reduction . . . . . . . . . . . . . . . 15.1.2 Specific Partial Reduction . . . . . . . . . . . . . . . . 15.2 Reduction of Tabular Systems — a Prolog Code Example .

259 260 260 262 263

16 Analysis of Completeness 16.1 Completeness of Rules . . . . . . . . . . . . . . . . . . . . 16.2 Verification of Completeness . . . . . . . . . . . . . . . . . 16.2.1 Logical Completeness of Rule-Based Systems . . . 16.2.2 Specific Completeness of Rule-Based Systems . . . 16.2.3 Missing Precondition Identification . . . . . . . . . 16.3 Verification of Completeness in XTT — a Prolog Code .

267 267 269 269 270 273 276

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . . .

. . . . . .

6

IV

CONTENTS

Design of Rule-Based Systems

279

17 An Introduction to Design of Rule-Based Systems 17.1 Problems of Rule-Based Systems Design . . . . . . . . 17.2 Knowledge Engineering . . . . . . . . . . . . . . . . . 17.2.1 Knowledge Acquisition . . . . . . . . . . . . . . 17.2.2 Knowledge Verification . . . . . . . . . . . . . . 17.2.3 Knowledge Management . . . . . . . . . . . . . 17.3 Design of Rule-Based Systems: Abstract Methodology 17.4 Rule-Based Systems Design: Basic Stages . . . . . . . 18 Logical Foundations: the Ψ-Trees Based 18.1 An Intuitive Introductory Example . . . 18.2 The Ψ-Trees for Design Support . . . . 18.2.1 Osiris — a Design Tool . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

281 . 281 . 283 . 284 . 286 . 286 . 286 . 290

Approach 295 . . . . . . . . . . . . 295 . . . . . . . . . . . . 299 . . . . . . . . . . . . 303

19 Design of Tabular Rule-Based Systems: the XTT Approach307 19.1 Principles the XTT Approach . . . . . . . . . . . . . . . . . . 307 19.2 The Principles of Integrated Design Process . . . . . . . . . . 308 19.3 Conceptual Design Phase . . . . . . . . . . . . . . . . . . . . 310 19.4 Logical Design Phase . . . . . . . . . . . . . . . . . . . . . . . 312 19.5 The Analysis and Verification Framework . . . . . . . . . . . 313 19.6 Implementation Phase . . . . . . . . . . . . . . . . . . . . . . 314 19.6.1 Testing the Prototype . . . . . . . . . . . . . . . . . . 314 19.6.2 Debugging the Prototype . . . . . . . . . . . . . . . . 315 19.6.3 Generating Stand-Alone Application . . . . . . . . . . 315 20 Design Example: Thermostat 317 20.1 Thermostat Control System . . . . . . . . . . . . . . . . . . . 318 21 Concluding Remarks

333

V

337

Closing Remarks and Appendices