Ai Dreams Forum

Member's Experiments & Projects => General Project Discussion => Topic started by: ivan.moony on November 10, 2022, 10:25:26 am

Title: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on November 10, 2022, 10:25:26 am
the idea

Experimentation with different custom made programming languages related to theorem proving has been one of my interests for a long time. Why theorem proving? Because it seemed like a logical step towards AI. In a meanwhile, deep learning ANNs (artificial neural networks) took over the world, and it could be a good thing. Similarity between an ANN and a theorem prover is that the starting point and ending result are the same in both cases, but the process in between is different. ANN utilizes pretty obscure weighted graph connecting input and output while theorem proving (in cases I'm considering) utilizes potentially human readable set of constructive theorems that need to be combined to connect input to output.

The theorem proving is still an area of my interest, but with addition of one missing link that ANNs seem to do pretty well (or at least in some extent). ANNs use the nowdays-all-present deep learning techniques to automatically form the connections between input and output. Analogously, the link I'm trying to explore is an alternative to deep learning in a form of automated semi-axiom construction. Here, I'm making a distinction between theorem proving and semi-axiom construction. In theorem proving, axioms need to be manually fed into the system to be used in further automated theorem construction. In semi-axiom construction, I'm seeking for a way to automatically construct semi-axioms, with semi-axioms being both axioms or theorems.

Googling around the web about this process (in 2022) gives somewhat rare and specialized results, so the space for a progress may be opened. I believe that appropriate term for the process I'm trying to explore could be "generalized theory synthesis". There are already some achievements on this process in a form of algorithm synthesis, and that is exactly direction I'm trying to head at, only applied also to theorems.

To finally explore the blurry cloud of theory synthesis and to see it in more focused features, the plan would be to fuse a selection of my existing languages, and present them in gradual form under the same language named Tricosm. The language should be applicable to theory synthesis, as well as to algorithm synthesis. In a simple example, from provided data:

input -> output
---------------
    2 -> 4
    4 -> 8
    8 -> 16
   16 -> 32

one of the generated theories (given that we already know how to handle integers and multiplication) would be:

input -> output
---------------
    x -> 2 * x


implementation

Co-rewrite takes an input file, an arbitrary metaprogram, and constructs an output file from the input file using the metaprogram. The metaprogram is actually a set of formulas similar to those in math science with the difference that the Co-rewrite formulas may transform not only math expressions, but also any kind of language expression.

It is possible to feed to Systelog a formula in a form of f(program(input) -> output) -> program where function program is being automatically constructed and returned by higher order function f, provided that we know what input -> output mappings hold.

The language goals are having minimal design, beginner friendly documentation, conveniently generating completely functional executable, multiplatform development environment, multiplatform runtime environment, and self hosting compiler.

progress

In this thread I plan to keep a log about the progress in programming the Systelog language for which I plan to be open sourced and hosted publicly on GitHub. Of course, I'd be delighted to hear any comments or to answer any questions in the same thread.


Project homepage is at : https://github.com/contrast-zone/co-rewrite (https://github.com/contrast-zone/co-rewrite)
Title: Re: λόγος - a gradually typed language for generalized theory synthesis
Post by: MagnusWootton on November 10, 2022, 01:09:27 pm
You need to write your autobiography and call it  "I, Ivan."    O0
Title: Re: %u03BB%u03CC%u03B3%u03BF%u03C2 - a gradually typed language for generalized theory synthesis
Post by: ivan.moony on November 10, 2022, 01:14:05 pm
You need to write your autobiography and call it  "I, Ivan."    O0

I think more appropriate title would be: "A highway to madness".  ;)
Title: Re: τρίκοσμ - a gradually typed language for generalized theory synthesis
Post by: ivan.moony on December 31, 2022, 04:15:28 pm
I decided to do some cleanup of this project for the end of the year (I believe feng shui would recommend this at this time of year for attracting a success - not that I'm a fanatic of feng shui, but anyway... it says that dust slows down energy flow, and this is a kind of de-dusting, plus winter should be a great time for new beginnings).

I renamed the project to Tricosm  8) and created a nice logo:

(https://github.com/tricosm/tricosm/raw/master/media/7promo.svg)

Also did a set up of a new GitHub organization to keep all the details of this long term hobby project: https://github.com/tricosm (https://github.com/tricosm)

Worked out some implementation details (see updates of "implementation" section at the top post), and made some targeting audience decisions.

This would be a new general project outline from the Tricosm home page:


As always, looking forward for suggestions, comments, questions, and discussions :)

