%%-------------------** Term Rewriting System (TRS) **------------------------ %% %% Authors : Andre Luiz Galdino %% Universidade Federal de Goiás - Brasil %% %% and %% %% Mauricio Ayala Rincon %% Universidade de Brasília - Brasil %% %% Last Modified On: September 29, 2009 %% %%----------------------------------------------------------------------------
replacement[variable: TYPE+, symbol: TYPE+, arity: [symbol -> nat]]: THEORY BEGIN
IMPORTING subterm[variable,symbol, arity]
p, q, p1, p2, q1: VAR position
s, r, t: VAR term
i: VAR posnat
fs: VAR finseq[term]
x, y: VAR (V)
%%%% Definition: replacing the subterm of s at position p by t %%%%%%%%%%%%%%%
replaceTerm(s: term, t: term, (p: positions?(s))): RECURSIVE term =
(IF length(p) = 0 THEN
t ELSE LET st = args(s),
i = first(p),
q = rest(p),
rst = replace(replaceTerm(st(i-1), t, q), st,i-1) IN
app(f(s), rst) ENDIF) MEASURE length(p)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.