Ai Dreams Forum

Member's Experiments & Projects => General Project Discussion => Topic started by: ivan.moony on January 04, 2021, 05:44:26 pm

Title: Exp-Log (a deductive system)
Post by: ivan.moony on January 04, 2021, 05:44:26 pm
Introduction to expression logic formal language

[Intended audience]
Beginners in language parsing, term rewriting, and logic deduction

[Short description]
Languages can be seen as streams of symbols used to carry on, process, and exchange informations. Expression logic is also a language, but it is a general kind of metalanguage capable of describing and hosting any other language. Expression logic is also able to perform any intermediate data processing upon recognizing hosted languages. Being a general kind of metalanguage, expression logic represents all of the following:
These descriptions render expression logic as a general solution verifier and problem solver, which seems to be a required minimum characteristic to process a wider range of formal languages.

[Project reference]
https://github.com/contrast-zone/exp-log (https://github.com/contrast-zone/exp-log)
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on January 19, 2021, 04:29:28 pm
Let's compare exp-log to a part of OpenCog.

Probably some of us heard of OpenCog. It is an expertimental symbolic AI development platform that exists since 2006. The famous robot Sophia (that one that got a citizenship of Saudi Arabia) is partially based on OpenCog. At the last, the platform of SingularityNet (that one that introduced AgiCoin digital currency) would be based on OpenCog too.

OpenCog is currently in a process of major restructuring, due to gaining experiences from the current work pros and cons. It won't be entirly different project with the same name and intention, except it would be a thorough upgrade with some seemingly neat ideas.

OpenCog is consisted of many parts, mostly programmed in some Lisp. In the heart of OpenCog there lays URE (unified rule engine) which is basically a deduction system capable of describing many deductive formalisms, and is based on natural deduction. OpenCog uses URE to support PLN (probability logic networks), a fuzzy version of logic conceived by dr. Ben Goertzel, the head of OpenCog team.

To finally draw a parallel to exp-log, exp-log represents an URE on steroids. To surpass the URE, besides deducing interesting facts, it also deals with mutable input/output syntax. Dealing with syntax, exp-log would be a perfect choice for constructing programming languages. And because I want to get some attention from a wider community, for now, I think I'll put a weight to supporting programming languages. Later, once I hopefully attract enough users, I may shift the attention to symbolic AI, which is why I started to develop this system in the first place.

Funny how things work out, if one does what he really likes, one can hardly get money or fame from it, but one gets a personal satisfaction of being really himself. The drawback is there will be no one to actually see it. Instead, to get some attention, one should make some considerable compromises in a direction of providing assets that a wider audience want to see. OpenCog did it with Sophia to get the fame, and then again with AgiCoin to get the money.

Now, I'm not interested in that scale of magnitude as long as money is concerned, but I could really use some attention (if the project happens to deserve such a thing) from at least a smaller part of audience. To do that, I'll try to introduce exp-log to programming languages compiler market, which is a piece of market that necessarily embraces only freeware and/or opensource languages. If things align with my plan, in the exp-log package, some more interesting use examples would find their place. Those would be examples of symbolic AI, just to heal my soul. Things like theorem proving and logical puzzle solving would finally be a part of a programming languages ecosystem I'm after in my quest.

Thus, I aim for symbolic AI introduction to a range of usual programmers, if you like, because all of it is not really a big deal to understand, at least not from a standpoint of usual programming, while it may be a very interesting asset to usual application development.
Title: Re: Exp-Log (a deductive system)
Post by: Zero on February 08, 2021, 08:01:01 pm
Hello my old friend :)

The web is a strange world. You can be something, while looking like something else.

Some projects have an awesome landing page, but are empty shells. Your project is the opposite: it is a high quality project, with the potential strength of a true world-class game changer, but... man, it looks like crap.

IMO, you need 2 things.

First is, a superman landing page. It is not enough to be amazing, you have to look amazing.

Second is, if exp-log can be used to create programming languages, go ahead and create a real one. People need a sample of what can be done with the product.

When I land on a page, first I look for a 'pricing' tab. If I find one, I fly away. Otherwise, I jump to the 'example' tab. And 2 minutes later, my opinion is made.
Title: Re: Exp-Log (a deductive system)
Post by: LOCKSUIT on February 09, 2021, 03:41:16 am
Hmm, Zero, good point. My new group will look like, hmm, I'm going to use Discord. Everything you see will certainly look incredible; what the text say, the videos, picture. The only thing missing might be that thing at the top that collect the flies, you know, the thing that is made of woombat-man material. But then again, others may think it's too kid like. Idk. But you're still right, it definitely has to look both sexy/ free/ simple/ advanced.
Title: Re: Exp-Log (a deductive system)
Post by: Zero on February 09, 2021, 04:29:29 am
A third thing would be a 'get started' tab, to help users.

And yes, a Discord could definitely be a 4th thing to add.  O0


edit: here is an example of good looking project
https://t3js.org/


