Ai Dreams Forum

Member's Experiments & Projects => General Project Discussion => Topic started by: Zero on January 16, 2018, 02:26:03 pm

Title: AiDL language draft
Post by: Zero on January 16, 2018, 02:26:03 pm


AiDL


primitive data type
    number                  | a Javascript number
    text                    | a Javascript string
    boolean                 | true or false
    verb                    | an anonymous procedure in Tcl-like code
    function                | an anonymous functional expression
    instant                 | a specific moment in time
    evolution               | a list of instant/value couples
    duration                | length of time
    parser                  | based on parsing expression grammar
    knowledge               | a coherent set of interrelated meanings
        meaning                 | a knowledge item
            relation                | a relation between items
            meta-data               | a semi-structured data chunk
            behavior                | a behavior tree
    schema                  | a data pattern
composite data type
    object                  | an Io-like object
    list                    | a plain old list


number syntax example
    23
    -56.9
    2e5


text syntax example
    bluesky
    "blue sky"
    'blue sky'
    {blue sky}


boolean syntax example
    true
    false


verb syntax example
    set increment [
        verb {
            set [argument] [sum [[argument]] 1];
        }
    ];


function syntax example
    set factorial [
        function {
            (argument<0) ? undefined : (
                (argument==0) ?
                    1 :
                    argument*factorial(argument-1)
            )
        }
    ];


object syntax example
    object {
        <tag1>key1: expr1,
        <tag2>key2: expr2
    }


list syntax example
    list {
        <tag1>expr1,
        <tag2>expr2
    }


knowledge syntax example
    meaning {

        item1 -> ownership {
            owner: Janis;
            owned: Mercedes;
        }

        item2 -> [email|
            [from|john@doe.com]
            [to|jane@tarzan.net]
            [title|meta/data test]
            [body|
                Hi, this is John sending
                semi-structured data.
            ]
        ]

        item3 ->
        (select,
            open the door,
            (sequence,
                get the key,
                unlock the door,
                open the door))
    }



There's also the pub/sub thing from Birdy, and lessons learned from Semantic JSON, which don't appear here, but are meant to be included. Also, there is no loop.

This could be my idea of an "AiDream" language...  :)
Title: Re: All-in language draft
Post by: ranch vermin on January 17, 2018, 09:51:51 am
these things are so hard to test,   u cant hardcode them because there is too much to hardcode.
And an automatic extraction off sensor is tricky to get your head around, just as much as a working symbolic database for an ai is. (this is one of those?)
Title: Re: All-in language draft
Post by: Zero on January 17, 2018, 12:19:23 pm
You're right, you can't hardcode everything because there's too much. But I think it's possible to reach some kind of top-down "critical mass", and BOOM. Like the Terminator.

Sensing can be tricky, yes: we need specific perception/interpretation devices or subsystems whatever you wanna call them. It can't be high-level. When your eyes meet a face, you just see a face. The mechanism that makes the "face construct" pop in your mind isn't conscious at all.

What do you think?
Title: Re: All-in language draft
Post by: ranch vermin on January 17, 2018, 12:52:33 pm
about an automatic sensor to fill it up->  if your putting tonnes of english with some kind of natural language processor that goes into the symbolic system, they tend to be parrotlike and take it in no matter how nonsensical it is,  a machine has no judgement of good reading matter unless u give it to it, and it would be tricky.

even people dont know what to believe,  its actually a fundamental problem with intelligence in general,  let alone parrotlike data collecting.

I guess it must take in the information,  but maybe you put a scope difference between "different opinions", and it takes them all in...  then a machine has a bit of a personality problem, doesnt know who to be. :)

