example to 1.:

after

)co iml

)co fidepermutationsINIT

one gets

(1) -> n1()$FideTransposition

   (1)  1
Type: NonNegativeInteger
(2) -> n2()$FideTransposition

   (2)  1
Type: NonNegativeInteger
(3) -> n()$FideTransposition

   (3)  2
Type: NonNegativeInteger
(4) -> init()$FideTransposition
   init() called using oneToN1 = [1]

   (4)  [1]
Type: FideTransposition
(5) -> set(3,5)$FideTransposition

   (5)  [3, 5]
Type: List(NonNegativeInteger)
(6) -> n1()$FideTransposition

   (6)  3
Type: NonNegativeInteger
(7) -> n2()$FideTransposition

   (7)  5
Type: NonNegativeInteger
(8) -> n()$FideTransposition

   (8)  8
Type: NonNegativeInteger
(9) -> init()$FideTransposition

   (9)  [1]
Type: FideTransposition

expected answer is [1,2,3]



Am 22.01.24 um 13:51 schrieb Qian Yun:

On 1/22/24 20:46, Prof. Dr. Johannes Grabmeier wrote:
Dear all,

1. following problem: I use Reference NNI to change internal values of a domain. A further constant function: init: () ->% depends of the changed values. It seems that FriCAS does not call the constant function again, but stores the old value of init(), then out of date. Non constant functions of course correctly use the changed values. How can I bring FriCAS to *call *and *evaluate* again the constant function with the updated values?

2. Another, very strange problem was noted:

The referenced values where in a domain called

)abbrev domain FIDETR FIDETransposition

Believe me or not: the changing of the referenced values did not work!

After long searching of the reasons I found: this depended on the name "FIDETransposition", i.e. the change to

)abbrev domain FIDETR FideTransposition

caused, that changing of referenced values work as expected! Can send an example, if someone is interested.


Yes, examples please, otherwise it's hard to debug.

Problem in 1 should not happen, because there are similar things in
FriCAS code base and they work well.  So please show me the example.

- Qian

--
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
Fax: +49-(0)-991-2979592

--
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/76a5fc70-c37b-4502-9c5a-974a0d250d86%40grabmeier.net.
)abbrev domain FIDETR FideTransposition
FideTransposition(): Exports == Implementation where
  PI   ==> PositiveInteger
  NNI  ==> NonNegativeInteger
  I    ==> Integer
  OF   ==> OutputForm
  mLP  ==> messageLevelPointer
  msg  ==> message

  Exports ==> Join(InternalMessageLevel, RetractableFrom List NNI, 
StepThrough(), Finite) with
    set_n1: NNI -> NNI
      ++ set_n1(n1) sets size of group S1
    set_n2: NNI -> NNI
      ++ set_n2(n1) sets size of group S2
    n1: () -> NNI
      ++ \spad{set_n1()} yields the size of subgroup S1 of the bracket.
    n2: () -> NNI
      ++ \spad{set_n2()} yields the size of subgroup S2 of the bracket.
    n: () -> NNI
      ++ \spad{set_n()} yields the size of the whole bracket.
    set: (NNI, NNI) -> List NNI
      ++ set(n1, n2) sets the sizes of group S1 and S2
    others: % -> List NNI 
      ++ others(fT) returns the other n2-n1 elements in increasing order.
    permutation: % -> Permutation NNI
      ++ permutation(fT) computes the permutation, which is coded by fT.
    permutationShifted: % -> Permutation NNI
      ++ permutationShifted(fT) computes the permutation, which is coded by fT, 
but
      ++ shifted by n1.
  Implementation ==> add
  
--------------------------------------------------------------------------------
  -- import of domains and packages
  
--------------------------------------------------------------------------------
    import OF
    import Combinatorics
    import IntegerCombinatoricFunctions Integer 
  
--------------------------------------------------------------------------------
  -- global variables
  
--------------------------------------------------------------------------------
    Rep := List NNI
    rep(t : %) : Rep == t @ Rep
    per(rp : Rep) : % == rp @ %
  
--------------------------------------------------------------------------------
  -- implementation of local functions
  