edit: just wondering, since the EBNF of Exp-log is minimalist, maybe it could be used through Blockly (https://developers.google.com/blockly/)?

Quote
Blockly in a browser allows web pages to include a visual code editor for any of Blockly's five supported programming languages, or your own.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on February 09, 2021, 11:14:11 am
Yes, there would be a number of enhancements to do on the site, once that the language is in working state. I still have to finish exp-log algorithm to get there. Right now it is merely a CFG-like parser with a lengthy to-do list, nothing more.

Blockly? Nice project, it caught my eye a while ago. I guess it is doable on higher levels, once that specific languages are defined. But the languages have to conform what Blockly expects them to look like.

Once, I was thinking about something similar to Blockly, but for BNF in general. It would be based on expression generator. Algorithm for generator is very similar to algorithm for parser. It would read an input, and offer all the expressions that could be a valid continuation of that input. Continuations would, in fact, be templates with placeholders to fill in. The placeholders could, again, be templates, and so on. Still, I'm not sure how would it behave on a superset of BNF, which exp-log tries to represent.

Projects like Blockly are great for beginners, to catch up with new languages. However, I'm worried that forcing such a thing would be a distraction for advanced users. I guess it is possible to blend such a thing with an editor, so it is optionally used by mouse, while leaving an option to ordinary type language elements by keyboard. Then that would be called... a projectional editor (https://en.wikipedia.org/wiki/Structure_editor)? Some guy on lambda-the-ultimate (http://lambda-the-ultimate.org/) site even had an idea for user defined specific graphical editors for specific kinds of expected input / function calls.

But I dunno anymore, maybe this whole editor thing is too big byte for me. One thing I know is that first things come first. I would like to try to finish the core language, then to see where the road leads me, hopefully to concentrate on deductive aspect of the language. There exist a vast of programming languages, while there exist only a good few of deductive systems. I would like to explore that direction.
Title: Re: Exp-Log (a deductive system)
Post by: Zero on February 10, 2021, 08:06:47 am
This sounds wise. I wish you the best on this project.

I follow your work for a long time now, and I know you're working in a very specific direction, with each new project being a new iteration of the previous one, with enhancements and different ideas. Do you think Exp-log could be the final stage you're looking for?
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on February 10, 2021, 06:36:16 pm
Do you think Exp-log could be the final stage you're looking for?

It may be. And it may be not. It can always be better. The question is how satisfied I am with the current version. I just hope I would not seek a hair in an egg anymore. The thing seems to work in theory, and I somehow like it enough to keep it. If I don't run into unsolvable problems, I believe I'm keeping the current version for good.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on February 10, 2021, 09:26:03 pm
Finally a piece of code after a long time. For now, only top level bootstrap of expression logic to detect if the top level syntax is ok. The theoretical definition remained the same as before, although there is a new section [3.2.2.] explaining the oldish algorithm in a new guise (33 lines of pseudocode).

You can play with exp-log top-level syntax in online editor over here (https://contrast-zone.github.io/exp-log/test/). Initial example shows lambda calculus definition. Semantics is yet to be programmed.

 I know it's not much, but it makes me happy. After all, it has been more than a year under the theoretical hood since the last code update. Cheers!  :beer-fresh:
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 04, 2021, 08:58:03 pm
Finally made myself to convert my chart parser output into a decent abstract syntax tree. This wasn't such a trivial task as I thought it would be. I'm using my own general parsing technology, and this is the first time I got usable abstract syntax tree from the output chart. Yey, the parser works! :favicon:

The plan is to turn the parser into abduction based logic programming language, as there is a correspondence between abduction and extended parsing. Here (https://contrast-zone.github.io/exp-log/playground/) is a spoiler if anyone wants to take a look.
Title: Re: Exp-Log (a deductive system)
Post by: infurl on May 04, 2021, 11:07:10 pm
That's great progress Ivan. :)

Your next challenge will be to handle feature constraints. If you do it right, you will get semantic parsing for free.  8)
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 05, 2021, 09:29:13 am
Your next challenge will be to handle feature constraints. If you do it right, you will get semantic parsing for free.  8)

May I ask what are feature constraints?
Title: Re: Exp-Log (a deductive system)
Post by: infurl on May 05, 2021, 12:59:56 pm
May I ask what are feature constraints?

https://en.wikipedia.org/wiki/Feature_structure (https://en.wikipedia.org/wiki/Feature_structure)
http://cs.union.edu/~striegnk/courses/nlp-with-prolog/html/node79.html (http://cs.union.edu/~striegnk/courses/nlp-with-prolog/html/node79.html)

You may recall that I implemented a very powerful GLR parser and some years ago I wrote a much more advanced version which can associate grammatical features with syntax rules. The result is that not only can much more be expressed with much simpler rules, the resulting parse trees are endowed with all the necessary semantic information as well. It is a very elegant and efficient way to solve a complex problem and now I am able to parse a sentence in plain English directly into an executable program.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 05, 2021, 03:26:08 pm
https://en.wikipedia.org/wiki/Feature_structure (https://en.wikipedia.org/wiki/Feature_structure)
http://cs.union.edu/~striegnk/courses/nlp-with-prolog/html/node79.html (http://cs.union.edu/~striegnk/courses/nlp-with-prolog/html/node79.html)

Wow, feature constraints are something new to me! It looks like a powerful and concise tool for building grammars.

As the language I'm building is a kind of Prolog packed in a special way, and Prolog may implement feature constraints on a level above Prolog kernel - in Prolog programming space, I hope I could do the same with Exp-Log. I'll certainly return to this subject at some point. Thanks for the links.

You may recall that I implemented a very powerful GLR parser and some years ago I wrote a much more advanced version which can associate grammatical features with syntax rules. The result is that not only can much more be expressed with much simpler rules, the resulting parse trees are endowed with all the necessary semantic information as well. It is a very elegant and efficient way to solve a complex problem and now I am able to parse a sentence in plain English directly into an executable program.


Executable program? Sounds like NLP programming language.
Title: Re: Exp-Log (a deductive system)
Post by: infurl on May 06, 2021, 02:27:54 am
Executable program? Sounds like NLP programming language.

Exactly. My software is a compiler for "The English Programming Language".
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 08, 2021, 11:34:13 am
Can feature constraints replace the need for variables?
Title: Re: Exp-Log (a deductive system)
Post by: infurl on May 08, 2021, 11:39:13 am
Can feature constraints replace the need for variables?

That depends on what you're using variables for. I'm certainly not using any variables for parsing.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 08, 2021, 11:44:39 am
Can feature constraints replace the need for variables?

That depends on what you're using variables for. I'm certainly not using any variables for parsing.

For example, to calculate factorial or Fibonacci numbers (happens in recursion)?
Title: Re: Exp-Log (a deductive system)
Post by: infurl on May 08, 2021, 11:50:19 am
It sounds to me like you're searching for The One True Hammer(tm) when you should just be using the best tool for any given job.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 08, 2021, 12:17:03 pm
Yeah, the mother of all the hammers sounds just about right!  ;D
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 11, 2021, 04:33:37 pm
I tidied up the parser output a bit and introduced `expected: ... at position ...` type of syntax error messages. Syntax will loose a clear distinction from semantics in later project phases, when the parser will be able to detect i.e. if a variable is declared before assignment using only exp-log patterns.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on June 10, 2021, 01:34:43 pm
Current project status:
Still working on logical programming language for describing other formal languages, based on extension of original parsing technology. Anytime soon, there will be completely functional general CFG parser which then has to be extended in two steps, first to be Turing complete, then to include appropriate logical operators (I observe productions as implications).

Last insights about program synthesis:
It should be possible to send arbitrary input and output pairs along the lambda calculus definition. From just that, the system could construct a set of possible specific lambda functions that turn provided inputs to provided outputs. If instead of lambda calculus we provide a definition of some other language, other kinds of source code may be synthesized. I'm still wondering about troubles with speed that may pop up, mostly around recursive functions. Anyway, simply typed LC should work well if I'm not mistaken.

Last insights about AI:
The same procedure for program synthesis should work as a replacement for what artificial neural networks provide. NNs are trained by pairing inputs to outputs, and in between, neuron set does all the future magic of firing outputs upon recognized inputs. With completely formalizing a Turing complete environment, instead of general neuron set, we may put 100% accurate synthesized pieces of code. Although the general idea should work, I'm afraid that details about AI would be pretty tricky to grasp.

What competition has to show on this subject:
Here is interesting video about business use - very insightful - https://www.microsoft.com/en-us/research/group/prose/ (https://www.microsoft.com/en-us/research/group/prose/)
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on July 12, 2021, 01:09:16 pm
I composed an example for visualizing natural deduction logical proofs: http://ocog.atspace.cc/ (http://ocog.atspace.cc/).

As exp-log heavily relies on natural deduction (https://en.wikipedia.org/wiki/Natural_deduction), this kind of visualization may be very relevant to it. I put the example online, and offered the whole library for use in OpenCog (https://opencog.org/) foundation (they also deal with natural deduction). This is still far away from concrete AI advancement I'm trying to do with exp-log, but beter something than nothing.

Natural deduction comprises rules of the form:
Code
  premises  
------------
 conclusion

Suppose we have a natural deduction proof composition:
Code
  ---   ---   ---     ---   ---   ---     ---   ---   ---
   I     J     K       L     M     N       P     Q     R
 -----------------   -----------------   -----------------
         A                   B                   C
-----------------------------------------------------------
                             X

We can already see the tree-like composition, but as it may span over a very wide and tall area, it may be required to represent it within an on-demand scaling system. The online example roughly shows what I have imagined for proof representation. In the example you can play with ovals, dragging them around and in or out the central area, zooming proof parts of the current interest. Notice how it is possible to represent and navigate nearly infinite length proofs, assuming enough memory space.

I already had possible plans for fusing exp-log and fract-exp in the future, and noted example shows one of the possibilities. But I'm still actively developing exp-log, so it is a long road before reaching the visualization state.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on August 10, 2021, 01:54:44 pm
I decided to change the direction of the project exp-log.

In fact, it will change its name and it will be degraded to support only Prolog like rules in Lisp-ish disguise, applied to string parsing and term rewriting, focusing to provide a form of server side scripting technology. It will still remain to be applicable to logic problem solving, only in a form of server side scripting language, and with the main focus on delivering web contents. If one wants to implement exp-log, one will be able to define it within this new scripting language more-or-less with ease.

The existing project code remains actual, as the new project direction follows a subset of the previously planned goal project. I'm thinking learning Go to program native server when the time comes. Until then, I'm trying to keep js code below 500 LOC. As for the current project iteration, I plan to finally pack up exp-log draft document and put it aside as a curiosity content. New draft is coming soon.

To get a glimpse of the new project attire, visit this link (https://contrast-zone.github.io/intelog/playground/).
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on August 25, 2021, 11:49:58 am
A story about contradiction (or: "blah, that boring logic stuff", if you are not crazy)

What I'm dealing here as building blocks in my language is a kind of Horn clause (https://en.wikipedia.org/wiki/Horn_clause) form of formulas. Horn clauses are of the form `a /\ b /\ c /\ ... -> u` while I deal with their extended form `a /\ b /\ c /\ ... -> u \/ v \/ w \/ ...`, which is equivalent of conjunctive normal form `¬a \/ ¬b \/ ¬c \/ ... \/ u \/ v \/ w \/...` of general logical formulas.

An interesting story comes when doing a proof construction. We start from origin multiple axioms in a form `true -> axiom`, then come assumptions in a form `a -> b` in between, and we try to connect it to `goal -> false` at the other end. One may ask: "Why the goal implies false? If the goal is false, then the whole formula conglomerate is false!" The answer may lay in the fact that one of the proving methods in logic is proof-by-contradiction. we state axioms and assumptions, we state the negated goal (`¬goal` is the same as `goal -> false`), and we try to derive a general contradiction. That means that if we prove that "`¬goal` yields contradiction", the same proof is read as: "non-negated `goal` is true" because of dual properties of the logic itself.

I find this story interesting because if we keep the whole formula conglomerate in `true -> axioms`, `a -> b`, `goal -> false` form, the whole conglomerate evaluates to false. Under proof of `axioms -> goal`, it is like we directly write `true -> false` - this is a contradiction. This kind of reminds me of imaginary numbers in math - (square root of -1) - although they are non-existent, we can do math with them, dragging them through all kinds of usual formulas, ultimately producing actually useful results at the end, when imaginary numbers are reduced in the previous process. Likewise, in this like logical systems (Prolog also accounts to this kind), we are manipulating contradictory form of clauses to produce a result that is actually true.

Funny, isn't it? Like we are trying to say a truth by stating a bunch of lies. And it all works at the end!
Title: Re: Exp-Log (a deductive system)
Post by: Zero on August 25, 2021, 02:15:43 pm
You know, I have trouble handling negation as failure. I just can't get my head around it yet. A few days ago, I was working on... wait. Ok, done uploaded here (https://github.com/SimpleFriend/Jamie/blob/master/FRkr.md). It's a knowledge base-structure thing, in French sorry, but it doesn't matter. Here is the problem:

In the list, there is a "is an instance of" relation. It was super easy to represent in Prolog, no problem. Then, the plan was to also have a "is not an instance of" relation. Dang. I could never get it to work properly.

How do you say that something does not hold, in logic? How does this mind-skkkrrrr****ing negation as failure work? Can your current system handle this kind of... non-relation? The idea would be something like:
- If I say it is true, then it is true
- If I say it is false, then it is false
- If I say nothing about it, then we don't know yet, and we should be able to "work" with the fact that we don't know it

I know it's about open-world vs closed world assumption, but I just don't get it. :)
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on August 25, 2021, 03:57:39 pm
I think your reasoning in three bullets stands for open world logic.

I also had problems with negation. I had some attempts to treat everything as a closed world, i.e. if something is not defined, then it is false, but it didn't sound consistent to me. I also struggled with self-definition, as I didn't have a way to express a query that returns true if I have a proof for a formula, otherwise it returns false. I mean I had idea about a dirty hack, but it looked like a perpetuum mobile thing, totally out of harmony with the Universe.

But I managed to avoid all that story about constants true / false. I completely expelled constants from my theoretical language. First level theory manages to define the next level theory, which again may hold another level theory, and so on, even if theories at all levels are the same. And there seems to be a restriction that any level theory can't define itself in the same level (see Tarski's undefinability theorem (https://en.wikipedia.org/wiki/Tarski%27s_undefinability_theorem)), assuming the theory is consistent, but it seems OK for the next level to hold anything we want, restricted by previous level.

So the road led me here: the thing is, all the formulas I care about, may be considered as stored in format: `~a \/ ~b \/ ~c \/ ... \/ u \/ v \/ w ...`. When converted to super-horn clause (hehe, what a name), negated atoms go to the conjunction on the left, and non-negated to the disjunction on the right of implication symbol. If the left side is an empty conjunction, then the left side is true. If the right side is an empty disjunction, then the right side is false. Empty conjunction and empty disjunction is the furthest I go when it comes to constants. That means I can't even store the truth on the right side (because it yields a tautology) or the falsehood on the left side (also yields tautology) of the implication.

See, this might be of your interest: I figured (Wikipedia and co. (https://en.wikipedia.org/wiki/Implicational_propositional_calculus#Virtual_completeness_as_an_operator)), negation of an atom is the same as we write `atom -> false`. Now, I don't have `false` defined internally, but it could be a user defined atom as any other. So, when I enter rules for it in a form like:

Code
            (       (~ 'true') -> 'false' ) /\
            (      (~ 'false') -> 'true'  ) /\

            (    (@a /\ ~ @a ) -> 'false' ) /\
            (  (@a /\ 'true' ) -> @a      ) /\
            ( (@a /\ 'false' ) -> 'false' ) /\
           
            (    (@a \/ ~ @a ) -> 'true'  ) /\
            (  (@a \/ 'true' ) -> 'true'  ) /\
            ( (@a \/ 'false' ) -> @a      )

and when I run organic-mind-proving-engine, things line up neatly: if the whole formula is contradictory, alone `false` is deduced; if the whole formula is tautology, alone `true` is deduced. This user-defined mechanism persuaded me to stop chasing built-in negation, and I thought - the best thing is to avoid explicit negation when it comes to exposing it to end users. All I have are empty left side conjunctions and empty right side disjunctions for my internal interpretations - only for noting axioms and goals. Otherwise, it is up to users to introduce negation, or not, it is all about user defined theories that may or may not depend on negations. As for internal interpretation, things are getting pretty weird (see the previous post): right side empty disjunction - falsehood - is interpreted as a success, following the proof by contradiction (https://en.wikipedia.org/wiki/Proof_by_contradiction).

Anyway, there's a parser I'm dragging now for years which I plan to extend by left side conjunctions and right side disjunctions (had that version also, but things changed so I have to re-do it for the new version). I'm planing not to tell the computer a thing about truth / falsehood, yet to leave to the algorithm to interpret empty sides just like any other element filled sides, but in empty `for` loops, by the same code, and see what happens. If the whole thing would work OK, that would be it, I would be out of the need for constants `true` and `false`, even internally.

And to develop things further, why these two constants: true / false? why not a probability range between 0 and 1, with 0 being false and 1 being true? And why to restrict ourselves to logic, why not 3 elements fractionals like red / green / blue combinations? There should be a numerous interpretations, as there are a numerous theories about everything else but logic. Now it made sense to me to leave out binary constants like true and false out of equation: users can define whatever they want, providing specific rules to handle those constants. Thus, I opted out for no built-in constants. I exploited logic as a food for thought to form the core language in my mind, but it happens to apply to any area, not only logic, and that should work without built-in constants, if I'm not mistaken.
Title: Re: Exp-Log (a deductive system)
Post by: Zero on August 25, 2021, 05:12:48 pm
But, wouldn't you say that conjunction, disjunction, implication and negation of atoms are anyway implicitly "carrying" the notions of true/false/anyConstant? I mean, if we use some many-valued logic (https://en.wikipedia.org/wiki/Many-valued_logic), we need to rewrite the tables of these operators ok, but there are still tables, which hold "things" in their cells! How can we have operators without having constants?
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on August 25, 2021, 05:37:00 pm
But, wouldn't you say that conjunction, disjunction, implication and negation of atoms are anyway implicitly "carrying" the notions of true/false/anyConstant? I mean, if we use some many-valued logic (https://en.wikipedia.org/wiki/Many-valued_logic), we need to rewrite the tables of these operators ok, but there are still tables, which hold "things" in their cells! How can we have operators without having constants?

What I'm trying to articulate is that I want to leave constants out of the system, meaning there is no built-in constants. Of course there is a notion of a constant, but users choose what constant they would use, provided interrelations between them by stating user defined formulas. Those formulas reason about the constants, but all of them are user-defined, not hard-coded.

I wouldn't want to intimidate you, but there is a stream in computing science that goes even further than I go when it comes to constants. For example, combinatory logic (https://en.wikipedia.org/wiki/Combinatory_logic) that relates to lambda calculus, is composed only of functions. Even constants like `true` and `false` are defined as functions like `λx.λy.x` and `λx.λy.y`. There are also Church numerals (https://en.wikipedia.org/wiki/Church_encoding#Church_numerals) that map all the numbers to lambda functions, without introducing a single constant, only combinators (combinators are functions that use no constants, only variables and previously defined combinators). But I'm not going that far because I want to achieve a clear distinction between the input/output constants (user defined and exposed to outer world) and internal rule system (also user defined, but not exposed to outer world).
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on August 26, 2021, 12:48:38 pm
You know, I have trouble handling negation as failure. I just can't get my head around it yet. A few days ago, I was working on... wait. Ok, done uploaded here (https://github.com/SimpleFriend/Jamie/blob/master/FRkr.md). It's a knowledge base-structure thing, in French sorry, but it doesn't matter. Here is the problem:

In the list, there is a "is an instance of" relation. It was super easy to represent in Prolog, no problem. Then, the plan was to also have a "is not an instance of" relation. Dang. I could never get it to work properly.

How do you say that something does not hold, in logic? How does this mind-skkkrrrr****ing negation as failure work? Can your current system handle this kind of... non-relation? The idea would be something like:
- If I say it is true, then it is true
- If I say it is false, then it is false
- If I say nothing about it, then we don't know yet, and we should be able to "work" with the fact that we don't know it

I know it's about open-world vs closed world assumption, but I just don't get it. :)

I had the same problem, but classical logic gave me only a half-solution - If something is true or false, or it can be proven true or false, then we can detect it. But if we don't know that something, or there is no proof of that something, then we can't detect its current non-existence.

My final solution was to break theories to sub-levels - the first level defines what is true or not in the second level, the second level defines what is true or not in the third level, and so on. That way I kept consistency. And it somehow sounded like a right solution.

Prolog? You should be able to detect element of set existence in Prolog, you just have to be explicit. First you define a set with its elements. Then you loop through all the elements, reporting true if you find the element, or false if the loop falls through. You just have to deal with equality comparison, which I guess is a Prolog's dirty hack (or defined in a previous level theory, if you like). In classical logic, equality can't be defined as a user defined predicate because you *can* detect if something is equal, but you *can not* detect if something is not equal (the same problem - you can detect a proof of `A = B`, but you can't detect non-existence of proof of `A = B`. Nevertheless, you can separately define a proof of `A != B`, but it may be that story of closed worlds, i.e. `digit != 1 <-> digit = 0 \/ digit = 2 \/ digit = 3 \/ ... \/ digit = 9`). I guess this is why *logic with equality* is a separate chapter in logic books.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on August 29, 2021, 06:03:20 pm
Semantic rhombus

The whole rhombus is defined by semantic rules. We give input. The task is to extract output. To compute output, we abduce from goals to input. Output is then in the way of this abduction. If there are many outputs, the one closest to goal is chosen. As an additional way to verify if input is correct, prior to extraction of output, we may try to deduce from facts to input.
Code: text
                    FACTS
                      _
                    _/ \_                      D ||      /\
                  _/ \_/ \_                    E ||     //\\
                _/ \_/ \_/ \_                  D ||    //||\\
              _/ \ / \ / \ / \_                U ||      ||
             /                 \               C ||      ||
          _         INPUT         _            T ||      ||
        _/  _   _   _   _   _   _  \_          I ||      ||
      _/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_        O ||      ||
    _/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_      N ||      ||
  _/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \_      ||      ||
 /                                         \     ||      ||
                  SEMANTICS                      ||      ||
 \_                                       _/     ||      ||
   \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/       ||      ||
     \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/         ||      || A
       \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/           ||      || B
         \_                       _/             ||      || D
                    OUTPUT                       ||      || U
             \_               _/                 ||      || C
               \_/ \_/ \_/ \_/                   ||      || T
                 \_/ \_/ \_/                   \\||//    || I
                   \_/ \_/                      \\//     || O
                     \_/                         \/      || N
                       
                    GOALS
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on December 09, 2021, 11:30:31 am
Quote
introduction to intermezzo programming

[Intended audience]

Beginners in language parsing, term rewriting, and logic deduction

[Short description]
As an embodiment of general problem solving strategy related to term rewriting, Intermezzo aims to be a host for a variety of kinds of formal languages, exhibiting rule-based programming system. For each area of interest, one is able to define a custom domain specific language in a language oriented programming paradigm. Having clearly defined communication input and output forms, Intermezzo performs transition from input to output by additionally defining possibly Turing complete set of chaining production rules. This sort of arrangement also sheds light on Intermezzo from an angle of systems theory, thus broadening a possible range of use cases.

[References]
Wikipedia web site

link to the paper (https://github.com/contrast-zone/exp-log/blob/master/intermezzo.md)

Anyone cares for a review? It's some 30 min read, less if you skim it fastly?
Title: Re: Exp-Log (a deductive system)
Post by: infurl on December 10, 2021, 01:03:05 am
That is beautifully presented and a subject area where I have done a lot of work. Code generation is a very useful technique and after completing a number of major projects with it I thought it would be useful to develop a generator for code generators. It took a lot of effort on and off over many years to build such a thing but I finally achieved it and experimented with some non-trivial applications of the technology. However in the end it seemed to have been not worth the effort because it was much more efficient to apply the meta-programming techniques that it took to get it to work directly to the problems that I was trying to solve.

If you are planning to pursue it further you should think in terms of graphs rather than acyclic graphs. Higher levels have to be able to introspect and summarise elements that are generated at lower levels. In other words, there needs to be feedback in the process.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on December 10, 2021, 04:05:42 am
That is beautifully presented and a subject area where I have done a lot of work. Code generation is a very useful technique and after completing a number of major projects with it I thought it would be useful to develop a generator for code generators. It took a lot of effort on and off over many years to build such a thing but I finally achieved it and experimented with some non-trivial applications of the technology. However in the end it seemed to have been not worth the effort because it was much more efficient to apply the meta-programming techniques that it took to get it to work directly to the problems that I was trying to solve.

Great to see someone is also interested in this subject. The current code generation industry state with LLVM and company is a bit clumsy by my opinion. They may got the backend right (all the optimization and machine stuff), but I think their frontend can be better.

Any chance we could be more informed about your project  soon?

If you are planning to pursue it further you should think in terms of graphs rather than acyclic graphs. Higher levels have to be able to introspect and summarise elements that are generated at lower levels. In other words, there needs to be feedback in the process.

I thought pattern matching introduces recursive graphs?
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on January 03, 2022, 11:34:24 am
3.1. automata programming

[Automata theory](https://en.wikipedia.org/wiki/Automata_theory#Classes_of_automata (https://en.wikipedia.org/wiki/Automata_theory#Classes_of_automata)) is the study of abstract machines and automata, as well as the computational problems that can be solved using them. It is a theory in theoretical computer science. The word automata (the plural of automaton) comes from the Greek word automatos, which means "self-acting, self-willed, self-moving". An automaton (Automata in plural) is an abstract self-propelled computing device which follows a predetermined sequence of operations automatically.

There exists a whole variety of more or less general classes of automata. Being Turing complete, *Intermezzo* is capable of emulating any automata, and here we bring an example of input/output stateless automation. The property of being stateless means that the automation doesn't remember any state on each call to the automation. This means that if we want to deal with states, we have to pass the states with an input, and return the modified states with an output each time we run the automation. This way, the states are evolving on each cycle of running the automation until we reach a state of ending the automation operation.

The following example represents a number guessing game, and bases its operation on repetitive cycles, passing through operational states on each input/output cycle. On the first cycle, the example in output asks a user to imagine a number between 1 and 8, while the automation starts guessing what is imagined number. Each cycle is comprised of a binary search, asking if the imagined number is less than, greater than, or equal to guessed number. Finally, in four or less steps, the automation declares its victory when the user admits that the guessed number is equal to imagined number.

Code
(
    COMPOSITE
    (
        INPUT
       
        (
            ELEMENTARY
            TOP
            <{"input": "start"}>
        )
        (
            ELEMENTARY
            TOP
            <{"input": "less", "state": {"guess": "<Num>", "delta": "<Num>", "step": "<Num>"}}>
        )
        (
            ELEMENTARY
            TOP
            <{"input": "more", "state": {"guess": "<Num>", "delta": "<Num>", "step": "<Num>"}}>
        )
        (
            ELEMENTARY
            TOP
            <{"input": "equal", "state": {"guess": "<Num>", "delta": "<Num>", "step": "<Num>"}}>
        )
       
        (ELEMENTARY <Num> <1>)
        (ELEMENTARY <Num> <2>)
        (ELEMENTARY <Num> <3>)
        (ELEMENTARY <Num> <4>)
        (ELEMENTARY <Num> <5>)
        (ELEMENTARY <Num> <6>)
        (ELEMENTARY <Num> <7>)
        (ELEMENTARY <Num> <8>)
    )
    (
        CHAIN
       
        // init
        (
            ELEMENTARY
            <{"input": "start"}>
            <{"output": "Imagine a number between 1 and 8. Is it 8?", "state": {"guess": "8", "delta": "8", "step": "1"}}>
        )
       
        // less
        (
            EQUALIZE
            (ID (DOMAIN <Guess> <Num>) (DOMAIN <Delta> <Num>) (DOMAIN <Step> <Num>))
            (
                ELEMENTARY
                <{"input": "less", "state": {"guess": "<Guess>", "delta": "<Delta>", "step": "<Step>"}}>
                <{"output": "Is it <Guess> - <Delta> / 2?", "state": {"guess": "<Guess> - <Delta> / 2", "delta": "<Delta> / 2", "step": "<Step> + 1"}}>
        )
       
        // more
        (
            EQUALIZE
            (ID (DOMAIN <Guess> <Num>) (DOMAIN <Delta> <Num>) (DOMAIN <Step> <Num>))
            (
                ELEMENTARY
                <{"input": "more", "state": {"guess": "<Guess>", "delta": "<Delta>", "step": "<Step>"}}>
                <{"output": "Is it <Guess> + <Delta> / 2?", "state": {"guess": "<Guess> + <Delta> / 2", "delta": "<Delta> / 2", "step": "<Step> + 1"}}>
        )
       
        // equal
        (
            EQUALIZE
            (ID (DOMAIN <Step> <Num>))
            (
                ELEMENTARY
                <{"input": "equal", "state": {"guess": "<Num>", "delta": "<Num>", "step": "<Step>"}}>
                <{"output": "Got ya in <Step> steps!"}>
            )
        )
    )
    (
        OUTPUT
       
        (ELEMENTARY <1> <Num>)
        (ELEMENTARY <2> <Num>)
        (ELEMENTARY <3> <Num>)
        (ELEMENTARY <4> <Num>)
        (ELEMENTARY <5> <Num>)
        (ELEMENTARY <6> <Num>)
        (ELEMENTARY <7> <Num>)
        (ELEMENTARY <8> <Num>)
       
        (
            ELEMENTARY
            <{"output": "Imagine a number between <Num> and <Num>. Is it <Num>?", "state": {"guess": "<Num>", "delta": "<Num>", "step": "<Num>"}>
            BOT
        )
        (
            ELEMENTARY
            <{"output": "Is it <Num> - <Num> / 2?", "state": {"guess": "<Num>", "delta": "<Num>", "step": "<Num>"}>
            BOT
        )
        (
            ELEMENTARY
            <{"output": "Is it <Num> + <Num> / 2?", "state": {"guess": "<Num>", "delta": "<Num>", "step": "<Num>"}>
            BOT
        )
        (
            ELEMENTARY
            <{"output": "Got ya in <Num> steps!"}>
            BOT
        )
    )
)

The input/output process of guessing is using [JSON](https://en.wikipedia.org/wiki/JSON (https://en.wikipedia.org/wiki/JSON)) format to exchange data between operation cycles. It is expected from an outer resource to calculate math expressions in JSON data prior to sending it to the next cycle (it is possible to implement these calculations as *Intermezzo* rules, but for a sake of simplicity of the example, we choose to leave out these definitions). Communicating between cycles, regarding to previous `output` question, we store to `input` property an arbitrary choice of `less`, `more`, or `equal` keywords, while `state` property from the previous output is copied to `state` property of the next input.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on January 18, 2022, 10:48:35 am
This whole automata emulation inside stateless environment is cumbersome. I want it to be simpler. States exist in real world, right? Why shouldn't then they be a part of the language?

I need to construct a stateful automata environment to embrace that stateless insides. Maybe I'll go for it in a direction of generalizing all three important automata classes (finite state, pushdown, and Turing machines) into a single automation parameterized kind.

But why wouldn't I use only Turing machine if it has greater expressive power than finite state and pushdown automata? Because pushdown is simpler to use than Turing, and finite state is simpler to use than pushdown. Turing machine is a necessary evil we should reach for only if we have to. Otherwise, those simpler kinds should be at disposition to easy up our work.
Title: Re: Exp-Log (a deductive system)
Post by: MagnusWootton on January 18, 2022, 06:44:26 pm
I prefer ANNs or Direct hardware logic, to turing machines by a mile,  heaps simpler, also universal.

Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on January 18, 2022, 08:51:42 pm
I prefer ANNs or Direct hardware logic, to turing machines by a mile,  heaps simpler, also universal.

Doesn't ANN resemble a stateless machine? You call ANN with some parameters, you get some result. No states remembered between cycles.

Edit:
What I like about Turing-like machines is that they are easy to formally describe and reason about. This provides a fruitful ground for algorithm synthesis. This is also a case with lambda calculus, though LC is a stateless and no-user-interaction-in-between-intended kind of a computation.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on April 10, 2022, 10:40:28 pm
Boy, was this a Gordian knot...

Quote
2.2.1. semantic rhombus

Semantics of *Canon* is contained within composing two kinds of rules: forward and backward rules. The semantics of these rules may be described by a vertically split rhombus representing a complex forward rule as a whole on the left, and a complex backward rule as a whole on the right side. Complex rules are consisted of other complex or simple rules. Simple rules are made of two sides simply linked without any internal structure.

Code: text
     ----------------------------------   ---------------------------------- 
    |                                  | |                                  |
    |     ||                      BACK | | FORE                      /\     |
    |     ||                           | |                          //\\    |
    |     ||                          /| |\                        //||\\   |
    |     ||                        / \| |/ \                        ||     |
    |     ||                      / \ /| |\ / \                      ||     |
    |     ||                    / \ / \| |/ \ / \                    ||     |
    |     ||                  /        | |        \                  ||     |
    |     ||                /  FORWARD | | BACKWARD \              B ||     |
    |     || F            /      RULES | | RULES      \            A ||     |
    |   D || O          /              | |              \          C || A   |
    |   E || R        / \ / \ / \ / \ /| |\ / \ / \ / \ / \        K || B   |
    |   D || W      / \ / \ / \ / \ / \| |/ \ / \ / \ / \ / \      W || D   |
    |   U || A    /                    | |                    \    A || U   |
    |   C || R          CHAINING RULES | | CHAINING RULES          R || C   |
    |   T || D    \                    | |                    /    D || T   |
    |   I ||        \ / \ / \ / \ / \ /| |\ / \ / \ / \ / \ /        || I   |
    |   O || R        \ / \ / \ / \ / \| |/ \ / \ / \ / \ /        R || O   |
    |   N || U          \              | |              /          U || N   |
    |     || L            \   BACKWARD | | FORWARD    /            L ||     |
    |     || E              \    RULES | | RULES    /              E ||     |
    |     ||                  \        | |        /                  ||     |
    |     ||                    \ / \ /| |\ / \ /                    ||     |
    |     ||                      \ / \| |/ \ /                      ||     |
    |     ||                        \ /| |\ /                        ||     |
    |   \\||//                        \| |/                          ||     |
    |    \\//                          | |                           ||     |
    |     \/                      FORE | | BACK                      ||     |
    |                                  | |                                  |
     ----------------------------------   ----------------------------------

The left side of the rhombus is depicting complex forward rule. It is containing arranged `forward rules`, `chaining rules`, and `backward rules`. The same side of rhombus is diverging branches from `BACK` node downwards, in a direction of forward rule, forming initial deduction tree. The same side of rhombus is also diverging branches from `FORE` node upwards, in a direction of backward rule, forming opposed abduction tree. The deduction and abduction branchings of the left side are required to be linked by the middle area of `chaining rules`, thus forming a complete inference system from `BACK` node to `FORE` node.

The right side of the rhombus is depicting complex backward rule. It is similar to the left side, only flipped upside-down.
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on April 11, 2022, 05:59:47 pm
Gordian knots! Gordian knots everywhere! Read all about it!

Well, just another checkpoint in my research. It is somewhat heavy read, but if you like theory about experimental programming languages, here's the link (https://github.com/contrast-zone/canon/blob/master/canon.md).
Title: Re: Exp-Log (a deductive system)
Post by: ivan.moony on May 11, 2022, 04:58:51 pm
I'm organizing the future direction of the project. The decision is to make it capable of automated planning as a problem solving manner. I expect it to be able to solve toy problems like "wolf, goat, cabbage" (https://en.wikipedia.org/wiki/Wolf,_goat_and_cabbage_problem), "monkey and banana" (https://en.wikipedia.org/wiki/Monkey_and_banana_problem), and "blocks world" (https://en.wikipedia.org/wiki/Blocks_world).