Looks fine to me, but I don't know how this changes the behaviour of the
interpreter.
Can you provide a concrete example (that you care about)that doesn't
work now and works after extending the Finite category?
Thank you
Ralf
On 1/5/20 8:33 PM, Prof. Dr. Johannes Grabmeier privat wrote:
> Hi all,
>
> Finite is Missing StepThrough! Any objection against adding a default
> step through:
>
> )abbrev category FINITE Finite
> ++ Author:
> ++ Basic Functions:
> ++ Related Constructors:
> ++ Also See:
> ++ AMS Classifications:
> ++ Keywords:
> ++ References:
> ++ Description:
> ++ The category of domains composed of a finite set of elements.
> ++ We include the functions \spadfun{lookup} and \spadfun{index} to give
> a bijection
> ++ between the finite set and an initial segment of positive integers.
> ++
> ++ Axioms:
> ++ \spad{lookup(index(n)) = n}
> ++ \spad{index(lookup(s)) = s}
> Finite() : Category == Join(SetCategory, ConvertibleTo InputForm,
> Comparable, StepThrough) with
> --operations
> size : () -> NonNegativeInteger
> ++ size() returns the number of elements in the set.
> index : PositiveInteger -> %
> ++ index(i) takes a positive integer i less than or equal
> ++ to \spad{size()} and
> ++ returns the \spad{i}-th element of the set. This
> ++ operation establishes a bijection
> ++ between the elements of the finite set and \spad{1..size()}.
> lookup : % -> PositiveInteger
> ++ lookup(x) returns a positive integer such that
> ++ \spad{x = index lookup x}.
> random : () -> %
> ++ random() returns a random element from the set.
> enumerate : () -> List %
> ++ enumerate() returns list of elements of the set.
> add
> random() == index((1+random(size()$%))::PositiveInteger)
>
> enumerate() == [index(i::PositiveInteger) for i in 1..size()]
>
> convert(x : %) : InputForm ==
> packageCall('index, [convert(lookup(x))@InputForm]
> )$InputFormFunctions1(%)
>
> if not(% has OrderedSet) then
>
> smaller?(x : %, y : %) : Boolean ==
> lookup(x) <$PositiveInteger lookup(y)
>
> ---------------------------------------------------------------------------
> -- exported functions from StepThrough:
>
> ---------------------------------------------------------------------------
> init() : % == index(1)
> nextItem(x: %): Union(%, "failed") ==
> p : PositiveInteger := lookup(x)
> p = size() => "failed"
> index(p+1)
>
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/013da0ae-818b-359a-8979-30d19c542af3%40hemmecke.org.