--------------------------------------------------------------------------------
    n1Ref : Reference NNI := ref 1
    n2Ref : Reference NNI := ref 1
    n  : NNI := deref n1Ref + deref n2Ref
    oneToN1: List NNI := [i for i in 1..deref n1Ref]
    oneToN2: List NNI := [i for i in 1..deref n2Ref]
    --oneToN(n2: NNI): List NNI == [i for i in 1..n2]
  
--------------------------------------------------------------------------------
  -- implementation of global functions from the definition
  
--------------------------------------------------------------------------------
  -- from SetCategory
  
--------------------------------------------------------------------------------
    coerce(t: %): OutputForm == coerce(rep t)$Rep@OutputForm
  
--------------------------------------------------------------------------------
  -- from RetractableTo List NNI
  
--------------------------------------------------------------------------------
    coerce(t : %): List NonNegativeInteger == rep t
    retractIfCan(lst: List NNI): Union(%, "failed") ==
      not (deref n2Ref = #lst) => "failed"
      not (sort(lst) = lst) => "failed"
      per lst
  
--------------------------------------------------------------------------------
  -- from StepThrough
  
--------------------------------------------------------------------------------
    init(): % ==  
      if mLP 0 then print hconcat [toOF "init() called using oneToN1 = ", 
oneToN1 :: OF]
      per oneToN1
      --n1 > n2 => error "FIDETransposition: first argument larger than second 
argument"
      --per [i for i in 1..deref n1Ref]
      --per oneToN (deref n1Ref)
      --index(1)
      --variationLex(deref n2Ref, deref n1Ref, 0)
--    nextItem (t: %): Union(%,"failed") == 
--      nxtI : Union(List NNI, "failed") := nextVariationLex(rep t, deref 
n2Ref) 
--      nxtI case "failed" => "failed"
--      per nxtI
  
--------------------------------------------------------------------------------
  -- from Finite
  
--------------------------------------------------------------------------------
    size(): NNI == 
      --n1 > n2 => 0
      (binomial(deref n2Ref, deref n1Ref)*factorial deref n1Ref) :: NNI
--    enumerate(): List % == [per v for v in listVariationsLex(deref n2Ref, 
deref n1Ref)]
--    random(): % == 
--      r : NNI := random size()
--      variationLex(deref n2Ref, deref n1Ref, r)
--    index(r: PI):  % == variationLex(deref n2Ref, deref n1Ref, (r-1) :: NNI)
--    lookup(t: %):  PI == (rankVariationLex(deref n2Ref, rep t) + 1) :: PI
    smaller?(t1: %, t2: %): Boolean == smaller?(rep t1, rep t2)
    convert(t: %): InputForm == convert(rep t)$Rep
  
--------------------------------------------------------------------------------
  -- from %
  
--------------------------------------------------------------------------------
    set_n1(an1: NNI): NNI == 
      an1 > deref n2Ref => error "FIDETransposition: argument larger than n2"
      setref(n1Ref, an1)
      n  := deref n1Ref + deref n2Ref
      oneToN1 := copy [i for i in 1..deref n1Ref]
      oneToN2 := copy [i for i in 1..deref n2Ref]
      deref n1Ref
    set_n2(an2: NNI): NNI == 
      deref n1Ref > an2 => error "FIDETransposition: argument smaller than n1"
      setref(n2Ref, an2)
      n  := deref n1Ref + deref n2Ref
      oneToN1 := [i for i in 1..deref n1Ref]
      oneToN2 := [i for i in 1..deref n2Ref]
      deref n2Ref
    set(an1: NNI, an2: NNI): List NNI == 
      an1 > an2 => error "FIDETransposition: argument 1 larger than argument 2"
      setref(n1Ref, an1) 
      setref(n2Ref, an2)
      n  := deref n1Ref + deref n2Ref
      oneToN1 := [i for i in 1..deref n1Ref]
      oneToN2 := [i for i in 1..deref n2Ref]
      [deref n1Ref, deref n2Ref]
    n1(): NNI == deref n1Ref
    n2(): NNI == deref n2Ref
    n(): NNI == n1() + n2()
    --others(fT: %): List NNI == reverse setDifference( oneToN(deref n2Ref), fT 
:: List NNI)
    others(fT: %): List NNI == reverse setDifference( oneToN2, fT :: List NNI)
    permutation(t: %): Permutation NNI == 
      --coercePreimagesImages [oneToN(n2), concat(t :: List NNI, others(t))]
      coercePreimagesImages [oneToN2, concat(t :: List NNI, others(t))]
    permutationShifted(t: %): Permutation NNI == 
      prIm : List NNI := [u+deref n1Ref for u in 1..deref n2Ref]
      Im : List NNI := [u+deref n1Ref for u in concat(t :: List NNI, others(t))]
      coercePreimagesImages [prIm, Im]
-- )abbrev category IML InternalMessageLevel
--Copyright (c) 2024,2009 Johannes Grabmeier
--All rights reserved.
--
--Redistribution and use in source and binary forms, with or without
--modification, are permitted provided that the following conditions are
--met:
--
--    - Redistributions of source code must retain the above copyright
--      notice, this list of conditions and the following disclaimer.
--
--    - Redistributions in binary form must reproduce the above copyright
--      notice, this list of conditions and the following disclaimer in
--      the documentation and/or other materials provided with the
--      distribution.
--
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

)abbrev category IML InternalMessageLevel
++ Author: Johannes Grabmeier
++ Date Created: 2009-03-05
++ Date Last Updated: 2024-01-21 (0.5) 2021-12-18 (0.4) 2009-04-16 (0.3)  
2009-03-19 (0.2)
++ Version: 0.5 added message level pointer 4
++ Version: 0.4 underscoreLine()
++ Basic Functions:
++ Related Constructors: 
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description:
++   For each domain which uses this category we define three
++   internal message level pointers pF1, pF2, pF3, pF4 to boolean values, 
++   default pointers are set to false. This gives three message levels 1,2,3,4 
++   default is 0. The value of the pointers are used as print flags.
++   If a code has statements like "if deref pF1 then print ...."
++   the users of the domain can dynamically change the message level
++   to get internal informations. This can be done by \axiom{setMessageLevel}
InternalMessageLevel(): Category == with
    toOF:  String -> OutputForm
      ++ toOF(st) transforms string st to OutputForm
    setMessageLevel:  NonNegativeInteger -> NonNegativeInteger 
      ++ setMessageLevel(l) depending on l=0 - only messages conditioned by mLP 0
      ++ are printed. l from 1, 2, 3, 4 gives internal messages and 
