Dealing with Inconsistency in PrediCalc

Download Report

Transcript Dealing with Inconsistency in PrediCalc

Stanford Logic Group
Logical Spreadsheets
Michael Kassoff
August 1, 2006
joint work with
Michael Genesereth
SRI AIC Seminar
Electronic Spreadsheets
• Huge success
• Used by everyone from
multinational conglomerates to
individuals
• Uses
– Financial planning
– Scientific data analysis
– Shopping lists
Why People Like Spreadsheets
•
Saves you work
– Automatic calculation
– Automatic recalculation
• Allows “what if” analysis
•
Programming is easy
– You don’t have to be a programmer to
program a spreadsheet
– Mathematical notation is familiar to
people (C1=A1+B1)
– Unlike traditional programs,
intermediate computation steps are all
displayed for you
– It’s like being in debug mode all the
time
Limitations of Traditional
Spreadsheets
Unidirectional update
Functional definitions,
not many-to-many
constraints
Applications of Many-to-Many,
Multidirectional Constraints
• Correct-on-capture data entry (smart forms)
– “Start times must be before end times”
– “The number of lap infants traveling must not be greater
than the number of adults”
• Enterprise Management policies
– “Only senior managers can reserve the third floor
conference room”
• Design / Configuration
– “If the car’s exterior color is blue, the possible interior
colors are tan and gray.”
– “Students must take at least 2 math courses to graduate”
Logical Spreadsheets
We choose to represent many-to-many relationships using
logical formulae
start-time(S) and end-time(E)  before(S,E)
“The start time must be before the end time”
event-owner(O) and senior-manager(O)  event-room(room301)
“Only senior managers can reserve the third floor
conference room”
Note that the arrows do not imply directionality. Relationships are omnidirectional.
From Functions to Constraints
Example: Event creation smart form Demo
Constraints
“Start Time < End Time”
“Start Time + Duration = End Time”
Agenda
-
Formal Definitions
Update Mechanism
Inconsistency Handling
Demo
Logical Spreadsheets on the Web
Formal Definitions
A logical spreadsheet consists of a finite set of cells,
a set of possible values for those cells, and a set of
constraints encoded as logical sentences.
Cells: {p, q, r}
Possible Values: {a, b, c, d}
Constraints: {p(x)  q(x), q(x) or r(x)}
Value Assignments
We represent value assignments to cells with
ground unary atoms
student
bob
major
math
{student(bob), major(math)}
Constraints
Universal first-order constraints over cells are
allowed
View Definitions:
r(X)  p(X)  q(X)
Functional Dependencies:
r(X)  r(Y)  X=Y
Integrity Constraints:
(p(X)  q(X))  r(X)
N-ary Relations
Through view definitions, can expand language to
include n-ary relations without an increase in
expressive power
View Definitions:
location(x,y)  e(x)  r(y)
Functional Dependencies:
location(x,y)  location(x,z)  y=z
Integrity Constraints:
needs-projector(x)  has-projector(y)  location(x,y)
For the rest of the preso, we’ll just use unary relations
Logical Spreadsheet = Interactive CSP
A constraint satisfaction problem consists of a
set of variables, a set of possible values for
those variables, and set of constraints
“variable” = “single-valued cell”
Note the focus on interactivity
Logical Spreadsheets as Databases
A logical spreadsheet can be viewed as a
deductive database (database with constraints)
consisting of unary relations
P
a
b
c
Q
c
d
R
b
c
d
Updating Logical Spreadsheets
User-specified Cells vs.
Computed Cells
Can assign a value to any cell
User-specified cells are
marked with a dark outline
Computed cells contain
logical consequences of
user-specified cells
p(X)  q(X)
p
a
q
a
p
b
q
b
User specified
System generated
Bilevel Update
Q: Why does a logical
spreadsheet distinguish
between user specified and
system generated values?
A: When values are removed
from user-specified cells,
their consequences go away
p(X)  q(X)
p
a
q
a
p
q
User specified
System generated
Direct Conflict
What happens when a newly assigned value conflicts
with a previously assigned one?
p(X)  q(X)
p
a
q
a
b
Possible outcomes
Reject
p
a
Conflict
q
a
p
a
q
b
Resolve
p
b
q
b
Information Loss vs. Inconsistency
eng
course1 course2 course3
eng
eng
course1(eng) or course2(eng) or course3(eng)
“Students must take some course from outside the engineering school.”
Possible outcomes
course1 course2 course3
eng
eng
course1 course2 course3
eng
eng
course1 course2 course3
eng
course1 course2 course3
eng
eng
eng
Problem
A set of sentences  logically
entails a sentence  if and
only if every model of  is
a model of .
An inconsistent theory has no
models.
course1 course2 course3 major
art,cs,
eng
eng
eng
math,…
Explosion!
Solution
We use a new paraconsistent entailment
relation called Existential -Entailment
instead of logical entailment
Existential -Entailment is not explosive
Existential -Entailment
A possible world W is a subset of the user-specified
value assignments  of a spreadsheet that is
consistent with the constraints 
A fact  is true in a possible world W iff W   |= 
 |  when  is true in some possible world of the
