This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !(import_prolog_function statistics) | |
| (= (BudgetLimitCheck) | |
| (if (> (- (statistics inferences) (get-state &initinferences)) (get-state &inferenceslimit)) | |
| (translatePredicate (shift (pay-for-inferences))) | |
| True)) | |
| (= (AssignBudgetLimit $N) | |
| (progn (change-state! &initinferences (statistics inferences)) | |
| (change-state! &inferenceslimit $N))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sexpdata import loads | |
| from petta import * | |
| metta = PeTTa() | |
| expstring = metta.process_metta_string("!(hello \"world\" (1.0 1))")[0] | |
| print(loads(expstring)) | |
| #Output: | |
| #[Symbol('hello'), 'world', [1.0, 1]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(readutil)). % read_file_to_string/3 | |
| :- use_module(library(pcre)). % re_replace/4 | |
| :- current_prolog_flag(argv, Args), ( (memberchk(silent, Args) ; memberchk('--silent', Args) ; memberchk('-s', Args)) | |
| -> assertz(silent(true)) ; assertz(silent(false)) ). | |
| %Read Filename into string S and process it (S holds MeTTa code): | |
| load_metta_file(Filename, Results) :- load_metta_file(Filename, Results, '&self'). | |
| load_metta_file(Filename, Results, Space) :- read_file_to_string(Filename, S, []), | |
| process_metta_string(S, Results, Space). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git clone https://github.com/jazzbox35/MettaWamJam | |
| cd MettaWamJam | |
| docker build -t mettawamjam:latest . | |
| docker run --rm -d --name mwj -p 127.0.0.1:5000:5000 mettawamjam:latest | |
| then run: | |
| python3 RunMeTTaCode.py | |
| python3 RunMutex_and_Transaction.py | |
| python3 RunMM2Code.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Input: Whales are mammals that live in the ocean. | |
| <(whale * ocean) --> live_in>. :|: {1.0 0.9} | |
| //Input: Animals that live in the ocean are marine animals. | |
| <(animal * ocean) --> live_in>. :|: {1.0 0.9} | |
| <animal --> marine_animal>. :|: {1.0 0.9} | |
| //Input: Marine mammals are exposed to pollutant P. | |
| <(marine_animal * pollutant_p) --> are_exposed_to>. :|: {1.0 0.9} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %Finding divisors | |
| 'find-divisor'(A, B, C) :- | |
| *(B, B, D), | |
| >(D, A, E), | |
| ( E==true | |
| -> C=A | |
| ; C=F, | |
| '%'(A, B, G), | |
| ==(0, G, H), | |
| ( H==true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (foo 1) | |
| (foo 2) | |
| ;Ok: Leads to unnecessary 'and' and 'empty' invocation in compiled output: | |
| (= (match-single1 $space $pat $ret) | |
| (if (and (= $x (match $space $pat $ret)) (cut)) | |
| $x (empty))) | |
| ;Bad: Leads to unneccesary maybe_call which is expensive: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ((step app) | |
| (, (num $1) ) | |
| (, (num (M $1)) | |
| (num (W $1)) )) | |
| ((step app) | |
| (, (num (M $1)), | |
| (num (W $1)) ) | |
| (, (num (C $1)) )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Needed: | |
| pip3 install requests-sse | |
| client.py: | |
| Replace /target/debug/mork_server with /target/release/mork_server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Exhaustive-until-depth deriver | |
| (= (Derive $derivationsLast $beliefs $depth $maxdepth) | |
| (if (> $depth $maxdepth) | |
| $beliefs | |
| (let $derivations | |
| (collapse (superpose ((let* (((Sentence $x $Ev1) (superpose $derivationsLast)) | |
| ((Sentence $y $Ev2) (superpose $beliefs)) | |
| ($stamp (TupleConcat $Ev1 $Ev2))) | |
| (if (StampDisjoint $Ev1 $Ev2) | |
| (case (|- $x $y) ((($T $TV) (Sentence ($T $TV) $stamp)))) (empty))) |
NewerOlder