informations 
      ++ with increasing details, e.g. l=3 gives all messages conditioned by
      ++ mLP 1, mLP 2 and mLP 3, but not the ones of mLP 4.
    messageLevel?:  () -> NonNegativeInteger 
      ++ messageLevel() returns 0, 1, 2, 3 or 4 as message levels
    mLP: NonNegativeInteger ->  Boolean 
      ++ mLP(i) returns the value to which the i-th pointer points.
    messageLevelPointer: NonNegativeInteger ->  Boolean 
      ++ messageLevelPointer(i) returns the value to which the i-th pointer 
points.
    messageLevelPointers: () ->  List Boolean
      ++ messageLevelPointers returns a list of all values to which 
      ++ the pointers point.
    line: String -> OutputForm
      ++ line(c: String) constructs a line, i.e. 80 copies of String c.
    line: (String, Integer) -> OutputForm
      ++ line(c: String, k)) constructs a line, i.e. 80-k copies of String c.
    dashLine: Integer -> OutputForm
      ++ dashLine(k) prints a dash line:   -------- ... after k blanks.
    dashLine: () -> OutputForm
      ++ dashLine () prints a dash line:----------- ...
    plusLine: Integer -> OutputForm
      ++ plusLine(k) prints a plus line:   ++++++++ ... after k blanks.
    plusLine: () -> OutputForm
      ++ plusLine () prints a dash line:+++++++++++ ...
    -- no constants are possible, although it compiles without problems:
    equalLine: Integer -> OutputForm
      ++ equalLine(k) prints an equal line:   ======== ... after k blanks.
    equalLine: () -> OutputForm
      ++ equalLine () prints an equal line: ============ ...
    dottedLine: Integer -> OutputForm
      ++ dottedLine(k) prints a dotted line:   ........ ... after k blanks.
    dottedLine: () -> OutputForm
      ++ dottedLine () prints a dotted line: ............ ...
    hashLine: Integer -> OutputForm
      ++ hashLine(k) prints a hashline:   ######## ... after k blanks.
    hashLine: () -> OutputForm
      ++ hashLine () prints a hash line: ############### ...
    colonLine: Integer -> OutputForm
      ++ colonLine(k) prints a colon line:   :::::::: ... after k blanks.
    colonLine: () -> OutputForm
      ++ colonLine () prints a colon line: :::::::::::::: ...
    starLine: Integer -> OutputForm
      ++ starLine(k) prints a star line:   ******** ... after k blanks.
    starLine: () -> OutputForm
      ++ starLine () prints a star line: ************* ...
    underscoreLine: Integer-> OutputForm
      ++ underscoreLine(k) prints an underscore line:   ________ ... after k 
