Adding the Axioms to Axiom
Total Page:16
File Type:pdf, Size:1020Kb
Adding the axioms to Axiom Towards a system of automated reasoning in Aldor Erik Poll Simon Thompson Computing Lab oratoryUniversityofKent CanterburyKent CT NF UK fEPollSJThompsongukcacuk Abstract Anumber of combinations of theorem proving and computer alge bra systems have b een prop osed in this pap er we describ e another namely a wayto incorp orate a logic in the computer algebra system Axiom We examine the typ e system of Aldor the Axiom Library Compiler and show that with some mo dications wecanusethede p endenttyp es of the system to mo del a logic under the CurryHoward isomorphism We giveanumb er of example applications of the logic we construct Intro duction Symbolic mathematical or computer algebra systems such as Axiom JS Maple and Mathematica are in everydayusebyscientists engineers and indeed mathematicians b ecause they provide a user with techniques of say integration which far exceed those of the p erson themselves and make routine many calculations which would have been imp ossible some years ago These systems are moreover taught as standard to ols within manyuniversity undergraduate programmes and are used in supp ort of b oth academic and commercial research There are however drawbacks to the widespread use of automated sup p ort of complex mathematical tasks which has b een widely noted Fateman Fat gives the graphic example of systems which will assume that a the basis that a has not been established This can have p oten on tially disastrous consequences for the naive user of the system or indeed if it o ccurs within a suciently complicated context any user Symb olic mathematics systems are also limited by their reliance on al gebraic techniques As Martin Mar remarks in p erforming op erations of analysis it might b e a precondition that a function b e continuous sucha prop erty cannot b e guaranteed by a computer algebra system alone All this makes the combination of computer algebra with theorem prov ing a topic of considerable interest the logical capabilities of a theorem prover could b e used to express the assumptions up on which an answer rests and in critical cases b e used to establish the truth of those assumptions The literature contains a number of dierent strategies prop osed for combining computer algebra and theorem proving see for instance Buc CH BCZ This pap er examines another prop osal that of using the typ e system of the Axiom JS computer algebra system to represent a logic and thus to use the constructions of Axiom to handle the logic and represent pro ofs and prop ositions in the same way as is done in theorem provers based on typ e theory such as Nuprl C or Co q Cor This pap er particularly explores the recent Axiom Library Compiler Aldor W which is unusual among computer algebra systems in be ing strongly typ ed and moreover in having a very powerful typ e system including dep endenttyp es The implementation of dep endenttyp es in Aldor is without evaluation of typ e expressions so each typ e expression is its own normal form and we show how this limits the expressivity of the dep endent typ es We pro p ose a mo dication of the Aldor system which allow the typ es to represent the prop ositions of a constructive logic under the CurryHoward corresp on tegrates a logic into the Aldor system and thus dence We argue that this in p ermits a variety of logical extensions to Aldor including adding pre and p ostconditions to function sp ecications axiomatisations to categories of mathematical ob jects as well as the ability to reason ab out the ob jects in Axiom The structure of the pap er is as follows Section intro duces Aldor and more details of Aldor dep endent typ es app ear in Section We show how a logic can be dened in a variant of the Aldor system in Section and Section gives some example applications We conclude with a discussion of related and future work An intro duction to Aldor previously known as AXIOM The Axiom Library Compiler Aldor W XL or A provides the user with a p owerful generalpurp ose programming language in which to mo del the structures of mathematics This language is functionally based and provides higher orderfunctions generators which b ear a strong relationship to list comprehensions and other features of mo d ern functional languages like Standard ML MTH and Haskell PH as well as b eing strongly typ ed The typ e system of Aldor Unusually among languages for computer algebra but in keeping with the functional scho ol Aldor is strongly typ ed and each declaration of a binding is accompanied by a declaration of the typ e of the value bound as in the example a Integer This contrasts with languages like Haskell in which typ es need not be de clared explicitly since they can b e deduced by the system In Aldor typ es have to b e declared explicitly since the typ e system has a variety of complex features including the following Overloading A single identier can be used to denote values of dierent typ e suchas Int Int and Int Bool Int Some supp ort is provided for users to resolve overloading when that proves to be necessary Co ercions Some courtesy co ercions are provided by the system automat ically these convert b etween multiple values a la LISP cross pro d ucts and tuples It is also p ossible to make explicit conversions by means of the coerce function from integers to oating p ointnumbers and so forth Typ es as values The typ e Type is itself a typ e it is by this means that the system supp orts functions over typ es suchas idType ty Type Type ty and explicit p olymorphism as in id ty Type x ty ty x This resembles the quantication in System F in which functions can dep end on typ e parameters and in F where functions can b e dened from typ es to typ es This is investigated further in Section Dep endent typ es Aldor p ermits functions to have dep endent typ es in which the typ e of a function result dep ends up on the value of a pa rameter An example is the function Most Haskell programmers would however tend to givetyp e declarations for their denitions since they serve b oth as an imp ortantcheck on the programmers intention as well as providing crucial do cumentation Note that this is a muchmore powerful overloading facility than that provided by Haskell typ e classes PH in whichoverloaded functions have to b e of the same arity vectorSum nInteger Vectorn Double in which the result of a function application say vectorSum has the typ e Vector Double b ecause its argument has the value In a similar way when the id function of denition is applied its result typ e is determined by the typ e which is passed as its rst argument We discuss this asp ect of the language in more detail in Section Variables The system is not fully functional containing as it do es variables which denote storage lo cations The presence of up datable variables inside expressions can cause sideeects whichmake the elucidation of typ es considerably more dicult There is a separate question ab out the role of mathematical variables in equations and the like and the role that they play in the typ e system of Axiom Categories and domains These features which provide a form of data abstraction are addressed in more detail in Section The Aldor typ e system can thus b e seen to b e highly complex and weshall indeed see that other features such as macros see Section complicate the picture further one of the asp ects of our work is to try to reachamore formal description of substantial parts of the typing mechanism of Aldor Categories and domains Axiom is designed to be a system in which to represent and manipulate mathematical ob jects of various kinds and supp ort for this is given bythe Aldor typ e system One can sp ecify what it is to be a monoid say by dening the Category called Monoidthus Monoid Category BasicType with f g This states that for a structure ov er a typ e to be a monoid it has to supply two bindings in other words a Category describ es a signature The rst name in the signature is and is a binary op eration over the typ e the second is an elementof There is no relation b etween Axioms notion of category and the notion from category theory In fact wehave stated slightly more than this as Monoid extends the cat egory BasicType which requires that the underlying typ e carries an equality op eration BasicType Category with f Boolean g We should observe that this Monoid category do es not imp ose any con straints on bindings to and we shall revisit this example in Section b elow Implementations of a category are abstract data typ es whichareknown in Axiom as domains and are dened as was the value a ab ove IntegerAdditiveMonoid Monoid add f Rep Integer import from Integer x y perrep x rep y per g The category of the ob ject b eing dened Monoid is the typeofthedomain which we are dening IntegerAdditiveMonoid The denition identies a representation typ e Rep and also uses the conversion functions rep and per whichhavethetyp es rep Rep per Rep In fact Rep rep and per are implemented using the macro mechanism of Aldor and so are eliminated b efore typ e checking Another asp ect of Aldor whichwe intend to explore are ways in whichthe macro system can be eliminated in favour of a prop erly typ e checked mechanism and so in particular supp ort the typ e abstraction machinery intro duced here Wehave seen already that one category can extend another this can b e seen as a form of inheritance Other op erations are available on categories including the Join op eration which