Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
B
Brainy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
spritely
Brainy
Commits
ed71b64b
Unverified
Commit
ed71b64b
authored
2 years ago
by
Christine Lemmer-Webber
Browse files
Options
Downloads
Patches
Plain Diff
Add a basic README
parent
f38ea403
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.org
+218
-0
218 additions, 0 deletions
README.org
with
218 additions
and
0 deletions
README.org
0 → 100644
+
218
−
0
View file @
ed71b64b
This is the very, very, very research-project'y implementation of the
[[https://dspace.mit.edu/handle/1721.1/49525][propagator model]] on top of Spritely Goblins. Spritely Brainy takes
a lot of syntax inspiration from the
[[https://groups.csail.mit.edu/mac/users/gjs/propagators/revised-html.html][Revised Report on the Propagator Model]], more so than from
[[https://dspace.mit.edu/handle/1721.1/49525][Radul's dissertation]]
* What can propagators do?
This implementation is in its infancy. It can currently:
- Solve simple algebraic equations in any direction
- That's about it
But in the future, it should be able to:
- Narrow down partial information as more information comes in!
- Explore multiple, possibly contradicting, worldviews
(truth maintenance systems)!
- Functional reactie programming!
- Logic programming!
- Theorem provers!
- Type solvers!
- [[https://people.csail.mit.edu/lgilpin/publication/dissertation/][Retroactively explain why your machine learning model crashed your car!]]
* Getting this up and running
TODO: set up Guix stuff to make this eeeeeeeeeasy
* Minimal example
Uh, here's a bare minimum example of usage.
#+BEGIN_SRC scheme
(use-modules (brainy) (brainy prun))
#+END_SRC
Let's spawn a propagator cell. (=prun= stands for "propagator-run";
it takes care of a bunch of things for you so that you can start
hacking with Brainy at the REPL fast):
#+BEGIN_SRC scheme
GUILE> (define x (prun (spawn-pcell)))
#+END_SRC
What's its contents? Currently nothing!
#+BEGIN_SRC scheme
GUILE> (prun (content x))
; => #<<nothing>>
#+END_SRC
Well we can add some information with =add-content=:
#+BEGIN_SRC scheme
GUILE> (prun (add-content x 25))
GUILE> (prun (content x))
; => 25
#+END_SRC
Well okay, that works but it's kind of boring. We already knew it
contained the information 25!
Let's make two more cells and hook up a propagator adder:
#+BEGIN_SRC scheme
GUILE> (prun (p:+ x y z))
; => #<local-object ^propagator>
#+END_SRC
Hm, well that did *something*... it returned a propagator object!
But that's not particularly interesting.
What are the contents of our cells currently?
#+BEGIN_SRC scheme
GUILE> (prun (content x))
; => 25
GUILE> (prun (content y))
; => #<<nothing>>
GUILE> (prun (content z))
; => #<<nothing>>
#+END_SRC
Okay, well let's add a value to =y=:
#+BEGIN_SRC scheme
GUILE> (prun (add-content y 42))
#+END_SRC
Now not only does =y= contain a value... but the adder has propagated
information to =z= as well:
#+BEGIN_SRC scheme
> (prun (content y))
; => 42
> (prun (content z))
; => 67
#+END_SRC
Ho-hum. This doesn't seem particularly interesting. Okay, that's
because it isn't! =p:+= only feeds information forward. But there's
another version called =c:+= that does something more interesting...
=c:+= can solve an equation in any direction!
#+BEGIN_SRC scheme
GUILE> (define x2 (prun (spawn-pcell 40)))
GUILE> (define y2 (prun (spawn-pcell)))
GUILE> (define z2 (prun (spawn-pcell 42)))
GUILE> (prun (c:+ x2 y2 z2))
GUILE> (prun (content y2))
; => 2
#+END_SRC
Oh hey look, the propagator figured out that the middle value should
be 2!
If we now try to submit contradictory information:
#+BEGIN_SRC text
GUILE> (prun (add-content y2 666))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
inconsistency "Inconsistency at unknown! Tried to add 666 but already had 32"
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
GUILE [1]>
#+END_SRC
Type =,q= to exist the debugger. So okay, it won't allow that kind of
nonsense. Fair enough!
But this kinda looks too level, almost like assembly. It would be
nice if we could run things expression-style. And we can! Let's use
the =e:= style prefix expression-based propagator constructors, which
automatically construct a "return" cell".
#+BEGIN_SRC scheme
GUILE> (define should-be-twelve (prun (e:/ 24 2)))
GUILE> (prun (content should-be-twelve))
; => 12
#+END_SRC
Okay now THAT looks much more familiar!
Now that we've got all this set up, let's show off something more
interesting... a celsius-to-farenheit converter.
The equation for this is:
: C = (F - 32) * 5
Except we're going to set up one that can solve for any direction.
Including the constant "32"... we'll show that if you supply
everything else, it can solve for that too.
Here's what this looks like. Cells are ascii art "circles"
like =(_)= whereas propagators are "squares" like =[_]=.
(This is taken right from [[https://dspace.mit.edu/handle/1721.1/49525][Alexey Radul's dissertation]], page 28.)
: Fahrenheit Celsius
:
: f f-32 c*9 c
: (_)->[-]->(_)->[*]->(_)->[/]->(_)
: ^ ^ ^
: | | |
: thirty-two (_) five (_) (_) nine
: ^ ^ ^
: | | |
: [32] [5] [9]
For funsies, we'll show that it can solve in any direction by allowing
the user to specify the =thirty-two= part of the equation.
#+BEGIN_SRC scheme
(define* (fahrenheit-celsius #:key
[fahrenheit nothing] [celsius nothing]
[thirty-two 32])
(define-pcell f fahrenheit)
(define-pcell p32 thirty-two)
(define f-32
(e:- f p32))
(define c*9
(e:* f-32 5))
(define c
(e:/ c*9 9))
(add-content c celsius)
(values f c p32))
#+END_SRC
Now this gets interesting!
#+BEGIN_SRC scheme
;; Solve for celsius!
GUILE> (define-values (f c thirty-two)
(prun (fahrenheit-celsius #:fahrenheit 113)))
GUILE> (prun (content c))
; => 45
;; Solve for farehrenheit!
GUILE> (define-values (f c thirty-two)
(prun (fahrenheit-celsius #:celsius 45)))
GUILE> (prun (content f))
; => 113
;; Solve for... thirty-two!
GUILE> (define-values (f c thirty-two)
(prun (fahrenheit-celsius #:fahrenheit 113
#:celsius 45
#:thirty-two nothing)))
GUILE> (prun (content thirty-two))
; => 32
#+END_SRC
What if... you change =thirty-two= to be =64= but leave the other
values the same? Try it!
* What's next
A lot more is coming. Sorry to be so tantalyzing, you found this repo
early!
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment