• No results found

A Term Rewrite System for Decimal Integer Arithmetic

N/A
N/A
Protected

Academic year: 2021

Share "A Term Rewrite System for Decimal Integer Arithmetic"

Copied!
45
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Bachelor Informatica

A Term Rewrite System for

Decimal Integer Arithmetic

Luca van der Kamp

June 8, 2016

Inf

orma

tica

Universiteit

v

an

Ams

terd

am

(2)
(3)

Abstract

A datatype for decimal number representation and arithmetic can be specified in a datatype defining rewrite system (DDRS). A system for natural numbers and an extension of this sys-tem to integer numbers, both based on digit tree constructors, are regarded. While ground-completeness, a required property of a DDRS, is already proved for the natural system, no proof for the integer system exists. Preceding attempts made to prove termination, ground-confluence, and thus ground-completeness using automatic tools have failed due to the complex-ity and size of the system. In this thesis, the integer system along with its natural counterpart are altered. This allows a termination proof for the integer system based on two standard termination methods: a transformational method followed by recursive path ordering with status.

(4)
(5)

Contents

1 Introduction 7

1.1 Related work . . . 8

1.2 Motivation . . . 9

1.3 Number representation and datatypes . . . 9

2 Term Rewriting 11 2.1 Preliminaries . . . 11 2.2 Termination . . . 12 2.3 Confluence . . . 13 2.4 Proving termination . . . 13 2.4.1 Multisets . . . 14

2.4.2 Recursive path ordering . . . 14

3 The Term Rewriting System for Decimal Numbers 19 3.1 Decimal representation with the digit tree constructor . . . 19

3.1.1 Semantics . . . 20

3.1.2 Notational conventions . . . 21

3.1.3 Ground normal forms . . . 21

3.1.4 The rules . . . 21 4 Termination proof 25 4.1 Termination ofNdt . . . 25 4.2 Termination ofZdt . . . 25 4.2.1 Termination ofZdt1 . . . 28 4.2.2 Termination ofZdt2 . . . 31 5 Ground-confluence proof 33 5.1 Ground-confluence . . . 33

(6)

6 The final TRSes 37 6.1 A minimal TRS . . . 37 6.2 A template for confluence . . . 38

7 Conclusion and Remarks 43

7.1 Discussion . . . 43 7.2 Future work . . . 44

(7)

Chapter 1

Introduction

To many, decimal number notation comes so natural that the details about such number systems are often forgotten. The same can apply to arithmetic with number representations. This might be the reason not many formal systems exist that specify datatypes for decimal notation. One way to establish a formal system for such datatypes is through the use of term rewrite systems (TRSes). TRSes that define datatypes are also called datatype defining rewrite systems (DDRSes).

This thesis presents a refinement of such a DDRS. This system represents numbers in deci-mal notation and allows for common arithmetic operations such as addition and multiplication. Two DDRSes are regarded: one for natural and one for integer numbers. Both DDRSes repre-sent numbers in positional decimal number notation. The DDRS for integers is an extension of the DDRS for naturals. These DDRSes were first defined in Bergstra and Ponse [2]. However, two important properties required for DDRSes, namely ground-confluence and termination, were left as open questions for the integer DDRS. Previous automated attempts of Kluiving and Woerkom [8] to prove these properties failed.

Altered TRSes based on the TRSes defined in Bergstra and Ponse [2] will be proposed. These alterations are motivated by failed attempts at proving termination of the original integer TRS and are intended to make the construction of a termination proof easier. Both termination and ground-confluence, and thus ground-completeness, of the new TRSes are proven. The new TRS is meant to function as a successor of the original rewrite system and therefore it is tried to keep the altered system closely related to the original. Unfortunately, these alterations do come with a trade-o↵. Therefore absolute superiority of the new TRS is not claimed.

There is some related work on TRSes for number representation; this will be discussed in the subsequent section. In Chapter 2, a short introduction to term rewriting is given. This includes some theory that is necessary for many termination proofs. The DDRSes that supply datatypes for decimal integers and naturals are presented and discussed in Chapter 3. The signature over which the TRSes are defined as well as some notational conventions adopted from Bergstra and Ponse [2] are also introduced.

(8)

In Chapter 4, the motivation for the alterations to the TRSes is given. Then, a termination proof for this altered TRS is given. Termination of the DDRS for naturals is proved automati-cally by Kluiving and Woerkom [8] using the automatic termination and complexity proof tool AProVE. In this thesis, another termination proof of this DDRS is given using recursive path ordering. This proof is a lot shorter than the automatic proof AProVE generates and will be used as a basis for the termination proof of the DDRS for integer representation.

In Chapter 5, confluence of the altered DDRS for integer representation is proved. Based on this proof more alterations to this DDRS are proposed in Chapter 6. Finally, Chapter 7 contains the conclusion and some concluding remarks.

1.1

Related work

Cohen and Watson [4] provide a rewrite system that represents numbers in base-4 positional notation. This system supports addition and multiplication. A number is represented by digits and the operator “.”. For example, the decimal number 12 is represented by “3.0”. Negative numbers are represented by prepending a number with the M IN constant. Thus 12 is represented by M IN.3.0. Local confluence of this TRS is proved. While the TRS is normalizing, termination of this TRS could not be proved.

Walters [11] constructs a rewrite system for decimal integers. This system supports addition and subtraction. Much like the system in Cohen and Watson [4], digits are appended to each other with a binary juxtaposition operator. Whereas in Cohen and Watson [4] the operator is visible, in Cohen and Watson [4] the operator is invisible. As such, the number 12 is represented as 12 which implies the application of the juxtaposition operator on the digits 1 and 2. Negative numbers can be represented by applying the unary “ ”. Termination is proved using an ad-hoc proof.

Walters and Zantema [12] specify three term rewrite systems for number representation. These systems support addition, subtraction, and multiplication. The first TRS for unary integer representation is based on a successor function, a predecessor function, and a zero constant. Negative integers are represented using the predecessor function.

Another TRS is given for representing naturals based on digit application. In this system, digits are unary post-fix functions. An invisible constant representing zero is also needed in order to start the unary digit string. The number 12 is represented by (()1)2 and zero is represented by the invisible constant (). This system only supports naturals.

The final system Walters and Zantema [12] provide is a rewrite system for integer represen-tations. This system extends a system defined in Walters [11] by supporting multiplication and an arbitrary number base. Termination of these TRSes is proved by recursive path ordering which, where required, is combined with semantic labeling and a transformational method. Ground-confluence of these systems is also proved.

In Contejean, March´e, and Rabehasaina [5] a system for natural number representation is given. Much like the digit application system in Walters and Zantema [12], numbers are represented by an “initial mark” followed by post-fix unary digit functions. The goal of this notation is to simplify termination proofs by not requiring rules similar to x ˆd(y ˆdz)! y ˆd(x+

z). This system supports addition as well as multiplication. This system is generalised to a non-terminating system that represents integers in 2-complement. An alternative terminating system is then proposed that represents integers in a balanced notation.

(9)

1.2

Motivation

Through the construction of a DDRS for natural and integer number representation, a further understanding of how the representation works will be obtained. The DDRS could also act as a basis for DDRSes representing rationals.

