%----------------------------------------------------------------------------- % Insert an element into a sequence of countable length defined as a % coalgebraic datatype. % % Author: Jerry James <loganjerry@gmail.com> % % This file and its accompanying proof file are distributed under the CC0 1.0 % Universal license: http://creativecommons.org/publicdomain/zero/1.0/. % % Version history: % 2007 Feb 14: PVS 4.0 version % 2011 May 6: PVS 5.0 version % 2013 Jan 14: PVS 6.0 version %-----------------------------------------------------------------------------
csequence_insert[T: TYPE]: THEORY BEGIN
IMPORTING csequence_nth[T]
t, u: VAR T
p: VAR pred[T]
index, n, m: VAR nat
cseq, cseq1, cseq2: VAR csequence
fseq: VAR finite_csequence
iseq: VAR infinite_csequence
% Insert t at position index in sequence cseq. If index is greater than % length(cseq), then t is appended instead.
insert(t, index, cseq): RECURSIVE nonempty_csequence = IF index = 0 OR empty?(cseq) THEN add(t, cseq) ELSE add(first(cseq), insert(t, index - 1, rest(cseq))) ENDIF MEASURE index
insert_first: THEOREM FORALL t, index, cseq:
first(insert(t, index, cseq)) = IF index = 0 OR empty?(cseq) THEN t ELSE first(cseq) ENDIF
insert_rest: THEOREM FORALL t, index, cseq:
rest(insert(t, index, cseq)) = IF index = 0 OR empty?(cseq) THEN cseq ELSE insert(t, index - 1, rest(cseq)) ENDIF
insert_insert: THEOREM FORALL t, u, n, m, cseq:
insert(t, n, insert(u, m, cseq)) = IF is_finite(cseq) AND n > length(cseq) AND m > length(cseq) THEN insert(u, length(cseq), insert(t, n, cseq)) ELSIF n <= m THEN insert(u, m + 1, insert(t, n, cseq)) ELSE insert(u, m, insert(t, n - 1, cseq)) ENDIF
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.