And happy New Year everyone!
:present: :ctree: :present:
Title: Re: τρίκοσμ - a gradually typed language for generalized theory synthesis
Post by: HS on December 31, 2022, 06:50:51 pm
Happy New Year, Ivan!
Title: Re: Systemath - a gradually typed language for generalized theory synthesis
Post by: ivan.moony on January 04, 2023, 01:45:38 pm
I renamed the project once again to: Systemath, and changed some design decisions. I hope this is it for a while. Seems no one is running a project with the same name on the web.

I'm about to update corresponding working draft.
Title: Re: Co-rewrite: a language for generalized theory synthesis
Post by: ivan.moony on February 14, 2023, 06:28:11 am
Working draft is updated, but expect some changes during further development.

Programming tasks done:

About half way to finished product, check out new updates at: https://github.com/contrast-zone/co-rewrite (https://github.com/contrast-zone/co-rewrite).

Direct playground link is here: https://contrast-zone.github.io/co-rewrite/playground/ (https://contrast-zone.github.io/co-rewrite/playground/). Choose an example, pass an input, and watch it being paired to relevant output. Provided examples are covered up to extensional reasoning.

Title: Re: Co-rewrite: a language for generalized theory synthesis
Post by: MagnusWootton on February 14, 2023, 07:27:41 am
So with this theorem proving,   its about the robot building a working model of its environment!

So it needs to know,  "Is this theorem a part of where I live, or is it not?"

But how exactly are u getting this mechanism to actually happen with the computer causing it,  thats where ur talent is coming in!
Title: Re: Reasoner.js: a language for generalized theory synthesis
Post by: ivan.moony on March 28, 2023, 04:45:42 am
It's been a ruff month...

Worked out mostly theoretical aspect of implications and co-implications to get a better understanding of automated reasoner. Now I have theoretical indices that I got it right from the first implementation.

Did a bit of syntax refactoring, corrected the implementation (now it uses exactly the same algorithm - only on negated rules - for backward chaining), and eradicated some bugs. The implementation takes about 350 LOC.

Also made some decisions about the future of the project: I may choose it to be a logic database for programming symbolic AI. I'm also considering bundling it with IDE and system debugger.

Code: text
project status:
    [ ] alpha conception
        [x] theorizing
        [ ] implementing
            [x] parsing input s-exprs
            [x] extensional reasoning
                [x] pattern matching involving write side disjunctions
                [x] non-deterministic matching involving read side conjunctions
                [x] non-deterministic matching involving write side disjunctions
                [x] pairing input to output
            [ ] intensional reasoning
                [ ] untyped variables
                [ ] typed variables
                [ ] free variables
            [ ] nested rules
            [ ] finalizing tasks
                [ ] sane error messages
                [ ] packaging executables
    [ ] beta testing and revising code
    [ ] gamma release

