100% found this document useful (4 votes)
25 views

AI Algorithms Data Structures and Idioms in Prolog Lisp and Java 6th Edition by George Luger, William Stubblefield 0136070477 9780136070474 download

The document is a comprehensive overview of AI algorithms, data structures, and programming idioms in Prolog, Lisp, and Java, authored by George Luger and William Stubblefield. It includes various chapters covering language idioms, programming techniques, and applications in artificial intelligence, alongside exercises for practical understanding. Additionally, it provides links to multiple related textbooks and digital downloads.

Uploaded by

erliskuest6m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
25 views

AI Algorithms Data Structures and Idioms in Prolog Lisp and Java 6th Edition by George Luger, William Stubblefield 0136070477 9780136070474 download

The document is a comprehensive overview of AI algorithms, data structures, and programming idioms in Prolog, Lisp, and Java, authored by George Luger and William Stubblefield. It includes various chapters covering language idioms, programming techniques, and applications in artificial intelligence, alongside exercises for practical understanding. Additionally, it provides links to multiple related textbooks and digital downloads.

Uploaded by

erliskuest6m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

AI Algorithms Data Structures and Idioms in

Prolog Lisp and Java 6th Edition by George


Luger, William Stubblefield 0136070477
9780136070474 install download
https://ebookball.com/product/ai-algorithms-data-structures-and-
idioms-in-prolog-lisp-and-java-6th-edition-by-george-luger-
william-stubblefield-0136070477-9780136070474-17248/

Explore and download more ebooks or textbooks


at ebookball.com
Get Your Digital Files Instantly: PDF, ePub, MOBI and More
Quick Digital Downloads: PDF, ePub, MOBI and Other Formats

Artificial Intelligence Structures and Strategies for Complex Problem


Solving 1st edition by George Luger, William Stubblefield 0805311963
978-0805311969

https://ebookball.com/product/artificial-intelligence-structures-
and-strategies-for-complex-problem-solving-1st-edition-by-george-
luger-william-stubblefield-0805311963-978-0805311969-19466/

Artificial Intelligence Structures and Strategies for Complex Problem


Solving 1st edition by William Luger, George Stubblefield
0805311963Â 978-0805311969

https://ebookball.com/product/artificial-intelligence-structures-
and-strategies-for-complex-problem-solving-1st-edition-by-
william-luger-george-
stubblefield-0805311963-978-0805311969-19456/

Data Structures and Algorithms in Java 1st Edition by Peter Drake ISBN
0131469142 9780131469143

https://ebookball.com/product/data-structures-and-algorithms-in-
java-1st-edition-by-peter-drake-
isbn-0131469142-9780131469143-12422/

Think Data Structures Algorithms and Information Retrieval in Java 1st


Edition by Allen Downey ISBN 9781491972311 1491972319

https://ebookball.com/product/think-data-structures-algorithms-
and-information-retrieval-in-java-1st-edition-by-allen-downey-
isbn-9781491972311-1491972319-15760/
Data Structures and Algorithms with Object Oriented Design Patterns in
Java 1st Edition by Bruno Preiss, PEng ISBN 0471346136 9780471346135

https://ebookball.com/product/data-structures-and-algorithms-
with-object-oriented-design-patterns-in-java-1st-edition-by-
bruno-preiss-peng-isbn-0471346136-9780471346135-19836/

Artificial Intelligence Structures And Strategies for Complex Problem


Solving 5th Edition by George Luger 0321263189 978-0321263186

https://ebookball.com/product/artificial-intelligence-structures-
and-strategies-for-complex-problem-solving-5th-edition-by-george-
luger-0321263189-978-0321263186-19470/

Data Structures and Algorithms in C 1st edition by Adam Drozdek ASIN


B002WLXMBY

https://ebookball.com/product/data-structures-and-algorithms-
in-c-1st-edition-by-adam-drozdek-asin-b002wlxmby-25076/

Artificial Intelligence Structures and Strategies for Complex Problem


Solving 5th edition by George Luger ISBN 0321263189 978-0321263186

https://ebookball.com/product/artificial-intelligence-structures-
and-strategies-for-complex-problem-solving-5th-edition-by-george-
luger-isbn-0321263189-978-0321263186-16442/

Data Structures Algorithms and Applications in C++ 1st edition by Adam


Drozdek ISBN 1133608426 9781133608424

https://ebookball.com/product/data-structures-algorithms-and-
applications-in-c-1st-edition-by-adam-drozdek-
isbn-1133608426-9781133608424-17250/
Luger_all_wcopyright_COsfixed.pd2 2 5/15/2008 6:34:39 PM
AI Algorithms, Data Structures, and
Idioms in Prolog, Lisp, and Java

Luger_all_wcopyright_COsfixed.pd1 1 5/15/2008 6:34:39 PM


Luger_all_wcopyright_COsfixed.pd2 2 5/15/2008 6:34:39 PM
AI Algorithms, Data Structures, and
Idioms in Prolog, Lisp, and Java

George F. Luger
William A. Stubblefield

Luger_all_wcopyright_COsfixed.pd3 3 5/15/2008 6:34:39 PM


Executive Editor Michael Hirsch
Acquisitions Editor Matt Goldstein
Editorial Assistant Sarah Milmore
Managing Editor Jeff Holcomb
Digital Assets Manager Marianne Groth
Senior Media Producer Bethany Tidd
Marketing Manager Erin Davis
Senior Author Support/
Technology Specialist Joe Vetere
Senior Manufacturing Buyer Carol Melville
Text Design, Composition, and Illustrations George F Luger
Cover Design Barbara Atkinson
Cover Image © Tom Barrow

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a
trademark claim, the designations have been printed in initial caps or all caps.

Copyright © 2009 Pearson Education, Inc. All rights reserved. No part of this publication may be
reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic,
mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher.
Printed in the United States of America. For information on obtaining permission for use of material in this
work, please submit a written request to Pearson Education, Inc., Rights and Contracts Department, 501
Boylston Street, Suite 900, Boston, MA 02116, fax (617) 671-3447, or online at
http://www.pearsoned.com/legal/permissions.htm.

ISBN-13: 978-0-13-607047-4
ISBN-10: 0-13-607047-7

1 2 3 4 5 6 7 8 9 10—OPM—12 11 10 09 08

Luger_copyright.pdf 1 5/15/2008 6:02:23 PM


Contents
Preface ix

Part I Language Idioms and the Master Programmer 1


Chapter 1 Idioms, Patterns, and Programming 3
1.1 Introduction: Idioms and Patterns 3
1.2 Selected Examples of Language Idioms 6
1.3 A Brief History of Three Programming Paradigms 11
1.4 A Summary of Our Task 15

Part II Programming in Prolog 17


Chapter 2 Prolog: Representation 19
2.1 Introduction: Logic-Based Representation 19
2.2 Prolog Syntax 20
2.3 Creating, Changing, and Tracing a Prolog Computation 24
2.4 Lists and Recursion in Prolog 25
2.5 Structured Representation and Inheritance Search 28
Exercises 32

Chapter 3 Abstract Data Types and Search 33


3.1 Introduction 33
3.2 Using cut to Control Search in Prolog 36
3.3 Abstract Data Types (ADTs) in Prolog 38
Exercises 42

Chapter 4 Depth- Breadth-, and Best-First Search 43


4.1 Production System Search in Prolog 43
4.2 A Production System Solution of the FWGC Problem 46
4.3 Designing Alternative Search Strategies 52
Exercises 58

Chapter 5 Meta-Linguistic Abstraction, Types, and Meta-Interpreters 59


5.1 Meta-Interpreters, Types, and Unification 59
5.2 Types in Prolog 61
5.3 Unification, Variable Binding, and Evaluation 64
Exercises 68
v

Luger_all_wcopyright_COsfixed.pd5 5 5/15/2008 6:34:39 PM


vi Contents

Chapter 6 Three Meta-Interpreters: Prolog in Prolog, EXSHELL, and a


Planner 59
6.1 An Introduction to Meta-Interpreters: Prolog in Prolog 69
6.2 A Shell for a Rule-Based System 73
6.3 A Prolog Planner 82
Exercises 85

Chapter 7 Machine Learning Algorithms in Prolog 87


7.1 Machine Learning: Version Space Search 87
7.2 Explanation Based Learning in Prolog 100
Exercises 106

Chapter 8 Natural Language Processing in Prolog 107


8.1 Natural Language Understanding 107
8.2 Prolog Based Semantic Representation 108
8.3 A Context-Free Parser in Prolog 111
8.4 Probabilistic Parsers in Prolog 114
8.5 A Context-Sensitive Parser in Prolog 119
8.6 A Recursive Descent Semantic Net Parser 120
Exercises 123

Chapter 9 Dynamic Programming and the Earley Parser 125


9.1 Dynamic Programming Revisited 125
9.2 The Earley Parser 126
9.3 The Earley Parser in Prolog 134
Exercises 139

Chapter 10 Prolog: Final Thoughts 141


10.1 Towards a Procedural Semantics 141
10.2 Prolog and Automated Reasoning 144
10.3 Prolog Idioms, Extensions, and References 145

Part III Programming in Lisp 149


Chapter 11 S-Expressions, the Syntax of Lisp 151
11.1 Introduction to Symbol Expressions 151
11.2 Control of Lisp Evaluation 154
11.3 Programming in Lisp: Creating New Functions 156
11.4 Program Control: Conditionals and Predicates 157
Exercises 160

Luger_all_wcopyright_COsfixed.pd6 6 5/15/2008 6:34:39 PM


Contents vii

Chapter 12 Lists and Recursive Search 161

12.1 Functions, Lists, and Symbolic Computing 161


12.2 Lists as Recursive Structures 163
12.3 Nested Lists, Structure, and car/cdr Recursion 166
Exercises 168

Chapter 13 Variables, Datratypes, and Search 171


13.1 Variables and Datatypes 171
13.2 Search: The Farmer, Wolf, Goat, and Cabbage Problem 177
Exercises 182

Chapter 14 Higher-Order Functions and Flexible Search 185


14.1 Higher-Order Functions and Abstraction 185
14.2 Search Strategies in Lisp 189
Exercises 193

Chapter 15 Unification and Embedded Languages in Lisp 195


15.1 Introduction 195
15.2 Interpreters and Embedded Languages 203
Exercises 205

Chapter 16 Logic programming in Lisp 207


16.1 A Simple Logic Programming Language 207
16.2 Streams and Stream Processing 209
16.3 A Stream-Based logic Programming Interpreter 211
Exercises 217

Chapter 17 Lisp-shell: An Expert System Shell in Lisp 219


17.1 Streams and Delayed Evaluation 219
17.2 An Expert System Shell in Lisp 223
Exercises 232

Chapter 18 Semantic Networks, Inheritance, and CLOS 233


18.1 Semantic nets and Inheritance in Lisp 233
18.2 Object-Oriented Programming Using CLOS 237
18.3 CLOS Example: A Thermostat Simulation 244
Exercises 250

Chapter 19 Machine Learning in Lisp 251


19.1 Learning: The ID3 Algorithm 251
19.2 Implementing ID3 259

Luger_all_wcopyright_COsfixed.pd7 7 5/15/2008 6:34:39 PM


viii Contents

Exercises 266

Chapter 20 Lisp: Final Thoughts 267

Part IV Programming in Java 269


Chapter 21 Java, Representation and Object-Oriented Programming 273
21.1 Introduction to O-O Representation and Design 273
21.2 Object Orientation 274
21.3 Classes and Encapsulation 275
21.4 Polymorphism 276
21.5 Inheritance 277
21.6 Interfaces 280
21.7 Scoping and Access 282
21.8 The Java Standard Library 283
21.9 Conclusions: Design in Java 284
Exercises 285

Chapter 22 Problem Spaces and Search 287


21.1 Abstraction and Generality in Java 287
21.2 Search Algorithms 288
21.3 Abstracting Problem States 292
21.4 Traversing the Solution Space 295
21.5 Putting the Framework to Use 298
Exercises 303

Chapter 23 Java Representation for Predicate Calculus and Unification 305


23.1 Introduction to the Task 305
23.2 A Review of the Predicate Calculus and Unification 307
23.3 Building a Predicate Calculus Problem Solver in Java 310
23.4 Design Discussion 320
23.5 Conclusions: Mapping Logic into Objects 322
Exercises 323

Chapter 24 A Logic-Based Reasoning System 325


24.1 Introduction 325
24.2 Reasoning in Logic as Searching an And/Or Graph 325
24.3 The Design of a Logic-Based Reasoning System 329
24.4 Implementing Complex Logic Expressions 330
24.5 Logic-Based Reasoning as And/Or Graph Search 335
24.6 Testing the Reasoning System 346

Luger_all_wcopyright_COsfixed.pd8 8 5/15/2008 6:34:40 PM


Contents ix

24.7 Design Discussion 348


Exercises 350

Chapter 25 An Expert System Shell 351


25.1 Introduction: Expert Systems 351
25.2 Certainty Factors and the Unification Problem Solver 352
25.3 Adding User Interactions 358
25.4 Design Discussion 360
Exercises 361

Chapter 26 Case Studies: JESS and other Expert System Shells in Java 363
26.1 Introduction 363
26.2 JESS 363
26.3 Other Expert system Shells 364
26.4 Using Open Source Tools 365

Chapter 27 ID3: Learning from Examples 367


27.1 Introduction to Supervised Learning 367
27.2 Representing Knowledge as Decision Trees 367
27.3 A Decision Tree Induction program 370
27.4 ID3: An Information Theoretic Tree Induction Algorithm 385
Exercises 388

Chapter 28 Genetic and Evolutionary Computing 389


28.1 Introduction 389
28.2 The Genetic Algorithm: A First Pass 389
28.3 A GA Java Implementation in Java 393
28.4 Conclusion: Complex Problem Solving and Adaptation 401
Exercises 401

Chapter 29 Case Studies: Java Machine Learning Software Available on the


Web 403
29.1 Java Machine Learning Software 403

Chapter 30 The Earley Parser: Dynamic Programming in Java 405


30.1 Chart Parsing 405
30.2 The Earley Parser: Components 406
30.3 The Earley Parser: Java Code 408
30.4 The Completed Parser 414
30.5 Generating Parse Trees from Charts and Grammar Rules 419
Exercises 422

