Docsity

Structural Induction and Sufficient Generation in Equational Logic - Prof. Jose Meseguer, Study notes of Computer Science

Partial preview of the text

Download Structural Induction and Sufficient Generation in Equational Logic - Prof. Jose Meseguer and more Study notes Computer Science in PDF only on Docsity!

Program Verification:

Lecture 9

Jos´ e Meseguer Computer Science Department University of Illinois at Urbana-Champaign 1

Structural Induction We have already observed how the ITP supports inductiveproofs in three cases: natural number induction, listinduction, and tree induction. But what is the general form of induction supported by the ITP for a specification havinga subsignature

of constructors? This general form is called structural induction

. It reduces proving an inductive property of the form

x

s

P

x

, to proving:

Base Case . For any constant a

nil

s ′^ in

with s ′^

s , the subgoal

P

x/a

Notation : Given a variable x , the substitution mapping x to a term t is denoted

x/t

, and its homomorphic extension

x/t

is also denoted

x/t

. 2

Structural Induction (III) Note : If the signature

of constructors has been fully specified, the base case and the induction step implicitly cover all subsorts , so that the third case should never arise, except perhaps for s ′^ an empty sort, with no terms whatsoever, for which the property

P

then trivially holds. Therefore, from now on we will systematically ignore the case of subsorts without constructors in the rest of ourtheoretical discussions. In practice, however, this case isactually quite useful, and this for two reasons: 4

Structural Induction (IV)

to deal with constants in predeclared modules , such as QID , which are built-in and are not defined as constructors (we encountered this phenomenon in ourtree-reverse example); and - to generalize these inductive proof methods to parameterized modules , such as

LIST(X)

, where the parametric sort of elements might be a subsort of thesort List(X) , but we have no a priori information about the constructors of such a parametric sort of elements. 5

Justification of the ind Rule Why is ind a sound inference rule? First consider: Lemma : Given a confluent and terminating equational theory

, E

with subsignature of constructors

, and given any

-equation

X

t

t ′ , we have T Σ /E

X

t

t ′^

θ

X

T

Ω

T

Σ /E

θt

θt ′

Proof : Notice that, since

is the subsignature of constructors, any assignment a

:^

X

T

Σ /E factors as a

θ

eval T Σ /E | Ω , where if a

x

) = [

t

]

, we can define θ

X

T

Ω by θ

x

can E

t

. Therefore, by the usual factorization and initiality argument,

T

Σ /E , a

t

t ′^

T

Σ /E

θt

θt ′

q.e.d. 7

Justification of the ind Rule (II) Notice that the argument of the above lemma does notdepend on our formula being actually an equation: it wouldsimilarly apply to conditional equations, and even togeneral, universally-quantified first-order formulas.Therefore, we have reduced the problem of proving aninductive property,

x

:^

s

P

x

, to that of proving that for all t

T

Ω ,s the instantiated property

P

x/t

holds. Here is where structural induction steps in as a method,namely, by analyzing more closely what it means to provesomething for all t

T

Ω ,s . 8

Justification of the ind Rule (IV)

for each constant a as above,

P

x/a

holds; and

for each f as above, assuming that

P

x/t i^1

,... , P

x/t i k

, holds then we prove that

P

x/f

t 1 ,... , t n

holds, (where t i j

T

Ω ,s ij , and s i j ,

j

k are those sorts among the s 1

... s n for the arguments of f such that s i j

s ,

j

k ) then we have proved that

P

x/t

holds for all t

T

Ω ,s (indeed, 1–2 above amount to a proof by induction on the depth of t

T

Ω ,s ) which, by our previous lemma, shows,

T

Σ /E

x

s

P

x

and therefore justifies ind as a sound inference rule. 10

Sufficient Generation All this is fine, but there is a pending issue. How do we know that the declared subsignature of constructors is correct?For example, as discussed in the justification of the split rule, the user may have overlooked giving enough equations for the defined functions, and then it becomes impossible tosimplify every ground term to a constructor term.A quick glance at our proof of the lemma involved injustifying the soundness of the ind rule shows that the reduction of proving

P

x

to proving

P

x/t

for each t

T

Ω ,s works just the same under much weaker assumptions than (Σ

, E

confluent and terminating with subsignature of constructors

. 11

Proving Sufficient Generation We consider two methods. The first method to provesufficient generation does not require any extension of ourinductive proof methods. It is a matter of carrying out other inductive proofs in a transformed theory . The transformed theory

, E

, associated to our original theory

, E

, introduces a new error supersort at the top of each connected component, and lifts to those error supersorts all the defined functions (nonconstructors) while leaving the constructors and equations unchanged

. For example, for fmod

, E

endfm the

NAT-MIXFIX

module defining natural number addition, fmod

, E

endfm is the module, 13

Proving Sufficient Generation (II) (fmod NAT-MIXFIX? is sorts Natural Natural? .subsort Natural < Natural? .op 0 : -> Natural [ctor] .op s_ : Natural -> Natural [ctor] .op + : Natural? Natural? -> Natural? .vars N M : Natural .eq N + 0 = N .eq N + s M = s(N + M) .endfm) 14

Proving Sufficient Generation (III) What do we then have to prove to ensure that a claimedsubsignature of constructors sufficiently generates all sortsfor our original theory

, E

? For example, in our

NAT-MIXFIX

module what we need to show is that the original operator declaration for theaddition function, op + : Natural Natural -> Natural. is inductively true in the transformed module

NAT-MIXFIX?

, even though it is not explicitly declared in such a module.How can we do that? By using membership equational logic , a natural conservative extension of the (order-sorted) equational logic that we have been using so far, that issupported by both Maude and the ITP. 16

Proving Sufficient Generation (IV) In membership equational logic, besides equations we allowalso memberships , which are statements of the form t

s , with t a term, and s a sort in the connected component of sorts that might possibly be assigned to t . The satisfaction of a membership

X

t

s in an algebra

A

has the obvious definition, namely, for all assignments a

:^

X

A

, we have, a

t

A

s . In this more expressive logic, the operator declaration op + : Natural Natural -> Natural. becomes equivalent to the sentence,

n, m

Natural

n

m

Natural

17

=================================suffgen$2.0=================================|-{V3#0:Natural}({N:Natural}(N:Natural + V3#0:Natural : Natural)==>{N:Natural}( N:Natural + s V3#0:Natural : Natural)) +++++++++++++++++++++++++++++++++Maude> (auto suffgen$1.0 .)=================================suffgen$2.0=================================|-{V3#0:Natural}({N:Natural}(N:Natural + V3#0:Natural : Natural)==>{N:Natural}( N:Natural + s V3#0:Natural : Natural)) +++++++++++++++++++++++++++++++++Maude> (auto suffgen$2.0 .)q.e.d 19

Justification of the Sufficient Generation Proof Method Why do we then know that the constructors of

NAT-MIXFIX

generate its initial algebra after a proof like this?More generally, suppose that we are given a ground confluent and terminating equational theory

, E

, with a supposed signature of constructors

, and we use the knowledge of

to obtain the transformed theory

, E

, with all nonconstructor constants and function symbolslifted to the new error supersorts at the tops of theconnected components.We assume that

is well-sorted relative to

, in the sense that for any sort s and term t

T

Ω we have, t

T

Ω ,s

t

T

Σ ,s

20