majority_seq[T: NONEMPTY_TYPE]: THEORY %------------------------------------------------------------------------ % % majority (basic definitions and properties) % ------------------------------------------- % % Author: Ricky W. Butler % % This theory defines the majority function over a finite sequence of % values. The following functions are defined: % % is_majority(mv,fs) -- predicate that is true IFF mv is % the majority value of the sequence % % maj_exists(fs) -- predicate that us true IFF a majority % exists % % maj(fs) -- function that returns the majority value % if a majority exists. If a majority does % not exist, the function returns an % unspecified value from the type T. % This value may not be in the sequence. % % inseq(x,fs) -- predicate that is true IFF x is in % the sequence % % Note: the following function can be defined that will return % a value from the sequence if a majority does not exist. % % finseq: TYPE = {fs | length(fs) > 0} % % fsq: VAR finseq % Maj(fsq): {x: T | in_seq(x,fsq)} = IF maj_exists(fsq) THEN maj(fsq) % ELSE choose({x: T | in_seq(x,fsq)}) % ENDIF % %------------------------------------------------------------------------
maj_const: LEMMA maj_exists(const_seq(n,c)) AND
maj(const_seq(n,c)) = c
END majority_seq
¤ 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.0.25Bemerkung:
(vorverarbeitet)
¤
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.