Discussion:
[fricas-devel] interpreter (command line): syntax of "rule"
Riccardo GUIDA
2018-07-05 16:20:44 UTC
Permalink
Hi

I do not understand how the syntax

rule sin(x) == x -- see (1) below

is accommodated to fit in the signature
(EXPR(INT), EXPR(INT)) -> RULE(INT,INT,EXPR(INT))
see fricas message below

In other words: in (1) I do not see a call to a function "rule" of two parameters, rule(f,g): what's happening? Is this an interpreter (command line) language construct that has nothing to do with standard function call of type rule(f,g)?

Can one rewrite (1) as an equivalent function call rule(f,g) for some f,g?

Thanks in advance for any hint,
Riccardo


(1) -> rule sin(x) == x -- unwise rule

Function Selection for sin
Arguments: VARIABLE(x)
-> no appropriate sin found in Variable(x)
-> no appropriate sin found in Symbol
-> no appropriate sin found in Variable(x)
-> no appropriate sin found in Symbol

Modemaps from Associated Packages
no modemaps

Remaining General Modemaps
[1] D -> D from D if D has TRIGCAT

[1] signature: EXPR(INT) -> EXPR(INT)
implemented: slot $$ from EXPR(INT)


Function Selection for rule
Arguments: (EXPR(INT), VARIABLE(x))
-> no appropriate rule found in Expression(Integer)
-> no appropriate rule found in Variable(x)
-> no appropriate rule found in Expression(Integer)
-> no appropriate rule found in Variable(x)

Modemaps from Associated Packages
no modemaps

Remaining General Modemaps
[1] (D1,D1) -> RewriteRule(D2,D3,D1) from RewriteRule(D2,D3,D1)
if D2 has SETCAT and D3 has Join(RING,PATMAB(D2),COMPAR,
KONVERT(PATTERN(D2))) and D1 has Join(FS(D3),PATMAB(D2),
KONVERT(PATTERN(D2)))

[1] signature: (EXPR(INT), EXPR(INT)) -> RULE(INT,INT,EXPR(INT))
implemented: slot $(Expression (Integer))(Expression (Integer)) from RULE(INT,INT,EXPR(INT))


(1) sin(x) == x
Type: RewriteRule(Integer,Integer,Expression(Integer))
(2) ->
--
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.
Bill Page
2018-07-05 17:23:09 UTC
Permalink
On Thu, Jul 5, 2018 at 12:20 PM, Riccardo GUIDA
Post by Riccardo GUIDA
Hi
I do not understand how the syntax
rule sin(x) == x -- see (1) below
is accommodated to fit in the signature
(EXPR(INT), EXPR(INT)) -> RULE(INT,INT,EXPR(INT))
see fricas message below
In other words: in (1) I do not see a call to a function "rule" of two
parameters, rule(f,g): what's happening? Is this an interpreter (command
line) language construct that has nothing to do with standard function call
of type rule(f,g)?
Can one rewrite (1) as an equivalent function call rule(f,g) for some f,g?
The syntax in (1) is a little bit of interpreter "magic". It is just
sugar for (2)

(1) -> rule sin(x) == x

(1) sin(x) == x
Type: RewriteRule(Integer,Integer,Expression(Integer))
(2) -> _rule(sin('x),'x)

(2) sin(x) == x
Type: RewriteRule(Integer,Integer,Expression(Integer))

The escape symbel _ is necessary in order to defeat the magic.

See also some other possibly useful functions in the RewriteRule,
Ruleset and Pattern domains. Eg,

(3) -> )sh RewriteRule
RewriteRule(Base: SetCategory,R:
Join(Ring,PatternMatchable(Base),Comparable,ConvertibleTo(Pattern(Base))),F:
Join(FunctionSpace(R),PatternMatchable(Base),ConvertibleTo(Pattern(Base))))
is a domain constructor
Abbreviation for RewriteRule is RULE
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------

?=? : (%, %) -> Boolean coerce : Equation(F) -> %
coerce : % -> OutputForm ?.? : (%, F) -> F
hash : % -> SingleInteger latex : % -> String
lhs : % -> F pattern : % -> Pattern(Base)
retract : % -> Equation(F) rhs : % -> F
rule : (F, F, List(Symbol)) -> % rule : (F, F) -> %
?~=? : (%, %) -> Boolean
elt : (%, F, PositiveInteger) -> F
hashUpdate! : (HashState, %) -> HashState
quotedOperators : % -> List(Symbol)
retractIfCan : % -> Union(Equation(F),"failed")
suchThat : (%, List(Symbol), (List(F) -> Boolean)) -> %
--
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.
Riccardo GUIDA
2018-07-05 18:28:58 UTC
Permalink
Post by Bill Page
The escape symbel _ is necessary in order to defeat the magic.
Great, many thanks Bill! I saw the API for RewriteRule and I was willing to try these functions, but I was unable to defeat interpreter's magics.

riccardo
--
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...