Re: FriCAS and Lyx

2021-04-14 Thread Pavel Sanda
On Wed, Apr 14, 2021 at 09:20:37PM +0200, Ralf Hemmecke wrote:
> I am not sure whether LyX could compete with Jupyter in this respect

I do not think so. Although you can use it for taking notebooks my bet
is that majority of users just wants some paper or book out with nice
typesetting...


Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: FriCAS and Lyx

2021-04-14 Thread Ralf Hemmecke
> That could have wider application than just CAS - think of matlab/octave
> or python sessions behind etc. But that needs quite some coding and thinking
> of what should happen to the session when you change some code snippet
> in the middle of the document full of other snippets...

Oh, that should not be THE problem. The CAS (or whatever lives on the
other end of the channel) has an internal state. Commands will be
executed as they come. If someone working in Lyx evaluates them
out-of-order, then he/she should not expect the same result as if the
evaluation starts from top to bottom. Every system that I know does it
that way. Even if you work inside a Mathematica/Maple notebook (i.e.
never leaving their systems) you would get this behaviour. So
out-of-order execution is the norm. Of course, you might want to have a
way that executes a number of lines in LyX (possibly the whole document)
in exacty the order as they are in the .lyx file.

Well as you say, the problem is that LyX must provide some connection
mechanism. It also took the Jupyter people quite some time to come up
with a nicely working way. I am not sure whether LyX could compete with
Jupyter in this respect, but who knows in which direction LyX will go.
As always in open-source development: nothing happens until someone
comes along and programs it.

Good luck with your project.

Ralf
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: FriCAS and Lyx

2021-04-14 Thread Pavel Sanda
On Tue, Apr 13, 2021 at 06:34:10PM +0200, Ralf Hemmecke wrote:
> But I somehow fear the whole idea of how LyX connects to a CAS is not
> very much useful. 
...
> Everything else is not really interesting from
> a CAS point of view. Just imagine that you want to write a paper that
> describes the flow of computation that you do in the CAS?

I think this is fair summary of the current state of the (LyX) art. To have
more reasonable interaction similar to e.g. jupyter notebook the 
framework would need to change so the helping engine runs in backgrounds
and holds the whole session as you interact.

That could have wider application than just CAS - think of matlab/octave
or python sessions behind etc. But that needs quite some coding and thinking
of what should happen to the session when you change some code snippet
in the middle of the document full of other snippets...

Pavel

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: FriCAS and Lyx

2021-04-13 Thread Ralf Hemmecke
On 13.04.21 16:54, Richard Kimberly Heck wrote:
> On 4/13/21 7:07 AM, Pavel Sanda wrote:
>> On Tue, Apr 13, 2021 at 11:08:24AM +0200, Ralf Hemmecke wrote:
 On the other hand if you are looking for someone who would write LyX part
 I am not much optimistic. Based on the minimal code flow and users
 feedback to this forgotten area (CAS integration) I think the devel/user
 base is rather tiny.
>>> Yes, maybe the user base is tiny, but to grow it. It would be
>>> interesting to learn what Lyx actually intends with this connection.
>> I don't think there is any intention. That code was not fundamentally touched
>> for more than a decade and I doubt it's because it matured :)
>> Currently you can type some statement in math editor, trigger in menu CAS,
>> which will evaluate it & put the result back behind '=' in math editor.

Being inexperienced with lyx, I somehow managed to type an expression,
select it with my mouse and then right-click CAS->Mathematica.

The expression was

  D[Sin[x],x]

according to the console, this is what Mathematica sees.

  TeXForm[ D [ Si n[ x ] ,x ]]

Surely, this is nonsense. But I cannot say whether it is just me being
unable to input correctly.

>> Relevant part of the code where one could start and check how diffcult
>> the implementation might be is in mathed/MathExtern.cpp.

> As Pavel suggests, you would basically just need to mimic the existing
> code for the other engines. The whole process starts at
> InsetMathHull::doExtern, which calls pipeThroughExtern in
> MathExtern.cpp, which calls one of pipeThroughMaple, etc, as is
> appropriate. That then calls the methods octave(), maxima(), maple(),
> and mathematica(), which each math inset has, and which output the
> appropriate code for the relevant CAS. You really only need to touch
> pipeThroughExtern, write pipeThroughFriCAS, and write the friCAS() methods.

First of all, thanks a lot for pointing me directly to the relevant
functions.