Because the DDRS also supports arithmetic operators, the DDRS can be used for compu-tation as well. The DDRS presented in this thesis supports addition and multiplication, but this system can be extended to support other operations as well.

The DDRS can also be extended to support rewriting from one representation to the other. An example of this is given in Bergstra and Ponse [2], where a DDRS representing decimals can rewrite a binary representation to decimal representation.

In Bergstra [1], it is also suggested that number representation through term rewriting can act as an innovative way to teach elementary mathematics. Through these DDRSes, positional number representation might also be taught to someone unfamiliar with the concept.

1.3

Number representation and datatypes

In order to discuss number representation, the distinction between representations of numbers and numbers themselves is made clear. A number refers to the concept of for example, the naturals or integers; while a number representation refers to the representation of a number in a certain numeral system. This distinction is important because representations of numbers can have properties that numbers do not possess themselves. When regarding natural numbers and representations thereof, 012, 10 + 2, 1100, and 12 could all be representations of the natural number 12. To see the distinction, predicates such as “the number [representation] contains leading zeros” or “the number [representation] contains arithmetic expressions” can be specified. While these can be applied on representations of natural numbers, natural numbers do not possess these properties themselves.

Numbers and number representations will be regarded in the context of datatypes. The details of datatypes are disregarded in this thesis. However, the concept analogous to numbers and number representation can still be grasped. For an explanation of datatypes, see Bergstra and Tucker [3].

In short, an abstract datatype (ADT) is an isomorphic class of single-sorted or many-sorted algebras. A (concrete) datatype is an instantiation of an abstract datatype [1]. In the context of number representation, naturals or integers are abstract datatypes and certain representation are instantiations of these ADTs. Subsequently, one ADT can have multiple instantiations; analogous to natural numbers having multiple ways to be represented.

(10)
(11)

Chapter 2

Term Rewriting

In order to proceed, a short introduction to term rewriting is required. In the following no preliminary knowledge of term rewriting is presumed. See Terese [10] for an in-depth and extensive literature covering term rewriting. Generally, term rewriting can be split into first-order term rewriting and higher first-order term rewriting. In this thesis, only first-first-order term rewriting is used, therefore only first-order rewriting will be considered.

Rewriting concerns discrete transformations of objects. In term rewriting, the objects that are transformed are terms. The transformations are defined in a term rewriting system (TRS). A TRS consists of a set of terms and a set of rules which transform, rewrite, or reduce these terms. These are called rewrite or reduction rules.

2.1

Preliminaries

Terms are defined over a certain signature. A term consists of a combination of symbols from this signature and variables from a set disjoint from the signature. Variables can be replaced by terms. This process is called substitution.

Definition 2.1.1. (Signature) A signature ⌃ consists of a finite set of symbols f, g, . . . . A function symbol f has a certain arity ar(f ). A function f with ar(f ) = n is called n-ary. All 0-ary function symbols are called constant symbols or just constants. 1-ary and 2-ary functions are called unary and binary functions.

Definition 2.1.2. (Term) A term consists of a combination of symbols from ⌃ and/or variables from X. X is assumed to be infinite and disjoint from ⌃. The set of terms over a signature T er(⌃) is defined inductively as:

1. X✓ T er(⌃)

2. if f is a n-ary function symbol of ⌃ and t1, . . . , tn 2 T er(⌃) then f(t1, . . . tn)2 T er(⌃).

When a term does not contain any variables the term is called closed or ground. Otherwise the term is called open.

Definition 2.1.3. (Substitution) Given a signature ⌃ and a substitution function : X ! T er(⌃). A substitution t on a term t2 T er(⌃) is defined inductively as:

(12)

1. f (t1, . . . , tn) = f (t1, . . . , tn) for every n-ary function f 2 ⌃.

2. x = (x) for every variable x2 X.

Definition 2.1.4. (TRS) A TRS (⌃, R) consists of a signature ⌃ and a set of pairs (l, r)2 R with l, r2 T er⌃(X).

A TRS defines a binary reduction relation! on terms.