spreadsheet
Formally,  |  when
W  and W |  and W | 
Example
course1(pe) or course2(pe) or course3(pe)
“Students must take some non-physical education class.”
course1(X) and course2(X) and course3(X)  minor(X)
“If a student takes three courses in the same subject, the student is awarded a
minor in that subject.”
course1(pe) or course2(pe) or course3(pe)  pe_requirement(yes)
“Students can fulfill their physical education requirement by taking any
physical education class.”
Value assignments: {c1(pe), c2(pe), c3(pe)}
Maximal consistent subsets (possible worlds):
{c1(pe), c2(pe)}   |= {c1(pe), c2(pe), pe_req(yes)}
{c1(pe), c3(pe)}   |= {c1(pe), c3(pe), pe_req(yes)}
{c2(pe), c3(pe)}   |= {c2(pe), c3(pe), pe_req(yes)}
Result:
{c1(pe),
c2(pe),
c3(pe),
pe_req(yes)}
Proof-Theoretic View
 | 
when there is some set of premises P from   
that proves 
such that P is consistent with .
Note that the proof-theoretic view tells us that there
is no need to take all (maximal) subsets of the
data. Just modify your favorite proof procedure
with a consistency check.
Because theory is unary, consistency checking is
decidable!
Example
Constraints = {c1(pe) or c2(pe) or c3(pe),
c1(X) and c2(X) and c3(X)  minor(X)}
Data = {c1(pe), c2(pe), c3(pe)}
Query = X.minor(X)
<Clause, Assumptions>
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
<{c1(X), c2(X), c3(X), minor(X)}, {}>
<{c1(pe), c2(pe), c3(pe)}, {}>
<{c1(pe)}, {c1(pe)}>
<{c2(pe)}, {c2(pe)}>
<{c3(pe)}, {c3(pe)}>
<{minor(X)}, {}>
<{c1(X), c2(X), c3(X)}, {}>
<{c2(pe), c3(pe)}, {c1(pe)}>
<{c3(pe)}, {c1(pe), c2(pe)}>
<{}, {c1(pe), c2(pe), c3(pe)}>
[Premise, constraint]
[Premise, constraint]
[Premise, data]
[Premise, data]
[Premise, data]
[Goal]
[6,1]
[7,3]
[8,4]
[9,5]
Consistent Query Answering
In the database literature, a growing subfield
is consistent query answering (CQA)
Designed for querying inconsistent databases
Similar to Existential -Entailment, except an
answer must be true in all possible worlds
(intersection instead of union)
Linear Resolution
Linear Resolution methods such as those used
in Model Elimination and Prolog are also
paraconsistent
Given {p, p, r  q} and a query r Prolog /
ME will not return true
However, Prolog / ME were not designed to
handle paraconsistency - this is merely a
side effect of their efficiency
Logical Spreadsheet Demo
Websheets
Each field is a cell
Cells can be related with logical formulae
We built two prototypes:
(1) AJAX-based (client/server) demo
(2) Completely JavaScript based (client only)
Interlinked Spreadsheets
World Wide Websheet
Thanks!