blanks.
    underscoreLine: () -> OutputForm
      ++ starLine () prints a star line: _____________ ...
    emptyLine: () -> OutputForm
      ++ starLine () prints an empty line: 
    toOF: String -> OutputForm
  add
    OF  ==> OutputForm
    import OF
    -- creations of four pointers for 5 levels
    pF0: Reference Boolean := ref true
    pF1: Reference Boolean := ref false
    pF2: Reference Boolean := ref false
    pF3: Reference Boolean := ref false
    pF4: Reference Boolean := ref false

    toOF(st:  String): OutputForm == st pretend OutputForm

    messageLevelPointer(i: NonNegativeInteger): Boolean == 
        i = 0 => deref pF0 
        i = 1 => deref pF1
        i = 2 => deref pF2
        i = 3 => deref pF3
        i = 4 => deref pF4
        error("messageLevelPointer: no such pointer")

    mLP(i: NonNegativeInteger): Boolean == messageLevelPointer(i)

    messageLevelPointers(): List Boolean == [deref pF1, deref pF2, deref pF3, 
deref pF4]

    messageLevel?(): NonNegativeInteger ==
        deref pF4 => 4
        deref pF3 => 3
        deref pF2 => 2
        deref pF1 => 1
        0

    setMessageLevel(l : NonNegativeInteger): NonNegativeInteger ==
        l = 1 => 
                -- do not use pF1 := ref true, as ref creates a new pointer!
                setref(pF1, true)
                setref(pF2, false)
                setref(pF3, false)
                setref(pF4, false)
                l
        l = 2 => 
                setref(pF1, true)
                setref(pF2, true)
                setref(pF3, false)
                setref(pF4, false)
                l
        l = 3 => 
                setref(pF1, true)
                setref(pF2, true)
                setref(pF3, true)
                setref(pF4, false)
                l
        l >= 4 => 
                setref(pF1, true)
                setref(pF2, true)
                setref(pF3, true)
                setref(pF4, true)
                l
        setref(pF1, false)
        setref(pF2, false)
        setref(pF3, false)
        setref(pF4, false)
        l

    line(c: String, k : Integer): OF == 
      k > 80 => error "line: second parameter too large"
      message concat concat(new(k :: NonNegativeInteger, " "), new((80-k) :: 
NonNegativeInteger, c))
    line(c: String): OF == line(c,0)
    dashLine(k: Integer): OF == line("-",k)
    dashLine(): OF == line("-")
    plusLine(k: Integer): OF == line("+",k)
    plusLine(): OF == line("+")
    emptyLine(): OF == line(" ")
    equalLine(k: Integer): OF == line("=",k)
    equalLine(): OF == line("=")
    dottedLine(k: Integer): OF == line(".",k)
    dottedLine(): OF == line(".")
    colonLine(k: Integer): OF == line(":",k)
    colonLine(): OF == line(":")
    hashLine(k: Integer): OF == line("#",k)
    hashLine(): OF == line("#")
    starLine(k: Integer): OF == line("*",k)
    starLine(): OF == line("*")
    underscoreLine(k: Integer): OF == line("__",k)
    underscoreLine(): OF == line("__")
    toOF(s: String): OF == s pretend OF
)co iml
)co fidepermutationsINIT
n1()$FideTransposition
n2()$FideTransposition
n()$FideTransposition
init()$FideTransposition
set(3,5)$FideTransposition
n1()$FideTransposition
n2()$FideTransposition
n()$FideTransposition
init()$FideTransposition

Reply via email to