Luger_all_wcopyright_COsfixed.pd9 9 5/15/2008 6:34:40 PM


x Contents

Chapter 31 Case Studies: Java Natural Language Tools on the Web 423
31.1 Java Natural Language Processing Software 423
31.2 LingPipe from the University of Pennsylvania 423
31.3 The Stanford Natural Language Processing Group Software 425
31.4 Sun’s Speech API 426

Part V Model Building and the Master Programmer 429

Chapter 32 Conclusion: The Master Programmer 431


32.1 Paradigm-Based Abstractions and Idioms 431
32.2 Programming as a Tool for Exploring Problem Domains 433
32.3 Programming as a Social Activity 434
32.4 Final Thoughts 437

Bibliography 439

Index 443

Luger_all_wcopyright_COsfixed.pd10 10 5/15/2008 6:34:40 PM


Preface
What we have to learn to do
We learn by doing…

- Aristotle, Ethics

Why Another Writing a book about designing and implementing representations and
Programming search algorithms in Prolog, Lisp, and Java presents the authors with a
Language number of exciting opportunities.
Book?
The first opportunity is the chance to compare three languages that give
very different expression to the many ideas that have shaped the evolution
of programming languages as a whole. These core ideas, which also
support modern AI technology, include functional programming, list
processing, predicate logic, declarative representation, dynamic binding,
meta-linguistic abstraction, strong-typing, meta-circular definition, and
object-oriented design and programming. Lisp and Prolog are, of course,
widely recognized for their contributions to the evolution, theory, and
practice of programming language design. Java, the youngest of this trio, is
both an example of how the ideas pioneered in these earlier languages
have shaped modern applicative programming, as well as a powerful tool
for delivering AI applications on personal computers, local networks, and
the world wide web.
The second opportunity this book affords is a chance to look at Artificial
Intelligence from the point of view of the craft of programming. Although
we sometimes are tempted to think of AI as a theoretical position on the
nature of intelligent activity, the complexity of the problems AI addresses
has made it a primary driver of progress in programming languages,
development environments, and software engineering methods. Both Lisp
and Prolog originated expressly as tools to address the demands of
symbolic computing. Java draws on object-orientation and other ideas that
can trace their roots back to AI programming. What is more important, AI
has done much to shape our thinking about program organization, data
structures, knowledge representation, and other elements of the software
craft. Anyone who understands how to give a simple, elegant formulation
to unification-based pattern matching, logical inference, machine learning
theories, and the other algorithms discussed in this book has taken a large
step toward becoming a master programmer.
The book’s third, and in a sense, unifying focus lies at the intersection of
these points of view: how does a programming language’s formal structure
interact with the demands of the art and practice of programming to

xi

Luger_all_wcopyright_COsfixed.pd11 11 5/15/2008 6:34:40 PM


xii Preface

create the idioms that define its accepted use. By idiom, we mean a set of
conventionally accepted patterns for using the language in practice.
Although not the only way of using a language, an idiom defines patterns
of use that have proven effective, and constitute a common understanding
among programmers of how to use the language. Programming language
idioms do much to both enable, as well as support, ongoing
communication and collaboration between programmers.
These, then, are the three points of view that shape our discussion of AI
programming. It is our hope that they will help to make this book more
than a practical guide to advanced programming techniques (although it is
certainly that). We hope that they will communicate the intellectual depth
and pleasure that we have found in mastering a programming language
and using it to create elegant and powerful computer programs.
The Design of There are five sections of this book. The first, made up of a single chapter,
this Book lays the conceptual groundwork for the sections that follow. This first
chapter provides a general introduction to programming languages and
style, and asks questions such as “What is a master programmer?” What is a
programming language idiom?,” and “How are identical design patterns
implemented in different languages?” Next, we introduce a number of
design patterns specific to supporting data structures and search strategies
for complex problem solving. These patterns are discussed in a “language
neutral” context, with pointers to the specifics of the individual
programming paradigms presented in the subsequent sections of our
book. The first chapter ends with a short historical overview of the
evolution of the logic-based, functional, and object-oriented approaches to
computer programming languages.
Part II of this book presents Prolog. For readers that know the rudiments
of first-order predicate logic, the chapters of Part II can be seen as a
tutorial introduction to Prolog, the language for programming in logic.
For readers lacking any knowledge of the propositional and predicate
calculi we recommend reviewing an introductory textbook on logic.
Alternatively, Luger (2005, Chapter 2) presents a full introduction to both
the propositional and predicate logics. The Luger introduction includes a
discussion, as well as a pseudo code implementation, of unification, the
pattern-matching algorithm at the heart of the Prolog engine.
The design patterns that make up Part II begin with the “flat” logic-based
representation for facts, rules, and goals that one might expect in any
relational data base formalism. We next show how recursion, supported by
unification-based pattern matching, provides a natural design pattern for
tree and graph search algorithms. We then build a series of abstract data
types, including sets, stacks, queues, and priority queues that support
patterns for search. These are, of course, abstract structures, crafted for
the specifics of the logic-programming environment that can search across
state spaces of arbitrary content and complexity. We then build and
demonstrate the “production system” design pattern that supports rule
based programming, planning, and a large number of other AI
technologies. Next, we present structured representations, including

Luger_all_wcopyright_COsfixed.pd12 12 5/15/2008 6:34:40 PM


Preface xiii

semantic networks and frame systems in Prolog and demonstrate


techniques for implementing single and multiple inheritance
representation and search. Finally, we show how the Prolog design
patterns presented in Part II can support the tasks of machine learning
and natural language understanding.
Lisp and functional programming make up Part III. Again, we present the
material on Lisp in the form of a tutorial introduction. Thus, a
programmer with little or no experience in Lisp is gradually introduced to
the critical data structures and search algorithms of Lisp that support
symbolic computing. We begin with the (recursive) definition of symbol-
expressions, the basic components of the Lisp language. Next we present
the “assembly instructions” for symbol expressions, including car, cdr, and
cons. We then assemble new patterns for Lisp with cond and defun.
Finally, we demonstrate the creation and/or evaluation of symbol
expressions with quote and eval. Of course, the ongoing discussion of
variables, binding, scope, and closures is critical to building more complex
design patterns in Lisp.
Once the preliminary tools and techniques for Lisp are presented, we
describe and construct many of the design patterns seen earlier in the
Prolog section. These include patterns supporting breadth-first, depth-
first, and best-first search as well as meta-interpreters for rule-based
systems and planning. We build and demonstrate a recursion-based
unification algorithm that supports a logic interpreter in Lisp as well as a
stream processor with delayed evaluation for handling potentially infinite
structures. We next present data structures for building semantic networks
and object systems. We then present the Common Lisp Object system
(CLOS) libraries for building object and inheritance based design patterns.
We close Part III by building design patterns that support decision-tree
based machine learning.
Java and its idioms are presented in Part IV. Because of the complexities
of the Java language, Part IV is not presented as a tutorial introduction to
the language itself. It is expected that the reader has completed at least an
introductory course in Java programming, or at the very least, has seen
object-oriented programming in another applicative language such as
C++, C#, or Objective C. But once we can assume a basic understanding
of Java tools, we do provide a tutorial introduction to many of the design
patterns of the language.
The first chapter of Part IV, after a brief overview of the origins of Java,
goes through many of the features of an object-oriented language that will
support the creation of design patterns in that environment. These
features include the fundamental data structuring philosophy of
encapsulation, polymorphism, and inheritance. Based on these concepts
we briefly address the analysis, iterative design, programming and test
phases for engineering programs. After the introductory chapter we begin
pattern building in Java, first considering the representation issue and how
to represent predicate calculus structures in Java. This leads to building

Luger_all_wcopyright_COsfixed.pd13 13 5/15/2008 6:34:41 PM


xiv Preface

patterns that support breadth-first, depth-first, and best-first search. Based


on patterns for search, we build a production system, a pattern that
supports the rule-based expert system. Our further design patterns
support the application areas of natural language processing and machine
learning. An important strength that Java offers, again because of its
object-orientation and modularity is the use of public domain (and other)
libraries available on the web. We include in the Java section a number of
web-supported AI algorithms, including tools supporting work in natural
language, genetic and evolutionary programming (a-life), natural language
understanding, and machine learning (WEKA).
The final component of the book, Part V, brings together many of the
design patterns introduced in the earlier sections. It also allows the authors
to reinforce many of the common themes that are, of necessity,
distributed across the various components of the presentation, We
conclude with general comments supporting the craft of programming.
Using this Book This book is designed for three primary purposes. The first is as a
programming language component of a general class in Artificial
Intelligence. From this viewpoint, the authors see as essential that the AI
student build the significant algorithms that support the practice of AI.
This book is designed to present exactly these algorithms. However, in the
normal lecture/lab approach taken to teaching Artificial Intelligence at the
University level, we have often found that it is difficult to cover more than
one language per quarter or semester course. Therefore we expect that the
various parts of this material, those dedicated to either Lisp, Prolog, or
Java, would be used individually to support programming the data
structures and algorithms presented in the AI course itself. In a more
advanced course in AI it would be expected that the class cover more than
one of these programming paradigms.
The second use of this book is for university classes exploring
programming paradigms themselves. Many modern computer science
departments offer a final year course in comparative programming
environments. The three languages covered in our book offer excellent
examples on these paradigms. We also feel that a paradigms course should
not be based on a rapid survey of a large number of languages while doing
a few “finger exercises” in each. Our philosophy for a paradigms course is
to get the student more deeply involved in fewer languages, and these
typically representing the declarative, functional, and object-oriented
approaches to programming. We also feel that the study of idiom and
design patterns in different environments can greatly expand the skill set
of the graduating student. Thus, our philosophy of programming is built
around the language idioms and design patterns presented in Part I and
summarized in Part V. We see these as an exciting opportunity for
students to appreciate the wealth and diversity of modern computing
environments. We feel this book offers exactly this opportunity.
The third intent of this book is to offer the professional programmer the
chance to continue their education through the exploration of multiple

Luger_all_wcopyright_COsfixed.pd14 14 5/15/2008 6:34:41 PM


Preface xv

programming idioms, patterns, and paradigms. For these readers we also


feel the discussion of programming idioms and design patterns presented
throughout our book is important. We are all struggling to achieve the
status of the master programmer.
We have built each chapter in this book to reflect the materials that would
be covered in either one or two classroom lectures, or about an hour’s
effort, if the reader is going through this material by herself. There are a
small number of exercises at the end of most chapters that may be used to
reinforce the main concepts of that chapter. There is also, near the end of
each chapter, a summary statement of the core concepts covered.
Acknowledg- First, we must thank several decades of students and colleagues at the
ments University of New Mexico. These friends not only suggested, helped
design, and tested our algorithms but have also challenged us to make
them better.
Second, we owe particular thanks to colleagues who wrote algorithms and
early drafts of chapters. These include Stan Lee, (PhD student at UNM)
for the Prolog chapter on Earley parsing, Breanna Ammons (MS in CS at
UNM) for the Java version of the Earley parser and along with Robert
Spurlock (CS undergraduate at UNM) the web-based NLP chapter, Paul
DePalma (Professor of CS at Gonzaga University) for the Java Genetic
Algorithms chapter, and Chayan Chakrabarti (MS in CS at UNM) for the
web-based machine learning chapter in Java
Third, there are several professional colleagues that we owe particular
debts. These include David MacQueen, University of Chicago, one of the
creators of SML, Manuel Hermenegildo, The Prince of Asturias Endowed
Chair of Computer Science at UNM and a designer of Ciao Prolog, Paul
De Palma, Professor of Computer Science at Gonzaga University, and
Alejandro Cdebaca, our friend and former student, who helped design
many of the algorithms of the Java chapters.
Fourth, we thank our friends at Pearson Education who have supported
our various creative writing activities over the past two decades. We
especially acknowledge our editors Alan Apt, Karen Mossman, Keith
Mansfield, Owen Knight, Simon Plumtree, and Matt Goldstein, along with
their various associate editors, proof readers, and web support personnel.
We also thank our wives, children, family, and friends; all those that have
made our lives not just survivable, but intellectually stimulating and
enjoyable.
Finally, to our readers; we salute you: the art, science, and practice of
programming is great fun, enjoy it!

GL
BS
July 2008
Albuquerque

Luger_all_wcopyright_COsfixed.pd15 15 5/15/2008 6:34:41 PM


xvi Preface

Luger_all_wcopyright_COsfixed.pd16 16 5/15/2008 6:34:41 PM


PART I: Language Idioms and the
Master Programmer

all good things - trout as well as eternal salvation - come by grace and grace comes by art and art does not
come easy…

- Norman Maclean, (1989) A River Runs Through It

Language and In defining a programming language idiom, an analogy with natural


Idioms
language use might help. If I ask a friend, “Do you know what time it is?”
or equivalently “Do you have a watch?”, I would be surprised if she simply
said “yes” and turned away. These particular forms for asking someone for
the time of day are idiomatic in that they carry a meaning beyond their
literal interpretation. Similarly, a programming language idiom consists of
those patterns of use that good programmers accept as elegant, expressive
of their design intent, and that best harness the language’s power. Good
idiomatic style tends to be specific to a given language or language
paradigm: the way experienced programmers organize a Prolog program
would not constitute accepted Java style.
Language idioms serve two roles. The first is to enhance communication
between programmers. As experienced programmers know, we do not
simply write code for a compiler; we also write it for each other. Writing in
a standard idiom makes it easier for other people to understand our intent,
and to maintain and/or extend our code. Second, a language’s idiom helps
us to make sure we fully use the power the language designers have
afforded us. People design a language with certain programming styles in
mind. In the case of Java, that style was object-oriented programming, and
getting full benefit of such Java features as inheritance, scoping, automatic
garbage collection, exception handling, type checking, packages, interfaces,
and so forth requires writing in an object-oriented idiom. A primary goal of
this book is to explore and give examples of good idioms in three diverse
language paradigms: the declarative (logic-based), functional, and object-
oriented.
The Master The goal of this book is to develop the idea and describe the practice of
Programmer
the master programmer. This phrase carries a decidedly working class
connotation, suggesting the kind of knowledge and effort that comes
through long practice and the transmission of tools and skills from master
to student through the musty rituals of apprenticeship. It certainly suggests
something beyond the immaculate formalization that we generally associate
with scientific disciplines. Indeed, most computer science curricula

