View
220
Download
0
Tags:
Embed Size (px)
Citation preview
Winter 2004/5 Pls – inductive – Catriel Beeri 1
Inductive Definitions(our meta-language for specifications)
Examples Syntax Semantics Proof Trees Rule set as a function Proof by induction Function (& relation) definition by induction Generalizing rule form
Winter 2004/5 Pls – inductive – Catriel Beeri 2
An inductive definition by
one axiom, one proper rule
Let be defined by
(r1) 4 ,
(r2) , , 2 10
Ex. 1
if &
then 2 3
S
S
x y S y x y
x y S
Examples
Winter 2004/5 Pls – inductive – Catriel Beeri 3
Questions:
1. Do we know which elements are in S?
(at least, can we enumerate them?)
2. Given c, can we answer :is c a member of S?
3. Which is the underlying universe here ?
A: any of N, Z, Q, ….
It is common to omit the universe, U, since:– It is often known from the context
– The rules “tell” us what it is
– Even if there are several candidates, the defined set is often the same in them
Winter 2004/5 Pls – inductive – Catriel Beeri 4
4. Is there just one set in N that satisfies (r1), (r2)? If not, which one is the one being defined?A: The intention is the least set that satisfies the rulesBut, “least’ is often omittedNote difference between minimal, least (in a collection)
* There is an abuse of language. It should be
Easier to use S for both: defined and a set variable
Let be the set that satisfies
(r1) 4 (r2) if , &...
leas
then
t
2 3
S
x y x
X
X XyX
Winter 2004/5 Pls – inductive – Catriel Beeri 5
Can we enumerate?
Solve membership?
Is the defined set independent of the universe?
: let S be defined by
(r1) 4 , (r2) 7 ,
, (r3)
2
Ex.2
3
S S
x y S
x y S
Winter 2004/5 Pls – inductive – Catriel Beeri 6
A new problem: goal resolution
Given c, can we find all y s.t. S(c,y)?
c – a goal (on 1st position)
y, such that S(c,y) – a solution
Can we solve when the goal is on 2nd position?
: let S be defined by
(r1) S(4,7) (r2) S(4,9)
( , ) ( ,z) (r3)
Ex.3
( 1,2 3 )
S x y S x
S x y z
Winter 2004/5 Pls – inductive – Catriel Beeri 7
Q: is the defined set independent of universe?
What about goal resolution on either column?
: let S be defined by
( , ) ( ,z) (r1) S(x, x+1) (r2)
(
Ex.
, )
4
S x y S y
S x z
Winter 2004/5 Pls – inductive – Catriel Beeri 8
Inductive definition: a set R of rules
A rule: conjunction of premises (הנחות)
implies conclusion
or: body implies head
Our style: (no commas!)
Syntax
1 ... ne S e S
e S
membershi -- a pr mip e seie S - a premise, an arbitrary formula
does include
conditio
membersnot
n
hips
Winter 2004/5 Pls – inductive – Catriel Beeri 9
Empty body (0 premises) – an axiom:
Otherwise, a proper rule
1st Example:
Here, x, y are individual variables
(r1) 4 (an axiom)S
2 10(r2) (a proper rule)
2 3
x S y S y x y
x y S
e S
Winter 2004/5 Pls – inductive – Catriel Beeri 10
SemanticsVariable assignment :
maps individual variables to constants (in U)
Applied to a rule a ground (var-free) rule instance
{ 3, 4} givesx y 3 4(r2)
18
S S true
S
S satisfies rule r if for each r-instance, if body is true in S then head is true in S (Individual vars are universally quantified)
S satisfies R, if it satisfies each r in R
Winter 2004/5 Pls – inductive – Catriel Beeri 11
• If U (the universe)– contains the constants in R,
– is closed under the operations in R,
then it satisfies R – satisfying set exists
• Intersection property :
If each set satisfies R,
so does
Hence, a (unique) least set that satisfies R exists
This set is the semantics of R – ind{R}
,iS i I
i I iS
Winter 2004/5 Pls – inductive – Catriel Beeri 12
Extensions • Define several sets simultaneously
– Can use in rules, for each defined
• Can assume certain sets are given (known)– Can use in premises
(This is not a real extension, can use these in conditions)
These enable construction of definition hierarchies.
j ie S iS
{ }jQ
ie Q
iS
Winter 2004/5 Pls – inductive – Catriel Beeri 13
Example of a proof of membership in an inductive set:
Each leaf – an axiom instance
Each internal node – inferred from its children
– a rule instance
4 420 4 44
52 20164
S SS S SS
S SS
Proof Trees
Winter 2004/5 Pls – inductive – Catriel Beeri 14
We abbreviate to :
Element a is inferred from by rule r if ...
Q: What when r is an axiom?
1,..., na a
1 ... ( )( ) , & ( ) is na S a Sr true
a S
1 is from , ..., by rule ifinferre d na S a S a S r
Winter 2004/5 Pls – inductive – Catriel Beeri 15
Proof TreeA tree in which each node is• labeled by a is the element at the node
• Associated with a rule r such that: is inferred from the children of the node by r (for a leaf --- associated rule is an axiom)(Labels of a node & its children ~ rule instance)
Proof trees contain only membership formulas
Proof tree – a composition of inferences
a S
a S
Winter 2004/5 Pls – inductive – Catriel Beeri 16
Fact: a is in ind{R} iff it has a proof tree Proof tree is a proof of membership for its root
How do we prove this?
1. An arbitrary satisfying set contains every element that has a proof tree --- induction on depth of tree
2. The set of elements that have proof trees is a satisfying set
Winter 2004/5 Pls – inductive – Catriel Beeri 17
Rule set as a function
Generalize:
For example 1:
( ) ( )R rr R
f Q f Q
( ) the elements inferred by from elements of rf Q r Q
( ) {4} { | 2 3 , , , 2 10 }Rf Q z z x y x y Q y x y
({2,3}) {4,10,15,13,12}Rf
Winter 2004/5 Pls – inductive – Catriel Beeri 18
Define: Q is closed under r/R if it is closed under :
Fact: closed under r/R = satisfies r/R
Fact:
same for
is :
monotone
( ) ( )r
r r
f
P Q f P f Q
( ) / ( )r Rf Q Q f Q Q
Rf
/r Rf f
Winter 2004/5 Pls – inductive – Catriel Beeri 19
Thm: [Knaster-Tarski, 1955]
A monotone function f on sets has the
intersection property for its closed sets:
if some set is closed under f, a least closed set exists
for any R, a least set closed under R exists (for a large enough universe)
(remember: closed under = satisfies)
ii I
if , are closed under
then S is closed under
iS i I f
f
Winter 2004/5 Pls – inductive – Catriel Beeri 20
• Prove for each axiom that P(e) holds• Prove for each rule
that if (and ) then P(e) holds (actually, prove it for each variable assignment)
proof by rule induction
Example: prove for Example 1 that each element in S is divisible by 4
Proof by induction
e S1 ... ne S e S
e S
P( )ii e
Winter 2004/5 Pls – inductive – Catriel Beeri 21
Function (& relation) definition by induction
• For each axiom , define f(e)
• For each rule
define f(e) in terms of
Example:
fact(0) = 1
fact(n+1) = (n+1)*fact(n)
Why is it called definition by induction?Hint: What is the domain, and the rules that define it?
and what is the form of the function definition
e S
1 ... ne S e S
e S
1f ( ), ..., f ( )ne e
Winter 2004/5 Pls – inductive – Catriel Beeri 22
Let rfact be the graph of fact , a binary relation.
Compare:
To fact(0) = 1
fact(n+1) = (n+1)*fact(n)
( 1) (0,1)
( , )( 2)
( 1,( 1)* )
f rfact
rfact n kf
rfact n n k
( 1) 0
( 2)1
N
nN
n
“Inductive” has a double meaning– the domain is inductively defined –The function is inductively defined (in a special syntax) and the two rules sets correspond
Winter 2004/5 Pls – inductive – Catriel Beeri 23
Function def. by induction:
function defined by clauses, one for each rule defining the domain
Significance :
One-to-one correspondence fact is total
Sometimes, we need a partial function;
we provide clauses for only some of the rules
that define the domain
Example: head and tail on lists
Winter 2004/5 Pls – inductive – Catriel Beeri 24
Consider:
Define
We have:
What went wrong? (think of proof trees)
“Function” is total, but ill-defined!
1 N
x N y N
x y N
(1) 0
( ) 1 max( ( ), ( ))
d
d x y d x d y
(4) 1 max( (3), (1)) 3
(4) 1 max( (2), (2)) 2
d d d
d d d
Winter 2004/5 Pls – inductive – Catriel Beeri 25
Function & relation definitions, summary
Over an inductively defined domain• Inductive definition of relation is always ok.
• Inductive function definition – Is always total
– may fail to be well-defined
a sufficient condition for well-defined-ness:
each value of domain has a unique proof tree
Winter 2004/5 Pls – inductive – Catriel Beeri 26
Generalizing rule form
It is allowed to combine membership formulas by• Conjunction in head• Disjunction in body
But,
Disjunction in head, negation in body/head are
forbidden
Why?
As for quantifiers --- see reading material