Definition 2.1.5. (Context) Given a signature ⌃, a context C is a term over ⌃[ {⇤} that contains zero or more occurrences of a context symbol⇤. If a context contains n such symbols C[t1, . . . , tn] denotes the replacement of these symbols from left to right by t1, . . . tn.

Definition 2.1.6. (Reduction)

Given a TRS (⌃, R), the pairs in R define reduction relations! on terms: 1. If (l, r)2 R then l ! r.

2. Given a substitution , l ! r if l ! r.

3. if l! r then C[l] ! C[r] for an arbitrary context.

If l ! r then l is said to be the one step reduct of r. A reduction sequence is a possibly infinite sequence of such steps: t1 ! t2 ! . . . . The reflexive and transitive closure of ! is

written as⇣.

With|t|x, where t2 T er(⌃) and x 2 X, the number of occurrences of the variable x in t is

denoted.

Definition 2.1.7. (Linear Term) A term t is called linear if no variable occurs more than once: 8x 2 X|t|x 1.

Definition 2.1.8. (Linear) A rule l! r is called left-linear if l is linear. If r is linear the rule is called right-linear

Definition 2.1.9. (Duplicating) A rule l! r is called duplicating if |l|x<|r|xfor some x2 X.

Definition 2.1.10. (Erasing) A rule l! r is called erasing if |r|x= 0 for some x2 X.

Definition 2.1.11. (Normal Form) A term t is a normal form if there exists no rewrite rule that rewrites t.

2.2

Termination

One very important property of a TRS is termination. Termination expresses whether or not rewriting ends. In general two forms of termination are distinguished: (strong) termination, and weak termination.

Definition 2.2.1. (Strong Termination) A TRS is called strongly terminating, strongly nor-malizing or just terminating if every reduction sequence of the TRS is finite.

Definition 2.2.2. (Weak Termination) A TRS is called weakly terminating or weakly normal-izing if for each term t there exists a t⇣ s where s is a normal form.

(13)

Example. An example of a non-terminating TRS is: f (x)! f(g(x)) g(x)! x

This TRS is non-terminating because the reduction sequence f (x)! f(g(x)) ! f(x) ! · · · is infinite.

2.3

Confluence

Another important property of a TRS is confluence. Confluence signifies that every two re-duction sequences starting from a term will eventually yield an equal result.

Definition 2.3.1. (Confluence) A TRS is called confluent or is said to have the Church-Rosser property if for every s and pair s⇣ t1, s⇣ t2there also exists a term t0such that t1⇣ t0and

t2⇣ t0.

Definition 2.3.2. (Complete) A TRS is said to be complete if the TRS is confluent and strongly terminating.

Definition 2.3.3. (Ground-complete) A TRS is said to be ground-complete if the TRS is ground-confluent and strongly terminating.

2.4

Proving termination

In general, whether or not a TRS is terminating is undecidable [6]. However, a lot of method-ologies are developed to simplify the process of finding termination proofs [10]. Most of these proofs rely on finding some kind of well-founded ordering.

Definition 2.4.1. (Partially ordered set) A partially ordered set (S, >) is a set S equipped with a transitive and irreflexive binary relation >.

Example. Two partially ordered sets are:

• (N, >) where > denotes the standard order of numbers is a partial order of naturals. • (Z, >) where > denotes the standard order of numbers is a partial order of integers. Definition 2.4.2. (Well-founded) A partially ordered set (S, >) is a said to be well-founded if there exists no infinite descending order of elements s1> s2>· · ·

Example. Using the partial orderings from the example above: • (N, >) is well-founded. There is no element smaller than 0.

• (Z, >) is not well-founded. For all z 2 Z, Z will always contain an element smaller than z.

Theorem. A TRS (⌃, R) is terminating if and only if there exists a well-founded order > on T er(⌃) such that for all t, u2 T er(⌃) if t ! u then t > u.

(14)

However, finding such an ordering is not trivial because there usually exists infinitely many terms t, u2 T er(⌃) such that t ! u. Most of the methods deal with making it easier to find and define such an ordering by defining the ordering on reduction rules instead.

One of the primary methods of finding such reduction orders is the recursive path order (RPO) [6]. Before explaining this method, some preliminaries will be discussed.

2.4.1

Multisets

A multiset is a set that allows multiple occurrences of elements. Square brackets are used to denote a multiset.

Definition 2.4.3. (Multiset) Formally a multiset (S, f ) consists of a set S and a function f : S! N+

where N+ represents the set of positive numbers. This function maps each element of S to a

count.

Given a multiset (S, f ), f can be extended to a more general multiplicity function: MS : U ! N

MX(x) =

(

0 if x /2 X f (x) otherwise

where U denotes the universal set. The multiset order is a well-founded ordering on multisets. Definition 2.4.4. (Multiset Order) Given a partial order (S, <S), the set of all finite multisets

on S: M(S), and two multisets M, N 2 M(S). M Î N if:

1. M6= N, and

2. for all s2 S, if MM(s) > MN(s) there is some s02 S such that s <S s0 and MM(s0) <

MN(s0).

Example.

1. [1, 2, 2, 3]Ï [1, 2, 3] 2. [2]Ï [1, 1]

2.4.2

Recursive path ordering

The RPO orders rules of a TRS using a well-founded precedence on the signature.

Definition 2.4.5. (Precedence) A precedence on a signature ⌃ is a strict partial order on ⌃. The precedence specifies how functions are ordered. To be able to compare arguments of function symbols, RPO lifts using a status function. For simplicity’s sake only status func-tions that lift to three di↵erent orders are regarded: multiset order, (left-to-right) lexicographic order and right-to-left lexicographic order.

(15)

Definition 2.4.6. (Status) A status function ⌧ maps all symbols of ⌃ to either: 1. Multiset order: mul.

2. Left-to-right lexicographic order: lex. 3. Right-to-left lexicographic order: lexr.

A partial order is then lifted using the status function ⌧ (f )which extends the partial order

to sequences of lenght ar(f ).

Definition 2.4.7. (Multiset extension) The multiset extension mul compares the sequences using the multiset ordering:

hs1, . . . , sni mulht1, . . . , tni , [s1, . . . , sn]Î [t1, . . . , tn]

Definition 2.4.8. (Lexicographic extension) The lexicographic extension lex compares the

sequences using lexicographic ordering. That is

hs1, . . . , sni ht1, . . . , tni

if9i  n such that 8j < i si = ti and sj tj. The right-to-left lexicographic extension lexr

is obtained by inversing the sequences:

hs1, . . . sni lexr ht1, . . . , tni , hsn, . . . s1i lexhtn, . . . , t1i

The original recursive path order described in Dershowitz [6] uses a status function that lifts to the multiset extension for all symbols. This ordering is also called the multiset path ordering (MPO) or just recursive path ordering.

If all symbols have lexicographic status the order is also called lexicographic path ordering (LPO).

Definition 2.4.9. (Recursive Path Ordering) Given a signature ⌃, a well-founded precedence on ⌃ and a status function ⌧ . The recursive path order rpo on T er(⌃) is defined as:

s = f (s1, . . . , sn) rpog(t1, . . . , tm) = t if:

(1) f = g and hs1, . . . , s2i ⌧ (f )rpo ht1, . . . , tmi, or

(2) f g and s rpoti for all 1 i  m, or

(3) f ✏ g and si⌫rpot for some 1 i  n

Withrpothe extension to rpo including equality is meant.

Example. Take the following TRS defined over ⌃ ={f, g}: f (g(x), g(x))! g(f(x, x))

g(g(x))! g(x) g(f (x))! f(x)

It easily follows that this TRS is terminating. The number of occurrences of g always decreases and this process will eventually stop. Termination of this TRS can also be proved using RPO. By specifying the precedence f > g on ⌃ an RPO is defined that is compatible with the TRS

(16)

defined above. When regarding RPOs it can be convenient to regard terms as finite non-commutative trees. To understand that f > g provides a compatible RPO note that the first rule requires: f g x g x rpo g f x x

For the precedence relation between f and g we have two options: 1. g > f : then (3) from Definition 2.4.9 applies:

g x ⌫rpo g f x x By (1): hxi mulh f x x i However, this is false; g > f is not compatible. 2. f > g: then by (2): f g x g x rpo f x x now (1) applies: h g x , g x i mpohx, xi Which is true because:

g x

rpox

Hence f > g is compatible with the first rule of the TRS.

For the second and third rule of the TRS, the precedence will not matter. After application of rule (1) on the second rule we obtain:

h g x

(17)

which is true no matter the precedence of g. Depending on the precedence either (1) or (3) applies for the third rule:

1. if f > g then the following must hold: f x ⌫rpo f x 2. if g > f then: g f x ⌫rpox

(18)
(19)

Chapter 3

The Term Rewriting System for

Decimal Numbers

In Bergstra [1], multiple datatype defining rewrite systems (DDRSes) for representing naturals are defined. A DDRS consists of a set of equations that when oriented left-to-right define a TRS. A DDRS is a rewrite system that specifies a datatype. Elements of this datatype are represented by the closed normal forms of the TRS defined by the DDRS.

The DDRSes in Bergstra [1] are all instantiations of, or views on the same abstract datatype: the natural numbers. Each of these views has a di↵erent set of normal forms associated with it. The unary view has normal forms representing naturals specified with a successor function. The binary view has normal forms specified with the binary digit append function and the decimal view has normal forms specified using the decimal digit append function. In Bergstra and Ponse [2], these DDRSes are extended to DDRSes specifying views on the integer numbers. Bergstra and Ponse [2] also define three alternate views of the naturals and integers. These views use “digit tree constructors” to construct numbers from digits. Again DDRSes for unary, binary, and decimal views are specified.

A DDRS is required to be strongly-terminating and ground-confluent [1]. Termination, ground-confluence and thus ground-completeness, of most of the DDRSes are proven in Bergstra and Ponse [2] and Kluiving and Woerkom [8]. However, these properties have not yet been proven for the DDRS for decimal integer representation using the digit tree constructor.

3.1

Decimal representation with the digit tree

construc-tor

The DDRS for decimal integers using the digit tree constructorZdtis an extension of the DDRS

defining decimal naturals using digit tree constructorsNdt. To avoid confusion with variants of

these DDRSes defined in this thesis as well in as other papers, all TRS from external sources will be labeled. When referring toNBP

dt andZBPdt ,Ndt andZdtfrom Bergstra and Ponse [2] are

(20)

NBP

dt and ZBPdt are defined over a signature which contains all functions needed for the

unary, binary, and decimal views using both digit append and digit tree constructor functions. However, because only the decimal view using the digit tree constructor is regarded in this thesis, a restriction of this signature is adopted. The signature ⌃N, underlying the TRSes that specify natural numbers, contains the following elements:

1. Ten constants from D ={0, 1, . . . , 9}, representing the digits. 2. One one-place functions S, the successor function.

3. The two-place functions + and·, representing addition and multiplication. These func-tions will be used in infix notation.

4. Another two-place function ˆd. The decimal digit tree constructor. Infix notation will

be used for this function as well. This function is used to form a number from the digits. The signature ⌃Z, underlying the TRSes that specify the integer numbers, is an extension of ⌃N. ⌃Z contains:

1. A one-place function representing the standard unary minus. x is usually written instead of (x) if no confusion can arise.

2. Another one-place function P , the predecessor function.

The successor and predecessor functions are not present in the normal forms of NBP dt and

ZBP

dt . Rather, these are used as auxiliary functions to represent an intermediate predecessor or

successor of a (sub)term. The decimal digit tree constructor itself is used to represent decimal positional notation of a natural or integer number.

3.1.1

Semantics

The meaning of closed terms over ⌃N and ⌃Z is provided by the interpretation in a certain model: the semantics. Because NBP

dt and ZBPdt represent naturals and integers, N and Z are

models for these TRSes respectively. The semantics of the functions are as follows: • digits i 2 D all have the obvious semantic JiK = i

• JS(x)K = JxK + 1 • JP (x)K = JxK 1 • Jx + yK = JxK + JyK • Jx · yK = JxK · JyK • J xK = JxK • Jx ˆdyK = 10 · JxK + JyK

Other than S, P , and ˆd all functions should be familiar to someone with an understanding

of the ring of integers. In its basic form, ˆd can be used to model decimal positional number

notation. When notating numbers in base-10 it could be said that ˆd is used implicitly. That

is, 154 is written and (1 ˆd5) ˆd4 is meant. Besides allowing decimal notation, ˆd also allows

the formation of more complex expressions. For example: 1 ˆd(1 ˆd5)

(21)

3.1.2

Notational conventions

Before defining the TRS, some notational conventions used in Bergstra and Ponse [2] are adopted. Each rewrite rule has a tag used for reference. A tag has the form [Nn] where “N” is some name and “n” is a natural number. Moreover, to avoid explicitly writing down the same rule for di↵erent digits, rules can be parameterised:

[N n.i]l i=k

with k, l2 {1, 2, · · · 9} and k < l will represent the l k + 1 equations with i instantiated from {k, . . . , l}. In the same fashion,

[N n.i.j]li,j=k

represents the (l k + 1)2 equations with both i and j instantiated from

{k, . . . , l}.

The successor of i is denoted with i0for the digits 0, 1, . . . , 8. For all digits, idenotes the “10

minus” subtraction. For example, 8⇤ denotes 2 and 5⇤ denotes 5. For the digits 1, 2, . . . , 9, i00 stands for the predecessor of i.

3.1.3

Ground normal forms

Because the datatype defined by a DDRS is determined by its ground normal forms, the normal forms of NBP

dt and ZBPdt are numbers. A number consists of a string of digits without leading

zeros. In ZBP

dt , all numbers except 0 can also be made negative by prepending it with a .

Thus the ground normal forms of NBP

dt should consist of either a single digit or should be of

the form x ˆdi where x is a non-zero normal form and i2 D is a digit. This corresponds to the

implicit use of ˆd when notating numbers in base 10.

ZBP

dt extends these normal forms to the integer numbers. Consequently, a normal form of

ZBP

dt should either be a normal form of NBPdt or should be of the form (t) with t a non-zero

normal form ofNBPdt . An example of a normal form of eitherNBPdt orZBPdt is:

(5 ˆd3) ˆd1

which represents 531. A normal form ofZBP dt is:

(3 ˆd1)

which represents 31. Note that ( 8) ˆd1 is not a normal form of ZBPdt . This would represent

10· ( 8) + 1 = 79 and is reducible to a normal form: ( 8) ˆd1⇣ (7 ˆd9)

3.1.4

The rules

NBP

dt is defined by the rules in Table 3.1. The extension to integersZBPdt is shown in Table 3.2.

The left column ofZBP

dt contains all rules fromNBPdt . The right column contains all rules needed

(22)

[dt1] 0 ˆdx! x

[dt2] x ˆd(y ˆdz)! (x + y) ˆdz

[dt3.i]8i=0 S(i)! i0

[dt4] S(9)! 1 ˆd0 [dt5.i]8i=0 S(x ˆdi)! x ˆdi0 [dt6] S(x ˆd9)! S(x) ˆd0 [dt7] x + 0! x [dt8.i]8i=0 x + i0! S(x) + i [dt9.i]9i=0 x + (y ˆdi)! (y ˆdx) + i [dt10] x· 0 ! 0 [dt11.i]8i=0 x· i0! x + (x · i) [dt12.i]9 i=0 x· (y ˆdi)! ((x · y) ˆd0) + (x· i) Table 3.1: NBP dt

(23)

[dt1] 0 ˆdx! x

[dt2] x ˆd(y ˆdz)! (x + y) ˆdz

[dt3.i]8i=0 S(i)! i0

[dt4] S(9)! 1 ˆd0 [dt5.i]8i=0 S(x ˆdi)! x ˆdi0 [dt6] S(x ˆd9)! S(x) ˆd0 [dt7] x + 0! x [dt8.i]8 i=0 x + i0 ! S(x) + i [dt9.i]9i=0 x + (y ˆdi)! (y ˆdx) + i [dt10] x· 0 ! 0 [dt11.i]8i=0 x· i0 ! x + (x · i) [dt12.i]9i=0 x· (y ˆdi)! ((x · y) ˆd0) + (x· i) [dt13] 0! 0 [dt14] ( x)! x [dt15] P (0)! 1 [dt16.i]8i=0 P (i0)! i [dt17] P (x ˆd0)! P (x) ˆd9 [dt18.i]8 i=0 P (x ˆdi0)! x ˆdi [dt19] P ( x)! S(x) [dt20.i]8 i=0 S( i0)! i [dt21] S( (x ˆd0))! (P (x) ˆd9) [dt22]8i=0 S( (x ˆdi0))! (x ˆdi) [dt23] ( x) ˆdy! (x ˆd( y))

[dt24.i.j]9i,j=1 i ˆd( j)! P (i) ˆdj⇤

[dt25.i]9i=1 (x ˆdy) ˆd( i)! P (x ˆdy) ˆdi⇤ [dt26] x ˆd( (y ˆdz))! ((y + ( x)) ˆdz) [dt27.i]9i=1 x + ( i)! Pi(x) [dt28] x + ( (y ˆdz))! (y ˆd(z + ( x))) [dt29.i]9 i=1 ( i) + (x)! Pi(x) [dt30] ( (x ˆdy)) + z! (x ˆd(y + ( z))) [dt31] x· ( y) ! (x · y) [dt32] ( x)· y ! (x · y) Table 3.2: ZBPdt

(24)
(25)

Chapter 4

Termination proof

All attempts made to prove termination ofZBP

dt using standard methodologies failed. Because of

this, some changes to the TRS are proposed in this chapter. These changes preserve correctness and ground-confluence of the TRS and allow a somewhat simple termination proof to be constructed. BecauseZBP

dt is an extension ofNBPdt , termination ofNBPdt will be discussed first.

4.1

Termination of

N

dt Termination of a variant of NBP

dt is proven in Kluiving and Woerkom [8] using the AProVE

tool [7]. This is done by altering some of the rules of NBP

dt [13]. The altered TRS NKWdt is

shown in Table 4.1. The changed rules are marked with a bold tag. Altering these rules will also introduce a new TRS for integer representationZKW

dt by applying the same changes to the

corresponding rules in ZBP dt .

However, the automatic termination proof for NKW

dt computed by AProVE is very large in

size and for this reason not usable as a basis for proving termination of extensions of NKWdt

by hand. Instead, a very simple termination proof ofNKW

dt can be constructed using recursive

path ordering with lexicographic status:

Proof. Given the following partial ordering of function symbols: · > + > S > ˆd > 9 >· · · > 0

where ˆd has lexicographic status from right to left. It is easily verified that that each rule in

Table 4.1 is compatible with this RPO.

Note that [dt2] is the only rule that requires ˆd to have a lexicographic status.

4.2

Termination of

Z

dt Proving termination ofZKW

dt with standard methodologies failed. Three very common methods

(26)

[dt1] 0 ˆdx! x

[dt2] x ˆd(y ˆdz)! (x + y) ˆdz

[dt3.i]8i=0 S(i)! i0

[dt4] S(9)! 1 ˆd0 [dt5.i]8 i=0 S(x ˆdi)! x ˆdi0 [dt6] S(x ˆd9)! S(x) ˆd0 [dt7] x + 0! x [dt8.i]9i=1 x + i! Si(x) [dt9.i]9i=0 x + (y ˆdi)! Si(y ˆdx) [dt10] x· 0 ! 0 [dt11.i]8i=0 x· i0! x + (x · i) [dt12.i]9i=0 x· (y ˆdi)! ((x · y) ˆd0) + (x· i) Table 4.1: NKW dt

1. The Knuth-Bendix Ordering cannot handle duplicating rules like [dt12].

2. The multiset based (standard) recursive path ordering fails because of rules like [dt2]. 3. Recursive path ordering with status fails as well. The direction of the lexicographic

statuses of ˆd needed for [dt2] and [dt23] oppose each other.

Due to the complexity and size of the TRS, other attempts made to prove termination ofZKW dt

through polynomial interpretation or weighing functions also failed. Constructing a proof with more complex methods such as semantic labeling [15] failed as well. Most automatic tools are also unsuccessful. As with earlier attempts [8], AProVE [7] cannot provide a termination proof. Moreover, TTT2 [9] and NaTT [14] also are incapable of finding a proof.

These failed attempts are the motivation to change ZKW

dt to allow for a somewhat simple

termination proof. Before introducing these changes, a rundown of the proof is given to make clear what adjustments have to be made.

The termination proof relies on a method that is roughly similar to that used in Walters and Zantema [12]. This method is based on splitting the TRS into two smaller and simpler TRSes. The TRS is split in such a way that proving termination of the smaller TRSes is sufficient for proving termination of the original. Thus, finding a termination proof is made less difficult by reasoning that proving termination of these smaller and simpler TRSes is easier than proving termination of the original.

ZKW

dt will be simplified by disregarding the di↵erence of digits and neglecting negativity

of numbers. This is done by applying a transformation to the TRS. This transformation simplifies the TRS and splits it into two parts: Zdt1 will contain all rules (l)! (r) where

(27)

0! 1! · · · 9! x! x P (x)! S(x)

Table 4.2: The RPS defining .

inequality is obtained between (l) and (r). Zdt2 will contain all rules l! r where equality

is obtained.

Zdt1 ={ (l) ! (r) | l ! r 2 ZKWdt ^ (l) 6= (r)}

Zdt2 ={l ! r 2 ZKWdt | (l) = (r)}

The transformation is defined as follows: (0) = (1) = . . . (9) = ( x) = (x) (x ˆdy) = (x) ˆd (y) (x + y) = (x) + (y) (x· y) = (x) · (y) ( x) = (x) (S(x)) = S( (x)) (P (x)) = S( (x))

Di↵erence in digits will be disregarded by replacing all digits with a common symbol . Neg-ativity is also neglected by removing minus symbols and replacing predecessor functions with successor functions. If both Zdt1 and Zdt2 are terminating, it can be concluded that Zdt is

terminating as well. This holds because is definable by a terminating non-erasing recursive program scheme. This RPS is shown in Table 4.2.

Definition 4.2.1. (Recursive program scheme) A recursive program scheme is a TRS where for all rules l! r:

1. l has a distinct root symbol

2. l has the shape f (x1, . . . , xn) where x1, . . . , xn are distinct variables.

See Terese [10] for the proof that any transformation defined by a terminating non-erasing RPS on a TRS R split into R1 and R2by the split defined above is terminating if and only if

R1and R2 are terminating. Proving termination of the RPS is trivial.

As previously stated, changes to a few rules of the TRS are needed in order to enable the use of :

(28)

1. After applying , rule [dt11] will become self-embedding. To counteract this, the rule can be changed to the following:

[dt11.i]9i=1 x· i ! i X x where i X x

for i2 {1, . . . , 9} denotes i 1 recursive applications of +:

1 X x = x (n+1) X x = x + n X For example: 3 X 1 = 1 + (1 + 1)

2. To allow the deletion of and the substitution of digits with , changes to [dt24] and [dt25] are required. When left alone, [dt24] will introduce a rewrite loop:

ˆ

d ! S( ) ˆd ! ˆd ! · · ·

this can be counteracted by substituting P (i) with i00in [dt24]: [dt24]9i,j=1 i ˆd( j)! i00ˆdj⇤

[dt25] will also introduce a loop:

(x ˆd ) ˆd ! S(x ˆd ) ˆd ! (x ˆd ) ˆd ! · · ·

this is prevented by changing the rule to be more specific: [dt25]9i,j=1 (x ˆdi) ˆd( j)! (x ˆdi00) ˆdj⇤

The altered TRS Zdt0 is shown in Table 4.3. The modified rules are marked with a bold tag.

Zdt1 andZdt2, obtained by applying the transformation toZdt

0, are shown in Table 4.4 and

4.5 respectively.

4.2.1

Termination of

Z

dt1

Proving termination of Zdt1 is achieved using RPO with status:

Proof. Given the following partial ordering on function symbols · > + > S > ˆd >

with ˆd having right to left lexicographic status. It is easily verified that each rule in Table 4.5

(29)

[dt1] 0 ˆdx! x

[dt2] x ˆd(y ˆdz)! (x + y) ˆdz

[dt3.i]8i=0 S(i)! i0

[dt4] S(9)! 1 ˆd0 [dt5.i]8i=0 S(x ˆdi)! x ˆdi0 [dt6] S(x ˆd9)! S(x) ˆd0 [dt7] x + 0! x [dt8.i]9i=1 x + i! Si(x) [dt9.i]9i=0 x + (y ˆdi)! Si(y ˆdx) [dt10] x· 0 ! 0 [dt11.i]9i=1 x· i ! i X x [dt12.i]9 i=0 x· (y ˆdi)! ((x · y) ˆd0) + (x· i) [dt13] 0! 0 [dt14] ( x)! x [dt15] P (0)! 1 [dt16.i]8i=0 P (i0)! i [dt17] P (x ˆd0)! P (x) ˆd9 [dt18.i]8i=0 P (x ˆdi0)! x ˆdi [dt19] P ( x)! S(x) [dt20.i]8i=0 S( i0)! i [dt21] S( (x ˆd0))! (P (x) ˆd9) [dt22]8 i=0 S( (x ˆdi0))! (x ˆdi) [dt23] ( x) ˆdy! (x ˆd( y)) [dt24.i.j]9i,j=1 i ˆd( j)! i00ˆdj⇤ [dt25.i]9i,j=1 (x ˆdi) ˆd( j)! (x ˆdi00) ˆdj⇤ [dt26] x ˆd( (y ˆdz))! ((y + ( x)) ˆdz) [dt27.i]9i=1 x + ( i)! Pi(x) [dt28] x + ( (y ˆdz))! (y ˆd(z + ( x))) [dt29.i]9i=1 ( i) + x! Pi(x) [dt30] ( (x ˆdy)) + z! (x ˆd(y + ( z))) [dt31] x· ( y) ! (x · y) [dt32] ( x)· y ! (x · y) Table 4.3: Zdt0

(30)

[dt1] ˆdx! x [dt2] x ˆd(y ˆdz)! (x + y) ˆdz [dt3.i]8 i=0 S( )! [dt4] S( )! ˆd [dt5.i]8i=0 S(x ˆd )! x ˆd [dt6] S(x ˆd )! S(x) ˆd [dt7] x + ! x [dt8.i]9i=1 x + ! Si(x) [dt9.i]9i=0 x + (y ˆd )! Si(y ˆdx) [dt10] x· ! [dt11.i]9 i=1 x· ! i X x [dt12.i]9i=0 x· (y ˆd )! ((x · y) ˆd ) + (x· ) [dt15] S( )! [dt16.i]8i=0 S( )! [dt17] S(x ˆd )! S(x) ˆd [dt18.i]8i=0 S(x ˆd )! x ˆd [dt20.i]8 i=0 S( )! [dt21] S(x ˆd )! S(x) ˆd [dt22]8i=0 S(x ˆd )! x ˆd [dt26] x ˆd(y ˆdz)! (y + x) ˆdz [dt27.i]9i=1 x + ! Si(x) [dt28] x + (y ˆdz)! y ˆd(z + x) [dt29.i]9i=1 + x! Si(x) [dt30] (x ˆdy) + z! x ˆd(y + z) Table 4.4: Zdt1 [dt13] 0! 0 [dt14] ( x)! x [dt19] P ( x)! S(x) [dt23] ( x) ˆdy! (x ˆd( y)) [dt24.i.j]9 i,j=1 i ˆd( j)! i00ˆdj⇤ [dt25.i]9i,j=1 (x ˆdi) ˆd( j)! (x ˆdi00) ˆdj⇤ [dt31] x· ( y) ! (x · y) [dt32] ( x)· y ! (x · y) Table 4.5: Zdt2

(31)

4.2.2

Termination of

Z

dt2

Proving termination of Zdt2 is also accomplished using RPO with status:

Proof. Given the following partial ordering of function symbols · > P > S > > > 9 >· · · > 0

with ˆd having right to left lexicographic status. It is easily verified that all rules rules in Table

(32)
(33)

Chapter 5

Ground-confluence proof

In this chapter, ground-confluence ofZdt0 is proven. This is done using structural induction on

terms. Both correctness and termination of Zdt0 are required for this proof. Termination has

been proved in the previous chapter. Correctness is proven by checking that all rules of the TRS are correct in the given model. It is easily verified that all the rules ofZdt0 are correct in

Z by using the semantics defined in Chapter 3.

5.1

Ground-confluence

The set N of ground terms over ⌃Z is first defined: N ={0} [ N+

[ N

N+= D\ {0} [ {w ˆdi| w 2 N+, i2 D}

N ={ t | t 2 N+

}

It is clear that if t2 N, then t is a normal form of Zdt0and each term in N has a distinct value

in Z. This follows from the correctness of Zdt. It is necessary to prove that each ground term

over ⌃Z is either a normal form or has a reduction step. This is achieved through structural induction.

Proof. Induction base: t2 D then obviously t 2 N. Next distinguish six cases:

1. Case t = r. Then by the induction hypotheses, assume r2 N. Apply case distinction on r:

(a) if r = 0, then by equation [dt13] t! 0 (b) if r2 D \ {0}, then t 2 N (c) if r = r0ˆ di for i2 D, then r 2 N (d) if r = i for i2 D, then by [dt14] t ! i (e) if r = (r0ˆ di) for i2 D, then by [dt14] t ! r ˆdi

2. Case t = r ˆdu. Again by the induction hypotheses, assume u, r 2 N. Apply case

(34)

(a) if r = 0, then by equation [dt1] t! u

(b) if r2 D \ {0}, then apply case distinction on u: i. if u2 D then t 2 N.

ii. if u = u0ˆ

dj, then by [dt2] t! (r + u0) ˆdj

iii. if u = j for j2 D \ {0}, then by [dt24.i.j] t ! i00ˆ

dj⇤

iv. if u = (u0ˆ

dj), then by [dt26] t! (((u0+ ( r)) ˆdj)

(c) if r = r0ˆ

di for i2 D \ {0}, then apply case distinction on u:

i. if u2 D, then t 2 N. ii. if u = u0ˆ

dj, then by [dt2] t! (r + u0) ˆdj

iii. if u = j for j2 D \ {0}, then by [dt25.i.j] t ! (r0ˆ

di00) ˆdj⇤

iv. if u = (u0ˆdj), then by [dt26] t! (((u0+ ( r)) ˆdj)

(d) if r = i for i2 D \ {0}, then by [dt23] t ! (i ˆd( u))

(e) if r = (r0ˆdi) for i2 D, then by [dt23] t ! (r ˆd( u))

3. Case t = u + r assuming u, r2 N. Apply case distinction on r: (a) if r = 0, then by [dt7] t! u

(b) if r = i, for i2 D \ {0}, then by [dt8] t ! Si(u)

(c) if r = r0, ˆ

di for i2 D, then by [dt9] t ! Si(r0ˆdu)

(d) if r = i for i2 D \ {0}, then by [dt27] t ! Pi(u)

(e) if r = (r0ˆdi) for i2 D, then by [dt28] t ! (r0ˆd(i + ( u)))

4. Case t = u· r assuming u, r 2 N. Apply case distinction on r: (a) if r = 0, then by [dt10] t! u

(b) if r = i for i2 D \ {0}, then by [dt11.i] t !Pi(u) (c) if r = r0ˆ

di with i2 D then by [dt12.i] t ! ((u · r0) ˆd0) + (u· i)

(d) if r = i for i2 D \ {0}, then by [dt31] t ! (u · i) (e) if r = (r0ˆdi) for i2 D, then by [dt31] t ! (u · (r0ˆdi))

5. Case t = S(r) assuming r2 N. Apply case distinction on r: (a) if r = i for i2 D \ {9}, then by [dt3.i] t ! i0

(b) if r = 9, then by [dt4] t! 1 ˆd0

(c) if r = r0ˆ

di for i2 D \ {9}, then by [dt5.i] t ! r0ˆdi0

(d) if r = r0ˆd9, then by [dt6] t! S(r0) ˆd0

(e) if r = i0 for i2 D \ {9}, then by [dt20.i] t ! i (f) if r = (r0ˆ

d0), then by [dt21] t! (P (r0) ˆd9)

(g) if r = (r0ˆdi0) for i2 D \ {9}, then by [dt22.i] t ! (r0ˆdi)

6. Case t = P (r) assuming r2 N. Apply case distinction on r: (a) if r = 0, then by [dt15] t! 1

(35)

(c) if r = r0ˆ

d0 then by [dt17] t! P (x) ˆd9

(d) if r = r0ˆdi0 for i2 D \ {0}, then by [dt18.i] t ! r0ˆdi

(e) if r = i for i2 D, then by [dt19] t ! S(i) (f) if r = (r0ˆ

(36)
(37)

Chapter 6

The final TRSes

In this chapter, the newly proposed Zdt0 is further investigated. By analyzing the

ground-confluence proof given in Chapter 5 it can be concluded that some rules inZdt0are not necessary

for ground-confluence. These rules will be removed from the TRS, giving us the final TRS for decimal natural representationNdt and its extension to integersZdt.

6.1

A minimal TRS

Because case distinction is always conducted on the second argument of binary functions, rule [dt29], [dt30], and [dt32] of Zdt0 are never used. The only use these rules could have is

in providing confluence. However, only ground confluence is required for DDRSes. Moreover, neitherNdt0norZ0dtare confluent. Using the same critical-pair found in Kluiving and Woerkom

[8] to disprove confluence ofNKW

dt andZKWdt ,Ndt0andZdt0 can be proven non-confluent as well:

0 ˆd(y ˆdz) [dt1] yy [dt2] && y ˆdz (0 + y) ˆdz (6.1)

Hence, it is sensible to remove these rules to aid in readability and compactness of the TRS. The final TRSes Ndt and Zdt are shown in Tables 6.1 and 6.2 respectively. Note that [dt7]

and [dt8] of Ndt0 andZdt0 have been merged to [dt7] by using the notation S0(x) = x. These

TRSes are still terminating and correct by earlier proofs because no rules have been altered or added.

(38)

6.2

A template for confluence

Ndt is proved non-confluent using the critical pair (6.1). Another critical pair arisen from the

same rule: x ˆd(y ˆd(z1ˆdz2)) [dt2] uu [dt2] )) (x + (y + z1)) ˆdz2 ((x + y) + z1) ˆdz2 (6.2)

(6.1) is easily made confluent by adding the rule: 0 + x! x (6.2) requires a commutative rule:

x + (y + z)! (x + y) + x

However, more critical pairs arise after adding these rules. The rules needed to eliminate all discovered critical pairs of Ndtare shown in Table 6.3.

(39)

[dt1] 0 ˆdx! x

[dt2] x ˆd(y ˆdz)! (x + y) ˆdz

[dt3.i]8i=0 S(i)! i0

[dt4] S(9)! 1 ˆd0 [dt5.i]8i=0 S(x ˆdi)! x ˆdi0 [dt6] S(x ˆd9)! S(x) ˆd0 [dt7.i]9i=0 x + i! Si(x) [dt8.i]9i=0 x + (y ˆdi)! Si(y ˆdx) [dt9] x· 0 ! 0 [dt10.i]9i=1 x· i ! i X x [dt11.i]9i=0 x· (y ˆdi)! ((x · y) ˆd0) + (x· i) Table 6.1: Ndt

(40)

[dt1] 0 ˆdx! x

[dt2] x ˆd(y ˆdz)! (x + y) ˆdz

[dt3.i]8i=0 S(i)! i0

[dt4] S(9)! 1 ˆd0 [dt5.i]8i=0 S(x ˆdi)! x ˆdi0 [dt6] S(x ˆd9)! S(x) ˆd0 [dt7.i]9i=0 x + i! Si(x) [dt8.i]9i=0 x + (y ˆdi)! Si(y ˆdx) [dt9] x· 0 ! 0 [dt10.i]9i=1 x· i ! i X x [dt11.i]9i=0 x· (y ˆdi)! ((x · y) ˆd0) + (x· i) [dt12] 0! 0 [dt13] ( x)! x [dt14] P (0)! 1 [dt15.i]8i=0 P (i0)! i [dt16] P (x ˆd0)! P (x) ˆd9 [dt17.i]8i=0 P (x ˆdi0)! x ˆdi [dt18] P ( x)! S(x) [dt19.i]8 i=0 S( i0)! i [dt20] S( (x ˆd0))! (P (x) ˆd9) [dt21]8i=0 S( (x ˆdi0))! (x ˆdi) [dt22] ( x) ˆdy! (x ˆd( y)) [dt23.i.j]9i,j=1 i ˆd( j)! i00ˆdj⇤ [dt24.i]9i,j=1 (x ˆdi) ˆd( j)! (x ˆdi00) ˆdj⇤ [dt25] x ˆd( (y ˆdz))! ((y + ( x)) ˆdz) [dt26.i]9 i=1 x + ( i)! Pi(x) [dt27] x + ( (y ˆdz))! (y ˆd(z + ( x))) [dt28] x· ( y) ! (x · y) Table 6.2: Zdt

(41)

[dtc1] x + (y + z)! (x + y) + z [dtc2] x + S(y)! S(x + y) [dtc3] S(x) + y! S(x + y) [dtc4.i]9i=0 i + x! Si(x) [dtc5.i]9 i=0 (x ˆdi) + y! Si(x ˆdy) [dtc6] x + (y ˆdz)! y ˆd(x + z) [dtc7] S10(x)! 1 ˆdx [dtc8] S(x ˆdy)! x ˆd(S(y)) Table 6.3: Nc

(42)
(43)

Chapter 7

Conclusion and Remarks

Termination ofZKW

dt could not be proven. Both KBO and RPO with and without status are

shown to be incompatible with ZKWdt . Other methods such as polynomial interpretation and

weighing functions fail due to the complexity of the TRS. Instead, alterations to NKW dt and

ZKW

dt are proposed. These altered TRSes are further simplified toNdtandZdtrespectively by

removing unnecessary rules. Ndt is proved to be terminating by recursive path ordering with

status. The termination proof for Zdt is based on a transformation that simplifies and splits

the TRS. This transformation has the property that the original TRS is terminating if and only if the transformed and split TRSes are terminating. Termination of the transformed TRSes is proven using recursive path ordering with status. Both Ndt andZdtare ground-confluent.

7.1

Discussion

Whether or not the changes made toNKW

dt andZKWdt are justified is debatable. Non-termination

of ZKW

dt has not been proven. Hence, these changes are not necessary in the sense that the

TRS would be non-terminating without them. Of course, these changes are somewhat justified for they enable a termination proof based on conventional methods.

However, it might still be possible to construct a termination proof through means either not mentioned or not proven incompatible in this thesis. Polynomial interpretation or weighing functions for example could still be used to provide a termination proof. Also, while less readable and more complex, an ad-hoc termination proof such as the termination proof in Walters [11] might exist.

One complaint that can be made which might motivate other termination proofs is that the changes made to rule [dt24] (previously [dt25] in Zdt0) imply that rule [dt24] now represents

more rules. The number of rules in Zdt is increased by 72; something which is not desirable.

However, this increase is not that significant: the TRSes concerned already have rule counts in the hundreds. Besides, even with the additional rules, Zdt has less rules than other TRSes

serving the same goal. This is visible in Table 7.1. Here the number of rules, both when parameterised and expanded, of several TRSes for number representation are shown.

(44)

Name Ndt Zdt Ndub Zdub DA(10) JP(10)

expanded rule count 62 277 172 444 135 438

rule count 11 28 14 32 10 30

representation for N Z N Z N Z

arithmetics +,· +,· +,· +,· +,·, +,·,

Table 7.1: The rule count of several TRSes for number representation. From top to bottom the expanded rule count (the number of rules the TRS has after expanding all parameterised rules), the (unexpanded) rule count, what numbers can be represented and the arithmetic operators supported of multiple TRSes are shown. NdtandZdtare from this thesis,Nduband

Zdub originate from Bergstra and Ponse [2]. DA(10) and JP(10) originate from Walters and

Zantema [12], and are instantiated for base 10.

7.2

Future work

As mentioned in the discussion, termination ofZKW

dt in its original state might be provable. A

TRS based on di↵erent changes which do not increase the amount of rules as much, while still allowing a simple termination proofmight exist as well.

Ndt and Zdt can be expanded in several ways. Both could be extended to support more

arithmetic operators such as exponentiation, subtraction and integer division. With Zdt as

a basis, DDRSes for fraction representation can be constructed. The DDRSes can also be expanded with rules to make them confluent. Some rules that could be considered for this have been shown in Table 6.1

A question left unanswered concerns the complexity of the TRSes forNdtandZdt. The

space-complexity of ground-terms is most likely logarithmic because decimal positional notation is used. However, the auxiliary functions could complicate the complexity a bit. Determining the time-complexity will be useful if the TRSes are to be used for computational purposes.

(45)

Bibliography

[1] Jan A. Bergstra. “Four datatype defining rewrite systems for an abstract datatype of natural numbers”. In: University of Amsterdam, Informatics Institute, Section Theory of Computer Science, Research Report TCS1407v2 (2014).

[2] Jan A. Bergstra and Alban Ponse. “Three datatype defining rewrite systems for datatypes of Integers each extending a datatype of Naturals, version 3”. In: arXiv preprint arXiv:1406.3280 (Feb. 2016).

[3] Jan A. Bergstra and John V. Tucker. “Equational specifications, complete term rewrit-ing systems, and computable and semicomputable algebras”. In: Journal of the ACM (JACM) 42.6 (1995), pp. 1194–1230.

[4] Dave Cohen and Phil Watson. “An efficient representation of arithmetic for term rewrit-ing”. In: Rewriting Techniques and Applications. Springer. 1991, pp. 240–251.

[5] Evelyne Contejean, Claude March´e, and Landy Rabehasaina. “Rewrite systems for natu-ral, integnatu-ral, and rational arithmetic”. In: Rewriting Techniques and Applications. Springer. 1997, pp. 98–112.

[6] Nachum Dershowitz. “Orderings for term-rewriting systems”. In: Foundations of Com-puter Science, 1979., 20th Annual Symposium on. IEEE. 1979, pp. 123–131.

[7] J¨urgen Giesl, Peter Schneider-Kamp, and Ren´e Thiemann. “AProVE 1.2: Automatic ter-mination proofs in the dependency pair framework”. In: Automated Reasoning. Springer, 2006, pp. 281–286.

[8] B. Kluiving and W. van Woerkom. “Number representations and term rewriting. Honours project BSc Computer Science and BSC Artificial Intellegence”. Jan. 2016.

[9] Martin Korp et al. “Tyrolean Termination Tool 2”. In: Rewriting Techniques and Appli-cations. Springer. 2009, pp. 295–304.

[10] Terese. Term Rewriting Systems. Cambridge University Press, 2003.

[11] Humphrey Robert Walters. A complete term rewriting system for decimal integer arith-metic. Tech. rep. CS-9435. Centrum voor Wiskunde en Informatica, 1994.

[12] Humphrey Robert Walters and Hans Zantema. “Rewrite systems for integer arithmetic”. In: Rewriting Techniques and Applications. Springer. 1995, pp. 324–338.

[13] W. van Woerkom. Personal communication. Apr. 16, 2016.

[14] Akihisa Yamada, Keiichirou Kusakari, and Toshiki Sakabe. “Nagoya Termination Tool”. In: Rewriting and Typed Lambda Calculi. Springer, 2014, pp. 466–475.

[15] Hans Zantema. “Termination of term rewriting by semantic labelling”. In: Fundamenta Informaticae 24.1, 2 (1995), pp. 89–105.

Referenties

GERELATEERDE DOCUMENTEN

If we use a turned comma to show the location a full point would occupy if ‘turned’ in the same way, we can see that the position is somewhat high, as in the decimal fraction

In the sequel we refer to the glyph used to separate the integer and decimal parts of a decimal number as the decimal symbol, and that used to group the digits of the integer

For example, R[,][.]{1}{1} will produce a column centered for numbers with one digit before and one after the decimal sign, which is a comma in the input file, but a point in

Maar ook enkele andere cultivars van deze Canadese kornoelje hebben op- vallend groene twijgen, zoals ’Budd’s Yellow’ en ’White Gold’.. sericea ’Cardinal’ heeft

Gedeelten van het openbare gebied die geschikt zijn voor de ver- schillende soorten rijverkeer behoren zodanig te zijn ingericht dat de kans op ernstige

Kijkend naar het ethische dilemma van Jennifer waarin haar leidinggevende een verzoek doet tot het aanpassen van cijfers, kan deze leidinggevende van invloed zijn op haar

Voorts waren er drie grote practi- cumzalen, later aangeduid als de A-, B- en C-labzalen, naar de practica die daar zou- den worden gegeven, en een (semi)sou- terrain met enerzijds

Determine which of the four arrangements of the two solar cells yields the highest possible power in the external circuit when one of the solar cells is shielded with the