Skip to content

Commit

Permalink
Merge pull request logicmoo#10 from trueagi-io/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
TeamSPoon authored Apr 11, 2024
2 parents bd12cd0 + 63a3b7e commit 896fc95
Show file tree
Hide file tree
Showing 888 changed files with 4,516,732 additions and 1,467,211 deletions.
33 changes: 27 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ ftp.flybase.net/**
.*/
*~
.*
*.qlf
*.datalog
*-wam.vpw?*
*.vtg
.bash_history
*.bak
tests~output/
reports/*/
swipl-devel/
ImplicitQuantification.tex
data/ftp.flybase.net/
data/SO-Ontologies/
Expand All @@ -35,11 +38,29 @@ src/main/swi_flybase_fast.new
src/main/swi_flybase_fast_good.pl
reqs/
# temp files
./FOUND_UNITS.sortme
./PASS_FAIL.md
./Results.md
./*.ansi
./TEE.ansi.UNITS
./TEST_LINKS.md
./final_MeTTaLog.md
./TEE*.ansi.UNITS
Result.html
# Added by Visual Studio Code
apples/
bline/
compout/
ctm.metta
file_info.tmp
last-run/
main123/
mettalog.bg
nars123/
repsss/
rr/
rtests/
src/CAAA/
src/canary/metta_compiler - Copy.pl
src/canary/metta_compiler.pl.304
src/canary/metta_compiler.pl.bak.right
src/canary/metta_compiler.pl.left
src/canary/metta_compiler.pl.new2
src/canary/metta_compiler.pl.newest
src/canary/metta_compiler.pl.old
tests_output/

211 changes: 68 additions & 143 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ Exit the REPL with `ctrl-D`.
MeTTa tests/baseline_compat/hyperon-experimental_scripts/b0_chaining_prelim.metta
```

**Note:** Remember, the `MeTTa` script's name is case-sensitive. Do not confuse it with `metta`, which might refer to a different tool written in Rust.
**Note:** Remember, the `MeTTa` script's name is case-sensitive. Do not confuse it with `metta`, which refers to the MeTTa Interpreter written in Rust.


**To run a metta file normally:**

```bash
MeTTa tests/baseline_compat/hyperon-experimental_scripts/b0_chaining_prelim.metta
```

** Launch Jupyter notebook: (in progress) **
- Contains a Jupyter Kernel for MeTTa (allows runing of MeTTa scripts remotely)
Expand Down Expand Up @@ -125,15 +121,23 @@ For queries or suggestions, please open an issue on our [GitHub repository](http
MeTTaLog is distributed under the LGPL License, facilitating open collaboration and use.


## :gear: Prerequisites for using in Rust
## :gear: Prerequisites for using MeTTaLog in Rust

- A build of [Hyperon Experimental](https://github.com/trueagi-io/hyperon-experimental) is required.
```bash
/home/user$ metta
metta> !(import-py! mettalog)
metta> !(mettalog:repl)
metta@&self +> !(ensure-loaded! whole_flybase)
metta@&self +> !(, (fbgn_fbtr_fbpp_expanded! $GeneID $TranscriptType $TranscriptID $GeneSymbol $GeneFullName $AnnotationID $28 $29 $30 $31 $32) (dmel_unique_protein_isoforms! $ProteinID $ProteinSymbol $TranscriptSymbol $33) (dmel_paralogs! $ParalogGeneID $ProteinSymbol $34 $35 $36 $37 $38 $39 $40 $41 $42) (gene_map_table! $MapTableID $OrganismAbbreviation $ParalogGeneID $RecombinationLoc $CytogeneticLoc $SequenceLoc) (synonym! $SynonymID $MapTableID $CurrentSymbol $CurrentFullName $43 $44))

metta@&self +> !(let $query
(, (fbgn_fbtr_fbpp_expanded $GeneID $TranscriptType $TranscriptID $GeneSymbol $GeneFullName $AnnotationID $_ $_ $_ $_ $_)
(dmel_unique_protein_isoforms $ProteinID $ProteinSymbol $TranscriptSymbol $_)
(dmel_paralogs $ParalogGeneID $ProteinSymbol $_ $_ $_ $_ $_ $_ $_ $_ $_)
(gene_map_table $MapTableID $OrganismAbbreviation $ParalogGeneID $RecombinationLoc $CytogeneticLoc $SequenceLoc)
(synonym $SynonymID $MapTableID $CurrentSymbol $CurrentFullName $_ $_))
(match &self $query $query))

```


Expand Down Expand Up @@ -186,162 +190,83 @@ Pass Test:(Values same: [[B]] == [[B]])
```
# MeTTa Execution Modes
[These are inherited from SWI-Prolog](https://www.swi-prolog.org/pldoc/man?section=cmdline)
MeTTa can be executed in one of the following modes:
- `mettalog [option ...] script-file [arg ...]`
Arguments after the script file are made available in the MeTTa flag `argv`.
- `mettalog [option ...] metta-file ... [[--] arg ...]`
This is the normal way to start MeTTa. The MeTTa flag `argv` provides access to `arg ...`. If the options are followed by one or more MeTTa file names (i.e., names with extension .metta), these files are loaded. The first file is registered in the MeTTa flag `associated_file`.
- `mettalog -o output -c metta-file ...`
The `-c` option is used to compile a set of MeTTa files into an executable.
- `mettalog -o output -b prolog-bootfile metta-file ...`
Bootstrap compilation.
### Command Line Options for Running MeTTa
[These are inherited from SWI-Prolog](https://www.swi-prolog.org/pldoc/man?section=cmdline)
Boolean options may be written as `--name` (true), `--noname` or `--no-name` (false).
- `--debug-on-interrupt`
Enable debugging on an interrupt signal immediately.
- `--home[=DIR]`
Use `DIR` as home directory.
- `--quiet`
Set the MeTTa flag `verbose` to `silent`, suppressing informational and banner messages. Also available as `-q`.
- `--no-debug`
Disable debugging.
- `--no-signals`
Inhibit any signal handling by MeTTa, a property that is sometimes desirable for embedded applications. This option sets the flag signals to false. Note that the handler to unblock system calls is still installed. This can be prevented using `--sigalert=0` additionally.
- `--no-threads`
Disable threading for the multi-threaded version at runtime. See also the flags `threads` and `gc_thread`.
- `--no-packs`
Do not attach extension packages (add-ons).
- `--no-pce`
Enable/disable the xpce GUI subsystem. Using `--pce` loads the xpce system in user space and `--no-pce` makes it unavailable in the session.
- `--on-error=style`
How to handle errors.
- `--on-warning=style`
How to handle warnings.
- `--pldoc[=port]`
Start the PlDoc documentation system on a free network port. If port is specified, the server is started at the given port and the browser is not launched.
- `--sigalert=NUM`
Use signal NUM (1 ... 31) for alerting a thread. If NUM is 0 (zero), this handler is not installed.
- `--no-tty`
Unix only. Switches controlling the terminal.
## Python interaction
- `-O`
Optimised compilation.
Module loading
; using the python default module resolver $PYTHONPATH
`!(import! &self motto.llm_gate)`
; using the python path
`!(import! &self ../path/to/motto/llm_gate.py)`
; Rust way (was the only way to load llm_gate functions from Rust)
`!(import! &self motto)`
- `-l file.metta`
Load file.metta.
; Script running
`!(pymain! &self ../path/to/motto/test_llm_gate.py ( arg1 arg2 ))`
; Single methods is python files
`!(pyr! &self ../path/to/motto/test_llm_gate.py "run_tests" ((= verbose True)))`
- `-s file.metta`
Use file.metta as a script file.
; Can define a shortcut
(: run-llm-tests (-> Bool Ratio))
(=
(run-llm-tests $verbose)
(pyr! &self ../path/to/motto/test_llm_gate.py "run_tests" ((= verbose $verbose))))
- `-f file.metta`
Use file.metta as initialisation file instead of the default `init.metta`.
## MeTTaLog Extras
- `-F script`
Select a startup script from the MeTTa home directory.
- `-x prolog-bootfile`
Boot from prolog-bootfile instead of the system''s default boot file.
(Imported member/2 1 superpose)
; For the compiler to know that the member function will be a predicate
(Compiled member/2)
; Declare member/2
(: member/2 Nondeterministic)
- `-p alias=path1[:path2 ...]`
Define a path alias for file_search_path.
- `--`
Stops scanning for more arguments.
; MeTTa file loading
`!(include! &self ../path/to/motto/test_llm_gate.metta)`
; Http Files
`!(include! &self https://somewhere/test_llm_gate.metta)`
### Controlling the Stack Sizes
```shell
$ mettalog --stack-limit=32g
```
; interfacing to Prolog
(:> OptionsList (List (^ Expresson (Arity 2))))
(:> ThreadOptions OptionsList)
(:> ThreadId Number)
(: make-thread (-> Expression ThreadOptions ThreadId))
(: thread_create/3 Deterministic)
;; (add-atom &self (Imported thread_create/3 2 make-thread))
(=
(make-thread $goal $options)
(let True
(as-tf (thread_create! $goal $result $options))
$result))

; returns a number and keeps going
!(make-thread (shell! "xeyes") ((detached False)))

- `--stack-limit=size[bkmg]`
Limit the combined size of the MeTTa stacks to the indicated size.
- `--table-space=size[bkmg]`
Limit for the table space.
- `--shared-table-space=size[bkmg]`
Limit for the table space for shared tables.
### Running Goals from the Command Line
- `-g goal`
Goal is executed just before entering the top level.
```shell
% mettalog <options> -g (go) -g (quit)
```
- `-t (goal)`
Use goal as an interactive top level instead of the default goal `!(repl!)`.
### Compilation Options
[MeTTa Code is tranliterated to SWI-Prolog code and compiled](https://www.swi-prolog.org/pldoc/man?section=runtime)
- `-c file.metta ...`
Compile files into an intermediate code file.
- `-o output`
Used in combination with `-c` to determine the output file for compilation.
### Informational Command Line Options
- `--arch`
When given as the only option, it prints the architecture identifier (see MeTTa flag `arch`) and exits. See also `--dump-runtime-variables`.
- `--dump-runtime-variables [=format]`
When given as the only option, it prints a sequence of variable settings that can be used in shell scripts to deal with MeTTa parameters.
```shell
eval `mettalog --dump-runtime-variables`
cc -I$PLBASE/include -L$PLBASE/lib/$PLARCH ...
To get comparable Interp vs Compiler statistics in one Main Output
```
clear ; mettalog --test --v=./src/main --log --html tests/*baseline*/ \
--output=4-06-main-both --clean
clear ; mettalog --test --v=./src/canary-lng --log --html tests/*baseline*/ \
--output=4-06-canary-lng-both --clean
clear ; mettalog --test --v=./src/canary --log --html tests/*baseline*/ \
--output=4-06-canary-wd-both --clean
```
- `--help`
When given as the only option, it summarises the most important options.
- `--version`
When given as the only option, it summarises the version and the architecture identifier.
- `--abi-version`
Print a key (string) that represents the binary compatibility on a number of aspects.
### Maintenance Options
[These are inherited from SWI-Prolog](https://www.swi-prolog.org/pldoc/man?section=cmdline)
- `-b initfile.metta ...-c file.metta ...`
Boot compilation.
- `-d token1,token2,...`
Print debug messages for DEBUG statements.
Vs for diffing
```

clear ; mettalog --test --v=./src/canary --log --html --compile=full tests/baseline_compat/ \
--output=4-06-compile_full --clean

clear ; mettalog --test --v=./src/canary --log --html --compile=false tests/baseline_compat/ \
--output=4-06-compile_false --clean

```
Loading

0 comments on commit 896fc95

Please sign in to comment.