Luger_all_wcopyright_COsfixed.pd17 17 5/15/2008 6:34:41 PM


2 Part I Introduction

downplay this craft of programming, favoring discussions of computability


and complexity, algorithms, data structures, and the software engineer’s
formalist longings. In reality, the idea of programming as a craft that
demands skill and dedication is widely accepted in practical circles. Few
major successful programming projects have existed that did not owe
significant components of that success to the craftsmanship of such
individuals.
But, what then, do master programmers know?
The foundation of a master programmer’s knowledge is a strong
understanding of the core domains of computer science. Although working
programmers may not spend much (or any) time developing and
publishing theorems, they almost always have a deep, intuitive grasp of
algorithms, data structures, logic, complexity, and other aspects of the
theory of formal systems. We could compare this to a master welder’s
understanding of metallurgy: she may not have a theoretician’s grasp of
metallic crystalline structure, but her welds do not crack. This book
presumes a strong grounding in these computer science disciplines.
Master programmers also tend to be language fanatics, exhibiting a fluency
in several programming languages, and an active interest in anything new
and unusual. We hope that our discussion of three major languages will
appeal to the craftsman’s fascination with their various tools and
techniques. We also hope that, by contrasting these three major languages
in a sort of “comparative language” discussion, we will help programmers
refine their understanding of what a language can provide, and the needs
that continue to drive the evolution of programming languages.

Luger_all_wcopyright_COsfixed.pd18 18 5/15/2008 6:34:42 PM


1 Idioms, Patterns, and Programming

Chapter This chapter introduces the ideas that we use to organize our thinking about
Objectives languages and how they shape the design and implementation of programs.
These are the ideas of language, idiom, and design pattern.

Chapter 1.1 Introduction


Contents 1.2 Selected Examples of AI Language Idioms
1.3 A Brief History of Three Programming Paradigms
1.4 A Summary of our Task

1.1 Introduction
Idioms and As with any craft, programming contains an undeniable element of
Patterns
experience. We achieve mastery through long practice in solving the
problems that inevitably arise in trying to apply technology to actual
problem situations. In writing a book that examines the implementation of
major AI algorithms in a trio of languages, we hope to support the reader’s
own experience, much as a book of musical etudes helps a young musician
with their own exploration and development.
As important as computational theory, tools, and experience are to a
programmer’s growth, there is another kind of knowledge that they only
suggest. This knowledge comes in the form of pattern languages and
idioms, and it forms a major focus of this book. The idea of pattern
languages originated in architecture (Alexander et al. 1977) as a way of
formalizing the knowledge an architect brings to the design of buildings
and cities that will both support and enhance the lives of their residents. In
recent years, the idea of pattern languages has swept the literature on
software design (Gamma, et al. 1995; Coplein & Schmidt 1995; Evans
2003), as a way of capturing a master’s knowledge of good, robust program
structure.
A design pattern describes a typical design problem, and outlines an
approach to its solution. A pattern language consists of a collection of
related design patterns. In the book that first proposed the use of pattern
languages in architecture, Christopher Alexander et al. (1977, page x) state
that a pattern
describes a problem which occurs over and over again in our environment, and
then describes the core of the solution to that problem, in such a way that you
can use this solution a million times over, without ever doing it the same way
twice.
Design patterns capture and communicate a form of knowledge that is
essential to creating computer programs that users will embrace, and that

Luger_all_wcopyright_COsfixed.pd19 19 5/15/2008 6:34:42 PM


4 Part I: Language Idioms and the Master Programmer

programmers will find to be elegant, logical, and maintainable. They


address programming and languages, not in terms of Turing completeness,
language paradigms, compiler semantics, or any of the other qualities that
constitute the core of computer science, but rather as tools for practical
problem solving. To a large extent, you can think of this book as
presenting a pattern language of the core problems of AI programming,
and examples – the patterns – of their solution.
Idioms are a form and structure for knowledge that helps us bridge the
differences between patterns as abstract descriptions of a problem and its
solutions and an understanding of how best to implement that solution in a
given programming language. A language idiom is the expression of a
design pattern in a given language. In this sense, design patterns + idioms =
quality programs.
Sample Design Consider, for example, the simple, widely used design pattern that we can
Patterns call map that applies some operator O to every element of a list L. We can
express this pattern in a pseudo code function as follows:
map(operator O, list L)
{
if (L contains no elements) quit;
h  the first element of L.
apply O to h;
map(O, L minus h);
}
This map function produces a stream of results: O applied to each element
of the list L. As our definition of pattern specifies, this describes a solution
to a recurring problem, and also fosters unlimited variations, depending on
the type of the elements that make up the list L, and the nature of the
operator, O.
Now, let us consider a fragment of Lisp code that implements this same
map pattern, where f is the mapped operator (in Lisp a function) and
list is the list:
(defun map (f list)
(cond ((null list) nil)
(t (cons (apply f (car list))
(map f (cdr list))))))
This function map, created by using the built-in Lisp defun function, not
only implements the map pattern, but also illustrates elements of the Lisp
programming idiom. These include the use of the operators car and cdr to
separate the list into its head and tail, the use of the cons operator to place
the results into a new list, and also the use of recursion to move down the
list. Indeed, this idiom of recursively working through a list is so central to
Lisp, that compiler writers are expected to optimize this sort of tail
recursive structure into a more efficient iterative implementation.
Let us now compare the Lisp map to a Java implementation that
demonstrates how idioms vary across languages:

Luger_all_wcopyright_COsfixed.pd20 20 5/15/2008 6:34:42 PM


Chapter 1 Idioms, Patterns, and the Master programmer 5

public Vector map(Vector l)


{
Vector result = new Vector();
Iterator iter = l.iterator();
while(iter.hasNext())
{
result.add(f(iter.next));
}
return result;
}
The most striking difference between the Java version and the Lisp version
is that the Java version is iterative. We could have written our list search in
a recursive form (Java supports recursion, and compilers should optimize it
where possible), but Java also offers us iterators for moving through lists.
Since the authors of Java provide us with list iterators, and we can assume
they are implemented efficiently, it makes sense to use them. The Java
idiom differs from the Lisp idiom accordingly.
Furthermore, the Java version of map creates the new variable, result.
When the iterator completes its task, result will be a vector of
elements, each the result of applying f to each element of the input list
(vector). Finally, result must be explicitly returned to the external
environment. In Lisp, however, the resulting list of mapped elements is the
result of invoking the function map (because it is returned as a direct
result of evaluating the map function).
Finally, we present a Prolog version of map. Of course in Prolog, map will
be a represented as a predicate. This predicate has three arguments, the
first the function, f, which will be applied to every element of the list that
is the second argument of the predicate. The third argument of the
predicate map is the list resulting from applying f to each element of the
second argument. The pattern [X|Y] is the Prolog list representation,
where X is the head of the list (car in Lisp) and Y is the list that is the rest
of the list (cdr in Lisp). The is operator binds the result of f applied to
H to the variable NH. As with Lisp, the map relationship is defined
recursively, although no tail recursive optimization is possible in this case.
Further clarifications of this Prolog specification are presented in Part II.
map(f, [ ], [ ]).
map(f, [H|T], [NH|NT]):-
NH is f(H), map(f, T, NT).
In the three examples above we see a very simple example of a pattern
having different idioms in each language, the eval&assign pattern. This
pattern evaluates some expression and assigns the result to a variable. In
Java, as we saw above, = simply assigns the evaluated expression on its
right-hand-side to the variable on its left. In Lisp this same activity requires
the cons of an apply of f to an element of the list. The resulting
symbol expression is then simply returned as part of the evaluated function
map. In Prolog, using the predicate representation, there are similar

Luger_all_wcopyright_COsfixed.pd21 21 5/15/2008 6:34:43 PM


6 Part I: Language Idioms and the Master Programmer

