
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Jos´ e Meseguer Computer Science Department University of Illinois at Urbana-Champaign
The ITP Inference Rules Notice that in the ITP we reason backwards , replacing the main goal
we want to prove by subgoals ,
1
n , such that if we prove each of the subgoals, then we have provedthe main goal.For such an inference to be sound , the implication G 1
n
should always be satisfied , that is, should be semantically valid in the initial model
Σ ,E on which we are doing the inductive reasoning.
Linearity of the Number Ordering Consider the following module defining the order onnumbers, which we would like to prove is linear. (fmod NATURAL-ORD is sort Natural .op 0 : -> Natural [ctor] .op s : Natural -> Natural [ctor] .op < : Natural Natural -> Bool .op =< : Natural Natural -> Bool .vars N M : Natural .eq N < 0 = false .eq 0 < s(N) = true .eq s(N) < s(M) = N < M .ceq N =< M = true if N < M .ceq N =< M = true if not(M < N) .ceq N =< M = false if M < N. endfm)
The cns Inference Rule After entering the goal stating that the order on thenaturals is linear, one of the possible ITP inference rules wecan invoke is the lemma of constants , which converts universally quantified variables in a goal into constants. Maude> (goal linear : NATURAL-ORD |- {N:Natural ; M:Natural} (((N:Natural =< M:Natural) or (M:Natural =< N:Natural)) = true) .) =================================linear$0=================================|-{N:Natural ; M:Natural}(N:Natural =< M:Natural or M:Natural =< N:Natural = true) +++++++++++++++++++++++++++++++++
The cns Inference Rule (II) The fact that this is a semantically valid inference is basedon the Constants Lemma , which states the equivalence between satisfiability of a quantified equation, and of thesame equation with the variables transformed into generic constants
Σ
t
t ′^
Σ( X )
t
t
Thanks to the completeness of equational reasoning, this is expressed in the ITP as the cns rule, E
Σ
t
t ′ E
Σ( X )
t
t ′
Justification of the cns Rule We can justify the validity of the Constants Lemma not only for unconditional equations, but also for conditionalones as follows. Given a conditional equation
ϕ
t
t ′^
u 1
v 1
u n
v n
we have
Σ
ϕ iff, by definition, (
A, a
Alg Σ( X )
Σ
A, a
Σ( X )
ϕ, which is equivalent, by Ex 6.2, to (
A, a
Alg Σ( X )
A, a
Σ( X )
A, a
Σ( X )
ϕ, which, by definition of satisfaction, is precisely E
Σ( X )
ϕ , as desired.
Reasoning by Cases: The split Rule (II) In our example we can give the split command, Maude> (split linear$0 on (NNatural < MNatural). )=================================linear$1.0=================================|- NNatural =< MNatural or MNatural =< NNatural = true=================================linear$2.0=================================|- NNatural =< MNatural or MNatural =< NNatural = true
Reasoning by Cases: The split Rule (III) The goals remain the same, but the split hypotheses foreach case have been added to each case’s module. Usingthese hypotheses we can now discharge each of thesubgoals with the auto tactic. Maude> (auto linear$1.0 .)=================================linear$2.0=================================|- NNatural =< MNatural or MNatural =< NNatural = true+++++++++++++++++++++++++++++++++Maude> (auto linear$2.0 .)q.e.d
Applications of split Must Protect
Regardless of the current ITP restrictions in the applicationof split , there is a fundamental way in which the application of split would be unsound, namely, if we have messed up the Booleans by adding junk and perhaps confusion to them, so that we do not have anymore two different canonical forms, true , and false , but may have other nonstandard Boolean elements as well.This can happen because, when defining new predicateswith operators of sort Bool , we do not give enough equations , thus adding “junk” to Bool , or we give the wrong equations , adding “confusion” and possibly also “junk” to Bool
. Therefore, sound application of split require that the BOOL submodule is protected .
Protecting Module Importations In general, if we have a theory
having a subtheory (Σ ′
′
with,
′^
and
′^
and the module fmod
endfm imports the submodule fmod
′
′
endfm in protecting mode, we require that the unique
′ -homomorphism eval E ′ T Σ ,E | Σ ′^
Σ ′^ /E ′^
Σ ,E
Σ ′ is an isomorphism .
Justification of the split Rule (II) Therefore, given any Boolean valued
-term p
Σ
Bool , and given any assignment a
Σ /E , we have, (
Σ /E , a
p
true
p
false
That is, for any such assignment a , the above proposition is equivalent to the identically false proposition,
, which is never satisfied:
Σ /E , a
p
true
p
false
Σ /E , a
Now, since for any proposition
we always have the Boolean equivalence,
, we also have an equivalence
. Therefore, given an equation
t
t ′ , we have, 16
Justification of the split Rule (III) T Σ /E
t
t ′^
Σ /E
t
t
or, equivalently, T Σ /E
t
t ′^
Σ /E
t
t ′
p
true
p
false
which, using distributivity of disjunction over conjunction,plus the fact that
, is equivalent to, T Σ /E
t
t ′^
Σ /E
p
true
t
t
p
false
t
which, modulo the distribution of
over
, is our desired justification for split as a sound inductive reasoning rule. 17
Induction on Other Data Structures: Tree Induction (II) Consider the following module defining binary trees whosenodes are quoted identifiers (constants in the predefinedmodule
), and a reverse function on binary trees. (fmod TREE isprotecting QID .sort Tree .subsort Qid < Tree .op # : Tree Tree -> Tree [ctor] .op rev : Tree -> Tree .var I : Qid .vars T T’ : Tree .eq rev(I) = I .eq rev(T # T’) = rev(T’) # rev(T) .endfm)
Induction on Other Data Structures: Tree Induction (III) We can apply binary tree induction to prove that for alltrees
the equation rev(rev(T)) = T holds. We can do so by entering the
module in the ITP and the goal: Maude> (goal rev : TREE |- {T:Tree}((rev(rev(T:Tree))) = (T:Tree)) .)=================================rev$0=================================|-{T:Tree}(rev(rev(T:Tree))= T:Tree)