You are on page 1of 16

Term Rewriting and its Usefulness

A quick review

Andrei Seiman

June, 2016

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

1/8

Term rewriting

Term rewriting is a branch of theoretical computer science, combining


elements of logic, universal algebra, automated theory proving and
functional programming. The foundation is its equational logic, being
distinguished by using directed replacement rules, i.e. left-hand side can be
replaced by right-hand side but not vice versa. We use term rewriting to
implement source-to-source transformations as a tool and as commercial
services.
The package is called the DMS Software Reengineering Toolkit and can
be found at
http://www.semanticdesigns.com/Products/DMS/DMSToolkit.html

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

2/8

Applications

in Applications TSR is great for coding optimization, we can also use


it to migrate from one language to another

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

3/8

Applications

in Applications TSR is great for coding optimization, we can also use


it to migrate from one language to another
Reverse engineering is also a pro, when trying to break a newly
created virus for example

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

3/8

Applications

Specific applications include enhancing C++ to include an APL-like


vector sublangauge targeting SIMD computation.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

4/8

Applications

Specific applications include enhancing C++ to include an APL-like


vector sublangauge targeting SIMD computation.
Analyzing enormous systems of mainframe COBOL code for the US
Social Security Administration, and migrating industrial process
control programs for Dow Chemical.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

4/8

DMS

It includes an ecosystem of compiler-style machinery for defining


language grammars, building various kinds of analyzers, and either
transforming code in one language to another.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

5/8

DMS

It includes an ecosystem of compiler-style machinery for defining


language grammars, building various kinds of analyzers, and either
transforming code in one language to another.
Reification if you go from a specification language to a concrete
programming language

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

5/8

DMS

It includes an ecosystem of compiler-style machinery for defining


language grammars, building various kinds of analyzers, and either
transforming code in one language to another.
Reification if you go from a specification language to a concrete
programming language
Translation/Migration if you go from one concrete language to
another

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

5/8

DMS

It includes an ecosystem of compiler-style machinery for defining


language grammars, building various kinds of analyzers, and either
transforming code in one language to another.
Reification if you go from a specification language to a concrete
programming language
Translation/Migration if you go from one concrete language to
another
Practical usage of DMS interweaves application of the compiler-like
aspects with term rewriting.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

5/8

Overall Usefulness

TRS blooms when you need to access a certain implementation in a


certain langauge.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

6/8

Overall Usefulness

TRS blooms when you need to access a certain implementation in a


certain langauge.
TRS does that, because you have this language that talks about
another language.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

6/8

Overall Usefulness

TRS blooms when you need to access a certain implementation in a


certain langauge.
TRS does that, because you have this language that talks about
another language.
Instead of writing another library you can tailor with the existing ones
and use TRS, to better design and model that library.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

6/8

Overall Usefulness

TRS blooms when you need to access a certain implementation in a


certain langauge.
TRS does that, because you have this language that talks about
another language.
Instead of writing another library you can tailor with the existing ones
and use TRS, to better design and model that library.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

6/8

Conclusion

With TRS you can get things that look and feel like parametric
polymorphism, partial evaluation, and dependent types without all of the
ceremony.
Of course, you can also shoot yourself in the foot with all of this power
quite easily, having non-terminating static evaluation over type-like
structures, or behavior that should be static leaking into the dynamic
semantics of a program.

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

7/8

For Further Reading I

F. Baader and T. Nipkow.


Term Rewriting and All That.
Cambridge University Press, 1998.
DMS.
DMS Software Reengineering Toolkit.
http://www.semanticdesigns.com/Products/DMS/DMSToolkit.html

Andrei Seiman

Term Rewriting and its Usefulness

June, 2016

8/8

You might also like