differences between assignment (based on unification with patterns such as


[H|T] and =) and evaluation (using is or making f be a goal).
Understanding and utilizing these idioms is an essential aspect of mastering
a programming language, in that they represent expected ways the language
will be used. This not only allows programmers more easily to understand,
maintain, and extend each other’s code, but also allows us to remain
consistent with the language designer’s assumptions and implementation
choices.
1.2 Selected Examples of AI Language Idioms
We can think of this book, then, as presenting some of the most important
patterns supporting Artificial Intelligence programming, and demonstrating
their implementation in the appropriate idioms of three major languages.
Although most of these patterns were introduced in this book’s companion
volume, Artificial Intelligence: Structures and Strategies for Complex Problem Solving
(Luger 2009), it is worthwhile to summarize a subset of them briefly in this
introduction.
Symbolic Artificial Intelligence rests on two basic ideas: first, representation or the use
Computing:
of symbol structures to represent problem solving knowledge (state), and
The Issue of second, search, the systematic consideration of sequences of operations on
Representation
these knowledge structures to solve complex problems. Symbolic
computing embraces a family of patterns for representing state and then
manipulating these (symbol) structures, as opposed to only performing
arithmetic calculations on states. Symbolic computing methods are the
foundation of artificial intelligence: in a sense, everything in this book rests
upon them. The recursive list-handling algorithm described above is a
fundamental symbolic computing pattern, as are the basic patterns for tree
and graph manipulation. Lisp was developed expressly as a language for
symbolic computing, and its s-expression representation (see Chapter 11)
has proved general, powerful and long-lived.
As we develop the examples of this book, pay close attention to how these
simple patterns of list, tree, and graph manipulation combine to form the
more complex, problem specific patterns described below.
Search Search in AI is also fundamental and complementary to representation (as
is emphasized throughout our book. Prolog, in fact, incorporates a form of
search directly into its language semantics. In addition to forming a
foundation of AI, search introduces many of its thorniest problems. In
most interesting problems, search spaces tend to be intractable, and much
of AI theory examines the use of heuristics to control this complexity. As
has been pointed out from the very beginnings of AI (Feigenbaum and
Feldman 1963, Newell and Simon 1976) support of intelligent search
places the greatest demands on AI programming.
Search related design patterns and problems we will examine in this book
include implementations of the basic search algorithms (breadth-first,
depth-first, and best-first), management of search history, and the recovery
of solution paths with the use of those histories.
A particularly interesting search related problem is in the representation

Luger_all_wcopyright_COsfixed.pd22 22 5/15/2008 6:34:43 PM


Chapter 1 Idioms, Patterns, and the Master programmer 7

and generation of problem states. Conceptually, AI search algorithms are


general: they can apply to any search space. Consequently, we will define
general, reusable search “frameworks” that can be applied to a range of
problem representations and operations for generating new states. How
the different programming paradigms address this issue is illuminating in
terms of their language-based idioms.
Lisp makes no syntactic distinction between functions and data structures:
both can be represented as symbol expressions (see s-expression, Chapter
11), and both can be handled identically as Lisp objects. In addition, Lisp
does not enforce strong typing on s-expressions. These two properties of
the language allow us to define a general search algorithm that takes as
parameters the starting problem state, and a list of Lisp functions, often
using the map design pattern described earlier, for producing child states.
Prolog includes a list representation that is very similar to lists in Lisp, but
differs in having built-in search and pattern matching in a language
supporting direct representation of predicate calculus rules. Implementing
a generalized search framework in Prolog builds on this language’s unique
idioms. We define the operators for generating states as rules, using pattern
matching to determine when these rules apply. Prolog offers explicit meta-
level controls that allow us to direct the pattern matching, and control its
built-in search.
Java presents its own unique idioms for generalizing search. Although Java
provides a “reflection” package that allows us to manipulate its objects,
methods, and their parameters directly, this is not as simple to do as in Lisp
or Prolog. Instead, we will use Java interface definitions to specify the
methods a state object must have at a general level, and define search
algorithms that take as states instances of any class that instantiates the
appropriate interface (see Chapters 22-24).
These three approaches to implementing search are powerful lessons in the
differences in language idioms, and the way they relate to a common set of
design patterns. Although each language implements search in a unique
manner, the basic search algorithms (breadth-, depth-, or best-first) behave
identically in each. Similarly, each search algorithm involves a number of
design patterns, including the management of problem states on a list, the
ordering of the state list to control search, and the application of state-
transition operators to a state to produce its descendants. These design
patterns are clearly present in all algorithms; it is only at the level of
language syntax, semantics, and idioms that these implementations differ.
Pattern Pattern matching is another support technology for AI programming that
Matching
spawns a number of useful design patterns. Approaches to pattern
matching can vary from checking for identical memory locations, to
comparing simple regular-expressions, to full pattern-based unification
across predicate calculus expressions, see Luger (2009, Section 2.3). Once
again, the differences in the way each language implements pattern
matching illustrate critical differences in their semantic structure and
associated idioms.
Prolog provides unification pattern matching directly in its interpreter:
unification and search on Predicate Calculus based data structures are the

Luger_all_wcopyright_COsfixed.pd23 23 5/15/2008 6:34:43 PM


8 Part I: Language Idioms and the Master Programmer

basis of Prolog semantics. Here, the question is not how to implement


pattern matching, but how to use it to control search, the flow of program
execution, and the use of variable bindings to construct problem solutions
as search progresses. In this sense, Prolog gives rise to its own very unique
language idioms.
Lisp, in contrast, requires that we implement unification pattern matching
ourselves. Using its basic symbolic computing capabilities, Lisp makes it
straightforward to match recursively the tree structures that implicitly
define predicate calculus expressions. Here, the main design problem
facing us is the management of variable bindings across the unification
algorithm. Because Lisp is so well suited to this type of implementation,
we can take its implementation of unification as a “reference
implementation” for understanding both Prolog semantics, and the Java
implementation of the same algorithm.
Unlike Lisp, which allows us to use nested s-expressions to define tree
structures, Java is a strongly typed language. Consequently, our Java
implementation will depend upon a number of user-created classes to
define expressions, constants, variables, and variable bindings. As with our
implementation of search, the differences between the Java and Lisp
implementations of pattern matching are interesting examples of the
differences between the two languages, their distinct idioms, and their
differing roles in AI programming.
Structured Although the basic symbolic structures (lists, trees, etc.) supported by all
Types and
Inheritance
these languages are at the foundation of AI programming, a major focus of
(Frames) AI work is on producing representations that reflect the way people think
about problems. This leads to more complex structures that reflect the
organization of taxonomies, similarity relationships, ontologies, and other
cognitive structures. One of the most important of these comes from
frame theory (Minsky 1975; Luger 2009, Section 7.1), and is based on
structured data types (collections of individual attributes combined in a
single object or frame), explicit relationships between objects, and the use of
class inheritance to capture hierarchical organizations of classes and their
attributes.
These representational principles have proved so effective for practical
knowledge representation that they formed the basis of object-oriented
programming: Smalltalk, the CommonLisp Object System libraries
(CLOS), C++, and Java. Just as Prolog bases its organization on predicate
calculus and search, and Lisp builds on (functional) operations on symbolic
structures, so Java builds directly on these ideas of structured
representation and inheritance.
This approach of object-oriented programming underlies a large number of
design patterns and their associated idioms (Gamma, et al. 1995; Coplein &
Schmidt 1995), as merited by the expressiveness of the approach. In this
book, we will often focus on the use of structured representations not
simply for design of program code, but also as a tool for knowledge
representation.
Meta-Linguistic Meta-linguistic abstraction is one of the most powerful ways of organizing
Abstraction programs to solve complex problems. In spite of its imposing title, the

Luger_all_wcopyright_COsfixed.pd24 24 5/15/2008 6:34:43 PM


Chapter 1 Idioms, Patterns, and the Master programmer 9

idea behind meta-linguistic abstraction is straightforward: rather than trying


to write a solution to a hard problem in an existing programming language,
use that language to create another language that is better suited to solving
the problem. We have touched on this idea briefly in this introduction in
our mention of general search frameworks, and will develop it throughout
the book (e.g., Chapters 5, 15, 26).
One example of meta-linguistic abstraction that is central to AI is the idea
of an inference engine: a program that takes a declarative representation of
domain knowledge in the form of rules, frames or some other
representation, and applies that knowledge to problems using general
inference algorithms. The commonest example of an inference engine is
found in a rule-based expert system shell. We will develop such a shell,
EXSHELL in Prolog (Chapter 6), Lisp-shell in Lisp (Chapter 17), and an
equivalent system in Java (Chapter 26), providing similar semantics in all
three language environments. This will be a central focus of the book, and
will provide an in-depth comparison of the programming idioms supported
by each of these languages.
Knowledge- This discussion of AI design patterns and language idioms has proceeded
Level Design
from simple features, such as basic, list-based symbol processing, to more
powerful AI techniques such as frame representations and expert system
shells. In doing so, we are adopting an organization parallel to the
theoretical discussion in Artificial Intelligence: Strategies and Structures for
Complex Problem Solving (Luger 2009). We are building a set of tools for
programming at what Allen Newell (1982) has called the knowledge level.

Figure 1.1 Levels of a Knowledge-Based System, adapted from Newell


(1982).
Allen Newell (1982) has distinguished between the knowledge level and the
symbol level in describing an intelligent system. As may be seen in Figure 1.1
(adapted from Newell, 1982), the symbol level is concerned with the
particular formalisms used to represent problem solving knowledge, for
example the predicate calculus. Above this symbol level is the knowledge
level concerned with the knowledge content of the program and the way in
which that knowledge is used.
The distinction between the symbol and knowledge level is reflected in the

Luger_all_wcopyright_COsfixed.pd25 25 5/15/2008 6:34:53 PM


10 Part I: Language Idioms and the Master Programmer

architectures of expert systems and other knowledge-based programs (see


Chapters 6, 15, and 25). Since the user will understand these programs in
terms of their knowledge content, these programs must preserve two
invariants: first, as just noted, there must be a knowledge-level
characterization, and second, there must be a clear distinction between this
knowledge and its control. We see this second invariant when we utilize the
production system design pattern in Chapters 6, 15, and 25. Knowledge level
concerns include questions such as: What queries will be made of the
system? What objects and/or relations are important in the domain? How
is new knowledge added to the system? Will information change over time?
How will the system need to reason about its knowledge? Does the
problem domain include missing or uncertain information?
The symbol level, just below the knowledge level, defines the knowledge
representation language, whether it be direct use of the predicate calculus
or production rules. At this level decisions are made about the structures
required to represent and organize knowledge. This separation from the
knowledge level allows the programmer to address such issues as
expressiveness, efficiency, and ease of programming, that are not relevant
to the programs higher level intent and behavior.
The implementation of the algorithm and data structure level constitutes a still
lower level of program organization, and defines an additional set of design
considerations. For instance, the behavior of a logic-based or function-
based program should be unaffected by the use of a hash table, heap, or
binary tree for implementing its symbol tables. These are implementation
decisions and invisible at higher levels. In fact, most of the techniques used
to implement representation languages for AI are common computer
science techniques, including binary trees and tables and an important
component of the knowledge-level design hypothesis is that they be hidden
from the programmer.
In thinking of knowledge level programming, we are defining a hierarchy
that uses basic programming language constructs to create more
sophisticated symbol processing languages, and uses these symbolic
languages to capture knowledge of complex problem domains. This is a
natural hierarchy that moves from machine models that reflect an
underlying computer architecture of variables, assignments and processes,
to a symbolic layer that works with more abstract ideas of symbolic
representation and inference. The knowledge level looks beyond symbolic
form to the semantics of problem solving domains and their associated
knowledge relationships.
The importance of this multi-level approach to system design cannot be
overemphasized: it allows a programmer to ignore the complexity hidden
at lower levels and focus on issues appropriate to the current level of
abstraction. It allows the theoretical foundations of artificial intelligence to
be kept free of the nuances of a particular implementation or programming
language. It allows us to modify an implementation, improving its
efficiency or porting it to another machine, without affecting its
specification and behavior at higher levels. But the AI programmer begins
addressing the problem-solving task from the programming language level.

Luger_all_wcopyright_COsfixed.pd26 26 5/15/2008 6:34:53 PM


Chapter 1 Idioms, Patterns, and the Master programmer 11

In fact, we may characterize the programmer’s ability to use design patterns


and their associated idioms as her ability to bridge and link the algorithms
and data structures afforded by different language paradigms with the
symbol level in the process of building expressive knowledge-intensive
programs.
To a large extent, then, our goal in writing this book is to give the reader
the intellectual tools for programming at the knowledge level. Just as an
experienced musician thinks past the problems of articulating individual
notes and chords on their instrument to the challenges of harmonic and
rhythmic structure in a composition, or an architect looks beyond the
layout of floor plans to ways buildings will interact with their occupants
over time, we believe the goal of a programmer’s development is to think
of computer programs in terms of the knowledge they incorporate, and the
way they engage human beings in the patterns of their work,
communication and relationships. Becoming the “master programmer” we
mentioned earlier in this introduction requires the ability to think in terms
of the human activities a program will support, and simultaneously to
understand the many levels of abstraction, algorithms, and data structures
that lie between those activities and the comparatively barren structures of
the “raw” programming language
1.3 A Brief History of Three Programming Paradigms
We conclude this chapter by giving a brief description of the origins of the
three programming languages we present. We also give a cursory
description of the three paradigms these languages represent. These details
are precursors of and an introduction to the material presented in the next
three parts of this book.
Logic Like Lisp, Prolog gains much of its power and elegance from its
Programming
in Prolog
foundations in mathematics. In the case of Prolog, those foundations are
predicate logic and resolution theorem proving. Of the three languages
presented in this book, Prolog may well seem unusual to most
programmers in that it is a declarative, rather than procedural, language. A
Prolog program is simply a statement, in first-order predicate calculus, of
the logical conditions a solution to a problem must satisfy. The declarative
semantics do not tell the computer what to do, only the conditions a
solution must satisfy. Execution of a Prolog program relies on search to
find a set of variable bindings that satisfy the conditions stated in the
particular goals required by the program. This declarative semantics makes
Prolog extremely powerful for a large class of problems that are of
particular interest to AI. These include constraint satisfaction problems,
natural language parsing, and many search problems, as will be
demonstrated in Part II.
A logic program is a set of specifications in formal logic; Prolog uses the
first-order predicate calculus. Indeed, the name itself comes from
programming in logic. An interpreter executes the program by
systematically making inferences from logic specifications. The idea of
using the representational power of the first-order predicate calculus to
express specifications for problem solving is one of the central

Luger_all_wcopyright_COsfixed.pd27 27 5/15/2008 6:34:53 PM


12 Part I: Language Idioms and the Master Programmer

contributions Prolog has made to computer science in general and to


artificial intelligence in particular. The benefits of using first-order
predicate calculus for a programming language include a clean and elegant
syntax and a well-defined semantics.
The implementation of Prolog has its roots in research on theorem proving
by J.A. Robinson (Robinson 1965), especially the creation of algorithms for
resolution refutation systems. Robinson designed a proof procedure called
resolution, which is the primary method for computing with Prolog. For a
more complete description of resolution refutation systems and of Prolog
as Horn clause refutation, see Luger (2009, Chapter 14).
Because of these features, Prolog has proved to be a useful vehicle for
investigating such experimental programming issues as automatic code
generation, program verification, and design of high-level specification
languages. As noted above, Prolog and other logic-based languages support
a declarative programming style—that is, constructing a program in terms
of high-level descriptions of a problem’s constraints—rather than a
procedural programming style—writing programs as a sequence of
instructions for performing an algorithm. This mode of programming
essentially tells the computer “what is true” and “what needs to be proven
(the goals)” rather than “how to do it.” This allows programmers to focus
on problem solving as creating sets of specifications for a domain rather
than the details of writing low-level algorithmic instructions for “what to
do next.”
The first Prolog program was written in Marseille, France, in the early
1970s as part of a project in natural language understanding (Colmerauer,
Kanoui et al. 1973, Roussel 1975, Kowalski 1979). The theoretical
background for the language is discussed in the work of Kowalski, Hayes,
and others (Hayes 1977, Kowalski 1979, Kowalski 1979, Lloyd 1984). The
major development of the Prolog language was carried out from 1975 to
1979 at the Department of Artificial Intelligence of the University of
Edinburgh. The people at Edinburgh responsible for the first “road
worthy” implementation of Prolog were David H.D. Warren and Fernando
Pereira. They produced the first Prolog interpreter robust enough for
delivery to the general computing community. This product was built using
the “C” language on the DEC-system 10 and could operate in both
interpretive and compiled modes (Warren, Pereira, et al. 1979).
Further descriptions of this early code and comparisons of Prolog with
Lisp may be found in Warren et al. (Warren, Pereira, et al. 1977). This
“Warren and Pereira” Prolog became the early standard. The book
Programming in Prolog (Clocksin and Mellish 1984, now in its fifth edition)
was created by two other researchers at the Department of Artificial
Intelligence, Bill Clocksin and Chris Mellish. This book quickly became the
chief vehicle for delivering Prolog to the computing community. We use
this standard, which has come to be known as Edinburgh Prolog. In fact,
all the Prolog code in this book may be run on the public domain
interpreter SWI-Prolog (to find, Google on swi-prolog).
Functional Lisp was arguably the first programming language to ground its semantics
Programming
in Lisp
in mathematical theory: the theory of partial recursive functions (McCarthy

Luger_all_wcopyright_COsfixed.pd28 28 5/15/2008 6:34:54 PM


Chapter 1 Idioms, Patterns, and the Master programmer 13

1960, Church 1941). In contrast to most of its contemporaries, which


essentially presented the architecture of the underlying computer in a
higher-level form, this mathematical grounding has given Lisp unusual
power, durability and influence. Ideas such as list-based data structures,
functional programming, and dynamic binding, which are now accepted
features of mainstream programming languages can trace their origins to
earlier work in Lisp. Meta-circular definition, in which compilers and
interpreters for a language are written in a core version of the language
itself, was the basis of the first, and subsequent Lisp implementations. This
approach, still revolutionary after more than fifty years, replaces
cumbersome language specifications with an elegant, formal, public,
testable meta-language kernel that supports the continued growth and
refinement of the language.
Lisp was first proposed by John McCarthy in the late 1950s. The language
was originally intended as an alternative model of computation based on
the theory of recursive functions. In an early paper, McCarthy (McCarthy
1960) outlined his goals: to create a language for symbolic rather than
numeric computation, to implement a model of computation based on the
theory of recursive functions (Church 1941), to provide a clear definition
of the language’s syntax and semantics, and to demonstrate formally the
completeness of this computational model. Although Lisp is one of the
oldest computing languages still in active use (along with FORTRAN and
COBOL), the careful thought given to its original design and the
extensions made to the language through its history have kept it in the
vanguard of programming languages. In fact, this programming model has
proved so effective that a number of other languages have been based on
functional programming, including SCHEME, SML-NJ, FP, and OCAML.
In fact, several of these newer languages, e.g., SCHEME and SML-NJ,
have been designed specifically to reclaim the semantic clarity of the earlier
versions of Lisp.
The list is the basis of both programs and data structures in Lisp: Lisp is an
acronym for list processing. Lisp provides a powerful set of list-handling
functions implemented internally as linked pointer structures. Lisp gives
programmers the full power and generality of linked data structures while
freeing them, with real-time garbage collection, from the responsibility for
explicitly managing pointers and pointer operations.
Originally, Lisp was a compact language, consisting of functions for
constructing and accessing lists (car, cdr, cons), defining new functions
(defun), detecting equality (eq), and evaluating expressions (quote,
eval). The only means for building program control were recursion and a
single conditional. More complicated functions, when needed, were
defined in terms of these primitives. Through time, the best of these new
functions became part of the language itself. This process of extending the
language by adding new functions led to the development of numerous
dialects of Lisp, often including hundreds of specialized functions for data
structuring, program control, real and integer arithmetic, input/output
(I/O), editing Lisp functions, and tracing program execution. These
dialects are the vehicle by which Lisp has evolved from a simple and
elegant theoretical model of computing into a rich, powerful, and practical

Luger_all_wcopyright_COsfixed.pd29 29 5/15/2008 6:34:54 PM


14 Part I: Language Idioms and the Master Programmer

environment for building large software systems. Because of the


proliferation of early Lisp dialects, the Defense Advanced Research
Projects Agency in 1983 proposed a standard dialect for the language,
known as Common Lisp.
Although Common Lisp has emerged as the lingua franca of Lisp dialects,
a number of simpler dialects continue to be widely used. One of the most
important of these is SCHEME, an elegant rethinking of the language that
has been used both for AI development and for teaching the fundamental
concepts of computer science. The dialect we use throughout the
remainder of our book is Common Lisp. All our code may be run on a
current public domain interpreter built by Carnegie Mellon University,
called CMUCL (Google CMUCL).
Object- Java is the third language considered in this book. Although it does not
Oriented
Programming
have Lisp or Prolog’s long historical association with Artificial Intelligence,
in Java it has become extremely important as a tool for delivering practical AI
applications. There are two primary reasons for this. The first is Java’s
elegant, dynamic implementation of object-oriented programming, a
programming paradigm with its roots in AI, that has proven its power for
use building AI programs through Smalltalk, Flavors, the Common Lisp
Object System (CLOS), and other object-oriented systems. The second
reason for Java’s importance to AI is that it has emerged as a primary
language for delivering tools and content over the world-wide-web. Java’s
ease of programming and the large amounts of reusable code available to
programmers greatly simplify the coding of complex programs involving
AI techniques. We demonstrate this in the final chapters of Part IV.
Object-oriented programming is based on the idea that programs can be
best modularized in terms of objects: encapsulated structures of data and
functionality that can be referenced and manipulated as a unit. The power
of this programming model is enhanced by inheritance, or the ability to
define sub-classes of more general objects that inherit and modify their
functionality, and the subtle control object-oriented languages provide over
the scoping of variables and functions alike.
The first language to build object-oriented representations was created in
Norway in the 1960s. Simula-67 was, appropriately, a simulation language.
Simulation is a natural application of object-oriented programming that
language objects are used to represent objects in the domain being
simulated. Indeed, this ability to easily define isomorphisms between the
representations in an object-oriented program and a simulation domain has
carried over into modern object-oriented programming style, where
programmers are encouraged to model domain objects and their
interactions directly in their code.
Perhaps the most elegant formulation of the object-oriented model is in
the Smalltalk programming language, built at Xerox PARC in the early
1970s. Smalltalk not only presented a very pure form of object-oriented
programming, but also used it as a tool for graphics programming. Many of
the ideas now central to graphics interfaces, such as manipulable screen
objects, event driven interaction, and so on, found their early
implementation in the Smalltalk language. Other, later implementations of

Luger_all_wcopyright_COsfixed.pd30 30 5/15/2008 6:34:54 PM


Chapter 1 Idioms, Patterns, and the Master programmer 15

object-programming include C++, Objective C, C#, and the Common


Lisp Object System. The success of the model has made it rare to find a
programming language that does not incorporate at least some object-
oriented ideas.
Our first introduction of object-oriented languages is with the Common
Lisp Object System in Chapter 18 of Part III. However, in Part IV, we
have chosen Java to present the use of object-oriented tools for AI
programming. Java offers an elegant implementation of object-orientation
that implements single inheritance, dynamic binding, interface definitions,
packages, and other object concepts in a language syntax that most
programmers will find natural. Java is also widely supported and
documented.
The primary reason, however, for including Java in this book is its great
success as a practical programming language for a large number and variety
of applications, most notably those on the world-wide-web. One of the
great benefits of object-oriented programming languages is that the ability
to define objects combining data and related methods in a single structure
encourages the development of reusable software objects.
Although Java is, at its core, a relatively simple language, the efforts of
thousands of programmers have led to large amounts of high-quality, often
open source, Java code. This includes code for networking, graphics,
processing html and XML, security, and other techniques for programming
on the world-wide-web. We will examine a number of public domain Java
tools for AI, such as expert system rule engines, machine learning
algorithms, and natural language parsers. In addition, the modularity and
control of the object-oriented model supports the development of large
programs. This has led to the embedding of AI techniques in larger and
indeed more ordinary programs. We see Java as an essential language for
delivering AI in practical contexts, and will discuss the Java language in this
context. In this book we refer primarily to public domain interpreters most
of which are easily web accessible.

1.4 A Summary of Our Task


We hope that in reading this introductory chapter, you have come to see
that our goal in writing this book is not simply to present basic
implementation strategies for major Artificial Intelligence algorithms.
Rather, our goal is to look at programming languages as tools for the
intellectual activities of design, knowledge modeling, and system
development.
Computer programming has long been the focus both for scientific theory
and engineering practice. These disciplines have given us powerful tools
for the definition and analysis of algorithms and for the practical
management of large and small programming projects. In writing this
book, it has been our overarching goal to provide a third perspective on
programming languages: as tools for the art of designing systems to
support people in their thinking, communication, and work.
It is in this third perspective that the ideas of idioms and patterns become

Luger_all_wcopyright_COsfixed.pd31 31 5/15/2008 6:34:55 PM


16 Part I: Language Idioms and the Master Programmer

important. It is not our goal simply to present examples of artificial


intelligence algorithms that can be reused in a narrow range of situations.
Our goal is to use these algorithms – with all their complexity and
challenges – to help programmers build a repertoire of patterns and idioms
that can serve well across a wide range of practical problem solving
situations. The examples of this book are not ends in themselves; they are
only small steps in the maturation of the master programmer. Our goal is
to see them as starting points for developing programmers’ skills. We hope
you will share our enthusiasm for these remarkable artist’s tools and the
design patterns and idioms they both enable and support.

Luger_all_wcopyright_COsfixed.pd32 32 5/15/2008 6:34:55 PM


PART II: Programming in Prolog

The only way to rectify our reasonings is to make them as tangible as those of the mathematicians, so that
we can find our error at a glance, and when there are disputes among persons we can simply say, “Let us
calculate… to see who is right.”
—Leibniz, The Art of Discovery

As an implementation of logic programming, Prolog makes many


important contributions to AI problem solving. First and foremost, is its
direct and transparent representation and interpretation of predicate
calculus expressions. The predicate calculus has been an important
representational scheme in AI from the beginning, used everywhere from
automated reasoning to robotics research. A second contribution to AI is
the ability to create meta-predicates or predicates that can constrain,
manipulate, and interpret other predicates. This makes Prolog ideal for
creating meta-interpreters or interpreters written in Prolog that can
interpret subsets of Prolog code. We will do this many times in the
following chapters, writing interpreters for expert rule systems, exshell,
interpreters for machine learning using version space search and
explanation based learning models, and deterministic and stochastic natural
language parsers.
Most importantly Prolog has a declarative semantics, a means of directly
expressing problem relationships in AI. Prolog also has built-in unification,
some high- powered techniques for pattern matching and a depth-first left
to right search. For a full description of Prolog representation, unification,
and search as well as Prolog interpreter compared to an automated
theorem prover, we recommend Luger (2009, Section 14.3) or references
mentioned in Chapter 10. We will also address many of the important
issues of Prolog and logic programming for artificial intelligence
applications in the chapters that make up Part II.
In Chapter 2 we present the basic Prolog syntax and several simple
programs. These programs demonstrate the use of the predicate calculus as
a representation language. We show how to monitor the Prolog
environment and demonstrate the use of the cut with Prolog’s built in
depth-first left-to-right search. We also present simple structured
representations including semantic nets and frames and present a simple
recursive algorithm that implements inheritance search.
In Chapter 3 we create abstract data types (ADTs) in Prolog. These ADTs
include stacks, queues, priority queues, and sets. These data types are the basis
for many of the search and control algorithms in the remainder of Part II.

17

Luger_all_wcopyright_COsfixed.pd33 33 5/15/2008 6:34:55 PM


Other documents randomly have
different content
eût cherché quelqu’un sur qui faire tomber sa colère, et posa sa
main sur sa hanche en prenant une pose de capitan:
—Tout beau, mes maîtres! dit-il; si l’un de vous prétend que je suis
ivre, ubriaco, je lui déclare qu’il en a menti par la gorge et que je le
tiens pour un maheustre, un cagou, un truand, un franc-mitou... un
académicien! acheva-t-il en poussant un grand éclat de rire; car il
crut que les mauvais plaisants devaient être écrasés par ce dernier
coup de massue.
—Parbleu! votre ami du moins a le vin gai, dit le notaire à Gerfaut,
tandis que voilà Bergenheim qui, sans avoir bu autant, à beaucoup
près, a l’air d’assister à un enterrement. Je le croyais plus solide que
cela.
La voix de Marillac, qui retentit plus éclatante que jamais, ne
permit pas d’entendre la réponse d’Octave.
—C’est excessivement supercoquentieux. Ils ont tous bu comme
des cochers de fiacre, et ils prétendent que c’est moi qui suis ivre.
Eh bien, je vous mets tous au défi; qui est-ce qui veut raisonner
avec moi? quidquid dixeris argumentabor, doctissime condiscipule.
Voulez-vous discuter art, littérature, politique, médecine, musique,
philosophie, archéologie, jurisprudence, magnétisme...
—Jurisprudence! cria d’une voix empâtée le procureur du roi, qui
sortit à ce mot électrique de la torpeur où l’engourdissait depuis
quelques instants le labeur de la digestion; parlons jurisprudence.
Quelle est votre opinion sur le dernier arrêt de la cour de cassation?
—Voulez-vous, dit Marillac sans s’arrêter à cette interruption, que
je vous improvise un discours sur la peine de mort ou sur la
tempérance? voulez-vous que je raconte Robert-Macaire? voulez-
vous que je vous fasse en cinq minutes le plan d’un drame en cinq
actes? voulez-vous que je vous narre un conte?
—Un conte! dit une voix.
—Un conte! un conte! répétèrent en chœur la plupart des autres
convives.
—Parlez, faites-vous servir; la vue n’en coûte rien, reprit l’artiste
en se frottant les mains d’un air radieux. Voulez-vous un conte
moyen âge? un conte Renaissance? un conte Pompadour? un conte
actuel? un conte fantastique? oriental, drôlatique, physiologique,
intime? Je vous préviens que ce qu’il y a de moins rococo, c’est le
conte intime.
—Va pour le conte intime, dirent les mêmes voix.
—Bien. Maintenant voulez-vous un conte intime chinois, arabe,
espagnol, juif, namaquois.
—Français, cria le procureur du roi.
—Je suis Français, tu es Français, il est Français... Magistrat, tu
t’appelles Chauvin.—Vous aurez donc un conte français.
Marillac appuya son front sur ses mains et ses coudes sur la table
afin de se recueillir et de rassembler ses idées. Après quelques
instants de méditation, il releva la tête et regarda successivement
Bergenheim et Gerfaut avec un singulier sourire.
—Ce sera très original, murmura-t-il à demi-voix, comme s’il eût
répondu à sa propre pensée, ce sera excessivement original. C’est
une idée à conserver pour ma première pièce, une scène dans le
genre de celle des comédiens dans Hamlet. Pourvu que je ne sois
pas tellement vrai qu’il se reconnaisse et se mette à crier comme
Claudius: Lights! Lights! des flambeaux en plein midi!
—Le conte! dit un des convives plus impatient que les autres.
—Présent, répondit l’artiste en s’accoudant de nouveau sur la
table. Vous savez tous, messieurs, que ce qu’il y a de plus difficile à
trouver, c’est le titre. Pour ne pas vous faire attendre, j’en choisirai
un déjà connu. Mon conte s’appellera donc, si vous voulez bien, le
Mari, la Femme et l’Amant. J’aurais même pu emprunter à Paul de
Kock le titre d’un de ses autres romans sans certaines raisons de
convenances. Nous ne sommes pas tous garçons, et un proverbe
sage dit qu’il ne faut jamais parler de corde...
Malgré l’embrouillement extraordinaire de ses idées, l’artiste
s’arrêta sans achever la citation. Un reste de raison lui fit voir qu’il
marchait sur un terrain dangereux et qu’il était sur le point de
commettre une impardonnable indiscrétion. Heureusement le baron,
fort étranger à la conversation, n’avait prêté aucune attention à ses
paroles; mais Gerfaut, justement effrayé du bavardage de son ami,
lui lança un regard où étaient renfermées les plus pressantes, et l’on
eût pu dire les plus menaçantes recommandations de prudence.
Marillac, comprenant vaguement son tort, fut intimidé par ce coup
d’œil comme un écolier qu’interroge un professeur sévère; il se
pencha devant le notaire qui le séparait de Gerfaut et dit à celui-ci
d’une voix qu’il cherchait à rendre confidentielle, mais qui, malgré sa
bonne volonté, fut entendue d’un bout de la table à l’autre:
—Sois tranquille, Octave, je raconterai cela à mots couverts, de
telle sorte qu’il n’y voie que du feu. C’est une scène pour un drame
que j’ai dans la tête.
—Tu te feras mal à force de boire et de parler, répondit Gerfaut de
plus en plus inquiet; tais-toi, ou sors de table avec moi.
—Quand je te dis que je parlerai à mots couverts,
allégoriquement, répondit l’artiste; pour qui me prends-tu? Je te jure
que je vais gazer cela de manière à ce que le diable ne devinerait
pas les masques.
—Le conte! le conte! crièrent plusieurs personnes qu’amusait le
bavardage incohérent de l’artiste.
—Nous y voilà, dit celui-ci en se remettant d’aplomb sur sa chaise,
non sans difficulté, et sans égard pour les nouvelles instances de son
ami. Nous disons: le Mari, la Femme et l’Amant, conte intime
français. La scène se passe dans une petite cour d’Allemagne.—
Heim! fit-il en regardant Gerfaut et en clignant un œil avec malice—
crois-tu que c’est gazé?
—Pas de cour d’Allemagne: vous avez annoncé un conte français,
observa le procureur du roi, disposé à faire de l’opposition et de la
critique contre l’orateur qui l’avait réduit au silence.
—Eh bien, c’est un conte français dont la scène se passe en
Allemagne, répondit avec sang-froid le conteur.—Prétendriez-vous
par hasard m’apprendre mon métier? Sachez que rien n’est élastique
comme une cour d’Allemagne; on y fait entrer tout ce qu’on veut: j’y
mettrais le shah de Perse et l’empereur de la Chine que vous
n’auriez pas le plus petit mot à dire. Si pourtant vous préférez une
cour d’Italie, ce sera absolument la même chose.
Cette proposition conciliante étant restée sans réponse, Marillac
commença en levant les yeux de manière à n’en laisser voir que le
blanc et comme s’il eût cherché ses paroles dans les caissons
ouvragés du plafond.
—Et elle marchait lentement dans l’allée mystérieuse, au bord du
torrent écumant, la princesse Borinska...
—Borinska! c’est donc une Polonaise? interrompit à son tour M. de
Camier.
—Oh! que diable, vieillard, ne me coupez pas la parole, s’écria
l’artiste impatienté.
—C’est juste. Silence donc!
—Vous avez la parole, dirent à la fois plusieurs auditeurs.
—... Et elle était pâle, et elle poussait des soupirs convulsifs en
tordant ses mains molles et tièdes, et une perle blanche roulait sous
les cils noirs de ses yeux bruns, et....
—Pourquoi, je vous prie, commencez-vous toutes vos phrases par
et? demanda le procureur du roi avec le purisme vétilleux d’un
critique inexorable.
—Parce que c’est biblique et naïf, et que le naïf et le biblique sont
tout ce qu’il y a de plus actuel. Ma diction ne vous fait-elle pas l’effet
d’un tableau de Cimabuë ou du Pérugin?
—Ça me fait l’effet de phrases qui ne sont pas construites selon
l’ordre logique et grammatical; il est évident que et, conjonction, ne
peut être placé qu’entre les deux mots auxquels il sert de liaison.
—Prenez un jaune d’œuf pour votre liaison, et laissez-moi en paix,
répondit Marillac avec un superbe dédain. Vous êtes robin, et je suis
artiste; qu’y a-t-il entre vous et moi?—Je continue:—Et lui la vit
passer de loin, pensive et éplorée qu’elle était, la belle jeune femme
pâle; et il dit au prince... Borinski: O prince, une racine de sapins,
contre laquelle je me suis heurté, a déchiré ma jambe, souffrez que
je rentre au palais. Et le prince Borinski lui dit: Voulez-vous que mes
gardes vous portent dans un palanquin? et le sournois d’Octave
répondit...
—Ton histoire n’a pas le sens commun, et tu es ennuyeux à périr,
interrompit brusquement Gerfaut. Messieurs, est-ce que nous
restons à table toute la nuit?
Il se leva, mais personne ne suivit son exemple. Bergenheim qui,
depuis quelques instants, prêtait l’oreille au récit de l’artiste,
regardait alternativement les deux amis d’un œil sombre et
observateur.
—Laissez-le donc parler, dit le jeune magistrat avec un sourire
ironique; j’aime beaucoup le palanquin dans une cour d’Allemagne.
C’est sans doute ce que ces messieurs les romantiques appellent la
couleur locale.—Ah! ah!—O Racine!
Marillac, sans se laisser intimider cette fois par les regards
foudroyants de Gerfaut, reprit avec l’obstination de l’ivresse et d’une
voix de plus en plus bégayante:
—Puisque je te jure de gazer l’allégorie; tu me vexes à la fin. Ne
sommes-nous pas nous autres des artistes, des hommes carrés par
la base? comment veux-tu que des pékins de bourgeois
comprennent!—Car, messeigneurs, sachez que j’ai commis une
erreur en appelant l’amant de mon conte Octave.... Il est clair
comme le jour qu’il s’appelle Boleslas... Boleslas Matalowski, du
duché de Varsovie... blessé à Grochow... Il n’y a pas plus de rapports
entre lui et mon ami Octave qu’entre mon autre ami Bergenheim et
le prince Kolinski... Woginski... comment diable s’appelle-t-il, mon
prince? récompense honnête à qui me dira le nom de mon prince.
—Il y a conscience d’abuser de son état et de le faire parler
davantage, interrompit de nouveau Gerfaut, dont ces paroles
portèrent au dernier degré l’inquiétude et l’effroi.—Je t’en conjure,
tais-toi et sors avec moi, dit-il ensuite en se baissant vers le conteur
entêté, et il le prit par le bras pour le faire lever. Cette tentative ne
fit qu’irriter Marillac au lieu de le persuader; il saisit le bord de la
table et s’y cramponna de toute sa vigueur, en criant comme un
pourceau qu’on égorge:
—Non! cinq cent quatre-vingt-dix-neuf mille fois non! je veux
achever mon conte. Président, maintenez-moi la parole.—Point de
licteurs dans le sanctuaire des lois.—Ah! ah! tu veux m’empêcher de
parler parce que tu sais que je conte mieux que toi, et que
j’impressionne mon auditoire. Jamais tu n’as pu attraper mon chic.
Jaloux! envieux! Je te connais, serpent.
—Je t’en supplie, si tu m’aimes, écoute-moi, répondit Octave, qui,
tout en penchant la tête sur l’épaule de son ami, remarquait avec
anxiété l’attention extrême que le baron apportait à ce débat et
l’expression sinistre de sa figure.
—Non! j’ai dit non! hurla de nouveau l’artiste d’une voix à faire
crouler le plafond, et en appuyant ce mot du plus épouvantable
juron de la langue française. Il se leva, repoussa brusquement
Gerfaut et s’appuya sur la table en riant aux éclats.
—Poètes, dit-il, rassurez-vous et réjouissez-vous; vous aurez votre
conte malgré les serpents de l’envie. Mais versez-moi à boire, car
mon gosier ressemble à une botte d’allumettes. Pas de vin, reprit-il,
à la vue du notaire armé d’une bouteille et prêt à remplir son verre.
Ce diable de vin m’altère au lieu de me rafraîchir; d’ailleurs, je suis
sobre comme saint Jean-Baptiste.
Gerfaut, avec la persévérance désespérée d’un homme qui se voit
au moment d’être noyé, le saisit de nouveau par le bras en le serrant
comme s’il eût voulu incruster ses doigts dans la chair, et en
cherchant à le fasciner de ce regard fixe et dominateur par lequel le
médecin d’une maison de fous maîtrise la fureur de ses malades.
Mais il n’obtint pour réponse, à cette muette et menaçante
supplication, qu’un sourire inintelligent et ces mots lourdement
bégayés:
—Donne-moi donc à boire, Boleslas... Marinski... Graboski... Je
crois que Satan a allumé ses réchauds dans ma poitrine.
Les personnes assises près des deux amis purent entendre un
sifflement de fureur qui sortit des lèvres serrées d’Octave. Tout à
coup il allongea le bras sur la table, saisit parmi plusieurs autres un
petit carafon en cristal et remplit jusqu’au bord le verre que lui
tendait Marillac.
—Merci, dit celui-ci en cherchant à se mettre d’aplomb sur ses
jambes; tu es aimable comme un petit ange. Aussi sois tranquille,
tes amours ne risquent rien. Je vais te gazer tout ça d’un voile
carabiné.—A votre santé, truands!
Il vida le verre aux deux tiers et le remit sur la table; il sourit
ensuite et salua de la main ses auditeurs avec une courtoisie royale;
mais sa bouche resta entr’ouverte comme si les lèvres eussent été
pétrifiées, ses yeux s’agrandirent d’une manière démesurée et leur
regard prit tout à coup une expression hagarde; sa main, qu’il avait
étendue, glissa à son côté; lui-même, un moment après, chancela et
tomba sur sa chaise, frappé en apparence d’une attaque foudroyante
d’apoplexie.
Gerfaut, dont les yeux ne l’avaient pas quitté depuis qu’il avait bu,
et qui avait suivi ces différents symptômes avec une anxiété
inexprimable, le soutint dans ses bras; mais, malgré l’effroi ou
l’intérêt qu’annonçait ce prompt secours, un soupir de soulagement
sortit de sa poitrine lorsqu’il remarqua la muette immobilité de
Marillac et l’impossibilité où il semblait être de reprendre la parole.
—C’est singulier, observa le notaire en l’aidant à éloigner de la
table son voisin hors de combat, ce verre d’eau lui a fait plus d’effet
que quatre ou cinq bouteilles de vin.
—Georges, dit Gerfaut à l’un des domestiques d’une voix agitée,
faites bassiner son lit et venez m’aider à le porter; monsieur de
Bergenheim, il y a sans doute une pharmacie chez vous, si l’on a
besoin de quelque remède.
La plupart des convives s’étaient levés à cet incident inattendu, et
une partie s’empressait autour de Marillac étendu sans mouvement
sur sa chaise. Malgré l’eau dont on lui baignait les tempes, un flacon
de sel qu’on lui faisait respirer, et quoiqu’on l’eût débarrassé de sa
cravate et de tout ce qui pouvait gêner le jeu des poumons, il n’avait
pas repris connaissance. Sa pâleur extrême, qui contrastait avec la
coloration habituelle de son teint, donnait à ses traits une expression
de souffrance et le rendait presque méconnaissable.
Au lieu de joindre ses secours à ceux des autres, Bergenheim
profita de la confusion générale pour se pencher sur la table. Il
plongea un doigt dans le verre de l’artiste où était restée une partie
de l’eau, et le porta ensuite à ses lèvres. Ce geste ne fut aperçu que
par le notaire, personnage curieux et observateur de sa nature. Le
trouvant assez étrange, celui-ci saisit le verre à son tour et avala
quelques gouttes du liquide qu’il contenait.
—Sapristi! dit-il à voix basse à Bergenheim, je ne m’étonne plus
que la rasade l’ait asphyxié sur place. Savez-vous, monsieur le
baron, que si ce M. de Gerfaut avait bu autre chose que de l’eau
pendant le souper, je croirais qu’il est le plus ivre des deux; ou bien
que, s’ils étaient moins amis, je supposerais qu’il a voulu
l’empoisonner pour lui couper le sifflet? Avez-vous remarqué qu’il ne
semblait pas content d’entendre cette histoire?
—Ah! vous aussi? tout le monde le saura donc! s’écria Christian
avec une sorte de fureur.
—Prendre une carafe de kirsch pour de l’eau claire! reprit le
notaire sans faire attention au trouble de son interlocuteur:—diable!
diable! il serait bon d’employer sur-le-champ l’émétique: ce pauvre
garçon a dans l’estomac une dose d’acide prussique capable
d’empoisonner un bœuf.
—Qui est-ce qui a parlé d’empoisonnement et d’acide prussique?
s’écria le procureur du roi en accourant de l’autre extrémité de la
table, d’un pas assez mal assuré, car la tête du jeune magistrat
n’avait guère mieux résisté que celle de l’artiste aux libations
traîtresses, et il commençait à être entièrement hors de son assiette
empesée et judiciaire,—qui est-ce qui a été empoisonné? je suis le
procureur du roi; c’est à moi de diriger l’instruction. A-t-on fait
l’autopsie du cadavre? et d’abord où l’a-t-on trouvé? dans un champ,
dans un bois, dans la rivière?
—Vous en avez menti, il n’y a pas de cadavre dans la rivière,
s’écria Bergenheim d’une voix foudroyante, et il le saisit au collet
avec une sorte d’égarement.
Le magistrat incapable d’opposer la moindre résistance à la main
vigoureuse qui l’étranglait fut secoué par elle à deux reprises comme
l’agneau qu’un loup emporte à sa mâchoire. Tout à coup le baron
s’arrêta et se frappa le front par un geste familier aux personnes qui
sentent leur raison troublée par un paroxysme de passion
indomptable.
—Je suis fou, dit-il avec beaucoup d’émotion.—Monsieur, vous me
voyez désespéré. Nous avons réellement un peu trop bu. Je vous
demande pardon, monsieur.—Je vous quitte un moment... j’ai besoin
d’air.
A ces mots il sortit précipitamment, heurtant sur son passage les
personnes qui emportaient Marillac dans sa chambre. Le procureur
du roi, dont les idées, déjà fort peu claires, s’étaient entièrement
brouillées à la suite de cette atteinte inouïe à sa dignité, se laissa
tomber en défaillance sur une chaise.
—Pauvres buveurs que cela! dit au notaire le gros M. de Camier
qui était resté seul avec lui, car le magistrat, à demi suffoqué
d’indignation et d’ivresse, ne pouvait plus être compté comme
convive.—Pour un doigt de vin, les voilà tous sous la table ou à
moitié fous.
Le notaire secoua la tête à plusieurs reprises d’un air mystérieux.
—Tout cela n’est rien moins que clair, dit-il ensuite; que ce M.
Marillac n’ait pas la tête très solide et raconte quand il est gris des
histoires à dormir debout, que son ami prenne du kirsch pour de
l’eau, je le comprendrais à la rigueur; mais c’est le baron qui
m’étonne. Avez-vous vu comme il secouait notre voisin, qui va tout à
l’heure glisser sur le parquet?
—Ce sera parquet sur parquet.—Chaud pour l’hiver, dit avec un
gros rire M. de Camier.
—Pas mauvais, le calembour. Mais, quant au baron qui pour
s’excuser prétend qu’il est ivre, je n’en crois pas un mot, car il n’a
presque bu que de l’eau. Il y avait des instants ce soir où il avait un
air très singulier. Il y a quelque diablerie là-dessous, monsieur de
Camier; soyez sûr qu’il y a quelque diablerie là-dessous.
—Je suis le procureur du roi, qu’on ne fasse pas sans moi la levée
du cadavre, balbutia d’une voix faible et entrecoupée le magistrat,
qui, après de vains efforts pour maintenir son équilibre, justifia le
calembour dont il avait été l’objet, en quittant sa chaise pour le
parquet de la salle à manger.
XXI

HRISTIAN de Bergenheim était un de ces hommes dont


Napoléon avait en quelque sorte ressuscité la race
graduellement éteinte depuis les siècles féodaux; homme
exclusivement d’action, ne faisant aucune dépense
superflue d’imagination ou de sensibilité, et, dans les
occasions capitales, ne laissant jamais voyager leur âme plus loin
que la portée de leur sabre. L’absence complète de ce sens que la
plupart nomment irritabilité maladive, et quelques-uns poésie, avait
conservé aux ressorts de son caractère leur inflexibilité rude et
native. Son âme manquait d’ailes pour sortir du monde positif; mais
cette indigence avait sa compensation: il était impossible d’appliquer
un bras plus vigoureux que le sien à tout ce qui était résistance
matérielle. Il ne vivait jamais ni hier ni demain, il vivait aujourd’hui.
Insignifiant avant ou après, il déployait au moment voulu une
énergie d’autant plus puissante qu’aucune déperdition intempestive
d’émotion ou de rêverie n’en avait amolli l’action. Les rares idées
contenues dans son cerveau y avaient acquis, par l’effet même de
cette rareté, un développement clair, dur et impénétrable, pareil au
diamant. A la clarté intérieure de ces étoiles fixes, il allait en toute
chose, comme on va au soleil, tête haute, droit devant lui et prêt à
broyer du pied les obstacles qui eussent essayé d’arrêter sa marche
ou de le faire dévier de son chemin.
En ce moment pourtant, malgré cette forte trempe de son
caractère, Bergenheim fut sur le point de fléchir sous le coup dont il
venait d’être frappé. Au lieu de se joindre aux personnes qui
transportaient Marillac, ce fut au jardin qu’il descendit en sortant de
la salle à manger, car le besoin d’air qu’il avait prétexté pour quitter
ses hôtes était une réalité en même temps qu’une excuse. Il se
sentait oppressé jusqu’à l’étouffement par les émotions auxquelles il
servait de proie depuis quelques heures. La dissimulation, dont la
prudence lui faisait une nécessité et son honneur un devoir, en avait
encore aggravé le tourment en le comprimant. Les douleurs de
l’homme ont ce raffinement qui les complète et les rend
incomparables; c’est de toute leur lourdeur qu’elles pèsent sur l’âme,
car l’épanchement leur est interdit. Depuis les gladiateurs de Rome
dressés à mourir avec grâce, il est une étiquette pour la souffrance
qui lui prescrit le silence et le secret. Il faut savoir faire de la chape
de plomb qui vous écrase, un manteau où se cache votre supplice.
Se découvrir un seul instant pour gémir en liberté, pour montrer aux
autres ses stigmates sanglants, cela s’appellerait faiblesse, impudeur,
lâcheté! On permet les cris à l’enfant et les pleurs à la femme; mais
l’homme doit boire son sang comme fit Beaumanoir, afin que nul ne
voie sa plaie et ne rie de lui parce qu’il est blessé.
Christian marcha longtemps d’un pas violent à travers les sentiers
et les taillis du parc. Baignant à l’air froid du soir sa tête nue et
brûlante, il cherchait à calmer ce bouillonnement intérieur, tempête
du sang qui se déchaîne, au milieu de laquelle la raison flotte et se
débat comme un navire près du naufrage. Dans certaines tortures
morales, le même feu qui embrase de ses langues aiguës les fibres
irritables du cœur fait monter au cerveau une vapeur obscure; et
plus la flamme dévore, plus la fumée étouffe; plus les sentiments
sont poignants, plus les idées se troublent.
Bergenheim lutta avec énergie contre ce vertige dans lequel il
sentait tournoyer son esprit; ne pouvant s’arracher tout entier au
supplice, il essaya du moins d’en dégager sa tête. Il employa tout ce
qu’il avait de force à recouvrer son sang-froid, à dominer les périls et
les douleurs dont il était entouré, d’un regard ferme, sinon
indifférent, à reconquérir en un mot l’empire sur lui-même qui lui
était habituel et qui, pendant le souper, l’avait abandonné à plusieurs
reprises. Ses efforts ne furent pas vains. La vigueur de son âme,
terrassée un instant par la violence de ses sensations, finit par
prendre le dessus. Sans faiblesse, sans exagération, sans
emportement, il contempla sa position comme s’il eût été question
d’un autre. Deux faits, l’un accompli, l’autre encore incertain, se
dressaient devant lui dans toute l’horreur d’une vision funèbre: d’un
côté le meurtre, de l’autre l’adultère; le tombeau dans le torrent
pour pendant au lit nuptial outragé. Aucune puissance humaine ne
pouvait remédier au premier de ces malheurs ou en arrêter les
conséquences; il l’adopta donc, comme on tend le cou à la hache sur
l’échafaud, mais il en détourna son esprit, dont il avait besoin pour
un autre supplice. En attendant le jour voisin peut-être de
l’expiation, il demanda une trêve au cadavre pour ne plus s’occuper
que de la femme. Il soumit au principe d’honneur orgueilleux et
inflexible, première religion de son âme, la conduite qu’il devait tenir
à son égard. Jusqu’alors il n’existait contre elle que des
présomptions, graves, il est vrai, si l’on réunissait les révélations de
Lambernier aux étranges indiscrétions de Marillac. Connaître la vérité
tout entière lui parut le premier devoir à remplir envers lui-même
comme envers elle: innocente, il avait un pardon à obtenir;
coupable, un châtiment à infliger.
—C’est un abîme, se dit-il, et je trouverai peut-être au fond autant
de boue que de sang. N’importe, j’y descendrai.
Lorsqu’il rentra au château, sa physionomie avait recouvré son
calme habituel. Le regard le plus observateur eût à peine découvert
une légère altération dans ses traits, la main la plus habile à
apprécier les pulsations de la fièvre n’eût rien deviné en interrogeant
la sienne. Le champ de bataille de la salle à manger était enfin
abandonné. Vainqueurs et vaincus s’étaient retirés dans leurs
chambres. Ce fut à celle de l’artiste qu’il monta d’abord, afin
qu’aucune singularité dans sa conduite n’attirât l’attention; car, en sa
qualité de maître de maison, une visite à l’un de ses hôtes tombé
mort ou à peu près à sa table était en quelque sorte un devoir. Les
soins prodigués à Marillac avaient prévenu le danger qu’auraient pu
faire naître son imprudente ivresse et l’espèce de poison dont il
l’avait couronné. Étendu au milieu de son lit, dans la position où on
l’y avait placé, il dormait du sommeil lourd et pénible qui sert
d’expiation aux excès bachiques. A quelque distance, Gerfaut
écrivait, assis devant une table; il semblait disposé à veiller toute la
nuit et à remplir ainsi, avec le dévouement de l’amitié, les fonctions
de garde-malade.
A la vue du baron, Octave se leva; sa figure, où tant d’émotions
s’étaient peintes pendant le souper, avait repris aussi une rare
expression de réserve. Ce fut avec un égal sang-froid que ces deux
hommes s’abordèrent.
—Dort-il? demanda Christian, en obéissant au geste de son hôte
qui lui recommandait de ne pas faire de bruit.
—Depuis quelques instants, répondit celui-ci; maintenant il est
tout à fait bien, et demain il n’y paraîtra plus. Mais j’espère que cela
vous servira de leçon et contiendra dans de justes bornes votre
hospitalité princière. Votre table est un vrai guet-apens.
—Ne me jetez pas la pierre, je vous prie, repartit le baron avec
une égale apparence de bonne humeur. Si demain notre ami doit
demander raison à quelqu’un, c’est bien à vous qui prenez du
kirschen de 1765 pour de l’eau.
—Je crois réellement que j’étais le plus ivre des deux, interrompit
Octave avec une vivacité qui dissimulait un certain embarras; nous
avons étrangement scandalisé M. de Camier qui a pris la plus
mauvaise opinion des têtes et des estomacs parisiens.
Après avoir regardé un moment l’artiste endormi, Christian
s’approcha de la table où était assis Gerfaut, et jeta un coup d’œil
sur ce qu’écrivait celui-ci.
—Vous travaillez donc toujours? dit-il, tandis que ses yeux
restaient fixés sur le papier.
—En ce moment, je fais le modeste métier de copiste. Ce sont des
vers que Mlle de Corandeuil a eu la gracieuseté de me demander...
—Faites-moi un plaisir. Je vais chez elle tout à l’heure, donnez-moi
ces vers pour que je les lui remette moi-même. Depuis le malheur
arrivé à Constance, elle m’en veut à mort, et je ne serais pas fâché
d’avoir un auxiliaire comme vous pour entrer en conversation.
Gerfaut écrivit les deux ou trois lignes qui lui restaient à transcrire
et remit la feuille à Bergenheim. Celui-ci la regarda quelque temps
avec attention, ensuite il plia soigneusement le papier et le mit dans
sa poche.
—Je vous remercie, monsieur, dit-il, et je vous laisse à vos devoirs
d’amitié.
L’accent extrêmement calme dont ces paroles furent prononcées
et le salut poli qui les accompagna avaient quelque chose de si grave
dans leur honnêteté que Gerfaut resta glacé, pour ainsi dire, quand
le baron fut sorti; mais l’impression qu’il éprouva n’alla pas jusqu’à
l’inquiétude: il n’avait pas compris.
En entrant chez lui, Bergenheim ouvrit une seconde fois le papier
qu’on venait de lui remettre et le compara au billet qu’il tenait de
Lambernier. Les soupçons qu’un examen séparé lui avait fait
concevoir se trouvèrent confirmés par cette confrontation; aucun
doute n’était possible: la lettre et la pièce de vers avaient été écrites
par la même main.
Après quelques instants de réflexion, Christian descendit chez sa
femme.

La molle sérénité de l’appartement de Mme de Bergenheim offrait,


avec les scènes bruyantes dont la salle à manger avait été le théâtre,
le contraste que l’on éprouve lorsque, de l’étouffement d’une foule
grossière, entassée dans une étroite enceinte, on s’échappe pour
respirer sous les lilas en fleur la fraîcheur d’une belle soirée de
printemps. Au lieu des chaudes vapeurs de l’orgie, on se plaisait dès
l’entrée dans je ne sais quelle atmosphère d’une douceur
indéfinissable; parfum sans nom et si particulier aux chambres de
quelques jeunes femmes, qu’on peut croire, sans être accusé de
céladonisme, que leur présence n’y est pas étrangère. Au milieu de
ces suaves senteurs avec lesquelles s’harmonisait la faible clarté
d’une lampe d’albâtre, les teintes douces à l’œil des tentures et un
silence qui avait une expression de recueillement, Clémence était
assise avec nonchalance dans une causeuse à l’angle de la
cheminée. Sur une table près d’elle, un ouvrage de broderie et
quelques livres annonçaient des intentions de travail ou de lecture
délaissées pour une de ces méditations séductrices, auxquelles les
esprits ardents ne savent pas résister. Les femmes surtout, que leur
condition fait esclaves, et leur nature avides de liberté, sont
d’insatiables rêveuses. Car la rêverie, c’est la prison qui s’ouvre, et
l’âme qui s’envole: et plus la prison est étroite, plus l’âme dans sa
délivrance imaginaire prend un essor désordonné. Telle, que le
monde juge froide, effrayerait par l’audace de ses secrètes pensées
l’imagination la plus virile; telle autre, qui en réalité n’a jamais failli,
se donne sans réserve, à certaines heures solitaires, à celui qui ne
sait rien obtenir quand il est là.

Mme de Bergenheim subissait alors cet entraînement irrésistible de


l’imagination qui brise sa chaîne. Jamais elle n’était allée si loin dans
l’abandon de ses sentiments, dans la hardiesse de ses réflexions.
Cette journée avait fait franchir à sa passion une distance qui l’eût
effrayée, si elle avait pu recouvrer un seul instant assez de calme
pour l’apprécier. Mais demander le calme au cœur qui aime, c’est
demander la lune sereine au ciel d’orage. Quoique son amant ne fût
plus là, elle était encore sous le charme de cette passion brûlante
autant que spirituelle qui répondait à la fois aux besoins de son âme,
aux délicatesses de son goût, à l’activité de son intelligence. En ce
moment, elle se trouvait heureuse de vivre; il n’était pas de pensée
triste qui ne s’effaçât devant ce mot magique: il m’aime! Par une
réussite bien rare, tous les détails de son raccommodement avec
Octave lui plaisaient; elle n’eût voulu rien en retrancher, rien y
ajouter; elle était arrivée au point qu’elle désirait, et s’y était arrêtée
sur un trône. Elle l’avait revu soumis comme aux premiers jours; il
avait reconnu sa souveraineté, en ne réservant pour lui que le droit
d’amour et de prière. Sans doute en se rappelant les concessions
dont elle avait payé ce triomphe, elle ne pouvait empêcher une
légère rougeur de colorer fugitivement sa joue; son orgueil féminin
était forcé de reconnaître qu’elle avait beaucoup permis, ou plutôt
beaucoup accordé; mais le souvenir de la délicatesse de son amant
calmait sa conscience et lui rendait moins pénibles les reproches de
sa pudeur; elle se pardonnait de lui avoir laissé deviner la force de
sa tendresse; la générosité dont il avait fait preuve n’était-elle pas
un gage qu’il n’abuserait jamais de cet aveu?
En amour, les femmes vont vite, surtout quand elles vont seules.
Lorsqu’on essaye de leur donner une impulsion trop rapide, un
instinct naturel les porte à la contradiction et à la résistance; mais
que le goût leur vienne de prendre d’elles-mêmes leur élan, elles
font d’un seul pas plus de chemin que les efforts de leurs amants
n’en eussent obtenu pendant un mois. Du moment que Mme de
Bergenheim eut décidé qu’Octave était un modèle de
désintéressement, elle mit à suivre son propre penchant, un
abandon aussi grand que l’avait été jusqu’alors sa retenue. Avec la
logique des passions, habiles à se faire une persuasion de leur désir,
elle exagéra jusqu’à l’héroïsme la belle conduite d’Octave, afin d’en
conclure pour elle-même un droit de tendresse plus confiante et plus
expansive. Puisqu’il avait tant d’empire sur lui-même, ne pouvait-elle
être moins rigide de son côté? Pourvu que sa vertu restât sans
tache, qu’importait qu’elle en dût le salut à sa propre force ou au
respect de son amant?
Selon l’usage de la plupart des femmes, qui, lorsqu’elles ne brisent
pas leur chaîne, cherchent du moins à l’allonger le plus possible, afin
de jouer avec leur esclavage, Clémence finit par voir le crime dans
un seul fait. Jusque-là, l’innocence lui sembla possible et la vertu
praticable; insensiblement, elle regarda comme péchés minimes et
pardonnables ces délits trop délicieux à commettre, que nos aïeux,
dans leur style expressif, nommaient les menus suffrages de l’amour.
Avec la réserve d’une imagination chaste et l’assurance d’un cœur
qui se croit infaillible, elle éleva une barrière devant le terme où
tendent toutes les passions, comme on pose un garde-fou au bord
d’un précipice; elle couvrit la barrière d’un voile pour s’ôter jusqu’à la
vue du danger, et, jetant les yeux sur le terrain dont elle se
permettait la jouissance, elle se dit: Ceci est à moi. Dans la naïveté
de son erreur, elle crut conciliables deux choses que nos mœurs ont
presque toujours séparées: la passion et le devoir; et pour les unir,
elle leur ôta à tous deux leurs aspérités trop incompatibles; elle fit la
passion sobre et le devoir tolérant. La hardiesse de ses réflexions
croissant à chaque instant, elle dépouilla peu à peu son mariage de
tout prestige de sentiment et finit par y voir ce qu’il avait été
réellement: un marché. A ce marché, elle appliqua, par une
conséquence logique, la loi d’équité qui sert de base à tous les
autres. Il lui sembla que, pour l’esprit ordinaire et l’âme inintelligente
de son mari, le sacrifice exclusif de toutes les richesses de sa propre
nature était un retour que nulle puissance humaine ne pouvait
prescrire. Réduisant au sens le plus faible le mot de fidélité qu’on lui
avait lu au nom de la loi, l’anneau qui en était le symbole lui parut
bien étroit pour enchaîner à jamais son cœur, son esprit, toutes ces
facultés impérieuses qui ne pouvaient exister que par l’amour;
puisque cet amour nécessaire à la vie de son âme ne s’était pas
rencontré parmi les autres présents de ses noces, elle crut pouvoir
l’agréer là où il s’offrait à elle. Au lieu de persister dans les
résistances d’une lutte impossible, elle accepta donc sa passion
comme inséparable désormais de son existence; elle fit d’elle-même
deux parts, l’une esclave du devoir, victime de ses serments,
humiliante et passive aliénation de sa personne; mais l’autre libre,
l’autre son bien, son être réel, sa vie véritable; et celle-ci, qui
pourrait lui contester le droit de l’accorder au cœur qui savait la
payer son prix?
Le bruit que fit en s’ouvrant la porte de la chambre à coucher
interrompit cette méditation dangereuse, dont chaque ondulation
effleurait d’un flot plus hardi les attrayants rivages de la terre
défendue. Mme de Bergenheim tourna la tête avec humeur; mais
lorsqu’au lieu de sa femme de chambre qu’elle s’apprêtait à
réprimander, elle eut reconnu son mari, l’impatience peinte sur ses
traits fit soudainement place à une expression de crainte. Par un
mouvement qu’elle ne put réprimer, elle se leva comme si elle eût
aperçu un étranger, et resta debout contre la cheminée, dans une
attitude dont l’observateur le moins clairvoyant eût remarqué le
trouble et la contrainte.
Rien dans les manières de Christian ne justifiait l’appréhension que
sa vue semblait causer à sa femme. Il s’avança d’un air tranquille,
avec ce sourire qu’il avait infligé à ses lèvres et qu’il n’y fixait qu’au
prix d’une crispation intérieure; sorte de fleur hypocrite, à corolle
épanouie, à racine hideuse. L’expression riante et presque
caressante de cette physionomie, au lieu de rassurer Clémence,
changea seulement la nature de sa crainte. Éveillée brusquement au
milieu d’un rêve coupable, son premier regard lui avait montré un
époux outragé et prêt à punir: un second, plus calme, lui en révéla
un autre non moins effrayant, un époux amoureux et disposé à
réclamer le privilège de ses droits. En ce moment, toute palpitante
encore des embrassements d’Octave, elle eût préféré trouver un
poignard aux mains de Christian, qu’un baiser à ses lèvres; en ce
moment c’était la fidélité à l’amant qui lui semblait devoir, et
l’abandon au mari adultère. Elle fut épouvantée de l’horreur que lui
inspira subitement ce dernier, mais le besoin d’échapper au supplice
dont elle se crut menacée fit taire tout autre sentiment. Avec la
présence d’esprit dont toutes les femmes sont douées en pareil cas,
elle se laissa retomber sur la causeuse et prit la parole d’un ton de
langueur souffrante mêlée à une expression de reproche.
...Christian poussa Lambernier dans le sentier qu’il lui avait indiqué...
—Dessin de WEISZ, gravure de H. MANESSE

—Je suis bien aise de vous voir un instant pour vous gronder, dit-
elle; je n’ai pas reconnu ce soir vos attentions ordinaires. Vous
n’avez donc pas pensé que le bruit de la salle à manger arrivait
jusqu’ici.
—En as-tu été incommodée? dit Christian en la regardant
attentivement.
—A moins d’avoir une tête de fer... il paraît que ces messieurs ont
un peu abusé de la liberté permise à la campagne. D’après ce que
m’a dit Justine, il s’est passé des choses qui eussent été mieux à leur
place à la Femme-sans-Tête.
—Tu souffres beaucoup?
—Une migraine affreuse. Je voudrais pouvoir un peu dormir.
—J’ai eu tort de ne pas prévoir cela. Mais tu me pardonnes, n’est-il
pas vrai?
Bergenheim se pencha sur la causeuse et passa un bras autour
des épaules de la jeune femme, en appuyant les lèvres sur le front
qu’elle tenait baissé. Pour la première fois de sa vie, il jouait un rôle
auprès d’elle et observait avec une attention implacable les moindres
expressions de son visage, les plus fugitives révélations de son
maintien. Il s’aperçut qu’elle frémissait sur le bras dont il l’avait
enveloppée, et sa bouche trouva prompt à se dérober et aussi froid
que le marbre le front qu’elle avait à peine effleuré.
Il se redressa et fit plusieurs tours dans la chambre en évitant de
la regarder, car l’aversion que lui annonçaient ces symptômes lui
parut une preuve complète et il craignit de ne pouvoir se contenir.
—Qu’avez-vous donc? demanda la jeune femme en remarquant
l’agitation de son mari.
Ces paroles rendirent au baron la prudence dont il avait besoin. Il
se rapprocha d’elle et répondit avec une sorte d’insouciance:
—J’éprouve une contrariété pour une cause assez frivole; il s’agit
de ta tante.
—Je sais. Elle est furieuse contre vous depuis le double malheur
arrivé à Constance et à son cocher. Quant à Constance, avouez que
vous êtes coupable.
—Elle ne se contente pas d’être furieuse; elle me menace d’une
rupture complète. Tiens, lis.
Il lui remit en disant ces mots une lettre pliée haut et large et
cachetée aux armes de Corandeuil. L’écusson accompagné de
supports, cimier, lambrequins et entouré de l’ancienne et
romanesque devise: Corandeuil, cœur en deuil! ressemblait plutôt,
pour la dimension, au sceau d’un diplôme qu’au cachet d’une lettre
ordinaire; il donnait d’abord une idée grave du contenu, et cette
impression se trouvait confirmée au premier coup d’œil par une
écriture droite, maigre, rigide, ainsi que par une belle orthographe
de douairière qui proscrivait sans pitié les a voltairiens et employait
volontiers les z au lieu des s.

Mme de Bergenheim lut le billet à haute voix:


«Après les événements inouïs et inqualifiables de ce jour, le parti que je
crois devoir prendre n’aura sans doute rien qui vous surprenne, monsieur;
vous comprendrez que je ne puisse ni ne veuille rester plus longtemps
dans une maison où la vie de mes domestiques et des autres créatures
que l’on sait m’être chères est exposée aux guets-apens les plus
déplorables. Depuis longtemps, quoique je voulusse bien fermer les yeux,
je m’étais aperçue des machinations tramées journellement contre tout ce
qui porte la livrée de Corandeuil. Je supposais que je n’avais pas besoin
d’y mettre fin, que vous vous chargeriez de ce soin; mais il ne paraît pas
que les égards et le respect pour les femmes fassent aujourd’hui partie
des devoirs d’un gentilhomme. Je dois donc suppléer à une absence
complète de procédés et veiller moi-même à la sûreté des personnes et
autres créatures qui me sont attachées. Je pars demain pour Paris. L’état
de Constance lui permettra, j’espère, de supporter les fatigues du voyage;
mais la blessure de Baptiste est trop grave pour que je veuille l’y exposer.
Je me décide donc, quoique à regret, à le laisser ici jusqu’à ce qu’il puisse
se mettre en route, le recommandant à l’humanité de ma nièce.
«Recevez, monsieur, avec mes adieux, tous mes remerciements pour
votre courtoise hospitalité.
«Yolande de Corandeuil.»

—Ta tante abuse un peu de la permission d’être folle, dit le baron,


lorsque sa femme eut achevé cette lecture; elle lève le camp en me
recommandant ses blessés comme après une bataille.
—Mais je l’ai vue il n’y a pas deux heures, et, quoiqu’elle fût fort
courroucée, elle ne m’a pas dit un mot de ce départ.
—Il n’y a qu’un instant que Jean m’a remis cette lettre, en grande
livrée et avec l’importance d’un ambassadeur qui demande ses
passeports. Il te faut, ma bonne amie, aller lui parler et employer
ton éloquence pour la faire changer de projet.
—J’y vais sur-le-champ, répondit Clémence en se levant.
—Tu sais que ta chère tante est passablement entêtée lorsqu’elle a
chaussé une fantaisie. Si elle persistait dans celle-ci, donne-lui, pour
la décider à rester, une raison dont elle comprendra la valeur. Je suis
obligé d’aller demain matin à Épinal avec M. de Camier, pour une
vente de bois, et je serai absent au moins trois jours. Tu comprends
qu’il est difficile que ta tante te laisse seule pendant mon absence, à
cause de ces messieurs.
—Certainement, cela ne se peut pas, dit-elle avec vivacité.
—Je n’y verrais, quant à moi, aucun inconvénient, reprit le baron
en essayant de sourire; mais il faut avant tout obéir aux
convenances. Tu es une maîtresse de maison trop jeune et trop jolie
pour te passer de chaperon, et Aline, au lieu de pouvoir t’en servir,
serait un inconvénient de plus. Il faut donc absolument que ta tante
reste ici jusqu’à mon retour.
—Et d’ici là, Constance et Baptiste seront guéris et sa colère
oubliée. Vous ne m’aviez pas encore parlé de ce voyage à Épinal et
de cette vente de bois.
—Va chez ta tante avant qu’elle soit couchée, répondit
Bergenheim, sans s’arrêter à cette observation et en s’asseyant sur
la causeuse; je t’attendrai ici. Nous partons demain de très bonne
heure et je veux savoir ce soir à quoi m’en tenir.
Dès que Mme de Bergenheim fut sortie et eut refermé la première
porte du petit parloir, Christian se leva, courut plutôt qu’il ne marcha
vers l’entre-deux des fenêtres, et chercha dans la rosace de la
boiserie le bouton secret dont lui avait parlé Lambernier. Il l’eût
bientôt trouvé; à la première pression, le ressort joua et le panneau
s’ouvrit. Le coffret de palissandre était sur la tablette, il le prit et
examina quelque temps avec attention les lettres qui s’y trouvaient
enfermées. La plupart ressemblaient pour la forme à celle dont il
était déjà possesseur; quelques-unes avaient une enveloppe à
l’adresse de Mme de Bergenheim et portaient un petit cachet armorié
qu’il reconnut pour celui de Gerfaut. L’identité de l’écriture était
d’ailleurs incontestable, et les doutes, s’il en conservait encore,
devaient tomber devant l’évidence. Après avoir jeté au hasard un
coup d’œil rapide sur quelques-uns de ces billets, il les remit dans le
coffret et celui-ci sur le rayon, en ayant soin de replacer toute chose
dans l’état où il l’avait trouvée. Il referma le panneau avec une égale
attention et vint se rasseoir au coin de la cheminée.
Lorsque Clémence rentra, son mari paraissait absorbé par la
lecture d’un des volumes qu’il avait trouvés sur la table, tandis que
sa main jouait machinalement avec une petite coupe de bronze où
sa femme mettait ordinairement en se déshabillant ses bagues et
ses boucles d’oreilles.
—J’ai gagné notre procès, dit la baronne d’un ton joyeux; ma
tante a compris les raisons que je lui ai données, et elle différera son
départ jusqu’à votre retour.
Christian ne répondit pas.
—C’est-à-dire qu’elle ne partira pas du tout, car pendant trois
jours sa grande colère aura le temps de se calmer; au fond, elle est
très bonne.—Mais depuis quand savez-vous l’anglais? continua-t-elle,
en remarquant l’attention avec laquelle son mari tenait les yeux fixés
sur le volume de lord Byron qui lui servait de contenance.
Bergenheim jeta le livre sur la table, leva la tête et essaya de
regarder sa femme d’un air calme. Malgré ses efforts, son visage
avait une expression dont celle-ci eût été probablement épouvantée;
mais elle n’y fit pas attention, ses yeux s’étaient arrêtés sur la coupe
que son mari tenait encore et qu’il tordait dans sa main comme s’il
eût pétri de l’argile.
—Mon Dieu! Christian, qu’avez-vous donc, et que vous a fait cette
pauvre coupe? demanda-t-elle avec une surprise où il entrait un peu
de cet effroi toujours si prompt à s’éveiller dans un cœur qui ne se
sent pas sans reproche.
Il se leva et remit le bronze déformé sur la cheminée.
—Je ne sais ce que j’ai ce soir, dit-il avec effort, je me sens les
nerfs irrités. Je vais vous laisser, car j’ai besoin de repos moi-même.
Je partirai demain bien avant votre lever et je serai de retour
mercredi.
—Pas plus tard au moins, mon ami, dit-elle avec une douceur de
langage et d’accent dont en pareilles circonstances bien peu de
femmes ont la loyauté de s’abstenir.
Il sortit sans répondre, car il craignait de n’être pas maître de lui:
à cette espèce de caresse hypocrite l’envie lui était venue d’en finir
et de la tuer sur-le-champ.
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookball.com

You might also like