sort_fseq[T: TYPE+, <= : (total_order?[T]) ]: THEORY %------------------------------------------------------------------------ % % sort_fseq (basic definitions and properties) % ------------------------------------------- % % Author: Ricky W. Butler % % This theory defines the sort function over an seq of % values. Most of the text of this theory is scaffolding to % demonstrate that the definition of "sort" is sound. In particular, % the function "asort" is a witness function and not intended % to be used externally. % % The following definitions should be used exclusively: % % is_permutation(A1,A2): bool = (EXISTS (f: [below(N) -> below(N)]): % bijective?(f) AND (FORALL ii: A1(ii) = A2(f(ii)))) % % increasing(A): bool = (FORALL i,j: 0 <= i AND i < j AND j < N % IMPLIES A(i) <= A(j)) % % sort(A): {a: seqs | is_permutation(A,a) AND increasing(a)} % % Note: % The properties of sort are readily obtained via % TYPEPRED "sort" or through use of sort_lem. % %------------------------------------------------------------------------
EXPORTING ALL BUT seq_to_array % i.e. do not export sort_array WITH permutations_fseq[T,<=], fseqs[T], fsq[T]
BEGIN
IMPORTING fseqs[T]
s,s1,s2,ss: VAR fseq
x, t: VAR T
i,j: VAR nat
%% <(x,y: T): bool = x <= y AND x /= y %% CAUSED SOME PROBLEMS
strictly_sort_subint_eq: LEMMALET sss = strictly_sort(s) IN increasing?(s) IMPLIESFORALL (ii:below(sss`length-1)): EXISTS (jj:below(s`length-1)): sss`seq(ii+1)=s`seq(jj+1) AND sss`seq(ii) = s`seq(jj)
strictly_sort_map(s): {sq: [below(strictly_sort(s)`length)->below(s`length)] | LET sss = strictly_sort(s) IN
(increasing?(s) AND sss`length >= 1IMPLIES sq(sss`length-1) = s`length-1) AND
(FORALL (ii:below(sss`length)): (sss`seq(ii) = s`seq(sq(ii)) AND
(increasing?(s) AND ii<sss`length-1IMPLIES sss`seq(ii+1) = s`seq(sq(ii)+1))))}
strictly_sort_map_between: LEMMALET sss = strictly_sort(s) IN FORALL (ii:below(sss`length-1)): FORALL (jj:below(s`length)):
increasing?(s) AND strictly_sort_map(s)(ii)<jj AND jj<=strictly_sort_map(s)(ii+1) IMPLIES
s`seq(strictly_sort_map(s)(ii+1)) = s`seq(jj)
strictly_sort_map_increasing: LEMMA increasing?(s) IMPLIESFORALL (ii,jj:below(strictly_sort(s)`length)): LET sq = strictly_sort_map(s) IN ii<jj IMPLIES sq(ii)<sq(jj)
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 und die Messung sind noch experimentell.