I had a quick look over the code in that file. I would say that writing
a pipeThroughFriCAS function would be pretty simple (assuming that what
I have to provide to mathed_parse_cell is pure latex code.

But I somehow fear the whole idea of how LyX connects to a CAS is not
very much useful. As Pavel experienced, when working with a CAS, then
one usually has a lot of expressions and the CAS remembers the results
in its session memory. In other words the CAS must be running
side-by-side with LyX only gets requests from Lyx and gives back the
respective LaTeX output. Everything else is not really interesting from
a CAS point of view. Just imagine that you want to write a paper that
describes the flow of computation that you do in the CAS? That is TeX
mixed with computation results and not just evaluation of some simple
math expression.

I guess, LyX aims at other users. Fair enough.

Contact the fricas-devel mailinglist if ever LyX sees some benefit of
being a frontend to computer algebra systems.

Anyway, thank you for your feedback. I wish you a prospering future for LyX.

Ralf
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: FriCAS and Lyx

2021-04-13 Thread Richard Kimberly Heck
On 4/13/21 7:07 AM, Pavel Sanda wrote:
> On Tue, Apr 13, 2021 at 11:08:24AM +0200, Ralf Hemmecke wrote:
>>> On the other hand if you are looking for someone who would write LyX part
>>> I am not much optimistic. Based on the minimal code flow and users
>>> feedback to this forgotten area (CAS integration) I think the devel/user
>>> base is rather tiny.
>> Yes, maybe the user base is tiny, but to grow it. It would be
>> interesting to learn what Lyx actually intends with this connection.
> I don't think there is any intention. That code was not fundamentally touched
> for more than a decade and I doubt it's because it matured :)
> Currently you can type some statement in math editor, trigger in menu CAS,
> which will evaluate it & put the result back behind '=' in math editor.
>
> Relevant part of the code where one could start and check how diffcult
> the implementation might be is in mathed/MathExtern.cpp.

As Pavel suggests, you would basically just need to mimic the existing
code for the other engines. The whole process starts at
InsetMathHull::doExtern, which calls pipeThroughExtern in
MathExtern.cpp, which calls one of pipeThroughMaple, etc, as is
appropriate. That then calls the methods octave(), maxima(), maple(),
and mathematica(), which each math inset has, and which output the
appropriate code for the relevant CAS. You really only need to touch
pipeThroughExtern, write pipeThroughFriCAS, and write the friCAS() methods.

There's also a way to use an external script to parse the 'normalized'
representation of the math inset and return a value. See here
pipeThroughExtern.

We would then need a menu entry to call the new routines. We can
certainly do that part!

Riki


-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: FriCAS and Lyx

2021-04-13 Thread Pavel Sanda
On Tue, Apr 13, 2021 at 11:08:24AM +0200, Ralf Hemmecke wrote:
> > On the other hand if you are looking for someone who would write LyX part
> > I am not much optimistic. Based on the minimal code flow and users
> > feedback to this forgotten area (CAS integration) I think the devel/user
> > base is rather tiny.
> 
> Yes, maybe the user base is tiny, but to grow it. It would be
> interesting to learn what Lyx actually intends with this connection.

I don't think there is any intention. That code was not fundamentally touched
for more than a decade and I doubt it's because it matured :)
Currently you can type some statement in math editor, trigger in menu CAS,
which will evaluate it & put the result back behind '=' in math editor.

Relevant part of the code where one could start and check how diffcult
the implementation might be is in mathed/MathExtern.cpp.

> > In past I even tried to create 'fancy' calculator build on top of lyx
> > which used lyx math editor + maxima in the background, but at the
> > end I found myself using only maxima itself most of the time.
> 
> When there is interest, then someone (interested) should perhaps help me
> finding the relevant parts of the existing code an explain how the
> workflow is an what would have to be done to integrate FriCAS. Otherwise
> it simply means that there is no interest.
> I have enough other projects to deal with so that I will not invest much
> time in looking through Lyx code.

Sorry for not being more positive, but for this we'd need likely avid user
of both LyX and FriCASs.
We can wait if someone else pops up (Hi Enrico:), but given the definition
above I am afraid we are in the no interest branch of universe...

Cheers,
Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: FriCAS and Lyx

2021-04-13 Thread Ralf Hemmecke
> there is interest in the sense that we generally accept patches
> implementing new features plus minus some adaptation.

Fair enough.

> On the other hand if you are looking for someone who would write LyX part
> I am not much optimistic. Based on the minimal code flow and users
> feedback to this forgotten area (CAS integration) I think the devel/user
> base is rather tiny.

Yes, maybe the user base is tiny, but to grow it. It would be
interesting to learn what Lyx actually intends with this connection.
Is it like in Texmacs that the CAS can be used just like a frontend to
the CAS or does Lyx just copy the output of the CAS into its .lyx
format, i.e. actually no interactive use of the CAS?

> In past I even tried to create 'fancy' calculator build on top of lyx
> which used lyx math editor + maxima in the background, but at the
> end I found myself using only maxima itself most of the time.

When there is interest, then someone (interested) should perhaps help me
finding the relevant parts of the existing code an explain how the
workflow is an what would have to be done to integrate FriCAS. Otherwise
it simply means that there is no interest.
I have enough other projects to deal with so that I will not invest much
time in looking through Lyx code.

Ralf
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: FriCAS and Lyx

2021-04-13 Thread Pavel Sanda
On Sun, Apr 11, 2021 at 06:35:51PM +0200, Ralf Hemmecke wrote:
> Question here is how we can do this? It certainly needs people from the
> Lyx and the FriCAS. Is there interest? How difficult would it be?

Dear Ralf,

there is interest in the sense that we generally accept patches
implementing new features plus minus some adaptation.

On the other hand if you are looking for someone who would write LyX part
I am not much optimistic. Based on the minimal code flow and users
feedback to this forgotten area (CAS integration) I think the devel/user
base is rather tiny.

In past I even tried to create 'fancy' calculator build on top of lyx
which used lyx math editor + maxima in the background, but at the
end I found myself using only maxima itself most of the time.

I don't know FriCAS syntax, but if it's similar enough to other already
supported engines it might be easy enough to just mimick that code
for what you want...

Pavel

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel