Professional Documents
Culture Documents
04 DGM Dlogisa
04 DGM Dlogisa
F. Miguel Dion
sio, Paula Gouveia, Jo~
ao Mar
os
ffmd,mpg,jmar
osgmath.ist.utl.pt
Center for Logi
and Computation, Department of Mathemati
s, IST
Lisbon, Portugal
There are several
omputerized tools to automati
ally and/or intera
tively prove theorems of given dedu
-
tive systems. In general, su
h tools deal with only one spe
i
dedu
tive system or a small
lass thereof
(for example, Otter deals with
lassi
al rst-order logi
with equality, NUPRL deals with intuitionisti
type theory, ModLeanTAP deals with a range of propositional modal logi
s). The software Isabelle is
a generi
theorem-proving environment that allows for the denition and use of dedu
tive systems for
many dierent logi
s. The dedu
tion rules may be spe
ied in dierent formats: natural dedu
tion rules,
Hilbert-style axioms and rules, sequent-style rules, tableau rules, et
. In this way, using Isabelle, it is
possible to dene and experiment with dierent logi
s, sin
e the user may implement the dedu
tion rules
she sees t.
Obviously, some initial training is needed for the task of using Isabelle in order to dene and experiment
with new logi
s. However, it is our experien
e that only a few main
on
epts are, in fa
t, essential. The
authors have been involved in tea
hing a logi
ourse for undergraduate students. The system Isabelle
was used for representation and use of natural dedu
tion systems for propositional, rst-order and modal
logi
s. Students learned how to dene logi
s and how to prove theorems and
he
k inferen
es in those
logi
s. From what they learned in one semester, most students were able to su
essfully deliver the nal
assignment that in
luded the denition of a (new) hybrid logi
, involving quantiers and modalities. This
tea
hing experien
e is reported in this paper, where you will nd the basi
on
epts needed to dene and
experiment with a logi
in Isabelle.
1 Introdu
tion
At the moment, there is a sizable number of models of logi
software available, and seemingly
there is still a strong impulse at the logi
ommunity to go and design their own personalized
proof assistant, for their own preferred dedu
tive systems. Some of the already existing logi
software are highly
exible, and are intended as generi
environments for doing a number of
a
tivities you would like the
omputer to help you with: doing intera
tive proofs, writing some
formally veried mathemati
s, writing and
he
king formal spe
i
ations of all sorts, and, why
not, doing some me
hanized reasoning, that old dream of Leibniz.
Su
h highly
exible models of logi
software have a strong potentiality still largely to be
unleashed in their use in
omputer-based learning and their integration to the standard set
of tea
hing strategies and resour
es. Used as laboratories for experimentation with abstra
t
entities, the right software
an turn a
omputer into a sort of `bubble
hamber' where ideas
an
be tested and improved |or reje
ted. Moreover, in the provo
ative words of Edward Feigenbaum
(Glei
k, 1987),
omputers
an also help us in `
reating intuition' about
ertain subje
ts. This
outlook
onverts the
omputer into a genuine tool for doing philosophi
al and mathemati
al
resear
h.
We had a simple goal in mind: To use the
omputer to tea
h logi
to undergraduate students.
Our main aim, however, was not (only) to tea
h the students about this and that dedu
tive
1
system, but to provide them with some expertise on using an extensively
ustomizable tool in
whi
h they would be able to dene and work with their own logi
s, if that be the
ase. After
some prospe
ting and experimentation with the existing proof assistants, Isabelle
alled our
attention. This is a software with an awful lot of logi
built-in in its design and implementation.
We are talking about a logi
al framework whose meta-logi
is Intuitionisti
Higher-Order Logi
with three main
omponents: (i) a meta-impli
ation that
an be used in laying down the obje
t-
logi
rules (see se
tion 2.2) of the spe
i
obje
t-logi
being thereby represented and that takes
are of the appli
ation of those rules and the dis
harge of assumptions; (ii) a meta-universal
quanti
ation that
an be used in laying down a number of obje
t-language quantiers (see
se
tion 2.6); (iii) a meta-equality that
an be used in laying down abbreviations as rewrite
rules (see se
tion 2.3). We are talking about a me
hanizable theorem prover (see se
tion 2.5)
where: (i) obje
t-logi
formulas are -terms disambiguated by way of a priority grammar (see
se
tion 2.1); (ii) rules of the obje
t-language are represented not as fun
tions but as formulas
of the underlying higher-order logi
; (iii) the
ombination and appli
ation of those rules is
performed by way of a uniform method of inferen
e | higher-order resolution; (iv) ta
ti
s are
implemented independently of the obje
t-logi
being represented (see se
tion 2.4). We are talking
about a simply typed environment where obje
t-language formulas
an be heavily stru
tured
(see se
tions 2.7 and 3), and very pre
ise spe
i
ations
an be met with.
Finally, it should be noted that Isabelle is written over ML (Paulson, 1996), a fun
tional
programming language that
an
ome to help at any point where even more expressivity is
needed. ML was designed pre
isely to serve as an implementation language for theorem provers.
This paper is not about the logi
behind Isabelle (for that you may
onsult the appropriate
handbooks), but about how Isabelle
an be used to look ahead into a number of new user-dened
logi
s. We will not be worried here about proving properties about our obje
t-logi
s, but about
how these very logi
s
an be dened,
hanged, and used. To that intent, the following se
tions
will systemati
ally illustrate the use of Isabelle in entirely pedestrian terms.
2.1 Language
The denition of the language and dedu
tive system of a given logi
onstitutes a theory of
Isabelle's meta-logi
. Ea
h theory must be spe
ied in one le (with extension .thy).
Conne
tives are internally represented using -
al
ulus and, therefore, understood as fun
-
tions that for given argument formulas return a new formula. For example,
onj(A,B) represents
the
onjun
tion of A and B. In this way
onj is a fun
tion that, given two argument formulas,
2
returns another a formula. The denition of this fun
tion is
onj::[o,o℄ >o, where o is the type
=
of formulas. The more usual notation A&B may also be used (and is internally translated to
onj(A,B)). Isabelle's
ode and notation for this
onne
tive is:
The values [36,35℄ 35 spe
ify (using a priority grammar) the priority of
onjun
tion (with
respe
t to other
onne
tives) and also that it is right-asso
iative. In a priority grammar, prior-
ities are assigned to o
urren
es of non-terminal symbols in a produ
tion, e.g. A35 A36 A35 ) ^
(that
orresponds to the priorities in rule
onj above). Terminal symbols are assigned priority
1 . Derivations are as usual, with the dieren
e that the o
urren
e of a non-terminal symbol
an only be substituted using produ
tions whose left-hand symbol has greater or equal priority.
^
For example, in A36 A35 only A35
an be substituted using A35 ) ^
A36 A35 resulting in
A 36^ A ^
36 A . This pro
ess disambiguates the grammar and, in this example, justies that
35
onjun
tion is right-asso
iative. Other
onne
tives are dealt with in a similar way and the as-
signment of dierent priorities to dierent
onne
tives sets its pre
eden
e. For example, the fa
t
that
onjun
tion has pre
eden
e over disjun
tion is
oded by disj::[o,o℄ >o (" | " [31,30℄ 30).
=
'1
This rule is represented by the metaformula P&Q > P where meta-impli
ation ( >) has
== ==
the intuitive meaning that the
onsequent
an be proved provided that the ante
edent has been
proved. On the other hand, the metaformula P >(Q >P&Q) means that P&Q
an be proved
== ==
provided that both P and Q have been proved. It
an also be written as [jP;Qj℄ > P&Q and it is
==
3
PROPOSITIONAL = Pure +
types
o
arities
o :: logi
onsts
Trueprop :: o => prop ("( )" 5)
(* Conne
tives *)
verum, falsum :: o
neg :: o => o (" " [40℄ 40)
onj :: [o, o℄ => o (" & " [36,35℄ 35)
disj :: [o, o℄ => o (" | " [31,30℄ 30)
imp :: [o, o℄ => o (" --> " [26,25℄ 25)
iff :: [o, o℄ => o (" <-> " [26,25℄ 25)
(* Abbreviations *)
verum def "verum == falsum-->falsum"
neg def "P == P-->falsum"
iff def "P<->Q == (P-->Q) & (Q-->P)"
end
The theory Hilbert.thy that
odes a Hilbert system for this logi
an be written in a similar way.
We omit the denition of the language (for simpli
ity we
onsider only impli
ation and falsum
as primitive
onne
tives) and present a set of suitable axiom s
hemas and the a
ompanying
inferen
e rule.
Hilbert = Pure +
...
rules
ax1 "A --> (B --> A)" (* Axioms *)
ax2 "(A-->(B-->C))-->((A-->B)-->(A-->C))"
ax3 "falsum-->A"
ax4 "((A-->falsum)-->falsum)-->A"
mp "[|A-->B;A|℄==>B" (* Rule *)
...
4
2.4 Using theories
In general, proofs in Isabelle are ba
kward proofs, meaning that the user starts by stating the goal
and applies the inferen
e rules ba
kwards (from the
on
lusion to the premises). Ea
h premise
onstitutes a new subgoal to be proved. The proof ends when no further subgoals remain to
be proved. The initial goal
an be either a formula (e.g. A-->(B-->A)) or a metaformula (e.g. [|
A&B; B-->C |℄ ==> C). In the rst
ase the goal
orresponds to a theorem and in the se
ond to a
derived rule of the dedu
tive system.
Synta
ti
equation solving is
alled uni
ation and the pro
edure to nd solutions is
alled
resolution. The
on
ept of uni
ation is fundamental to understanding how rules
an be applied
to a (sub)goal. Rules are represented (internally) as s
hema metaformulas. For example the
rule
onjI, i.e. [| P;Q |℄ ==> P&Q, is, in fa
t, represented as [| ?P;?Q |℄ ==> ?P&?Q. The variables
?P and ?Q are s
hema variables, that is, variables that may be instantiated by any formula. This
represents the fa
t that this rule
an be applied to any formula of the form ?P&?Q. In order
to
he
k whether a given formula F has that form, an equation has to be solved, namely the
equation ?P&?Q=F. The equation ?P&?Q=A&(B-->C) has the solution ?P=A and ?Q=B-->C. In this way,
the me
hanism underlying the appli
ation of a rule to a goal
orresponds to the uni
ation of the
on
lusion of the rule with the goal. New subgoals appear
orresponding to the premises of the
rule (where appropriate s
hema variables have been repla
ed by the
orresponding solution of
the equation). In the following example we establish [| A; C |℄ ==> A & (B-->C) using the theory
PROPOSITIONAL.
5
The
ommand by (resolve ta
[
onjI℄ number ) applies the rule
onjI to the subgoal identied
by number (similarly for by (resolve ta
[impI℄ number )). Some subgoals do not need rules to be
proved sin
e they are premises or uniable with premises. These are proved using by (assume ta
number ). In general, (sub)goals are proved by applying a ta
ti
. The most important ta
ti
s are
the previously referred ta
ti
s of resolution and assumption, the ta
ti
resolve ta
[rule ℄ number
and the ta
ti
assume ta
number . Moreover, rta
abbreviates resolve ta
and ata
abbreviates
assume ta
. Also, br rule i abbreviates by (rta
[rule ℄ i ) and ba i abbreviates by (ata
i ).
The variable it
ontains the value of the presently evaluated expression. We will omit the
orresponding output line whenever it is not relevant.
It is worth noti
ing that by establishing [| A; C |℄ ==> A&(B-->C) one has established a derived
rule of the
urrent dedu
tive system. This rule
an be used in other proofs. For that purpose
a name has to be assigned to it using qed "newName";. Afterwards one may use by (resolve ta
[newName℄ number ) to apply the new rule to a subgoal. The rule will only be available in the
urrent session. A simple way of making new rules available in all sessions is to write down their
proofs in a le with extension ML, named after the
urrent theory, in this
ase PROPOSITIONAL.ML.
It is also possible to prove more
omplex metaformulas. For example the metaformula
[|[|P==>Q;P|℄==>R; P==>Q; P|℄==>R is a rule having other rules (e.g. [|P==>Q;P|℄==>R) as premises.
Su
h rules may be taken as primitive rules in extensions of natural dedu
tion systems like
those proposed in S
hroeder-Heister (1984). Whenever the ante
edent
ontains non-atomi
metaformulas the result of Goal is the list of metarules asso
iated to the premises.
> Goal "[|[|P==>Q;P|℄==>R; P==>Q; P|℄==>R";
Level 0 (1 subgoal)
R
1. R
val it = ["[| P ==> Q; P |℄ ==> R" [.℄, "P ==> Q" [.℄, "P" [.℄℄ : Thm.thm list
Note that the goal to be established is simply R and there are three metarules, ea
h one asso
iated
with a
orresponding premise. These
an also be re
overed with premises(). Ea
h metarule states
that ea
h premise is derivable from itself and is of the form [Pr℄ Pr (with the
on
lusion to the
right). The previous output hides the metaformulas within [℄ (to see them use set show hyps;).
It is useful to assign a name to ea
h metarule in the list, so that
an be referred to later on.
This
an be a
hieved using val [pr1,pr2,pr3℄ = premises(); that assigns to the rst element of
the list the name pr1, to the se
ond the name pr2 and to the third pr3. This
an also be a
hieved
dire
tly by using
> val [pr1,pr2,pr3℄=Goal "[|[|P==>Q;P|℄==>R; P==>Q; P|℄==>R";
Level 0 (1 subgoal)
R
1. R
val pr1 = "[| P ==> Q; P |℄ ==> R" [.℄ : Thm.thm
val pr2 = "P ==> Q" [.℄ : Thm.thm
val pr3 = "P" [.℄ : Thm.thm
The proof is as expe
ted, noting that the names of the premises are used.
> br pr1 1;
Level 1 (2 subgoals)
R
1. P ==> Q
6
2. P
> br pr2 1;
Level 2 (2 subgoals)
R
1. P ==> P
2. P
> ba 1;
Level 3 (1 subgoal)
R
1. P
> br pr3 1;
Level 4
R
No subgoals!
To establish a goal involving abbreviations, e.g. P<->P, the abbreviated expressions must be
rewritten (using the
onvenient rewrite rules, in this
ase neg def and iff def). One way of doing
this is by using the
ommand Goalw [def1,def2,...℄ metaformula that rewrites the abbreviations
in metaformula using the denitions in the argument list:
> Goalw [neg def,iff def℄ "P <-> P";
Level 0 (1 subgoal)
P<->P
1. (((P-->falsum)-->falsum)-->P)&(P-->(P-->falsum)-->falsum)
denotes a sequent with ante
edent A,B-->C and
onsequent D, E&F. Variables prexed by $ are
list variables. The sequent
"$H, P, $G |- $E, P, $F"
odes the left-introdu
tion rule for impli
ation. Lists and sequents are provided by the the-
ory Sequents.thy available in Isabelle's distribution. The following theory SPROP.thy denes the
sequent
al
ulus for
lassi
al propositional logi
by providing the syntax of formulas and the
sequent rules.
SPROP = Sequents +
onsts
Trueprop :: "two seqi"
"Trueprop" :: "two seqe" ("(( )/ |- ( ))" [6,6℄ 5)
7
(* Conne
tives *)
falsum,verum :: o
neg :: o => o (" " [40℄ 40)
onj :: [o, o℄ => o (" & " [36,35℄ 35)
disj :: [o, o℄ => o (" | " [31,30℄ 30)
imp :: [o, o℄ => o (" --> " [26,25℄ 25)
iff :: [o, o℄ => o (" <-> " [26,25℄ 25)
(* Abbreviations *)
verum def "verum == falsum-->falsum"
iff def "P<->Q == (P-->Q) & (Q-->P)"
neg def "P == P-->falsum"
end
ML
val parse translation = [("Trueprop",Sequents.two seq tr "Trueprop")℄;
val print translation = [("Trueprop",Sequents.two seq tr' "Trueprop")℄;
The reason for the use of both Trueprop and Trueprop is that there are, in fa
t, two dierent repre-
sentations of lists, the one referred above (and
alled the external representation) and a fun
tional
representation of lists (
alled the internal representation). Trueprop(A,B), also written A|-B, is a
sequent where the lists involved are written in the external representation. Trueprop(alpha,beta)
is the sequent where the lists involved are written in the internal representation. The two lines
in ML
ode at the end of the above theory provide fun
tions that translate between the two
representations of sequents.
In order to use this theory (with use thy) the system must load the theory Sequents:
Before illustrating the use of this theory with an example, we present the notion of ta
ti
al.
Ta
ti
als are forms of
ombining ta
ti
s. Useful ta
ti
als are the iterative
ombinator of ta
-
ti
s REPEAT and the alternative
ombinator ORELSE. The ta
ti
REPEAT ta
ti
orresponds to the
repeated appli
ation of the argument ta
ti
until it fails. The ta
ti
ta
ti
1 ORELSE ta
ti
2
or-
responds to ta
ti
1 alone when the appli
ation of ta
ti
1 su
eeds. Otherwise it
orresponds
to ta
ti
2 alone. Ta
ti
als are useful in intera
tive proofs and they are the fundamental tools
in developing automati
proving te
hniques.
The proof of |-(A-->(B-->C))-->((A-->B)-->(A-->C)) begins with three appli
ations of resolu-
tion with impR to the rst subgoal. These three steps may be simplied by using REPEAT (rta
impR 1).
8
> Goal "|- (A-->(B-->C))-->((A-->B)-->(A-->C))";
Level 0 (1 subgoal)
|- (A --> B --> C) --> (A --> B) --> A --> C
1. |- (A --> B --> C) --> (A --> B) --> A --> C
> br impL 1;
Level 2 (2 subgoals)
|- (A --> B --> C) --> (A --> B) --> A --> C
1. A --> B, A |- C, A
2. B --> C, A --> B, A |- C
> br axS 1;
Level 3 (1 subgoal)
|- (A --> B --> C) --> (A --> B) --> A --> C
1. B --> C, A --> B, A |- C
It may be helpful to exhibit parentheses making formulas more readable. The
ommand set
show bra
kets; sets the
orresponding
ag to true.
As referred above, sequent
al
ulus provides a de
ision pro
edure for validity (in
lassi
al propo-
sitional logi
). In fa
t, ea
h (ba
kward) appli
ation of the rules de
reases the
omplexity of the
formulas involved in the sequent. In the end, subgoals
onsist of axioms or sequents without
onne
tives that en
ode a
ounter-example for the original goal.
With this de
ision pro
edure in mind, one
an easily write down a ta
ti
that su
eeds
whenever the original goal is a valid sequent and fails otherwise. First one has to dene a
ta
ti
that
orresponds to the appli
ation of some rule. This ta
ti
should try the rules in
some order until it nds one that unies. In this dedu
tive system, the order of appli
ation of
rules is irrelevant. It is more eÆ
ient to prefer rules that eliminate subgoals or introdu
e less
new subgoals over other rules. One possible
hoi
e is to try appli
ation of rules in this order:
axS,falsumL,impR,
onjL,disjR,impL,
onjR,disjL. The ta
ti
9
applies the axiom or some rule to the rst subgoal and fails only if none is appli
able. Repeated
appli
ation of this ta
ti
is a
hieved by
REPEAT ((rta
axS 1) ORELSE ... ORELSE (rta
disjL 1)).
Given a valid sequent, the appli
ation of this ta
ti
su
eeds, sin
e the rst subgoal is repeatedly
simplied until an instan
e of the axiom axS is obtained and eliminated. At this point, if there
are further subgoals, the se
ond be
omes the rst and this pro
ess goes on until no subgoal is
left. If the original sequent is not valid, the ta
ti
fails in the rst subgoal
onsisting of a sequent
without
onne
tives that is not an axiom. In this
ase more subgoals
an be left unworked. In
the following example the original sequent is valid. The above ta
ti
is given the name ta
Seq1.
> val ta
Seq1= REPEAT ((rta
axS 1) ORELSE ... ORELSE (rta
disjL 1));
> Goal " |- (A --> B --> C) --> (A --> B) --> A --> C";
Level 0 (1 subgoal)
|- (A --> B --> C) --> (A --> B) --> A --> C
1. |- (A --> B --> C) --> (A --> B) --> A --> C
> by ta
Seq1;
Level 1
|- (A --> B --> C) --> (A --> B) --> A --> C
No subgoals!
It is not diÆ
ult to improve the previous ta
ti
to also work out the remaining subgoals. In
this way, for invalid sequents, the remaining subgoals will en
ode the
ounter-examples. For
that purpose one simply has to rewrite the previous ta
ti
in su
h a way that it
an be applied
to subgoals other than the rst. The rst step is to dene a fun
tion that, to ea
h subgoal
i asso
iates the ta
ti
(rta
axS i) ORELSE ... ORELSE (rta
disjL i). This is a
hieved by val
ta
Seqfun = fn i => (rta
axS i) ORELSE ... ORELSE (rta
disjL i).
In the previous
ommand the intended fun
tion (fn i => (rta
axS i) ...) is given the name
ta
Seqfun. Finally, the improved ta
ti
is given by REPEAT FIRST ta
Seqfun that repeatedly applies
ta
Seqfun to ea
h subgoal (starting with the rst). When no further appli
ations of ta
Seqfun
are possible, the next subgoal is worked out. For
onvenien
e, the name ta
Seq is given to
REPEAT FIRST ta
Seqfun. Note that the behavior of the new ta
ti
on valid sequents is the same
as the old ta
ti
. We illustrate the new ta
ti
using the previous (invalid) sequent.
> Goal "|- (A --> D --> C) --> (A --> B) --> A --> E";
Level 0 (1 subgoal)
|- (A --> D --> C) --> (A --> B) --> A --> E
1. |- (A --> D --> C) --> (A --> B) --> A --> E
10
> by ta
Seq;
Level 1 (2 subgoals)
|- (A --> D --> C) --> (A --> B) --> A --> E
1. B, A |- E, D
2. C, B, A |- E
rules (* Quantifiers *)
allI "(!!x. P(x)) ==> (ALL x. P(x))"
allE "(ALL x. P(x)) ==> P(t)"
exI "P(t) ==> (EX x. P(x))"
exE "[| EX x. P(x); !!x. (P(x) ==> R) |℄ ==> R"
end
The theory uses the
onne
tives and rules of
lassi
al propositional logi
and adds quantied
formulas and their rules. It is noteworthy that term is not a type but a
lass to whi
h any term
type must belong. For instan
e, noting that 'a is a variable ranging over types, the fun
tion all
:: ('a::term=>o)=>o is a fun
tion that asso
iates a formula to a predi
ate (on its turn, a fun
tion
that asso
iates a formula to a term). Finally, in rule exE, the fa
t that R does not depend on
x
odes the
ondition that x
annot o
ur free in R. In the next example we want to establish
11
[| ALL x. Q(f(x)); ALL x. (P(x)-->Q(x)) |℄ ==> ALL x. Q(f(g(x))) using the theory CLASSIC. It seems
easy, at rst glan
e, sin
e the
on
lusion follows from the rst premise. We rst apply rule allI
and then rule allE.
> Goal "[| ALL x. Q(f(x)); ALL x. (P(x)-->Q(x)) |℄ ==> ALL x. Q(f(g(x)))";
Level 0 (1 subgoal)
[|ALL x. Q(f(x)); ALL x. P(x)-->Q(x)|℄ ==> ALL x. Q(f(g(x)))
1. [| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(g(x)))
> br allI 1;
Level 1 (1 subgoal)
[| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(g(x)))
1. !!y. [| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> Q(f(g(y)))
> br allE 1;
Level 2 (1 subgoal)
[| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(g(x)))
1. !!y. [| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(x)
> ba 1;
** by: ta
ti
failed Ex
eption- ERROR raised
When applying allE, the uni
ation of its
on
lusion %P. %t. P(t) with Q(f(g(y))) has more than
one solution. Isabelle displays rst the result of -redu
ing %P. %t. P(t) into %t. Q(t) and the latter
into Q(f(g(y)). In this
ase, however, this is not the suitable solution sin
e ALL x. Q(x) does not
unify with the hypothesis ALL x. Q(f(x)). Isabelle's unifying pro
edure is
lever in produ
ing all
possible solutions (and in rst-order logi
there
an be an innite number of them) by using lazy
evaluation (evaluation on demand). To demand Isabelle to
onsider another solution we use the
ommand ba
k().
> ba
k();
Level 2 (1 subgoal)
[| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(g(x)))
1. !!y. [| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(x))
> ba 1;
Level 3
[| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(g(x)))
No subgoals!
The -redu
tion of %P. %t. P(t) into %t. Q(f(t)) and the latter into Q(f(g(y)) is now
onsidered.
The rest of the proof is straightforward.
An alternative approa
h uses the ta
ti
res inst ta
[("v1 ","f1 "),...,"vn ","fn ")℄ rule number ,
that
orresponds to the use of resolution with rule to the subgoal identied by number for
ing
the s
hema variable v1 to be instantiated into f1 . . . and vn into fn . In this
ase we
an use
res inst ta
just after the appli
ation of the rule allI:
...
> by (res inst ta
[("t","g(y)")℄ allE 1);
Level 2 (1 subgoal)
[| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(g(x)))
1. !!y. [| ALL x. Q(f(x)); ALL x. P(x)-->Q(x) |℄ ==> ALL x. Q(f(x))
12
2.7 Labeled modal logi
s
The theories previously des
ribed are
losely related to similar theories provided by Isabelle's
distribution. Although theories for modal logi
s (in
luding sequent
al
ulus) are also available in
that distribution we
hoose to present theories based on labeled dedu
tion, as in Vigano (2000).
Labeled dedu
tion internalizes semanti
notions in the obje
t-language and dedu
tive system.
Dedu
tive systems for normal modal logi
s
an thus be
ome modular in the sense that they
are obtained simply by adding suitable rules (representing the properties of the a
essibility
relation) to the dedu
tive system of modal logi
K . With labeled dedu
tion as the
hoi
e of
formalization for our modal languages we
an es
ape the traditional diÆ
ulties that surfa
e
when the
orresponding logi
al systems are represented, as advan
ed in (Paulson, 1990).
Formulas are obtained by prexing a term (usually a variable) to a modal formula. For
instan
e, x : ( ! ) is a formula. Informally, this formula means that ( ! ) holds
in the world denoted by x. These are
alled generalized modal formulas. Formulas x Rel y state
that the world denoted by y is a
essible from the world denoted by x and are
alled relational
modal formulas. More generally, they may also involve terms as in t1 Rel t2 . By the present
_ 8
onstru
tion, strings su
h as (x : ) (y : ) and ( x)(x Rel x) are not formulas of K |but
they will be formulas of the hybrid logi
presented in the next se
tion.
The theory for the minimal normal modal logi
K is presented below. There are three types
of synta
ti
entities involved in that theory: tm for terms (that prex modal formulas), sbf for
modal (sub)formulas and o for formulas. The latter are either generalized formulas (built with
gf) or relational formulas (built with rf). The rules for ([℄) and (<>) are similar to the rules
for the universal and the existential quantiers. For instan
e, the rule boxI (introdu
tion of )
asserts that x:[℄P follows from the proof that P holds in y for arbitrary y related to x. We omit
most of the propositional fragment as straightforward.
K = Pure +
lasses
term < logi
types
tm (* the type of terms for labels *)
sbf (* the type of modal subformulas *)
o (* the type of formulas *)
arities
tm :: term
sbf :: logi
o :: logi
onsts (* Formula Generators *)
gf :: [tm,sbf℄ => o (" : " [0,0℄ 10)
rf :: [tm,tm℄ => o (" Rel " [0,0℄ 10)
Trueprop :: o => prop ("( )" 5)
(* Modal (sub)formulas *)
and :: [sbf, sbf℄ => sbf (" & " [36,35℄ 35)
...
box :: sbf => sbf ("[℄ " [40℄ 40)
dia :: sbf => sbf ("<> " [40℄ 40)
rules
(* Propositional *)
onjI "[| x:P; x:Q |℄ ==> x:P&Q"
13
...
(* Modal Operators *)
boxI "(!!y. (x Rel y ==> y:P)) ==> x:[℄P"
boxE "[| x:[℄P; x Rel y|℄ ==> y:P"
diaI "[| x Rel y; y:P|℄ ==> x:<>P"
diaE "[| x:<>P; (!!y. [|x Rel y; y:P|℄==> z:Q)|℄==> z:Q"
(* Abbreviations *)
verum def "x:verum == x:falsum-->falsum"
neg def "x:P == x:P-->falsum"
iff def "x:P<->Q == x:(P-->Q) & (Q-->P)"
The theory for KT
an be obtained from the theory for K by adding the axiom (a rule with
no premises) of re
exivity (x Rel x). The theory for KB adds to the theory for K the rule of
symmetry (x Rel y ==> y Rel x), and the theory for S 5 adds to the theory for K both the axiom
of re
exivity and the rule of symmetry, together with the rule of transitivity ([|x Rel y; y Rel
z|℄ ==> x Rel z). Many other modal systems
an be formalized in a similar way. To dene more
omplex systems su
h as the normal modal logi
of
on
uen
e, one might make use of terms in
the labels. In this
ase, we add to the theory for K a Skolem fun
tion as a new
onstru
tor of
the form h :: [tm,tm,tm℄ => tm, and we add also the rules [|x Rel y; x Rel z|℄ ==> y Rel h(x,y,z)
and [|x Rel y; x Rel z|℄ ==> z Rel h(x,y,z).
3 A hybrid logi
The issues addressed before are part of the syllabus of a
ourse in logi
for undergraduate
students in Mathemati
s and in Computer S
ien
e, in
luding the logi
s previously referred. The
nal assignment in
luded the denition of a theory in Isabelle representing the hybrid logi
des
ribed in the following. To learn more about hybrid languages, see Bla
kburn and Seligman
(1998).
The hybrid logi
to be dened, using only Pure, is a labeled modal logi
where quanti
ation
8
over worlds is allowed. Formulas like x(x Rel x) !8 x(x : ! x : )
an be written in the
logi
. In this logi
the atomi
formulas are generalized modal formulas and relational modal
formulas, dened as in se
tion 2.7. However, falsum, negation, disjun
tion and are the only
onne
tives herein
onsidered as primitive for the
onstru
tion of the atomi
formulas (verum,
onjun
tion, impli
ation, equivalen
e and are taken as abbreviations). The set of formulas
is obtained by
losing the latter set of atomi
formulas with negation, disjun
tion and the
universal quantier (
onjun
tion, impli
ation, equivalen
e and the existential quantier are
8
taken as abbreviations). In parti
ular, strings su
h as ( x) and (x : ) will not
onstitute
formulas of the present language. Note that the propositional
onne
tives o
ur in formulas
_
and also within atomi
formulas. For example, in the atomi
formula x : ( ), disjun
tion
involves two modal subformulas whereas in the (non-atomi
) formula (x : ) (x : ) _
it involves two formulas of the hybrid logi
. The intended interpretation assigns to both
formulas the same meaning (justi
ation: ( _ ) is true at the world x if and only if either
is true at x or is true at x) and the dedu
tive system must be able to prove them
equivalent. Moreover, the derived rules for all symbols dened by abbreviation should be
made available by the student.
Most students were able to su
essfully deliver the
orresponding Isabelle theory. One pos-
sible solution, using natural dedu
tion, follows. In this solution we use polymorphism to dene
14
the
onne
tives that are
ommon to the two dierent types of `formulas', the modal subfor-
mulas and the formulas themselves. For example, not::('a::logi
) => 'a denes a polymorphi
operation not that takes any type of
lass logi
and returns a value of that type. In our
ase
we have two possible types, namely sbf (for modal subformulas) and o (for formulas). In this
way not::('a::logi
) => 'a simultaneously denes the two fun
tions (
onne
tives) not::sbf =>
sbf and not::o => o. In general, one has to provide introdu
tion and elimination rules for both
onne
tives. However, our solution provides rules only for not::o => o and provides further rules
to transform subformulas into formulas and vi
e-versa (when appli
able). For example, in order
to
on
lude x:P one may rst
on
lude (x:P) and then apply the rule that transforms it into
x:P. The new rules for negation are negOut "x:(P) ==> (x:P)" and negIn "(x:P) ==> x:(P)".
By using su
h transformation rules the introdu
tion and elimination rules for not::sbf => sbf
an be derived in this system. Similar
onsiderations apply to other
onne
tives.
HYBRID = Pure +
lasses
term < logi
default
term
types
tm (* the type of terms for labels *)
sbf (* the type of modal subformulas *)
o (* the type of formulas *)
arities
tm :: term
sbf :: logi
o :: logi
onsts
(* Formula Generators *)
labf :: [tm,sbf℄ => o (" : " [0,0℄ 45)
relf :: [tm,tm℄ => o (" Rel " [0,0℄ 45)
Trueprop :: o => prop ("( )" 5)
(* For modal subformulas only *)
verum, falsum :: sbf
box :: sbf => sbf ("[℄ " [50℄ 50)
dia :: sbf => sbf ("<> " [50℄ 50)
(* Quantifiers (for formulas only) *)
all :: ('a => o) => o (binder "ALL " 10)
ex :: ('a => o) => o (binder "EX " 10)
(* Conne
tives for both modal subformulas and formulas *)
not :: 'a::logi
=> 'a (" " [40℄ 40)
and :: ['a::logi
, 'a℄ => 'a (" & " [36,35℄ 35)
or :: ['a::logi
, 'a℄ => 'a (" | " [31,30℄ 30)
imp :: ['a::logi
, 'a℄ => 'a (" --> " [26,25℄ 25)
iff :: ['a::logi
, 'a℄ => 'a (" <-> " [26,25℄ 25)
rules
(* Conne
tives *)
abs "(P ==> y:falsum) ==> P"
negE "[| P; P |℄ ==> Q"
negI "(P ==> y:falsum) ==> P"
15
negOut "x:(P) ==> (x:P)"
negIn "(x:P) ==> x:(P)"
disjIr "P ==> P|Q"
disjIl "Q ==> P|Q"
disjE "[| P|Q; P ==> R; Q ==> R |℄ ==> R"
disjOut "x:(P|Q) ==> (x:P)|(x:Q)"
disjIn "(x:P)|(x:Q) ==> x:(P|Q)"
(* Modal Operators *)
boxI "(!!y. (x Rel y ==> y:P)) ==> x:[℄P"
boxE "[| x:[℄P; x Rel y |℄ ==> y:P"
(* Quantifier *)
allI "(!!y. P(y)) ==> (ALL x. P(x))"
allE "(ALL x. P(x)) ==> P(z)"
(* Abbreviations *)
verum def "verum == falsum-->falsum"
onj def "P&Q == ((P)|(Q))"
imp def "P-->Q == (P)|Q"
iff def "P<->Q == (((P)|Q) | (P|(Q)))"
dia def "<>P == ([℄P)"
ex def "EX x. P(x) == (ALL x. P(x))"
end
Note a dieren
e between the abbreviations of the theory HYBRID and those of the theory K, in
se
tion 2.7. In the present theory, a
onne
tive like <->
an be used to generate both atomi
formulas (as in P<->Q) and formulas of the above hybrid logi
(as in x Rel y <-> z:[℄P). Therefore,
the rewrite rules must now be laid down so as to apply to both situations.
We illustrate the theory with some examples. In the rst one we prove the derived rule
for the elimination of disjun
tion of modal subformulas. Re
all from se
tion 2.4 that when the
ante
edent
ontains non-atomi
metaformulas it is
onvenient to asso
iate a name to ea
h of the
elements of the result of Goal.
16
Other examples follow. Only the used rules are shown. In the very last example, we use the
ta
ti
rotate ta
number steps , that
orresponds to a left permutation of the subgoal identied
by number by a number of steps .
Goal "(x:(A&B))<->(x:A)&(x:B)";
br eqI 1; br
onjOut 1; ba 1; br
onjIn 1; ba 1;
Goal "(ALL x y z. ((x Rel y) & (y Rel z) --> (x Rel z)))-->(ALL x. (x:([℄P-->[℄[℄P)))";
br impI 1; br allI 1; br impIn 1; br impI 1; br boxI 1; br boxI 1; br boxE 1;
ba 1; br impE 1; br
onjI 2; by (rotate ta
2 2); by (rotate ta
3 3); ba 2; ba 2;
by (res inst ta
[("z","yb")℄ allE 1); by (res inst ta
[("z","ya")℄ allE 1);
by (res inst ta
[("z","y")℄ allE 1); ba 1;
A
knowledgements
This work was partially supported by FCT and FEDER, namely, via the Proje
t FibLog
POCTI/MAT/372 39/2001 of CLC (Centro de Logi
a e Computa
~ao). The third author is
partially supported by FCT grant SFRH / BD / 8825 / 2002.
Referen
es
Bla
kburn, P. and Seligman, J.: 1998, What are hybrid languages?, in M. Kra
ht, M. de Rijke
and H. Wansing (eds), Advan
es in Modal Logi
, Volume 1, CSLI Publi
ations, Stanford,
California, pp. 41{62.
17
Glei
k, J.: 1987, Chaos, Making a New S
ien
e, Penguin Books, New York, NY.
Nipkow, T., Paulson, L. C. and Wenzel, M.: 2002, Isabelle/HOL, Vol. 2283 of Le
ture Notes in
Computer S
ien
e, Springer-Verlag, Berlin. A proof assistant for higher-order logi
.
Paulson, L. C.: 1990, Isabelle: The next 700 theorem provers, in P. Odifreddi (ed.), Logi
and
Computer S
ien
e, A
ademi
Press, pp. 361{386.
Paulson, L. C.: 1996, ML for the Working Programmer, Cambridge Univ. Press. 2nd edition.
S
hroeder-Heister, P.: 1984, A natural extension of natural dedu
tion, The Journal of Symboli
Logi
49(4), 1284{1300.
Troelstra, A. and S
hwi
htenberg, H.: 1996, Basi
Proof Theory, Cambridge Univ. Press.
Vigano, L.: 2000, Labelled Non-Classi
al Logi
s, Kluwer A
ademi
Publishers.
18