Im not saying these symbolic structures dont work tho,  I think they do just as much as pattern recognition stuff does.  (see Yann Lecun's amazing works) its all assignment after all. (=) in both techniques.
Title: Re: All-in language draft
Post by: Zero on January 17, 2018, 02:35:40 pm
I agree: if you just stuff it with analysed english sentences, or even structured definitions or ontologies, it never works. Because it doesn't experience it.

But if you sit down calmly and have a nice little chat with it about simple things it does experience, like "hey Ai, did you notice how that variable has been modified when you called this function? interesting isn't it"

Then maybe you can start sharing true knowledge, and expand from there.
Title: Re: All-in language draft
Post by: ivan.moony on January 17, 2018, 03:55:32 pm
See: reflection (https://en.wikipedia.org/wiki/Reflection_(computer_programming)), or more interestingly: metaprogramming (https://en.wikipedia.org/wiki/Metaprogramming).
Title: Re: All-in language draft
Post by: Zero on January 17, 2018, 03:59:33 pm
Yes, Wikipedia articles are always well structured and interesting.
:)
Title: Re: All-in language draft
Post by: Zero on January 18, 2018, 08:57:41 am
I think I'll name this language AiDL, in honor of our amazing community. If Freddy greenlights me!
:)

Quote
Im not saying these symbolic structures dont work tho,  I think they do just as much as pattern recognition stuff does.  (see Yann Lecun's amazing works) its all assignment after all. (=) in both techniques.

Actually, what I'd like to do is create a top-down knowledge structure that describes the AiDL programming language features: the data types, the syntax and semantic of source code, the control structures, the execution model, how things connect and work together, what happens when foo and bar happen (cause-consequences chains), ...etc. This knowledge would be described using the "meaning" datatype, with relations, semi-structured data chunks, and behaviors. It would be able to describe the results and effects of code snippets. This knowledge would also contain information about what happens when you modify the code, and more importantly, about how to modify the code. All this would be built-in, it comes in the box.

Then, we apply the idea of internal sensors to this (see Semantic JSON), connecting every little aspect of the user's program execution to these symbolic structures. The internal sensors collect data about everything, and the collected data is sent through the symbolic structures for interpretation. This way, the program knows what it is doing: not only sensing events and evolution of its states, but also interpreting them in a meaningful way.

Then, a simplified controlled version of natural language (like Attempto (http://attempto.ifi.uzh.ch/site/)) should be made available to communicate with the program, in order to talk with it about itself. And this is where we start to teach it how to develop software, how to develop itself.

Thanks for the pointer to Yann Lecun: you made me discover the Lush (https://en.wikibooks.org/wiki/Lush) programming language.
Title: Re: All-in language draft
Post by: Freddy on January 18, 2018, 03:11:06 pm
Quote
I think I'll name this language AiDL, in honor of our amazing community. If Freddy greenlights me!

Consider the green light on, I think we would all be honoured  :)

I must set down a proper definition for ElfScript but I tend to be making it up as I go along.  ;D
Title: Re: All-in language draft
Post by: Zero on January 18, 2018, 08:35:26 pm
 O0  Wow, thanks a lot Freddy!

Elfscript is cool. I like the project, and I like the name! :)
It's evolving fast, isn't it?
Title: Re: AiDL language draft
Post by: Freddy on January 18, 2018, 09:31:46 pm
It evolves fast when I work on it, as I get addicted to the problem solving. But I have to take breaks from it if I can pull myself away long enough - otherwise I am up till dawn tapping away on the keys.

I'm having a break from it at the moment actually, but there's an itch to scratch developing again lately   ;D
Title: Re: AiDL language draft
Post by: ranch vermin on January 19, 2018, 08:50:02 am
the good thing about this is you could read what its doing not like hidden layers in neural networks where its all unlabelled gibberish.
Title: Re: AiDL language draft
Post by: Zero on January 19, 2018, 09:27:45 am
It evolves fast when I work on it, as I get addicted to the problem solving. But I have to take breaks from it if I can pull myself away long enough - otherwise I am up till dawn tapping away on the keys.

I'm having a break from it at the moment actually, but there's an itch to scratch developing again lately   ;D

Yeah, I know what it feels like ;)

In fact, if my wife wasn't here to kick my ass on a daily basis, I think I would just stick to my computer day&night  ;D

the good thing about this is you could read what its doing not like hidden layers in neural networks where its all unlabelled gibberish.

Exactly. I'm targeting the browser. I made a simple UI made of a lot of draggable frames, like a dashboard. You'd use those frames to set up spies and follow what's happening. You can see a demo page here (http://thinkbots.are.free.fr/). I like the "dev on the fly" approach!  :D
Title: Re: AiDL language draft
Post by: Zero on January 22, 2018, 11:18:52 am
I added 3 new data types: parser, instant, and duration. Also, I moved meaning and schema from composite data types to primitive data types: indeed, they're not meant to contain values of other types. I'm considering adding a code type, to manipulate the AST with a DOM-like interface. Please share your pros&cons!

Parentheses don't mean text constant anymore. In Tcl, math expressions can be evaluated with the expr command. In AiDL, we use = instead of expr. But since complex formulae are still cumbersome with this syntax, I introduce the parenthese syntax as a fallback to classical notation. See the "factorial" math expression syntax example.

I'm dropping the "goal-directed execution" concept from Icon programming language. I really appreciate it as a great tool, very clever. But on this one, I'm going to walk the Python path: "To describe something as 'clever' is not considered a compliment in the Python culture." In fact, goal-directed execution is a little tough to wrap your head around, and if we're gonna teach a program how to develop itself, we'd better stick to more conventional programming patterns. It hasn't been widely adopted for a reason.

WIP!

ED:

PUB/SUB

Objects can subscribe to channels, publish on channels, and receive from channels.

A channel is a list of texts.

For example, when a value published on channel list { abc def ghi }

Channel subscribed to      Reception
=====================      =========
abc def ghi                yes
abc def                    yes
abc def ghi jkl            yes
abc xyz                    no
def ghi                    no
abc ghi                    no


PARSER

Parsers have a specific syntax that looks like this:

    parser {
        rule1 = parsingExpression
        rule2 = parsingExpression
        rule3 = parsingExpression
        ...
    }


Where parsingExpression is one of:

    "literal"
    . (dot character)
    [characters]
    rule
    ( expression )
    parsingExpression *
    parsingExpression +
    parsingExpression ?
    & parsingExpression
    ! parsingExpression
    & { predicate }
    ! { predicate }
    $ parsingExpression
    label : parsingExpression
    parsingExpression1 parsingExpression2 ... parsingExpressionN
    parsingExpression { action source code }
    parsingExpression1 / parsingExpression2 / ... / parsingExpressionN

Title: Re: AiDL language draft
Post by: ivan.moony on January 22, 2018, 09:48:59 pm
Something surprised me recently on web: railroad-diagrams (https://github.com/tabatkins/railroad-diagrams). The project is also great because it has very pro-liberal license.

(https://i.stack.imgur.com/5c3jo.gif)

This would look great for documenting code parts. Extraction of diagrams for EBNF is relatively easy, and there are a lot of tools doing it, but unfortunately, ordinary BNF is not supported anywhere near. There is no even a converter from BNF to EBNF. I was a bit disappointed because I wanted to have something like this for /**... */ sections of my language like in javadoc (https://en.wikipedia.org/wiki/Javadoc), but as the language is based on ordinary BNF, I can't have it. Maybe I'll think of something, but materia gets extremely complicated with introduction of dependent types (https://en.wikipedia.org/wiki/Dependent_type), even if I figure out what to do with ordinary BNF.

Anyway, `parsingExpression` part of AiDL looks somewhat similar to EBNF, so I thought you might be interested in automatic railroads extraction.
Title: Re: AiDL language draft
Post by: Zero on January 22, 2018, 10:56:55 pm
Yeah, cool idea. Thanks  :)

AiDL parsers will be implemented using PEGjs (https://pegjs.org/). They use Parsing Expression Grammar formalism, which is close to EBNF. There's a tool called GrammKit (http://dundalek.com/GrammKit/) that can generate railroads directly from PEGjs, so that's probably what I'd use.

About converting BNF to EBNF, isn't it possible to detect recursion and replace it with " * " or " + " operators? And anyway, isn't EBNF a superset of BNF, semantically?
Title: Re: AiDL language draft
Post by: ivan.moony on January 23, 2018, 12:10:45 am
AiDL parsers will be implemented using PEGjs (https://pegjs.org/). They use Parsing Expression Grammar formalism, which is close to EBNF. There's a tool called GrammKit (http://dundalek.com/GrammKit/) that can generate railroads directly from PEGjs, so that's probably what I'd use.

Yeah, PEG.js is faaaaaaaaaaaaaaaaaaassssssssssssssssttttttttttttttt :)

About converting BNF to EBNF, isn't it possible to detect recursion and replace it with " * " or " + " operators? And anyway, isn't EBNF a superset of BNF, semantically?

It seems that converting recursions is not such a trivial task (on a first look). There are left, middle and right recursions. There are also nested kinds recursions, and then we may branch over multiple recursions inside a single rule. Moreover, a conditional branching may be added too. All of this looks discouraging, while I don't want to give up of simplicity of BNF (I want to use the least possible number of primitive operators - more about this soon).

Of course, one could write BNF in EBNF, but in that case, mentioned tools would not give a meaningful result, I think railroad looping essence is in a use of `+`, `*` and `?`. Otherwise, they use references that look like everything but a railroad to me.

[Edit]
Just slipped my mind, references could have a little [+/-] beside, just to [expand / contract] their content. That could make a hell of a structural code editor, if combined with railroads... But what about the loops? Huh...

[New edit]
With some proper `null` treatment, I guess it could work, I think I'll give it a try when the time comes.
Title: Re: AiDL language draft
Post by: Zero on January 23, 2018, 09:45:15 am
Ok, harder than I thought.

The simplest form of syntax description would be a multiset of couples... when the left hand appears several times, it means "or". Am I wrong?
Title: Re: AiDL language draft
Post by: ivan.moony on January 23, 2018, 10:09:22 am
If I understood the question, you are right about `or`.

If you skim over context free grammar (CFG) (https://en.wikipedia.org/wiki/Context-free_grammar) definition, from which is BNF derived, you'll notice that there are only these kind of productions: `A -> B C D ...`, and repeating the same left side `A` makes an `or` set. This follows from a logic operator of consequence `->` where from:
A -> B
C -> D
follows:
(A or B) -> (C and D)

That is how the logic field works. Left sides are `or`-ed and right sides are `and`-ed. Repeating the same letter multiple times over multiple lines on the left or on the right sides makes wonders.

Make a notice that CFG productions draw arrows in the opposite direction than logic. What is in CFG written as
A -> B C D
should in logic be written as
B C D -> A
or more readable
A <- B C D
Title: Re: AiDL language draft
Post by: Zero on January 23, 2018, 02:38:38 pm
Quote
A -> B
C -> D
follows:
(A or B) -> (C and D)
If there's no typo in this quote, then I don't get it. How could (A or B) be related to (C and D), since there's no link between "A -> B" and "C -> D"?

Your notice about CFG and logic is exciting. Could they be expressed and manipulated uniformly? Do they both belong to the same superset?
Title: Re: AiDL language draft
Post by: ivan.moony on January 23, 2018, 04:09:01 pm
Quote
A -> B
C -> D
follows:
(A or B) -> (C and D)
If there's no typo in this quote, then I don't get it. How could (A or B) be related to (C and D), since there's no link between "A -> B" and "C -> D"?

Sorry, it was a typo. I meant: (A or C) -> (B and D). But I overcalculated myself, sorry again, this statement is also false.

What I really meant (I hope I wrote it right now) was this:
A -> B
A -> C
consequences with:
A -> (B and C)

and other way around:
B -> A
C -> A
consequences with:
(B or C) -> A

This much is logical to me, and it is a kind of a common sense, if you think about it. I derived it a while ago, by connecting the pairs of formulas by `and` and doing a bit of classical logic (https://en.wikipedia.org/wiki/Propositional_calculus) inference by resolution method (https://en.wikipedia.org/wiki/Resolution_(logic)) and rules:
(A -> B) <-> (¬A or B)
((A and B) or C ) <-> ((A or C) and (B or C))
((A or B) and C) <-> ((A and C) or (B and C))
¬(A and B) <-> (¬A or ¬B)
¬(A or B) <-> (¬A and ¬B)

Your notice about CFG and logic is exciting. Could they be expressed and manipulated uniformly? Do they both belong to the same superset?
It seems, for now, that logic alone is not suitable for processing streams of data, while it is good for isolated stream (sequence) elements. There has to be some sequence operator extension to logic. Maybe in a form of predicates (https://en.wikipedia.org/wiki/First-order_logic), but then each predicate parameter (as a sequence element) should implement its little sub-logic connected to the above for references and recursion. Very inspiring question. And very good scientific paper could be extracted from CFG - Logic analogy. Proving a contradiction in a grammar would mean that the grammar would never parse anything (it would always report an error upon parsing), and could be considered as an error in grammar.
Title: Re: AiDL language draft
Post by: Zero on January 24, 2018, 09:50:49 am
Quote
What I really meant (I hope I wrote it right now) was this:
A -> B
A -> C
consequences with:
A -> (B and C)

and other way around:
B -> A
C -> A
consequences with:
(B or C) -> A
Thank you, I understand now.

About the CFG - Logic analogy, I'm far from mastering these subjects. But CFG seem to "shrink" data (when used as parser), while logic inference rules seem to "expand" data. So maybe what CFG can do in one direction, logic can do in the opposite direction?

About AiDL, I'm splitting what was functions in two distinct tools: verbs and functions.

Verbs use the Tcl-like syntax. The results of all statements of  a verb are collected during execution, and returned as an "evolution" (a new data type). Verbs can have side-effects.

Functions can't have side-effect, and use a mathematical (classical) syntax, more like a spreadsheet formula's syntax.

ED:

I'm a moron. If verbs return an "evolution", how can I replace square brackets by the result of the code inside them. Stupid me. So... Back to normal: verbs return the value of their last statement.
Title: Re: AiDL language draft
Post by: LOCKSUIT on January 24, 2018, 10:22:18 pm
Zero.........what is this thread all about ???????? I have a hint but...   Is it about creating an AI that learns/uses language?

Zero/Ranch, when you bring up "else it's parrot-like", are you talking about a hierarchical knowledge tree made up of neural layers that connect letters to words and then words to sentences in higher layers "meanings" and hence their relations defined by connections? And that when you talk to it and fill it up with human English language, it says the same stuff, even exactly, out of its mouth? I know how to fix that.
Title: Re: AiDL language draft
Post by: Zero on January 25, 2018, 09:04:41 am
How would you know "how to fix that", if you don't know what this thread is about?  ;)

This thread is about a new programming language named AiDL, which:
- is inspired from Tcl (https://en.wikipedia.org/wiki/Tcl) and Io (https://en.wikipedia.org/wiki/Io_(programming_language)),
- is based on previous works on the pub/sub pattern,
- features a "meaning" type to handle semantic data,
- allows deep metaprogramming,
- targets modern browsers as a platform.

ED: Added links to Tcl and Io.
Title: Re: AiDL language draft
Post by: LOCKSUIT on January 25, 2018, 06:37:36 pm
Basically, by parrot-talk, I mean, we input into the ANN, and the output is well, the same! No good! It's a parrot! Is this your problem?
Title: Re: AiDL language draft
Post by: Zero on January 25, 2018, 09:34:11 pm
Thank you LOCKSUIT. There's no neural net here, and no problem to solve. Ranch was "generally speaking".
Title: Re: AiDL language draft
Post by: LOCKSUIT on January 26, 2018, 04:01:26 am
Quote
You're right, you can't hardcode everything because there's too much. But I think it's possible to reach some kind of top-down "critical mass", and BOOM. Like the Terminator.

Sensing can be tricky, yes: we need specific perception/interpretation devices or subsystems whatever you wanna call them. It can't be high-level. When your eyes meet a face, you just see a face. The mechanism that makes the "face construct" pop in your mind isn't conscious at all.



about an automatic sensor to fill it up->  if your putting tonnes of english with some kind of natural language processor that goes into the symbolic system, they tend to be parrotlike and take it in no matter how nonsensical it is,  a machine has no judgement of good reading matter unless u give it to it, and it would be tricky.

even people dont know what to believe,  its actually a fundamental problem with intelligence in general,  let alone parrotlike data collecting.

I guess it must take in the information,  but maybe you put a scope difference between "different opinions", and it takes them all in...  then a machine has a bit of a personality problem, doesnt know who to be. :)

Im not saying these symbolic structures dont work tho,  I think they do just as much as pattern recognition stuff does.  (see Yann Lecun's amazing works) its all assignment after all. (=) in both techniques.

Q1) It seems from the above that this incorporates AI, senses, and actions?
Q2) Why AiDL and not C++? If it comes with T5000 then I get why.
Title: Re: AiDL language draft
Post by: Zero on January 26, 2018, 08:54:54 am
Thanks for your questions.

Q1. Indeed, it's a global project.
Q2. Because you can't express everything easily in C++. I want a unified high-level language, that's able to define everything above senses: abstract concepts and their instances, behaviors, relations. And I want an engine that can run the whole 'mind' of a thinkbot, in a browser. That's why I'm creating AiDL.
ED: I know that most AI hobbyists believe that the key to success lies in learning techniques. I don't think so. I think we need to build an ontology of self, an ontology of the AI's own 'mind', and then use it to interpret and understand the various data produced by its 'internal sensors'. Then, establish a communication with the AI, through a controlled natural language, and teach it how to develop itself, until it starts enhancing itself by itself.
Title: Re: AiDL language draft
Post by: Zero on January 26, 2018, 03:48:21 pm
Code
set Hand [ object {
    <body-part>fingers: 5,
    <state>holds: nothing,
    <action>grab: verb {
        if (holds==nothing) {
            set holds [argument];
        };
    },
    <action>write: verb {
        if (holds==pencil) {
            Console log "Writing [argument]";
        };
    },
    <action>drop: verb {
        set holds nothing;
    }
}];

set Human [ object {
    <body-part>head: object {
        <action>say: verb {
            console log "Saying [argument]";
        }
    },
    <body-part>left-hand: [Hand clone],
    <body-part>right-hand: [Hand clone]
}];

set John [Human clone];

John right-hand grab pencil, write "Hello world";

This is a taste of AiDL, as it is today. Like Io, it works by message-passing. Like Tcl, code between square brackets is evaluated, and square brackets are replaced by the result of the evaluation.
- In the last line, we send the message right-hand grab pencil, write "Hello world"; to John.
- Then John sends grab pencil, write "Hello world"; to its right-hand slot.
- Then John's right-hand calls its grab method with pencil as argument.
- Then John's right-hand calls its write method with "Hello world" as argument.
Title: Re: AiDL language draft
Post by: Zero on January 29, 2018, 08:35:40 am
I was wondering what interface should I propose for AiDL. It has to be neutral, give developers freedom to do whatever they want with their page... Then I remembered Amber (http://www.amber-lang.net/index.html), a Smalltalk environment in the browser. The cool thing here is what happens when you click the big green button "Try Amber in your browser!". A panel shows up at the bottom of the page, just like the developer's tool every browser would show when you hit CTRL+SHIT+I. This might be a nice solution for AiDL.

ED: Probably with Golden Layout (https://golden-layout.com/) because, let's face it, it's awesome isn't it?