As usual, playground link is here (https://symbolverse.github.io/reasoner.js/playground/).
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on May 31, 2023, 09:13:12 pm
Been busy with my other project and making a new web page for my mother's business last month, but finally recently returned to reasoner.js to deal with variables. I thought it would be a two-working-days-solution, but I stumbled upon problems with combining variables with nondeterministic reasoning. The proof structure ramifies, and I know it has to join back somewhere, but tracking it becomes a nearly debugging hell. I based my algorithm on some optimizations not caring about back propagating variables, and now the algorithm chokes. I have to be an Einstein to fix it the right way, and I'm not the Einstein. Serves me right, when I program without planning, but who would plan that far, I had to start with something...

Anyway, the playground of what is finished is here (https://symbolverse.github.io/reasoner.js/playground/) (and it works "somehow" - still would be some things to fix), but I lean towards entirely resetting the project and start fresh. This would be my second project reset (since I'm counting in logs), but I feel like I have new ideas that I just have to implement from the start. The code now has more than 400 LOC, and I can't gather my thoughts around it, so I'll probably try to make it simpler, if not shorter if I opt for another reset.

:-[

Those were some bad news, but that's not all to report. Before programming I was paying a bit attention to the future promotion. Check out my new promo page (https://github.com/symbolverse) to see if you like it. I have a new logo too. Not much, and maybe a bad timing, but it had to be done at some point in time. It may be useful later.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: WriterOfMinds on May 31, 2023, 11:32:16 pm
Sometimes you just have to learn what the obstacles are by going ahead and trying to do something. Maybe it feels like wasted time (I know, I hate it when stuff like this happens to me), but it's really a step on the way.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on June 04, 2023, 03:54:21 pm
I'm not giving up: https://symbolverse.github.io/ (https://symbolverse.github.io/)
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on June 07, 2023, 08:05:49 am
All right, taking a new approach. I'm inventing algorithm similar to those for parsing CFG, but only I want also to support unrestricted grammars, left side conjunctions and right side disjunctions, and variables. This would take some time in a matter of weeks, but this time I'm planning it all ahead not to fall into the same trap like from the last few days. Mitigating circumstance is that I'm not doing the full parser of flat text, yet verifier of ready-made AST in a form of s-exprs. I'm doing it on paper first, and when it's finished, I move onto programming. Result I'm hoping for? Constructive deductive system.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on June 16, 2023, 09:24:39 am
Project reset done. Reprogrammed it to functionality that I had in previous version, but this time I have an idea how to proceed with variables. Postponed nondeterministic reasoning for later. Crux code size reduced from ~160 LOC to ~70 LOC.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on July 10, 2023, 07:05:35 pm
So far, so good, variables should more-or-less work. Here: https://mind-child.github.io/reasoner.js/playground/ (https://mind-child.github.io/reasoner.js/playground/). Sure there are bugs I don't know about, but the further examples battery should do the job.

Not sure what to do with nondeterministic conjunctions and disjunctions. I left it for later, but... the thing is already Turing complete. Dunno... I might make that nondeterministic effort if it is not too complicated to implement. I try to cherish a minimalistic approach, so... maybe.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on August 21, 2023, 06:20:43 pm
Reasoner.js just got gradual typing

Reasoner.js is a conceptual term graph rewriting system I'm developing for a while now. It specifically takes an s-expr input (may be AST or other data), transforms the input, and outputs another s-expr (again may be AST or something else).

Until now, (1st step) input would be validated against grammar specifying input type, and output would be constructed (2nd step) from grammar specifying output type with additional transformation rules abducing backwards the inference line.

In this iteration, I separated transformation rules from output rules while input kept the same treatment. So now it does: (1st step) validating input forwards, (2nd step) applying transformation rules, and (3rd step) validating output backwards. All steps are performed using the same AST processing algorithm, changing only input, output, and direction parameters.

This separation enabled isolating the step of applying transformation rules from initially imbued output type checking, labelling the project as gradually typed system.

There is still some interesting work to do like non-deterministic inference with left side conjunctions and right side disjunctions, which would place this system side-by-side with Hilbert calculus, natural deduction calculus, and sequent calculus.

Nevertheless, already implemented functionality provides possibilities for many interesting definitions like rudimentary equality predicate implementation, branching choice decision, Boolean calculator, and a lot more since the internal AST processing algorithm is already Turing complete.

This iteration also provides rudimentary insight to AST construction path which will be advanced to simplified proof elaboration in the future versions.

So, things go on bit by bit, and I'm slowly approaching the production version, hoping to be finally used by hobby programmers researching and fastly prototyping custom formal systems.

To check out the current project iteration, please refer to online playground (https://contrast-zone.github.io/reasoner.js/playground/) and the project home page (https://github.com/contrast-zone/reasoner.js).
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on October 21, 2023, 05:36:21 am
I took a break and invested some time in the future PR. This would be the new PR site: https://mind-child.github.io/ (https://mind-child.github.io/).

I hope to offer a dream about building a true AI. I'd like users to invest enough effort in their creation to be able to finally say "I built it", or at least "I raised it". I believe that feeling they'd have after doing it would be worth of the effort. I'll try to do my best to provide them a solid foundations to create upon.

And I've got a cute new logo, look:
(https://mind-child.github.io/mind-child.png)
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on November 16, 2023, 03:21:00 pm
I did a major refactoring of the main loop. Now the code is a lot cleaner, meaning there should be less bugs. Speed of execution is also improved by a multiple factor. I think the project finally entered the phase when actually it may be fun to play around with. I also added some intriguing examples with binary numbers in the playground.

There is still a lot work to do, but I'm on it. This is the current roadmap:
Code: text
    [ ] alpha conception
        [x] theorizing
        [ ] implementing
            [x] main loop recognizing unrestricted grammars
            [x] variables substitution (to do: [ ] unbound variables)
            [x] gradual typing (to do: [ ] any depth metarules; [ ] deep variables)
            [ ] improved s-expr meta capabilities: mandatory `PAIR` and `LIST`
            [ ] non-deterministic sequent matching
                [ ] `READ` side conjunction
                [ ] `WRITE` side disjunction
            [ ] error messages
            [ ] stress test
    [ ] beta testing and revising code
    [ ] gamma release

As usual, there is online playground (https://contrast-zone.github.io/reasoner.js/playground/) and the project home page (https://github.com/contrast-zone/reasoner.js).
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on December 25, 2023, 04:13:25 pm
Done more bug fixing, cleaning and refactoring to enter the new year fresh and clean. The code is another 2x faster now, and some important tests pas now, like, for example, proof checking. The speed is overall a lot slower than in initial rewrite.js experiment from a year and so ago, but I hope to justify that by open doors for additional features like type checking and nondeterminism which will be crucial in later automated theorem proving.

As for proof checking, there is a new example in the project playground. Consider each function as a rule, and function applications as proof steps. Function parameters take assumptions, and function result represents consequence. With stacking a proper beginning set of assumptions to function parameters, and composing such functions, the whole system conflue to the final proved theorem while the computing lines from starts to end represent the proof. For this occasion, I constructed a proof for De Morgan's law applied to logic instead of sets, and this proof check, fortunately, runs almost instantly. Automated proving is yet to be seen, but I hope the speed would be in acceptable range. The goal is that it should be at least faster than doing proofs by hand with pen and paper.

And not to forget, merry Christmas to everyone  :ctree:.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on January 12, 2024, 11:34:31 am
So, Reasoner.js would be a virtual device. Console also. Permanent and temporary memory also. This minimal set could be enriched by other devices like sound, vision, ... Note that every device has its input or output, or both.

In between of these devices, there would be a "coordinator". It would be a glue which mediates between devices, receiving messages from source devices and sending them to target devices. A coordinator could be also considered a kind of device.

There could be many coordinators, and each coordinator code would follow this pattern:

Code: text
(
    COORDINATE
    (
        CONDUCT
        (
            EVENTS
            (RECEIVE (SOURCE ...) (DATA ...))
            ...
        )
        (
            ACTIONS
            (SEND (TARGET ...) (DATA ...))
            ...
        )
    )
    ...
)

The coordinator is a set of conductors that listens to device events and conducts related actions to devices.

The problem solved by coordinator is very important one: managing states. Managing states is needed when, for example, we want to change memory contents as inputs flow in. Code written in Reasoner.js is just a static conglomerate of referentially transparent functions, and if we would be solving states in Reasoner.js, we would have to deal with monads or other gimmicks I am not a big fan of. Other than that, it was also taken under consideration making a separate finite state machine for managing states. But it turned out we don't need anything else than the coordinator between devices which, internally, do or don't manage states.

So, when we want to receive a message from, say, console source, we listen from coordinator to console input event. Then, if we want to process the console input, we pair that event to an action of calling Reasoner.js target code, passing the console input as a parameter, and listening for a result message. The resulting message may raise a new event coupled with an action of sending the data to memory device. By the same event we may also want to write something back to console. To do that, we can put another action for it, next to the action of memorizing data. The whole cycle could repeat on every console input event. Maybe some other arbitrary device events could be also shown useful, like custom reminders, timers, attention requests, ...

With the coordinator I saved myself a bit of a trouble of writing a finite state machine which would be more complicated than implementing the coordinator listening and talking to different devices. It would be up to devices how to manage states. Less is better, right? Especially if there are no functionality trade offs.

[EDIT]
After some research, I discovered that what I'm planning to implement is exactly well known service oriented programming (SOP (https://en.wikipedia.org/wiki/Service-oriented_programming)) paradigm. Good to know. What I call "device", it is called "service" in SOP. I'll align my terminology with SOP terminology. Nevertheless, the process between receiving and sending messages in SOP reminds me very much of term rewriting. Actually it's exactly term rewriting if we are sending and receiving messages from and to the same coordinator/router. I plan to use here the same "variable" notion from reasoner.js, of course, but without nondeterminism.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on March 09, 2024, 06:26:30 pm
Something more from me writing things down and clearing up my thoughts. Read the almost finished paper here (https://github.com/contrast-zone/reasoner.js/blob/master/draft/reasoner.md) if you have the patience. Expect some serious stuff about functional-logic typing rules.
Title: Re: Reasoner.js: a framework for generalized theory synthesis
Post by: ivan.moony on April 30, 2024, 07:37:57 pm
Done some rethinking about service virtual machines, and my framework conceptualization slowly fits into a shape decent enough for implementing: https://svm-suite.github.io/ (https://svm-suite.github.io/)