Discussion:
[fricas-devel] New domains FiniteSet / OneToN
Prof. Dr. Johannes Grabmeier privat
2018-06-30 15:08:29 UTC
Permalink
Hi all,
since long I have a domain which respresents the elements of a list as a
elements of the domain: FiniteSet(S, List S) and a special case OneToN =
{1,2,3,...,n}.

Two problems:

1. < of PartialOrder does not work properly. Note, that the order of the
elements in the finite set is the given order in the list.

2. OneToN: my attempts to make it as comfortable for the user by using
as underlying domain PositiveInteger gives an error message:

(14) -> enumerate()$Q10

   >> System error:
   The value
  #:G2267
is not of type
  LIST

Using Integer instead gives confusion for coercing from positive
integers to OneToN by missing retractIfCan, but could not be identified,
what the system means.
Is the list argument ln a problem?


If the problems can be fixed, the domains could go into the system.

-- Here is an example computation:


FS4 := FiniteSet(Integer, [2,1,3,4])


   (1)  FiniteSet(Integer,[2,1,3,4])
                                                                                         
Type: Type
eFS4 := enumerate()$FS4


   (2)  [2, 1, 3, 4]
                                                            Type:
List(FiniteSet(Integer,[2,1,3,4]))
a : FS4 := first eFS4


   (3)  2
                                                                  Type:
FiniteSet(Integer,[2,1,3,4])
b : FS4 := second eFS4


   (4)  1
                                                                  Type:
FiniteSet(Integer,[2,1,3,4])
a <= b


   (5)  true
                                                                                      
Type: Boolean
b <= a


   (6)  false
                                                                                      
Type: Boolean
a < b


   (7)  false
                                                                                      
Type: Boolean
"in the interpreter this is true, in accordance with the implementation
of <= in the domain!"


   (8)  "in the interpreter this is true, in accordance with the
implementation of <= in the domain!"
                                                                                       
Type: String
(a <= b) and not(b <= a)


   (9)  true
                                                                                      
Type: Boolean
Q10 := OneToN 10


   (10)  OneToN(10)
                                                                                         
Type: Type
enumerate()$Q10


   >> System error:
   The value
  #:G2456
is not of type
  LIST


--
Mit freundlichen GrÌßen

Johannes Grabmeier

Prof. Dr. Johannes Grabmeier
Köckstraße 1, D-94469 Deggendorf
Tel. +49-(0)-991-2979584, Tel. +49-(0)-151-681-70756
Tel. +49-(0)-991-3615-141 (d), Fax: +49-(0)-32224-192688
--
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 fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Waldek Hebisch
2018-06-30 15:52:18 UTC
Permalink
Just quick remark: in similar situations I used a helper
package, like:

)abbrev package OTNHELP OneToNHelper
OneToNHelper : with
mklist : PositiveInteger -> List(PositiveInteger)
== add
mklist(n) == [i :: PositiveInteger for i in 1..n]$List(PositiveInteger)

Than in OneToN:

private ==> FiniteSet(PositiveInteger, mklist(n)$OneToNHelper) add

This seems to work around the problem.
--
Waldek Hebisch
--
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 fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Prof. Dr. Johannes Grabmeier privat
2018-07-01 05:33:20 UTC
Permalink
Thanks, this solves one of the two problems!

The first problem seems to have to do that seeningly the interpreter
deals differently with numbers 1 and 2 and perhaps calls < from the
Integers.

The coorect  behaviour is shown by the following example with Strings:

C :=  FiniteSet(String, ["red", "green", "yellow", "pink"])


   (160)  FiniteSet(String,["red","green","yellow","pink"])
                                                                                         
Type: Type
c := index(2)$C


   (161)  "green"
                                             Type:
FiniteSet(String,["red","green","yellow","pink"])
d := nextItem c


   (162)  "yellow"
                                  Type:
Union(FiniteSet(String,["red","green","yellow","pink"]),...)
c <= d


   (163)  true
                                                                                      
Type: Boolean
d <= c


   (164)  false
                                                                                      
Type: Boolean
c < d


   (165)  true
Post by Waldek Hebisch
Just quick remark: in similar situations I used a helper
)abbrev package OTNHELP OneToNHelper
OneToNHelper : with
mklist : PositiveInteger -> List(PositiveInteger)
== add
mklist(n) == [i :: PositiveInteger for i in 1..n]$List(PositiveInteger)
private ==> FiniteSet(PositiveInteger, mklist(n)$OneToNHelper) add
This seems to work around the problem.
--
Mit freundlichen Grüßen

Johannes Grabmeier

Prof. Dr. Johannes Grabmeier
Köckstraße 1, D-94469 Deggendorf
Tel. +49-(0)-991-2979584, Tel. +49-(0)-151-681-70756
Tel. +49-(0)-991-3615-141 (d), Fax: +49-(0)-32224-192688
--
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 fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, vi
Waldek Hebisch
2018-07-19 15:32:18 UTC
Permalink
Post by Prof. Dr. Johannes Grabmeier privat
Thanks, this solves one of the two problems!
The first problem seems to have to do that seeningly the interpreter
deals differently with numbers 1 and 2 and perhaps calls < from the
Integers.
C := FiniteSet(String, ["red", "green", "yellow", "pink"])
You defined '<='. Which means that you used inherited '<'. But
S is "closer" to FiniteSet than PartialOrder so '<' was inherited
from S. More precisely, FriCAS _first_ looks for operation in
S and only later in categories. Defining '<' solves problem
when S is Integer. But in general one would have to override
all operations that depend on order. Namely, operations defined
in S use order from S. I must admit that I find it safer to avoid
inheritance from domains in cases when one wants to redefine
operations.
--
Waldek Hebisch
--
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 fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Loading...