From 71b10cd08444708312a68e262e14e70e02596c26 Mon Sep 17 00:00:00 2001
From: Douglas R Miles
Date: Wed, 6 Dec 2023 22:00:01 -0800
Subject: [PATCH] metta_data.
---
.bash_history | 71 +
examples/.bash_history | 2 +
.../nars/nars_v0/tests0.metta.answers | 6 +-
.../nars/nars_v0/tests1.metta.answers | 8 +-
.../nars/nars_v0/tests2.metta.answers | 6 +-
.../nars/nars_v0/tests3.metta.answers | 4 +-
.../nars/nars_v0/tests4.metta.answers | 6 +-
.../nars/nars_v0/tests5.metta.answers | 6 +-
.../nars/new/tests0.metta.answers | 4 +-
.../nars/new/tests1.metta.answers | 8 +-
.../nars/new/tests2.metta.answers | 4 +-
.../nars/new/tests3.metta.answers | 4 +-
.../nars/new/tests4.metta.answers | 4 +-
.../nars/new/tests5.metta.answers | 4 +-
.../nars/prev/tests0.metta.answers | 14 +
.../nars/prev/tests1.metta.answers | 13 +
.../nars/prev/tests2.metta.answers | 18 +
.../nars/prev/tests3.metta.answers | 11 +
.../nars/prev/tests4.metta.answers | 11 +
.../nars/prev/tests5.metta.answers | 12 +
examples/features/send-more.metta | 1 +
.../pathfinding-hard-f.metta.answers | 6 +-
.../pathfinding-hard.metta.answers | 7 -
.../performance/state_types.metta.answers | 4 +-
...er_function_application_type.metta.answers | 4 +-
.../test_list_concatenation.metta.answers | 4 +-
.../extend/example1.metta.answers | 21 +-
.../extend/example2.metta.answers | 23 +-
.../extend/example3.metta.answers | 26 +-
.../extend/example4.metta.answers | 28 +-
.../extend/example5.metta.answers | 25 +-
.../extend/example6.metta.answers | 22 +-
.../sandbox/das_gate/test_das.metta.answers | 6 +-
.../neurospace/test_assist.metta.answers | 23 +-
.../neurospace/test_nspace.metta.answers | 85 +-
.../sandbox/numpy/nm_test.metta.answers | 4 +-
.../sandbox/resolve/r.metta.answers | 6 +-
.../sql_space/sql_space_test.metta.answers | 14 +-
metta_vspace/pyswip/flybase_induced_types.pl | 330 ++++
metta_vspace/pyswip/flybase_main.pl | 971 ++++------
metta_vspace/pyswip/flybase_obo.pl | 85 +-
metta_vspace/pyswip/metta_compiler.pl | 178 +-
metta_vspace/pyswip/metta_data.pl | 21 +-
metta_vspace/pyswip/metta_eval.pl | 464 ++---
metta_vspace/pyswip/metta_interp.pl | 32 +-
metta_vspace/pyswip/metta_prelude.metta | 283 +++
metta_vspace/pyswip/metta_python.pl | 120 +-
metta_vspace/pyswip/metta_space.pl | 2 +-
metta_vspace/pyswip/metta_types.pl | 55 +-
metta_vspace/pyswip/metta_utils.pl | 3 +-
metta_vspace/pyswip/read_obo | 0
metta_vspace/pyswip/read_obo.pl | 0
metta_vspace/pyswip/swi_support.pl | 25 +-
metta_vspace/pyswip_2a/flybase_convert.pl | 3 +-
metta_vspace/pyswip_6l/metta_data.pl | 17 +-
metta_vspace/pyswip_6l/metta_eval.pl | 1585 ++++++++---------
metta_vspace/pyswip_6l/metta_interp.pl | 114 +-
metta_vspace/pyswip_6l/metta_space.pl | 5 +-
metta_vspace/pyswip_6l/metta_testing.pl | 3 +-
metta_vspace/pyswip_6l/metta_types.pl | 1154 ++++++++++++
.../Dmel_enzyme_data_fb_2023_04.tsv.metta | 2 +-
..._genetic_interactions_fb_2023_04.tsv.metta | 2 +-
...omated_gene_summaries_fb_2023_04.tsv.metta | 2 +-
.../best_gene_summary_fb_2023_04.tsv.metta | 2 +-
.../cDNA_clone_data_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/chebi_fb_2023_04.obo.metta | 2 +-
prebuilt_metta/cyto-genetic-seq.tsv.metta | 2 +-
prebuilt_metta/cytotable.txt.metta | 2 +-
.../dataset_metadata_fb_2023_04.tsv.metta | 2 +-
...ase_model_annotations_fb_2023_04.tsv.metta | 2 +-
..._ontology_annotations_fb_2023_04.tsv.metta | 2 +-
...man_orthologs_disease_fb_2023_04.tsv.metta | 2 +-
.../dmel_paralogs_fb_2023_04.tsv.metta | 2 +-
...ique_protein_isoforms_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/doid.obo.metta | 2 +-
.../entity_publication_fb_2023_04.tsv.metta | 2 +-
.../fb_synonym_fb_2023_04.tsv.metta | 2 +-
.../fbal_to_fbgn_fb_2023_04.tsv.metta | 2 +-
.../fbgn_NAseq_Uniprot_fb_2023_04.tsv.metta | 2 +-
.../fbgn_annotation_ID_fb_2023_04.tsv.metta | 2 +-
.../fbgn_exons2affy1_overlaps.tsv.metta | 2 +-
.../fbgn_exons2affy2_overlaps.tsv.metta | 2 +-
...gn_fbtr_fbpp_expanded_fb_2023_04.tsv.metta | 2 +-
.../fbgn_fbtr_fbpp_fb_2023_04.tsv.metta | 2 +-
.../fbgn_gleanr_fb_2023_04.tsv.metta | 2 +-
.../fbgn_uniprot_fb_2023_04.tsv.metta | 2 +-
.../fbrf_pmid_pmcid_doi_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/fly_anatomy.obo.metta | 2 +-
prebuilt_metta/fly_development.obo.metta | 2 +-
.../flybase_controlled_vocabulary.obo.metta | 2 +-
.../flybase_stock_vocabulary.obo.metta | 2 +-
.../fu_gal4_table_fb_2023_04.json.metta | 2 +-
prebuilt_metta/gene_association.fb.metta | 2 +-
...ional_complementation_fb_2023_04.tsv.metta | 2 +-
..._genetic_interactions_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/gene_group_FB2023_04.obo.metta | 2 +-
.../gene_group_data_fb_2023_04.tsv.metta | 2 +-
.../gene_groups_HGNC_fb_2023_04.tsv.metta | 2 +-
.../gene_map_table_fb_2023_04.tsv.metta | 2 +-
.../gene_rpkm_matrix_fb_2023_04.tsv.metta | 2 +-
.../gene_rpkm_report_fb_2023_04.tsv.metta | 2 +-
.../gene_snapshots_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/genome-cyto-seq.txt.metta | 2 +-
.../genomic_clone_data_fb_2023_04.tsv.metta | 2 +-
...notype_phenotype_data_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/go-basic.obo.metta | 2 +-
prebuilt_metta/gp_information.fb.metta | 2 +-
prebuilt_metta/image.obo.metta | 2 +-
.../insertion_mapping_fb_2023_04.tsv.metta | 2 +-
.../ncRNA_genes_fb_2023_04.json.metta | 2 +-
.../organism_list_fb_2023_04.tsv.metta | 2 +-
.../pathway_group_data_fb_2023_04.tsv.metta | 2 +-
...al_interactions_mitab_fb_2023_04.tsv.metta | 2 +-
.../pmid_fbgn_uniprot_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/psi-mi.obo.metta | 2 +-
...A-Seq_gene_expression_fb_2023_04.tsv.metta | 2 +-
prebuilt_metta/slice.chebi.obo.metta | 2 +-
prebuilt_metta/so-simple.obo.metta | 2 +-
prebuilt_metta/stocks_FB2023_04.tsv.metta | 2 +-
.../transposon_sequence_set.fa.metta | 2 +-
.../transposon_sequence_set.gff.metta | 2 +-
precomputed_files | 2 +-
122 files changed, 4062 insertions(+), 2037 deletions(-)
mode change 100644 => 100755 metta_vspace/pyswip/metta_data.pl
delete mode 100644 metta_vspace/pyswip/read_obo
delete mode 100644 metta_vspace/pyswip/read_obo.pl
diff --git a/.bash_history b/.bash_history
index de3b31bd..2389031b 100755
--- a/.bash_history
+++ b/.bash_history
@@ -1364,3 +1364,74 @@ git commit -am PASS_FAIL3
git push logicmoo
git commit -am PASS_FAIL4
git push logicmoo
+git commit -am dir
+git push logicmoo
+cls ; ./MeTTa examples/interp_00/metta-morph_tests/types3.metta
+cls ; ./MeTTa examples/baseline_compat/metta-morph_tests/zeroargs.metta
+cls
+ls
+cd ../..
+cd ..
+./MeTTa examples/flybase/sanity/load_all_of_flybase.metta
+gzip flybase.metta.qlf
+./MeTTa examples/flybase/sanity/load_all_of_flybase.metta
+./MeTTa examples/flybase/sanity/load_all_of_flybase.metta --clean
+./MeTTa examples/flybase/sanity/load_all_of_flybase.metta
+./MeTTa examples/flybase/sanity/load_all_of_flybase.metta --clean
+./MeTTa --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta --clean
+./MeTTa --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta --fresh
+./MeTTa --clean --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta --fresh
+./scripts/test_in_metta.sh --clean --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta --fresh
+./scripts/test_in_metta.sh --clean --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta.html --fresh
+rm examples/flybase/sanity/load_all_of_flybase.metta.html
+rm examples/flybase/sanity/load_all_of_flybase.metta.answers
+./scripts/test_in_metta.sh --clean --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta.html --fresh
+./scripts/test_in_metta.sh --clean --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta
+./scripts/test_in_metta.sh --fresh --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta
+cls
+./scripts/test_in_metta.sh --fresh --exec=rtrace examples/flybase/sanity/load_all_of_flybase.metta
+./scripts/test_in_metta.sh --fresh --exec=rtrace examples/flybase/sanity/
+./scripts/test_in_metta.sh --fresh --exec=rtrace examples/extended_compat/
+find -name "alle*.metta"
+cd ..
+cd -
+ks -l prebuilt_metta/
+ls -l prebuilt_metta/
+find -name "alle*.metta"
+ls -l
+cd ,,/
+cd ..
+ls -l
+rm precomputed_files
+ln -s /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/data/ftp.flybase.org/releases/FB2023_04/precomputed_file
+ln -s /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/data/ftp.flybase.org/releases/FB2023_04/precomputed_files/
+ls
+rm precomputed_file
+ls prebuilt_metta/
+ls prebuilt_metta/ -l
+rm d2utmp3EFiGC.metta
+cd ..
+ls
+cp flybase.metta.qlf.gz flybase_metta.qlf.gz
+gunzip flybase_metta.qlf.gz
+swipl -l flybase_metta.qlf
+./MeTTa
+./MeTTa
+grep is_syspre metta_vspace -R
+grep is_syspre metta_vspace -R | grep s2p
+grep is_syspre metta_vspace -R | grep s2p
+./MeTTa --fresh --exec=rtrace examples/extended_compat/
+metta
+shutdown -r now
+uptime
+cd /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/
+ls
+./MeTTa --clean examples/baseline_compat/
+./MeTTa --clean examples/baseline_compat/metta-morph_tests/types3.metta
+./MeTTa examples/baseline_compat/metta-morph_tests/types3.metta
+cp metta_vspace/pyswip metta_vspace/pyswip_touser
+cp metta_vspace/pyswip metta_vspace/pyswip_touser -a
+./MeTTa examples/baseline_compat/metta-morph_tests/types3.metta
+git checkout metta_vspace/pyswip/metta_eval.pl
+./MeTTa examples/baseline_compat/metta-morph_tests/types3.metta
+git status .
diff --git a/examples/.bash_history b/examples/.bash_history
index 0b253061..59e7f5d3 100644
--- a/examples/.bash_history
+++ b/examples/.bash_history
@@ -576,3 +576,5 @@ rmdir */*/*
rmdir */*/*/*
find
cd ,,
+touch simple_query2_llm.metta
+cd ../..
diff --git a/examples/extended_compat/nars/nars_v0/tests0.metta.answers b/examples/extended_compat/nars/nars_v0/tests0.metta.answers
index ea5761a4..f5666261 100644
--- a/examples/extended_compat/nars/nars_v0/tests0.metta.answers
+++ b/examples/extended_compat/nars/nars_v0/tests0.metta.answers
@@ -8,7 +8,7 @@
[()]
[(Error (assertEqualToResult (|- ((A --> cat) (1.0 0.9)) ((B --> cat) (1.0 0.9))) (((B --> A) (1.0 0.44751381215469616)) (((A ~ B) --> cat) (0.0 0.81)) (((A | B) --> cat) (1.0 0.81)) ((B <-> A) (1.0 0.44751381215469616)) (((A & B) --> cat) (1.0 0.81))))
Expected: [((B --> A) (1.0 0.44751381215469616)), (((A ~ B) --> cat) (0.0 0.81)), (((A | B) --> cat) (1.0 0.81)), ((B <-> A) (1.0 0.44751381215469616)), (((A & B) --> cat) (1.0 0.81))]
-Got: [((B <-> A) (1.0 0.44751381215469616)), ((B <-> A) (1.0 0.44751381215469616)), ((B --> A) (1.0 0.44751381215469616))]
+Got: [((B --> A) (1.0 0.44751381215469616)), ((B <-> A) (1.0 0.44751381215469616)), ((B <-> A) (1.0 0.44751381215469616))]
Missed result: (((A ~ B) --> cat) (0.0 0.81)))]
-0.69user 0.02system 0:00.72elapsed 100%CPU (0avgtext+0avgdata 36300maxresident)k
-0inputs+0outputs (0major+4312minor)pagefaults 0swaps
+0.69user 0.01system 0:00.71elapsed 99%CPU (0avgtext+0avgdata 36692maxresident)k
+0inputs+0outputs (0major+4358minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/nars_v0/tests1.metta.answers b/examples/extended_compat/nars/nars_v0/tests1.metta.answers
index d047ab5e..d4a41be7 100644
--- a/examples/extended_compat/nars/nars_v0/tests1.metta.answers
+++ b/examples/extended_compat/nars/nars_v0/tests1.metta.answers
@@ -5,9 +5,9 @@
[()]
[()]
[()]
-[(Error (assertEqual (TupleCount (get-atoms GroundingSpace-0x2df97b8)) 0)
+[(Error (assertEqual (TupleCount (get-atoms GroundingSpace-0x559bf93e46c8)) 0)
Expected: [0]
-Got: [(Error (TupleCount (get-atoms GroundingSpace-0x2df97b8)) NoValidAlternatives)]
+Got: [(Error (TupleCount (get-atoms GroundingSpace-0x559bf93e46c8)) NoValidAlternatives)]
Missed result: 0)]
-0.16user 0.02system 0:00.18elapsed 99%CPU (0avgtext+0avgdata 31968maxresident)k
-8inputs+0outputs (0major+4113minor)pagefaults 0swaps
+0.32user 0.00system 0:00.33elapsed 100%CPU (0avgtext+0avgdata 36420maxresident)k
+0inputs+0outputs (0major+4275minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/nars_v0/tests2.metta.answers b/examples/extended_compat/nars/nars_v0/tests2.metta.answers
index 62afc334..59d3d873 100644
--- a/examples/extended_compat/nars/nars_v0/tests2.metta.answers
+++ b/examples/extended_compat/nars/nars_v0/tests2.metta.answers
@@ -55,6 +55,6 @@
[]
[]
[]
-[(Error (match &attentional_focus (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#292943 $BeliefEvent#292944 $CPrio#292945) $Belief#292943) match expects a space as the first argument), (Error (match &concepts (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#292943 $BeliefEvent#292944 $CPrio#292945) $Belief#292943) match expects a space as the first argument)]
-15.37user 0.04system 0:15.41elapsed 99%CPU (0avgtext+0avgdata 38168maxresident)k
-0inputs+0outputs (0major+4635minor)pagefaults 0swaps
+[(Error (match &attentional_focus (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#292950 $BeliefEvent#292951 $CPrio#292952) $Belief#292950) match expects a space as the first argument), (Error (match &concepts (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#292950 $BeliefEvent#292951 $CPrio#292952) $Belief#292950) match expects a space as the first argument)]
+16.51user 0.02system 0:16.54elapsed 99%CPU (0avgtext+0avgdata 38456maxresident)k
+0inputs+0outputs (0major+4720minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/nars_v0/tests3.metta.answers b/examples/extended_compat/nars/nars_v0/tests3.metta.answers
index a0b971ca..7b539087 100644
--- a/examples/extended_compat/nars/nars_v0/tests3.metta.answers
+++ b/examples/extended_compat/nars/nars_v0/tests3.metta.answers
@@ -21,5 +21,5 @@
Expected: [None]
Got: [(BestDecision (Error (Error (Error (Error (Error (get-state ¤tTime) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) (Error (Error (Error (Error (Error (get-state &tempbest) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) (Error (Error (Error (get-state &FIFO) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument))]
Missed result: None)]
-5.05user 0.02system 0:05.07elapsed 100%CPU (0avgtext+0avgdata 38048maxresident)k
-0inputs+0outputs (0major+4646minor)pagefaults 0swaps
+5.41user 0.01system 0:05.43elapsed 99%CPU (0avgtext+0avgdata 38692maxresident)k
+0inputs+0outputs (0major+4737minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/nars_v0/tests4.metta.answers b/examples/extended_compat/nars/nars_v0/tests4.metta.answers
index ce72eb86..4ed3323d 100644
--- a/examples/extended_compat/nars/nars_v0/tests4.metta.answers
+++ b/examples/extended_compat/nars/nars_v0/tests4.metta.answers
@@ -17,7 +17,7 @@
[]
[(Error (assertEqual (EternalQuestion (({ garfield }) --> artist)) (Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0))))
Expected: [(Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0)))]
-Got: [(Error (match &attentional_focus (Concept (({ garfield }) --> artist) $Belief#93103 $BeliefEvent#93104 $CPrio#93105) $Belief#93103) match expects a space as the first argument), (Error (match &concepts (Concept (({ garfield }) --> artist) $Belief#93103 $BeliefEvent#93104 $CPrio#93105) $Belief#93103) match expects a space as the first argument)]
+Got: [(Error (match &attentional_focus (Concept (({ garfield }) --> artist) $Belief#93110 $BeliefEvent#93111 $CPrio#93112) $Belief#93110) match expects a space as the first argument), (Error (match &concepts (Concept (({ garfield }) --> artist) $Belief#93110 $BeliefEvent#93111 $CPrio#93112) $Belief#93110) match expects a space as the first argument)]
Missed result: (Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0))))]
-5.34user 0.02system 0:05.37elapsed 100%CPU (0avgtext+0avgdata 38756maxresident)k
-0inputs+0outputs (0major+4772minor)pagefaults 0swaps
+5.75user 0.00system 0:05.76elapsed 99%CPU (0avgtext+0avgdata 38940maxresident)k
+0inputs+0outputs (0major+4852minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/nars_v0/tests5.metta.answers b/examples/extended_compat/nars/nars_v0/tests5.metta.answers
index e0342149..97796f39 100644
--- a/examples/extended_compat/nars/nars_v0/tests5.metta.answers
+++ b/examples/extended_compat/nars/nars_v0/tests5.metta.answers
@@ -19,7 +19,7 @@
[]
[(Error (assertEqual (EternalQuestion (({ instance1 }) --> sheep)) (Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0))))
Expected: [(Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0)))]
-Got: [(Error (match &attentional_focus (Concept (({ instance1 }) --> sheep) $Belief#93704 $BeliefEvent#93705 $CPrio#93706) $Belief#93704) match expects a space as the first argument), (Error (match &concepts (Concept (({ instance1 }) --> sheep) $Belief#93704 $BeliefEvent#93705 $CPrio#93706) $Belief#93704) match expects a space as the first argument)]
+Got: [(Error (match &attentional_focus (Concept (({ instance1 }) --> sheep) $Belief#93711 $BeliefEvent#93712 $CPrio#93713) $Belief#93711) match expects a space as the first argument), (Error (match &concepts (Concept (({ instance1 }) --> sheep) $Belief#93711 $BeliefEvent#93712 $CPrio#93713) $Belief#93711) match expects a space as the first argument)]
Missed result: (Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0))))]
-5.48user 0.02system 0:05.50elapsed 99%CPU (0avgtext+0avgdata 38516maxresident)k
-0inputs+0outputs (0major+4719minor)pagefaults 0swaps
+5.68user 0.03system 0:05.72elapsed 99%CPU (0avgtext+0avgdata 38900maxresident)k
+0inputs+0outputs (0major+4797minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/new/tests0.metta.answers b/examples/extended_compat/nars/new/tests0.metta.answers
index 6fe55a1f..54796f68 100644
--- a/examples/extended_compat/nars/new/tests0.metta.answers
+++ b/examples/extended_compat/nars/new/tests0.metta.answers
@@ -8,5 +8,5 @@
Expected: [((B --> A) (1.0 0.44751381215469616)), (((A ~ B) --> cat) (0.0 0.81)), (((A | B) --> cat) (1.0 0.81)), ((B <-> A) (1.0 0.44751381215469616)), (((A & B) --> cat) (1.0 0.81))]
Got: [((B <-> A) (1.0 0.44751381215469616)), ((B <-> A) (1.0 0.44751381215469616)), ((B --> A) (1.0 0.44751381215469616))]
Missed result: (((A ~ B) --> cat) (0.0 0.81)))]
-0.75user 0.02system 0:00.78elapsed 99%CPU (0avgtext+0avgdata 36016maxresident)k
-32inputs+0outputs (2major+4333minor)pagefaults 0swaps
+0.69user 0.02system 0:00.71elapsed 99%CPU (0avgtext+0avgdata 36584maxresident)k
+0inputs+0outputs (0major+4358minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/new/tests1.metta.answers b/examples/extended_compat/nars/new/tests1.metta.answers
index 129756ad..42859897 100644
--- a/examples/extended_compat/nars/new/tests1.metta.answers
+++ b/examples/extended_compat/nars/new/tests1.metta.answers
@@ -1,7 +1,7 @@
[()]
-[(Error (assertEqual (TupleCount (get-atoms GroundingSpace-0x560dd6ef32e8)) 0)
+[(Error (assertEqual (TupleCount (get-atoms GroundingSpace-0x563948a851a8)) 0)
Expected: [0]
-Got: [(Error (TupleCount (get-atoms GroundingSpace-0x560dd6ef32e8)) NoValidAlternatives)]
+Got: [(Error (TupleCount (get-atoms GroundingSpace-0x563948a851a8)) NoValidAlternatives)]
Missed result: 0)]
-0.28user 0.02system 0:00.30elapsed 100%CPU (0avgtext+0avgdata 35728maxresident)k
-0inputs+0outputs (0major+4250minor)pagefaults 0swaps
+0.26user 0.01system 0:00.28elapsed 99%CPU (0avgtext+0avgdata 36332maxresident)k
+0inputs+0outputs (0major+4275minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/new/tests2.metta.answers b/examples/extended_compat/nars/new/tests2.metta.answers
index 378e9002..cd35cb32 100644
--- a/examples/extended_compat/nars/new/tests2.metta.answers
+++ b/examples/extended_compat/nars/new/tests2.metta.answers
@@ -56,5 +56,5 @@
[]
[]
[(Error (match &attentional_focus (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#292950 $BeliefEvent#292951 $CPrio#292952) $Belief#292950) match expects a space as the first argument), (Error (match &concepts (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#292950 $BeliefEvent#292951 $CPrio#292952) $Belief#292950) match expects a space as the first argument)]
-17.89user 0.01system 0:17.91elapsed 100%CPU (0avgtext+0avgdata 37928maxresident)k
-0inputs+0outputs (0major+4699minor)pagefaults 0swaps
+16.88user 0.00system 0:16.89elapsed 99%CPU (0avgtext+0avgdata 38768maxresident)k
+0inputs+0outputs (0major+4728minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/new/tests3.metta.answers b/examples/extended_compat/nars/new/tests3.metta.answers
index a30a4844..2ae3b210 100644
--- a/examples/extended_compat/nars/new/tests3.metta.answers
+++ b/examples/extended_compat/nars/new/tests3.metta.answers
@@ -21,5 +21,5 @@
Expected: [None]
Got: [(BestDecision (Error (Error (Error (Error (Error (get-state ¤tTime) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) (Error (Error (Error (Error (Error (get-state &tempbest) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) (Error (Error (Error (get-state &FIFO) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument))]
Missed result: None)]
-5.87user 0.03system 0:05.90elapsed 99%CPU (0avgtext+0avgdata 37920maxresident)k
-0inputs+0outputs (0major+4705minor)pagefaults 0swaps
+5.46user 0.02system 0:05.49elapsed 99%CPU (0avgtext+0avgdata 38568maxresident)k
+0inputs+0outputs (0major+4723minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/new/tests4.metta.answers b/examples/extended_compat/nars/new/tests4.metta.answers
index be6e5b06..b79d6be9 100644
--- a/examples/extended_compat/nars/new/tests4.metta.answers
+++ b/examples/extended_compat/nars/new/tests4.metta.answers
@@ -19,5 +19,5 @@
Expected: [(Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0)))]
Got: [(Error (match &attentional_focus (Concept (({ garfield }) --> artist) $Belief#93110 $BeliefEvent#93111 $CPrio#93112) $Belief#93110) match expects a space as the first argument), (Error (match &concepts (Concept (({ garfield }) --> artist) $Belief#93110 $BeliefEvent#93111 $CPrio#93112) $Belief#93110) match expects a space as the first argument)]
Missed result: (Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0))))]
-6.74user 0.05system 0:06.80elapsed 99%CPU (0avgtext+0avgdata 38296maxresident)k
-0inputs+0outputs (0major+4812minor)pagefaults 0swaps
+5.75user 0.03system 0:05.78elapsed 99%CPU (0avgtext+0avgdata 39036maxresident)k
+0inputs+0outputs (0major+4839minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/new/tests5.metta.answers b/examples/extended_compat/nars/new/tests5.metta.answers
index 3596d437..cbdb69ed 100644
--- a/examples/extended_compat/nars/new/tests5.metta.answers
+++ b/examples/extended_compat/nars/new/tests5.metta.answers
@@ -24,5 +24,5 @@
Expected: [(Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0)))]
Got: [(Error (match &attentional_focus (Concept (({ instance1 }) --> sheep) $Belief#93714 $BeliefEvent#93715 $CPrio#93716) $Belief#93714) match expects a space as the first argument), (Error (match &concepts (Concept (({ instance1 }) --> sheep) $Belief#93714 $BeliefEvent#93715 $CPrio#93716) $Belief#93714) match expects a space as the first argument)]
Missed result: (Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0))))]
-7.52user 0.05system 0:07.58elapsed 99%CPU (0avgtext+0avgdata 38128maxresident)k
-0inputs+0outputs (0major+4770minor)pagefaults 0swaps
+6.32user 0.01system 0:06.33elapsed 99%CPU (0avgtext+0avgdata 38904maxresident)k
+0inputs+0outputs (0major+4798minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/prev/tests0.metta.answers b/examples/extended_compat/nars/prev/tests0.metta.answers
index e69de29b..be36b71c 100644
--- a/examples/extended_compat/nars/prev/tests0.metta.answers
+++ b/examples/extended_compat/nars/prev/tests0.metta.answers
@@ -0,0 +1,14 @@
+[()]
+[()]
+[()]
+[()]
+[()]
+[()]
+[()]
+[()]
+[(Error (assertEqualToResult (|- ((A --> cat) (1.0 0.9)) ((B --> cat) (1.0 0.9))) (((B --> A) (1.0 0.44751381215469616)) (((A ~ B) --> cat) (0.0 0.81)) (((A | B) --> cat) (1.0 0.81)) ((B <-> A) (1.0 0.44751381215469616)) (((A & B) --> cat) (1.0 0.81))))
+Expected: [((B --> A) (1.0 0.44751381215469616)), (((A ~ B) --> cat) (0.0 0.81)), (((A | B) --> cat) (1.0 0.81)), ((B <-> A) (1.0 0.44751381215469616)), (((A & B) --> cat) (1.0 0.81))]
+Got: [((B <-> A) (1.0 0.44751381215469616)), ((B <-> A) (1.0 0.44751381215469616)), (((A & B) --> cat) (1.0 0.81)), (((A ~ B) --> cat) (0.0 0.81)), (((A | B) --> cat) (1.0 0.81)), ((B --> A) (1.0 0.44751381215469616))]
+Excessive result: ((B <-> A) (1.0 0.44751381215469616)))]
+0.57user 0.01system 0:00.58elapsed 100%CPU (0avgtext+0avgdata 36364maxresident)k
+0inputs+0outputs (0major+4277minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/prev/tests1.metta.answers b/examples/extended_compat/nars/prev/tests1.metta.answers
index e69de29b..96a8cdee 100644
--- a/examples/extended_compat/nars/prev/tests1.metta.answers
+++ b/examples/extended_compat/nars/prev/tests1.metta.answers
@@ -0,0 +1,13 @@
+[()]
+[()]
+[()]
+[()]
+[()]
+[()]
+[()]
+[(Error (assertEqual (TupleCount (get-atoms GroundingSpace-0x55cfe6b68a98)) 0)
+Expected: [0]
+Got: [(Error (TupleCount (get-atoms GroundingSpace-0x55cfe6b68a98)) NoValidAlternatives)]
+Missed result: 0)]
+0.20user 0.02system 0:00.22elapsed 100%CPU (0avgtext+0avgdata 35844maxresident)k
+0inputs+0outputs (0major+4180minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/prev/tests2.metta.answers b/examples/extended_compat/nars/prev/tests2.metta.answers
index e69de29b..2fe0a0ac 100644
--- a/examples/extended_compat/nars/prev/tests2.metta.answers
+++ b/examples/extended_compat/nars/prev/tests2.metta.answers
@@ -0,0 +1,18 @@
+[()]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[]
+[(Error (match &attentional_focus (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#101701 $BeliefEvent#101702 $CPrio#101703) $Belief#101701) match expects a space as the first argument), (Error (match &concepts (Concept ((ballleft &/ (^ $Op)) =/> ballhit) $Belief#101701 $BeliefEvent#101702 $CPrio#101703) $Belief#101701) match expects a space as the first argument)]
+11.43user 0.00system 0:11.44elapsed 99%CPU (0avgtext+0avgdata 37820maxresident)k
+0inputs+0outputs (0major+4570minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/prev/tests3.metta.answers b/examples/extended_compat/nars/prev/tests3.metta.answers
index e69de29b..b047f045 100644
--- a/examples/extended_compat/nars/prev/tests3.metta.answers
+++ b/examples/extended_compat/nars/prev/tests3.metta.answers
@@ -0,0 +1,11 @@
+[()]
+[]
+[]
+[]
+[]
+[(Error (assertEqual (AddGoalEvent (Outside (1.0 0.9))) None)
+Expected: [None]
+Got: [(BestDecision (Error (Error (Error (Error (Error (get-state ¤tTime) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) (Error (Error (Error (Error (Error (get-state &tempbest) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument) (Error (Error (Error (get-state &FIFO) get-state expects single state atom as an argument) get-state expects single state atom as an argument) get-state expects single state atom as an argument))]
+Missed result: None)]
+3.82user 0.03system 0:03.85elapsed 99%CPU (0avgtext+0avgdata 37908maxresident)k
+0inputs+0outputs (0major+4585minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/prev/tests4.metta.answers b/examples/extended_compat/nars/prev/tests4.metta.answers
index e69de29b..69db419f 100644
--- a/examples/extended_compat/nars/prev/tests4.metta.answers
+++ b/examples/extended_compat/nars/prev/tests4.metta.answers
@@ -0,0 +1,11 @@
+[()]
+[]
+[]
+[]
+[]
+[(Error (assertEqual (EternalQuestion (({ garfield }) --> artist)) (Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0))))
+Expected: [(Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0)))]
+Got: [(Error (match &attentional_focus (Concept (({ garfield }) --> artist) $Belief#34540 $BeliefEvent#34541 $CPrio#34542) $Belief#34540) match expects a space as the first argument), (Error (match &concepts (Concept (({ garfield }) --> artist) $Belief#34540 $BeliefEvent#34541 $CPrio#34542) $Belief#34540) match expects a space as the first argument)]
+Missed result: (Event ((({ garfield }) --> artist) (1.0 0.27508280575237937)) (eternal (4 3 2 1.0) (0 0.0))))]
+3.92user 0.01system 0:03.94elapsed 100%CPU (0avgtext+0avgdata 38524maxresident)k
+0inputs+0outputs (0major+4694minor)pagefaults 0swaps
diff --git a/examples/extended_compat/nars/prev/tests5.metta.answers b/examples/extended_compat/nars/prev/tests5.metta.answers
index e69de29b..aa5800a6 100644
--- a/examples/extended_compat/nars/prev/tests5.metta.answers
+++ b/examples/extended_compat/nars/prev/tests5.metta.answers
@@ -0,0 +1,12 @@
+[()]
+[]
+[]
+[]
+[]
+[]
+[(Error (assertEqual (EternalQuestion (({ instance1 }) --> sheep)) (Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0))))
+Expected: [(Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0)))]
+Got: [(Error (match &attentional_focus (Concept (({ instance1 }) --> sheep) $Belief#34693 $BeliefEvent#34694 $CPrio#34695) $Belief#34693) match expects a space as the first argument), (Error (match &concepts (Concept (({ instance1 }) --> sheep) $Belief#34693 $BeliefEvent#34694 $CPrio#34695) $Belief#34693) match expects a space as the first argument)]
+Missed result: (Event ((({ instance1 }) --> sheep) (1.0 0.30916030534351147)) (eternal (4 3) (0 0.0))))]
+4.14user 0.02system 0:04.17elapsed 99%CPU (0avgtext+0avgdata 38352maxresident)k
+0inputs+0outputs (0major+4648minor)pagefaults 0swaps
diff --git a/examples/features/send-more.metta b/examples/features/send-more.metta
index f189e00c..4000604a 100755
--- a/examples/features/send-more.metta
+++ b/examples/features/send-more.metta
@@ -43,4 +43,5 @@
!(solve)
+(: member (-> $e (List $e) NDet))
diff --git a/examples/performance/pathfinding-hard-f.metta.answers b/examples/performance/pathfinding-hard-f.metta.answers
index 5699ea89..e5fa9a80 100644
--- a/examples/performance/pathfinding-hard-f.metta.answers
+++ b/examples/performance/pathfinding-hard-f.metta.answers
@@ -1,5 +1,5 @@
-[]
+[()]
[(assertTrue True)]
[(assertFalse False)]
-0.10user 0.02system 0:00.12elapsed 100%CPU (0avgtext+0avgdata 28284maxresident)k
-0inputs+0outputs (0major+3278minor)pagefaults 0swaps
+0.13user 0.00system 0:00.14elapsed 100%CPU (0avgtext+0avgdata 33264maxresident)k
+0inputs+0outputs (0major+3476minor)pagefaults 0swaps
diff --git a/examples/performance/pathfinding-hard.metta.answers b/examples/performance/pathfinding-hard.metta.answers
index 2cdb7444..e69de29b 100644
--- a/examples/performance/pathfinding-hard.metta.answers
+++ b/examples/performance/pathfinding-hard.metta.answers
@@ -1,7 +0,0 @@
-[()]
-[(Error (assertEqual (path a f 11) True)
-Expected: [True]
-Got: [(path a f 11)]
-Missed result: True)]
-0.10user 0.01system 0:00.11elapsed 100%CPU (0avgtext+0avgdata 32960maxresident)k
-0inputs+0outputs (0major+3483minor)pagefaults 0swaps
diff --git a/examples/performance/state_types.metta.answers b/examples/performance/state_types.metta.answers
index 7c016839..ed202052 100644
--- a/examples/performance/state_types.metta.answers
+++ b/examples/performance/state_types.metta.answers
@@ -31,5 +31,5 @@
[("bind &right_7-first with &right_7")]
[()]
[(Error False BadType)]
-0.92user 0.00system 0:00.92elapsed 100%CPU (0avgtext+0avgdata 33000maxresident)k
-0inputs+0outputs (0major+3510minor)pagefaults 0swaps
+0.91user 0.01system 0:00.92elapsed 99%CPU (0avgtext+0avgdata 33268maxresident)k
+0inputs+0outputs (0major+3508minor)pagefaults 0swaps
diff --git a/examples/performance/test_infer_function_application_type.metta.answers b/examples/performance/test_infer_function_application_type.metta.answers
index 526562fb..e0c90fa7 100644
--- a/examples/performance/test_infer_function_application_type.metta.answers
+++ b/examples/performance/test_infer_function_application_type.metta.answers
@@ -2,5 +2,5 @@
Expected: [String]
Got: [(Error (if (: (apply reverse "Hello") $t) $t) IncorrectNumberOfArguments)]
Missed result: String)]
-0.08user 0.02system 0:00.11elapsed 99%CPU (0avgtext+0avgdata 33104maxresident)k
-0inputs+0outputs (0major+3497minor)pagefaults 0swaps
+0.10user 0.02system 0:00.12elapsed 100%CPU (0avgtext+0avgdata 33132maxresident)k
+0inputs+0outputs (0major+3490minor)pagefaults 0swaps
diff --git a/examples/performance/test_list_concatenation.metta.answers b/examples/performance/test_list_concatenation.metta.answers
index 2cbf0d3f..99b5302d 100644
--- a/examples/performance/test_list_concatenation.metta.answers
+++ b/examples/performance/test_list_concatenation.metta.answers
@@ -1,3 +1,3 @@
[()]
-0.10user 0.01system 0:00.12elapsed 100%CPU (0avgtext+0avgdata 33104maxresident)k
-0inputs+0outputs (0major+3493minor)pagefaults 0swaps
+0.10user 0.01system 0:00.12elapsed 100%CPU (0avgtext+0avgdata 33132maxresident)k
+0inputs+0outputs (0major+3485minor)pagefaults 0swaps
diff --git a/examples/python_compat/extend/example1.metta.answers b/examples/python_compat/extend/example1.metta.answers
index 19eb3891..a43367f7 100644
--- a/examples/python_compat/extend/example1.metta.answers
+++ b/examples/python_compat/extend/example1.metta.answers
@@ -1,3 +1,18 @@
-[(Error (extend-py! mettamorph) extend-py! not available in metta repl without Python support)]
-0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 6504maxresident)k
-0inputs+0outputs (0major+460minor)pagefaults 0swaps
+sh: 0: cannot open run_scheme.sh: No such file
+cat: ./../RUN.scm: No such file or directory
+[]
+[(Error (compile! compileme.metta) Exception caught:
+OSError: COMPILEME.so: cannot open shared object file: No such file or directory
+
+At:
+ /usr/lib/python3.11/ctypes/__init__.py(376): __init__
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(116): call_compilefile
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(18): wrapper
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(13): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
+ (18): run_step
+)]
+0.46user 0.09system 0:00.55elapsed 99%CPU (0avgtext+0avgdata 36560maxresident)k
+8inputs+608outputs (0major+19804minor)pagefaults 0swaps
diff --git a/examples/python_compat/extend/example2.metta.answers b/examples/python_compat/extend/example2.metta.answers
index 9b65833e..e057ede5 100644
--- a/examples/python_compat/extend/example2.metta.answers
+++ b/examples/python_compat/extend/example2.metta.answers
@@ -1,10 +1,23 @@
+sh: 0: cannot open run_scheme.sh: No such file
+cat: ./../RUN.scm: No such file or directory
[]
-[(compile! "
+[(Error (compile! "
(= (facF $n)
(If (== $n 0)
1
(* $n (facF (- $n 1)))))
-")]
-[(facF 10)]
-0.12user 0.01system 0:00.13elapsed 100%CPU (0avgtext+0avgdata 33476maxresident)k
-0inputs+0outputs (0major+3542minor)pagefaults 0swaps
+") Exception caught:
+OSError: TEMP.so: cannot open shared object file: No such file or directory
+
+At:
+ /usr/lib/python3.11/ctypes/__init__.py(376): __init__
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(116): call_compilefile
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(18): wrapper
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(13): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
+ (18): run_step
+)]
+0.47user 0.07system 0:00.55elapsed 100%CPU (0avgtext+0avgdata 36552maxresident)k
+0inputs+616outputs (0major+19193minor)pagefaults 0swaps
diff --git a/examples/python_compat/extend/example3.metta.answers b/examples/python_compat/extend/example3.metta.answers
index cb9c44f4..ddcd73f2 100644
--- a/examples/python_compat/extend/example3.metta.answers
+++ b/examples/python_compat/extend/example3.metta.answers
@@ -1,12 +1,22 @@
+sh: 0: cannot open run_scheme.sh: No such file
+cat: ./../RUN.scm: No such file or directory
[]
-[(compile! "
+[(Error (compile! "
(= (f1 $x) (+ 2 $x))
(= (use1 $f $arg)
($f $arg))
-")]
-[(+ 1 (use1 f2 40))]
-[(+ 1 (use1 f1 39))]
-[42]
-[(+ 1 (f1 39))]
-0.16user 0.00system 0:00.17elapsed 98%CPU (0avgtext+0avgdata 34040maxresident)k
-744inputs+0outputs (5major+3566minor)pagefaults 0swaps
+") Exception caught:
+OSError: TEMP.so: cannot open shared object file: No such file or directory
+
+At:
+ /usr/lib/python3.11/ctypes/__init__.py(376): __init__
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(116): call_compilefile
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(18): wrapper
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(13): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
+ (18): run_step
+)]
+0.53user 0.05system 0:00.58elapsed 100%CPU (0avgtext+0avgdata 36652maxresident)k
+0inputs+616outputs (0major+19209minor)pagefaults 0swaps
diff --git a/examples/python_compat/extend/example4.metta.answers b/examples/python_compat/extend/example4.metta.answers
index 649d17de..3c016b5e 100644
--- a/examples/python_compat/extend/example4.metta.answers
+++ b/examples/python_compat/extend/example4.metta.answers
@@ -1,14 +1,22 @@
+sh: 0: cannot open run_scheme.sh: No such file
+cat: ./../RUN.scm: No such file or directory
[]
-[(compile! "
+[(Error (compile! "
!(bind! &schemespace (new-space))
(= (add-atom-scheme $x) (add-atom &schemespace $x))
(= (get-atoms-scheme) (get-atoms &schemespace))
-")]
-[()]
-[()]
-[()]
-[(add-atom-scheme 44)]
-[(add-atom-scheme 45)]
-[42, 43, (get-atoms-scheme)]
-0.16user 0.00system 0:00.17elapsed 100%CPU (0avgtext+0avgdata 33420maxresident)k
-0inputs+0outputs (1major+3547minor)pagefaults 0swaps
+") Exception caught:
+OSError: TEMP.so: cannot open shared object file: No such file or directory
+
+At:
+ /usr/lib/python3.11/ctypes/__init__.py(376): __init__
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(116): call_compilefile
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(18): wrapper
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(13): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
+ (18): run_step
+)]
+0.47user 0.06system 0:00.53elapsed 100%CPU (0avgtext+0avgdata 36652maxresident)k
+8inputs+616outputs (1major+19193minor)pagefaults 0swaps
diff --git a/examples/python_compat/extend/example5.metta.answers b/examples/python_compat/extend/example5.metta.answers
index 8001f64b..8f4affae 100644
--- a/examples/python_compat/extend/example5.metta.answers
+++ b/examples/python_compat/extend/example5.metta.answers
@@ -1,14 +1,25 @@
+sh: 0: cannot open run_scheme.sh: No such file
+cat: ./../RUN.scm: No such file or directory
[]
-[(compile! "
+[(Error (compile! "
(= (Add $x Z) $x)
(= (Add $x (S $y)) (Add (S $x) $y))
(= (Sub) 2)
(= (Sub) 3)
(= (Mul) (superpose (4 5)))
-")]
-[(Add (S (S (S Z))) (S (S (S Z))))]
-[(Sub)]
-[(Mul)]
-0.13user 0.01system 0:00.15elapsed 100%CPU (0avgtext+0avgdata 33508maxresident)k
-0inputs+0outputs (0major+3543minor)pagefaults 0swaps
+") Exception caught:
+OSError: TEMP.so: cannot open shared object file: No such file or directory
+
+At:
+ /usr/lib/python3.11/ctypes/__init__.py(376): __init__
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(116): call_compilefile
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(18): wrapper
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(13): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
+ (18): run_step
+)]
+0.45user 0.07system 0:00.52elapsed 100%CPU (0avgtext+0avgdata 36568maxresident)k
+0inputs+616outputs (0major+18183minor)pagefaults 0swaps
diff --git a/examples/python_compat/extend/example6.metta.answers b/examples/python_compat/extend/example6.metta.answers
index f1c5b3bb..c074bb22 100644
--- a/examples/python_compat/extend/example6.metta.answers
+++ b/examples/python_compat/extend/example6.metta.answers
@@ -1,6 +1,18 @@
+sh: 0: cannot open run_scheme.sh: No such file
+cat: ./../RUN.scm: No such file or directory
[]
-[(compile! ((= (test1) 42) (: test2 (-> Number Number)) (= (test2 $x) 42)))]
-[(test1)]
-[(test2 33)]
-0.13user 0.00system 0:00.13elapsed 99%CPU (0avgtext+0avgdata 33276maxresident)k
-0inputs+0outputs (0major+3546minor)pagefaults 0swaps
+[(Error (compile! ((= (test1) 42) (: test2 (-> Number Number)) (= (test2 $x) 42))) Exception caught:
+OSError: TEMP.so: cannot open shared object file: No such file or directory
+
+At:
+ /usr/lib/python3.11/ctypes/__init__.py(376): __init__
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(116): call_compilefile
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(18): wrapper
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/extend/mettamorph.py(13): execute
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
+ (18): run_step
+)]
+0.49user 0.08system 0:00.68elapsed 85%CPU (0avgtext+0avgdata 36552maxresident)k
+66248inputs+616outputs (421major+18464minor)pagefaults 0swaps
diff --git a/examples/python_compat/hyperon-experimental_python/sandbox/das_gate/test_das.metta.answers b/examples/python_compat/hyperon-experimental_python/sandbox/das_gate/test_das.metta.answers
index e6003eb0..57cb792c 100644
--- a/examples/python_compat/hyperon-experimental_python/sandbox/das_gate/test_das.metta.answers
+++ b/examples/python_compat/hyperon-experimental_python/sandbox/das_gate/test_das.metta.answers
@@ -2,7 +2,7 @@
ModuleNotFoundError: No module named 'hyperon_das'
At:
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/compat/hyperon-experimental/python/sandbox/das_gate/dasgate.py(5):
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/hyperon-experimental_python/sandbox/das_gate/dasgate.py(5):
(241): _call_with_frames_removed
(940): exec_module
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(165): load_py_module_from_path
@@ -13,5 +13,5 @@ At:
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
(18): run_step
)]
-0.10user 0.01system 0:00.11elapsed 100%CPU (0avgtext+0avgdata 33588maxresident)k
-0inputs+16outputs (0major+3523minor)pagefaults 0swaps
+0.09user 0.01system 0:00.11elapsed 100%CPU (0avgtext+0avgdata 33464maxresident)k
+0inputs+0outputs (0major+3474minor)pagefaults 0swaps
diff --git a/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_assist.metta.answers b/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_assist.metta.answers
index d2e6f294..ddf39dca 100644
--- a/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_assist.metta.answers
+++ b/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_assist.metta.answers
@@ -1,18 +1,19 @@
-[(Error (extend-py! llm_gate) Exception caught:
-KeyError: 'OPENAI_API_KEY'
+[]
+[(Error (llm (Messages () (Messages (system "You are the SingularityNet AI platform and marketplace assistant")) (user "What is the SingularityNET platform?")) (Functions set_subgoal)) Exception caught:
+AuthenticationError: Incorrect API key provided: freeve. You can find your API key at https://platform.openai.com/account/api-keys.
At:
- (679): __getitem__
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/compat/hyperon-experimental/python/sandbox/neurospace/llm_gate.py(6):
- (241): _call_with_frames_removed
- (940): exec_module
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(165): load_py_module_from_path
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(154): load_py_module_from_mod_or_file
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(78):
+ /usr/local/lib/python3.11/dist-packages/openai/api_requestor.py(765): _interpret_response_line
+ /usr/local/lib/python3.11/dist-packages/openai/api_requestor.py(700): _interpret_response
+ /usr/local/lib/python3.11/dist-packages/openai/api_requestor.py(298): request
+ /usr/local/lib/python3.11/dist-packages/openai/api_resources/abstract/engine_api_resource.py(153): create
+ /usr/local/lib/python3.11/dist-packages/openai/api_resources/chat_completion.py(26): create
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/llm_gate.py(76): llm
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/llm_gate.py(95):
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
(18): run_step
)]
-0.36user 0.04system 0:00.52elapsed 78%CPU (0avgtext+0avgdata 67592maxresident)k
-43024inputs+16outputs (150major+9771minor)pagefaults 0swaps
+0.40user 0.05system 0:00.62elapsed 72%CPU (0avgtext+0avgdata 70652maxresident)k
+0inputs+0outputs (1major+10524minor)pagefaults 0swaps
diff --git a/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_nspace.metta.answers b/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_nspace.metta.answers
index f4efc64c..d8950316 100644
--- a/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_nspace.metta.answers
+++ b/examples/python_compat/hyperon-experimental_python/sandbox/neurospace/test_nspace.metta.answers
@@ -1,18 +1,67 @@
-[(Error (extend-py! neurospace) Exception caught:
-KeyError: 'OPENAI_API_KEY'
-
-At:
- (679): __getitem__
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/compat/hyperon-experimental/python/sandbox/neurospace/neurospace.py(6):
- (241): _call_with_frames_removed
- (940): exec_module
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(165): load_py_module_from_path
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(154): load_py_module_from_mod_or_file
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(78):
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
- (18): run_step
-)]
-0.31user 0.04system 0:00.36elapsed 99%CPU (0avgtext+0avgdata 67584maxresident)k
-0inputs+16outputs (0major+9867minor)pagefaults 0swaps
+thread 'main' panicked at src/metta_shim.rs:168:20:
+called `Result::unwrap()` on an `Err` value: PyErr { type: , value: AuthenticationError(message='Incorrect API key provided: freeve. You can find your API key at https://platform.openai.com/account/api-keys.', http_status=401, request_id=None), traceback: Some() }
+stack backtrace:
+ 0: 0x55c52e94ed3c - std::backtrace_rs::backtrace::libunwind::trace::h67a838aed1f4d6ec
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
+ 1: 0x55c52e94ed3c - std::backtrace_rs::backtrace::trace_unsynchronized::h1d1786bb1962baf8
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
+ 2: 0x55c52e94ed3c - std::sys_common::backtrace::_print_fmt::h5a0b1f807a002d23
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:67:5
+ 3: 0x55c52e94ed3c - ::fmt::hf84ab6ad0b91784c
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:44:22
+ 4: 0x55c52e97185c - core::fmt::rt::Argument::fmt::h28f463bd1fdabed5
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/fmt/rt.rs:138:9
+ 5: 0x55c52e97185c - core::fmt::write::ha37c23b175e921b3
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/fmt/mod.rs:1114:21
+ 6: 0x55c52e94beee - std::io::Write::write_fmt::haa1b000741bcbbe1
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/io/mod.rs:1763:15
+ 7: 0x55c52e94eb24 - std::sys_common::backtrace::_print::h1ff1030b04dfb157
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:47:5
+ 8: 0x55c52e94eb24 - std::sys_common::backtrace::print::hb982056c6f29541c
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:34:9
+ 9: 0x55c52e9500a3 - std::panicking::default_hook::{{closure}}::h11f92f82c62fbd68
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:272:22
+ 10: 0x55c52e94fdc4 - std::panicking::default_hook::hb8810fe276772c66
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:292:9
+ 11: 0x55c52e950625 - std::panicking::rust_panic_with_hook::hd2f0efd2fec86cb0
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:731:13
+ 12: 0x55c52e950521 - std::panicking::begin_panic_handler::{{closure}}::h3651b7fc4f61d784
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:609:13
+ 13: 0x55c52e94f266 - std::sys_common::backtrace::__rust_end_short_backtrace::hbc468e4b98c7ae04
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys_common/backtrace.rs:170:18
+ 14: 0x55c52e950272 - rust_begin_unwind
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
+ 15: 0x55c52e7a7545 - core::panicking::panic_fmt::h979245e2fdb2fabd
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
+ 16: 0x55c52e7a79e3 - core::result::unwrap_failed::h8c4b86241881fbbb
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/result.rs:1652:5
+ 17: 0x55c52e7b8318 - metta::metta_shim::metta_interface_mod::MettaShim::exec::he664f34e01237be7
+ 18: 0x55c52e7bd52c - metta::main::h4061cff84c875f01
+ 19: 0x55c52e7c4f93 - std::sys_common::backtrace::__rust_begin_short_backtrace::h9ba8fef5bf9c9a16
+ 20: 0x55c52e7ca36d - std::rt::lang_start::{{closure}}::h44f0433eb5c0c983
+ 21: 0x55c52e94665b - core::ops::function::impls:: for &F>::call_once::hf9057cfaeeb252e2
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:284:13
+ 22: 0x55c52e94665b - std::panicking::try::do_call::h629e203a624883e4
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
+ 23: 0x55c52e94665b - std::panicking::try::h7b61614724d6a4f1
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
+ 24: 0x55c52e94665b - std::panic::catch_unwind::h354ac1c0268491d8
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
+ 25: 0x55c52e94665b - std::rt::lang_start_internal::{{closure}}::h919fee3c5ba8f617
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/rt.rs:148:48
+ 26: 0x55c52e94665b - std::panicking::try::do_call::h54583f67455bff32
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
+ 27: 0x55c52e94665b - std::panicking::try::hb0e12c4e01d39dc2
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
+ 28: 0x55c52e94665b - std::panic::catch_unwind::h367b6339e3ca9a3b
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
+ 29: 0x55c52e94665b - std::rt::lang_start_internal::ha5ce8533eaa0fda8
+ at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/rt.rs:148:20
+ 30: 0x55c52e7bf8d5 - main
+ 31: 0x7f2c572f018a -
+ 32: 0x7f2c572f0245 - __libc_start_main
+ 33: 0x55c52e7a7ca1 - _start
+ 34: 0x0 -
+Command exited with non-zero status 101
+0.43user 0.04system 0:00.71elapsed 67%CPU (0avgtext+0avgdata 77332maxresident)k
+16248inputs+0outputs (82major+11083minor)pagefaults 0swaps
diff --git a/examples/python_compat/hyperon-experimental_python/sandbox/numpy/nm_test.metta.answers b/examples/python_compat/hyperon-experimental_python/sandbox/numpy/nm_test.metta.answers
index a69feca0..6cfe80bd 100644
--- a/examples/python_compat/hyperon-experimental_python/sandbox/numpy/nm_test.metta.answers
+++ b/examples/python_compat/hyperon-experimental_python/sandbox/numpy/nm_test.metta.answers
@@ -18,5 +18,5 @@
[8, 3]]), $x)]]
[[np.add, ($x#36, $y2#37)]]
["X"]
-0.40user 0.04system 0:00.44elapsed 99%CPU (0avgtext+0avgdata 52072maxresident)k
-680inputs+16outputs (5major+6217minor)pagefaults 0swaps
+0.39user 0.02system 0:00.43elapsed 97%CPU (0avgtext+0avgdata 52316maxresident)k
+3240inputs+0outputs (32major+6225minor)pagefaults 0swaps
diff --git a/examples/python_compat/hyperon-experimental_python/sandbox/resolve/r.metta.answers b/examples/python_compat/hyperon-experimental_python/sandbox/resolve/r.metta.answers
index 0b65a489..f238a94e 100644
--- a/examples/python_compat/hyperon-experimental_python/sandbox/resolve/r.metta.answers
+++ b/examples/python_compat/hyperon-experimental_python/sandbox/resolve/r.metta.answers
@@ -1,6 +1,6 @@
[]
[]
-[]
+[]
[resolve]
[120]
[content]
@@ -11,5 +11,5 @@
[]
[720]
[720]
-0.40user 0.00system 0:00.41elapsed 99%CPU (0avgtext+0avgdata 34548maxresident)k
-0inputs+16outputs (0major+3809minor)pagefaults 0swaps
+0.35user 0.02system 0:00.38elapsed 100%CPU (0avgtext+0avgdata 34384maxresident)k
+0inputs+0outputs (0major+3835minor)pagefaults 0swaps
diff --git a/examples/python_compat/hyperon-experimental_python/sandbox/sql_space/sql_space_test.metta.answers b/examples/python_compat/hyperon-experimental_python/sandbox/sql_space/sql_space_test.metta.answers
index 1290303c..d3a737da 100644
--- a/examples/python_compat/hyperon-experimental_python/sandbox/sql_space/sql_space_test.metta.answers
+++ b/examples/python_compat/hyperon-experimental_python/sandbox/sql_space/sql_space_test.metta.answers
@@ -1,20 +1,20 @@
[]
[()]
[]
-[GroundingSpace-0x55fb90f8d9f8]
+[GroundingSpace-0x5644bc8f9998]
[(Error (Error (new-sql-space musicbrainz_db localhost musicbrainz musicbrainz 5432) Exception caught:
-OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: password authentication failed for user "musicbrainz"
-connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: password authentication failed for user "musicbrainz"
+OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
+ Is the server running on that host and accepting TCP/IP connections?
At:
/usr/lib/python3/dist-packages/psycopg2/__init__.py(122): connect
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/compat/hyperon-experimental/python/sandbox/sql_space/sql_space.py(134): __init__
- /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/compat/hyperon-experimental/python/sandbox/sql_space/sql_space.py(230):
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/hyperon-experimental_python/sandbox/sql_space/sql_space.py(134): __init__
+ /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/examples/python_compat/hyperon-experimental_python/sandbox/sql_space/sql_space.py(230):
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(320): execute
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/atoms.py(167): _priv_call_execute_on_grounded_atom
/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/hyperon-experimental/python/hyperon/runner.py(31): run_step
(18): run_step
) BadType)]
-0.14user 0.03system 0:00.18elapsed 95%CPU (0avgtext+0avgdata 47052maxresident)k
-960inputs+32outputs (4major+4628minor)pagefaults 0swaps
+0.15user 0.01system 0:00.17elapsed 97%CPU (0avgtext+0avgdata 44772maxresident)k
+784inputs+0outputs (7major+4580minor)pagefaults 0swaps
diff --git a/metta_vspace/pyswip/flybase_induced_types.pl b/metta_vspace/pyswip/flybase_induced_types.pl
index 575041ab..667de526 100755
--- a/metta_vspace/pyswip/flybase_induced_types.pl
+++ b/metta_vspace/pyswip/flybase_induced_types.pl
@@ -1,4 +1,334 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+Finding Publications That Link Multiple Mutations
+SQL Version:
+
+SELECT P1.title AS Publication1, M1.name AS Mutation1, P2.title AS Publication2, M2.name AS Mutation2
+FROM Mutation AS M1
+INNER JOIN MutationPublication AS MP1 ON M1.id = MP1.mutation_id
+INNER JOIN Publication AS P1 ON MP1.publication_id = P1.id
+INNER JOIN MutationPublication AS MP2 ON M1.id != MP2.mutation_id
+INNER JOIN Mutation AS M2 ON MP2.mutation_id = M2.id
+INNER JOIN Publication AS P2 ON MP2.publication_id = P2.id AND P1.id = P2.id
+WHERE M1.name != M2.name
+*/
+
+
+
+linked_mutations(Publication1, Mutation1, Publication2, Mutation2) :-
+ mutation(M1_id, Mutation1),
+ mutation_publication(M1_id, MP1_id),
+ publication(MP1_id, Publication1),
+ mutation_publication(M2_id, MP2_id),
+ mutation(M2_id, Mutation2),
+ publication(MP2_id, Publication2),
+ M1_id \= M2_id,
+ Mutation1 \= Mutation2,
+ MP1_id = MP2_id.
+
+/*
+ Publications Discussing Mutations in Related Genes
+SQL Version:
+
+SELECT G1.name AS Gene1, M1.name AS Mutation1, G2.name AS Gene2, M2.name AS Mutation2, P.title
+FROM Gene AS G1
+INNER JOIN Mutation AS M1 ON G1.id = M1.gene_id
+INNER JOIN MutationPublication AS MP1 ON M1.id = MP1.mutation_id
+INNER JOIN Publication AS P ON MP1.publication_id = P.id
+INNER JOIN Mutation AS M2 ON P.id IN (SELECT publication_id FROM MutationPublication WHERE mutation_id = M2.id)
+INNER JOIN Gene AS G2 ON M2.gene_id = G2.id AND G1.id != G2.id
+WHERE G1.function = G2.function OR G1.pathway = G2.pathway
+*/
+
+
+
+related_genes_publication(Gene1, Mutation1, Gene2, Mutation2, Title) :-
+ gene(G1_id, Gene1, Function1, Pathway1),
+ mutation(M1_id, Mutation1),
+ mutation_gene(M1_id, G1_id),
+ mutation_publication(M1_id, MP1_id),
+ publication(MP1_id, Title),
+ gene(G2_id, Gene2, Function2, Pathway2),
+ mutation(M2_id, Mutation2),
+ mutation_gene(M2_id, G2_id),
+ mutation_publication(M2_id, MP2_id),
+ publication(MP2_id, Title),
+ G1_id \= G2_id,
+ (Function1 = Function2; Pathway1 = Pathway2).
+
+/*
+
+ Publications Linking Phenotypic Effects of Different Mutations
+SQL Version:
+
+SELECT M1.name AS Mutation1, P1.description AS Phenotype1, M2.name AS Mutation2, P2.description AS Phenotype2, Pub.title
+FROM Mutation AS M1
+INNER JOIN Phenotype AS P1 ON M1.phenotype_id = P1.id
+INNER JOIN MutationPublication AS MP1 ON M1.id = MP1.mutation_id
+INNER JOIN Publication AS Pub ON MP1.publication_id = Pub.id
+INNER JOIN MutationPublication AS MP2 ON Pub.id = MP2.publication_id AND MP1.mutation_id != MP2.mutation_id
+INNER JOIN Mutation AS M2 ON MP2.mutation_id = M2.id
+INNER JOIN Phenotype AS P2 ON M2.phenotype_id = P2.id
+*/
+
+
+
+linked_phenotypes(Publication, Mutation1, Phenotype1, Mutation2, Phenotype2) :-
+ mutation(M1_id, Mutation1),
+ mutation_phenotype(M1_id, P1_id),
+ phenotype(P1_id, Phenotype1),
+ mutation_publication(M1_id, MP1_id),
+ publication(MP1_id, Publication),
+ mutation_publication(M2_id, MP2_id),
+ mutation(M2_id, Mutation2),
+ mutation_phenotype(M2_id, P2_id),
+ phenotype(P2_id, Phenotype2),
+ publication(MP2_id, Publication),
+ M1_id \= M2_id.
+
+
+
+
+/*
+
+ Gene Expression and Phenotypes
+SQL Version:
+
+
+SELECT Gene.name, Expression.tissue, Phenotype.description
+FROM Gene
+INNER JOIN Expression ON Gene.id = Expression.gene_id
+INNER JOIN Phenotype ON Gene.id = Phenotype.gene_id
+WHERE Expression.tissue = 'wing disc' AND Phenotype.description LIKE '%wing defects%'
+*/
+
+
+
+gene_expression_phenotype(GeneName, Tissue, PhenotypeDescription) :-
+ gene(GeneId, GeneName),
+ expression(GeneId, Tissue),
+ Tissue = 'wing disc',
+ phenotype(GeneId, PhenotypeDescription),
+ sub_string(PhenotypeDescription, _, _, _, 'wing defects').
+
+/*
+ Protein-Protein Interactions
+SQL Version:
+
+SELECT Protein1.name, Protein2.name
+FROM Protein AS Protein1
+INNER JOIN Interaction ON Protein1.id = Interaction.protein1_id
+INNER JOIN Protein AS Protein2 ON Interaction.protein2_id = Protein2.id
+WHERE Protein1.name = 'protein_of_interest'
+*/
+
+
+
+protein_interaction(ProteinName1, ProteinName2) :-
+ protein(Protein1Id, ProteinName1),
+ ProteinName1 = 'protein_of_interest',
+ interaction(Protein1Id, Protein2Id),
+ protein(Protein2Id, ProteinName2).
+
+/*
+ Genetic Modifiers of a Mutation
+SQL Version:
+
+SELECT ModifierGene.name, Mutation.name, ModifiedPhenotype.description
+FROM Gene AS ModifierGene
+INNER JOIN GeneticInteraction ON ModifierGene.id = GeneticInteraction.modifier_gene_id
+INNER JOIN Mutation ON GeneticInteraction.mutation_id = Mutation.id
+INNER JOIN Phenotype AS ModifiedPhenotype ON Mutation.phenotype_id = ModifiedPhenotype.id
+WHERE Mutation.name = 'specific_mutation'
+*/
+
+
+
+genetic_modifier(ModifierGeneName, MutationName, PhenotypeDescription) :-
+ gene(ModifierGeneId, ModifierGeneName),
+ genetic_interaction(ModifierGeneId, MutationId),
+ mutation(MutationId, MutationName),
+ MutationName = 'specific_mutation',
+ phenotype(MutationId, PhenotypeDescription).
+
+/*
+4. Gene Ontology (GO) Annotations
+SQL Version:
+
+SELECT Gene.name, GOAnnotation.GO_term, GOAnnotation.description
+FROM Gene
+INNER JOIN GOAnnotation ON Gene.id = GOAnnotation.gene_id
+WHERE Gene.name IN ('gene1', 'gene2', 'gene3')
+*/
+
+
+
+gene_go_annotation(GeneName, GOTerm, GODescription) :-
+ gene(GeneId, GeneName),
+ member(GeneName, ['gene1', 'gene2', 'gene3']),
+ go_annotation(GeneId, GOTerm, GODescription).
+
+
+/*
+
+SELECT Strain.name, StockCenter.name, StockCenter.location
+FROM Strain
+INNER JOIN StockCenter ON Strain.stock_center_id = StockCenter.id
+WHERE Strain.name LIKE '%desired_trait%'
+ChatGPT
+Translating these SQL queries to Prolog predicates involves creating a set of Prolog facts and rules that mimic the structure and logic of the SQL database and queries. Here's how each of these queries can be represented in Prolog:
+
+ Gene Alleles and Associated Diseases
+
+SELECT Gene.name, Allele.name, Disease.human_disease
+FROM Gene
+INNER JOIN Allele ON Gene.id = Allele.gene_id
+LEFT JOIN Disease ON Allele.disease_id = Disease.id
+WHERE Gene.name = 'target_gene_name'
+*/
+
+
+
+gene_allele_disease(GeneName, AlleleName, HumanDisease) :-
+ gene(GeneId, GeneName),
+ GeneName = 'target_gene_name',
+ allele(GeneId, AlleleId, AlleleName),
+ ( disease(AlleleId, HumanDisease)
+ ; HumanDisease = 'No associated disease').
+
+/*
+
+ Transcription Factors Regulating a Gene
+SQL Version:
+SELECT TranscriptionFactor.name, TargetGene.name, Regulation.type
+FROM Gene AS TranscriptionFactor
+INNER JOIN GeneRegulation AS Regulation ON TranscriptionFactor.id = Regulation.transcription_factor_id
+INNER JOIN Gene AS TargetGene ON Regulation.target_gene_id = TargetGene.id
+WHERE TargetGene.name = 'specific_target_gene'
+*/
+
+
+
+transcription_factor_regulation(TranscriptionFactorName, TargetGeneName, RegulationType) :-
+ gene(TranscriptionFactorId, TranscriptionFactorName),
+ gene_regulation(TranscriptionFactorId, TargetGeneId, RegulationType),
+ gene(TargetGeneId, TargetGeneName),
+ TargetGeneName = 'specific_target_gene'.
+
+/*
+
+ Publications Related to a Gene Mutation
+SQL Version:
+
+SELECT Mutation.name, Publication.title, Publication.authors
+FROM Mutation
+INNER JOIN MutationPublication ON Mutation.id = MutationPublication.mutation_id
+INNER JOIN Publication ON MutationPublication.publication_id = Publication.id
+WHERE Mutation.name = 'specific_mutation_name'
+*/
+
+
+
+mutation_publication_info(MutationName, Title, Authors) :-
+ mutation(MutationId, MutationName),
+ MutationName = 'specific_mutation_name',
+ mutation_publication(MutationId, PublicationId),
+ publication(PublicationId, Title, Authors).
+
+/*
+
+4. RNAi Knockdown Effects on Phenotype
+SQL Version:
+
+SELECT Gene.name, RNAiExperiment.description, Phenotype.description
+FROM Gene
+INNER JOIN RNAiExperiment ON Gene.id = RNAiExperiment.gene_id
+INNER JOIN Phenotype ON RNAiExperiment.phenotype_id = Phenotype.id
+WHERE Gene.name = 'gene_of_interest'
+*/
+
+
+
+rnai_knockdown_phenotype(GeneName, RNAiDescription, PhenotypeDescription) :-
+ gene(GeneId, GeneName),
+ GeneName = 'gene_of_interest',
+ rnai_experiment(GeneId, RNAiId, RNAiDescription),
+ phenotype(RNAiId, PhenotypeDescription).
+
+
+
+/*
+5. Stock Center Information for Specific Strains
+
+SELECT Strain.name, StockCenter.name, StockCenter.location
+FROM Strain
+INNER JOIN StockCenter ON Strain.stock_center_id = StockCenter.id
+WHERE Strain.name LIKE '%desired_trait%'
+*/
+stock_center_info(StrainName, StockCenterName, Location) :-
+ strain(StrainId, StrainName),
+ sub_string(StrainName, _, _, _, 'desired_trait'),
+ stock_center(StrainId, StockCenterId, StockCenterName, Location).
+
+
+
+
+
+
+
flybase_tables([
analysis, analysisfeature, analysisgrp, analysisgrpmember, analysisprop, audit_chado, cell_line, cell_line_loaderm, cell_line_loadermprop,
cell_line_dbxref, cell_line_feature, cell_line_library, cell_line_libraryprop, cell_line_pub, cell_line_relationship, cell_line_strain,
diff --git a/metta_vspace/pyswip/flybase_main.pl b/metta_vspace/pyswip/flybase_main.pl
index 224dc952..b4fa2871 100755
--- a/metta_vspace/pyswip/flybase_main.pl
+++ b/metta_vspace/pyswip/flybase_main.pl
@@ -12,10 +12,14 @@
% ==============
% OBO LOADER
% ==============
-:- set_option_value(encoding,iso_latin_1).
+:- set_option_value(encoding,utf8).
:- ensure_loaded(flybase_obo).
+:- ensure_loaded(metta_interp).
+
+save_to_pl:- tell(all_data),forall(fb_pred(F,A),listing(F/A)),told.
+
% ==============
% VSPACE LOADER
% ==============
@@ -70,277 +74,14 @@
symbol_prefix('CHEBI', obo, 'Chemical Entities of Biological Interest').
-%./KBs/SUMO-OBO/gene-merged-SUMO.kif
-%
-%FBbt_00051628
-
-concept_type(Arg,Type):-
- fb_arg(Arg),
- fb_arg_table_n(Arg,Fn,N),
- table_n_type(Fn,N,Type).
-
-good_concept(E1):- var(E1),!,table_columns(F1,P1),nth1(N1,P1,E2),(E1=E2;E1=nth(N1,F1)).
-good_concept(E1):- symbol(E1),!, is_good_symbol_name(E1).
-good_concept(E1):- number(E1),!, E1>300.
-good_concept(listOf(E1,_)):- good_concept(E1),symbol(E1).
-good_concept(listOf(E1)):- good_concept(E1),symbol(E1).
-
-%:- abolish(maybe_corisponds/2).
-:- dynamic(maybe_corisponds/2).
-
-
-is_good_symbol_name(E1):- symbol(E1), symbol_length(E1,L),L>=2, \+ symbol_number(E1,_).
-
-fb_pred_g(F,A):-fb_pred(F,A), \+ skipped_anotations(F).
-
-mine_corisponds(Concept1,Corispondance):-
- fb_arg_table_n(Concept1,Fn1,Nth1),is_good_symbol_name(Concept1),
- fb_arg_table_n(Concept1,Fn2,Nth2),
- (Fn1+Nth1)@>(Fn2+Nth2),
- tables_can_join(Fn1,Fn2),
- once((table_colnum_type(Fn1,Nth1,Type1),nonvar(Type1),
- table_colnum_type(Fn2,Nth2,Type2),nonvar(Type2))),
- (maybe_corisponds('ConceptMapFn'(Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Type2,Nth2,Fn2/*Arity2*/))
- = Corispondance).
-
-mine_overlaps:-
- retractall(maybe_corisponds(_,_)),
- time(once(mine_overlaps1)),
- skip(mine_overlaps2).
-
-mine_overlaps1:-
- for_all(mine_corisponds(Concept1,How), assert_progress(mine_overlaps1(Concept1),How)).
-
-mine_overlaps2_slow:-
- % for_all(mine_typelevel_overlaps,true),
- for_all(mine_symbolspace_overlaps,true).
-
-mine_typelevel_overlaps:-
- for_all(mine_typelevel_overlaps(Concept1,SC1,SC2),
- assert_progress(mine_typelevel_overlaps(Concept1),maybe_corisponds(SC1,SC2))).
-
-tables_can_join(Fn1,Fn2):- Fn1@>Fn2, can_join_using(Fn1),can_join_using(Fn2).
-
-can_join_using(V):- var(V),!.
-can_join_using(fbgn_exons2affy1_overlaps):- !, fail.
-can_join_using(fbgn_exons2affy2_overlaps):- !, fail.
-can_join_using(_).
-
-mine_typelevel_overlaps(Concept1,'ConceptMapFn'(Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Type2,Nth2,Fn2/*Arity2*/)):-
-
- %fail, % Skip over simple type named things
-
- Type1=Concept1,Type2=Concept1,
- table_columns(Fn1,Atom1), table_columns(Fn2,Atom2),
- fb_pred_g(Fn1,Arity1), fb_pred_g(Fn2,Arity2),
- Fn1@>Fn2, nth1(Nth1,Atom1,Concept1),
- good_concept(Concept1),
- once((nth1(Nth2,Atom2,Concept1),length(Atom1,Arity1),length(Atom2,Arity2))).
-
-mine_symbolspace_overlaps:-
- fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2),
- once((functor(Atom1,Fn1,Arity1),functor(Atom2,Fn2,Arity2),
- tables_can_join(Fn1,Fn2),
- call(Atom1), arg(Nth1,Atom1,Concept1),good_concept(Concept1), arg(Nth2,Atom2,Concept1),call(Atom2))),
- once((
- table_colnum_type(Fn1,Nth1,Type1),nonvar(Type1),
- table_colnum_type(Fn2,Nth2,Type2),nonvar(Type1))),
- assert_progress(Concept1,maybe_corisponds('ConceptMapFn'(Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Type2,Nth2,Fn2/*Arity2*/))).
-
-mine_unif_overlap:-
- forall((fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2),
- once((functor(Atom1,Fn1,Arity1),functor(Atom2,Fn2,Arity2),
- arg(Nth1,Atom1,Concept1), arg(Nth2,Atom2,Concept1),
- call(Atom1),call(Atom2),
- interesting_to_unify(Concept1)))),
-
- assert_progress(Concept1,maybe_corisponds('ConceptMapFn'(Nth1,Fn1/*Arity1*/),'ConceptMapFn'(Nth2,Fn2/*Arity2*/)))).
-
-interesting_to_unify(Concept1):- string(Concept1),!,symbol_length(Concept1,L),L>3.
-interesting_to_unify(Concept1):- good_concept(Concept1).
-interesting_to_unify(Number):- number(Number),Number>1000.
-
-
-fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2):-
!,
- fb_pred_g(Fn1,Arity1), fb_pred_g(Fn2,Arity2),
- tables_can_join(Fn1,Fn2),
- between(1,Arity1,Nth1),Nth1<20,between(1,Arity2,Nth2),Nth2<20,
- (Fn1==Fn2-> (Nth1>Nth2); true).
-
-fb_two_preds(Fn1,Nth1,Arity1,Fn2,Nth2,Arity2):-
- fb_pred_g(Fn1,Arity1), fb_pred_g(Fn2,Arity2),Fn1@>Fn2,
- mine_typelevel_overlaps(_,'ConceptMapFn'(_Type1,Nth1,Fn1/*Arity1*/),'ConceptMapFn'(_Type2,Nth2,Fn2/*Arity2*/)).
-
-table_colnum_type(Fn,Nth,Type):- table_n_type(Fn,Nth,TypeC,TypeB),(nonvar(TypeB)->Type=TypeB;Type=TypeC).
-
-synth_conj(QV,(Atom1),(Atom2)):-
- maybe_corisponds('ConceptMapFn'(Type1,Nth1,Fn1),'ConceptMapFn'(Type2,Nth2,Fn2)),
- make_symbol(Fn1,Nth1,Atom1,Arg1),
- make_symbol(Fn2,Nth2,Atom2,Arg2),
- Fn1\=@=Fn2,
- skip(Type1),skip(Type2),
- Arg1=Arg2,QV=Arg1.
-
-synth_query(Len,Query):- synth_query(_,Len,Query).
-
-synth_query(_,1,[Atom]):- !, make_symbol(Atom).
-synth_query(QV,N,[Q1,Q2|Query]):-
- M is N -1,
- synth_conj(QV,Q1,Q2),
- (M>1 -> dif(QV,QV2) ; true),
- synth_query(QV2,M,[Q2|Query]),
- all_dif_functors([Q1,Q2|Query]).
-
-all_dif_functors(List):- \+ (select(Q1,List,Rest),member(Q2,Rest),functor(Q1,F1,_),functor(Q2,F2,_), F1==F2, \+ (ok_if_dupped(F1))).
-
-make_symbol(Atom):- fb_pred_g(F,A),functor(Atom,F,A).
-make_symbol(Fn,Nth,Atom,Arg):- fb_pred_g(Fn,Arity),functor(Atom,Fn,Arity),arg(Nth,Atom,Arg).
-
-ok_if_dupped(best_gene_summary).
-
-try_overlaps:- try_overlaps(5).
-
-try_overlaps(N):-
- synth_query(N,Query),
- \+ \+ (call_match(Query),
- pp_fb(grounded=Query),
- ignore(maybe_english(Query))),nl,nl,
- AQ = [and|Query],
- pp_fb('!'(match('&flybase',AQ,AQ))),nl,nl,nl.
-
-no_english(fbrf_pmid_pmcid_doi,_).
-no_english(physical_interactions_mitab,8).
-
-maybe_english(Query):-
- extract_concepts(Query,Concepts),!,
- ignore((maybe_english(Query,Concepts))),!.
-
-maybe_english(_Query,Concepts):- select(C,Concepts,Rest),is_englishy(C),member(C2,Rest),is_englishy(C2),!, pp_fb(english=[C,C2]).
-maybe_english(_Query,Concepts):- pp_fb(concepts=Concepts), maplist(some_english,Concepts).
-
-is_englishy(C):- \+ symbol(C), \+ string(C), !, fail.
-is_englishy(C):- split_string(C, ". ", " ", [_,_,_|_]).
-is_englishy(C):- symbol_contains(C,". ").
-
-some_english(Term):-
- ignore((fb_arg_table_n(C,Fn1,Nth1), \+ no_english(Fn1,Nth1),is_englishy(C),
- make_symbol(Fn1,Nth1,Atom,English),
- arg(Nth2,Atom,Term),Nth2\==Nth1,
- call(Atom),English\=='',!,
- pp_fb(Term=English))).
-
-extract_concepts(Query,Concepts):-
- findall(C,(sub_term(C,Query),symbolic(C),good_concept(C)),L),
- predsort(longest_first,L,Concepts).
-
-longest_first(R,A,B):- into_len(A,L1),into_len(B,L2),compare(R,L2,L1).
-into_len(A,0):- var(A),!.
-into_len(A,L):- \+ string(A), !, sformat(S,"~w",[A]),into_len(S,L).
-into_len(A,0+A):- symbol_contains(A," ").
-into_len(A,L+A):- symbol_length(A,L1), (L1 == 11 -> L = 0 ; L is - L1).
-
-assert_progress(Concept,Atom):- Atom=..[OP,A1,A2], A1@>A2,!,AtomSwp=..[OP,A2,A1],!,assert_progress(Concept,AtomSwp).
-assert_progress(Concept,Atom):- call(Atom),!,pp_fb(already(Concept)=Atom).
-assert_progress(Concept,Atom):- pp_fb(assert_progress(Concept)=Atom),assert(Atom).
-
-
-
-loaded_from_file_count(X):- flag(loaded_from_file_count,X,X).
-incr_file_count(X):- flag(loaded_from_file_count,X,X+1), flag(total_loaded_symbols,TA,TA+1).
-
-should_cache:- loaded_from_file_count(X), option_else(max_disk_cache,Num,1000), X==Y.
-should_fix_args :- fail, \+ should_sample.
-should_sample :- should_show_data(_),!.
-should_sample :-
- once(option_value(samples_per_million,Fifty);Fifty=50), loaded_from_file_count(X), Y is X mod 1_000_000,!, Y >= 0, Y =< Fifty,!.
-should_show_data(X):- loaded_from_file_count(X),
- once((X=<13,X>=10); (X>0,(0 is X rem 1_000_000))),
- format(user_error,'~N',[]),
- format(user_output,'~N',[]),!,
- heartbeat.
-should_show_data(X):- nb_current(loading_file,F),F\==[],symbol_concat(_,'.obo',F),
- loaded_from_file_count(X),Y is X mod 100_000, Y=<15,Y>=10.
-
-
-
-% Convert a function and its arguments into a compound term
-into_datum(Fn, [D|DataL], Data):-
- (option_value(pred_va, true) -> Data =.. [Fn,D,DataL]; Data =.. [Fn,D|DataL]).
-
-% Create a new assertion from old data
-make_assertion4(Fn, Cols, NewData, OldData):-
- into_datum(Fn, Cols, OldData),
- OldData =.. [Fn|Args],
- % skip(if_t(var(ArgTypes), must_det_ll_r((once((length(Args,Len),length(ArgTypes,Len),once((table_columns(Fn,ArgTypes);table_columns(F,ArgTypes))))))))),
- maybe_fix_args(Fn, Args, NewArgs),
- maybe_sample(Fn, NewArgs),
- NewData =.. [Fn|NewArgs], !.
-
-maybe_fix_args( Fn,Args,NewArgs):- do_fix_fast_args( Fn,1,Args,NewArgs),!.
-maybe_fix_args( Fn,Args,NewArgs):- should_fix_args,
- nb_current(fb_argtypes,ArgTypes), fix_list_args(Fn,ArgTypes,Args,NewArgs),!.
-maybe_fix_args(_Fn,Args,Args).
-
-do_fix_fast_args( Fn,Nth,[A|Args],[New|NewArgs]):- maybe_fix_columns_nth(Fn,Nth,A,New),
- Nth2 is Nth+1, !, do_fix_fast_args( Fn,Nth2,Args,NewArgs).
-do_fix_fast_args(_,_,A,A).
-
-maybe_fix_columns_nth(Fn,Nth,A,New):- fix_columns_nth(Fn,Nth), fix_concept(A,New),!.
-maybe_fix_columns_nth(_,_,A,A).
-
-
-cleanup_arities:- for_all((fb_pred(F,2),fb_pred(F,N),N>2),retract(fb_pred(F,2))).
-
-
-
-
-:- discontiguous column_names_ext/2.
-:- discontiguous primary_column/2.
-
-must_det_ll_r((G1,G2)):- !, once(G1),must_det_ll_r(G2).
-must_det_ll_r(G):- call(G).
-
-% Safely executes the given Goal and prints any exception raised.
-% Usage: safe(+Goal, +Info).
-safe(Goal, Info) :-
- % Try to call Goal. If an exception is raised, unify Exception with the exception.
- catch(Goal, Exception,
- % If an exception is raised, portray the clause (Info :- Goal)
- % along with the exception, then rethrow the exception.
- (catch_ignore(portray_clause(exception:Exception:(Info:- Goal))), throw(Exception))
- ).
-% Safely executes the given Goal and prints any exception raised.
-% Usage: safe(+Goal).
-safe(Goal) :- safe(Goal,safe/1).
-
-
-skipped_anotations(fbgn_exons2affy1_overlaps).
-skipped_anotations(gene_rpkm_matrix).
-skipped_anotations(dmel_gene_sequence_ontology_annotations).
-skipped_anotations(fbgn_annotation_ID).
-
-gc_now:- set_option_value(gc,true), garbage_collect,garbage_collect_atoms,garbage_collect_clauses.
-
-extreme_debug(_).
-
-numbervars_w_singles(P):- term_singletons(P, Vars),
- numbervars(Vars,260,_,[attvar(bind),singletons(false)]),
- numbervars(P,14,_,[attvar(bind),singletons(true)]).
-
-
-
-pp_fb(P):- format("~N "), \+ \+ (numbervars_w_singles(P), pp_fb1(P)),flush_output.
-pp_fb1(P):- write_src(P),!,nl.
-:- if(current_predicate(pp_ilp/1)).
-pp_fb1(P):- pp_as(P),!,format("~N"),pp_ilp(P),!.
-:- endif.
-pp_fb1(P):- pp_as(P),!.
-pp_fb1(P):- print(P),!,nl.
-pp_fb1(P):- fbdebug1(P),!,nl.
-
-
+%:- abolish(gp_information/0).
+:- forall(retract(fb_pred(F,0)),abolish(F/0)).
+:- include(flybase_learn).
+%fbd(X,P):- fb_pred(F,A),functor(P,F,A),arg(_,P,X), no_repeats(P,call(P)).
+fbdead:- fb_pred(F,A),functor(P,F,A),arg(_,P,xxxxxxxxxxxxxxxxx),no_repeats(P,call(P)),
+ writeln(fbdead=P),fail.
+fbdead.
:- use_module(library(csv)).
@@ -380,10 +121,12 @@
% Convert flybase data from CSV to Prolog format.
load_flybase:- is_scryer,!,load_flybase_files.
-load_flybase:- make,recount_total_loaded_symbols,!,load_flybase_files,!,cleanup_arities,!,fb_stats.
+load_flybase:-
+ with_option(mettafiles,false,
+ (make,recount_total_loaded_symbols,!,load_flybase_files,!,cleanup_arities,!,fb_stats)).
load_flybase_dirs:-
- load_flybase('./data/ftp.flybase.net/releases/current/das_precomputed'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*'),
+ load_flybase('./data/ftp.flybase.net/releases/current/das_precomputed/*'),
+ load_flybase('./precomputed_files/*'),
load_flybase('./data/ftp.flybase.net/releases/current/./*sv'),!.
@@ -392,17 +135,17 @@
declare -a StringArray=(\
"fbgn_fbtr_fbpp_expanded_*.tsv.gz" \
-"physical_interactions_mitab_fb_*.tsv.gz" \
-"dmel_gene_sequence_ontology_annotations_fb_*.tsv.gz" \
+"physical_interactions_mitab*.tsv.gz" \
+"dmel_gene_sequence_ontology_annotations*.tsv.gz" \
"gene_map_table_*.tsv.gz" \
"ncRNA_genes_fb_*.json.gz" \
"gene_association.fb.gz" \
"gene_genetic_interactions_*.tsv.gz" \
"allele_genetic_interactions_*.tsv.gz" \
"allele_phenotypic_data_*.tsv.gz" \
-"disease_model_annotations_fb_*.tsv.gz" \
-"dmel_human_orthologs_disease_fb_*.tsv.gz" \
-"fbrf_pmid_pmcid_doi_fb_*.tsv.gz")
+"disease_model_annotations*.tsv.gz" \
+"dmel_human_orthologs_disease*.tsv.gz" \
+"fbrf_pmid_pmcid_doi*.tsv.gz")
*/
load_flybase_files:-
@@ -412,23 +155,23 @@
load_flybase_das_11:-
- % DAS's 11 tsv and 1 json file
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/fbgn_fbtr_fbpp_expanded_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/physical_interactions_mitab_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/dmel_gene_sequence_ontology_annotations_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/gene_map_table_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/ncRNA_genes_fb_*.json'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/gene_association_*.fb',tsv),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/gene_genetic_interactions_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/allele_genetic_interactions_fb_*.tsv'),
+ % DAS''s 11 tsv and 1 json file
+ load_flybase('./precomputed_files/*/ncRNA_genes_fb_*.json'),
+ load_flybase('./precomputed_files/*/fbgn_fbtr_fbpp_expanded*.tsv'),
+ load_flybase('./precomputed_files/*/physical_interactions_mitab*.tsv'),
+ load_flybase('./precomputed_files/*/dmel_gene_sequence_ontology_annotations*.tsv'),
+ load_flybase('./precomputed_files/*/gene_map_table*.tsv'),
+ load_flybase('./precomputed_files/*/gene_association_*.fb',tsv),
+ load_flybase('./precomputed_files/*/gene_genetic_interactions*.tsv'),
+ load_flybase('./precomputed_files/*/allele_genetic_interactions*.tsv'),
% Note: this file replaces 'allele_phenotypic_data_*.tsv' from FB2023_01 onward.
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/alleles/genotype_phenotype_data_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/allele_phenotypic_data_fb_*.tsv'),
+ load_flybase('./precomputed_files/alleles/genotype_phenotype_data*.tsv'),
+ load_flybase('./precomputed_files/*/allele_phenotypic_data*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/disease_model_annotations_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/dmel_human_orthologs_disease_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/fbrf_pmid_pmcid_doi_fb_*.tsv'),
+ load_flybase('./precomputed_files/*/disease_model_annotations*.tsv'),
+ load_flybase('./precomputed_files/*/dmel_human_orthologs_disease*.tsv'),
+ load_flybase('./precomputed_files/*/fbrf_pmid_pmcid_doi*.tsv'),
format("~n================================================================================================="),
format("~n=====================================Das Checkpoint=============================================="),
format("~n================================================================================================="),
@@ -439,45 +182,47 @@
!.
load_flybase_files_ftp:-
+ maplist(must_det_ll,[
+ load_flybase('./precomputed_files/collaborators/pmid_fbgn_uniprot*.tsv'),
%% load_flybase_obo_files,
load_flybase_das_11,
% 36 more that DAS doesnt load
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/alleles/fbal_to_fbgn_fb_*.tsv'),
-
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/clones/cDNA_clone_data_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/clones/genomic_clone_data_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/collaborators/fbgn_uniprot_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/collaborators/gp_information.fb'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/collaborators/pmid_fbgn_uniprot_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/automated_gene_summaries.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/automated_gene_summaries_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/best_gene_summary_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/Dmel_enzyme_data_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/dmel_unique_protein_isoforms_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/fbgn_annotation_ID_fb_*.tsv'),
- with_option([pred_va=true],load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/fbgn_exons2affy1_overlaps.tsv')),
- with_option([pred_va=true],load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/fbgn_exons2affy2_overlaps.tsv')),
- with_option([pred_va=false],load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/fbgn_fbtr_fbpp_fb_*.tsv')),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/fbgn_gleanr_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/fbgn_NAseq_Uniprot_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/gene_functional_complementation_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/gene_group_data_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/gene_groups_HGNC_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/gene_rpkm_matrix_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/gene_rpkm_report_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/gene_snapshots_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/pathway_group_data_fb_*.tsv'),
- %load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/insertions/construct_maps.zip'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/insertions/fu_gal4_table_fb_*.json'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/insertions/insertion_mapping_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/map_conversion/cyto-genetic-seq.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/metadata/dataset_metadata_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/orthologs/dmel_paralogs_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/references/entity_publication_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/species/organism_list_fb_*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/stocks/stocks_FB*.tsv'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/synonyms/fb_synonym_fb_*.tsv'),
+
+
+ load_flybase('./precomputed_files/alleles/fbal_to_fbgn*.tsv'),
+
+ load_flybase('./precomputed_files/clones/cDNA_clone_data*.tsv'),
+ load_flybase('./precomputed_files/clones/genomic_clone_data*.tsv'),
+ load_flybase('./precomputed_files/collaborators/fbgn_uniprot*.tsv'),
+ load_flybase('./precomputed_files/collaborators/gp_information*.fb'),
+ load_flybase('./precomputed_files/genes/automated_gene_summaries*.tsv'),
+ load_flybase('./precomputed_files/genes/best_gene_summary*.tsv'),
+ load_flybase('./precomputed_files/genes/Dmel_enzyme_data*.tsv'),
+ load_flybase('./precomputed_files/genes/dmel_unique_protein_isoforms*.tsv'),
+ load_flybase('./precomputed_files/genes/fbgn_annotation_ID*.tsv'),
+ with_option([pred_va='True'],load_flybase('./precomputed_files/genes/fbgn_exons2affy1_overlaps*.tsv')),
+ with_option([pred_va='True'],load_flybase('./precomputed_files/genes/fbgn_exons2affy2_overlaps*.tsv')),
+ with_option([pred_va=false],load_flybase('./precomputed_files/genes/fbgn_fbtr_fbpp*.tsv')),
+ load_flybase('./precomputed_files/genes/fbgn_gleanr*.tsv'),
+ load_flybase('./precomputed_files/genes/fbgn_NAseq_Uniprot*.tsv'),
+ load_flybase('./precomputed_files/genes/gene_functional_complementation*.tsv'),
+ load_flybase('./precomputed_files/genes/gene_group_data*.tsv'),
+ load_flybase('./precomputed_files/genes/gene_groups_HGNC*.tsv'),
+ load_flybase('./precomputed_files/genes/gene_rpkm_matrix*.tsv'),
+ load_flybase('./precomputed_files/genes/gene_rpkm_report*.tsv'),
+ load_flybase('./precomputed_files/genes/gene_snapshots*.tsv'),
+ load_flybase('./precomputed_files/genes/pathway_group_data*.tsv'),
+ %load_flybase('./precomputed_files/insertions/construct_maps.zip'),
+ load_flybase('./precomputed_files/insertions/fu_gal4_table_fb_*.json'),
+ load_flybase('./precomputed_files/insertions/insertion_mapping*.tsv'),
+ load_flybase('./precomputed_files/map_conversion/cyto-genetic-seq*.tsv'),
+ load_flybase('./precomputed_files/metadata/dataset_metadata*.tsv'),
+ load_flybase('./precomputed_files/orthologs/dmel_paralogs*.tsv'),
+ load_flybase('./precomputed_files/references/entity_publication*.tsv'),
+ load_flybase('./precomputed_files/species/organism_list*.tsv'),
+ load_flybase('./precomputed_files/stocks/stocks_FB*.tsv'),
+ load_flybase('./precomputed_files/synonyms/fb_synonym*.tsv'),
format("~n================================================================================================="),
format("~n==========================Should be 18 minute Checkpoint========================================="),
format("~n================================================================================================="),
@@ -485,33 +230,33 @@
format("~n================================================================================================="),
format("~n================================================================================================="),
format("~n=================================================================================================~n"),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/map_conversion/cytotable.txt',tsv),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/map_conversion/genome-cyto-seq.txt',tsv),
- load_fbase_after_17,
+ load_flybase('./precomputed_files/map_conversion/cytotable.txt',tsv),
+ load_flybase('./precomputed_files/map_conversion/genome-cyto-seq.txt',tsv),
+ load_fbase_after_17]),
!.
load_fbase_after_17:-
- %load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/genes/scRNA-Seq_gene_expression_fb_*.tsv'),
- must_det_ll(load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/transposons/transposon_sequence_set.gff',tsv)),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/transposons/transposon_sequence_set.fa'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/ncRNA_genes_fb_*.json'),
+ %load_flybase('./precomputed_files/genes/scRNA-Seq_gene_expression*.tsv'),
+ must_det_ll(load_flybase('./precomputed_files/transposons/transposon_sequence_set.gff',tsv)),
+ load_flybase('./precomputed_files/transposons/transposon_sequence_set.fa'),
+ load_flybase('./precomputed_files/*/ncRNA_genes_fb_*.json'),
load_obo_files,
%% load_flybase_chado,
!.
load_flybase_obo_files:-
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/doid.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/fly_anatomy.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/fly_development.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/flybase_controlled_vocabulary.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/flybase_stock_vocabulary.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/gene_group_FB*.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/go-basic.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/image.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/psi-mi.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/slice.chebi.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/so-simple.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/chebi_fb_*.obo'),
+ load_flybase('./precomputed_files/ontologies/doid.obo'),
+ load_flybase('./precomputed_files/ontologies/fly_anatomy.obo'),
+ load_flybase('./precomputed_files/ontologies/fly_development.obo'),
+ load_flybase('./precomputed_files/ontologies/flybase_controlled_vocabulary.obo'),
+ load_flybase('./precomputed_files/ontologies/flybase_stock_vocabulary.obo'),
+ load_flybase('./precomputed_files/ontologies/gene_group_FB*.obo'),
+ load_flybase('./precomputed_files/ontologies/go-basic.obo'),
+ load_flybase('./precomputed_files/ontologies/image.obo'),
+ load_flybase('./precomputed_files/ontologies/psi-mi.obo'),
+ load_flybase('./precomputed_files/ontologies/slice.chebi.obo'),
+ load_flybase('./precomputed_files/ontologies/so-simple.obo'),
+ load_flybase('./precomputed_files/ontologies/chebi_fb_*.obo'),
!.
@@ -543,7 +288,7 @@
-(load_fb_obo "./data/ftp.flybase.net/releases/current/precomputed_files/ontologies/so-simple.obo" )
+(load_fb_obo "./precomputed_files/ontologies/so-simple.obo" )
; Total Atoms (Atomspace size): ...................................................... 19,484
; ConceptNodes: ................................................................. 4,194
@@ -584,7 +329,7 @@
load_obo_files:-
%load_obo('./reqs/obonet/tests/data/?*.obo'),
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/so*.obo'),
+ load_flybase('./precomputed_files/*/so*.obo'),
fb_stats,
load_flybase('./data/SO-Ontologies/Ontology_Files/*.obo'),
% Total Atoms (Atomspace size): ...................................................... 20,069
@@ -620,24 +365,24 @@
%loaded_from_file( 23, './data/SO-Ontologies/Legacy/Cross_Products/so-xp.obo').
%loaded_from_file( 23, './data/SO-Ontologies/Legacy/Cross_Products/so-xp-simple.obo').
- load_flybase('./data/ftp.flybase.net/releases/current/precomputed_files/*/*.obo'),
+ load_flybase('./precomputed_files/*/*.obo'),
% Total Atoms (Atomspace size): ................................................... 3,489,211
% ConceptNodes: ............................................................... 688,541
% Random samples: .............................................................. 26,006
% Total Memory Used: ............................................................ 1.19G
% Runtime (days:hh:mm:ss): ................................................. 0:00:34:35
print_loaded_from_files,
-%loaded_from_file(2_637_502, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/chebi_fb_2023_04.obo').
-%loaded_from_file( 451_168, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/go-basic.obo').
-%loaded_from_file( 221_705, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/fly_anatomy.obo').
-%loaded_from_file( 128_798, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/doid.obo').
+%loaded_from_file(2_637_502, './precomputed_files/ontologies/chebi_fb_2023_04.obo').
+%loaded_from_file( 451_168, './precomputed_files/ontologies/go-basic.obo').
+%loaded_from_file( 221_705, './precomputed_files/ontologies/fly_anatomy.obo').
+%loaded_from_file( 128_798, './precomputed_files/ontologies/doid.obo').
%loaded_from_file( 19_515, './data/SO-Ontologies/Ontology_Files/so-simple.obo').
-%loaded_from_file( 9_852, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/psi-mi.obo').
-%loaded_from_file( 8_644, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/gene_group_FB2023_04.obo').
-%loaded_from_file( 7_605, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/flybase_controlled_vocabulary.obo').
-%loaded_from_file( 1_598, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/fly_development.obo').
-%loaded_from_file( 834, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/image.obo').
-%loaded_from_file( 491, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/flybase_stock_vocabulary.obo').
+%loaded_from_file( 9_852, './precomputed_files/ontologies/psi-mi.obo').
+%loaded_from_file( 8_644, './precomputed_files/ontologies/gene_group_FB2023_04.obo').
+%loaded_from_file( 7_605, './precomputed_files/ontologies/flybase_controlled_vocabulary.obo').
+%loaded_from_file( 1_598, './precomputed_files/ontologies/fly_development.obo').
+%loaded_from_file( 834, './precomputed_files/ontologies/image.obo').
+%loaded_from_file( 491, './precomputed_files/ontologies/flybase_stock_vocabulary.obo').
%loaded_from_file( 481, './data/SO-Ontologies/Ontology_Files/so.obo').
%loaded_from_file( 336, './data/SO-Ontologies/Legacy/Cross_Products/so-xp-dec.obo').
%loaded_from_file( 310, './data/SO-Ontologies/Ontology_Files/subsets/SOFA.obo').
@@ -645,10 +390,10 @@
%loaded_from_file( 73, './data/SO-Ontologies/Ontology_Files/subsets/Alliance_of_Genome_Resources.obo').
%loaded_from_file( 35, './data/SO-Ontologies/Legacy/Cross_Products/so-xp-non-classified.obo').
%loaded_from_file( 31, './data/SO-Ontologies/Ontology_Files/subsets/DBVAR.obo').
-%loaded_from_file( 25, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/so-simple.obo').
+%loaded_from_file( 25, './precomputed_files/ontologies/so-simple.obo').
%loaded_from_file( 23, './data/SO-Ontologies/Legacy/Cross_Products/so-xp.obo').
%loaded_from_file( 23, './data/SO-Ontologies/Legacy/Cross_Products/so-xp-simple.obo').
-%loaded_from_file( 21, './data/ftp.flybase.net/releases/current/precomputed_files/ontologies/slice.chebi.obo').
+%loaded_from_file( 21, './precomputed_files/ontologies/slice.chebi.obo').
!.
@@ -762,200 +507,200 @@
est_size( 1, transcribed_from).
est_size( 1, guided_by).
% SQL
-est_size( 248_392_753,feature_relationship).
-est_size( 141_933_326,dbxrefprop).
-est_size( 98_464_501,featureloc).
-est_size( 92_616_769,feature).
-est_size( 78_909_674,analysisfeature).
-est_size( 61_025_741,feature_dbxref).
-est_size( 53_031_862,library_featureprop).
-est_size( 39_950_319,dbxref).
-est_size( 27_923_221,library_feature).
-est_size( 23_805_221,feature_relationshipprop).
-est_size( 21_279_999,featureprop).
-est_size( 7_474_185,feature_synonym).
-est_size( 6_554_427,synonym).
-est_size( 5_578_280,feature_pub).
-est_size( 5_341_100,featureprop_pub).
-est_size( 4_865_118,feature_relationship_pub).
-est_size( 2_813_405,feature_interactionprop).
-est_size( 2_464_355,feature_cvterm).
-est_size( 1_950_807,feature_cvtermprop).
-est_size( 1_377_258,feature_interaction).
-est_size( 1_116_490,feature_genotype).
-est_size( 888_210,pubprop).
-est_size( 734_870,featureloc_pub).
-est_size( 688_734,pubauthor).
-est_size( 518_569,genotype_synonym).
-est_size( 495_848,genotype).
-est_size( 491_538,feature_pubprop).
-est_size( 466_209,phenstatement).
-est_size( 413_338,pub_dbxref).
-est_size( 382_054,genotype_dbxref).
-est_size( 351_942,phendesc).
-est_size( 277_992,phenotype_comparison_cvterm).
-est_size( 254_298,feature_expressionprop).
-est_size( 252_544,phenotype_comparison).
-est_size( 251_928,pub).
-est_size( 242_344,pub_relationship).
-est_size( 227_406,feature_expression).
-est_size( 213_360,cvterm_relationship).
-est_size( 212_142,cvterm_dbxref).
-est_size( 209_164,interaction_cvterm).
-est_size( 195_000,cvtermsynonym).
-est_size( 180_311,expression_cvterm).
-est_size( 167_582,update_track).
-est_size( 150_401,feature_relationshipprop_pub).
-est_size( 149_855,stockcollection_stock).
-est_size( 149_855,stock).
-est_size( 149_835,stock_genotype).
-est_size( 146_846,interactionprop).
-est_size( 122_004,interaction_group).
-est_size( 119_611,feature_interaction_pub).
-est_size( 112_784,interaction_pub).
-est_size( 112_781,interaction).
-est_size( 101_687,interaction_group_feature_interaction).
-est_size( 96_405,feature_grpmember_pub).
-est_size( 94_765,cvterm).
-est_size( 79_466,expression_cvtermprop).
-est_size( 74_873,interactionprop_pub).
-est_size( 73_828,library_interaction).
-est_size( 57_144,organism).
-est_size( 48_730,humanhealthprop).
-est_size( 41_075,feature_grpmember).
-est_size( 36_960,expression).
-est_size( 23_565,library_cvterm).
-est_size( 23_483,library_cvtermprop).
-est_size( 21_251,cvtermprop).
-est_size( 19_797,libraryprop).
-est_size( 18_396,phenotype).
-est_size( 17_871,phenotype_cvterm).
-est_size( 16_617,humanhealth_dbxrefprop).
-est_size( 16_529,interaction_expressionprop).
-est_size( 16_318,humanhealth_pub).
-est_size( 15_400,library_synonym).
-est_size( 15_355,humanhealth_dbxref).
-est_size( 15_142,cell_line_feature).
-est_size( 14_972,libraryprop_pub).
-est_size( 13_694,interaction_expression).
-est_size( 13_218,interaction_cell_line).
-est_size( 10_720,library_pub).
-est_size( 9_870,library_relationship).
-est_size( 9_851,humanhealthprop_pub).
-est_size( 9_558,library_dbxref).
-est_size( 8_339,library_relationship_pub).
-est_size( 7_095,grp_pub).
-est_size( 6_719,cell_line_pub).
-est_size( 6_657,grp_relationship).
-est_size( 6_605,strain_synonym).
-est_size( 5_990,grp_synonym).
-est_size( 5_947,humanhealth_synonym).
-est_size( 5_785,strainprop).
-est_size( 5_783,strainprop_pub).
-est_size( 5_769,library).
-est_size( 5_543,grp_cvterm).
-est_size( 5_444,cell_line_synonym).
-est_size( 5_277,library_expression).
-est_size( 5_187,grpprop).
-est_size( 5_159,grpmember).
-est_size( 4_469,humanhealth_dbxrefprop_pub).
-est_size( 4_450,library_expressionprop).
-est_size( 4_415,grpprop_pub).
-est_size( 4_319,stock_cvterm).
-est_size( 3_832,library_dbxrefprop).
-est_size( 3_829,grpmemberprop).
-est_size( 3_777,genotype_cvterm).
-est_size( 3_744,humanhealth_featureprop).
-est_size( 3_721,library_strainprop).
-est_size( 3_721,library_strain).
-est_size( 3_625,humanhealth_feature).
-est_size( 2_641,grp_dbxref).
-est_size( 2_263,humanhealth_relationship).
-est_size( 2_220,humanhealth_relationship_pub).
-est_size( 2_093,strain_pub).
-est_size( 2_010,grp_relationship_pub).
-est_size( 1_939,strain_cvtermprop).
-est_size( 1_939,strain_cvterm).
-est_size( 1_814,grp).
-est_size( 1_777,strain_dbxref).
-est_size( 1_776,strain).
-est_size( 1_739,organism_dbxref).
-est_size( 1_643,feature_humanhealth_dbxref).
-est_size( 1_540,humanhealth_cvtermprop).
-est_size( 1_540,humanhealth_cvterm).
-est_size( 1_515,humanhealth).
-est_size( 1_300,cell_lineprop_pub).
-est_size( 1_291,cell_lineprop).
-est_size( 1_215,cell_line_dbxref).
-est_size( 1_198,cell_line_libraryprop).
-est_size( 1_081,cell_line_library).
-est_size( 1_013,organism_pub).
-est_size( 821,organismprop).
-est_size( 731,organismprop_pub).
-est_size( 714,cell_line_cvterm).
-est_size( 518,db).
-est_size( 435,strain_relationship_pub).
-est_size( 435,strain_relationship).
-est_size( 320,cell_line).
-est_size( 308,analysis).
-est_size( 238,stockprop).
-est_size( 171,cell_line_relationship).
-est_size( 139,strain_featureprop).
-est_size( 139,strain_feature).
-est_size( 107,strain_phenotypeprop).
-est_size( 96,humanhealth_pubprop).
-est_size( 73,cell_line_cvtermprop).
-est_size( 71,cv).
-est_size( 54,strain_phenotype).
-est_size( 40,environment).
-est_size( 27,stockcollectionprop).
-est_size( 26,contact).
-est_size( 18,environment_cvterm).
-est_size( 11,organism_library).
-est_size( 7,stockcollection).
-est_size( 1,lock).
-est_size( 0,analysisgrp).
-est_size( 0,analysisgrpmember).
-est_size( 0,analysisprop).
-est_size( 0,audit_chado).
-est_size( 0,cell_line_strain).
-est_size( 0,cell_line_strainprop).
-est_size( 0,cvtermpath).
-est_size( 0,eimage).
-est_size( 0,expression_image).
-est_size( 0,expression_pub).
-est_size( 0,expressionprop).
-est_size( 0,feature_cvterm_dbxref).
-est_size( 0,feature_phenotype).
-est_size( 0,featuremap).
-est_size( 0,featuremap_pub).
-est_size( 0,featurepos).
-est_size( 0,featurerange).
-est_size( 0,genotype_cvtermprop).
-est_size( 0,genotype_pub).
-est_size( 0,genotypeprop).
-est_size( 0,genotypeprop_pub).
-est_size( 0,grp_pubprop).
-est_size( 0,grp_relationshipprop).
-est_size( 0,grpmember_cvterm).
-est_size( 0,grpmember_pub).
-est_size( 0,grpmemberprop_pub).
-est_size( 0,humanhealth_phenotype).
-est_size( 0,humanhealth_phenotypeprop).
-est_size( 0,interaction_cvtermprop).
-est_size( 0,library_grpmember).
-est_size( 0,library_humanhealth).
-est_size( 0,library_humanhealthprop).
-est_size( 0,organism_cvterm).
-est_size( 0,organism_cvtermprop).
-est_size( 0,organism_grpmember).
-est_size( 0,project).
-est_size( 0,stock_dbxref).
-est_size( 0,stock_pub).
-est_size( 0,stock_relationship).
-est_size( 0,stock_relationship_pub).
-est_size( 0,stockprop_pub).
-est_size( 0,tableinfo).
+sql_est_size( 248_392_753,feature_relationship).
+sql_est_size( 141_933_326,dbxrefprop).
+sql_est_size( 98_464_501,featureloc).
+sql_est_size( 92_616_769,feature).
+sql_est_size( 78_909_674,analysisfeature).
+sql_est_size( 61_025_741,feature_dbxref).
+sql_est_size( 53_031_862,library_featureprop).
+sql_est_size( 39_950_319,dbxref).
+sql_est_size( 27_923_221,library_feature).
+sql_est_size( 23_805_221,feature_relationshipprop).
+sql_est_size( 21_279_999,featureprop).
+sql_est_size( 7_474_185,feature_synonym).
+sql_est_size( 6_554_427,synonym).
+sql_est_size( 5_578_280,feature_pub).
+sql_est_size( 5_341_100,featureprop_pub).
+sql_est_size( 4_865_118,feature_relationship_pub).
+sql_est_size( 2_813_405,feature_interactionprop).
+sql_est_size( 2_464_355,feature_cvterm).
+sql_est_size( 1_950_807,feature_cvtermprop).
+sql_est_size( 1_377_258,feature_interaction).
+sql_est_size( 1_116_490,feature_genotype).
+sql_est_size( 888_210,pubprop).
+sql_est_size( 734_870,featureloc_pub).
+sql_est_size( 688_734,pubauthor).
+sql_est_size( 518_569,genotype_synonym).
+sql_est_size( 495_848,genotype).
+sql_est_size( 491_538,feature_pubprop).
+sql_est_size( 466_209,phenstatement).
+sql_est_size( 413_338,pub_dbxref).
+sql_est_size( 382_054,genotype_dbxref).
+sql_est_size( 351_942,phendesc).
+sql_est_size( 277_992,phenotype_comparison_cvterm).
+sql_est_size( 254_298,feature_expressionprop).
+sql_est_size( 252_544,phenotype_comparison).
+sql_est_size( 251_928,pub).
+sql_est_size( 242_344,pub_relationship).
+sql_est_size( 227_406,feature_expression).
+sql_est_size( 213_360,cvterm_relationship).
+sql_est_size( 212_142,cvterm_dbxref).
+sql_est_size( 209_164,interaction_cvterm).
+sql_est_size( 195_000,cvtermsynonym).
+sql_est_size( 180_311,expression_cvterm).
+sql_est_size( 167_582,update_track).
+sql_est_size( 150_401,feature_relationshipprop_pub).
+sql_est_size( 149_855,stockcollection_stock).
+sql_est_size( 149_855,stock).
+sql_est_size( 149_835,stock_genotype).
+sql_est_size( 146_846,interactionprop).
+sql_est_size( 122_004,interaction_group).
+sql_est_size( 119_611,feature_interaction_pub).
+sql_est_size( 112_784,interaction_pub).
+sql_est_size( 112_781,interaction).
+sql_est_size( 101_687,interaction_group_feature_interaction).
+sql_est_size( 96_405,feature_grpmember_pub).
+sql_est_size( 94_765,cvterm).
+sql_est_size( 79_466,expression_cvtermprop).
+sql_est_size( 74_873,interactionprop_pub).
+sql_est_size( 73_828,library_interaction).
+sql_est_size( 57_144,organism).
+sql_est_size( 48_730,humanhealthprop).
+sql_est_size( 41_075,feature_grpmember).
+sql_est_size( 36_960,expression).
+sql_est_size( 23_565,library_cvterm).
+sql_est_size( 23_483,library_cvtermprop).
+sql_est_size( 21_251,cvtermprop).
+sql_est_size( 19_797,libraryprop).
+sql_est_size( 18_396,phenotype).
+sql_est_size( 17_871,phenotype_cvterm).
+sql_est_size( 16_617,humanhealth_dbxrefprop).
+sql_est_size( 16_529,interaction_expressionprop).
+sql_est_size( 16_318,humanhealth_pub).
+sql_est_size( 15_400,library_synonym).
+sql_est_size( 15_355,humanhealth_dbxref).
+sql_est_size( 15_142,cell_line_feature).
+sql_est_size( 14_972,libraryprop_pub).
+sql_est_size( 13_694,interaction_expression).
+sql_est_size( 13_218,interaction_cell_line).
+sql_est_size( 10_720,library_pub).
+sql_est_size( 9_870,library_relationship).
+sql_est_size( 9_851,humanhealthprop_pub).
+sql_est_size( 9_558,library_dbxref).
+sql_est_size( 8_339,library_relationship_pub).
+sql_est_size( 7_095,grp_pub).
+sql_est_size( 6_719,cell_line_pub).
+sql_est_size( 6_657,grp_relationship).
+sql_est_size( 6_605,strain_synonym).
+sql_est_size( 5_990,grp_synonym).
+sql_est_size( 5_947,humanhealth_synonym).
+sql_est_size( 5_785,strainprop).
+sql_est_size( 5_783,strainprop_pub).
+sql_est_size( 5_769,library).
+sql_est_size( 5_543,grp_cvterm).
+sql_est_size( 5_444,cell_line_synonym).
+sql_est_size( 5_277,library_expression).
+sql_est_size( 5_187,grpprop).
+sql_est_size( 5_159,grpmember).
+sql_est_size( 4_469,humanhealth_dbxrefprop_pub).
+sql_est_size( 4_450,library_expressionprop).
+sql_est_size( 4_415,grpprop_pub).
+sql_est_size( 4_319,stock_cvterm).
+sql_est_size( 3_832,library_dbxrefprop).
+sql_est_size( 3_829,grpmemberprop).
+sql_est_size( 3_777,genotype_cvterm).
+sql_est_size( 3_744,humanhealth_featureprop).
+sql_est_size( 3_721,library_strainprop).
+sql_est_size( 3_721,library_strain).
+sql_est_size( 3_625,humanhealth_feature).
+sql_est_size( 2_641,grp_dbxref).
+sql_est_size( 2_263,humanhealth_relationship).
+sql_est_size( 2_220,humanhealth_relationship_pub).
+sql_est_size( 2_093,strain_pub).
+sql_est_size( 2_010,grp_relationship_pub).
+sql_est_size( 1_939,strain_cvtermprop).
+sql_est_size( 1_939,strain_cvterm).
+sql_est_size( 1_814,grp).
+sql_est_size( 1_777,strain_dbxref).
+sql_est_size( 1_776,strain).
+sql_est_size( 1_739,organism_dbxref).
+sql_est_size( 1_643,feature_humanhealth_dbxref).
+sql_est_size( 1_540,humanhealth_cvtermprop).
+sql_est_size( 1_540,humanhealth_cvterm).
+sql_est_size( 1_515,humanhealth).
+sql_est_size( 1_300,cell_lineprop_pub).
+sql_est_size( 1_291,cell_lineprop).
+sql_est_size( 1_215,cell_line_dbxref).
+sql_est_size( 1_198,cell_line_libraryprop).
+sql_est_size( 1_081,cell_line_library).
+sql_est_size( 1_013,organism_pub).
+sql_est_size( 821,organismprop).
+sql_est_size( 731,organismprop_pub).
+sql_est_size( 714,cell_line_cvterm).
+sql_est_size( 518,db).
+sql_est_size( 435,strain_relationship_pub).
+sql_est_size( 435,strain_relationship).
+sql_est_size( 320,cell_line).
+sql_est_size( 308,analysis).
+sql_est_size( 238,stockprop).
+sql_est_size( 171,cell_line_relationship).
+sql_est_size( 139,strain_featureprop).
+sql_est_size( 139,strain_feature).
+sql_est_size( 107,strain_phenotypeprop).
+sql_est_size( 96,humanhealth_pubprop).
+sql_est_size( 73,cell_line_cvtermprop).
+sql_est_size( 71,cv).
+sql_est_size( 54,strain_phenotype).
+sql_est_size( 40,environment).
+sql_est_size( 27,stockcollectionprop).
+sql_est_size( 26,contact).
+sql_est_size( 18,environment_cvterm).
+sql_est_size( 11,organism_library).
+sql_est_size( 7,stockcollection).
+sql_est_size( 1,lock).
+sql_est_size( 0,analysisgrp).
+sql_est_size( 0,analysisgrpmember).
+sql_est_size( 0,analysisprop).
+sql_est_size( 0,audit_chado).
+sql_est_size( 0,cell_line_strain).
+sql_est_size( 0,cell_line_strainprop).
+sql_est_size( 0,cvtermpath).
+sql_est_size( 0,eimage).
+sql_est_size( 0,expression_image).
+sql_est_size( 0,expression_pub).
+sql_est_size( 0,expressionprop).
+sql_est_size( 0,feature_cvterm_dbxref).
+sql_est_size( 0,feature_phenotype).
+sql_est_size( 0,featuremap).
+sql_est_size( 0,featuremap_pub).
+sql_est_size( 0,featurepos).
+sql_est_size( 0,featurerange).
+sql_est_size( 0,genotype_cvtermprop).
+sql_est_size( 0,genotype_pub).
+sql_est_size( 0,genotypeprop).
+sql_est_size( 0,genotypeprop_pub).
+sql_est_size( 0,grp_pubprop).
+sql_est_size( 0,grp_relationshipprop).
+sql_est_size( 0,grpmember_cvterm).
+sql_est_size( 0,grpmember_pub).
+sql_est_size( 0,grpmemberprop_pub).
+sql_est_size( 0,humanhealth_phenotype).
+sql_est_size( 0,humanhealth_phenotypeprop).
+sql_est_size( 0,interaction_cvtermprop).
+sql_est_size( 0,library_grpmember).
+sql_est_size( 0,library_humanhealth).
+sql_est_size( 0,library_humanhealthprop).
+sql_est_size( 0,organism_cvterm).
+sql_est_size( 0,organism_cvtermprop).
+sql_est_size( 0,organism_grpmember).
+sql_est_size( 0,project).
+sql_est_size( 0,stock_dbxref).
+sql_est_size( 0,stock_pub).
+sql_est_size( 0,stock_relationship).
+sql_est_size( 0,stock_relationship_pub).
+sql_est_size( 0,stockprop_pub).
+sql_est_size( 0,tableinfo).
est_size_loaded(N,F/A):- fb_pred_major(F,A),metta_stats(F,A,N).
@@ -972,6 +717,10 @@
sort(L,S),reverse(S,R),maplist(call,R),
print_est_sizes.
+fb_info:- print_loaded_from_files,fb_stats.
+
+fb_show:- print_loaded_from_files,fb_stats.
+
print_est_sizes:-
findall(print_est_size(est_size_loaded,N,F),
est_size_loaded(N,F),L),
@@ -1069,8 +818,11 @@
:- dynamic(is_loaded_from_file_count/2).
:- use_module(library(http/json)).
+:- ensure_loaded(flybase_json).
+load_fb_json(Fn,File):- fbug(load_fb_json(Fn,File)),
+ current_predicate(load_flybase_json/2),load_flybase_json(Fn,File).
load_fb_json(Fn,File):- fbug(load_fb_json(Fn,File)),
- setup_call_cleanup(open(File,read,In), json:json_read(In,Term,[]), close(In)),
+ setup_call_cleanup(open(File,read,In,[encoding(utf8)]), json:json_read(In,Term,[]), close(In)),
time(assert(saved_fb_json(File,Term,Fn))).
@@ -1099,7 +851,7 @@
:- dynamic(fb_arg/1).
:- dynamic(fb_arg_table_n/3).
-assert_arg_table_n(A,Fn,N):-
assert_new(fb_arg(A)), assert_new(fb_arg_table_n(A,Fn,N)).
+assert_arg_table_n(A,Fn,N):- assert_new(fb_arg(A)), assert_new(fb_arg_table_n(A,Fn,N)).
assert_arg_samples(Fn,N,[A|Args]):-
(dont_sample(A)->true;assert_arg_table_n(A,Fn,N)),
@@ -1108,31 +860,38 @@
dont_sample(N):- \+ symbol(N). dont_sample(''). dont_sample('-').
-data_pred0(X,Y):- symbol_concat('public.',YY,X),!,data_pred0(YY,Y).
data_pred0(X,Y):- symbolic_list_concat(List,'/',X),List\==[],List\=[_],!,last(List,L),data_pred0(L,Y).
-data_pred0(X,Y):- symbolic_list_concat(List,'_',X),once(not_trimmed_path(List,NewList)),
- NewList\==[],NewList\==List,symbolic_list_concat(NewList,'_',Y),!.
-data_pred0(X,Y):- symbolic_list_concat([L,_|_],'_fb_',X),!,data_pred0(L,Y).
+data_pred0(X,Y):- symbol_concat(YY,'.tsv',X),!,data_pred0(YY,Y).
+data_pred0(X,Y):- symbol_concat(YY,'.fb',X),!,data_pred0(YY,Y).
+data_pred0(X,Y):- symbol_concat(YY,'_',X),!,data_pred0(YY,Y).
+data_pred0(X,Y):- symbol_concat(YY,'_fb',X),!,data_pred0(YY,Y).
+data_pred0(X,Y):- symbol_concat('public.',YY,X),!,data_pred0(YY,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'.',X),L=[_,_|_],symbolic_list_concat(L,'_',XL),!,data_pred0(XL,Y).
+%data_pred0(X,Y):- symbolic_list_concat([L,_|_],'_fb_2',X),!,data_pred0(L,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_0',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_1',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_2',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_3',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_4',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_5',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_6',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_7',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_8',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb_9',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+data_pred0(X,Y):- symbolic_list_concat(L,'_fb__',X),L=[_,_|_],symbolic_list_concat(L,'_fb_',XL),!,data_pred0(XL,Y).
+%data_pred0(X,Y):- symbolic_list_concat(List,'_',X),once(not_trimmed_path(List,NewList)),
+% NewList\==[],NewList\==List,symbolic_list_concat(NewList,'_',Y),!.
data_pred0(X,X).
data_pred(X,Y):- data_pred0(X,Y), Y\=='',!.
data_pred(X,X).
-is_trimmed_path(X):- symbol_contains(X,'0'),!.
-is_trimmed_path('fb').
-is_trimmed_path('public').
-is_trimmed_path('data').
-%is_trimmed_path(Atom):- path_chars(Atom,Chars), read_term_from_chars(Chars,Term,[]),number(Term),!.
-not_trimmed_path([H|List],NewList):- is_trimmed_path(H),!,not_trimmed_path(List,NewList).
-not_trimmed_path([H|List],[H|NewList]):- !, not_trimmed_path(List,NewList).
-not_trimmed_path([],[]).
-
%file_to_sep(_File,9).
-file_to_sep(File,','):- file_name_extension(_,csv,File),!.
-file_to_sep(File,'\t'):- file_name_extension(_,tsv,File),!.
file_to_sep(csv,',').
file_to_sep(tsv,'\t').
+file_to_sep(metta_x,'\t').
+file_to_sep(File,Sep):- file_name_extension(_,Ext,File),clause(file_to_sep(Ext,Sep),true),!.
file_to_sep(_,'\t').
is_swipl:- \+ is_scryer.
@@ -1162,7 +921,7 @@
:- dynamic(done_reading/1).
-
+use_metta_x:- fail.
load_fb_cache(_File,OutputFile,_Fn):- exists_file(OutputFile),!,ensure_loaded(OutputFile),!.
load_fb_cache(File,_OutputFile,_Fn):- load_files([File],[qcompile(large)]).
@@ -1170,6 +929,7 @@
'load_flybase_tiny':- load_flybase(20_000).
'load_flybase_full':- load_flybase(1_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000).
+'save_flybase_full':- load_flybase_full,qsave_program.
load_flybase(N):- (number(N)->true;N==inf),!,
with_option([max_per_file=N],
@@ -1180,28 +940,41 @@
load_flybase0(Ext,_File):- Ext=='pl',!.
load_flybase0(Ext,File):-
- file_name_extension(Name,_,File),
- data_pred(Name,Fn),load_flybase(Ext,File,Fn).
+ must_det_ll((file_name_extension(Name,_,File),
+ data_pred(Name,Fn),load_flybase(Ext,File,Fn))).
:- dynamic(load_state/2).
%load_flybase(_Ext,_File,OutputFile,_Fn):- exists_file(OutputFile),size_file(OutputFile,N),N>100,!.
load_flybase(_Ext,File,_Fn):- load_state(File,_),!.
load_flybase(Ext,File,Fn):-
+ must_det_ll((
assert(load_state(File,loading)),
fbug(load_flybase(Ext,File,Fn)),
load_flybase_ext(Ext,File,Fn),
- retract(load_state(File,loading)),
- assert(load_state(File,loaded)),fb_stats.
+ ignore(retract(load_state(File,loading))),
+ assert(load_state(File,loaded)),fb_stats)).
+load_flybase_ext(_Ext,File,_Fn):- use_metta_x, atom_concat(File,'.metta_x',MFile),
+ exists_file(MFile), \+ is_converting, % Ext \== 'obo',
+ \+ option_value(metta_x_files,false),!,
+ process_metta_x_file(MFile).
+load_flybase_ext(_Ext,File,_Fn):- fail, atom_concat(File,'.metta',MFile),
+ exists_file(MFile), \+ is_converting, % Ext \== 'obo',
+ \+ option_value(mettafiles,false),!,
+ load_flybase_metta(MFile).
+load_flybase_ext(Ext,File,_Fn):- Ext==obo,current_predicate(load_obo/1),!,load_obo(File).
load_flybase_ext(Ext,File, Fn):- Ext==json,!,load_fb_json(Fn,File),!.
load_flybase_ext(Ext,File, Fn):- Ext==fa,!,load_fb_fa(Fn,File),!.
-load_flybase_ext(Ext,File,_Fn):- Ext==obo,current_predicate(load_obo/1),!,load_obo(File).
-load_flybase_ext(Ext,File,_Fn):- Ext==metta,current_predicate(load_metta/2),!,load_metta('&self',File).
+load_flybase_ext(Ext,File,_Fn):- Ext==metta,current_predicate(load_metta/2),!,load_flybase_metta(File).
load_flybase_ext(Ext,File, Fn):- file_to_sep(Ext,Sep),!,
track_load_into_file(File,
-
setup_call_cleanup(open(File,read,Stream), load_flybase_sv(Sep,File,Stream,Fn), close(Stream))),!.
+setup_call_cleanup(open(File,read,Stream), load_flybase_sv(Sep,File,Stream,Fn), close(Stream))),!.
load_flybase_ext(Ext,File, Fn):- fbug(missed_loading_flybase(Ext,File,Fn)),!.
+%load_flybase_metta(File):- !, load_metta('&flybase',File).
+load_flybase_metta(File):-
+ with_option('trace-on-load',false,
+ load_metta('&flybase',File)).
fix_list_args(_,_,Y,Y):- option_value(early_canon,[]), \+ should_sample,!.
@@ -1317,9 +1090,10 @@
write_flybase_data(_ArgTypes,_Fn,[]):-!.
write_flybase_data(_ArgTypes,_Fn,['']):-!.
-write_flybase_data(_ArgTypes,Fn,DataL):- fail, !, Data=..[Fn|DataL], assert_MeTTa(Data).
-write_flybase_data(_ArgTypes,Fn,DataL):- into_datum(Fn,DataL,Data),
- assert_MeTTa(Data).
+write_flybase_data(_ArgTypes,_Fn,[_]):-!.
+write_flybase_data(_ArgTypes,Fn,DataL0):-
+ maplist(fast_column,DataL0,DataL), !, Data=..[Fn|DataL], assert_MeTTa(Data).
+%write_flybase_data(_ArgTypes,Fn,DataL):- into_datum(Fn,DataL,Data), assert_MeTTa(Data).
/*
@@ -1339,6 +1113,8 @@
ignore((fail,catch_ignore(ignore((X<1000,must_det_ll_r((write_canonical(OutputStream,Data),writeln(OutputStream,'.')))))))))),!.
*/
+make_assertion(Fn, Cols, NewData, OldData):- !, make_assertion4(Fn, Cols, NewData, OldData).
+
make_assertion(Fn,DataL0,Data,DataL0):-
must_det_ll_r((
into_datum(Fn,DataL0,Data0),
@@ -1481,6 +1257,7 @@
((primary_column(Fn,Name),nth1(N,ArgTypes,Name))->NArgTypes=[N|ArgTypes];NArgTypes=[1|ArgTypes]),
if_t(is_list(ArgTypes),add_table_n_types(Fn,1,ArgTypes)),
ground(NArgTypes),
+ if_t(is_list(ArgTypes),ignore((length(ArgTypes,A),decl_fb_pred(Fn,A)))),
time((repeat,
read_line_to_chars(Stream, Chars),
once(load_flybase_chars(NArgTypes,File,Stream,Fn,Sep,Chars)),
@@ -1495,19 +1272,34 @@
is_really_header_row([H|_],_Names):- symbol_concat('',_,H),!.
-%read_csv_stream(Sep,CharsStream,Header):- read_string(CharsStream, "\n", "\r\true ",_,)
+process_metta_x_file(MXFile):-
+ data_pred(MXFile,Fn),
+ setup_call_cleanup(open(MXFile,read,In,[encoding(utf8)]),
+ ((repeat,
+ read_line_to_string(In,Chars),
+ (In == end_of_file -> ! ;
+ once((atomic_list_concat(Row0,'\t', Chars),
+ maplist(fast_column,Row0,Row),
+ assert_MeTTa([Fn|Row])))))),
+ close(In)).
+
+fast_column(X,X):- !.
+fast_column(X,Y):- into_fb_term(X,Y),!.
+fast_column(X,X).
+
+%read_csv_stream(Sep,CharsStream,Header):- read_string(CharsStream, "\n", "\r\t ",_,)
read_csv_stream(Sep,CharsStream,Header):- % \+ option_value(full_canon,[]),!,
read_line_to_string(CharsStream,Chars),
(Chars == end_of_file -> Header= Chars ; symbolic_list_concat(Header, Sep, Chars)).
read_csv_stream(Sep,CharsStream,Header):- \+ option_value(full_canon,[]),!, read_line_to_string(CharsStream,Chars),
- (Chars == end_of_file -> Header= Chars ; split_string(Chars, Sep, "\s\true\n", Header)).
+ (Chars == end_of_file -> Header= Chars ; split_string(Chars, Sep, "\s\t\n", Header)).
read_csv_stream(Sep,CharsStream,Header):-
name(Sep,[SepCode]),
csv_options(CompiledHeaderOptions,[separator(SepCode)]),
csv_read_row(CharsStream, HeaderRow, CompiledHeaderOptions),
HeaderRow=..[_|Header],!.
-read_csv(Sep,Chars,Header):- \+ option_value(full_canon,[]),!, split_string(Chars, Sep, "\s\true\n", Header).
+read_csv(Sep,Chars,Header):- \+ option_value(full_canon,[]),!, split_string(Chars, Sep, "\s\t\n", Header).
read_csv(Sep,Chars,Header):-
open_string(Chars,CharsStream),read_csv_stream(Sep,CharsStream,Header).
@@ -1544,7 +1336,7 @@
load_fb_data(ArgTypes,File,Stream,Fn,Sep, is_swipl):- % \+ option_value(full_canon,[]), !,
(option_value(max_per_file,Max)->true;Max=inf),
fbug(load_fb_data(ArgTypes,File,Max,Fn,Sep)),
- add_table_n_types(Fn,1,ArgTypes),!,
+ add_table_n_types(Fn,1,ArgTypes),!,% trace,
repeat,
once(read_csv_stream(Sep,Stream,Data)),
loaded_from_file_count(X),
@@ -2762,9 +2554,6 @@
(print(column_names(T,CNs)),nl)).
-xinfo(X,P):- fb_pred(F,A),functor(P,F,A),arg(_,P,X), no_repeats(P,call(P)).
-xinfo(X):- forall(xinfo(X,P),(format('~N'),write_src(P))),format('~N').
-
%:- ensure_loaded(read_obo).
show_cmds:- prolog_load_context(source,This),for_all((source_file(P0,This),functor(P0,F,0)),writeln(add_history1(F))).
diff --git a/metta_vspace/pyswip/flybase_obo.pl b/metta_vspace/pyswip/flybase_obo.pl
index 8f5bce36..ea8133d8 100755
--- a/metta_vspace/pyswip/flybase_obo.pl
+++ b/metta_vspace/pyswip/flybase_obo.pl
@@ -3,7 +3,10 @@
% - Douglas R. Miles 2023
% ===========================================
-% requires: assert_OBO/1, track_load_into_file/2
+% requires: assert_MeTTa/1, track_load_into_file/2
+
+:- use_module(library(logicmoo_utils)).
+:- ensure_loaded(flybase_main).
assert_OBO(P,X,Y):- assert_OBO(ontology_info(P,X,Y)).
@@ -21,7 +24,49 @@
atomic(Directory), exists_directory(Directory),
directory_file_path(Directory, "*.obo", Filename),
expand_file_name(Filename,List),!,maplist(load_obo,List).
+load_obo(Filename) :- fail,
+ process_obo_file(Filename),!.
load_obo(Filename) :-
+ process_obo_direct(Filename),!.
+
+
+process_obo_file(File):- atom_concat(File,'.metta_x',MXFile),process_obo_file(File,MXFile).
+process_obo_file(_File,MXFile):- exists_file(MXFile),!,process_metta_x_file(MXFile).
+process_obo_file(File, MXFile):- exists_file(File),!,
+ setup_call_cleanup(
+ open(MXFile,write,Strm,[]),
+ setup_call_cleanup(
+ set_stream(Strm,alias(metta_x_output)),
+ with_option(make_metta_x,'True',
+ process_obo_direct(File)),
+ set_stream(current_output,alias(metta_x_output))),
+ close(Strm)),
+ remove_duplicates(MXFile),
+ process_metta_x_file(MXFile).
+process_obo_file(File, MXFile):- throw(process_obo_file(File, MXFile)).
+
+
+
+% remove_duplicates(+InputFile) - removes duplicate lines from a file in place.
+remove_duplicates(InputFile) :-
+ % Create a temporary output file
+ format(atom(OutputFile), '~w.tmp', [InputFile]),
+ % Build the command to remove duplicates and output to the temporary file
+ format(atom(Command), 'sort ~w | uniq > ~w', [InputFile, OutputFile]),
+ % Execute the command
+ shell(Command, ExitStatus),
+ % Check the exit status
+ ExitStatus =:= 0,
+ % Move the temporary output file to the original input file
+ format(atom(Command2), 'mv ~w ~w', [OutputFile, InputFile]),
+ shell(Command2, ExitStatus2),
+ ExitStatus2 =:= 0,!.
+
+% rename_file(+Source, +Destination) - renames or moves a file.
+rename_file(Source, Destination) :-
+ rename(Source, Destination).
+
+process_obo_direct(Filename):-
directory_file_path(Directory, BaseName, Filename),
file_name_extension(Id, _, BaseName),
symbol_concat(Id,'.metta',OutputFile),
@@ -34,7 +79,7 @@
assert_OBO('pathname',Id,Filename),!,
assert_OBO('basename',Id,BaseName),!,
assert_OBO('directory',Id,Directory),!,
- setup_call_cleanup(open(Filename, read, Stream),
+ setup_call_cleanup(open(Filename, read, Stream, [encoding(utf8)]),
process_obo_stream_repeat(Stream),
close(Stream))))),
nop(told).
@@ -45,7 +90,7 @@
nb_current(obo_type,Type),
nb_current(obo_id, Id),
once((read_line_to_string(Stream, Line),
- (should_show_data(_) -> writeln(Line); true),
+ ((should_show_data(_),fail) -> writeln(Line); true),
normalize_space(chars(Chars),Line))),
Chars\==[],
once(process_obo_chars( Type, Chars, Id)),
@@ -200,16 +245,42 @@
assert_OBO(property_value(Term, Pred, V)):- atom(Pred),!,OBO=..[Pred,Term,V],assert_OBO(OBO).
assert_OBO(synonym(Pred,A,Term,V)):- simplify_obo_arg(V,VV),!,assert_OBO(synonym(Pred,A,Term,VV)).
assert_OBO(ontology_info(Pred,Term,V)):- assert_OBO(property_value(Term, Pred, V)).
+assert_OBO([F|List]):- is_list([F|List]),atom(F),OBO=..[F|List],!,assert_OBO(OBO).
assert_OBO(OBO):-
+ must_det_ll((
OBO=..[Fn|Cols],
into_obofn(Fn,OboFn),
+ assert_OB1([OboFn|Cols]))).
+
+assert_OB1(List):- nb_current(make_metta_x,'True'),!, assert_OB2(List).
+assert_OB1([OboFn|Cols]):-
OBO1=..[OboFn|Cols],
- assert_MeTTa(OBO1),
-% format('~N'), write_src(OBO1),nl.
+ assert_MeTTa(OBO1).
+
+assert_OB2(List):- maplist(to_metta_x_args,List,ListO),
+ atomics_to_string(ListO,'\t',Str),
+ writeln(metta_x_output,Str).
+
+to_metta_x_args(X,O):- X==[],!,O='[]'.
+to_metta_x_args(X,O):- atomic(X),!,O=X.
+to_metta_x_args(X,O):- term_to_atom(X,O).
+
+args_x_metta(X,O):- X=='[]',!,O=[].
+args_x_metta(X,O):- atomic(X),atom_concat('?-',Read,X),!,atom_to_term(Read,O,_).
+args_x_metta(X,O):- X=O.
+/*
+ OBOW=..[OboFn|Cols],
+ (is_converting -> (format('~N'), write_src(OBOW));(OBO1=..OBOW,assert_MeTTa(OBO1))))),
!.
+*/
+
+into_obofn(Fn,OboFn):- atom_concat('obo-',_,Fn),!,Fn=OboFn,!.
+into_obofn(Fn,OboFn):- atom_concat('obo-',Fn,OboF_),!,use_dashes(OboF_,OboFn).
+
-into_obofn(Fn,OboFn):- atom_concat(obo_,_,Fn),!,Fn=OboFn,!.
-into_obofn(Fn,OboFn):- atom_concat(obo_,Fn,OboFn),!.
+use_dashes(OboF_,OboFn):-
+ atomic_list_concat(List,'_',OboF_),
+ atomic_list_concat(List,'-',OboFn),!.
simplify_obo_arg(I,_O):- \+ string(I), \+ atom(I),!,fail.
diff --git a/metta_vspace/pyswip/metta_compiler.pl b/metta_vspace/pyswip/metta_compiler.pl
index 1b748dd8..fe984c47 100755
--- a/metta_vspace/pyswip/metta_compiler.pl
+++ b/metta_vspace/pyswip/metta_compiler.pl
@@ -21,9 +21,9 @@
:- ensure_loaded(metta_space).
% =======================================
% TODO move non flybase specific code between here and the compiler
-:- ensure_loaded(swi_flybase).
+:- ensure_loaded(flybase_main).
% =======================================
-:- set_option_value(encoding,iso_latin_1).
+:- set_option_value(encoding,utf8).
% Meta-predicate that ensures that for every instance where G1 holds, G2 also holds.
:- meta_predicate(for_all(0,0)).
@@ -43,8 +43,10 @@
'=~'(A,B):- compound_non_cons(B),!,A=B.
'=~'(A,B):- '=..'(A,B).
+%into_list_args(A,AA):- is_ftVar(A),AA=A.
+%into_list_args(C,[C]):- \+ compound(C),!.
+into_list_args(C,C):- \+ compound(C),!.
into_list_args(A,AA):- is_ftVar(A),AA=A.
-into_list_args(C,[C]):- \+ compound(C),!.
into_list_args([H|T],[H|T]):- \+ is_list(T),!.
into_list_args([H,List,A],HT):- H == u_assign,!,append(List,[A],HT),!.
into_list_args([H|T],[H|T]):- is_list(T),!.
@@ -216,7 +218,7 @@
as_functor_args(AsPred,F,A,ArgsL):- nonvar(AsPred),!,into_list_args(AsPred,[F|ArgsL]),length(ArgsL,A).
as_functor_args(AsPred,F,A,ArgsL):- nonvar(F),length(ArgsL,A),AsPred =~ [F|ArgsL].
-compile_for_assert(HeadIs, AsBodyFn, Converted) :-
+compile_for_assert(HeadIs, AsBodyFn, Converted) :-
(AsBodyFn =@= HeadIs ; AsBodyFn == []), !,/*trace,*/
compile_head_for_assert(HeadIs,Converted).
@@ -540,33 +542,34 @@
-compile_flow_control(_HeadIs,RetResult,Convert,is_True(RetResult)) :-
- Convert =~ ['and'],!.
+compile_flow_control(_HeadIs,RetResult,Convert,is_True(RetResult)) :- is_compiled_and(AND),
+ Convert =~ [AND],!.
-compile_flow_control(HeadIs,RetResult,Convert, Converted) :-
- Convert =~ ['and',Body],!,
+compile_flow_control(HeadIs,RetResult,Convert, Converted) :- is_compiled_and(AND),
+ Convert =~ [AND,Body],!,
f2p(HeadIs,RetResult,Body,BodyCode),
compile_test_then_else(RetResult,BodyCode,'True','False',Converted).
-compile_flow_control(HeadIs,RetResult,Convert, Converted) :-
- Convert =~ ['and',Body1,Body2],!,
+compile_flow_control(HeadIs,RetResult,Convert, Converted) :- is_compiled_and(AND),
+ Convert =~ [AND,Body1,Body2],!,
f2p(HeadIs,B1Res,Body1,Body1Code),
f2p(HeadIs,RetResult,Body2,Body2Code),
into_equals(B1Res,'True',AE),
Converted = (Body1Code,AE,Body2Code),!.
-compile_flow_control(HeadIs,RetResult,Convert, Converted) :-
- Convert =~ ['and',Body1,Body2],!,
+compile_flow_control(HeadIs,RetResult,Convert, Converted) :- is_compiled_and(AND),
+ Convert =~ [AND,Body1,Body2],!,
f2p(HeadIs,B1Res,Body1,Body1Code),
f2p(HeadIs,_,Body2,Body2Code),
into_equals(B1Res,'True',AE),
compile_test_then_else(RetResult,(Body1Code,AE,Body2Code),'True','False',Converted).
-compile_flow_control(HeadIs,RetResult,Convert, Converted) :-
- Convert =~ ['and',Body1,Body2|BodyMore],!,
- And2 =~ ['and',Body2|BodyMore],
- compile_flow_control(HeadIs,RetResult,'and'(Body1,And2), Converted).
+compile_flow_control(HeadIs,RetResult,Convert, Converted) :- is_compiled_and(AND),
+ Convert =~ [AND,Body1,Body2|BodyMore],!,
+ And2 =~ [AND,Body2|BodyMore],
+ Next =~ [AND,Body1,And2],
+ compile_flow_control(HeadIs,RetResult, Next, Converted).
compile_flow_control(HeadIs,RetResult,sequential(Convert), Converted) :- !,
compile_flow_control(HeadIs,RetResult,transpose(Convert), Converted).
@@ -604,6 +607,8 @@
dif_functors(HeadIs,Convert):- compound(HeadIs),compound(Convert),
compound_name_arity(HeadIs,F,A),compound_name_arity(Convert,F,A).
+is_compiled_and(AND):- member(AND,[ (','), ('and')]).
+
flowc.
@@ -745,7 +750,7 @@
subst(Convert, ConvertFunction, Result, Converting), % Substitute AsFunction by Result in Convert
f2p(HeadIs,RetResult, (AsPred, Converting), Converted). % Proceed with the conversion of the remaining terms
-/* MAYBE USE ?*/
+/* MAYBE USE ?
% If Convert is a compound term, we need to recursively convert its arguments.
f2p(HeadIs,RetResult, Convert, Converted) :- fail,
compound(Convert), !,
@@ -753,14 +758,15 @@
maplist(convert_argument, Args, ConvertedArgs), % Recursively convert each argument
Converted =~ [Functor|ConvertedArgs], % Reconstruct Converted with the converted arguments
(callable(Converted) -> f2p(HeadIs,RetResult, Converted, _); true). % If Converted is callable, proceed with its conversion
+% Helper predicate to convert an argument of a compound term
+convert_argument(Arg, ConvertedArg) :-
+ (callable(Arg) -> ftp(_, _, Arg, ConvertedArg); ConvertedArg = Arg).
+*/
% The catch-all If no specific case is matched, consider Convert as already converted.
f2p(_HeadIs,_RetResult,u_assign(Convert,Res), u_assign(Convert,Res)):-!.
f2p(_HeadIs,RetResult,Convert, Code):- into_u_assign(Convert,RetResult,Code).
-% Helper predicate to convert an argument of a compound term
-convert_argument(Arg, ConvertedArg) :-
- (callable(Arg) -> functs_to_preds(_, Arg, ConvertedArg); ConvertedArg = Arg).
data_term(Convert):- self_eval(Convert),!.
@@ -814,7 +820,7 @@
% the equivalent predicate with the 'Result' at the 'Nth' position.
%
% Example:
-% funct_with_result_is_nth_of_pred(HeadIs,+(1, 2), Result, 3, +(1, 2, Result)).
+% funct_with_result_is_nth_of_pred(HeadIs,+(1, 2), Result, 3, +(1, 2, Result)).
into_callable(Pred,AsPred):- is_ftVar(Pred),!,AsPred=holds(Pred).
into_callable(Pred,AsPred):- Pred=AsPred,!.
@@ -1031,10 +1037,10 @@
% The first argument is the input in Prolog syntax,
% and the second argument is the output converted to MeTTa syntax.
p2m(NC, NC) :- var(NC), !. % If NC is a variable, do not translate.
-p2m(NC, NC) :- is_ftVar(NC), !. % If NC is a free term variable, do not translate.
+p2m(NC, NC) :- is_ftVar(NC), !. % If NC is a free term variable, do not translate.
% Conversion for lists
p2m([], 'Nil'). % empty list
-p2m([H|T], 'Cons'(OH, OT)):- p2m(H, OH), p2m(T, OT).
+p2m([H|T], 'Cons'(OH, OT)):- p2m(H, OH), p2m(T, OT).
p2m(NC, OO) :-
% If NC is a list, map each element of the list from Prolog to MeTTa
is_list(NC),!,
@@ -1047,19 +1053,19 @@
p2m('[|]','Cons').
p2m(( ';' ),or).
-p2m(( ',' ),and).
-p2m(( '\\+' ),unless).
+%p2m(( ',' ),and).
+%p2m(( '\\+' ),unless).
%p2m(( ':-' ),entailed_by).
p2m('=..','atom_2_list').
-
+
% Conversion for any atomic term
-p2m(A, A):- atomic(A).
-
+p2m(A, A):- atomic(A).
+
p2m(NC,NC):- \+ compound(NC),!.
p2m(NC,[F]):- compound_name_arity(NC,F,0),!.
-
+
% Conversion for the negation as failure
-p2m((\+ A), O):- !, p2m(not(A), O).
+p2m((\+ A), O):- !, p2m(not(A), O).
% Conversion for arithmetic evaluation
%p2m(is(A, B), O):- !, p2m(eval(B, A), O).
@@ -1083,7 +1089,7 @@
p2m(retract(X),'remove-atom'('&self',X)).
p2m(assert(X),'add-atom'('&self',X)).
% The catch-all case for the other compound terms.
-p2m(I,O):- I=..[F|II],maplist(p2m,[F|II],OO),O=..OO.
+p2m(I,O):- I=..[F|II],maplist(p2m,[F|II],OO),O=..OO.
% It will break down compound terms into their functor and arguments and apply p2m recursively
p2m(I, O):-
@@ -1104,18 +1110,18 @@
% Define predicates to support the transformation from Prolog to MeTTa syntax
-% (Continuing the translation from Prolog to MeTTa syntax as per the given code)
+% (Continuing the translation from Prolog to MeTTa syntax as per the given code)
% Handle the case where the body is a conjunction of terms
into_sequential(Body, SP) :-
% Check if Body is not a list and convert conjunctions in Body to a list of conjuncts.
- \+ is_list(Body),
- conjuncts_to_list(Body, List), % Converts a list of conjunctions into a sequential representation in MeTTa
+ \+ is_list(Body),
+ conjuncts_to_list(Body, List), % Converts a list of conjunctions into a sequential representation in MeTTa
into_sequential(List, SP), !.
-into_sequential(Nothing,'True'):- Nothing ==[],!.
- % If there's only one element
+into_sequential(Nothing,'True'):- Nothing ==[],!.
+ % If there's only one element
into_sequential([SP],O):- prolog_to_metta(SP,O).
-% Otherwise, construct sequential representation using 'and'.
-into_sequential(List, ['and'|SPList]) :- maplist(prolog_to_metta, List, SPList),!.
+% Otherwise, construct sequential representation using AND.
+into_sequential(List, [AND|SPList]) :- is_compiled_and(CAND),CAND==AND, maplist(prolog_to_metta, List, SPList),!.
@@ -1300,7 +1306,7 @@
% The 'fb0' rule showing mettalog sources with specific definitions.
fb0:- show_mettalog_src((two_pi(R):-(pi(A), +(A, A, B), R is B))).
fb0:- show_mettalog_src(factorial_tail_basic).
-fb0:- show_mettalog_src(funct).
+fb0:- show_mettalog_src(funct).
print_metta_src :- show_mettalog_src.
% 'show_mettalog_src' rule compiles the program and shows mettalog sources for each source file containing 'metta'.
@@ -1338,12 +1344,12 @@
% 'show_cvts' continues processing, performing conversions between predicates and functions,
% and pretty-printing original terms, function forms, and Prolog forms.
-show_cvts(Term):- compound(Term),Term=(_=_),!, ppc(orig,Term),Term = FunctForm,
- functs_to_preds(_RetResult,FunctForm,Prolog), ppc(preds,Prolog),
+show_cvts(Term):- iz_conz(Term),!, ppc(orig,Term),Term = FunctForm,
+ functs_to_preds(FunctForm,Prolog), ppc(preds,Prolog),
preds_to_functs(Prolog,NFunctForm), ppc(functs,NFunctForm).
show_cvts(Term):- ppc(orig,Term),
preds_to_functs(Term,FunctForm), ppc(functs,FunctForm),
- functs_to_preds(_RetResult,FunctForm,Prolog), ppc(preds,Prolog).
+ functs_to_preds(FunctForm,Prolog), ppc(preds,Prolog).
% 'show_mettalog_src' for specific predicate, prints metta clauses if they exist in the source file containing 'metta'.
show_mettalog_src(F,A):- functor(Head,F,A),
@@ -1417,13 +1423,13 @@
with_indents(TF, Goal) :-
% Set the value of the `src_indents` option to TF and then execute the Goal
with_option(src_indents, TF, Goal).
-
+
% The predicate allow_concepts/0 checks whether the use of concepts is allowed.
% It does this by checking the value of the concepts option and ensuring it is not false.
allow_concepts :-
% Check if the option `concepts` is not set to false
- option_else(concepts, TF, true),
- \+ TF == false.
+ option_else(concepts, TF, 'False'),
+ \+ TF == 'False'.
% The predicate with_concepts/2 enables or disables the use of concepts during the execution of a given goal.
% The first argument is a Boolean indicating whether to enable (true) or disable (false) concepts.
@@ -1436,7 +1442,8 @@
% Various 'write_src' and 'write_src0' rules are handling the writing of the source,
% dealing with different types of values, whether they are lists, atoms, numbers, strings, compounds, or symbols.
write_src(V):- notrace(write_src0(V)).
-write_src0(V):- allow_concepts,!,with_concepts(false,write_src1(V)),flush_output.
+write_src0(V):- V ==[],!,write('()').
+write_src0(V):- allow_concepts,!,with_concepts('False',write_src1(V)),flush_output.
write_src0(V):- is_list(V),!,pp_sexi(V).
write_src0(V):- write_src1(V),!.
@@ -1453,7 +1460,8 @@
% Continuing with 'write_src1', 'write_mobj', and related rules,
% handling different cases based on the value�s type and structure, and performing the appropriate writing action.
-write_src1(V):- symbol(V),needs_quoted_in_metta(V,_),!, symbol_string(V,S),writeq(S).
+write_src1(V):- symbol(V), should_quote(V),!,
+ symbol_string(V,S),writeq(S).
write_src1(V):- symbol(V),!,write(V).
write_src1(V):- compound(V), \+ is_list(V),!,write_mobj(V).
write_src1(V):- pp_sex(V),!.
@@ -1463,22 +1471,49 @@
write_mobj(V):- compound_name_list(V,F,Args),write_mobj(F,Args),!.
write_mobj(V):- writeq(V).
-write_mobj(exec,[V]):- !, write('!'),with_indents(true,write_src(V)).
+write_mobj(exec,[V]):- !, write('!'),write_src(V).
+write_mobj('$OBJ',[_,S]):- write('['),write_src(S),write(' ]').
+write_mobj('{...}',[S]):- write('{'),write_src(S),write(' }').
+write_mobj('[...]',[S]):- write('['),write_src(S),write(' ]').
write_mobj('$STRING',[S]):- !, writeq(S).
-write_mobj(F,Args):- mlog_sym(K),pp_sexi([K,F|Args]).
+write_mobj(F,Args):- fail, mlog_sym(K),!,pp_sexi([K,F|Args]).
+write_mobj(F,Args):- pp_sexi([F|Args]).
% Rules for determining when a symbol needs to be quoted in metta.
-needs_quoted_in_metta(H,_):- upcase_atom(H,U),downcase_atom(H,U),!,fail.
-needs_quoted_in_metta('','"').
-needs_quoted_in_metta(V,'"'):- symbol_contains(V," ").
-needs_quoted_in_metta(V,'"'):- symbol_contains(V,"/").
-needs_quoted_in_metta(V,'"'):- symbol_contains(V,'"').
-needs_quoted_in_metta(V,'"'):- symbol_contains(V,'"').
-needs_quoted_in_metta(V,'"'):- symbol_contains(V,',').
-%needs_quoted_in_metta(V,"'"):- symbol_length(V,L),L==1.
-%needs_quoted_in_metta(V,"'"):- symbol_contains(V,")").
-needs_quoted_in_metta(V,'"'):- symbol_contains(V,"|").
-needs_quoted_in_metta(V,'"'):- symbol_contains(V,"'").
+
+dont_quote(Atom):- atom(Atom),upcase_atom(Atom,Atom),downcase_atom(Atom,Atom).
+
+should_quote(Atom) :- \+ atom(Atom), \+ string(Atom),!,fail.
+should_quote(Atom) :-
+ \+ dont_quote(Atom),
+ % atom(Atom), % Ensure that the input is an atom
+ atom_chars(Atom, Chars),
+ once(should_quote_chars(Chars);should_quote_atom_chars(Atom,Chars)).
+
+contains_unescaped_quote(['"']):- !, fail. % End with a quote
+contains_unescaped_quote(['"'|_]) :- !.
+contains_unescaped_quote(['\\', '"'|T]) :- !, contains_unescaped_quote(T).
+contains_unescaped_quote([_|T]) :- contains_unescaped_quote(T).
+
+% Check if the list of characters should be quoted based on various conditions
+should_quote_chars([]).
+should_quote_chars(['"'|Chars]):- !, contains_unescaped_quote(Chars).
+should_quote_chars(Chars) :-
+ member('"', Chars); % Contains quote not captured with above clause
+ member(' ', Chars); % Contains space
+ member('''', Chars); % Contains single quote
+ member('/', Chars); % Contains slash
+ member(',', Chars); % Contains comma
+ member('|', Chars). % Contains pipe
+should_quote_atom_chars(Atom,_) :- atom_number(Atom,_),!.
+should_quote_atom_chars(Atom,[Digit|_]) :- char_type(Digit, digit), \+ atom_number(Atom,_).
+
+% Example usage:
+% ?- should_quote('123abc').
+% true.
+% ?- should_quote('123.456').
+% false.
+
% =========================================
% STERM -> PTERM
@@ -1513,6 +1548,11 @@
sexpr_s2p(_Fn,_Nth,'#'(S),P):- iz_exact_symbol(S,P),!.
sexpr_s2p(_Fn,_Nth,VAR,'$VAR'(Name)):- atom(VAR),svar(VAR,Name),!.
sexpr_s2p(Fn,Nth,S,P):- S==[], iz_fun_argz(Fn,Nth),!,P=S.
+
+sexpr_s2p(Fn,Nth,S,P):- expects_type(Fn,Nth,Type),will_become_type(Type,S,P),!.
+
+sexpr_s2p(Fn,Nth,[F|SList],P):- is_list(SList), length(SList,Len),is_syspred(F,Len,Pred), sexpr_s2p_arglist(F,1,SList,PList), !, P=..[Pred|PList].
+
sexpr_s2p(Fn,Nth,[S|SList],[P|PList]):- iz_fun_argz(Fn,Nth),!,sexpr_s2p(S,P), sexpr_s2p(Fn,Nth,SList,PList).
sexpr_s2p(Fn,Nth,[S|SList],[P|PList]):- ( \+ atom(S) ; \+ is_list(SList)), !,sexpr_s2p(list(Fn),Nth,S,P), sexpr_s2p(list(Fn),Nth,SList,PList).
sexpr_s2p(_Fn,_Nth,[S,STERM0],PTERM):- iz_quoter(S),sexpr_s2p_pre_list(S,0,STERM0,STERM), !,PTERM=..[S,STERM],!.
@@ -1526,7 +1566,7 @@
zalwayz((sexpr_s2p_arglist(Fn,Nth,TERM,PLIST),
PTERM =~ [S,Vars|PLIST])),!.
*/
-% sexpr_s2p(progn,_,[S|TERM],PTERM):- S=='and',!,zalwayz((maplist(sexpr_s2p,TERM,PLIST),list_to_conjuncts(',',PLIST,PTERM))).
+% sexpr_s2p(progn,_,[S|TERM],PTERM):- S==AND,!,zalwayz((maplist(sexpr_s2p,TERM,PLIST),list_to_conjuncts(',',PLIST,PTERM))).
%sexpr_s2p(Fn,Nth,[S|TERM],PTERM):- (number(S); (atom(S),fail,atom_concat_or_rtrace(_,'Fn',S))),sexpr_s2p_arglist(Fn,Nth,[S|TERM],PTERM),!.
%sexpr_s2p(Fn,Nth,[S],O):- is_ftVar(S),sexpr_s2p(Fn,Nth,S,Y),!,z_univ(Fn,Nth,O,[Y]),!.
%sexpr_s2p(Fn,Nth,[S],O):- nonvar(S),sexpr_s2p(Fn,Nth,S,Y),!,z_univ(Fn,Nth,O,[Y]),!.
@@ -1539,6 +1579,21 @@
sexpr_s2p_arglist(S,1,STERM,PLIST), z_univ(Fn,Nth,PTERM,[S|PLIST]),!.
sexpr_s2p(_Fn,_Nth,VAR,VAR).
+
+expects_type(Fn,Nth,Type):-
+ get_operator_typedef(Self,Fn,Params,RetType),
+ nth0(Nth,[RetType|Params],Type),nonvar(Type).
+
+will_become_type(Type,S,P):- try_adjust_arg_types(_RetType,88,_Self,[Type],[S],[PS]),PS=P,!.
+will_become_type(Type,S,P):- is_ftVar(S),!,P=S.
+will_become_type(Type,S,P):-
+ get_type(S,T),!,
+ (is_subtype(T,Type)->S=P; P=coerce(Type,S)).
+will_become_type(_Type,S,P):-!,S=P.
+
+is_subtype(T,TT):- T=@=TT,!,T=TT.
+is_subtype(T,TT):- T=TT,!.
+
iz_quoter('#BQ'):- iz_common_lisp.
iz_quoter('#COMMA'):- iz_common_lisp.
iz_quoter('quote').
@@ -1549,6 +1604,7 @@
iz_fun_argz(defun,2).
iz_fun_argz(let,1).
iz_fun_argz('let*',1).
+iz_fun_argz('member',2).
%iz_fun_argz('let*',2).
iz_fun_argz(F,1):- iz_quoter(F).
diff --git a/metta_vspace/pyswip/metta_data.pl b/metta_vspace/pyswip/metta_data.pl
old mode 100644
new mode 100755
index 9eedab3e..58c5b374
--- a/metta_vspace/pyswip/metta_data.pl
+++ b/metta_vspace/pyswip/metta_data.pl
@@ -171,16 +171,22 @@
state_decltype(Expr,Type):- functor(Expr,_,A),arg(A,Expr,Type),once(var(Type);is_decl_type(Type)).
+
get_type1(_Dpth,_Slf,Var,'%Undefined%'):- var(Var),!.
get_type1(_Dpth,_Slf,Val,'Number'):- number(Val),!.
get_type1(Depth,Self,Expr,['StateMonad',Type]):- is_valid_nb_state(Expr),'get-state'(Expr,Val),!,
get_type1(Depth,Self,Val,Type).
-get_type1(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),eval_args(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
+
+
+get_type1(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),
+ eval_args(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
get_type1(Depth,Self,Val,Type).
+
get_type1(_Dpth,Self,[Fn|_],Type):- symbol(Fn),metta_type(Self,Fn,List),last_element(List,Type), nonvar(Type),
is_type(Type).
get_type1(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,List,LType),last_element(LType,Type), nonvar(Type),
is_type(Type).
+
get_type1(Depth,_Slf,Type,Type):- Depth<1,!.
get_type1(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,Type,['->'|List]).
get_type1(Depth,Self,List,Types):- List\==[], is_list(List),Depth2 is Depth-1,maplist(get_type1(Depth2,Self),List,Types).
@@ -188,7 +194,11 @@
%get_type1(Depth,Self,Fn,Type):- nonvar(Fn),metta_type(Self,Fn,Type2),Depth2 is Depth-1,get_type1(Depth2,Self,Type2,Type).
%get_type1(Depth,Self,Fn,Type):- Depth>0,nonvar(Fn),metta_type(Self,Type,Fn),!. %,!,last_element(List,Type).
-get_type1(Depth,Self,Expr,Type):-Depth2 is Depth-1, eval_args(Depth2,Self,Expr,Val),Expr\=@=Val,get_type1(Depth2,Self,Val,Type).
+get_type1(Depth,Self,Expr,Type):-Depth2 is Depth-1,
+ eval_args(Depth2,Self,Expr,Val),
+ Expr\=@=Val,get_type1(Depth2,Self,Val,Type).
+
+
get_type1(_Dpth,_Slf,Val,'String'):- string(Val),!.
get_type1(_Dpth,_Slf,Val,Type):- is_decl_type(Val),Type=Val.
get_type1(_Dpth,_Slf,Val,'Bool'):- (Val=='False';Val=='True'),!.
@@ -211,6 +221,9 @@
adjust_args(_Dpth,Self,F,X,X):- (is_special_op(Self,F); \+ iz_conz(X)),!.
adjust_args(Depth,Self,Op,X,Y):-
get_operator_typedef(Self,Op,Params,RetType),
+ try_adjust_arg_types(RetType,Depth,Self,Params,X,Y).
+
+try_adjust_arg_types(RetType,Depth,Self,Params,X,Y):-
as_prolog(Depth,Self,X,M),
args_conform(Depth,Self,M,Params),!,
set_type(Depth,Self,Y,RetType),
@@ -255,9 +268,6 @@
is_pro_eval_kind('Symbol').
is_pro_eval_kind('Bool').
-
-
-
is_feo_f('Cons').
is_seo_f('{...}').
@@ -270,7 +280,6 @@
is_seo_f('Concept').
is_seo_f(N):- number(N),!.
-
%is_user_defined_goal(Self,[H|_]):- is_user_defined_head(Self,H).
is_user_defined_head(Other,H):- mnotrace(is_user_defined_head0(Other,H)).
diff --git a/metta_vspace/pyswip/metta_eval.pl b/metta_vspace/pyswip/metta_eval.pl
index 42102411..51d835cf 100755
--- a/metta_vspace/pyswip/metta_eval.pl
+++ b/metta_vspace/pyswip/metta_eval.pl
@@ -59,31 +59,33 @@
eval_args(X,Y):- current_self(Space), eval_args(100,Space,X,Y).
-eval_args(Depth,Self,X,Y):- eval_args0(Depth,Self,X,Y).
-eval_args(Expander,RetType,Depth,Self,X,Y):- eval_args0(Expander,RetType,Depth,Self,X,Y).
+eval_args(Depth,Self,X,Y):-
+ eval(Depth,Self,X,Y).
+eval_args(Expander,RetType,Depth,Self,X,Y):-
+ eval(Expander,RetType,Depth,Self,X,Y).
-%eval_args0(Expander,RetType,Depth,_Self,X,_Y):- forall(between(6,Depth,_),write(' ')),writeqln(eval_args0(Expander,RetType,X)),fail.
-eval_args0(Depth,Self,X,Y):- eval_args0('=',_RetType,Depth,Self,X,Y).
+%eval(Expander,RetType,Depth,_Self,X,_Y):- forall(between(6,Depth,_),write(' ')),writeqln(eval(Expander,RetType,X)),fail.
+eval(Depth,Self,X,Y):- eval('=',_RetType,Depth,Self,X,Y).
-%eval_args0(Expander,RetType,_Dpth,_Slf,X,Y):- nonvar(Y),X=Y,!.
+%eval(Expander,RetType,_Dpth,_Slf,X,Y):- nonvar(Y),X=Y,!.
-eval_args0(Expander,RetType,Depth,Self,X,Y):- nonvar(Y),!,
+eval(Expander,RetType,Depth,Self,X,Y):- nonvar(Y),!,
get_type(Depth,Self,Y,RetType), !,
- eval_args0(Expander,RetType,Depth,Self,X,XX),evals_to(XX,Y).
+ eval(Expander,RetType,Depth,Self,X,XX),evals_to(XX,Y).
-eval_args0(_Expander,_RetType,_Dpth,_Slf,X,Y):- var(X),!,Y=X.
+eval(_Expander,_RetType,_Dpth,_Slf,X,Y):- var(X),!,Y=X.
-eval_args0(Expander,RetType,_Dpth,_Slf,[X|T],Y):- T==[], number(X),!, do_expander(Expander,RetType,X,YY),Y=[YY].
+eval(Expander,RetType,_Dpth,_Slf,[X|T],Y):- T==[], number(X),!, do_expander(Expander,RetType,X,YY),Y=[YY].
-eval_args0(Expander,RetType,Depth,Self,[F|X],Y):-
+eval(Expander,RetType,Depth,Self,[F|X],Y):-
(F=='superpose' ; ( option_value(no_repeats,false))),
notrace((D1 is Depth-1)),!,
- eval_args00(Expander,RetType,D1,Self,[F|X],Y).
+ eval_00(Expander,RetType,D1,Self,[F|X],Y).
-eval_args0(Expander,RetType,Depth,Self,X,Y):-
+eval(Expander,RetType,Depth,Self,X,Y):-
mnotrace((no_repeats_var(YY),
D1 is Depth-1)),
- eval_args00(Expander,RetType,D1,Self,X,Y),
+ eval_00(Expander,RetType,D1,Self,X,Y),
mnotrace(( \+ (Y\=YY))).
@@ -140,14 +142,14 @@
:- nodebug(metta(overflow)).
-eval_args99(Expander,RetType,Depth,Self,X,Y):- eval_args0(Expander,RetType,Depth,Self,X,Y)*->true;eval_args_failed(Depth,Self,X,Y).
+eval_99(Expander,RetType,Depth,Self,X,Y):- eval(Expander,RetType,Depth,Self,X,Y)*->true;eval_args_failed(Depth,Self,X,Y).
-eval_args00(_Expander,_RetType,Depth,_Slf,X,Y):- Depth<1,!,X=Y, (\+ trace_on_overflow-> true; flag(eval_num,_,0),debug(metta(eval))).
-%eval_args00(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval0(X),!,Y=X.
-eval_args00(Expander,RetType,Depth,Self,X,YO):-
+eval_00(_Expander,_RetType,Depth,_Slf,X,Y):- Depth<1,!,X=Y, (\+ trace_on_overflow-> true; flag(eval_num,_,0),debug(metta(eval))).
+%eval_00(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval0(X),!,Y=X.
+eval_00(Expander,RetType,Depth,Self,X,YO):-
( Depth2 is Depth-1,
eval_args11(Expander,RetType,Depth,Self,X,M),
- (M\=@=X ->eval_args00(Expander,RetType,Depth2,Self,M,Y);Y=X)),
+ (M\=@=X ->eval_00(Expander,RetType,Depth2,Self,M,Y);Y=X)),
eval_args_finish(Depth2,Self,Y,YO).
@@ -155,7 +157,7 @@
eval_args11(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,do_expander(Expander,RetType,X,Y).
eval_args11(Expander,RetType,Depth,Self,X,Y):- \+ is_debugging((eval)),!,
D1 is Depth-1,
- eval_args20(Expander,RetType,D1,Self,X,Y).
+ eval_20(Expander,RetType,D1,Self,X,Y).
eval_args11(Expander,RetType,Depth,Self,X,Y):-
notrace((
@@ -169,10 +171,10 @@
if_trace((eval),indentq(Depth,'-->'(EX,eval(Self,X,'$VAR'('RET')),depth(DR)))),
Ret=retval(fail))),
call_cleanup((
- eval_args20(Expander,RetType,D1,Self,X,Y),
+ eval_20(Expander,RetType,D1,Self,X,Y),
notrace(( \+ (Y\=YY), nb_setarg(1,Ret,Y)))),
mnotrace(ignore(((Y\=@=X,if_trace((eval),indentq(Depth,'<--'(EX,Ret)))))))),
- (Ret\=@=retval(fail)->true;(rtrace(eval_args00(Expander,RetType,D1,Self,X,Y)),fail)).
+ (Ret\=@=retval(fail)->true;(rtrace(eval_00(Expander,RetType,D1,Self,X,Y)),fail)).
@@ -194,13 +196,13 @@
-:- discontiguous eval_args20/6.
-%:- discontiguous eval_args40/6.
+:- discontiguous eval_20/6.
+%:- discontiguous eval_40/6.
%:- discontiguous eval_args30fz/5.
%:- discontiguous eval_args31/5.
-%:- discontiguous eval_args60/5.
+%:- discontiguous eval_60/5.
-eval_args20(Expander,RetType,_Dpth,_Slf,Name,Y):-
+eval_20(Expander,RetType,_Dpth,_Slf,Name,Y):-
atom(Name), nb_current(Name,X),!,do_expander(Expander,RetType,X,Y).
@@ -222,16 +224,16 @@
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,_Dpth,_Slf,[X|T],Y):- T==[], \+ callable(X),!, do_expander(Expander,RetType,X,YY),Y=[YY].
+eval_20(Expander,RetType,_Dpth,_Slf,[X|T],Y):- T==[], \+ callable(X),!, do_expander(Expander,RetType,X,YY),Y=[YY].
-eval_args20(Expander,RetType,Depth,Self,[V|VI],VVO):- \+ is_list(VI),!,
- eval_args0(Expander,RetType,Depth,Self,VI,VM),
- ( VM\==VI -> eval_args0(Expander,RetType,Depth,Self,[V|VM],VVO) ;
- (eval_args0(Expander,RetType,Depth,Self,V,VV), (V\==VV -> eval_args0(Expander,RetType,Depth,Self,[VV|VI],VVO) ; VVO = [V|VI]))).
+eval_20(Expander,RetType,Depth,Self,[V|VI],VVO):- \+ is_list(VI),!,
+ eval(Expander,RetType,Depth,Self,VI,VM),
+ ( VM\==VI -> eval(Expander,RetType,Depth,Self,[V|VM],VVO) ;
+ (eval(Expander,RetType,Depth,Self,V,VV), (V\==VV -> eval(Expander,RetType,Depth,Self,[VV|VI],VVO) ; VVO = [V|VI]))).
-eval_args20(Expander,RetType,_Dpth,_Slf,X,Y):- \+ is_list(X),!,do_expander(Expander,RetType,X,Y).
+eval_20(Expander,RetType,_Dpth,_Slf,X,Y):- \+ is_list(X),!,do_expander(Expander,RetType,X,Y).
-eval_args20(Expander,_RetType,Depth,Self,[V|VI],[V|VO]):- var(V),is_list(VI),!,maplist(eval_args0(Expander,_ArgRetType,Depth,Self),VI,VO).
+eval_20(Expander,_RetType,Depth,Self,[V|VI],[V|VO]):- var(V),is_list(VI),!,maplist(eval(Expander,_ArgRetType,Depth,Self),VI,VO).
% =================================================================
@@ -242,35 +244,35 @@
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,_Dpth,_Slf,['repl!'],Y):- !, repl,check_returnval(Expander,RetType,Y).
-eval_args20(Expander,RetType,Depth,Self,['!',Cond],Res):- !, call(eval_args0(Expander,RetType,Depth,Self,Cond,Res)).
-eval_args20(Expander,RetType,Depth,Self,['rtrace',Cond],Res):- !, rtrace(eval_args0(Expander,RetType,Depth,Self,Cond,Res)).
-eval_args20(Expander,RetType,Depth,Self,['trace',Cond],Res):- !, with_debug(eval,eval_args0(Expander,RetType,Depth,Self,Cond,Res)).
-eval_args20(Expander,RetType,Depth,Self,['time',Cond],Res):- !, time_eval(eval(Cond),eval_args0(Expander,RetType,Depth,Self,Cond,Res)).
-eval_args20(Expander,RetType,Depth,Self,['print',Cond],Res):- !, eval_args0(Expander,RetType,Depth,Self,Cond,Res),format('~N'),print(Res),format('~N').
+eval_20(Expander,RetType,_Dpth,_Slf,['repl!'],Y):- !, repl,check_returnval(Expander,RetType,Y).
+eval_20(Expander,RetType,Depth,Self,['!',Cond],Res):- !, call(eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['rtrace!',Cond],Res):- !, rtrace(eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['trace',Cond],Res):- !, with_debug(eval,eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['time',Cond],Res):- !, time_eval(eval(Cond),eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['print',Cond],Res):- !, eval(Expander,RetType,Depth,Self,Cond,Res),format('~N'),print(Res),format('~N').
% !(println! $1)
-eval_args20(Expander,RetType,Depth,Self,['println!'|Cond],Res):- !, maplist(eval_args0(Expander,RetType,Depth,Self),Cond,[Res|Out]),
+eval_20(Expander,RetType,Depth,Self,['println!'|Cond],Res):- !, maplist(eval(Expander,RetType,Depth,Self),Cond,[Res|Out]),
format('~N'),maplist(write_src,[Res|Out]),format('~N').
-eval_args20(Expander,RetType,Depth,Self,['trace!',A|Cond],Res):- !, maplist(eval_args0(Expander,RetType,Depth,Self),[A|Cond],[AA|Result]),
+eval_20(Expander,RetType,Depth,Self,['trace!',A|Cond],Res):- !, maplist(eval(Expander,RetType,Depth,Self),[A|Cond],[AA|Result]),
last(Result,Res), format('~N'),maplist(write_src,[AA]),format('~N').
-%eval_args20(Expander,RetType,Depth,Self,['trace!',A,B],C):- !,eval_args0(Expander,RetType,Depth,Self,B,C),format('~N'),wdmsg(['trace!',A,B]=C),format('~N').
-%eval_args20(Expander,RetType,_Dpth,_Slf,['trace!',A],A):- !, format('~N'),wdmsg(A),format('~N').
+%eval_20(Expander,RetType,Depth,Self,['trace!',A,B],C):- !,eval(Expander,RetType,Depth,Self,B,C),format('~N'),wdmsg(['trace!',A,B]=C),format('~N').
+%eval_20(Expander,RetType,_Dpth,_Slf,['trace!',A],A):- !, format('~N'),wdmsg(A),format('~N').
-eval_args20(Expander,RetType,_Dpth,_Slf,List,YY):- is_list(List),maplist(self_eval,List),List=[H|_], \+ atom(H), !,Y=List,do_expander(Expander,RetType,Y,YY).
+eval_20(Expander,RetType,_Dpth,_Slf,List,YY):- is_list(List),maplist(self_eval,List),List=[H|_], \+ atom(H), !,Y=List,do_expander(Expander,RetType,Y,YY).
-eval_args20(Expander,_ListOfRetType,Depth,Self,['TupleConcat',A,B],OO):- fail, !,
- eval_args0(Expander,RetType,Depth,Self,A,AA),
- eval_args0(Expander,RetType,Depth,Self,B,BB),
+eval_20(Expander,_ListOfRetType,Depth,Self,['TupleConcat',A,B],OO):- fail, !,
+ eval(Expander,RetType,Depth,Self,A,AA),
+ eval(Expander,RetType,Depth,Self,B,BB),
append(AA,BB,OO).
-eval_args20(Expander,OuterRetType,Depth,Self,['range',A,B],OO):- (is_list(A);is_list(B)),
- ((eval_args0(Expander,RetType,Depth,Self,A,AA),
- eval_args0(Expander,RetType,Depth,Self,B,BB))),
+eval_20(Expander,OuterRetType,Depth,Self,['range',A,B],OO):- (is_list(A);is_list(B)),
+ ((eval(Expander,RetType,Depth,Self,A,AA),
+ eval(Expander,RetType,Depth,Self,B,BB))),
((AA+BB)\=@=(A+B)),
- eval_args20(Expander,OuterRetType,Depth,Self,['range',AA,BB],OO),!.
+ eval_20(Expander,OuterRetType,Depth,Self,['range',AA,BB],OO),!.
-%eval_args20(Expander,RetType,Depth,Self,['colapse'|List], Flat):- !, maplist(eval_args0(Expander,RetType,Depth,Self),List,Res),flatten(Res,Flat).
+%eval_20(Expander,RetType,Depth,Self,['colapse'|List], Flat):- !, maplist(eval(Expander,RetType,Depth,Self),List,Res),flatten(Res,Flat).
@@ -284,24 +286,24 @@
% =================================================================
-eval_args20(Expander,RetType,Depth,Self,['assertTrue', X],TF):- !, eval_args0(Expander,RetType,Depth,Self,['assertEqual',X,'True'],TF).
-eval_args20(Expander,RetType,Depth,Self,['assertFalse',X],TF):- !, eval_args0(Expander,RetType,Depth,Self,['assertEqual',X,'False'],TF).
+eval_20(Expander,RetType,Depth,Self,['assertTrue', X],TF):- !, eval(Expander,RetType,Depth,Self,['assertEqual',X,'True'],TF).
+eval_20(Expander,RetType,Depth,Self,['assertFalse',X],TF):- !, eval(Expander,RetType,Depth,Self,['assertEqual',X,'False'],TF).
-eval_args20(Expander,RetType,Depth,Self,['assertEqual',X,Y],RetVal):- !,
+eval_20(Expander,RetType,Depth,Self,['assertEqual',X,Y],RetVal):- !,
loonit_assert_source_tf(
['assertEqual',X,Y],
(bagof_eval(Expander,RetType,Depth,Self,X,XX), bagof_eval(Expander,RetType,Depth,Self,Y,YY)),
equal_enough_for_test(XX,YY), TF),
(TF=='True'->return_empty(RetVal);RetVal=[got,XX,[expected(_)],YY]).
-eval_args20(Expander,RetType,Depth,Self,['assertNotEqual',X,Y],RetVal):- !,
+eval_20(Expander,RetType,Depth,Self,['assertNotEqual',X,Y],RetVal):- !,
loonit_assert_source_tf(
['assertEqual',X,Y],
(bagof_eval(Expander,RetType,Depth,Self,X,XX), bagof_eval(Expander,RetType,Depth,Self,Y,YY)),
\+ equal_enough(XX,YY), TF),
(TF=='True'->return_empty(RetVal);RetVal=[got,XX,expected,YY]).
-eval_args20(Expander,RetType,Depth,Self,['assertEqualToResult',X,Y],RetVal):- !,
+eval_20(Expander,RetType,Depth,Self,['assertEqualToResult',X,Y],RetVal):- !,
loonit_assert_source_tf(
['assertEqualToResult',X,Y],
(bagof_eval(Expander,RetType,Depth,Self,X,XX), sort(Y,YY)),
@@ -382,25 +384,25 @@
% =================================================================
% do_metta(_Who,What,Where,PredDecl,_TF):- do_metta(Where,What, PredDecl).
/*
-eval_args20(Expander,RetType,_Dpth,Self,['add-atom',Other,PredDecl],TF):- !, into_space(Self,Other,Space), as_tf(do_metta(Space,load,PredDecl),TF).
-eval_args20(Expander,RetType,_Dpth,Self,['remove-atom',Other,PredDecl],TF):- !, into_space(Self,Other,Space), as_tf(do_metta(Space,unload,PredDecl),TF).
-eval_args20(Expander,RetType,_Dpth,Self,['atom-count',Other],Count):- !, into_space(Self,Other,Space), findall(_,metta_defn(Other,_,_),L1),length(L1,C1),findall(_,metta_atom(Space,_),L2),length(L2,C2),Count is C1+C2.
-eval_args20(Expander,RetType,_Dpth,Self,['atom-replace',Other,Rem,Add],TF):- !, into_space(Self,Other,Space), copy_term(Rem,RCopy),
+eval_20(Expander,RetType,_Dpth,Self,['add-atom',Other,PredDecl],TF):- !, into_space(Self,Other,Space), as_tf(do_metta(Space,load,PredDecl),TF).
+eval_20(Expander,RetType,_Dpth,Self,['remove-atom',Other,PredDecl],TF):- !, into_space(Self,Other,Space), as_tf(do_metta(Space,unload,PredDecl),TF).
+eval_20(Expander,RetType,_Dpth,Self,['atom-count',Other],Count):- !, into_space(Self,Other,Space), findall(_,metta_defn(Other,_,_),L1),length(L1,C1),findall(_,metta_atom(Space,_),L2),length(L2,C2),Count is C1+C2.
+eval_20(Expander,RetType,_Dpth,Self,['atom-replace',Other,Rem,Add],TF):- !, into_space(Self,Other,Space), copy_term(Rem,RCopy),
as_tf((metta_atom_iter_ref(Space,RCopy,Ref), RCopy=@=Rem,erase(Ref), do_metta(Other,load,Add)),TF).
*/
-eval_args20(Expander,RetType,Depth,Self,['add-atom',Other,PredDecl],Res):- !,
+eval_20(Expander,RetType,Depth,Self,['add-atom',Other,PredDecl],Res):- !,
into_space(Depth,Self,Other,Space),
do_metta(python,load,Space,PredDecl,TF),return_empty([],Res),check_returnval(Expander,RetType,TF).
-eval_args20(Expander,RetType,Depth,Self,['remove-atom',Other,PredDecl],Res):- !, into_space(Depth,Self,Other,Space),
+eval_20(Expander,RetType,Depth,Self,['remove-atom',Other,PredDecl],Res):- !, into_space(Depth,Self,Other,Space),
do_metta(python,unload,Space,PredDecl,TF),return_empty([],Res),check_returnval(Expander,RetType,TF).
-eval_args20(Expander,RetType,Depth,Self,['atom-count',Other],Count):- !, (( into_space(Depth,Self,Other,Space), findall(_,metta_defn(Other,_,_),L1),length(L1,C1),
+eval_20(Expander,RetType,Depth,Self,['atom-count',Other],Count):- !, (( into_space(Depth,Self,Other,Space), findall(_,metta_defn(Other,_,_),L1),length(L1,C1),
findall(_,metta_atom(Space,_),L2),length(L2,C2),Count is C1+C2)),check_returnval(Expander,RetType,Count).
-eval_args20(Expander,RetType,Depth,Self,['atom-replace',Other,Rem,Add],TF):- !,
+eval_20(Expander,RetType,Depth,Self,['atom-replace',Other,Rem,Add],TF):- !,
((into_space(Depth,Self,Other,Space), copy_term(Rem,RCopy),
as_tf((metta_atom_iter_ref(Space,RCopy,Ref), RCopy=@=Rem,erase(Ref), do_metta(Other,load,Add)),TF))),
check_returnval(Expander,RetType,TF).
-eval_args20(Expander,RetType,Depth,Self,['get-atoms',Other],Atom):- !,
+eval_20(Expander,RetType,Depth,Self,['get-atoms',Other],Atom):- !,
ignore(RetType='Atom'),
get_atoms(Depth,Self,Other,Atom), check_returnval(Expander,RetType,Atom).
@@ -419,15 +421,15 @@
space_to_Space(Depth,Self,Space,SpaceC):- findall(Atom, metta_atom_iter(Depth,Self,Space,Atom),Atoms),
SpaceC = 'hyperon::space::DynSpace'(Atoms).
-%eval_args20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Template):- into_space(Self,Other,Space),!, metta_atom_iter(Depth,Space,Goal).
-%eval_args20(Expander,RetType,Depth,Self,['match',Other,Goal,Template,Else],Template):- into_space(Self,Other,Space),!, (metta_atom_iter(Depth,Space,Goal)*->true;Else=Template).
+%eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Template):- into_space(Self,Other,Space),!, metta_atom_iter(Depth,Space,Goal).
+%eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template,Else],Template):- into_space(Self,Other,Space),!, (metta_atom_iter(Depth,Space,Goal)*->true;Else=Template).
% Match-ELSE
-eval_args20(Expander,RetType,Depth,Self,['match',Other,Goal,Template,Else],Template):- !,
- ((eval_args20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Template),
+eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template,Else],Template):- !,
+ ((eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Template),
\+ return_empty([],Template))*->true;Template=Else).
% Match-TEMPLATE
-eval_args20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Res):- !,
+eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Res):- !,
dcall(( % copy_term(Goal+Template,CGoal+CTemplate),
catch(get_atoms(Depth,Self,Other,Goal),E,
(wdmsg(catch(get_atoms(Depth,Self,Other,Goal)=E)),
@@ -440,7 +442,7 @@
try_ma tch(Expander,RetType,Depth,Self,Other,Goal,Template,Res):- fail,
into_space(Depth,Self,Other,Space),
metta_atom_iter(Depth,Self,Space,Goal),
- eval_args99(Expander,RetType,Depth,Self,Template,Res).
+ eval_99(Expander,RetType,Depth,Self,Template,Res).
*/
try_match(Depth,Self,Other,Goal,_Template):-
@@ -471,7 +473,7 @@
%metta_atom_iter_l2(Depth,Self,Other,H):- metta_atom_iter(Depth,Self,Other,H).
%$metta_atom_iter(_Dpth,_Slf,[]):-!.
-eval_args20(Expander,RetType,_Dpth,_Slf,['new-space'],Space):- !, 'new-space'(Space),check_returnval(Expander,RetType,Space).
+eval_20(Expander,RetType,_Dpth,_Slf,['new-space'],Space):- !, 'new-space'(Space),check_returnval(Expander,RetType,Space).
/*
@@ -505,18 +507,18 @@
% =================================================================
% Macro: case
-eval_args20(Expander,RetType,Depth,Self,['case',A,CL|T],Res):-
+eval_20(Expander,RetType,Depth,Self,['case',A,CL|T],Res):-
must_det_ll(T==[]),
into_case_list(CL,CASES),
findall(Key-Value,
(nth0(Nth,CASES,Case0),
(is_case(Key,Case0,Value),
if_trace(metta(case),(format('~N'),writeqln(c(Nth,Key)=Value))))),KVs),!,
- ((eval_args0(Expander,RetType,Depth,Self,A,AA),
+ ((eval(Expander,RetType,Depth,Self,A,AA),
if_trace(metta(case),writeqln(switch=AA)),
(select_case(Depth,Self,AA,KVs,Value)->true;(member(Void -Value,KVs),Void=='%void%')))
*->true;(member(Void -Value,KVs),Void=='%void%')),
- eval_args0(Expander,RetType,Depth,Self,Value,Res).
+ eval(Expander,RetType,Depth,Self,Value,Res).
select_case(Depth,Self,AA,Cases,Value):-
(best_key(AA,Cases,Value) -> true ;
@@ -535,7 +537,7 @@
is_case(AA,[AA|Value],Value).
maybe_special_keys(Depth,Self,[K-V|KVI],[AK-V|KVO]):-
- eval_args0(Depth,Self,K,AK), K\=@=AK,!,
+ eval(Depth,Self,K,AK), K\=@=AK,!,
maybe_special_keys(Depth,Self,KVI,KVO).
maybe_special_keys(Depth,Self,[_|KVI],KVO):-
maybe_special_keys(Depth,Self,KVI,KVO).
@@ -553,18 +555,18 @@
%[collapse,[1,2,3]]
-eval_args20(Expander,RetType,Depth,Self,['collapse',List],Res):-!,
+eval_20(Expander,RetType,Depth,Self,['collapse',List],Res):-!,
bagof_eval(Expander,RetType,Depth,Self,List,Res).
%[superpose,[1,2,3]]
-eval_args20(Expander,RetType,Depth,Self,['superpose',List],Res):- !,
- ((is_user_defined_goal(Self,List) ,eval_args0(Expander,RetType,Depth,Self,List,UList), List\=@=UList)
- *-> eval_args20(Expander,RetType,Depth,Self,['superpose',UList],Res)
- ; ((member(E,List),eval_args0(Expander,RetType,Depth,Self,E,Res))*->true;return_empty([],Res))).
+eval_20(Expander,RetType,Depth,Self,['superpose',List],Res):- !,
+ ((is_user_defined_goal(Self,List) ,eval(Expander,RetType,Depth,Self,List,UList), List\=@=UList)
+ *-> eval_20(Expander,RetType,Depth,Self,['superpose',UList],Res)
+ ; ((member(E,List),eval(Expander,RetType,Depth,Self,E,Res))*->true;return_empty([],Res))).
%[sequential,[1,2,3]]
-eval_args20(Expander,RetType,Depth,Self,['sequential',List],Res):- !,
- eval_args20(Expander,RetType,Depth,Self,['superpose',List],Res).
+eval_20(Expander,RetType,Depth,Self,['sequential',List],Res):- !,
+ eval_20(Expander,RetType,Depth,Self,['superpose',List],Res).
get_sa_p1(P3,E,Cmpd,SA):- compound(Cmpd), get_sa_p2(P3,E,Cmpd,SA).
get_sa_p2(P3,E,Cmpd,call(P3,N1,Cmpd)):- arg(N1,Cmpd,E).
@@ -575,7 +577,7 @@
call(P1,Var))), !,
%max_counting(F,20),
member(Var,List),
- eval_args0(Expander,RetType,Depth,Self, Term, Res).
+ eval(Expander,RetType,Depth,Self, Term, Res).
sub_sterm(Sub,Sub).
@@ -588,7 +590,7 @@
mnotrace(( get_sa_p1(setarg,ST,Term,P1),
compound(ST), ST = [F,List],F=='collapse',nonvar(List), %maplist(atomic,List),
call(P1,Var))), !, bagof_eval(Expander,RetType,Depth,Self,List,Var),
- eval_args0(Expander,RetType,Depth,Self, Term, Res).
+ eval(Expander,RetType,Depth,Self, Term, Res).
max_counting(F,Max):- flag(F,X,X+1), X true; (flag(F,_,10),!,fail).
@@ -602,30 +604,30 @@
-eval_args20(Expander,RetType,Depth,Self,['if',Cond,Then,Else],Res):- !,
- eval_args0(Expander,'Bool',Depth,Self,Cond,TF),
+eval_20(Expander,RetType,Depth,Self,['if',Cond,Then,Else],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
(is_True(TF)
- -> eval_args0(Expander,RetType,Depth,Self,Then,Res)
- ; eval_args0(Expander,RetType,Depth,Self,Else,Res)).
+ -> eval(Expander,RetType,Depth,Self,Then,Res)
+ ; eval(Expander,RetType,Depth,Self,Else,Res)).
-eval_args20(Expander,RetType,Depth,Self,['If',Cond,Then,Else],Res):- !,
- eval_args0(Expander,'Bool',Depth,Self,Cond,TF),
+eval_20(Expander,RetType,Depth,Self,['If',Cond,Then,Else],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
(is_True(TF)
- -> eval_args0(Expander,RetType,Depth,Self,Then,Res)
- ; eval_args0(Expander,RetType,Depth,Self,Else,Res)).
+ -> eval(Expander,RetType,Depth,Self,Then,Res)
+ ; eval(Expander,RetType,Depth,Self,Else,Res)).
-eval_args20(Expander,RetType,Depth,Self,['If',Cond,Then],Res):- !,
- eval_args0(Expander,'Bool',Depth,Self,Cond,TF),
- (is_True(TF) -> eval_args0(Expander,RetType,Depth,Self,Then,Res) ;
+eval_20(Expander,RetType,Depth,Self,['If',Cond,Then],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
+ (is_True(TF) -> eval(Expander,RetType,Depth,Self,Then,Res) ;
(!, fail,Res = [],!)).
-eval_args20(Expander,RetType,Depth,Self,['if',Cond,Then],Res):- !,
- eval_args0(Expander,'Bool',Depth,Self,Cond,TF),
- (is_True(TF) -> eval_args0(Expander,RetType,Depth,Self,Then,Res) ;
+eval_20(Expander,RetType,Depth,Self,['if',Cond,Then],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
+ (is_True(TF) -> eval(Expander,RetType,Depth,Self,Then,Res) ;
(!, fail,Res = [],!)).
-eval_args20(Expander,RetType,_Dpth,_Slf,[_,Nothing],NothingO):- 'Nothing'==Nothing,!,do_expander(Expander,RetType,Nothing,NothingO).
+eval_20(Expander,RetType,_Dpth,_Slf,[_,Nothing],NothingO):- 'Nothing'==Nothing,!,do_expander(Expander,RetType,Nothing,NothingO).
@@ -640,14 +642,14 @@
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,Depth,Self,['let',A,A5,AA],OO):- !,
+eval_20(Expander,RetType,Depth,Self,['let',A,A5,AA],OO):- !,
%(var(A)->true;trace),
- ((eval_args0(Expander,RetType,Depth,Self,A5,AE), AE=A)),
- eval_args0(Expander,RetType,Depth,Self,AA,OO).
-%eval_args20(Expander,RetType,Depth,Self,['let',A,A5,AA],AAO):- !,eval_args0(Expander,RetType,Depth,Self,A5,A),eval_args0(Expander,RetType,Depth,Self,AA,AAO).
-eval_args20(Expander,RetType,Depth,Self,['let*',[],Body],RetVal):- !, eval_args0(Expander,RetType,Depth,Self,Body,RetVal).
-eval_args20(Expander,RetType,Depth,Self,['let*',[[Var,Val]|LetRest],Body],RetVal):- !,
- eval_args20(Expander,RetType,Depth,Self,['let',Var,Val,['let*',LetRest,Body]],RetVal).
+ ((eval(Expander,RetType,Depth,Self,A5,AE), AE=A)),
+ eval(Expander,RetType,Depth,Self,AA,OO).
+%eval_20(Expander,RetType,Depth,Self,['let',A,A5,AA],AAO):- !,eval(Expander,RetType,Depth,Self,A5,A),eval(Expander,RetType,Depth,Self,AA,AAO).
+eval_20(Expander,RetType,Depth,Self,['let*',[],Body],RetVal):- !, eval(Expander,RetType,Depth,Self,Body,RetVal).
+eval_20(Expander,RetType,Depth,Self,['let*',[[Var,Val]|LetRest],Body],RetVal):- !,
+ eval_20(Expander,RetType,Depth,Self,['let',Var,Val,['let*',LetRest,Body]],RetVal).
% =================================================================
@@ -680,19 +682,19 @@
typed_list(Cmpd,Type,List):- compound(Cmpd), Cmpd\=[_|_], compound_name_arguments(Cmpd,Type,[List|_]),is_list(List).
:- endif.
-%eval_args20(Expander,RetType,Depth,Self,['colapse'|List], Flat):- !, maplist(eval_args0(Expander,RetType,Depth,Self),List,Res),flatten(Res,Flat).
+%eval_20(Expander,RetType,Depth,Self,['colapse'|List], Flat):- !, maplist(eval(Expander,RetType,Depth,Self),List,Res),flatten(Res,Flat).
-%eval_args20(Expander,RetType,Depth,Self,['flatten'|List], Flat):- !, maplist(eval_args0(Expander,RetType,Depth,Self),List,Res),flatten(Res,Flat).
+%eval_20(Expander,RetType,Depth,Self,['flatten'|List], Flat):- !, maplist(eval(Expander,RetType,Depth,Self),List,Res),flatten(Res,Flat).
-eval_args20(Expander,RetType,_Dpth,_Slf,['car-atom',Atom],CAR_Y):- !, Atom=[CAR|_],!,do_expander(Expander,RetType,CAR,CAR_Y).
-eval_args20(Expander,RetType,_Dpth,_Slf,['cdr-atom',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Expander,RetType,CDR,CDR_Y).
+eval_20(Expander,RetType,_Dpth,_Slf,['car-atom',Atom],CAR_Y):- !, Atom=[CAR|_],!,do_expander(Expander,RetType,CAR,CAR_Y).
+eval_20(Expander,RetType,_Dpth,_Slf,['cdr-atom',Atom],CDR_Y):- !, Atom=[_|CDR],!,do_expander(Expander,RetType,CDR,CDR_Y).
-eval_args20(Expander,RetType,Depth,Self,['Cons', A, B ],['Cons', AA, BB]):- no_cons_reduce, !,
- eval_args0(Expander,RetType,Depth,Self,A,AA), eval_args0(Expander,RetType,Depth,Self,B,BB).
+eval_20(Expander,RetType,Depth,Self,['Cons', A, B ],['Cons', AA, BB]):- no_cons_reduce, !,
+ eval(Expander,RetType,Depth,Self,A,AA), eval(Expander,RetType,Depth,Self,B,BB).
-eval_args20(Expander,RetType,Depth,Self,['Cons', A, B ],[AA|BB]):- \+ no_cons_reduce, !,
- eval_args0(Expander,RetType,Depth,Self,A,AA), eval_args0(Expander,RetType,Depth,Self,B,BB).
+eval_20(Expander,RetType,Depth,Self,['Cons', A, B ],[AA|BB]):- \+ no_cons_reduce, !,
+ eval(Expander,RetType,Depth,Self,A,AA), eval(Expander,RetType,Depth,Self,B,BB).
@@ -704,16 +706,16 @@
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,Depth,Self,['change-state!',StateExpr, UpdatedValue], Ret):- !, eval_args0(Expander,RetType,Depth,Self,StateExpr,StateMonad),
- eval_args0(Expander,RetType,Depth,Self,UpdatedValue,Value), 'change-state!'(Depth,Self,StateMonad, Value, Ret).
-eval_args20(Expander,RetType,Depth,Self,['new-state',UpdatedValue],StateMonad):- !,
- eval_args0(Expander,RetType,Depth,Self,UpdatedValue,Value), 'new-state'(Depth,Self,Value,StateMonad).
-eval_args20(Expander,RetType,Depth,Self,['get-state',StateExpr],Value):- !,
- eval_args0(Expander,RetType,Depth,Self,StateExpr,StateMonad), 'get-state'(StateMonad,Value).
+eval_20(Expander,RetType,Depth,Self,['change-state!',StateExpr, UpdatedValue], Ret):- !, eval(Expander,RetType,Depth,Self,StateExpr,StateMonad),
+ eval(Expander,RetType,Depth,Self,UpdatedValue,Value), 'change-state!'(Depth,Self,StateMonad, Value, Ret).
+eval_20(Expander,RetType,Depth,Self,['new-state',UpdatedValue],StateMonad):- !,
+ eval(Expander,RetType,Depth,Self,UpdatedValue,Value), 'new-state'(Depth,Self,Value,StateMonad).
+eval_20(Expander,RetType,Depth,Self,['get-state',StateExpr],Value):- !,
+ eval(Expander,RetType,Depth,Self,StateExpr,StateMonad), 'get-state'(StateMonad,Value).
-% eval_args20(Expander,RetType,Depth,Self,['get-state',Expr],Value):- !, eval_args0(Expander,RetType,Depth,Self,Expr,State), arg(1,State,Value).
+% eval_20(Expander,RetType,Depth,Self,['get-state',Expr],Value):- !, eval(Expander,RetType,Depth,Self,Expr,State), arg(1,State,Value).
@@ -815,13 +817,13 @@
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,Depth,Self,['get-type',Val],TypeO):- !, get_type(Depth,Self,Val,Type),ground(Type),Type\==[], Type\==Val,!,
+eval_20(Expander,RetType,Depth,Self,['get-type',Val],TypeO):- !, get_type(Depth,Self,Val,Type),ground(Type),Type\==[], Type\==Val,!,
do_expander(Expander,RetType,Type,TypeO).
-eval_args20(Expander,RetType,Depth,Self,['length',L],Res):- !, eval_args0(Expander,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1).
-eval_args20(Expander,RetType,Depth,Self,['CountElement',L],Res):- !, eval_args0(Expander,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1).
+eval_20(Expander,RetType,Depth,Self,['length',L],Res):- !, eval(Expander,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1).
+eval_20(Expander,RetType,Depth,Self,['CountElement',L],Res):- !, eval(Expander,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1).
@@ -849,7 +851,7 @@
get_type(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),
- eval_args0(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
+ eval(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
get_type(Depth,Self,Val,Type).
get_type(_Dpth,Self,[Fn|_],Type):- symbol(Fn),metta_type(Self,Fn,List),last_element(List,Type), nonvar(Type),
@@ -864,7 +866,7 @@
%get_type(Depth,Self,Fn,Type):- nonvar(Fn),metta_type(Self,Fn,Type2),Depth2 is Depth-1,get_type(Depth2,Self,Type2,Type).
%get_type(Depth,Self,Fn,Type):- Depth>0,nonvar(Fn),metta_type(Self,Type,Fn),!. %,!,last_element(List,Type).
-get_type(Depth,Self,Expr,Type):-Depth2 is Depth-1, eval_args0(Depth2,Self,Expr,Val),Expr\=@=Val,get_type(Depth2,Self,Val,Type).
+get_type(Depth,Self,Expr,Type):-Depth2 is Depth-1, eval(Depth2,Self,Expr,Val),Expr\=@=Val,get_type(Depth2,Self,Val,Type).
get_type(_Dpth,_Slf,Val,'String'):- string(Val),!.
@@ -891,28 +893,28 @@
is_seo_f(N):- number(N),!.
-eval_args20(Expander,RetType,Depth,Self,[F,A|Args],Res):-
+eval_20(Expander,RetType,Depth,Self,[F,A|Args],Res):-
\+ self_eval(A),
- eval_args0(Expander,RetType,Depth,Self,A,AA),AA\==A,
- eval_args0(Expander,RetType,Depth,Self,[F,AA|Args],Res).
+ eval(Expander,RetType,Depth,Self,A,AA),AA\==A,
+ eval(Expander,RetType,Depth,Self,[F,AA|Args],Res).
-eval_args20(Expander,RetType,Depth,Self,[F,A1|AArgs],Res):- fail, member(F,['+']),
+eval_20(Expander,RetType,Depth,Self,[F,A1|AArgs],Res):- fail, member(F,['+']),
cwdl(40,((
append(L,[A|R],AArgs),
\+ self_eval(A),
- eval_args0(Expander,RetType,Depth,Self,A,AA),AA\==A,!,
- append(L,[AA|R],NewArgs), eval_args0(Expander,RetType,Depth,Self,[F,A1|NewArgs],Res)))).
+ eval(Expander,RetType,Depth,Self,A,AA),AA\==A,!,
+ append(L,[AA|R],NewArgs), eval(Expander,RetType,Depth,Self,[F,A1|NewArgs],Res)))).
*/
/* %%
% !(assertEqualToResult ((inc) 2) (3))
-eval_args20(Expander,RetType,Depth,Self,[F|Args],Res):- is_list(F),
- metta_atom_iter(Depth,Self,['=',F,R]), eval_args0(Expander,RetType,Depth,Self,[R|Args],Res).
+eval_20(Expander,RetType,Depth,Self,[F|Args],Res):- is_list(F),
+ metta_atom_iter(Depth,Self,['=',F,R]), eval(Expander,RetType,Depth,Self,[R|Args],Res).
-eval_args20(Expander,RetType,Depth,Self,[F|Args],Res):- is_list(F), Args\==[],
- append(F,Args,FArgs),!,eval_args0(Expander,RetType,Depth,Self,FArgs,Res).
+eval_20(Expander,RetType,Depth,Self,[F|Args],Res):- is_list(F), Args\==[],
+ append(F,Args,FArgs),!,eval(Expander,RetType,Depth,Self,FArgs,Res).
*/
@@ -925,17 +927,17 @@
% =================================================================
nb_bind(Name,Value):- nb_current(Name,Was),same_term(Value,Was),!.
nb_bind(Name,Value):- nb_setval(Name,Value),!.
-eval_args20(Expander,RetType,Depth,Self,['import!',Other,File],RetVal):-
+eval_20(Expander,RetType,Depth,Self,['import!',Other,File],RetVal):-
(( into_space(Depth,Self,Other,Space),!, include_metta(Space,File),!,return_empty(Space,RetVal))),
check_returnval(Expander,RetType,RetVal). %RetVal=[].
-eval_args20(Expander,RetType,Depth,Self,['bind!',Other,Expr],RetVal):-
- must_det_ll((into_name(Self,Other,Name),!,eval_args0(Expander,RetType,Depth,Self,Expr,Value),
+eval_20(Expander,RetType,Depth,Self,['bind!',Other,Expr],RetVal):-
+ must_det_ll((into_name(Self,Other,Name),!,eval(Expander,RetType,Depth,Self,Expr,Value),
nb_bind(Name,Value), return_empty(Value,RetVal))),
check_returnval(Expander,RetType,RetVal).
-eval_args20(Expander,RetType,Depth,Self,['pragma!',Other,Expr],RetVal):-
- must_det_ll((into_name(Self,Other,Name),!,nd_ignore((eval_args0(Expander,RetType,Depth,Self,Expr,Value),set_option_value(Name,Value))), return_empty(Value,RetVal),
+eval_20(Expander,RetType,Depth,Self,['pragma!',Other,Expr],RetVal):-
+ must_det_ll((into_name(Self,Other,Name),!,nd_ignore((eval(Expander,RetType,Depth,Self,Expr,Value),set_option_value(Name,Value))), return_empty(Value,RetVal),
check_returnval(Expander,RetType,RetVal))).
-eval_args20(Expander,RetType,_Dpth,Self,['transfer!',File],RetVal):- !, must_det_ll((include_metta(Self,File), return_empty(Self,RetVal),check_returnval(Expander,RetType,RetVal))).
+eval_20(Expander,RetType,_Dpth,Self,['transfer!',File],RetVal):- !, must_det_ll((include_metta(Self,File), return_empty(Self,RetVal),check_returnval(Expander,RetType,RetVal))).
nd_ignore(Goal):- call(Goal)*->true;true.
@@ -954,19 +956,19 @@
% =================================================================
% =================================================================
% ================================================================
-eval_args20(_Expander,_RetType1,Depth,Self,['nop',Expr], Empty):- !,
- eval_args0('=',_RetType2,Depth,Self,Expr,_),
+eval_20(_Expander,_RetType1,Depth,Self,['nop',Expr], Empty):- !,
+ eval('=',_RetType2,Depth,Self,Expr,_),
return_empty([], Empty).
-eval_args20(_Expander,_RetType1,Depth,Self,['do',Expr], Empty):- !,
- eval_args0('=',_RetType2,Depth,Self,Expr,_),
+eval_20(_Expander,_RetType1,Depth,Self,['do',Expr], Empty):- !,
+ eval('=',_RetType2,Depth,Self,Expr,_),
return_empty([],Empty).
/*
-eval_args20(Expander,_RetType1,Depth,Self,['do',Expr], Empty):- !,
- forall(eval_args0(Expander,_RetType2,Depth,Self,Expr,_),true),
+eval_20(Expander,_RetType1,Depth,Self,['do',Expr], Empty):- !,
+ forall(eval(Expander,_RetType2,Depth,Self,Expr,_),true),
return_empty([],_Empty).
*/
-eval_args20(_Expander,_RetType,_Depth,_Self,['nop'],_ ):- !, fail.
+eval_20(_Expander,_RetType,_Depth,_Self,['nop'],_ ):- !, fail.
@@ -993,16 +995,16 @@
is_and('and2','True').
is_and('#COMMA','True'). is_and(',','True'). % is_and('And').
-eval_args20(Expander,RetType,_Dpth,_Slf,[And],True):- is_and(And,True),!,check_returnval(Expander,RetType,True).
-eval_args20(Expander,RetType,Depth,Self,[And,X,Y],TF):- is_and(And,True),!, as_tf((
+eval_20(Expander,RetType,_Dpth,_Slf,[And],True):- is_and(And,True),!,check_returnval(Expander,RetType,True).
+eval_20(Expander,RetType,Depth,Self,[And,X,Y],TF):- is_and(And,True),!, as_tf((
eval_args(Expander,RetType,Depth,Self,X,True),eval_args(Expander,RetType,Depth,Self,Y,True)),TF).
-eval_args20(Expander,RetType,Depth,Self,[And,X],True):- is_and(And,True),!,
+eval_20(Expander,RetType,Depth,Self,[And,X],True):- is_and(And,True),!,
eval_args(Expander,RetType,Depth,Self,X,True).
-eval_args20(Expander,RetType,Depth,Self,[And,X|Y],TF):- is_and(And,_True),!,
+eval_20(Expander,RetType,Depth,Self,[And,X|Y],TF):- is_and(And,_True),!,
eval_args(Expander,RetType,Depth,Self,X,TF1), \+ \+ is_True(TF1),
eval_args(Expander,RetType,Depth,Self,[And|Y],TF).
-eval_args20(Expander,RetType,Depth,Self,['or',X,Y],TF):- !,
+eval_20(Expander,RetType,Depth,Self,['or',X,Y],TF):- !,
as_tf((eval_args(Expander,RetType,Depth,Self,X,'True');eval_args(Expander,RetType,Depth,Self,Y,'True')),TF).
@@ -1013,12 +1015,12 @@
% =================================================================
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,Depth,Self,['+',N1,N2],N):- number(N1),!,
- eval_args0(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1+N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
-eval_args20(Expander,RetType,Depth,Self,['-',N1,N2],N):- number(N1),!,
- eval_args0(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1-N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
-eval_args20(Expander,RetType,Depth,Self,['*',N1,N2],N):- number(N1),!,
- eval_args0(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1*N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
+eval_20(Expander,RetType,Depth,Self,['+',N1,N2],N):- number(N1),!,
+ eval(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1+N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
+eval_20(Expander,RetType,Depth,Self,['-',N1,N2],N):- number(N1),!,
+ eval(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1-N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
+eval_20(Expander,RetType,Depth,Self,['*',N1,N2],N):- number(N1),!,
+ eval(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1*N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
% =================================================================
% =================================================================
@@ -1027,9 +1029,9 @@
% =================================================================
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,Depth,Self,[V|VI],[V|VO]):-
+eval_20(Expander,RetType,Depth,Self,[V|VI],[V|VO]):-
nonvar(V),is_metta_data_functor(V),is_list(VI),!,
- maplist(eval_args0(Expander,RetType,Depth,Self),VI,VO).
+ maplist(eval(Expander,RetType,Depth,Self),VI,VO).
% =================================================================
@@ -1039,8 +1041,8 @@
% =================================================================
% =================================================================
% =================================================================
-eval_args20(Expander,RetType,Depth,Self,X,Y):-
- (eval_args40(Expander,RetType,Depth,Self,X,M)*->
+eval_20(Expander,RetType,Depth,Self,X,Y):-
+ (eval_40(Expander,RetType,Depth,Self,X,M)*->
M=Y ;
% eval_args_finish(Depth,Self,M,Y);
(eval_args_failed(Depth,Self,X,Y)*->true;X=Y)).
@@ -1051,50 +1053,50 @@
eval_args_finish(_Dpth,_Slf,T,TT):- var(T),!,TT=T.
eval_args_finish(_Dpth,_Slf,[],[]):-!.
%eval_args_finish(_Dpth,_Slf,[F|LESS],Res):- once(eval_selfless([F|LESS],Res)),mnotrace([F|LESS]\==Res),!.
-%eval_args_finish(Depth,Self,[V|Nil],[O]):- Nil==[], once(eval_args0(Expander,RetType,Depth,Self,V,O)),V\=@=O,!.
+%eval_args_finish(Depth,Self,[V|Nil],[O]):- Nil==[], once(eval(Expander,RetType,Depth,Self,V,O)),V\=@=O,!.
eval_args_finish(Depth,Self,[H|T],[HH|TT]):- !,
- eval_args0(Depth,Self,H,HH),
+ eval(Depth,Self,H,HH),
eval_args_finish(Depth,Self,T,TT).
-eval_args_finish(Depth,Self,T,TT):- eval_args0(Depth,Self,T,TT).
+eval_args_finish(Depth,Self,T,TT):- eval(Depth,Self,T,TT).
- %eval_args0(Expander,RetType,Depth,Self,X,Y):- eval_args20(Expander,RetType,Depth,Self,X,Y)*->true;Y=[].
+ %eval(Expander,RetType,Depth,Self,X,Y):- eval_20(Expander,RetType,Depth,Self,X,Y)*->true;Y=[].
-%eval_args20(Expander,RetType,Depth,_,_,_):- Depth<1,!,fail.
-%eval_args20(Expander,RetType,Depth,_,X,Y):- Depth<3, !, ground(X), (Y=X).
-%eval_args20(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
+%eval_20(Expander,RetType,Depth,_,_,_):- Depth<1,!,fail.
+%eval_20(Expander,RetType,Depth,_,X,Y):- Depth<3, !, ground(X), (Y=X).
+%eval_20(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
-% Kills zero arity functions eval_args20(Expander,RetType,Depth,Self,[X|Nil],[Y]):- Nil ==[],!,eval_args0(Expander,RetType,Depth,Self,X,Y).
+% Kills zero arity functions eval_20(Expander,RetType,Depth,Self,[X|Nil],[Y]):- Nil ==[],!,eval(Expander,RetType,Depth,Self,X,Y).
/*
into_values(List,Many):- List==[],!,Many=[].
into_values([X|List],Many):- List==[],is_list(X),!,Many=X.
into_values(Many,Many).
-eval_args40(Expander,RetType,_Dpth,_Slf,Name,Value):- atom(Name), nb_current(Name,Value),!.
+eval_40(Expander,RetType,_Dpth,_Slf,Name,Value):- atom(Name), nb_current(Name,Value),!.
*/
% Macro Functions
-%eval_args20(Expander,RetType,Depth,_,_,_):- Depth<1,!,fail.
-eval_args40(_Expander,_RetType,Depth,_,X,Y):- Depth<3, !, fail, ground(X), (Y=X).
-eval_args40(Expander,RetType,Depth,Self,[F|PredDecl],Res):- fail,
+%eval_20(Expander,RetType,Depth,_,_,_):- Depth<1,!,fail.
+eval_40(_Expander,_RetType,Depth,_,X,Y):- Depth<3, !, fail, ground(X), (Y=X).
+eval_40(Expander,RetType,Depth,Self,[F|PredDecl],Res):- fail,
Depth>1,
mnotrace((sub_sterm1(SSub,PredDecl), ground(SSub),SSub=[_|Sub], is_list(Sub), maplist(atomic,SSub))),
- eval_args0(Expander,RetType,Depth,Self,SSub,Repl),
+ eval(Expander,RetType,Depth,Self,SSub,Repl),
mnotrace((SSub\=Repl, subst(PredDecl,SSub,Repl,Temp))),
- eval_args0(Expander,RetType,Depth,Self,[F|Temp],Res).
+ eval(Expander,RetType,Depth,Self,[F|Temp],Res).
% user defined function
-eval_args40(Expander,RetType,Depth,Self,[H|PredDecl],Res):-
+eval_40(Expander,RetType,Depth,Self,[H|PredDecl],Res):-
mnotrace(is_user_defined_head(Self,H)),!,
- eval_args60(Expander,RetType,Depth,Self,[H|PredDecl],Res).
+ eval_60(Expander,RetType,Depth,Self,[H|PredDecl],Res).
-eval_args40(Expander,RetType,Depth,Self,[AE|More],Res):- is_special_op(AE),!,
- eval_args70(Expander,RetType,Depth,Self,[AE|More],Res),
+eval_40(Expander,RetType,Depth,Self,[AE|More],Res):- is_special_op(AE),!,
+ eval_70(Expander,RetType,Depth,Self,[AE|More],Res),
check_returnval(Expander,RetType,Res).
-eval_args40(Expander,RetType,Depth,Self,[AE|More],Res):-
+eval_40(Expander,RetType,Depth,Self,[AE|More],Res):-
maplist(must_eval_args(Expander,_,Depth,Self),More,Adjusted),
- eval_args70(Expander,RetType,Depth,Self,[AE|Adjusted],Res),
+ eval_70(Expander,RetType,Depth,Self,[AE|Adjusted],Res),
check_returnval(Expander,RetType,Res).
must_eval_args(Expander,RetType,Depth,Self,More,Adjusted):-
@@ -1106,12 +1108,12 @@
(trace, throw(must_eval_args(Expander,RetType,Depth,Self,More,Adjusted))))))).
-eval_args70(_Expander,_RetType,_Dpth,_Slf,['==',X,Y],Res):- !,as_tf(X=Y,Res).
+eval_70(_Expander,_RetType,_Dpth,_Slf,['==',X,Y],Res):- !,as_tf(X=Y,Res).
-eval_args70(Expander,RetType,Depth,Self,PredDecl,Res):-
+eval_70(Expander,RetType,Depth,Self,PredDecl,Res):-
Do_more_defs = do_more_defs(true),
- clause(eval_args80(Expander,RetType,Depth,Self,PredDecl,Res),Body),
+ clause(eval_80(Expander,RetType,Depth,Self,PredDecl,Res),Body),
Do_more_defs == do_more_defs(true),
call(Body),nb_setarg(1,Do_more_defs,false).
@@ -1123,13 +1125,13 @@
% =================================================================
% =================================================================
% =================================================================
-eval_args80(_Expander,_RetType,_Dpth,_Slf,LESS,Res):-
+eval_80(_Expander,_RetType,_Dpth,_Slf,LESS,Res):-
notrace((ground(LESS),once((eval_selfless(LESS,Res),mnotrace(LESS\==Res))))),!.
% predicate inherited by system
-eval_args80(Expander,RetType,_Depth,_Self,[AE|More],TF):-
+eval_80(Expander,RetType,_Depth,_Self,[AE|More],TF):-
length(More,Len),
is_syspred(AE,Len,Pred),
%mnotrace( \+ is_user_defined_goal(Self,[AE|More])),!,
@@ -1140,7 +1142,7 @@
:- if( \+ current_predicate( adjust_args / 2 )).
- :- discontiguous eval_args80/6.
+ :- discontiguous eval_80/6.
is_user_defined_goal(Self,Head):-
is_user_defined_head(Self,Head).
@@ -1148,7 +1150,7 @@
% function inherited by system
-eval_args80(Expander,RetType,_Depth,_Self,[AE|More],Res):-
+eval_80(Expander,RetType,_Depth,_Self,[AE|More],Res):-
length([AE|More],Len),
is_syspred(AE,Len,Pred),
%mnotrace( \+ is_user_defined_goal(Self,[AE|More])),!,
@@ -1166,8 +1168,8 @@
adjust_args(_Depth,_Self,_V,VI,VI).
:- endif.
-eval_args80(Expander,RetType,Depth,Self,PredDecl,Res):-
- eval_args67(Expander,RetType,Depth,Self,PredDecl,Res).
+eval_80(Expander,RetType,Depth,Self,PredDecl,Res):-
+ eval_67(Expander,RetType,Depth,Self,PredDecl,Res).
@@ -1202,10 +1204,10 @@
-%eval_args40(Expander,RetType,Depth,Self,PredDecl,Res):- eval_args6(Depth,Self,PredDecl,Res).
+%eval_40(Expander,RetType,Depth,Self,PredDecl,Res):- eval_6(Depth,Self,PredDecl,Res).
-%eval_args40(Expander,RetType,_Dpth,_Slf,L1,Res):- is_list(L1),maplist(self_eval,L1),!,Res=L1.
-%eval_args40(Expander,RetType,_Depth,_Self,X,X).
+%eval_40(Expander,RetType,_Dpth,_Slf,L1,Res):- is_list(L1),maplist(self_eval,L1),!,Res=L1.
+%eval_40(Expander,RetType,_Depth,_Self,X,X).
/*
is_user_defined_head(Other,H):- mnotrace(is_user_defined_head0(Other,H)).
@@ -1270,69 +1272,69 @@
% =================================================================
% =================================================================
-eval_args60(Expander,RetType,Depth,Self,H,B):-
- (eval_args64(Expander,RetType,Depth,Self,H,B)*->true;eval_args67(Expander,RetType,Depth,Self,H,B)).
+eval_60(Expander,RetType,Depth,Self,H,B):-
+ (eval_64(Expander,RetType,Depth,Self,H,B)*->true;eval_67(Expander,RetType,Depth,Self,H,B)).
-eval_args64(Expander,_RetType,_Dpth,Self,H,B):- Expander='=',!, metta_defn(Self,H,B).
-eval_args64(Expander,_RetType,_Dpth,Self,H,B):- Expander='match', dcall(metta_atom(Self,H)),B=H.
+eval_64(Expander,_RetType,_Dpth,Self,H,B):- Expander='=',!, metta_defn(Self,H,B).
+eval_64(Expander,_RetType,_Dpth,Self,H,B):- Expander='match', dcall(metta_atom(Self,H)),B=H.
% Has argument that is headed by the same function
-eval_args67(Expander,RetType,Depth,Self,[H1|Args],Res):-
+eval_67(Expander,RetType,Depth,Self,[H1|Args],Res):-
mnotrace((append(Left,[[H2|H2Args]|Rest],Args), H2==H1)),!,
- eval_args0(Expander,RetType,Depth,Self,[H2|H2Args],ArgRes),
+ eval(Expander,RetType,Depth,Self,[H2|H2Args],ArgRes),
mnotrace((ArgRes\==[H2|H2Args], append(Left,[ArgRes|Rest],NewArgs))),
- eval_args60(Expander,RetType,Depth,Self,[H1|NewArgs],Res).
+ eval_60(Expander,RetType,Depth,Self,[H1|NewArgs],Res).
-eval_args67(Expander,RetType,Depth,Self,[[H|Start]|T1],Y):-
+eval_67(Expander,RetType,Depth,Self,[[H|Start]|T1],Y):-
mnotrace((is_user_defined_head_f(Self,H),is_list(Start))),
metta_defn(Self,[H|Start],Left),
- eval_args0(Expander,RetType,Depth,Self,[Left|T1],Y).
+ eval(Expander,RetType,Depth,Self,[Left|T1],Y).
% Has subterm to eval
-eval_args67(Expander,RetType,Depth,Self,[F|PredDecl],Res):-
+eval_67(Expander,RetType,Depth,Self,[F|PredDecl],Res):-
Depth>1,
quietly(sub_sterm1(SSub,PredDecl)),
mnotrace((ground(SSub),SSub=[_|Sub], is_list(Sub),maplist(atomic,SSub))),
- eval_args0(Expander,RetType,Depth,Self,SSub,Repl),
+ eval(Expander,RetType,Depth,Self,SSub,Repl),
mnotrace((SSub\=Repl,subst(PredDecl,SSub,Repl,Temp))),
- eval_args60(Expander,RetType,Depth,Self,[F|Temp],Res).
+ eval_60(Expander,RetType,Depth,Self,[F|Temp],Res).
-%eval_args67(Expander,RetType,Depth,Self,X,Y):- (eval_args68(Expander,RetType,Depth,Self,X,Y)*->true;metta_atom_iter(Depth,Self,[=,X,Y])).
+%eval_67(Expander,RetType,Depth,Self,X,Y):- (eval_68(Expander,RetType,Depth,Self,X,Y)*->true;metta_atom_iter(Depth,Self,[=,X,Y])).
/*
-eval_args67_fail(Depth,Self,PredDecl,Res):- fail,
+eval_67_fail(Depth,Self,PredDecl,Res):- fail,
((term_variables(PredDecl,Vars),
(metta_atom(Self,PredDecl) *-> (Vars ==[]->Res='True';Vars=Res);
- (eval_args0(Expander,RetType,Depth,Self,PredDecl,Res),ignore(Vars ==[]->Res='True';Vars=Res))))),
+ (eval(Expander,RetType,Depth,Self,PredDecl,Res),ignore(Vars ==[]->Res='True';Vars=Res))))),
PredDecl\=@=Res.
*/
-%eval_args68(Expander,RetType,_Dpth,Self,[H|_],_):- mnotrace( \+ is_user_defined_head_f(Self,H) ), !,fail.
-%eval_args68(Expander,RetType,_Dpth,Self,[H|T1],Y):- metta_defn(Self,[H|T1],Y).
-%eval_args68(Expander,RetType,_Dpth,Self,[H|T1],'True'):- metta_atom(Self,[H|T1]).
-%eval_args68(Expander,RetType,_Dpth,Self,CALL,Y):- fail,append(Left,[Y],CALL),metta_defn(Self,Left,Y).
+%eval_68(Expander,RetType,_Dpth,Self,[H|_],_):- mnotrace( \+ is_user_defined_head_f(Self,H) ), !,fail.
+%eval_68(Expander,RetType,_Dpth,Self,[H|T1],Y):- metta_defn(Self,[H|T1],Y).
+%eval_68(Expander,RetType,_Dpth,Self,[H|T1],'True'):- metta_atom(Self,[H|T1]).
+%eval_68(Expander,RetType,_Dpth,Self,CALL,Y):- fail,append(Left,[Y],CALL),metta_defn(Self,Left,Y).
-%eval_args6(Depth,Self,['ift',CR,Then],RO):- fail, !, %fail, % trace,
-% metta_defn(Self,['ift',R,Then],Become),eval_args0(Expander,RetType,Depth,Self,CR,R),eval_args0(Expander,RetType,Depth,Self,Then,_True),eval_args0(Expander,RetType,Depth,Self,Become,RO).
+%eval_6(Depth,Self,['ift',CR,Then],RO):- fail, !, %fail, % trace,
+% metta_defn(Self,['ift',R,Then],Become),eval(Expander,RetType,Depth,Self,CR,R),eval(Expander,RetType,Depth,Self,Then,_True),eval(Expander,RetType,Depth,Self,Become,RO).
%not_compound(Term):- \+ is_list(Term),!.
-%eval_args40(Expander,RetType,Depth,Self,Term,Res):- maplist(not_compound,Term),!,eval_args645(Depth,Self,Term,Res).
+%eval_40(Expander,RetType,Depth,Self,Term,Res):- maplist(not_compound,Term),!,eval_645(Depth,Self,Term,Res).
% function inherited by system
/*
-eval_args80(Expander,RetType,Depth,Self,[F|X],FY):- is_function(F), \+ is_special_op(F), is_list(X),
- maplist(eval_args0(Expander,ArgTypes,Depth,Self),X,Y),!,
- eval_args85(Depth,Self,[F|Y],FY).
+eval_80(Expander,RetType,Depth,Self,[F|X],FY):- is_function(F), \+ is_special_op(F), is_list(X),
+ maplist(eval(Expander,ArgTypes,Depth,Self),X,Y),!,
+ eval_85(Depth,Self,[F|Y],FY).
-eval_args80(Expander,RetType,Depth,Self,FX,FY):- eval_args85(Depth,Self,FX,FY).
+eval_80(Expander,RetType,Depth,Self,FX,FY):- eval_85(Depth,Self,FX,FY).
-eval_args85(Depth,Self,[AE|More],TF):- length(More,Len),
- (is_syspred(AE,Len,Pred),catch_warn(as_tf(apply(Pred,More),TF)))*->true;eval_args86(Depth,Self,[AE|More],TF).
-eval_args86(_Dpth,_Slf,[AE|More],TF):- length([AE|More],Len), is_syspred(AE,Len,Pred),append(More,[TF],Args),!,catch_warn(apply(Pred,Args)).
+eval_85(Depth,Self,[AE|More],TF):- length(More,Len),
+ (is_syspred(AE,Len,Pred),catch_warn(as_tf(apply(Pred,More),TF)))*->true;eval_86(Depth,Self,[AE|More],TF).
+eval_86(_Dpth,_Slf,[AE|More],TF):- length([AE|More],Len), is_syspred(AE,Len,Pred),append(More,[TF],Args),!,catch_warn(apply(Pred,Args)).
*/
-%eval_args80(Expander,RetType,Depth,Self,[X1|[F2|X2]],[Y1|Y2]):- is_function(F2),!,eval_args0(Expander,RetType,Depth,Self,[F2|X2],Y2),eval_args0(Expander,RetType,Depth,Self,X1,Y1).
+%eval_80(Expander,RetType,Depth,Self,[X1|[F2|X2]],[Y1|Y2]):- is_function(F2),!,eval(Expander,RetType,Depth,Self,[F2|X2],Y2),eval(Expander,RetType,Depth,Self,X1,Y1).
% =================================================================
@@ -1348,18 +1350,18 @@
%bagof_eval(Expander,RetType,Depth,Self,X,L):- bagof_eval(Expander,RetType,_RT,Depth,Self,X,L).
-%bagof_eval(Expander,RetType,Depth,Self,X,S):- bagof(E,eval_args_ne(Expander,RetType,Depth,Self,X,E),S)*->true;S=[].
+%bagof_eval(Expander,RetType,Depth,Self,X,S):- bagof(E,eval_ne(Expander,RetType,Depth,Self,X,E),S)*->true;S=[].
bagof_eval(_Expander,_RetType,_Dpth,_Slf,X,L):- typed_list(X,_Type,L),!.
bagof_eval(Expander,RetType,Depth,Self,X,L):-
- findall(E,eval_args_ne(Expander,RetType,Depth,Self,X,E),L).
+ findall(E,eval_ne(Expander,RetType,Depth,Self,X,E),L).
setof_eval(Depth,Self,X,L):- setof_eval('=',_RT,Depth,Self,X,L).
setof_eval(Expander,RetType,Depth,Self,X,S):- bagof_eval(Expander,RetType,Depth,Self,X,L),
sort(L,S).
-eval_args_ne(Expander,RetType,Depth,Self,X,E):-
- eval_args0(Expander,RetType,Depth,Self,X,E), \+ var(E), \+ is_empty(E).
+eval_ne(Expander,RetType,Depth,Self,X,E):-
+ eval(Expander,RetType,Depth,Self,X,E), \+ var(E), \+ is_empty(E).
diff --git a/metta_vspace/pyswip/metta_interp.pl b/metta_vspace/pyswip/metta_interp.pl
index 485571a0..b207810e 100755
--- a/metta_vspace/pyswip/metta_interp.pl
+++ b/metta_vspace/pyswip/metta_interp.pl
@@ -355,16 +355,16 @@
load_metta('&self',Filename).
+load_metta(_Self,Filename):- Filename=='--repl',!,repl.
+load_metta(Self,Filename):-
+ (\+ atom(Filename); \+ exists_file(Filename)),!,
+ with_wild_path(load_metta(Self),Filename),!,loonit_report.
load_metta(Self,RelFilename):-
atom(RelFilename),
exists_file(RelFilename),!,
absolute_file_name(RelFilename,Filename),
track_load_into_file(Filename,
include_metta(Self,RelFilename)).
-load_metta(_Self,Filename):- Filename=='--repl',!,repl.
-load_metta(Self,Filename):-
- (\+ atom(Filename); \+ exists_file(Filename)),!,
- with_wild_path(load_metta(Self),Filename),!,loonit_report.
include_metta(Self,Filename):-
(\+ atom(Filename); \+ exists_file(Filename)),!,
@@ -388,11 +388,10 @@
set_exec_num(Filename,1),
load_answer_file(Filename),
set_exec_num(Filename,0))),
- ((repeat,
- must_det_ll((
+ once((repeat, ((
((nb_current(read_mode,Mode),Mode\==[])->true;Mode=load),
once(read_metta(In,Expr)), %write_src(read_metta=Expr),nl,
- once((do_metta(file(Filename),Mode,Self,Expr,_O)->true;
+ must_det_ll((do_metta(file(Filename),Mode,Self,Expr,_O)->true;
pp_m(unknown_do_metta(file(Filename),Mode,Self,Expr)))),
flush_output)),
at_end_of_stream(In)))))),!.
@@ -844,7 +843,8 @@
metta_atom_stdlib([:, Type, 'Type']):- type_decl(Type).
metta_atom_stdlib([:, Op, [->|List]]):- op_decl(Op,Params,ReturnType),append(Params,[ReturnType],List).
-metta_atom(KB, [F, A| List]):- nonvar(F), KB=='&flybase',fb_pred(F, Len), length([A|List],Len),apply(F,[A|List]).
+metta_atom(KB, [F, A| List]):- KB=='&flybase',fb_pred(F, Len), length([A|List],Len),apply(F,[A|List]).
+%metta_atom(KB, [F|List]):- KB=='&flybase',fb_pred(F, Len), length(List,Len),apply(F,List).
metta_atom(Space, Atom):- typed_list(Space,_,L),!, member(Atom,L).
metta_atom(KB,Atom):- nonvar(KB), nonvar(Atom), metta_atom_stdlib(Atom).
@@ -853,7 +853,6 @@
-%metta_atom(KB, [F|List]):- KB=='&flybase',fb_pred(F, Len), length(List,Len),apply(F,List).
%metta_atom(KB,[F,A|List]):- metta_atom(KB,F,A,List), F \== '=',!.
metta_defn(KB,Head,Body):- metta_atom(KB,['=',Head,Body]).
@@ -865,7 +864,7 @@
metta_anew1(Load,_OBO):- var(Load),trace,!.
metta_anew1(Load,OBO):- maybe_xform(OBO,XForm),!,metta_anew1(Load,XForm).
-
+metta_anew1(Ch,OBO):- metta_interp_mode(Ch,Mode), !, metta_anew1(Mode,OBO).
metta_anew1(load,OBO):- OBO= metta_atom(Space,Atom),!,'add-atom'(Space, Atom).
metta_anew1(unload,OBO):- OBO= metta_atom(Space,Atom),!,'remove-atom'(Space, Atom).
@@ -878,6 +877,7 @@
metta_anew2(Load,_OBO):- var(Load),trace,!.
metta_anew2(Load,OBO):- maybe_xform(OBO,XForm),!,metta_anew2(Load,XForm).
+metta_anew2(Ch,OBO):- metta_interp_mode(Ch,Mode), !, metta_anew2(Mode,OBO).
metta_anew2(load,OBO):- must_det_ll((load_hook(load,OBO),subst_vars_not_last(OBO,Cl),assertz_if_new(Cl))). %to_metta(Cl).
metta_anew2(unload,OBO):- subst_vars_not_last(OBO,Cl),load_hook(unload,OBO),
expand_to_hb(Cl,Head,Body),
@@ -1249,7 +1249,7 @@
\+ \+ write_exec(TermV),
into_metta_callable(Self,TermV,Term,X,NamedVarsList,Was),
Control = contrl(each),
- forall(may_rtrace(Term),
+ forall(may_rt race(rtrace(Term)),
(( notrace(ignore(((color_g_mesg(yellow,
((write(' '),
write_src(X),nl,
@@ -1280,7 +1280,7 @@
%NamedVarsList=[_=RealRealRes|_],
var(RealRes),
X = RealRes,
- may_rtrace(Term).
+ may_ rtrace(Term).
do_metta_ exec(From,Mode,Self,TermV,X,NamedVarsList,Was):-!,
notrace(( must_det_ll((
@@ -1296,7 +1296,7 @@
nl,print(subst_vars(TermV,Term,NamedVarsList,Vars)),nl)))),
option_else('stack-max',StackMax,100),
nop(maplist(verbose_unify,Vars)))))),
- may_rtrace(eval_args(StackMax,Self,Term,X)).
+ may_r trace(eval_args(StackMax,Self,Term,X)).
*/
@@ -1458,16 +1458,18 @@
%GG = interact(['Result'=X|NamedVarsList],Term,trace_off),
(((From = file(_Filename), option_value('exec',skip), \+ always_exec(BaseEval)))
-> GG = (skip(Term),deterministic(Complete))
- ; GG = (Term,deterministic(Complete))),
+ ; GG = (dcall(Term),deterministic(Complete))),
Result = res(FOut),
!, % metta_toplevel
flag(result_num,_,0),
+ with_indents(false,
\+ \+ (
maplist(name_vars,NamedVarsList),
name_vars('OUT'=X),
%add_history_src(exec(BaseEval)),
color_g_mesg('#fa90f6', (write('; '), with_indents(false,write_src(exec(BaseEval))))),
- color_g_mesg('#da70d6', (write('% DEBUG: '), writeq(eval_args(100,Self,BaseEval,X)),writeln('.')))))),
+ if_t(is_interactive(From),if_t(is_list(BaseEval),add_history_src(exec(TermV)))),
+ color_g_mesg('#da70d6', (write('% DEBUG: '), writeq(eval_args(100,Self,BaseEval,X)),writeln('.'))))))),
(forall_interactive(
From, WasInteractive,may_rtrace(GG),
diff --git a/metta_vspace/pyswip/metta_prelude.metta b/metta_vspace/pyswip/metta_prelude.metta
index 4c7caa16..ebeac455 100755
--- a/metta_vspace/pyswip/metta_prelude.metta
+++ b/metta_vspace/pyswip/metta_prelude.metta
@@ -1,4 +1,13 @@
+(: unify (-> Atom Atom Atom Atom %Undefined%))
+(: if (-> Bool Atom Atom $t#330))
+(: quote (-> Atom Atom))
+(: Error (-> Atom Atom ErrorType))
+(: empty (-> %Undefined%))
+(: get-atoms (-> Space Atom))
+(: add-atom (-> Space Atom (->)))
+(: remove-atom (-> Space Atom (->)))
+(: add-atom (-> Space Atom (->)))
;`$then`, `$else` should be of `Atom` type to avoid evaluation
; and infinite cycle in inference
@@ -144,4 +153,278 @@
(eval (if-error $result $result
(eval (interpret $result $type $space)) ))))))
+(: ErrorType Type)
+(: Error (-> Atom Atom ErrorType))
+(: ReturnType Type)
+(: return (-> Atom ReturnType))
+
+(: function (-> Atom Atom))
+(: eval (-> Atom Atom))
+(: chain (-> Atom Variable Atom Atom))
+(: unify (-> Atom Atom Atom Atom Atom))
+(: cons (-> Atom Atom Atom))
+(: decons (-> Atom Atom))
+
+(: id (-> Atom Atom))
+(= (id $x) $x)
+
+(: apply (-> Atom Variable Atom Atom))
+(= (apply $atom $var $templ)
+ (function (chain (eval (id $atom)) $var (return $templ))) )
+
+(: if-non-empty-expression (-> Atom Atom Atom Atom))
+(= (if-non-empty-expression $atom $then $else)
+ (function (chain (eval (get-metatype $atom)) $type
+ (eval (if-equal $type Expression
+ (eval (if-equal $atom () (return $else) (return $then)))
+ (return $else) )))))
+
+(: if-decons (-> Atom Variable Variable Atom Atom Atom))
+(= (if-decons $atom $head $tail $then $else)
+ (function (eval (if-non-empty-expression $atom
+ (chain (decons $atom) $list
+ (unify $list ($head $tail) (return $then) (return $else)) )
+ (return $else) ))))
+
+(: if-empty (-> Atom Atom Atom Atom))
+(= (if-empty $atom $then $else)
+ (function (eval (if-equal $atom Empty (return $then) (return $else)))) )
+
+(: if-not-reducible (-> Atom Atom Atom Atom))
+(= (if-not-reducible $atom $then $else)
+ (function (eval (if-equal $atom NotReducible (return $then) (return $else)))) )
+
+(: if-error (-> Atom Atom Atom Atom))
+(= (if-error $atom $then $else)
+ (function (eval (if-decons $atom $head $_
+ (eval (if-equal $head Error (return $then) (return $else)))
+ (return $else) ))))
+
+(: return-on-error (-> Atom Atom Atom))
+(= (return-on-error $atom $then)
+ (function (eval (if-empty $atom (return (return Empty))
+ (eval (if-error $atom (return (return $atom))
+ (return $then) ))))))
+
+(: switch (-> %Undefined% Expression Atom))
+(= (switch $atom $cases)
+ (function (chain (decons $cases) $list
+ (chain (eval (switch-internal $atom $list)) $res
+ (chain (eval (if-not-reducible $res Empty $res)) $x (return $x)) ))))
+
+(= (switch-internal $atom (($pattern $template) $tail))
+ (function (unify $atom $pattern
+ (return $template)
+ (chain (eval (switch $atom $tail)) $ret (return $ret)) )))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; MeTTa interpreter implementation ;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(= (match-types $type1 $type2 $then $else)
+ (function (eval (if-equal $type1 %Undefined%
+ (return $then)
+ (eval (if-equal $type2 %Undefined%
+ (return $then)
+ (eval (if-equal $type1 Atom
+ (return $then)
+ (eval (if-equal $type2 Atom
+ (return $then)
+ (unify $type1 $type2 (return $then) (return $else)) ))))))))))
+
+(= (type-cast $atom $type $space)
+ (function (chain (eval (get-metatype $atom)) $meta
+ (eval (if-equal $type $meta
+ (return $atom)
+ ; TODO: the proper way to get types is something like
+ ; `(collapse (get-type ))` but it leads to the infinite
+ ; recursion because interpreter called by `collapse` evaluates
+ ; `type-cast` again.
+ (chain (eval (collapse-get-type $atom $space)) $actual-types
+ (chain (eval (foldl-atom $actual-types False
+ $a $b (chain (eval (match-types $b $type True False)) $is-b-comp
+ (chain (eval (or $a $is-b-comp)) $or $or) ))) $is-some-comp
+ (eval (if $is-some-comp
+ (return $atom)
+ (return (Error $atom BadType)) )))))))))
+
+
+(= (is-function $type)
+ (function (chain (eval (get-metatype $type)) $meta
+ (eval (switch ($type $meta) (
+ (($_ Expression)
+ (eval (if-decons $type $head $_tail
+ (unify $head -> (return True) (return False))
+ (return (Error (is-function $type) "is-function non-empty expression as an argument")) )))
+ ($_ (return False))
+ ))))))
+
+(: filter-atom (-> Expression Variable Atom Expression))
+(= (filter-atom $list $var $filter)
+ (function (eval (if-decons $list $head $tail
+ (chain (eval (filter-atom $tail $var $filter)) $tail-filtered
+ (chain (eval (apply $head $var $filter)) $filter-expr
+ (chain $filter-expr $is-filtered
+ (eval (if $is-filtered
+ (chain (cons $head $tail-filtered) $res (return $res))
+ (return $tail-filtered) )))))
+ (return ()) ))))
+
+(: map-atom (-> Expression Variable Atom Expression))
+(= (map-atom $list $var $map)
+ (function (eval (if-decons $list $head $tail
+ (chain (eval (map-atom $tail $var $map)) $tail-mapped
+ (chain (eval (apply $head $var $map)) $map-expr
+ (chain $map-expr $head-mapped
+ (chain (cons $head-mapped $tail-mapped) $res (return $res)) )))
+ (return ()) ))))
+
+(: foldl-atom (-> Expression Atom Variable Variable Atom Atom))
+(= (foldl-atom $list $init $a $b $op)
+ (function (eval (if-decons $list $head $tail
+ (chain (eval (apply $init $a $op)) $op-init
+ (chain (eval (apply $head $b $op-init)) $op-head
+ (chain $op-head $head-folded
+ (chain (eval (foldl-atom $tail $head-folded $a $b $op)) $res (return $res)) )))
+ (return $init) ))))
+
+(= (interpret $atom $type $space)
+ (function (chain (eval (get-metatype $atom)) $meta
+ (eval (if-equal $type Atom
+ (return $atom)
+ (eval (if-equal $type $meta
+ (return $atom)
+ (eval (switch ($type $meta) (
+ (($_type Variable) (return $atom))
+ (($_type Symbol)
+ (chain (eval (type-cast $atom $type $space)) $ret (return $ret)))
+ (($_type Grounded)
+ (chain (eval (type-cast $atom $type $space)) $ret (return $ret)))
+ (($_type Expression)
+ (chain (eval (interpret-expression $atom $type $space)) $ret (return $ret)))
+ ))))))))))
+
+(= (interpret-expression $atom $type $space)
+ (function (eval (if-decons $atom $op $args
+ (chain (eval (get-type $op $space)) $op-type
+ (chain (eval (is-function $op-type)) $is-func
+ (unify $is-func True
+ (chain (eval (interpret-func $atom $op-type $type $space)) $reduced-atom
+ (chain (eval (metta-call $reduced-atom $type $space)) $ret (return $ret)) )
+ (chain (eval (interpret-tuple $atom $space)) $reduced-atom
+ (chain (eval (metta-call $reduced-atom $type $space)) $ret (return $ret)) ))))
+ (chain (eval (type-cast $atom $type $space)) $ret (return $ret)) ))))
+
+(= (interpret-func $expr $type $ret-type $space)
+ (function (eval (if-decons $expr $op $args
+ (chain (eval (interpret $op $type $space)) $reduced-op
+ (eval (return-on-error $reduced-op
+ (eval (if-decons $type $arrow $arg-types
+ (chain (eval (interpret-args $expr $args $arg-types $ret-type $space)) $reduced-args
+ (eval (return-on-error $reduced-args
+ (chain (cons $reduced-op $reduced-args) $r (return $r)))))
+ (return (Error $type "Function type expected")) )))))
+ (return (Error $expr "Non-empty expression atom is expected")) ))))
+
+(= (interpret-args $atom $args $arg-types $ret-type $space)
+ (function (unify $args ()
+ (eval (if-decons $arg-types $actual-ret-type $_tail
+ (eval (match-types $actual-ret-type $ret-type
+ (return ())
+ (return (Error $atom BadType)) ))
+ (return (Error (interpret-args $atom $args $arg-types $ret-type $space) "interpret-args expects a non-empty value for $arg-types argument")) ))
+ (eval (if-decons $args $head $tail
+ (eval (if-decons $arg-types $head-type $tail-types
+ (chain (eval (interpret $head $head-type $space)) $reduced-head
+ ; check that head was changed otherwise Error or Empty in the head
+ ; can be just an argument which is passed by intention
+ (eval (if-equal $reduced-head $head
+ (chain (eval (interpret-args-tail $atom $reduced-head $tail $tail-types $ret-type $space)) $ret (return $ret))
+ (eval (return-on-error $reduced-head
+ (chain (eval (interpret-args-tail $atom $reduced-head $tail $tail-types $ret-type $space)) $ret (return $ret)) )))))
+ (return (Error $atom BadType)) ))
+ (return (Error (interpret-atom $atom $args $arg-types $space) "Non-empty expression atom is expected")) )))))
+
+(= (interpret-args-tail $atom $head $args-tail $args-tail-types $ret-type $space)
+ (function (chain (eval (interpret-args $atom $args-tail $args-tail-types $ret-type $space)) $reduced-tail
+ (eval (return-on-error $reduced-tail
+ (chain (cons $head $reduced-tail) $ret (return $ret)) )))))
+
+(= (interpret-tuple $atom $space)
+ (function (unify $atom ()
+ (return $atom)
+ (eval (if-decons $atom $head $tail
+ (chain (eval (interpret $head %Undefined% $space)) $rhead
+ (eval (if-empty $rhead (return Empty)
+ (chain (eval (interpret-tuple $tail $space)) $rtail
+ (eval (if-empty $rtail (return Empty)
+ (chain (cons $rhead $rtail) $ret (return $ret)) ))))))
+ (return (Error (interpret-tuple $atom $space) "Non-empty expression atom is expected as an argument")) )))))
+
+(= (metta-call $atom $type $space)
+ (function (eval (if-error $atom (return $atom)
+ (chain (eval $atom) $result
+ (eval (if-not-reducible $result (return $atom)
+ (eval (if-empty $result (return Empty)
+ (eval (if-error $result (return $result)
+ (chain (eval (interpret $result $type $space)) $ret (return $ret)) )))))))))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Standard library written in MeTTa ;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;`$then`, `$else` should be of `Atom` type to avoid evaluation
+; and infinite cycle in inference
+(: if (-> Bool Atom Atom $t))
+(= (if True $then $else) $then)
+(= (if False $then $else) $else)
+
+(: or (-> Bool Bool Bool))
+(= (or False False) False)
+(= (or False True) True)
+(= (or True False) True)
+(= (or True True) True)
+
+(: and (-> Bool Bool Bool))
+(= (and False False) False)
+(= (and False True) False)
+(= (and True False) False)
+(= (and True True) True)
+
+(: match (-> Atom Atom Atom %Undefined%))
+(= (match $space $pattern $template)
+ (unify $pattern $space $template Empty))
+
+(: let (-> Atom %Undefined% Atom Atom))
+(= (let $pattern $atom $template)
+ (unify $atom $pattern $template Empty))
+
+(: let* (-> Expression Atom Atom))
+(= (let* $pairs $template)
+ (eval (if-decons $pairs ($pattern $atom) $tail
+ (let $pattern $atom (let* $tail $template))
+ $template )))
+
+(: car-atom (-> Expression Atom))
+(= (car-atom $atom)
+ (eval (if-decons $atom $head $_
+ $head
+ (Error (car-atom $atom) "car-atom expects a non-empty expression as an argument") )))
+
+(: cdr-atom (-> Expression Expression))
+(= (cdr-atom $atom)
+ (eval (if-decons $atom $_ $tail
+ $tail
+ (Error (cdr-atom $atom) "cdr-atom expects a non-empty expression as an argument") )))
+
+(: quote (-> Atom Atom))
+(= (quote $atom) NotReducible)
+
+(: unquote (-> %Undefined% %Undefined%))
+(= (unquote (quote $atom)) $atom)
+
+; TODO: there is no way to define operation which consumes any number of
+; arguments and returns unit
+(= (nop) ())
+(= (nop $x) ())
diff --git a/metta_vspace/pyswip/metta_python.pl b/metta_vspace/pyswip/metta_python.pl
index 20733d30..2efcb688 100755
--- a/metta_vspace/pyswip/metta_python.pl
+++ b/metta_vspace/pyswip/metta_python.pl
@@ -1,3 +1,7 @@
+:- encoding(iso_latin_1).
+:- flush_output.
+:- setenv('RUST_BACKTRACE',full).
+%:- '$set_source_module'('user').
/*
# Core in Rust
In the original version, the core logic and functionalities of the MeTTa system are implemented in Rust. Rust is known for its performance and safety features, making it a suitable choice for building robust, high-performance systems.
@@ -6,7 +10,7 @@
Python is used to extend or customize MeTTa. Typically, Python interacts with the Rust core through a Foreign Function Interface (FFI) or similar bridging mechanisms. This allows Python programmers to write code that can interact with the lower-level Rust code, while taking advantage of Python's ease of use and rich ecosystem.
# Prolog Allows Python Extensions
-Just like the Rust core allowed for Python extensions, the Prolog code also permits Python and Rust developers (thru python right now) to extend or customize parts of MeTTa. This maintains the system�s extensibility and allows users who are more comfortable with Python to continue working with the system effectively.
+Just like the Rust core allowed for Python extensions, the Prolog code also permits Python and Rust developers (thru python right now) to extend or customize parts of MeTTa. This maintains the system?s extensibility and allows users who are more comfortable with Python to continue working with the system effectively.
*/
@@ -14,58 +18,59 @@
:- use_module(library(janus)).
:- use_module(library(filesex)).
-:- prolog_load_context(directory, ChildDir),
- file_directory_name(ChildDir, ParentDir),
- py_add_lib_dir(ParentDir).
+is_rust_space(GSpace):- is_python_space(GSpace).
-is_metta_space(GSpace):- is_python_space(GSpace).
+is_not_prolog_space(GSpace):- is_rust_space(GSpace).
+is_not_prolog_space(GSpace):- \+ is_asserted_space(GSpace).
-ensure_space(Space,GSpace):- py_is_object(Space),!,GSpace=Space.
-ensure_space(Space,GSpace):-
- var(Space),init_metta_space(GSpace), Space=GSpace.
+ensure_space_py(Space,GSpace):- py_is_object(Space),!,GSpace=Space.
+ensure_space_py(Space,GSpace):- var(Space),init_primary_metta_space(GSpace), Space=GSpace.
:- dynamic(is_metta/1).
-init_metta(MeTTa):- is_metta(MeTTa),!.
-init_metta(MeTTa):-
+ensure_rust_metta(MeTTa):- is_metta(MeTTa),!.
+ensure_rust_metta(MeTTa):-
py_call(hyperon:'MeTTa'(),MeTTa),
asserta(is_metta(MeTTa)).
-% Initialize a new hyperon.base.GroundingSpace and get a reference
-init_metta_space(GSpace) :- is_metta_space(GSpace),!.
-init_metta_space(GSpace) :- init_metta(MeTTa), py_call(MeTTa:space(),GSpace),
- asserta(is_python_space(GSpace)).
-init_metta_space(GSpace) :-
- py_call(hyperon:base:'GroundingSpace'(), GSpace),
- asserta(is_python_space(GSpace)).
+:- dynamic(is_metta_learner/1).
+ensure_metta_learner(Metta_Learner):- is_metta_learner(Metta_Learner),!.
+ensure_metta_learner(Metta_Learner):-
+ py_call(metta_vspace:'metta_learner':'MettaLearner'(),Metta_Learner),
+ asserta(is_metta_learner(Metta_Learner)).
:- multifile(space_type_method/3).
:- dynamic(space_type_method/3).
-space_type_method(is_python_space_not_prolog,new_space,init_metta_space).
-space_type_method(is_python_space_not_prolog,add_atom,add_to_space).
-space_type_method(is_python_space_not_prolog,remove_atom,remove_from_space).
-space_type_method(is_python_space_not_prolog,replace_atom,replace_in_space).
-space_type_method(is_python_space_not_prolog,atom_count,atom_count_in_space).
-space_type_method(is_python_space_not_prolog,get_atoms,query_from_space).
-space_type_method(is_python_space_not_prolog,atom_iter,atoms_iter_in_space).
-space_type_method(is_python_space_not_prolog,query,query_from_space).
+space_type_method(is_not_prolog_space,new_space,new_rust_space).
+space_type_method(is_not_prolog_space,add_atom,add_to_space).
+space_type_method(is_not_prolog_space,remove_atom,remove_from_space).
+space_type_method(is_not_prolog_space,replace_atom,replace_in_space).
+space_type_method(is_not_prolog_space,atom_count,atom_count_from_space).
+space_type_method(is_not_prolog_space,get_atoms,query_from_space).
+space_type_method(is_not_prolog_space,atom_iter,atoms_iter_from_space).
+space_type_method(is_not_prolog_space,query,query_from_space).
+
+% Initialize a new hyperon.base.GroundingSpace and get a reference
+init_primary_metta_space(GSpace) :- is_rust_space(GSpace),!.
+init_primary_metta_space(GSpace) :- ensure_rust_metta(MeTTa), py_call(MeTTa:space(),GSpace),
+ asserta(is_python_space(GSpace)).
+init_primary_metta_space(GSpace) :- new_rust_space(GSpace).
+
+:- if( \+ current_predicate(new_rust_space/1 )).
+% Initialize a new hyperon.base.GroundingSpace and get a reference
+new_rust_space(GSpace) :-
+ py_call(hyperon:base:'GroundingSpace'(), GSpace),
+ asserta(is_python_space(GSpace)).
+:- endif.
+:- if( \+ current_predicate(query_from_space/3 )).
% Query from hyperon.base.GroundingSpace
query_from_space(Space, QueryAtom, Result) :-
ensure_space(Space,GSpace),
py_call(GSpace:'query'(QueryAtom), Result).
-% Add an atom to hyperon.base.GroundingSpace
-add_to_space(Space, Atom) :-
- ensure_space(Space,GSpace),
- py_call(GSpace:'add'(Atom), _).
-
-% Remove an atom from hyperon.base.GroundingSpace
-remove_from_space(Space, Atom) :-
- ensure_space(Space,GSpace),
- py_call(GSpace:'remove'(Atom), _).
% Replace an atom in hyperon.base.GroundingSpace
replace_in_space(Space, FromAtom, ToAtom) :-
@@ -73,28 +78,57 @@
py_call(GSpace:'replace'(FromAtom, ToAtom), _).
% Get the atom count from hyperon.base.GroundingSpace
-atom_count_in_space(Space, Count) :-
+atom_count_from_space(Space, Count) :-
ensure_space(Space,GSpace),
py_call(GSpace:'atom_count'(), Count).
% Get the atom count from hyperon.base.GroundingSpace
-atom_count_in_space(Space, Count) :-
+atom_count_from_space(Space, Count) :-
ensure_space(Space,GSpace),
py_call(GSpace:'get_atoms'(), Count).
% Get the atom iterator from hyperon.base.GroundingSpace
-atoms_iter_in_space(Space, Atoms) :-
+atoms_iter_from_space(Space, Atoms) :-
ensure_space(Space,GSpace),
py_call(GSpace:'atoms_iter'(), Atoms).
+:- endif.
+
+
+% Remove an atom from hyperon.base.GroundingSpace
+:- if( \+ current_predicate(remove_from_space/2 )).
+remove_from_space(Space, Atom) :-
+ ensure_space(Space,GSpace),
+ py_call(GSpace:'remove'(Atom), _).
+:- endif.
+
+% Add an atom to hyperon.base.GroundingSpace
+:- if( \+ current_predicate(add_to_space/2 )).
+add_to_space(Space, Atom) :-
+ ensure_space(Space,GSpace),
+ py_call(GSpace:'add'(Atom), _).
+:- endif.
+
+'extend-py!'(Module,_):-
+ set_prolog_flag(argv,[]),
+ %listing(ensure_rust_metta/1),
+ ensure_metta_learner,
+ wdmsg('extend-py!'(Module)),
+ ensure_rust_metta(MeTTa),
+ replace_in_string(["/"="."],Module,ToPython),
+ py_call(MeTTa:load_py_module(ToPython),Result),
+ wdmsg(result(MeTTa->Result)),!.
+ensure_metta_learner:-
+ ensure_metta_learner(Learner),
+ wdmsg(ensure_metta_learner(Learner)).
% Example usage
example_usage :-
- init_metta_space(GSpace),
+ init_primary_metta_space(GSpace),
query_from_space(GSpace, some_query, Result),
- write(Result).
+ writeln(Result).
/*
@@ -111,3 +145,11 @@
*/
+
+%:- ensure_loaded(metta_interp).
+
+%:- prolog_load_context(directory, ChildDir),
+% file_directory_name(ChildDir, ParentDir),
+% py_add_lib_dir(ParentDir).
+
+
diff --git a/metta_vspace/pyswip/metta_space.pl b/metta_vspace/pyswip/metta_space.pl
index 7c475431..e78d6c83 100755
--- a/metta_vspace/pyswip/metta_space.pl
+++ b/metta_vspace/pyswip/metta_space.pl
@@ -469,7 +469,7 @@
pp_sex(V) :- w_proper_indent(2,w_in_p(pp_sexi(V))).
-no_src_indents:- option_else(src_indents,TF,true),!,TF=='False'.
+no_src_indents:- option_else(src_indents,TF,true),!,TF\=='True'.
pp_sexi_l([H,S]):-H=='[...]', write('['),print_items_list(S),write(' ]').
pp_sexi_l([H,S]):-H=='{...}', write('{'),print_items_list(S),write(' }').
diff --git a/metta_vspace/pyswip/metta_types.pl b/metta_vspace/pyswip/metta_types.pl
index 466ebe1d..58c5b374 100755
--- a/metta_vspace/pyswip/metta_types.pl
+++ b/metta_vspace/pyswip/metta_types.pl
@@ -171,16 +171,22 @@
state_decltype(Expr,Type):- functor(Expr,_,A),arg(A,Expr,Type),once(var(Type);is_decl_type(Type)).
+
get_type1(_Dpth,_Slf,Var,'%Undefined%'):- var(Var),!.
get_type1(_Dpth,_Slf,Val,'Number'):- number(Val),!.
get_type1(Depth,Self,Expr,['StateMonad',Type]):- is_valid_nb_state(Expr),'get-state'(Expr,Val),!,
get_type1(Depth,Self,Val,Type).
-get_type1(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),eval_args(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
+
+
+get_type1(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),
+ eval_args(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
get_type1(Depth,Self,Val,Type).
+
get_type1(_Dpth,Self,[Fn|_],Type):- symbol(Fn),metta_type(Self,Fn,List),last_element(List,Type), nonvar(Type),
is_type(Type).
get_type1(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,List,LType),last_element(LType,Type), nonvar(Type),
is_type(Type).
+
get_type1(Depth,_Slf,Type,Type):- Depth<1,!.
get_type1(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,Type,['->'|List]).
get_type1(Depth,Self,List,Types):- List\==[], is_list(List),Depth2 is Depth-1,maplist(get_type1(Depth2,Self),List,Types).
@@ -188,7 +194,11 @@
%get_type1(Depth,Self,Fn,Type):- nonvar(Fn),metta_type(Self,Fn,Type2),Depth2 is Depth-1,get_type1(Depth2,Self,Type2,Type).
%get_type1(Depth,Self,Fn,Type):- Depth>0,nonvar(Fn),metta_type(Self,Type,Fn),!. %,!,last_element(List,Type).
-get_type1(Depth,Self,Expr,Type):-Depth2 is Depth-1, eval_args(Depth2,Self,Expr,Val),Expr\=@=Val,get_type1(Depth2,Self,Val,Type).
+get_type1(Depth,Self,Expr,Type):-Depth2 is Depth-1,
+ eval_args(Depth2,Self,Expr,Val),
+ Expr\=@=Val,get_type1(Depth2,Self,Val,Type).
+
+
get_type1(_Dpth,_Slf,Val,'String'):- string(Val),!.
get_type1(_Dpth,_Slf,Val,Type):- is_decl_type(Val),Type=Val.
get_type1(_Dpth,_Slf,Val,'Bool'):- (Val=='False';Val=='True'),!.
@@ -201,9 +211,19 @@
%get_type1(Depth,Self,Val,Type):- Depth2 is Depth-1, get_type0(Depth2,Self,Val,Type).
+
+as_prolog(_Dpth,_Slf,I,O):- \+ iz_conz(I),!,I=O.
+as_prolog(Depth,Self,[H|T],O):- H=='::',!,as_prolog(Depth,Self,T,O).
+as_prolog(Depth,Self,[H|T],[HH|TT]):- as_prolog(Depth,Self,H,HH),as_prolog(Depth,Self,T,TT).
+
+
+
adjust_args(_Dpth,Self,F,X,X):- (is_special_op(Self,F); \+ iz_conz(X)),!.
adjust_args(Depth,Self,Op,X,Y):-
get_operator_typedef(Self,Op,Params,RetType),
+ try_adjust_arg_types(RetType,Depth,Self,Params,X,Y).
+
+try_adjust_arg_types(RetType,Depth,Self,Params,X,Y):-
as_prolog(Depth,Self,X,M),
args_conform(Depth,Self,M,Params),!,
set_type(Depth,Self,Y,RetType),
@@ -248,9 +268,6 @@
is_pro_eval_kind('Symbol').
is_pro_eval_kind('Bool').
-
-
-
is_feo_f('Cons').
is_seo_f('{...}').
@@ -263,8 +280,7 @@
is_seo_f('Concept').
is_seo_f(N):- number(N),!.
-
-is_user_defined_goal(Self,[H|_]):- is_user_defined_head(Self,H).
+%is_user_defined_goal(Self,[H|_]):- is_user_defined_head(Self,H).
is_user_defined_head(Other,H):- mnotrace(is_user_defined_head0(Other,H)).
is_user_defined_head0(Other,[H|_]):- !, nonvar(H),!, is_user_defined_head_f(Other,H).
@@ -275,13 +291,17 @@
is_user_defined_head_f(Other,H):- is_user_defined_head_f1(Other,[H|_]).
%is_user_defined_head_f1(Other,H):- metta_type(Other,H,_).
-is_user_defined_head_f1(Other,H):- metta_atom(Other,[H|_]).
+%s_user_defined_head_f1(Other,H):- metta_atom(Other,[H|_]).
is_user_defined_head_f1(Other,H):- metta_defn(Other,[H|_],_).
%is_user_defined_head_f(_,H):- is_metta_builtin(H).
+
+is_special_op(Op):- current_self(Self),is_special_op(Self,Op).
+
is_special_op(_Slf,F):- \+ atom(F), \+ var(F), !, fail.
-is_special_op(Self,Op):- get_operator_typedef(Self,Op,Params,_RetType), maplist(=('Atom'),Params).
+is_special_op(Self,Op):- get_operator_typedef(Self,Op,Params,_RetType),
+ maplist(is_non_eval_kind,Params).
is_special_op(_Slf,Op):- is_special_builtin(Op).
is_syspred(H,Len,Pred):- notrace(is_syspred0(H,Len,Pred)).
@@ -290,11 +310,10 @@
is_syspred0(H,Len,Pred):- current_predicate(H/Len),!,Pred=H.
is_syspred0(H,Len,Pred):- atom_concat(Mid,'!',H), H\==Mid, is_syspred0(Mid,Len,Pred),!.
is_syspred0(H,Len,Pred):- into_underscores(H,Mid), H\==Mid, is_syspred0(Mid,Len,Pred),!.
-
%is_function(F):- atom(F).
is_metta_data_functor(_Othr,H):- clause(is_data_functor(H),_).
is_metta_data_functor(Other,H):- H\=='Right', H\=='Something',
- metta_type(Other,H,_), % fail,
+ % metta_type(Other,H,_), % fail,
\+ metta_atom(Other,[H|_]),
\+ metta_defn(Other,[H|_],_),
\+ is_metta_builtin(H),
@@ -306,9 +325,10 @@
get_operator_typedef1(Self,Op,Params,RetType)*->true;
get_operator_typedef2(Self,Op,Params,RetType).
get_operator_typedef1(Self,Op,Params,RetType):-
- metta_type(Self,Op,['->'|List]), once(append(Params,[RetType],List)).
-get_operator_typedef2(Self,Op,Params,RetType):- fail,
- wdmsg(missing(get_operator_typedef2(Self,Op,Params,RetType))),!,fail.
+ metta_type(Self,Op,['->'|List]),
+ append(Params,[RetType],List).
+get_operator_typedef2(Self,Op,Params,RetType):-
+ nop(wdmsg(missing(get_operator_typedef2(Self,Op,Params,RetType)))),!,fail.
is_metta_data_functor(F):-
current_self(Self),is_metta_data_functor(Self,F).
@@ -317,7 +337,7 @@
is_special_builtin('case').
is_special_builtin(':').
-is_special_builtin('=').
+%is_special_builtin('=').
is_special_builtin('->').
is_special_builtin('bind!').
%is_special_builtin('new-space').
@@ -332,12 +352,12 @@
is_special_builtin('call').
is_special_builtin('let').
is_special_builtin('let*').
-%is_special_builtin('nop').
+is_special_builtin('nop').
is_special_builtin('assertEqual').
is_special_builtin('assertEqualToResult').
is_special_builtin('collapse').
is_special_builtin('superpose').
-is_special_builtin('==').
+%is_special_builtin('==').
is_metta_builtin(Special):- is_special_builtin(Special).
@@ -1133,3 +1153,4 @@
%
+
diff --git a/metta_vspace/pyswip/metta_utils.pl b/metta_vspace/pyswip/metta_utils.pl
index a2d6558d..c3286ffb 100755
--- a/metta_vspace/pyswip/metta_utils.pl
+++ b/metta_vspace/pyswip/metta_utils.pl
@@ -239,13 +239,14 @@
%must_det_ll(G):- !, once((/*notrace*/(G)*->true;md_failed(P1,G))).
%:- if( \+ current_predicate(must_det_ll/1)).
+must_det_ll(X):- tracing,!,once(X).
must_det_ll(X):- md(once,X).
%:- endif.
+md(P1,G):- tracing,!, call(P1,G). % once((call(G)*->true;md_failed(P1,G))).
md(P1,G):- remove_must_det(MD), wraps_each(MD,P1),!,call(G).
md(P1,G):- never_rrtrace,!, call(P1,G).
md(P1,G):- /*notrace*/(arc_html),!, ignore(/*notrace*/(call(P1,G))),!.
-md(P1,G):- tracing,!, call(P1,G). % once((call(G)*->true;md_failed(P1,G))).
%md(P1,X):- !,must_not_error(X).
md(P1,(X,Goal)):- is_trace_call(X),!,call((itrace,call(P1,Goal))).
md(_, X):- is_trace_call(X),!,itrace.
diff --git a/metta_vspace/pyswip/read_obo b/metta_vspace/pyswip/read_obo
deleted file mode 100644
index e69de29b..00000000
diff --git a/metta_vspace/pyswip/read_obo.pl b/metta_vspace/pyswip/read_obo.pl
deleted file mode 100644
index e69de29b..00000000
diff --git a/metta_vspace/pyswip/swi_support.pl b/metta_vspace/pyswip/swi_support.pl
index 7830309e..719f1409 100755
--- a/metta_vspace/pyswip/swi_support.pl
+++ b/metta_vspace/pyswip/swi_support.pl
@@ -45,16 +45,25 @@
was_option_value(N,V):- current_prolog_flag(N,VV),!,V=VV.
was_option_value(N,V):- prolog_load_context(N,VV),!,V=VV.
-option_else( N,V,_Else):- was_option_value(N,VV),!,VV=V.
-option_else(_N,V, Else):- !,V=Else.
-
-option_value( N,V):- nonvar(V), option_value( N,VV), p2m(VV,V1),p2m(V,V2),!,equal_enough(V1,V2).
-option_value( N,V):- option_else( N,V ,[]).
-
+option_else(N,V,Else):- notrace(option_else0(N,V,Else)).
+option_else0( N,V,_Else):- was_option_value(N,VV),!,VV=V.
+option_else0(_N,V, Else):- !,V=Else.
+
+option_value(N,V):- notrace(option_value0(N,V)).
+option_value0( N,V):- nonvar(V), option_value0( N,VV), !, p2m(VV,V1),p2m(V,V2),!,V1=V2.%equal_enough(V1,V2).
+option_value0( N,V):- option_else0( N,V ,[]).
+
+p2mE(NA,NA):- \+ atom(NA),!.
+p2mE(false,'False').
+p2mE(true,'True').
+p2mE(E,E).
set_option_value(N,V):-
- catch(nb_setval(N,V),E,fbug(E)),
+ set_option_value0(N,V).
+set_option_value0(N,V):-
+ p2mE(V,VV),!,
+ catch(nb_setval(N,VV),E,fbug(E)),
catch(create_prolog_flag(N,V,[keep(false),access(read_write), type(term)]),E,fbug(E)),
- catch(set_prolog_flag(N,V),E,fbug(E)).
+ catch(set_prolog_flag(N,V),E,fbug(E)),!.
kaggle_arc:- \+ exists_directory('/opt/logicmoo_workspace/packs_sys/logicmoo_agi/prolog/kaggle_arc/'), !.
%kaggle_arc:- !.
diff --git a/metta_vspace/pyswip_2a/flybase_convert.pl b/metta_vspace/pyswip_2a/flybase_convert.pl
index 84f63d2a..4ce70154 100644
--- a/metta_vspace/pyswip_2a/flybase_convert.pl
+++ b/metta_vspace/pyswip_2a/flybase_convert.pl
@@ -4,8 +4,7 @@
:- ensure_loaded(flybase_main).
:- ensure_loaded(flybase_json).
+:- ensure_loaded(flybase_obo).
%:- ensure_loaded(swi_support).
-%:- ensure_loaded(flybase_obo).
-:- ensure_loaded(flybase_main).
diff --git a/metta_vspace/pyswip_6l/metta_data.pl b/metta_vspace/pyswip_6l/metta_data.pl
index 238dc15f..a9e9b722 100755
--- a/metta_vspace/pyswip_6l/metta_data.pl
+++ b/metta_vspace/pyswip_6l/metta_data.pl
@@ -175,7 +175,8 @@
get_type1(_Dpth,_Slf,Val,'Number'):- number(Val),!.
get_type1(Depth,Self,Expr,['StateMonad',Type]):- is_valid_nb_state(Expr),'get-state'(Expr,Val),!,
get_type1(Depth,Self,Val,Type).
-get_type1(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),eval_args(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
+get_type1(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),
+ eval_args(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
get_type1(Depth,Self,Val,Type).
get_type1(_Dpth,Self,[Fn|_],Type):- symbol(Fn),metta_type(Self,Fn,List),last_element(List,Type), nonvar(Type),
is_type(Type).
@@ -188,7 +189,9 @@
%get_type1(Depth,Self,Fn,Type):- nonvar(Fn),metta_type(Self,Fn,Type2),Depth2 is Depth-1,get_type1(Depth2,Self,Type2,Type).
%get_type1(Depth,Self,Fn,Type):- Depth>0,nonvar(Fn),metta_type(Self,Type,Fn),!. %,!,last_element(List,Type).
-get_type1(Depth,Self,Expr,Type):-Depth2 is Depth-1, eval_args(Depth2,Self,Expr,Val),Expr\=@=Val,get_type1(Depth2,Self,Val,Type).
+get_type1(Depth,Self,Expr,Type):-Depth2 is Depth-1,
+ eval_args(Depth2,Self,Expr,Val),
+ Expr\=@=Val,get_type1(Depth2,Self,Val,Type).
get_type1(_Dpth,_Slf,Val,'String'):- string(Val),!.
get_type1(_Dpth,_Slf,Val,Type):- is_decl_type(Val),Type=Val.
get_type1(_Dpth,_Slf,Val,'Bool'):- (Val=='False';Val=='True'),!.
@@ -201,9 +204,19 @@
%get_type1(Depth,Self,Val,Type):- Depth2 is Depth-1, get_type0(Depth2,Self,Val,Type).
+
+as_prolog(_Dpth,_Slf,I,O):- \+ iz_conz(I),!,I=O.
+as_prolog(Depth,Self,[H|T],O):- H=='::',!,as_prolog(Depth,Self,T,O).
+as_prolog(Depth,Self,[H|T],[HH|TT]):- as_prolog(Depth,Self,H,HH),as_prolog(Depth,Self,T,TT).
+
+
+
adjust_args(_Dpth,Self,F,X,X):- (is_special_op(Self,F); \+ iz_conz(X)),!.
adjust_args(Depth,Self,Op,X,Y):-
get_operator_typedef(Self,Op,Params,RetType),
+ try_adjust_arg_types(RetType,Depth,Self,Params,X,Y).
+
+try_adjust_arg_types(RetType,Depth,Self,Params,X,Y):-
as_prolog(Depth,Self,X,M),
args_conform(Depth,Self,M,Params),!,
set_type(Depth,Self,Y,RetType),
diff --git a/metta_vspace/pyswip_6l/metta_eval.pl b/metta_vspace/pyswip_6l/metta_eval.pl
index 357ececb..552bec10 100755
--- a/metta_vspace/pyswip_6l/metta_eval.pl
+++ b/metta_vspace/pyswip_6l/metta_eval.pl
@@ -1,22 +1,19 @@
-:- style_check(-singleton).
-
-%self_eval(X):- var(X),!.
-%self_eval(X):- string(X),!.
-%self_eval(X):- number(X),!.
-%self_eval([]).
-self_eval(X):- \+ callable(X),!.
-self_eval(X):- is_metta_declaration(X),!.
-self_eval(X):- is_valid_nb_state(X),!.
-self_eval(X):- is_list(X),!,fail.
-self_eval(X):- typed_list(X,_,_),!.
-%self_eval(X):- compound(X),!.
-%self_eval(X):- is_ref(X),!,fail.
-self_eval(X):- atom(X),!, \+ nb_current(X,_),!.
-self_eval('True'). self_eval('False'). % self_eval('F').
-self_eval('Empty').
+%:- style_check(-singleton).
+self_eval0(X):- \+ callable(X),!.
+self_eval0(X):- is_valid_nb_state(X),!.
+self_eval0(X):- atom(X),!, \+ nb_current(X,_),!.
+self_eval0(X):- is_metta_declaration(X),!.
+self_eval0(X):- is_list(X),!,fail.
+self_eval0(X):- typed_list(X,_,_),!.
+%self_eval0(X):- compound(X),!.
+%self_eval0(X):- is_ref(X),!,fail.
+self_eval0('True'). self_eval0('False'). % self_eval0('F').
+self_eval0('Empty').
+
+self_eval(X):- notrace(self_eval0(X)).
:- set_prolog_flag(access_level,system).
hyde(F/A):- functor(P,F,A), redefine_system_predicate(P),'$hide'(F/A), '$iso'(F/A).
@@ -32,43 +29,71 @@
%:- 'hyde'(option_value/2).
-is_metta_declaration([F,_,_|T]):- T ==[], (F==':'; (F=='=', \+
+is_metta_declaration([F|_]):- F == '->',!.
+is_metta_declaration([F,_,_|T]):- T ==[], is_metta_declaration_f(F).
+
+is_metta_declaration_f(F):- F == ':', !.
+is_metta_declaration_f(F):- F == '=', !,
+ \+ (current_self(Space), is_user_defined_head_f(Space,F)).
+
+(F==':';
+ (F=='=', \+
\+ (current_self(Space), is_user_defined_head_f(Space,F)))).
% is_metta_declaration([F|T]):- is_list(T), is_user_defined_head([F]),!.
:- nb_setval(self_space, '&self').
-evals_to(XX,Y):- Y==XX,!.
+evals_to(XX,Y):- Y=@=XX,!.
evals_to(XX,Y):- Y=='True',!, is_True(XX),!.
current_self(Space):- nb_current(self_space,Space).
-eval_args(A,AA):-
- eval_args(_RetType,A,AA).
-eval_args(RetType,A,AA):-
- current_self(Space),
- eval_args(RetType,1000,Space,A,AA).
-eval_args(Depth,Self,X,Y):-
- eval_args(_RetType,Depth,Self,X,Y).
-%eval_args(RetType,Depth,_Self,X,_Y):- forall(between(6,Depth,_),write(' ')),writeqln(eval_args(RetType,X)),fail.
+do_expander('=',_,X,X):-!.
+do_expander(':',_,X,Y):- !, get_type(X,Y)*->X=Y.
+
+'get_type'(Arg,Type):- 'get-type'(Arg,Type).
+
+
+
+
+eval_args(X,Y):- current_self(Space), eval_args(100,Space,X,Y).
+eval_args(Depth,Self,X,Y):- eval(Depth,Self,X,Y).
+eval_args(Expander,RetType,Depth,Self,X,Y):- eval(Expander,RetType,Depth,Self,X,Y).
+
+%eval(Expander,RetType,Depth,_Self,X,_Y):- forall(between(6,Depth,_),write(' ')),writeqln(eval(Expander,RetType,X)),fail.
+eval(Depth,Self,X,Y):- eval('=',_RetType,Depth,Self,X,Y).
+
+%eval(Expander,RetType,_Dpth,_Slf,X,Y):- nonvar(Y),X=Y,!.
+eval(Expander,RetType,Depth,Self,X,Y):- nonvar(Y),!,
+ get_type(Depth,Self,Y,RetType), !,
+ eval(Expander,RetType,Depth,Self,X,XX),evals_to(XX,Y).
-eval_args(RetType,Depth,Self,X,Y):-
- notrace(allow_repeats_eval(X)),
+eval(_Expander,_RetType,_Dpth,_Slf,X,Y):- var(X),!,Y=X.
+
+eval(Expander,RetType,_Dpth,_Slf,[X|T],Y):- T==[], number(X),!, do_expander(Expander,RetType,X,YY),Y=[YY].
+
+eval(Expander,RetType,Depth,Self,[F|X],Y):-
+ (F=='superpose' ; ( option_value(no_repeats,false))),
+ notrace((D1 is Depth-1)),!,
+ eval_00(Expander,RetType,D1,Self,[F|X],Y).
+
+eval(Expander,RetType,Depth,Self,X,Y):-
+ notrace(allow_repeats_eval_(X)),
!,
- eval_args00(RetType,Depth,Self,X,Y).
-eval_args(RetType,Depth,Self,X,Y):-
+ eval_00(Expander,RetType,Depth,Self,X,Y).
+eval(Expander,RetType,Depth,Self,X,Y):-
notrace((no_repeats_var(YY),
D1 is Depth-1)),
- eval_args00(RetType,D1,Self,X,Y),
+ eval_00(Expander,RetType,D1,Self,X,Y),
notrace(( \+ (Y\=YY))).
-allow_repeats_eval(_):- !.
-allow_repeats_eval(_):- option_value(no_repeats,false),!.
-allow_repeats_eval(X):- \+ is_list(X),!,fail.
-allow_repeats_eval([F|_]):- atom(F),allow_repeats_eval_f(F).
+allow_repeats_eval_(_):- !.
+allow_repeats_eval_(_):- option_value(no_repeats,false),!.
+allow_repeats_eval_(X):- \+ is_list(X),!,fail.
+allow_repeats_eval_([F|_]):- atom(F),allow_repeats_eval_f(F).
allow_repeats_eval_f('superpose').
allow_repeats_eval_f('collapse').
@@ -91,7 +116,7 @@
with_debug(Flag,Goal):- is_debugging(Flag),!, call(Goal).
with_debug(Flag,Goal):- flag(eval_num,_,0),
- setup_call_cleanup(set_debug(Flag,true),call(Goal),set_debug(Flag,flase)).
+ setup_call_cleanup(set_debug(Flag,true),call(Goal),set_debug(Flag,false)).
flag_to_var(Flag,Var):- atom(Flag), \+ atom_concat('trace-on-',_,Flag),!,atom_concat('trace-on-',Flag,Var).
flag_to_var(metta(Flag),Var):- !, nonvar(Flag), flag_to_var(Flag,Var).
@@ -124,27 +149,27 @@
:- nodebug(metta(overflow)).
-eval_args_ne(RetType,Depth,Self,X,E):- eval_args(RetType,Depth,Self,X,E), \+ return_empty([],E).
-eval_args90(RetType,Depth,Self,X,Y):- eval_args_ne(RetType,Depth,Self,X,Y). %*->true;eval_args_failed(Depth,Self,X,Y).
-eval_args99(RetType,Depth,Self,X,Y):- eval_args(RetType,Depth,Self,X,Y)*->true;eval_args_failed(Depth,Self,X,Y).
+eval_ne(Expander,RetType,Depth,Self,X,E):- eval(Expander,RetType,Depth,Self,X,E), \+ return_empty([],E).
+eval_90(Expander,RetType,Depth,Self,X,Y):- eval_ne(Expander,RetType,Depth,Self,X,Y). %*->true;eval_failed(Depth,Self,X,Y).
+eval_99(Expander,RetType,Depth,Self,X,Y):- eval(Expander,RetType,Depth,Self,X,Y)*->true;eval_failed(Depth,Self,X,Y).
-eval_args00(_RetType,Dpth,_Slf,X,Y):- Dpth<0,!,X = Y.
-eval_args00(RetType,_Dpth,_Slf,X,Y):- nonvar(Y),X=Y,!, check_returnval(RetType,Y).
-eval_args00(RetType,_Dpth,_Slf,X,Y):- notrace(var(X)),!,X=Y, check_returnval(RetType,Y).
-eval_args00(RetType,Depth,Self,X,Y):- notrace(nonvar(Y)),!,eval_args00(RetType,Depth,Self,X,XX),evals_to(XX,Y).
-eval_args00(RetType,_Dpth,_Slf,X,Y):- notrace(self_eval(X)),!,Y=X, check_returnval(RetType,Y).
-eval_args00(RetType,_Dpth,_Slf,[X|T],Y):- notrace((T==[], \+ callable(X))),!,Y=[X], check_returnval(RetType,Y).
-eval_args00(RetType,Depth,_Slf,X,Y):- Depth<1,!,X=Y, (\+ is_debugging(overflow)-> true; flag(eval_num,_,0),set_debug((eval),true)), check_returnval(RetType,Y).
-%eval_args00(RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
-eval_args00(RetType,Depth,Self,X,Y):-
+eval_00(Expander,_RetType,Dpth,_Slf,X,Y):- Dpth<0,!,X = Y.
+eval_00(Expander,RetType,_Dpth,_Slf,X,Y):- nonvar(Y),X=Y,!, check_returnval(Expander,RetType,Y).
+eval_00(Expander,RetType,_Dpth,_Slf,X,Y):- notrace(var(X)),!,X=Y, check_returnval(Expander,RetType,Y).
+eval_00(Expander,RetType,Depth,Self,X,Y):- notrace(nonvar(Y)),!,eval_00(Expander,RetType,Depth,Self,X,XX),eval_s_to(XX,Y).
+eval_00(Expander,RetType,_Dpth,_Slf,X,Y):- notrace(self_eval(X)),!,Y=X, check_returnval(Expander,RetType,Y).
+eval_00(Expander,RetType,_Dpth,_Slf,[X|T],Y):- notrace((T==[], \+ callable(X))),!,Y=[X], check_returnval(Expander,RetType,Y).
+eval_00(Expander,RetType,Depth,_Slf,X,Y):- Depth<1,!,X=Y, (\+ is_debugging(overflow)-> true; flag(eval_num,_,0),set_debug((eval),true)), check_returnval(Expander,RetType,Y).
+%eval_00(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
+eval_00(Expander,RetType,Depth,Self,X,Y):-
Answers=ans([]),
copy_term(X,XX),
Depth2 is Depth-1,
- call_nth(eval_args111(RetType,Depth,Self,X,M),Nth),
+ call_nth(eval_111(Expander,RetType,Depth,Self,X,M),Nth),
(is_bool_or_same(XX,Answers,Nth,M)
-> (!, (Nth=1->Y=M;fail) )
- ; eval_args(RetType,Depth2,Self,M,Y)),
+ ; eval(Expander,RetType,Depth2,Self,M,Y)),
nop(nonvar(Y)).
is_bool_or_same( X,_Ans,_Nth,M):- X=@=M,!.
@@ -161,32 +186,32 @@
%if_trace(not('disable-exec-trace'),
if_may_trace(G):- once(G).
-eval_args111(_RetType,Dpth,_Slf,X,Y):- Dpth<0,!,X = Y.
-eval_args111(RetType,Depth,Self,X,Y):-
+eval_111(Expander,_RetType,Dpth,_Slf,X,Y):- Dpth<0,!,X = Y.
+eval_111(Expander,RetType,Depth,Self,X,Y):-
copy_term(X,XX),
Depth2 is Depth-1,
- eval_args11(RetType,Depth2,Self,X,M),
- ((XX=@=M;X=@=M) -> Y =M ; eval_args00(RetType,Depth2,Self,M,Y)).
+ eval_11(Expander,RetType,Depth2,Self,X,M),
+ ((XX=@=M;X=@=M) -> Y =M ; eval_00(Expander,RetType,Depth2,Self,M,Y)).
- %eval_args11(RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
-%eval_args11(RetType,Depth,Self,X,Y):- \+ debugging(metta(eval)),!, eval_args20(RetType,Depth,Self,X,Y).
+ %eval_11(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
+%eval_11(Expander,RetType,Depth,Self,X,Y):- \+ debugging(metta(eval)),!, eval_20(Expander,RetType,Depth,Self,X,Y).
-eval_args11f(_Dpth,_Slf,[F|LESS],Res):- notrace((ground([F|LESS]),once(maybe_efbug(show_success,eval_selfless([F|LESS],Res))),mnotrace(([F|LESS]\==Res)))).
+eval_11f(_Dpth,_Slf,[F|LESS],Res):- notrace((ground([F|LESS]),once(maybe_efbug(show_success,eval_selfless([F|LESS],Res))),mnotrace(([F|LESS]\==Res)))).
-eval_args11(RetType,Depth,Self, [Op|More], Res):-
+eval_11(Expander,RetType,Depth,Self, [Op|More], Res):-
mnotrace(( get_sa_p3a(ST,More,P1), % ST\==Term,
- compound(ST), eval_args11f(Depth,Self,ST,Var),
+ compound(ST), eval_11f(Depth,Self,ST,Var),
call(P1,Var))), !, %max_counting(F,30), member(Var,List),
- eval_args11(RetType,Depth,Self, [Op|More], Res).
+ eval_11(Expander,RetType,Depth,Self, [Op|More], Res).
-eval_args11(RetType,Depth,Self, [Op|More], Res):- fail,
+eval_11(Expander,RetType,Depth,Self, [Op|More], Res):- fail,
mnotrace(( get_sa_p3(ST,More,P1), % ST\==Term,
- compound(ST), eval_args11f(Depth,Self,ST,Var),
+ compound(ST), eval_11f(Depth,Self,ST,Var),
call(P1,Var))), !, %max_counting(F,30), member(Var,List),
- eval_args11(RetType,Depth,Self, [Op|More], Res).
+ eval_11(Expander,RetType,Depth,Self, [Op|More], Res).
-eval_args11(RetType,Depth,Self,X,Y):- flag(eval_num,EX,EX+1),
+eval_11(Expander,RetType,Depth,Self,X,Y):- flag(eval_num,EX,EX+1),
option_else(traclen,Max,100),
(EX>Max->(set_debug(eval,false),set_debug(exec,false),set_debug(overflow,false),
skip(write('Switched off tracing. For a longer trace !(pragma! tracelen 101))')));true),
@@ -195,10 +220,10 @@
if_may_trace(if_trace((eval),indentq(Depth,'-->'(EX,Self,X,depth(Depth))))),
Ret=retval(fail),
call_cleanup(
- (eval_args20(RetType,D1,Self,X,Y),
+ (eval_20(Expander,RetType,D1,Self,X,Y),
notrace(( nb_setarg(1,Ret,Y)))),
if_may_trace(notrace(ignore(((Y\=@=X,flag(eval_num,_,EX),if_trace((eval),indentq(Depth,'<--'(EX,Ret))))))))),
- (Ret\=@=retval(fail)->true;(rtrace(eval_args20(RetType,D1,Self,X,Y)),fail)).
+ (Ret\=@=retval(fail)->true;(rtrace(eval_20(Expander,RetType,D1,Self,X,Y)),fail)).
@@ -230,38 +255,38 @@
-:- discontiguous eval_args20/5.
-:- discontiguous eval_args20/5.
-:- discontiguous eval_args40/5.
-:- discontiguous eval_args30fz/5.
-:- discontiguous eval_args31/5.
-:- discontiguous eval_args60/5.
+:- discontiguous eval_20/5.
+:- discontiguous eval_20/5.
+:- discontiguous eval_80/5.
+:- discontiguous eval_30fz/5.
+:- discontiguous eval_31/5.
+:- discontiguous eval_60/5.
/*
-eval_args20(RetType,Depth,Self,[F,A|Args],Res):-
+eval_20(Expander,RetType,Depth,Self,[F,A|Args],Res):-
\+ self_eval(A),
- eval_args(RetType,Depth,Self,A,AA),AA\==A,
- eval_args(RetType,Depth,Self,[F,AA|Args],Res).
+ eval(Expander,RetType,Depth,Self,A,AA),AA\==A,
+ eval(Expander,RetType,Depth,Self,[F,AA|Args],Res).
-eval_args20(RetType,Depth,Self,[F,A1|AArgs],Res):- fail, member(F,['+']),
+eval_20(Expander,RetType,Depth,Self,[F,A1|AArgs],Res):- fail, member(F,['+']),
cwdl(40,((
append(L,[A|R],AArgs),
\+ self_eval(A),
- eval_args(RetType,Depth,Self,A,AA),AA\==A,!,
- append(L,[AA|R],NewArgs), eval_args(RetType,Depth,Self,[F,A1|NewArgs],Res)))).
+ eval(Expander,RetType,Depth,Self,A,AA),AA\==A,!,
+ append(L,[AA|R],NewArgs), eval(Expander,RetType,Depth,Self,[F,A1|NewArgs],Res)))).
*/
/* %%
% !(assertEqualToResult ((inc) 2) (3))
-eval_args20(RetType,Depth,Self,[F|Args],Res):- is_list(F),
- metta_atom_iter(Depth,Self,['=',F,R]), eval_args(RetType,Depth,Self,[R|Args],Res).
+eval_20(Expander,RetType,Depth,Self,[F|Args],Res):- is_list(F),
+ metta_atom_iter(Depth,Self,['=',F,R]), eval(Expander,RetType,Depth,Self,[R|Args],Res).
-eval_args20(RetType,Depth,Self,[F|Args],Res):- is_list(F), Args\==[],
- append(F,Args,FArgs),!,eval_args(RetType,Depth,Self,FArgs,Res).
+eval_20(Expander,RetType,Depth,Self,[F|Args],Res):- is_list(F), Args\==[],
+ append(F,Args,FArgs),!,eval(Expander,RetType,Depth,Self,FArgs,Res).
*/
@@ -270,127 +295,127 @@
as_prolog(Depth,Self,[H|T],[HH|TT]):- as_prolog(Depth,Self,H,HH),as_prolog(Depth,Self,T,TT).
-% eval_args20 is "1 step"
-eval_args20(RetType,_Dpth,_Slf,Name,Value):- atom(Name), !, (nb_current(Name,Value) -> true ; Value=Name), check_returnval(Value,RetType).
-eval_args20(RetType,Depth,_,X,Y):- Depth<3, !, ground(X), (Y=X), check_returnval(RetType,Y).
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% VAR HEADS/ NON-LISTS
-% =================================================================
-% =================================================================
-% =================================================================
-
-
-eval_args20(RetType,_Dpth,_Slf,X,Y):- \+ iz_conz(X),!,Y=X, check_returnval(RetType,Y).
-
-
-%eval_args20(RetType,Depth,Self,[V|VI],[V|VO]):- var(V),!, freeze(V,eval_args20(RetType,Depth,Self,[V|VI],[V|VO])).
-eval_args20(_RetType,Depth,Self,[V|VI],[V|VO]):- var(V),!,maplist(eval_args(Depth,Self),VI,VO).
-
-
-eval_args20(RetType,Depth,Self,[V|VI],VVO):- \+ is_list(VI),!,
- eval_args(RetType,Depth,Self,VI,VM),
- ( VM\==VI -> eval_args(RetType,Depth,Self,[V|VM],VVO) ;
- (eval_args(RetType,Depth,Self,V,VV), (V\==VV -> eval_args(RetType,Depth,Self,[VV|VI],VVO) ; VVO = [V|VI]))).
-
-eval_args20(RetType,_Dpth,_Slf,X,Y):- \+ is_list(X),!,Y=X, check_returnval(RetType,Y).
-eval_args20(RetType,_Dpth,_Slf,List,Y):- List=[H|_], \+ atom(H), maplist(self_eval,List), !,Y=List, check_returnval(RetType,Y).
-%eval_args20(RetType,_Dpth,_Slf,[V|VI],[V|VO]):- var(V),!,VI=VO.
-%eval_args20(RetType,_Dpth,_Slf,['=',H,B],['=',H,B]):- trace,throw(should_been_caught_by_is_metta_decl/1).
-
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% TRACE/PRINT
-% =================================================================
-% =================================================================
-% =================================================================
-eval_args20(RetType,_Dpth,_Slf,['repl!'],Y):- !, repl,check_returnval(RetType,Y).
-eval_args20(RetType,Depth,Self,['!',Cond],Res):- !, call(eval_args(RetType,Depth,Self,Cond,Res)).
-eval_args20(RetType,Depth,Self,['rtrace',Cond],Res):- !, rtrace(eval_args(RetType,Depth,Self,Cond,Res)).
-eval_args20(RetType,Depth,Self,['trace',Cond],Res):- !, with_debug(eval,eval_args(RetType,Depth,Self,Cond,Res)).
-eval_args20(RetType,Depth,Self,['time',Cond],Res):- !, time_eval(eval(Cond),eval_args(RetType,Depth,Self,Cond,Res)).
-eval_args20(RetType,Depth,Self,['print',Cond],Res):- !, eval_args(RetType,Depth,Self,Cond,Res),format('~N'),print(Res),format('~N').
+% eval_20 is "1 step"
+eval_20(Expander,RetType,_Dpth,_Slf,Name,Value):- atom(Name), !, (nb_current(Name,Value) -> true ; Value=Name), check_returnval(Value,Expander,RetType).
+eval_20(Expander,RetType,Depth,_,X,Y):- Depth<3, !, ground(X), (Y=X), check_returnval(Expander,RetType,Y).
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% VAR HEADS/ NON-LISTS
+% =================================================================
+% =================================================================
+% =================================================================
+
+
+eval_20(Expander,RetType,_Dpth,_Slf,X,Y):- \+ iz_conz(X),!,Y=X, check_returnval(Expander,RetType,Y).
+
+
+%eval_20(Expander,RetType,Depth,Self,[V|VI],[V|VO]):- var(V),!, freeze(V,eval_20(Expander,RetType,Depth,Self,[V|VI],[V|VO])).
+eval_20(Expander,_RetType,Depth,Self,[V|VI],[V|VO]):- var(V),!,maplist(eval(Depth,Self),VI,VO).
+
+
+eval_20(Expander,RetType,Depth,Self,[V|VI],VVO):- \+ is_list(VI),!,
+ eval(Expander,RetType,Depth,Self,VI,VM),
+ ( VM\==VI -> eval(Expander,RetType,Depth,Self,[V|VM],VVO) ;
+ (eval(Expander,RetType,Depth,Self,V,VV), (V\==VV -> eval(Expander,RetType,Depth,Self,[VV|VI],VVO) ; VVO = [V|VI]))).
+
+eval_20(Expander,RetType,_Dpth,_Slf,X,Y):- \+ is_list(X),!,Y=X, check_returnval(Expander,RetType,Y).
+eval_20(Expander,RetType,_Dpth,_Slf,List,Y):- List=[H|_], \+ atom(H), maplist(self_eval,List), !,Y=List, check_returnval(Expander,RetType,Y).
+%eval_20(Expander,RetType,_Dpth,_Slf,[V|VI],[V|VO]):- var(V),!,VI=VO.
+%eval_20(Expander,RetType,_Dpth,_Slf,['=',H,B],['=',H,B]):- trace,throw(should_been_caught_by_is_metta_decl/1).
+
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% TRACE/PRINT
+% =================================================================
+% =================================================================
+% =================================================================
+eval_20(Expander,RetType,_Dpth,_Slf,['repl!'],Y):- !, repl,check_returnval(Expander,RetType,Y).
+eval_20(Expander,RetType,Depth,Self,['!',Cond],Res):- !, call(eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['rtrace!',Cond],Res):- !, rtrace(eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['trace',Cond],Res):- !, with_debug(eval,eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['time',Cond],Res):- !, time_eval(eval(Cond),eval(Expander,RetType,Depth,Self,Cond,Res)).
+eval_20(Expander,RetType,Depth,Self,['print',Cond],Res):- !, eval(Expander,RetType,Depth,Self,Cond,Res),format('~N'),print(Res),format('~N').
% !(println! $1)
-eval_args20(RetType,Depth,Self,['println!'|Cond],Res):- !, maplist(eval_args(RetType,Depth,Self),Cond,[Res|Out]),
+eval_20(Expander,RetType,Depth,Self,['println!'|Cond],Res):- !, maplist(eval(Expander,RetType,Depth,Self),Cond,[Res|Out]),
format('~N'),maplist(write_src,[Res|Out]),format('~N').
-eval_args20(RetType,Depth,Self,['trace!',A|Cond],Res):- !, maplist(eval_args(RetType,Depth,Self),[A|Cond],[AA|Result]),
+eval_20(Expander,RetType,Depth,Self,['trace!',A|Cond],Res):- !, maplist(eval(Expander,RetType,Depth,Self),[A|Cond],[AA|Result]),
last(Result,Res), format('~N'),maplist(write_src,[AA]),format('~N').
-%eval_args20(RetType,Depth,Self,['trace!',A,B],C):- !,eval_args(RetType,Depth,Self,B,C),format('~N'),wdmsg(['trace!',A,B]=C),format('~N').
-%eval_args20(RetType,_Dpth,_Slf,['trace!',A],A):- !, format('~N'),wdmsg(A),format('~N').
-
-
-
-eval_args20(_RetType,Depth,Self,['TupleConcat',A,B],OO):- !,
- eval_args0(RetType,Depth,Self,A,AA),
- eval_args0(RetType,Depth,Self,B,BB),
+%eval_20(Expander,RetType,Depth,Self,['trace!',A,B],C):- !,eval(Expander,RetType,Depth,Self,B,C),format('~N'),wdmsg(['trace!',A,B]=C),format('~N').
+%eval_20(Expander,RetType,_Dpth,_Slf,['trace!',A],A):- !, format('~N'),wdmsg(A),format('~N').
+
+eval_20(Expander,RetType,_Dpth,_Slf,List,YY):- is_list(List),maplist(self_eval,List),List=[H|_], \+ atom(H), !,Y=List,do_expander(Expander,RetType,Y,YY).
+
+eval_20(Expander,_ListOfRetType,Depth,Self,['TupleConcat',A,B],OO):- fail, !,
+ eval(Expander,RetType,Depth,Self,A,AA),
+ eval(Expander,RetType,Depth,Self,B,BB),
append(AA,BB,OO).
-eval_args20(_RetType,Depth,Self,['range',A,B],OO):- (is_list(A);is_list(B)),
- ((eval_args0(RetType,Depth,Self,A,AA),
- eval_args0(RetType,Depth,Self,B,BB))),
+eval_20(Expander,OuterRetType,Depth,Self,['range',A,B],OO):- (is_list(A);is_list(B)),
+ ((eval(Expander,RetType,Depth,Self,A,AA),
+ eval(Expander,RetType,Depth,Self,B,BB))),
((AA+BB)\=@=(A+B)),
- eval_args20(_RetType,Depth,Self,['range',AA,BB],OO).
-
-
-%eval_args20(RetType,Depth,Self,['colapse'|List], Flat):- !, maplist(eval_args(RetType,Depth,Self),List,Res),flatten(Res,Flat).
-
-
+ eval_20(Expander,OuterRetType,Depth,Self,['range',AA,BB],OO),!.
-% =================================================================
-% =================================================================
-% =================================================================
-% UNIT TESTING/assert
-% =================================================================
-% =================================================================
+%eval_20(Expander,RetType,Depth,Self,['colapse'|List], Flat):- !, maplist(eval(Expander,RetType,Depth,Self),List,Res),flatten(Res,Flat).
+
+
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% UNIT TESTING/assert
+% =================================================================
+% =================================================================
% =================================================================
-eval_args20(RetType,Depth,Self,['assertTrue', X],TF):- !, eval_args(RetType,Depth,Self,['assertEqual',X,'True'],TF).
-eval_args20(RetType,Depth,Self,['assertFalse',X],TF):- !, eval_args(RetType,Depth,Self,['assertEqual',X,'False'],TF).
+eval_20(Expander,RetType,Depth,Self,['assertTrue', X],TF):- !, eval(Expander,RetType,Depth,Self,['assertEqual',X,'True'],TF).
+eval_20(Expander,RetType,Depth,Self,['assertFalse',X],TF):- !, eval(Expander,RetType,Depth,Self,['assertEqual',X,'False'],TF).
-eval_args20(RetType,Depth,Self,['assertEqual',X0,Y0],RetVal):- !,
+eval_20(Expander,RetType,Depth,Self,['assertEqual',X0,Y0],RetVal):- !,
subst_vars(X0,X),subst_vars(Y0,Y),
loonit_assert_source_tf(
['assertEqual',X0,Y0],
- (bagof_eval(Depth,Self,X,XX),
- bagof_eval(Depth,Self,Y,YY)),
+ (bagof_eval_(Depth,Self,X,XX),
+ bagof_eval_(Depth,Self,Y,YY)),
equal_enough_for_test(XX,YY), TF),
(TF=='True'->return_empty(RetVal);RetVal=[got,XX,expected,YY]),
- check_returnval(RetType,Y).
+ check_returnval(Expander,RetType,Y).
-eval_args20(RetType,Depth,Self,['assertNotEqual',X0,Y0],RetVal):- !,
+eval_20(Expander,RetType,Depth,Self,['assertNotEqual',X0,Y0],RetVal):- !,
subst_vars(X0,X),subst_vars(Y0,Y),
loonit_assert_source_tf(
['assertNotEqual',X0,Y0],
- (bagof_eval(Depth,Self,X,XX), bagof_eval(Depth,Self,Y,YY)),
+ (bagof_eval_(Depth,Self,X,XX), bagof_eval_(Depth,Self,Y,YY)),
\+ equal_enough(XX,YY), TF),
(TF=='True'->return_empty(RetVal);RetVal=[got,XX,expected,not,YY]),
- check_returnval(RetType,Y).
+ check_returnval(Expander,RetType,Y).
-eval_args20(RetType,Depth,Self,['assertEqualToResult',X0,Y0],RetVal):- !,
+eval_20(Expander,RetType,Depth,Self,['assertEqualToResult',X0,Y0],RetVal):- !,
subst_vars(X0,X),subst_vars(Y0,Y),
loonit_assert_source_tf(
['assertEqualToResult',X0,Y0],
- (bagof_eval(Depth,Self,X,XX), =(Y,YY)),
+ (bagof_eval_(Depth,Self,X,XX), =(Y,YY)),
equal_enough_for_test(XX,YY), TF),
(TF=='True'->return_empty(RetVal);RetVal=[got,XX,expected,YY]),!,
- check_returnval(RetType,Y).
+ check_returnval(Expander,RetType,Y).
loonit_assert_source_tf(Src,Goal,Check,TF):-
copy_term(Goal,OrigGoal),
color_g_mesg('#114411',(writeq(Src))),
- loonit_asserts(Src, time_eval('\n; EVAL TEST\n;',Goal), Check),
+ loonit_asserts(Src, time_eval_('\n; EVAL TEST\n;',Goal), Check),
as_tf(Check,TF),!,
ignore((
once((TF=='True', is_debugging(pass));(TF=='False', is_debugging(fail))),
- with_debug((eval),time_eval('Trace',OrigGoal)))).
+ with_debug((eval),time_eval_('Trace',OrigGoal)))).
sort_result(Res,Res):- \+ compound(Res),!.
sort_result([And|Res1],Res):- is_and(And),!,sort_result(Res1,Res).
@@ -412,7 +437,7 @@
equal_enough(R,V):- is_list(R),is_list(V),sort(R,RR),sort(V,VV),!,equal_enouf(RR,VV),!.
equal_enough(R,V):- copy_term(R,RR),copy_term(V,VV),equal_enouf(R,V),!,R=@=RR,V=@=VV.
-
+
%s_empty(X):- var(X),!.
s_empty(X):- var(X),!,fail.
is_empty('Empty').
@@ -449,53 +474,53 @@
%[superpose,[1,2,3]]
/*
-eval_args20(RetType,Depth,Self,[Superpose,List],Res):-
+eval_20(Expander,RetType,Depth,Self,[Superpose,List],Res):-
'superpose' == Superpose, !,
List=[H|_],
- ((fail,is_user_defined_head_f(Self,H)) -> (eval_args(RetType,Depth,Self,List,RList),member(Res,RList)) ;
- (member(E,List),eval_args(RetType,Depth,Self,E,Res) , \+ return_empty([],Res))).
+ ((fail,is_user_defined_head_f(Self,H)) -> (eval(Expander,RetType,Depth,Self,List,RList),member(Res,RList)) ;
+ (member(E,List),eval(Expander,RetType,Depth,Self,E,Res) , \+ return_empty([],Res))).
*/
-eval_args20(_RtType,_Dpth,_Slf,[Superpose,List],E):-
- 'sequential' == Superpose, !, member(E,List).
+eval_20(_RtType,_Dpth,_Slf,[Superpose,List],E):-
+ 'sequential' == Superpose, !, member(E,List).
-eval_args20(_RtType,_Dpth,_Slf,[Superpose,List],E):-
+eval_20(_RtType,_Dpth,_Slf,[Superpose,List],E):-
'superpose' == Superpose, !, member(E,List).
-eval_args20(RetType,Depth,Self,[Op,Arg1|VI],Res):- !,
+eval_20(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res):- !,
((is_list(Arg1),ground(Arg1),
- get_operator_typedef(Self,Op,[Type1|_Rest],RetType), \+ is_non_eval_kind(Type1),
- set_type(Depth,Res,Self,RetType),!,
- eval_args(Type1,Depth,Self,Arg1,Res1), Arg1\=@=Res1, not_arg_violation(Depth,Self,Res1,Type1))
- *-> (if_trace(eval,write_src_nl(cont([Op,Res1|VI]))),eval_args20(RetType,Depth,Self,[Op,Res1|VI],Res))
- ;eval_args20(RetType,Depth,Self,[Op,Arg1|VI],Res)).
-
-
-eval_args20(_RetType,Depth,Self,[V|VI],[V|VO]):- var(V),!,maplist(eval_args(Depth,Self),VI,VO).
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% SPACE EDITING
-% =================================================================
-% =================================================================
-% =================================================================
-
-
-eval_args20(RetType,Depth,Self,['add-atom',Other,PredDecl],Res):- !, into_space(Depth,Self,Other,Space),
- do_metta(python,load,Space,PredDecl,TF),return_empty([],Res),check_returnval(RetType,TF).
-eval_args20(RetType,Depth,Self,['remove-atom',Other,PredDecl],Res):- !, into_space(Depth,Self,Other,Space),
- do_metta(python,unload,Space,PredDecl,TF),return_empty([],Res),check_returnval(RetType,TF).
-eval_args20(RetType,Depth,Self,['atom-count',Other],Count):- !, (( into_space(Depth,Self,Other,Space), findall(_,metta_defn(Other,_,_),L1),length(L1,C1),
- findall(_,metta_atom(Space,_),L2),length(L2,C2),Count is C1+C2)),check_returnval(RetType,Count).
-eval_args20(RetType,Depth,Self,['atom-replace',Other,Rem,Add],TF):- !,
+ get_operator_typedef(Self,Op,[Type1|_Rest],Expander,RetType), \+ is_non_eval_kind(Type1),
+ set_type(Depth,Res,Self,Expander,RetType),!,
+ eval(Type1,Depth,Self,Arg1,Res1), Arg1\=@=Res1, not_arg_violation(Depth,Self,Res1,Type1))
+ *-> (if_trace(eval,write_src_nl(cont([Op,Res1|VI]))),eval_20(Expander,RetType,Depth,Self,[Op,Res1|VI],Res))
+ ;eval_20(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res)).
+
+
+eval_20(Expander,_RetType,Depth,Self,[V|VI],[V|VO]):- var(V),!,maplist(eval(Depth,Self),VI,VO).
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% SPACE EDITING
+% =================================================================
+% =================================================================
+% =================================================================
+
+
+eval_20(Expander,RetType,Depth,Self,['add-atom',Other,PredDecl],Res):- !, into_space(Depth,Self,Other,Space),
+ do_metta(python,load,Space,PredDecl,TF),return_empty([],Res),check_returnval(Expander,RetType,TF).
+eval_20(Expander,RetType,Depth,Self,['remove-atom',Other,PredDecl],Res):- !, into_space(Depth,Self,Other,Space),
+ do_metta(python,unload,Space,PredDecl,TF),return_empty([],Res),check_returnval(Expander,RetType,TF).
+eval_20(Expander,RetType,Depth,Self,['atom-count',Other],Count):- !, (( into_space(Depth,Self,Other,Space), findall(_,metta_defn(Other,_,_),L1),length(L1,C1),
+ findall(_,metta_atom(Space,_),L2),length(L2,C2),Count is C1+C2)),check_returnval(Expander,RetType,Count).
+eval_20(Expander,RetType,Depth,Self,['atom-replace',Other,Rem,Add],TF):- !,
((into_space(Depth,Self,Other,Space), copy_term(Rem,RCopy),
as_tf((metta_atom_iter_ref(Space,RCopy,Ref), RCopy=@=Rem,erase(Ref), do_metta(Other,load,Add)),TF))),
- check_returnval(RetType,TF).
-eval_args20(RetType,Depth,Self,['get-atoms',Other],Atom):- !, ignore(RetType='Atom'),
- get_atoms(Depth,Self,Other,Atom), check_returnval(RetType,Atom).
+ check_returnval(Expander,RetType,TF).
+eval_20(Expander,RetType,Depth,Self,['get-atoms',Other],Atom):- !, ignore(Expander,RetType='Atom'),
+ get_atoms(Depth,Self,Other,Atom), check_returnval(Expander,RetType,Atom).
get_atoms(Depth,Self,Other,Atom):-
into_space(Depth,Self,Other,Space),
@@ -508,23 +533,23 @@
SpaceC = 'hyperon::space::DynSpace'(Atoms).
% Match-ELSE
-eval_args20(RetType,Depth,Self,['match',Other,Goal,Template,Else],Template):-
- ((eval_args20(RetType,Depth,Self,['match',Other,Goal,Template],Template),
+eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template,Else],Template):-
+ ((eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Template),
\+ return_empty([],Template))*->true;Template=Else).
% Match-TEMPLATE
-eval_args20(RetType,Depth,Self,['match',Other,Goal,Template],Res):- !,
- try_match(RetType,Depth,Self,Other,Goal,Template,Res).
+eval_20(Expander,RetType,Depth,Self,['match',Other,Goal,Template],Res):- !,
+ try_match(Expander,RetType,Depth,Self,Other,Goal,Template,Res).
/*
-try_match(RetType,Depth,Self,Other,Goal,Template,Res):- fail,
+try_match(Expander,RetType,Depth,Self,Other,Goal,Template,Res):- fail,
into_space(Depth,Self,Other,Space),
metta_atom_iter(Depth,Self,Space,Goal),
- eval_args99(RetType,Depth,Self,Template,Res).
+ eval_99(Expander,RetType,Depth,Self,Template,Res).
*/
-try_match(RetType,Depth,Self,Other,GoalM,Template,Res):-
+try_match(Expander,RetType,Depth,Self,Other,GoalM,Template,Res):-
get_atoms(Depth,Self,Other,Goal),once(GoalM=Goal),
- eval_args99(RetType,Depth,Self,Template,Res).
+ eval_99(Expander,RetType,Depth,Self,Template,Res).
metta_atom_iter(Depth,_Slf,Other,[Equal,[F|H],B]):- fail, '=' == Equal,!, % trace,
metta_defn(Other,[F|HH],BB),
@@ -540,10 +565,10 @@
metta_atom_iter(Depth,Self,Other,H):- metta_defn(Other,H,B), D2 is Depth -1, metta_atom_iter(D2,Self,Other,B).
%metta_atom_iter(Depth,Other,H):- D2 is Depth -1, metta_defn(Other,H,B),metta_atom_iter(D2,Other,B).
%metta_atom_iter_l2(Depth,Self,Other,H):- metta_atom_iter(Depth,Self,Other,H).
-%$metta_atom_iter(_Dpth,_Slf,[]):-!.
-
-eval_args20(RetType,_Dpth,_Slf,['new-space'],Space):- !, 'new-space'(Space),check_returnval(RetType,Space).
-
+%$metta_atom_iter(_Dpth,_Slf,[]):-!.
+
+eval_20(Expander,RetType,_Dpth,_Slf,['new-space'],Space):- !, 'new-space'(Space),check_returnval(Expander,RetType,Space).
+
/*
metta_atom_iter2(_,Self,[=,X,Y]):- metta_defn(Self,X,Y).
metta_atom_iter2(_Dpth,Other,[Equal,H,B]):- '=' == Equal,!, metta_defn(Other,H,B).
@@ -553,31 +578,31 @@
*/
metta_atom_iter_ref(Other,['=',H,B],Ref):-clause(metta_defn(Other,H,B),true,Ref).
metta_atom_iter_ref(Other,H,Ref):-clause(metta_atom(Other,H),true,Ref).
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% CASE/SWITCH
-% =================================================================
-% =================================================================
-% =================================================================
-% Macro: case
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% CASE/SWITCH
+% =================================================================
+% =================================================================
+% =================================================================
+% Macro: case
:- debug(metta(case)).
-eval_args20(RetType,Depth,Self,['case',A,CL],Value):- !,
- ((eval_args(Depth,Self,A,AA),
+eval_20(Expander,RetType,Depth,Self,['case',A,CL],Value):- !,
+ ((eval(Depth,Self,A,AA),
if_trace((case),(writeqln('switch'(A)=AA))),
must_det_ll(into_case_list(1,CL,KVs)),
select_switch(Depth,Self,AA,KVs,Match,Value),
if_trace((case),(writeqln('matched'=Match))),
if_trace((case),(writeqln('result'=Value))))*->true;member(['%void%',Value],CL)),
- check_returnval(Value,RetType).
+ check_returnval(Value,Expander,RetType).
select_switch(Depth,_Self,_A,_Cases,_Match,_Value):- Depth<1,!,fail.
select_switch(Depth,Self,A,Cases,Match,Value):-
Depth2 is Depth -1,
((if_trace((case),(writeqln('select-1'=A))),select_case(Depth2,Self,A,Cases,Match,Value))*->true;
- ((eval_args_complete_change(_RetType,Depth2,Self,A,AA),if_trace((case),(writeqln('select-2'=AA))),select_switch(Depth2,Self, AA,Cases,Match,Value))*->true;
+ ((eval_complete_change(Expander,_RetType,Depth2,Self,A,AA),if_trace((case),(writeqln('select-2'=AA))),select_switch(Depth2,Self, AA,Cases,Match,Value))*->true;
(best_key('%void%',Cases,Match,Value)))).
/*
!(assertEqualToResult
@@ -608,215 +633,206 @@
is_case(AA,[AA,Value],Value):-!.
is_case(AA,[AA|Value],Value).
- %maybe_special_keys(Depth,Self,[K-V|KVI],[AK-V|KVO]):- fail,eval_args(RetType,Depth,Self,K,AK), K\=@=AK,!, maybe_special_keys(Depth,Self,KVI,KVO).
+ %maybe_special_keys(Depth,Self,[K-V|KVI],[AK-V|KVO]):- fail,eval(Expander,RetType,Depth,Self,K,AK), K\=@=AK,!, maybe_special_keys(Depth,Self,KVI,KVO).
maybe_special_keys(Depth,Self,[_|KVI],KVO):-
fail, maybe_special_keys(Depth,Self,KVI,KVO).
maybe_special_keys(_Depth,_Self,[],[]).
-
-% =================================================================
-% =================================================================
-% =================================================================
-% COLLAPSE/SUPERPOSE
-% =================================================================
-% =================================================================
+
+% =================================================================
+% =================================================================
% =================================================================
-
-
-
-
-
+% COLLAPSE/SUPERPOSE
+% =================================================================
+% =================================================================
+% =================================================================
+
+
%[collapse,[1,2,3]]
-eval_args20(RetType,Depth,Self,['collapse',List],Res):-!, bagof_eval(Depth,Self,List,Res),check_returnval(RetType,Res).
+eval_20(Expander,RetType,Depth,Self,['collapse',List],Res):-!, bagof_eval_(Depth,Self,List,Res),check_returnval(Expander,RetType,Res).
% @TODO: This should not be here
-eval_args40(RetType,_Dpth,_Slf,['ift',Cond,Then],Then):- Cond == 'True', !,check_returnval(RetType,Then).
+eval_80(Expander,RetType,_Dpth,_Slf,['ift',Cond,Then],Then):- Cond == 'True', !,check_returnval(Expander,RetType,Then).
/*
get_sa_p1(P3,E,Cmpd,SA):- compound(Cmpd), get_sa_p2(P3,E,Cmpd,SA).
get_sa_p2(P3,E,Cmpd,call(P3,N1,Cmpd)):- arg(N1,Cmpd,E).
get_sa_p2(P3,E,Cmpd,SA):- arg(_,Cmpd,Arg),get_sa_p1(P3,E,Arg,SA).
-eval_args_disabledfz(RetType,Depth,Self, Term, Res):- fail,
+eval_disabledfz(Expander,RetType,Depth,Self, Term, Res):- fail,
mnotrace(( get_sa_p1(setarg,ST,Term,P1), % ST\==Term,
compound(ST), ST = [F,List],F=='superpose',nonvar(List), %maplist(atomic,List),
call(P1,Var))), !,
%max_counting(F,30),
member(Var,List),
- eval_args(RetType,Depth,Self, Term, Res).
+ eval(Expander,RetType,Depth,Self, Term, Res).
*/
-eval_args_disabledzf(RetType,Depth,Self, Term, Res):- fail,
+eval_disabledzf(Expander,RetType,Depth,Self, Term, Res):- fail,
mnotrace(( get_sa_p1(setarg,ST,Term,P1),
compound(ST), ST = [F,List],F=='collapse',nonvar(List), %maplist(atomic,List),
- call(P1,Var))), !, setof_eval(Depth,Self,List,Var),
- eval_args(RetType,Depth,Self, Term, Res).
+ call(P1,Var))), !, setof_eval_(Depth,Self,List,Var),
+ eval(Expander,RetType,Depth,Self, Term, Res).
-eval_args_disabledaaaa(RetType,Depth,Self,[Op|Args],Res):- append(ArgsL,[ArgE|ArgsR],Args),is_list(ArgE),!,
- ((get_operator_typedef(Self,Op,Types,RetType),
+eval_disabledaaaa(Expander,RetType,Depth,Self,[Op|Args],Res):- append(ArgsL,[ArgE|ArgsR],Args),is_list(ArgE),!,
+ ((get_operator_typedef(Self,Op,Types,Expander,RetType),
length(ArgsL,N), length(TypesL,N),
append(TypesL,[TypeE|TypesR],Types),
\+ is_non_eval_kind(TypeE),
maplist(not_arg_violation(Depth,Self),ArgsL,TypesL),
maplist(not_arg_violation(Depth,Self),ArgsR,TypesR),
- eval_args11(RetType,Depth,Self,ArgE,ResE), ArgE\=@=ResE,
+ eval_11(Expander,RetType,Depth,Self,ArgE,ResE), ArgE\=@=ResE,
not_arg_violation(Depth,Self,ResE,TypeE),
- set_type(Depth,Res,Self,RetType),
+ set_type(Depth,Res,Self,Expander,RetType),
append(ArgsL,[ResE|ArgsR],EArgs))
- *-> eval_args(RetType,Depth,Self,[Op|EArgs],Res);
- eval_args40(RetType,Depth,Self,[Op|Args],Res)).
+ *-> eval(Expander,RetType,Depth,Self,[Op|EArgs],Res);
+ eval_80(Expander,RetType,Depth,Self,[Op|Args],Res)).
% Macro Functions
-eval_args_disableda1a(RetType,Depth,Self,[F|PredDecl],Res):-
+eval_disableda1a(Expander,RetType,Depth,Self,[F|PredDecl],Res):-
(Depth>1,
quietly(sub_sterm1(SSub,PredDecl)),
mnotrace((ground(SSub),SSub=[_|Sub], is_list(Sub),maplist(atomic,SSub))),
- eval_args(RetType,Depth,Self,SSub,Repl),
- mnotrace((SSub\=Repl,subst(PredDecl,SSub,Repl,Temp))))*-> eval_args(RetType,Depth,Self,[F|Temp],Res);
- eval_args40(RetType,Depth,Self,[F|PredDecl],Res).
+ eval(Expander,RetType,Depth,Self,SSub,Repl),
+ mnotrace((SSub\=Repl,subst(PredDecl,SSub,Repl,Temp))))*-> eval(Expander,RetType,Depth,Self,[F|Temp],Res);
+ eval_80(Expander,RetType,Depth,Self,[F|PredDecl],Res).
% Macro Functions
-eval_args_disabledfzr(RetType,Depth,Self,[F|PredDecl],Res):- fail,
+eval_disabledfzr(Expander,RetType,Depth,Self,[F|PredDecl],Res):- fail,
Depth>1,
mnotrace((sub_sterm1(SSub,PredDecl), ground(SSub),SSub=[Op|Sub], is_list(Sub), maplist(atomic,SSub))),
- nop(is_user_defined_head_f(Self,Op)), eval_args(RetType,Depth,Self,SSub,Repl),
+ nop(is_user_defined_head_f(Self,Op)), eval(Expander,RetType,Depth,Self,SSub,Repl),
mnotrace((SSub\=Repl, subst(PredDecl,SSub,Repl,Temp))),
- eval_args(RetType,Depth,Self,[F|Temp],Res).
+ eval(Expander,RetType,Depth,Self,[F|Temp],Res).
+
+eval_20(Expander,_RetType,Dpth,_Slf,_X,Y):- Dpth<0,!,[] = Y.
-eval_args20(_RetType,Dpth,_Slf,_X,Y):- Dpth<0,!,[] = Y.
-
sub_sterm(Sub,Sub).
sub_sterm(Sub,Term):- sub_sterm1(Sub,Term).
sub_sterm1(_ ,List):- \+ compound(List),!,fail.
sub_sterm1(Sub,List):- is_list(List),!,member(SL,List),sub_sterm(Sub,SL).
sub_sterm1(_ ,[_|_]):-!,fail.
sub_sterm1(Sub,Term):- arg(_,Term,SL),sub_sterm(Sub,SL).
-
+
max_counting(F,Max):- flag(F,X,X+1), X true; (flag(F,_,10),!,fail).
-% =================================================================
-% =================================================================
-% =================================================================
-% if/If
-% =================================================================
-% =================================================================
+% =================================================================
+% =================================================================
+% =================================================================
+% if/If
+% =================================================================
+% =================================================================
% =================================================================
-eval_args20(RetType,Depth,Self,['if',Cond,Then,Else],Res):- !,
- eval_args('Bool',Depth,Self,Cond,TF),
- (is_True(TF) -> eval_args(RetType,Depth,Self,Then,Res);eval_args(RetType,Depth,Self,Else,Res)).
+eval_20(Expander,RetType,Depth,Self,['if',Cond,Then,Else],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
+ (is_True(TF)
+ -> eval(Expander,RetType,Depth,Self,Then,Res)
+ ; eval(Expander,RetType,Depth,Self,Else,Res)).
-eval_args20(RetType,Depth,Self,['If',Cond,Then,Else],Res):- !,
- eval_args('Bool',Depth,Self,Cond,TF),
- (is_True(TF) -> eval_args(RetType,Depth,Self,Then,Res);eval_args(RetType,Depth,Self,Else,Res)).
+eval_20(Expander,RetType,Depth,Self,['If',Cond,Then,Else],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
+ (is_True(TF)
+ -> eval(Expander,RetType,Depth,Self,Then,Res)
+ ; eval(Expander,RetType,Depth,Self,Else,Res)).
-eval_args20(RetType,Depth,Self,['if',Cond,Then],Res):- !,
- eval_args('Bool',RetType,Depth,Self,Cond,TF),
- (is_True(TF) -> eval_args(RetType,Depth,Self,Then,Res) ;
+eval_20(Expander,RetType,Depth,Self,['If',Cond,Then],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
+ (is_True(TF) -> eval(Expander,RetType,Depth,Self,Then,Res) ;
(!, fail,Res = [],!)).
-% =================================================================
-% =================================================================
-% =================================================================
-% NOP/EQUALITU/DO
-% =================================================================
-% =================================================================
-% ================================================================
-eval_args20(RetType,Depth,Self,['==',X,Y],TF):- !, as_tf((eval_until_eq(RetType,Depth,Self,X,Y)),TF),!.
-
-eval_args20(RetType,Depth,Self,['nop',Expr],Empty):- !, eval_args(Depth,Self,Expr,_), return_empty([],Empty),check_returnval(RetType,Empty).
-eval_args20(RetType,_Dpth,_Slf,['nop'],Empty):- !, return_empty([],Empty),check_returnval(RetType,Empty).
-eval_args40(RetType,Depth,Self,['do',Expr],Empty):- !, ignore(eval_args(Depth,Self,Expr,_)),
- return_empty([],Empty),check_returnval(RetType,Empty).
-
-
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% LET/LET*
-% =================================================================
-% =================================================================
-% =================================================================
-
-
+
+eval_20(Expander,RetType,Depth,Self,['if',Cond,Then],Res):- !,
+ eval(Expander,'Bool',Depth,Self,Cond,TF),
+ (is_True(TF) -> eval(Expander,RetType,Depth,Self,Then,Res) ;
+ (!, fail,Res = [],!)).
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% LET/LET*
+% =================================================================
+% =================================================================
+% =================================================================
+
+
eval_until_unify(_Dpth,_Slf,X,X):- !.
-eval_until_unify(Depth,Self,X,Y):- eval_until_eq(_RetType,Depth,Self,X,Y).
-
-eval_until_eq(RetType,_Dpth,_Slf,X,Y):- X=Y,check_returnval(RetType,Y).
-%eval_until_eq(RetType,Depth,Self,X,Y):- var(Y),!,eval_args_in_steps_or_same(RetType,Depth,Self,X,XX),Y=XX.
-%eval_until_eq(RetType,Depth,Self,Y,X):- var(Y),!,eval_args_in_steps_or_same(RetType,Depth,Self,X,XX),Y=XX.
-eval_until_eq(RetType,Depth,Self,X,Y):- \+is_list(Y),!,eval_args_in_steps_some_change(RetType,Depth,Self,X,XX),Y=XX.
-eval_until_eq(RetType,Depth,Self,Y,X):- \+is_list(Y),!,eval_args_in_steps_some_change(RetType,Depth,Self,X,XX),Y=XX.
-eval_until_eq(RetType,Depth,Self,X,Y):- eval_args_in_steps_some_change(RetType,Depth,Self,X,XX),eval_until_eq(RetType,Depth,Self,Y,XX).
-eval_until_eq(_RetType,_Dpth,_Slf,X,Y):- length(X,Len), \+ length(Y,Len),!,fail.
-eval_until_eq(RetType,Depth,Self,X,Y):- nth1(N,X,EX,RX), nth1(N,Y,EY,RY),
- EX=EY,!, maplist(eval_until_eq(RetType,Depth,Self),RX,RY).
-eval_until_eq(RetType,Depth,Self,X,Y):- nth1(N,X,EX,RX), nth1(N,Y,EY,RY),
- ((var(EX);var(EY)),eval_until_eq(RetType,Depth,Self,EX,EY)),
- maplist(eval_until_eq(RetType,Depth,Self),RX,RY).
-eval_until_eq(RetType,Depth,Self,X,Y):- nth1(N,X,EX,RX), nth1(N,Y,EY,RY),
- h((is_list(EX);is_list(EY)),eval_until_eq(RetType,Depth,Self,EX,EY)),
- maplist(eval_until_eq(RetType,Depth,Self),RX,RY).
-
- eval_args_1change(RetType,Depth,Self,EX,EXX):-
- eval_args20(RetType,Depth,Self,EX,EXX), EX \=@= EXX.
-
-eval_args_complete_change(RetType,Depth,Self,EX,EXX):-
- eval_args(RetType,Depth,Self,EX,EXX), EX \=@= EXX.
-
-eval_args_in_steps_some_change(_RetType,_Dpth,_Slf,EX,_):- \+ is_list(EX),!,fail.
-eval_args_in_steps_some_change(RetType,Depth,Self,EX,EXX):- eval_args_1change(RetType,Depth,Self,EX,EXX).
-eval_args_in_steps_some_change(RetType,Depth,Self,X,Y):- append(L,[EX|R],X),is_list(EX),
- eval_args_in_steps_some_change(RetType,Depth,Self,EX,EXX), EX\=@=EXX,
- append(L,[EXX|R],XX),eval_args_in_steps_or_same(RetType,Depth,Self,XX,Y).
-
-eval_args_in_steps_or_same(RetType,Depth,Self,X,Y):-eval_args_in_steps_some_change(RetType,Depth,Self,X,Y).
-eval_args_in_steps_or_same(RetType,_Dpth,_Slf,X,Y):- X=Y,check_returnval(RetType,Y).
-
- % (fail,return_empty([],Template))).
-
-
-
-%eval_args20(RetType,Depth,Self,['let',A,A5,AA],OO):- var(A),A=A5,!,eval_args20(RetType,Depth,Self,AA,OO).
-eval_args20(RetType,Depth,Self,['let',A,A5,AA],OO):- !,
+eval_until_unify(Depth,Self,X,Y):- eval_until_eq(Expander,_RetType,Depth,Self,X,Y).
+
+eval_until_eq(Expander,RetType,_Dpth,_Slf,X,Y):- X=Y,check_returnval(Expander,RetType,Y).
+%eval_until_eq(Expander,RetType,Depth,Self,X,Y):- var(Y),!,eval_in_steps_or_same(Expander,RetType,Depth,Self,X,XX),Y=XX.
+%eval_until_eq(Expander,RetType,Depth,Self,Y,X):- var(Y),!,eval_in_steps_or_same(Expander,RetType,Depth,Self,X,XX),Y=XX.
+eval_until_eq(Expander,RetType,Depth,Self,X,Y):- \+is_list(Y),!,eval_in_steps_some_change(Expander,RetType,Depth,Self,X,XX),Y=XX.
+eval_until_eq(Expander,RetType,Depth,Self,Y,X):- \+is_list(Y),!,eval_in_steps_some_change(Expander,RetType,Depth,Self,X,XX),Y=XX.
+eval_until_eq(Expander,RetType,Depth,Self,X,Y):- eval_in_steps_some_change(Expander,RetType,Depth,Self,X,XX),eval_until_eq(Expander,RetType,Depth,Self,Y,XX).
+eval_until_eq(Expander,_RetType,_Dpth,_Slf,X,Y):- length(X,Len), \+ length(Y,Len),!,fail.
+eval_until_eq(Expander,RetType,Depth,Self,X,Y):- nth1(N,X,EX,RX), nth1(N,Y,EY,RY),
+ EX=EY,!, maplist(eval_until_eq(Expander,RetType,Depth,Self),RX,RY).
+eval_until_eq(Expander,RetType,Depth,Self,X,Y):- nth1(N,X,EX,RX), nth1(N,Y,EY,RY),
+ ((var(EX);var(EY)),eval_until_eq(Expander,RetType,Depth,Self,EX,EY)),
+ maplist(eval_until_eq(Expander,RetType,Depth,Self),RX,RY).
+eval_until_eq(Expander,RetType,Depth,Self,X,Y):- nth1(N,X,EX,RX), nth1(N,Y,EY,RY),
+ h((is_list(EX);is_list(EY)),eval_until_eq(Expander,RetType,Depth,Self,EX,EY)),
+ maplist(eval_until_eq(Expander,RetType,Depth,Self),RX,RY).
+
+ eval_1change(Expander,RetType,Depth,Self,EX,EXX):-
+ eval_20(Expander,RetType,Depth,Self,EX,EXX), EX \=@= EXX.
+
+eval_complete_change(Expander,RetType,Depth,Self,EX,EXX):-
+ eval(Expander,RetType,Depth,Self,EX,EXX), EX \=@= EXX.
+
+eval_in_steps_some_change(Expander,_RetType,_Dpth,_Slf,EX,_):- \+ is_list(EX),!,fail.
+eval_in_steps_some_change(Expander,RetType,Depth,Self,EX,EXX):- eval_1change(Expander,RetType,Depth,Self,EX,EXX).
+eval_in_steps_some_change(Expander,RetType,Depth,Self,X,Y):- append(L,[EX|R],X),is_list(EX),
+ eval_in_steps_some_change(Expander,RetType,Depth,Self,EX,EXX), EX\=@=EXX,
+ append(L,[EXX|R],XX),eval_in_steps_or_same(Expander,RetType,Depth,Self,XX,Y).
+
+eval_in_steps_or_same(Expander,RetType,Depth,Self,X,Y):-eval_in_steps_some_change(Expander,RetType,Depth,Self,X,Y).
+eval_in_steps_or_same(Expander,RetType,_Dpth,_Slf,X,Y):- X=Y,check_returnval(Expander,RetType,Y).
+
+ % (fail,return_empty([],Template))).
+
+
+
+%eval_20(Expander,RetType,Depth,Self,['let',A,A5,AA],OO):- var(A),A=A5,!,eval_20(Expander,RetType,Depth,Self,AA,OO).
+eval_20(Expander,RetType,Depth,Self,['let',A,A5,AA],OO):- !,
%(var(A)->true;trace),
- ((eval_args(Depth,Self,A5,AE), AE=A)),
- eval_args(RetType,Depth,Self,AA,OO).
-%eval_args20(RetType,Depth,Self,['let',A,A5,AA],AAO):- !,eval_args(RetType,Depth,Self,A5,A),eval_args(RetType,Depth,Self,AA,AAO).
-eval_args20(RetType,_Dpth,_Slf,['let*',[]|T], RetVal):- T==[], !, return_empty([],RetVal), check_returnval(RetType,RetVal).
-eval_args20(RetType,Depth,Self,['let*',[],Body],RetVal):- !, eval_args(RetType,Depth,Self,Body,RetVal).
+ ((eval(Depth,Self,A5,AE), AE=A)),
+ eval(Expander,RetType,Depth,Self,AA,OO).
+%eval_20(Expander,RetType,Depth,Self,['let',A,A5,AA],AAO):- !,eval(Expander,RetType,Depth,Self,A5,A),eval(Expander,RetType,Depth,Self,AA,AAO).
+eval_20(Expander,RetType,_Dpth,_Slf,['let*',[]|T], RetVal):- T==[], !, return_empty([],RetVal), check_returnval(Expander,RetType,RetVal).
+eval_20(Expander,RetType,Depth,Self,['let*',[],Body],RetVal):- !, eval(Expander,RetType,Depth,Self,Body,RetVal).
% let* version 2
-eval_args20(RetType,Depth,Self,['let*',[[Var,Val]|LetRest],Body],RetVal):- !, eval_args20(RetType,Depth,Self,['let',Var,Val,['let*',LetRest,Body]],RetVal).
+eval_20(Expander,RetType,Depth,Self,['let*',[[Var,Val]|LetRest],Body],RetVal):- !, eval_20(Expander,RetType,Depth,Self,['let',Var,Val,['let*',LetRest,Body]],RetVal).
% let* version 1
-eval_args20(RetType,Depth,Self,['let*',[[Var,Val]|LetRest]|Body],RetVal):- !,
+eval_20(Expander,RetType,Depth,Self,['let*',[[Var,Val]|LetRest]|Body],RetVal):- !,
eval_until_unify(Depth,Self,Var,Val),
- %eval_args(RetType,Depth,Self,['==',Var,Val],_),
- eval_args20(RetType,Depth,Self,['let*',LetRest|Body],RetVal).
+ %eval(Expander,RetType,Depth,Self,['==',Var,Val],_),
+ eval_20(Expander,RetType,Depth,Self,['let*',LetRest|Body],RetVal).
-must_eval(G):- call(G)*->true;throw(must_eval(G)).
+must_eval_(G):- call(G)*->true;throw(must_eval_(G)).
-%eval_args20(RetType,Depth,Self,[V|VI],Res):- is_special_builtin(V),!, eval_args20(RetType,Depth,Self,[V|VI],Res).
-%eval_args20(RetType,Depth,Self,[V|VI],Res):- is_metta_builtin(V),!, adjust_args(Depth,Self,V,VI,VO), eval_args20(RetType,Depth,Self,[V|VO],Res).
+%eval_20(Expander,RetType,Depth,Self,[V|VI],Res):- is_special_builtin(V),!, eval_20(Expander,RetType,Depth,Self,[V|VI],Res).
+%eval_20(Expander,RetType,Depth,Self,[V|VI],Res):- is_metta_builtin(V),!, adjust_args(Depth,Self,V,VI,VO), eval_20(Expander,RetType,Depth,Self,[V|VO],Res).
-eval_args20(RetType,_Dpth,_Slf,X,Y):- typed_list(X,_,List), !, member(Y,List),check_returnval(RetType,Y).
-
-
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% CONS/CAR/CDR
-% =================================================================
-% =================================================================
+eval_20(Expander,RetType,_Dpth,_Slf,X,Y):- typed_list(X,_,List), !, member(Y,List),check_returnval(Expander,RetType,Y).
+
+
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% CONS/CAR/CDR
+% =================================================================
+% =================================================================
% =================================================================
into_pl_list(Var,Var):- var(Var),!.
@@ -835,54 +851,54 @@
into_listoid(AtomC,Atom):- is_list(AtomC),!,Atom=AtomC.
into_listoid(AtomC,Atom):- typed_list(AtomC,_,Atom),!.
-eval_args20(RetType,_Dpth,_Slf,['car-atom',AtomC],CAR):- !,
+eval_20(Expander,RetType,_Dpth,_Slf,['car-atom',AtomC],CAR):- !,
into_listoid(AtomC,Atom),
check_returnval('ListExpression',Atom),
- Atom=[CAR|_],!,check_returnval(RetType,CAR).
-eval_args20(RetType,_Dpth,_Slf,['cdr-atom',AtomC],CDR):- !,
+ Atom=[CAR|_],!,check_returnval(Expander,RetType,CAR).
+eval_20(Expander,RetType,_Dpth,_Slf,['cdr-atom',AtomC],CDR):- !,
into_listoid(AtomC,Atom),
check_returnval('ListExpression',Atom),
- Atom=[_|CDR],!,check_returnval(RetType,CDR).
+ Atom=[_|CDR],!,check_returnval(Expander,RetType,CDR).
-eval_args20(RetType,Depth,Self,['Cons', A, B ],['Cons', AA, BB]):- %no_cons_reduce, !,
- eval_args99(_,Depth,Self,A,AA),
- eval_args99(RetType,Depth,Self,B,BB).
-%eval_args20(RetType,Depth,Self,['Cons', A, B ],[AA|BB]):- \+ no_cons_reduce, !,
-% eval_args90(RetType,Depth,Self,A,AA), eval_args90(RetType,Depth,Self,B,BB).
-eval_args20(RetType,_Dpth,_Slf,['::'|Expr],Expr):- !,check_returnval(RetType,Expr).
+eval_20(Expander,RetType,Depth,Self,['Cons', A, B ],['Cons', AA, BB]):- %no_cons_reduce, !,
+ eval_99(_,Depth,Self,A,AA),
+ eval_99(Expander,RetType,Depth,Self,B,BB).
+%eval_20(Expander,RetType,Depth,Self,['Cons', A, B ],[AA|BB]):- \+ no_cons_reduce, !,
+% eval_90(Expander,RetType,Depth,Self,A,AA), eval_90(Expander,RetType,Depth,Self,B,BB).
+eval_20(Expander,RetType,_Dpth,_Slf,['::'|Expr],Expr):- !,check_returnval(Expander,RetType,Expr).
-
-% =================================================================
-% =================================================================
-% =================================================================
-% STATE EDITING
-% =================================================================
-% =================================================================
+
+% =================================================================
+% =================================================================
+% =================================================================
+% STATE EDITING
+% =================================================================
+% =================================================================
% =================================================================
-check_returnval(_RetType,_PredDecl).
+check_returnval(Expander,_RetType,_PredDecl).
-eval_args20(RetType,Depth,Self,['change-state!',StateExpr, UpdatedValue], Ret):- !,
- eval_args('StateMonad',Depth,Self,StateExpr,StateMonad),
- eval_args(RetType,Depth,Self,UpdatedValue,Value),
+eval_20(Expander,RetType,Depth,Self,['change-state!',StateExpr, UpdatedValue], Ret):- !,
+ eval('StateMonad',Depth,Self,StateExpr,StateMonad),
+ eval(Expander,RetType,Depth,Self,UpdatedValue,Value),
'change-state!'(Depth,Self,StateMonad, Value, Ret),
- check_returnval(RetType,Ret).
+ check_returnval(Expander,RetType,Ret).
-eval_args20(RetType,Depth,Self,['get-state',StateExpr],Value):- !,
- eval_args('StateMonad',Depth,Self,StateExpr,StateMonad),
+eval_20(Expander,RetType,Depth,Self,['get-state',StateExpr],Value):- !,
+ eval('StateMonad',Depth,Self,StateExpr,StateMonad),
'get-state'(StateMonad,Value),
- check_returnval(RetType,Value).
+ check_returnval(Expander,RetType,Value).
-eval_args20(RetType,Depth,Self,['new-state',UpdatedValue],StateMonad):- !,
- eval_args(Depth,Self,UpdatedValue,Value), 'new-state'(Depth,Self,Value,StateMonad),
- check_returnval(RetType,StateMonad).
+eval_20(Expander,RetType,Depth,Self,['new-state',UpdatedValue],StateMonad):- !,
+ eval(Depth,Self,UpdatedValue,Value), 'new-state'(Depth,Self,Value,StateMonad),
+ check_returnval(Expander,RetType,StateMonad).
-% eval_args20(RetType,Depth,Self,['get-state',Expr],Value):- !, eval_args(RetType,Depth,Self,Expr,State), arg(1,State,Value).
+% eval_20(Expander,RetType,Depth,Self,['get-state',Expr],Value):- !, eval(Expander,RetType,Depth,Self,Expr,State), arg(1,State,Value).
@@ -896,7 +912,7 @@
:- dynamic(is_registered_state/1).
is_nb_state(G):- is_valid_nb_state(G) -> true ;
is_registered_state(G),nb_current(G,S),is_valid_nb_state(S).
-
+
:- multifile(state_type_method/3).
:- dynamic(state_type_method/3).
state_type_method(is_nb_state,new_state,init_state).
@@ -962,166 +978,114 @@
; writeln('Error: Invalid input.')
),
is_valid_nb_state(State).
-
-% =================================================================
-% =================================================================
-% =================================================================
-% GET-TYPE
-% =================================================================
-% =================================================================
-% =================================================================
-
-eval_args20(RetType,Depth,Self,['get-type',Val],Type):- !,
- get_type(Depth,Self,Val,Type),check_returnval(RetType,Type).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% IMPORT/BIND
-% =================================================================
-% =================================================================
+
+% =================================================================
+% =================================================================
+% =================================================================
+% GET-TYPE
+% =================================================================
+% =================================================================
+% =================================================================
+
+eval_20(Expander,RetType,Depth,Self,['get-type',Val],Type):- !,
+ get_type(Depth,Self,Val,Type),check_returnval(Expander,RetType,Type).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% IMPORT/BIND
+% =================================================================
+% =================================================================
% =================================================================
nb_bind(Name,Value):- nb_current(Name,Was),same_term(Value,Was),!.
nb_bind(Name,Value):- nb_setval(Name,Value),!.
-eval_args20(RetType,Depth,Self,['import!',Other,File],RetVal):-
+eval_20(Expander,RetType,Depth,Self,['import!',Other,File],RetVal):-
(( into_space(Depth,Self,Other,Space),!, include_metta(Space,File),!,return_empty(Space,RetVal))),
- check_returnval(RetType,RetVal). %RetVal=[].
-eval_args20(RetType,Depth,Self,['bind!',Other,Expr],RetVal):-
- must_det_ll((into_name(Self,Other,Name),!,eval_args(RetType,Depth,Self,Expr,Value),
+ check_returnval(Expander,RetType,RetVal). %RetVal=[].
+eval_20(Expander,RetType,Depth,Self,['bind!',Other,Expr],RetVal):-
+ must_det_ll((into_name(Self,Other,Name),!,eval(Expander,RetType,Depth,Self,Expr,Value),
nb_bind(Name,Value), return_empty(Value,RetVal))),
- check_returnval(RetType,RetVal).
-eval_args20(RetType,Depth,Self,['pragma!',Other,Expr],RetVal):-
- must_det_ll((into_name(Self,Other,Name),!,nd_ignore((eval_args(RetType,Depth,Self,Expr,Value),set_option_value(Name,Value))), return_empty(Value,RetVal),check_returnval(RetType,RetVal))).
-eval_args20(RetType,_Dpth,Self,['transfer!',File],RetVal):- !, must_det_ll((include_metta(Self,File), return_empty(Self,RetVal),check_returnval(RetType,RetVal))).
-
-nd_ignore(Goal):- call(Goal)*->true;true.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% AND/OR
-% =================================================================
-% =================================================================
-% =================================================================
-
+ check_returnval(Expander,RetType,RetVal).
+eval_20(Expander,RetType,Depth,Self,['pragma!',Other,Expr],RetVal):-
+ must_det_ll((into_name(Self,Other,Name),!,nd_ignore((eval(Expander,RetType,Depth,Self,Expr,Value),set_option_value(Name,Value))), return_empty(Value,RetVal),check_returnval(Expander,RetType,RetVal))).
+eval_20(Expander,RetType,_Dpth,Self,['transfer!',File],RetVal):- !, must_det_ll((include_metta(Self,File), return_empty(Self,RetVal),check_returnval(Expander,RetType,RetVal))).
+
+nd_ignore(Goal):- call(Goal)*->true;true.
+
+
+
+
+
+
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% NOP/EQUALITU/DO
+% =================================================================
+% =================================================================
+% ================================================================
+eval_20(Expander,RetType,Depth,Self,['==',X,Y],TF):- !, as_tf((eval_until_eq(Expander,RetType,Depth,Self,X,Y)),TF),!.
+
+eval_20(Expander,RetType,Depth,Self,['nop',Expr],Empty):- !, eval(Depth,Self,Expr,_), return_empty([],Empty),check_returnval(Expander,RetType,Empty).
+eval_20(Expander,RetType,_Dpth,_Slf,['nop'],Empty):- !, return_empty([],Empty),check_returnval(Expander,RetType,Empty).
+eval_80(Expander,RetType,Depth,Self,['do',Expr],Empty):- !, ignore(eval(Depth,Self,Expr,_)),
+ return_empty([],Empty),check_returnval(Expander,RetType,Empty).
+
+
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% AND/OR
+% =================================================================
+% =================================================================
+% =================================================================
+
is_True(T):- T=='True'. % \=='False',T\=='F',T\==[].
is_and(S):- \+ atom(S),!,fail.
@@ -1131,249 +1095,228 @@
is_and('and2','True').
is_and('#COMMA','True'). is_and(',','True'). % is_and('And').
-eval_args20(RetType,_Dpth,_Slf,[And],True):- is_and(And,True),!,check_returnval(RetType,True).
-eval_args20(RetType,Depth,Self,[And,X,Y],TF):- is_and(And,True),!, as_tf((
- eval_args(RetType,Depth,Self,X,True),eval_args(RetType,Depth,Self,Y,True)),TF).
-eval_args20(RetType,Depth,Self,[And,X],True):- is_and(And,True),!,
- eval_args(RetType,Depth,Self,X,True).
-eval_args20(RetType,Depth,Self,[And,X|Y],TF):- is_and(And,_True),!,
- eval_args(RetType,Depth,Self,X,TF1), \+ \+ is_True(TF1),
- eval_args(RetType,Depth,Self,[And|Y],TF).
-%eval_args40(RetType,Depth,Self,[H|T],_):- \+ is_list(T),!,fail.
-eval_args20(RetType,Depth,Self,['or',X,Y],TF):- !, as_tf((eval_args(RetType,Depth,Self,X,'True');eval_args(RetType,Depth,Self,Y,'True')),TF).
-
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% DATA/FUNCTORS
-% =================================================================
-% =================================================================
-% =================================================================
-
-%eval_args20(RetType,Depth,Self,[V|VI],[V|VO]):- is_metta_data_functor(V), is_list(VI),!,maplist(eval_args(RetType,Depth,Self),VI,VO).
-eval_args40(RetType,Depth,Self,[V|VI],O):- is_metta_data_functor(V), !, must_eval(adjust_args(Depth,Self,V,VI,VO)),
- O =.. [V|VO],
- check_returnval(RetType,O).
+eval_20(Expander,RetType,_Dpth,_Slf,[And],True):- is_and(And,True),!,check_returnval(Expander,RetType,True).
+eval_20(Expander,RetType,Depth,Self,[And,X,Y],TF):- is_and(And,True),!, as_tf((
+ eval(Expander,RetType,Depth,Self,X,True),eval(Expander,RetType,Depth,Self,Y,True)),TF).
+eval_20(Expander,RetType,Depth,Self,[And,X],True):- is_and(And,True),!,
+ eval(Expander,RetType,Depth,Self,X,True).
+eval_20(Expander,RetType,Depth,Self,[And,X|Y],TF):- is_and(And,_True),!,
+ eval(Expander,RetType,Depth,Self,X,TF1), \+ \+ is_True(TF1),
+ eval(Expander,RetType,Depth,Self,[And|Y],TF).
+%eval_80(Expander,RetType,Depth,Self,[H|T],_):- \+ is_list(T),!,fail.
+eval_20(Expander,RetType,Depth,Self,['or',X,Y],TF):- !, as_tf((eval(Expander,RetType,Depth,Self,X,'True');eval(Expander,RetType,Depth,Self,Y,'True')),TF).
-%eval_args20(RetType,_Dpth,_Slf,[_,Nothing],Nothing):- 'Nothing'==Nothing,!.
-
+
+% =================================================================
+% =================================================================
+% =================================================================
+% MATH/+/-
+% =================================================================
+% =================================================================
+% =================================================================
+
+eval_20(Expander,RetType,Depth,Self,['+',N1,N2],N):- number(N1),!,
+ eval(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1+N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
+eval_20(Expander,RetType,Depth,Self,['-',N1,N2],N):- number(N1),!,
+ eval(Expander,RetType,Depth,Self,N2,N2Res), catch(N is N1-N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
+
+eval_20(Expander,RetType,_Dpth,_Slf,[F|LESS],Res):-
+ notrace((ground([F|LESS]), once(maybe_efbug(show_success,eval_selfless([F|LESS],Res))),mnotrace(([F|LESS]\==Res)))),
+ check_returnval(Expander,RetType,Res).
+
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% DATA FUNCTOR
+% =================================================================
+% =================================================================
+% =================================================================
+
+%eval_20(Expander,RetType,Depth,Self,[V|VI],[V|VO]):- is_metta_data_functor(V), is_list(VI),!,maplist(eval(Expander,RetType,Depth,Self),VI,VO).
+eval_80(Expander,RetType,Depth,Self,[V|VI],O):- is_metta_data_functor(V), !, must_eval_(adjust_args(Depth,Self,V,VI,VO)),
+ O =.. [V|VO],
+ check_returnval(Expander,RetType,O).
+
+%eval_20(Expander,RetType,_Dpth,_Slf,[_,Nothing],Nothing):- 'Nothing'==Nothing,!.
+
/*
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% EVAL FAILED
-% =================================================================
-% =================================================================
-% =================================================================
-%eval_args_failed(_Dpth,_Slf,T,TT):- var(T),!,TT=T.
-%eval_args_failed(_Dpth,_Slf,[F|LESS],Res):- once(eval_selfless([F|LESS],Res)),mnotrace([F|LESS]\==Res),!.
-%eval_args_failed(Depth,Self,[V|Nil],[O]):- Nil==[], once(eval_args(RetType,Depth,Self,V,O)),V\=@=O,!.
-
-eval_args_failed(Depth,Self,T,TT):- eval_args(RetType,Depth,Self,T,TT).
-
- %eval_args(RetType,Depth,Self,X,Y):- eval_args20(RetType,Depth,Self,X,Y)*->true;Y=[].
-*/
-
-eval_args_failed(Depth,Self,[X|XX],[Y]):- XX == [],!,eval_args99(_RetType,Depth,Self,X,Y).
-eval_args_failed(_Dpth,_Slf,T,TT):- T==[],!,TT=[].
-eval_args_failed(Depth,Self,[H|T],[HH|TT]):- !,
- eval_args99(_RetType,Depth,Self,H,HH),
- eval_args_failed(Depth,Self,T,TT).
-
-eval_args_failed(_Dpth,_Slf,T,TT):- ignore(T=TT).
-
-%eval_args20(RetType,Depth,_,_,_):- Depth<1,!,fail.
-%eval_args20(RetType,Depth,_,X,Y):- Depth<3, !, ground(X), (Y=X).
-%eval_args20(RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
+
+% =================================================================
+% =================================================================
+% =================================================================
+% EVAL FAILED
+% =================================================================
+% =================================================================
+% =================================================================
+%eval_failed(_Dpth,_Slf,T,TT):- var(T),!,TT=T.
+%eval_failed(_Dpth,_Slf,[F|LESS],Res):- once(eval_selfless([F|LESS],Res)),mnotrace([F|LESS]\==Res),!.
+%eval_failed(Depth,Self,[V|Nil],[O]):- Nil==[], once(eval(Expander,RetType,Depth,Self,V,O)),V\=@=O,!.
+
+eval_failed(Depth,Self,T,TT):- eval(Expander,RetType,Depth,Self,T,TT).
+
+ %eval(Expander,RetType,Depth,Self,X,Y):- eval_20(Expander,RetType,Depth,Self,X,Y)*->true;Y=[].
+*/
+
+eval_failed(Depth,Self,[X|XX],[Y]):- XX == [],!,eval_99(Expander,_RetType,Depth,Self,X,Y).
+eval_failed(_Dpth,_Slf,T,TT):- T==[],!,TT=[].
+eval_failed(Depth,Self,[H|T],[HH|TT]):- !,
+ eval_99(Expander,_RetType,Depth,Self,H,HH),
+ eval_failed(Depth,Self,T,TT).
+
+eval_failed(_Dpth,_Slf,T,TT):- ignore(T=TT).
+
+%eval_20(Expander,RetType,Depth,_,_,_):- Depth<1,!,fail.
+%eval_20(Expander,RetType,Depth,_,X,Y):- Depth<3, !, ground(X), (Y=X).
+%eval_20(Expander,RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
% Kills zero arity functions
-% eval_args20(RetType,Depth,Self,[X|Nil],[Y]):- Nil ==[],!,eval_args(RetType,Depth,Self,X,Y).
+% eval_20(Expander,RetType,Depth,Self,[X|Nil],[Y]):- Nil ==[],!,eval(Expander,RetType,Depth,Self,X,Y).
-
-% =================================================================
-% =================================================================
-% =================================================================
-% EVAL ARGS
-% =================================================================
-% =================================================================
+
+% =================================================================
+% =================================================================
+% =================================================================
+% EVAL ARGS
+% =================================================================
+% =================================================================
% =================================================================
/*
-eval_args20(RetType,Depth,Self,[Op,Arg1|VI],Res):- !,
+eval_20(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res):- !,
((is_list(Arg1),ground(Arg1),
- get_operator_typedef(Self,Op,[Type1|_Rest],RetType), \+ is_non_eval_kind(Type1),
- set_type(Depth,Res,Self,RetType),!,
- eval_args11(RetType,Depth,Self,Arg1,Res1), Arg1\=@=Res1, not_arg_violation(Depth,Self,Res1,Type1))
- *-> eval_args20(RetType,Depth,Self,[Op,Res1|VI],Res)
- ;eval_args40(RetType,Depth,Self,[Op,Arg1|VI],Res)).
+ get_operator_typedef(Self,Op,[Type1|_Rest],Expander,RetType), \+ is_non_eval_kind(Type1),
+ set_type(Depth,Res,Self,Expander,RetType),!,
+ eval_11(Expander,RetType,Depth,Self,Arg1,Res1), Arg1\=@=Res1, not_arg_violation(Depth,Self,Res1,Type1))
+ *-> eval_20(Expander,RetType,Depth,Self,[Op,Res1|VI],Res)
+ ;eval_80(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res)).
*/
-get_operator_typedef_nr(Self,Op,Types,RetType):-
+get_operator_typedef_nr(Self,Op,Types,Expander,RetType):-
no_repeats_var(OTD),
- get_operator_typedef(Self,Op,Types,RetType),
+ get_operator_typedef(Self,Op,Types,Expander,RetType),
term_variables(Types,Vars),
maplist(on_bind_test(Types = OTD),Vars).
on_bind_test(Goal,Var):- freeze(Var,Goal).
-guess_operator_typedef(Self,Op,Args,_Res,Types,RetType):-
- quietly(( (get_operator_typedef_nr(Self,Op,Types,RetType)*->true;
+guess_operator_typedef(Self,Op,Args,_Res,Types,Expander,RetType):-
+ quietly(( (get_operator_typedef_nr(Self,Op,Types,Expander,RetType)*->true;
(is_list(Args)-> (length(Args,N),length(Types,N)) ;
true)))).
-
+
% Has argument that is headed by the same function
-eval_args20(RetType,Depth,Self,[H1|Args],Res):-
+eval_20(Expander,RetType,Depth,Self,[H1|Args],Res):-
mnotrace((append(Left,[[H2|H2Args]|Rest],Args), H2==H1)),!,
- eval_args(RetType,Depth,Self,[H2|H2Args],ArgRes),
+ eval(Expander,RetType,Depth,Self,[H2|H2Args],ArgRes),
mnotrace((ArgRes\==[H2|H2Args], append(Left,[ArgRes|Rest],NewArgs))),
- eval_args40(RetType,Depth,Self,[H1|NewArgs],Res).
+ eval_80(Expander,RetType,Depth,Self,[H1|NewArgs],Res).
-eval_args20(RetType,Depth,Self,[Op|Args],Res):- !, %is_list(Args),!,
- (quietly(((guess_operator_typedef(Self,Op,Args,Res,Types,RetType),
- set_type(Depth,Res,Self,RetType),
- eval_args30c(RetType,Depth,Self,Op,1,Args,Types,NewArgs,Res))))
- *->eval_args40(RetType,Depth,Self,[Op|NewArgs],Res)
- ; eval_args40(RetType,Depth,Self,[Op|Args],Res)).
-%eval_args40(RetType,Depth,Self,Cond,TF):- eval_args40(RetType,Depth,Self,Cond,TF).
-eval_args20(RetType,Depth,Self,Cond,TF):-
- eval_args40(RetType,Depth,Self,Cond,TF).
+eval_20(Expander,RetType,Depth,Self,[Op|Args],Res):- !, %is_list(Args),!,
+ (quietly(((guess_operator_typedef(Self,Op,Args,Res,Types,Expander,RetType),
+ set_type(Depth,Res,Self,Expander,RetType),
+ eval_30c(Expander,RetType,Depth,Self,Op,1,Args,Types,NewArgs,Res))))
+ *->eval_80(Expander,RetType,Depth,Self,[Op|NewArgs],Res)
+ ; eval_80(Expander,RetType,Depth,Self,[Op|Args],Res)).
+%eval_80(Expander,RetType,Depth,Self,Cond,TF):- eval_80(Expander,RetType,Depth,Self,Cond,TF).
+eval_20(Expander,RetType,Depth,Self,Cond,TF):-
+ eval_80(Expander,RetType,Depth,Self,Cond,TF).
-eval_args30c(RetType,Depth,Self,Op,N,Args,Types,NewArgs,Res):-
+eval_30c(Expander,RetType,Depth,Self,Op,N,Args,Types,NewArgs,Res):-
length(ArgsL,N), append(ArgsL,[ArgE|ArgsR],Args),
(((is_list(ArgE),
length(TypesL,N), append(TypesL,[TypeE|TypesR],Types), \+ is_non_eval_kind(TypeE),
maplist(not_arg_violation(Depth,Self),ArgsL,TypesL),
maplist(not_arg_violation(Depth,Self),ArgsR,TypesR),
- eval_args11(RetType,Depth,Self,ArgE,ResE), ArgE\=@=ResE))-> true ; ResE=ArgE),
+ eval_11(Expander,RetType,Depth,Self,ArgE,ResE), ArgE\=@=ResE))-> true ; ResE=ArgE),
not_arg_violation(Depth,Self,ResE,TypeE),
append(ArgsL,[ResE|ArgsR],EArgs),
- plus(1,N,NPlus1),eval_args30c(RetType,Depth,Self,Op,NPlus1,EArgs,Types,NewArgs,Res).
-eval_args30c(_RetType,_Depth,_Self,_Op,_N,Args,_Types,Args,_Res).
+ plus(1,N,NPlus1),eval_30c(Expander,RetType,Depth,Self,Op,NPlus1,EArgs,Types,NewArgs,Res).
+eval_30c(Expander,_RetType,_Depth,_Self,_Op,_N,Args,_Types,Args,_Res).
/*
-eval_args30d(RetType,Depth,Self,Op,N,Args,Res):-
+eval_30d(Expander,RetType,Depth,Self,Op,N,Args,Res):-
length(ArgsL,N), append(ArgsL,[ArgE|ArgsR],Args),
- (((is_list(ArgE), eval_args11(RetType,Depth,Self,ArgE,ResE), ArgE\=@=ResE))-> true ; ResE=ArgE),
+ (((is_list(ArgE), eval_11(Expander,RetType,Depth,Self,ArgE,ResE), ArgE\=@=ResE))-> true ; ResE=ArgE),
append(ArgsL,[ResE|ArgsR],EArgs),!,
- plus(1,N,NPlus1),eval_args32(RetType,Depth,Self,Op,NPlus1,EArgs,Res).
-eval_args30d(RetType,Depth,Self,Op,_,Args,Res):- eval_args40(RetType,Depth,Self,[Op|Args],Res).
+ plus(1,N,NPlus1),eval_32(Expander,RetType,Depth,Self,Op,NPlus1,EArgs,Res).
+eval_30d(Expander,RetType,Depth,Self,Op,_,Args,Res):- eval_80(Expander,RetType,Depth,Self,[Op|Args],Res).
*/
/*
into_values(List,Many):- List==[],!,Many=[].
into_values([X|List],Many):- List==[],is_list(X),!,Many=X.
into_values(Many,Many).
-eval_args40(RetType,_Dpth,_Slf,Name,Value):- atom(Name), nb_current(Name,Value),!.
-*/
-
+eval_80(Expander,RetType,_Dpth,_Slf,Name,Value):- atom(Name), nb_current(Name,Value),!.
+*/
-% =================================================================
-% =================================================================
-% =================================================================
-% METTLOG PREDEFS
-% =================================================================
-% =================================================================
+
+% =================================================================
+% =================================================================
+% =================================================================
+% METTLOG PREDEFS
+% =================================================================
+% =================================================================
% =================================================================
% use function we cheated with
-eval_args40(RetType,Depth,Self,['length',L],Res):- !, eval_args(Depth,Self,L,LL),
+eval_80(Expander,RetType,Depth,Self,['length',L],Res):- !, eval(Depth,Self,L,LL),
(is_list(LL)->length(LL,Res);Res=1),
- check_returnval(RetType,Res).
-
-eval_args40(RetType,Depth,Self,['If',Cond,Then],Res):- !,
- eval_args('Bool',Depth,Self,Cond,TF),
- (is_True(TF) -> eval_args(RetType,Depth,Self,Then,Res) ; (fail, Res = [])).
+ check_returnval(Expander,RetType,Res).
-eval_args40(RetType,_Dpth,_Slf,['arity',F,A],TF):- !,as_tf(current_predicate(F/A),TF),check_returnval(RetType,TF).
-eval_args40(RetType,Depth,Self,['CountElement',L],Res):- !, eval_args(RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1),check_returnval(RetType,Res).
-eval_args40(RetType,_Dpth,_Slf,['make_list',List],MettaList):- !, into_metta_cons(List,MettaList),check_returnval(RetType,MettaList).
+eval_80(Expander,RetType,Depth,Self,['If',Cond,Then],Res):- !,
+ eval('Bool',Depth,Self,Cond,TF),
+ (is_True(TF) -> eval(Expander,RetType,Depth,Self,Then,Res) ; (fail, Res = [])).
-% less Macro-ey Functions
-% =================================================================
-% =================================================================
-% =================================================================
-% MATH/+/-
-% =================================================================
-% =================================================================
-% =================================================================
+eval_80(Expander,RetType,_Dpth,_Slf,['arity',F,A],TF):- !,as_tf(current_predicate(F/A),TF),check_returnval(Expander,RetType,TF).
+eval_80(Expander,RetType,Depth,Self,['CountElement',L],Res):- !, eval(Expander,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1),check_returnval(Expander,RetType,Res).
+eval_80(Expander,RetType,_Dpth,_Slf,['make_list',List],MettaList):- !, into_metta_cons(List,MettaList),check_returnval(Expander,RetType,MettaList).
-eval_args40(RetType,Depth,Self,['+',N1,N2],N):- number(N1),!,
- eval_args(RetType,Depth,Self,N2,N2Res), catch(N is N1+N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
-eval_args40(RetType,Depth,Self,['-',N1,N2],N):- number(N1),!,
- eval_args(RetType,Depth,Self,N2,N2Res), catch(N is N1-N2Res,_E,(set_last_error(['Error',N2Res,'Number']),fail)).
+% less Macro-ey Functions
-eval_args40(RetType,_Dpth,_Slf,[F|LESS],Res):-
- notrace((ground([F|LESS]), once(maybe_efbug(show_success,eval_selfless([F|LESS],Res))),mnotrace(([F|LESS]\==Res)))),
- check_returnval(RetType,Res).
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% function inherited by system
-% =================================================================
-% =================================================================
+% =================================================================
+% =================================================================
+% =================================================================
+% function inherited by system
+% =================================================================
+% =================================================================
% =================================================================
% predicate inherited by system
-eval_args40(RetType,Depth,Self,[AE|More],TF):-
+eval_80(Expander,RetType,_Depth,_Self,[AE|More],TF):-
length(More,Len),
is_syspred(AE,Len,Pred),
mnotrace( \+ is_user_defined_goal(Self,[AE|More])),!,
adjust_args(Depth,Self,AE,More,Adjusted),!,
catch_warn(efbug(show_call,as_tf(apply(Pred,Adjusted),TF))),
- check_returnval(RetType,TF).
+ check_returnval(Expander,RetType,TF).
% function inherited by system
-eval_args40(RetType,Depth,Self,[AE|More],TF):-
+eval_80(Expander,RetType,Depth,Self,[AE|More],TF):-
length([AE|More],Len),
is_syspred(AE,Len,Pred),
mnotrace( \+ is_user_defined_goal(Self,[AE|More])),!,
adjust_args(Depth,Self,AE,More,Adjusted),!,
append(Adjusted,[TF],Args),!,
efbug(show_call,catch_warn(apply(Pred,Args))),
-check_returnval(RetType,TF).
+check_returnval(Expander,RetType,TF).
last_element(T,E):- \+ compound(T),!,E=T.
@@ -1400,71 +1343,71 @@
eval_selfless(LIS,Y):- mnotrace((
LIS=[F,_,_], atom(F), catch_warn(current_op(_,yfx,F)),
catch((LIS\=[_], s2p(LIS,IS), Y is IS),_,fail))),!.
-
-
-:- discontiguous eval_args6/4.
-%eval_args40(RetType,Depth,Self,PredDecl,Res):- eval_args6(RetType,Depth,Self,PredDecl,Res).
-%eval_args40(RetType,_Dpth,_Slf,L1,Res):- is_list(L1),maplist(self_eval,L1),!,Res=L1.
-%eval_args40(RetType,_Depth,_Self,X,X).
+
+:- discontiguous eval_6/4.
+%eval_80(Expander,RetType,Depth,Self,PredDecl,Res):- eval_6(Expander,RetType,Depth,Self,PredDecl,Res).
+
+%eval_80(Expander,RetType,_Dpth,_Slf,L1,Res):- is_list(L1),maplist(self_eval,L1),!,Res=L1.
+%eval_80(Expander,RetType,_Depth,_Self,X,X).
-%eval_args40(RetType,Depth,Self,['eq',X,Y],Res):- !, as_tf(eval_until_eq(RetType,Depth,Self,X,Y),Res).
-eval_args40(RetType,_Dpth,_Slf,['memb',E,List],Res):- !, into_pl_list(List,PLList),as_tf(member(E,PLList), Res),check_returnval(RetType,Res).
+%eval_80(Expander,RetType,Depth,Self,['eq',X,Y],Res):- !, as_tf(eval_until_eq(Expander,RetType,Depth,Self,X,Y),Res).
+eval_80(Expander,RetType,_Dpth,_Slf,['memb',E,List],Res):- !, into_pl_list(List,PLList),as_tf(member(E,PLList), Res),check_returnval(Expander,RetType,Res).
-eval_args40(RetType,Depth,Self,X,Y):-
- (efbug(show_success,eval_args60(RetType,Depth,Self,X,Y))*->true ;
- (efbug(show_failure,eval_args_failed(Depth,Self,X,Y)*->true;X=Y))).
+eval_80(Expander,RetType,Depth,Self,X,Y):-
+ (efbug(show_success,eval_60(Expander,RetType,Depth,Self,X,Y))*->true ;
+ (efbug(show_failure,eval_failed(Depth,Self,X,Y)*->true;X=Y))).
+
+eval_60(Expander,RetType,Depth,Self,PredDecl,Res):-
+ eval_61(Expander,RetType,Depth,Self,PredDecl,B),
+ eval(Expander,RetType,Depth,Self,B,Res).
-eval_args60(RetType,Depth,Self,PredDecl,Res):-
- eval_args61(RetType,Depth,Self,PredDecl,B),
- eval_args(RetType,Depth,Self,B,Res).
-
/*
-eval_args40(RetType,Depth,Self,[Op,Arg1|VI],Res):- is_list(Arg1),!,
- ((get_operator_typedef(Self,Op,[Type1|_Rest],RetType),
+eval_80(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res):- is_list(Arg1),!,
+ ((get_operator_typedef(Self,Op,[Type1|_Rest],Expander,RetType),
\+ is_non_eval_kind(Type1),
- eval_args00(RetType,Depth,Self,Arg1,Res1), Arg1\=@=Res1, \+ arg_violation(Depth,Self,Res1,Type1), set_type(Depth,Self,Res,RetType) )
- *-> eval_args40(RetType,Depth,Self,[Op,Res1|VI],Res);
- eval_args63(RetType,Depth,Self,[Op,Arg1|VI],Res)).
-
-eval_args40(RetType,Depth,Self,[Op,Arg1|VI],Res):- fail, !,
- ((is_list(Arg1),eval_args_in_steps_some_change(RetType,Depth,Self,Arg1,Res1))
- *-> eval_args63(RetType,Depth,Self,[Op,Res1|VI],Res)
- ;eval_args63(RetType,Depth,Self,[Op,Arg1|VI],Res)).
-*/
-
-
-% =================================================================
-% =================================================================
-% =================================================================
-% USER DEFINED FUNCTIONS
-% =================================================================
-% =================================================================
-% =================================================================
-
-eval_args61(_RetType,_Depth,Self,H,B):- \+ iz_conz(H), !,metta_defn(Self,H,B).
-%eval_args40(RetType,Depth,Self,[H|Args],B):- is_special_op(Self,H),!,eval_args64(RetType,Depth,Self,H,B).
-eval_args61(RetType,Depth,Self,[AE|More],TF):-
+ eval_00(Expander,RetType,Depth,Self,Arg1,Res1), Arg1\=@=Res1, \+ arg_violation(Depth,Self,Res1,Type1), set_type(Depth,Self,Res,Expander,RetType) )
+ *-> eval_80(Expander,RetType,Depth,Self,[Op,Res1|VI],Res);
+ eval_63(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res)).
+
+eval_80(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res):- fail, !,
+ ((is_list(Arg1),eval_in_steps_some_change(Expander,RetType,Depth,Self,Arg1,Res1))
+ *-> eval_63(Expander,RetType,Depth,Self,[Op,Res1|VI],Res)
+ ;eval_63(Expander,RetType,Depth,Self,[Op,Arg1|VI],Res)).
+*/
+
+
+% =================================================================
+% =================================================================
+% =================================================================
+% USER DEFINED FUNCTIONS
+% =================================================================
+% =================================================================
+% =================================================================
+
+eval_61(Expander,_RetType,_Depth,Self,H,B):- \+ iz_conz(H), !,metta_defn(Self,H,B).
+%eval_80(Expander,RetType,Depth,Self,[H|Args],B):- is_special_op(Self,H),!,eval_64(Expander,RetType,Depth,Self,H,B).
+eval_61(Expander,RetType,Depth,Self,[AE|More],TF):-
%adjust_args(Depth,Self,AE,More,Adjusted),!,
More=Adjusted,
- eval_args64(RetType,Depth,Self,[AE|Adjusted],TF).
+ eval_64(Expander,RetType,Depth,Self,[AE|Adjusted],TF).
-%eval_args40(RetType,Depth,Self,[Equals,X,Y],E):-Equals=='=',!, eval_args(RetType,Depth,Self,['==',Y,X],E).
+%eval_80(Expander,RetType,Depth,Self,[Equals,X,Y],E):-Equals=='=',!, eval(Expander,RetType,Depth,Self,['==',Y,X],E).
-%eval_args63(RetType,Depth,Self,H,B):-
- %( no_repeats(H+B,eval_args64(RetType,Depth,Self,H,B))*->true;eval_args67(RetType,Depth,Self,H,B)).
-%eval_args63(RetType,Depth,Self,H,B):-
- % ( (eval_args64(RetType,Depth,Self,H,B))*->true;eval_args67(RetType,Depth,Self,H,B)).
+%eval_63(Expander,RetType,Depth,Self,H,B):-
+ %( no_repeats(H+B,eval_64(Expander,RetType,Depth,Self,H,B))*->true;eval_67(Expander,RetType,Depth,Self,H,B)).
+%eval_63(Expander,RetType,Depth,Self,H,B):-
+ % ( (eval_64(Expander,RetType,Depth,Self,H,B))*->true;eval_67(Expander,RetType,Depth,Self,H,B)).
-eval_args64(_RetType,_Depth,Self,[H|Args],B):- % no weird template matchers
+eval_64(Expander,_RetType,_Depth,Self,[H|Args],B):- % no weird template matchers
forall(metta_defn(Self,[H|Template],_),maplist(not_template_arg,Template)),!,
metta_defn(Self,[H|Args],B).
% Use the first template match
-eval_args64(_RetType,_Depth,Self,[H|Args],B):-
+eval_64(Expander,_RetType,_Depth,Self,[H|Args],B):-
metta_defn(Self,[H|Template],B),
Args=Template,!.
@@ -1473,105 +1416,105 @@
%not_template_arg(TArg):- is_list(TArg),!,fail.
/*
-eval_args66(_RetType,Depth,Self,[H|Start],B):- !,
- maplist(eval_args(Depth,Self),Start,NewStart),
+eval_66(Expander,_RetType,Depth,Self,[H|Start],B):- !,
+ maplist(eval(Depth,Self),Start,NewStart),
metta_defn(Self,[H|NewStart],B).
-eval_args67(RetType,Depth,Self,[[H|Start]|T1],Y):-
+eval_67(Expander,RetType,Depth,Self,[[H|Start]|T1],Y):-
mnotrace((
nonvar(H),
% is_user_defined_head_f(Self,H),
is_list(Start))),
- maplist(eval_args(Depth,Self),Start,NewStart),
+ maplist(eval(Depth,Self),Start,NewStart),
metta_defn(Self,[H|NewStart],Left),
- eval_args(RetType,Depth,Self,[Left|T1],Y).
+ eval(Expander,RetType,Depth,Self,[Left|T1],Y).
*/
/*FAILS
% Has subterm to eval
-eval_args67(RetType,Depth,Self,[F|PredDecl],Res):- !, fail,
+eval_67(Expander,RetType,Depth,Self,[F|PredDecl],Res):- !, fail,
Depth>1,
quietly(sub_sterm1(SSub,PredDecl)),
mnotrace((ground(SSub),SSub=[_|Sub], is_list(Sub),maplist(atomic,SSub))),
- eval_args(RetType,Depth,Self,SSub,Repl),
+ eval(Expander,RetType,Depth,Self,SSub,Repl),
mnotrace((SSub\=Repl,subst(PredDecl,SSub,Repl,Temp))),
- eval_args40(RetType,Depth,Self,[F|Temp],Res).
+ eval_80(Expander,RetType,Depth,Self,[F|Temp],Res).
-%eval_args67(RetType,Depth,Self,X,Y):- (eval_args68(RetType,Depth,Self,X,Y)*->true;metta_atom_iter(Depth,Self,[=,X,Y])).
+%eval_67(Expander,RetType,Depth,Self,X,Y):- (eval_68(Expander,RetType,Depth,Self,X,Y)*->true;metta_atom_iter(Depth,Self,[=,X,Y])).
-eval_args67(RetType,Depth,Self,PredDecl,Res):- fail,
+eval_67(Expander,RetType,Depth,Self,PredDecl,Res):- fail,
((term_variables(PredDecl,Vars),
(metta_atom(Self,PredDecl) *-> (Vars ==[]->Res='True';Vars=Res);
- (eval_args(RetType,Depth,Self,PredDecl,Res),ignore(Vars ==[]->Res='True';Vars=Res))))),
+ (eval(Expander,RetType,Depth,Self,PredDecl,Res),ignore(Vars ==[]->Res='True';Vars=Res))))),
PredDecl\=@=Res.
-%eval_args68(_RetType,_Dpth,Self,[H|_],_):- mnotrace( \+ is_user_defined_head_f(Self,H) ), !,fail.
-eval_args68(_RetType,_Dpth,Self,[H|T1],Y):- metta_defn(Self,[H|T1],Y).
-%eval_args68(RetType,_Dpth,Self,[H|T1],'True'):- metta_atom(Self,[H|T1]).
-%val_args68(RetType,_Dpth,Self,CALL,Y):- fail,append(Left,[Y],CALL),metta_defn(Self,Left,Y).
+%eval_68(Expander,_RetType,_Dpth,Self,[H|_],_):- mnotrace( \+ is_user_defined_head_f(Self,H) ), !,fail.
+eval_68(Expander,_RetType,_Dpth,Self,[H|T1],Y):- metta_defn(Self,[H|T1],Y).
+%eval_68(Expander,RetType,_Dpth,Self,[H|T1],'True'):- metta_atom(Self,[H|T1]).
+%val_args68(Expander,RetType,_Dpth,Self,CALL,Y):- fail,append(Left,[Y],CALL),metta_defn(Self,Left,Y).
-%eval_args6(RetType,Depth,Self,['ift',CR,Then],RO):- fail, !, %fail, % trace,
-% metta_defn(Self,['ift',R,Then],Become),eval_args(RetType,Depth,Self,CR,R),eval_args(RetType,Depth,Self,Then,_True),eval_args(RetType,Depth,Self,Become,RO).
+%eval_6(Expander,RetType,Depth,Self,['ift',CR,Then],RO):- fail, !, %fail, % trace,
+% metta_defn(Self,['ift',R,Then],Become),eval(Expander,RetType,Depth,Self,CR,R),eval(Expander,RetType,Depth,Self,Then,_True),eval(Expander,RetType,Depth,Self,Become,RO).
*/
/*
-eval_args40(RetType,Depth,Self,X,Y):-
- (efbug(show_success,eval_args80(RetType,Depth,Self,X,Y))*->true ;
- (efbug(show_failure,eval_args_failed(Depth,Self,X,Y)*->true;X=Y))).
+eval_80(Expander,RetType,Depth,Self,X,Y):-
+ (efbug(show_success,eval_80(Expander,RetType,Depth,Self,X,Y))*->true ;
+ (efbug(show_failure,eval_failed(Depth,Self,X,Y)*->true;X=Y))).
*/
%not_compound(Term):- \+ is_list(Term),!.
-%eval_args40(RetType,Depth,Self,Term,Res):- maplist(not_compound,Term),!,eval_args645(RetType,Depth,Self,Term,Res).
+%eval_80(Expander,RetType,Depth,Self,Term,Res):- maplist(not_compound,Term),!,eval_645(Expander,RetType,Depth,Self,Term,Res).
+
+%eval_80(Expander,RetType,Depth,Self,[X1|[F2|X2]],[Y1|Y2]):- is_function(F2),!,eval(Expander,RetType,Depth,Self,[F2|X2],Y2),eval(Expander,RetType,Depth,Self,X1,Y1).
-%eval_args40(RetType,Depth,Self,[X1|[F2|X2]],[Y1|Y2]):- is_function(F2),!,eval_args(RetType,Depth,Self,[F2|X2],Y2),eval_args(RetType,Depth,Self,X1,Y1).
-
-% =================================================================
-% =================================================================
-% =================================================================
-% AGREGATES
-% =================================================================
-% =================================================================
+% =================================================================
+% =================================================================
+% =================================================================
+% AGREGATES
+% =================================================================
+% =================================================================
% =================================================================
cwdl(DL,Goal):- call_with_depth_limit(Goal,DL,R), (R==depth_limit_exceeded->(!,fail);true).
-findall_eval(Depth,Self,X,L):- !, findall(E,eval_args_ne(_RetType,Depth,Self,X,E),L).
+findall_eval_(Depth,Self,X,L):- !, findall(E,eval_ne(Expander,_RetType,Depth,Self,X,E),L).
-bagof_eval(_Dpth,_Slf,X,L):- typed_list(X,_Type,L),!.
-bagof_eval(Depth,Self,X,L):- !,bagof_or_nil(E,eval_args_ne(_RetType,Depth,Self,X,E),L).
-setof_eval(Depth,Self,X,S):- !,bagof_eval(Depth,Self,X,L),sort(L,S).
-%setof_eval(Depth,Self,X,S):- setof(E,eval_args(RetType,Depth,Self,X,E),S)*->true;S=[].
+bagof_eval_(_Dpth,_Slf,X,L):- typed_list(X,_Type,L),!.
+bagof_eval_(Depth,Self,X,L):- !,bagof_or_nil(E,eval_ne(Expander,_RetType,Depth,Self,X,E),L).
+setof_eval_(Depth,Self,X,S):- !,bagof_eval_(Depth,Self,X,L),sort(L,S).
+%setof_eval_(Depth,Self,X,S):- setof(E,eval(Expander,RetType,Depth,Self,X,E),S)*->true;S=[].
bagof_or_nil(T,G,L):- findall(T,G,L).
%bagof_or_nil(T,G,L):- bagof(T,G,L)*->true;L=[].
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/metta_vspace/pyswip_6l/metta_interp.pl b/metta_vspace/pyswip_6l/metta_interp.pl
index c99e2d86..7bb96d68 100755
--- a/metta_vspace/pyswip_6l/metta_interp.pl
+++ b/metta_vspace/pyswip_6l/metta_interp.pl
@@ -47,7 +47,7 @@
option_value_def('time',true).
option_value_def('exec',true).
option_value_def('html',false).
-option_value_def('python',load).
+option_value_def('python',false).
option_value_def('halt',false).
option_value_def('prolog',false).
option_value_def('doing_repl',false).
@@ -58,10 +58,11 @@
option_value_def('trace-on-overflow',false).
option_value_def('trace-on-error',true).
option_value_def('trace-on-load',true).
+option_value_def('trace-on-exec',true).
+option_value_def('trace-on-eval',true).
option_value_def('trace-on-fail',false).
option_value_def('trace-on-pass',false).
-option_value_def('trace-on-eval',false).
-option_value_def('trace-on-exec',true).
+
@@ -71,6 +72,8 @@
set_option_value('trace-on-eval',TF),
set_option_value('trace-on-pass',false),
set_option_value('trace-on-fail',false),
+ set_option_value('exec',rtrace),
+ set_option_value('eval',rtrace),
!.
:- set_is_unit_test(true).
@@ -129,7 +132,7 @@
% %%%% Nondet Opteration
% ============================
% Superpose a List
-%'superpose'(List, SuperposedList):- eval_args(['superpose', List], SuperposedList).
+'superpose'(List, SuperposedList):- eval_args(['superpose', List], SuperposedList).
% ============================
% %%%% Testing
@@ -227,13 +230,6 @@
metta_cmd_args(Rest):- current_prolog_flag(argv,Rest).
run_cmd_args:- metta_cmd_args(Rest), !, do_cmdline_load_metta('&self',Rest).
-is_metta_data_functor(F):-
- current_self(Self),is_metta_data_functor(Self,F).
-
-is_metta_data_functor(Other,H):-
- metta_type(Other,H,_),
- \+ metta_atom(Other,[H|_]),
- \+ metta_defn(Other,[H|_],_).
@@ -361,16 +357,16 @@
load_metta('&self',Filename).
+load_metta(_Self,Filename):- Filename=='--repl',!,repl.
+load_metta(Self,Filename):-
+ (\+ atom(Filename); \+ exists_file(Filename)),!,
+ with_wild_path(load_metta(Self),Filename),!,loonit_report.
load_metta(Self,RelFilename):-
atom(RelFilename),
exists_file(RelFilename),!,
absolute_file_name(RelFilename,Filename),
track_load_into_file(Filename,
include_metta(Self,RelFilename)).
-load_metta(_Self,Filename):- Filename=='--repl',!,repl.
-load_metta(Self,Filename):-
- (\+ atom(Filename); \+ exists_file(Filename)),!,
- with_wild_path(load_metta(Self),Filename),!,loonit_report.
include_metta(Self,Filename):-
(\+ atom(Filename); \+ exists_file(Filename)),!,
@@ -394,11 +390,10 @@
set_exec_num(Filename,1),
load_answer_file(Filename),
set_exec_num(Filename,0))),
- ((repeat,
- must_det_ll((
+ once((repeat, ((
((nb_current(read_mode,Mode),Mode\==[])->true;Mode=load),
once(read_metta(In,Expr)), %write_src(read_metta=Expr),nl,
- once((do_metta(file(Filename),Mode,Self,Expr,_O)->true;
+ must_det_ll((do_metta(file(Filename),Mode,Self,Expr,_O)->true;
pp_m(unknown_do_metta(file(Filename),Mode,Self,Expr)))),
flush_output)),
at_end_of_stream(In)))))),!.
@@ -462,7 +457,8 @@
; Transformed = Input % Keep other non-compound terms as they are
).
-is_syspred(H,Len,Pred):- notrace(is_syspred0(H,Len,Pred)).
+/*
+_syspred(H,Len,Pred):- notrace(is_syspred0(H,Len,Pred)).
is_syspred0(H,_Ln,_Prd):- \+ atom(H),!,fail.
is_syspred0(H,_Ln,_Prd):- upcase_atom(H,U),downcase_atom(H,U),!,fail.
is_syspred0(H,Len,Pred):- current_predicate(H/Len),!,Pred=H.
@@ -473,6 +469,14 @@
fn_append1(List,X,ListX),
into_fp(ListX,Call).
+is_metta_data_functor(F):-
+ current_self(Self),is_metta_data_functor(Self,F).
+
+is_metta_data_functor(Other,H):-
+ metta_type(Other,H,_),
+ \+ metta_atom(Other,[H|_]),
+ \+ metta_defn(Other,[H|_],_).
+*/
is_function(F):- atom(F).
is_False(X):- X\=='True', (is_False1(X)-> true ; (eval_args(X,Y),is_False1(Y))).
@@ -834,18 +838,19 @@
type_decl('Variable').
:- dynamic(metta_atom/2).
-metta_atom('&stdlib', [:, Type, 'Type']):- type_decl(Type).
-metta_atom('&stdlib', [:, Op, [->|List]]):- op_decl(Op,Params,ReturnType),append(Params,[ReturnType],List).
-metta_atom(KB,Atom):- KB \= '&stdlib', metta_atom('&stdlib',Atom).
-metta_atom(KB, [F, A| List]):- nonvar(F), KB=='&flybase',fb_pred(F, Len), length([A|List],Len),apply(F,[A|List]).
+metta_atom_stdlib([:, Type, 'Type']):- type_decl(Type).
+metta_atom_stdlib([:, Op, [->|List]]):- op_decl(Op,Params,ReturnType),append(Params,[ReturnType],List).
+
+metta_atom(KB, [F, A| List]):- KB=='&flybase',fb_pred(F, Len), length([A|List],Len),apply(F,[A|List]).
+%metta_atom(KB, [F|List]):- KB=='&flybase',fb_pred(F, Len), length(List,Len),apply(F,List).
metta_atom(Space, Atom):- typed_list(Space,_,L),!, member(Atom,L).
+metta_atom(KB,Atom):- nonvar(KB), nonvar(Atom), metta_atom_stdlib(Atom).
%atom1_atom_4(Space,F,A,List):- nonvar(Space), metta_atom(Space, F, A, List).
-%metta_atom(KB, [F|List]):- KB=='&flybase',fb_pred(F, Len), length(List,Len),apply(F,List).
%metta_atom(KB,[F,A|List]):- metta_atom(KB,F,A,List), F \== '=',!.
metta_defn(KB,Head,Body):- metta_atom(KB,['=',Head,Body]).
@@ -857,11 +862,12 @@
metta_anew1(Load,_OBO):- var(Load),trace,!.
metta_anew1(Load,OBO):- maybe_xform(OBO,XForm),!,metta_anew1(Load,XForm).
-
+metta_anew1(Ch,OBO):- metta_interp_mode(Ch,Mode), !, metta_anew1(Mode,OBO).
metta_anew1(load,OBO):- OBO= metta_atom(Space,Atom),!,'add-atom'(Space, Atom).
metta_anew1(unload,OBO):- OBO= metta_atom(Space,Atom),!,'remove-atom'(Space, Atom).
-metta_anew1(load,OBO):- must_det_ll((load_hook(load,OBO),subst_vars(OBO,Cl),assertz_if_new(Cl))). %to_metta(Cl).
+metta_anew1(load,OBO):- !, must_det_ll((load_hook(load,OBO),
+ subst_vars(OBO,Cl),show_failure(assertz_if_new(Cl)))). %to_metta(Cl).
metta_anew1(unload,OBO):- subst_vars(OBO,Cl),load_hook(unload,OBO),
expand_to_hb(Cl,Head,Body),
predicate_property(Head,number_of_clauses(_)),
@@ -869,6 +875,7 @@
metta_anew2(Load,_OBO):- var(Load),trace,!.
metta_anew2(Load,OBO):- maybe_xform(OBO,XForm),!,metta_anew2(Load,XForm).
+metta_anew2(Ch,OBO):- metta_interp_mode(Ch,Mode), !, metta_anew2(Mode,OBO).
metta_anew2(load,OBO):- must_det_ll((load_hook(load,OBO),subst_vars_not_last(OBO,Cl),assertz_if_new(Cl))). %to_metta(Cl).
metta_anew2(unload,OBO):- subst_vars_not_last(OBO,Cl),load_hook(unload,OBO),
expand_to_hb(Cl,Head,Body),
@@ -1039,7 +1046,8 @@
metta_anew(Load,Src,metta_atom(Self,PredDecl)),
ignore((PredDecl=['=',Head,Body], metta_anew(Load,Src,metta_defn(Self,Head,Body)))),
ignore((Body == 'True',!,do_metta(File,Self,Load,Head))),
- nop((fn_append(Head,X,Head), fn_append(PredDecl,X,Body), metta_anew((Head:- Body)))),!.*/
+ nop((fn_append(Head,X,Head), fn_append(PredDecl,X,Body),
+ metta_anew((Head:- Body)))),!.*/
asserted_do_metta2(Self,Load,[EQ,Head,Result], Src):- EQ=='=', !,
must_det_ll((
@@ -1430,6 +1438,9 @@
eval(Form,Out):-
current_space(Self),
+ eval(Self,Form,Out).
+
+eval(Self,Form,Out):-
do_metta(prolog,exec,Self,Form,Out).
name_vars(X='$VAR'(X)).
@@ -1444,16 +1455,18 @@
%GG = interact(['Result'=X|NamedVarsList],Term,trace_off),
(((From = file(_Filename), option_value('exec',skip), \+ always_exec(BaseEval)))
-> GG = (skip(Term),deterministic(Complete))
- ; GG = (Term,deterministic(Complete))),
+ ; GG = (dcall(Term),deterministic(Complete))),
Result = res(FOut),
!, % metta_toplevel
flag(result_num,_,0),
+ with_indents(false,
\+ \+ (
maplist(name_vars,NamedVarsList),
name_vars('OUT'=X),
- add_history_src(exec(BaseEval)),
+ %add_history_src(exec(BaseEval)),
color_g_mesg('#fa90f6', (write('; '), with_indents(false,write_src(exec(BaseEval))))),
- color_g_mesg('#da70d6', (write('% DEBUG: '), writeq(eval_args(100,Self,BaseEval,X)),writeln('.')))))),
+ if_t(is_interactive(From),if_t(is_list(BaseEval),add_history_src(exec(TermV)))),
+ color_g_mesg('#da70d6', (write('% DEBUG: '), writeq(eval_args(100,Self,BaseEval,X)),writeln('.'))))))),
(forall_interactive(
From, WasInteractive,may_rtrace(GG),
@@ -1473,12 +1486,13 @@
(write("More Solutions? "),get_single_char_key(C), writeq(key=C),nl,
(C=='b' -> (once(repl),fail) ;
(C=='m' -> make ;
- (C=='t' -> set_debug(eval,true) ;
+ (C=='t' -> (nop(set_debug(eval,true)),rtrace) ;
+ (C=='T' -> (set_debug(eval,true));
(C==';' -> true ;
(C==esc('[A',[27,91,65]) -> nb_setarg(1, Control, leap) ;
(C=='l' -> nb_setarg(1, Control, leap) ;
(((C=='\n');(C=='\r')) -> (!,fail);
- (!,fail))))))))));((Complete==true) ->! ; true)))
+ (!,fail)))))))))));((Complete==true) ->! ; true)))
*-> (Result = res(FOut))
; (flag(result_num,ResNum,ResNum),(ResNum==0->(format('~N~n~n'),!,fail);true))).
@@ -1488,10 +1502,10 @@
get_single_char_key(C,A):- name(A,[C]).
forall_interactive(file(_),false,Goal,After):- !, forall(Goal,After).
-forall_interactive(prolog,false,Goal,After):- !, Goal,ignore(After).
+forall_interactive(prolog,false,Goal,After):- !, Goal,quietly(After).
forall_interactive(From,WasInteractive,Goal,After):-
(is_interactive(From) -> WasInteractive = true ; WasInteractive = false),!,
- forall(Goal,After).
+ forall(Goal,quietly(After)).
print_var(Name=Var) :- print_var(Name,Var).
print_var(Name,Var):- write('$'),write(Name), write(' = '), write_src(Var), nl.
@@ -1668,12 +1682,12 @@
really_trace:- once(option_value('exec',rtrace);option_value('eval',rtrace);is_debugging((exec));is_debugging((eval))).
% !(pragma! exec rtrace)
may_rtrace(Goal):- really_trace,!, really_rtrace(Goal).
-may_rtrace(Goal):- time_eval((Goal))*->true;really_rtrace(Goal).
+may_rtrace(Goal):- rtrace_on_existence_error(time_eval(dcall(Goal)))*->true;really_rtrace(Goal).
really_rtrace(Goal):- use_metta_compiler,!,rtrace(call(Goal)).
really_rtrace(Goal):- with_debug((eval),with_debug((exec),Goal)).
-
-
+rtrace_on_existence_error(G):- !, catch(G,E,(wdmsg(E),rtrace(G))).
+%rtrace_on_existence_error(G):- catch(G,error(existence_error(procedure,W),Where),rtrace(G)).
% Measures the execution time of a Prolog goal and displays the duration in seconds,
% milliseconds, or microseconds, depending on the execution time.
@@ -1682,7 +1696,7 @@
% - Goal: The Prolog goal to be executed and timed.
%
% The predicate uses the `statistics/2` predicate to measure the CPU time before
-% and after executing the provided goal. It calculates the elapsed time in seconds
+% and after executing the provided goal.It calculates the elapsed time in seconds
% and converts it to milliseconds and microseconds. The output is formatted to
% provide clear timing information:
%
@@ -1716,8 +1730,28 @@
;( Micro is Milliseconds * 1_000,
format('; ~w took ~6f secs. (~2f microseconds) ~n', [What, Seconds, Micro])))).
-
-
+example0(_):- fail.
+example1(a). example1(_):- fail.
+example2(a). example2(b). example2(_):- fail.
+example3(a). example3(b). example3(c). example3(_):- fail.
+
+%dcall(X):- (call(X),deterministic(YN)),trace,((YN==true)->!;true).
+ dcall(XX):-
+ USol = sol(dead),
+ copy_term(XX,X),
+ call_nth(USol,X,Nth,Det,Prev),
+ %wdmsg(call_nth(USol,X,Nth,Det,Prev)),
+ XX=Prev,
+ (Det==yes -> (!, (XX=Prev;XX=X)) ;
+ (((var(Nth) -> ( ! , Prev\==dead) ;
+ true),
+ (Nth==1 -> ! ; true)))).
+
+call_nth(USol,XX,Nth,Det,Prev):-
+ repeat,
+ ((call_nth(XX,Nth),deterministic(Det),arg(1,USol,Prev))*->
+ ( nb_setarg(1,USol,XX))
+ ; (!, arg(1,USol,Prev))).
catch_red(Term):- catch(Term,E,pp_m(red,in(Term,E))).
diff --git a/metta_vspace/pyswip_6l/metta_space.pl b/metta_vspace/pyswip_6l/metta_space.pl
index 01624864..f549ad6e 100755
--- a/metta_vspace/pyswip_6l/metta_space.pl
+++ b/metta_vspace/pyswip_6l/metta_space.pl
@@ -63,9 +63,10 @@
% Add an atom to the space
'add-atom'(SpaceNameOrInstance, Atom) :-
- debug_metta(['add-atom',SpaceNameOrInstance, Atom]),
+ % debug_metta(['add-atom',SpaceNameOrInstance, Atom]),
space_type_method(Type,add_atom,Method), call(Type,SpaceNameOrInstance),!,
- debug_metta(['type-method',Type,Method]),
+ if_t((SpaceNameOrInstance\=='&self' ; Type\=='is_asserted_space'),
+ debug_metta(['type-method',Type,Method,SpaceNameOrInstance,Atom])),
call(Method,SpaceNameOrInstance,Atom).
% Add Atom
'add-atom'(Environment, AtomDeclaration, Result):- eval_args(['add-atom', Environment, AtomDeclaration], Result).
diff --git a/metta_vspace/pyswip_6l/metta_testing.pl b/metta_vspace/pyswip_6l/metta_testing.pl
index 6b597e24..b24755b0 100755
--- a/metta_vspace/pyswip_6l/metta_testing.pl
+++ b/metta_vspace/pyswip_6l/metta_testing.pl
@@ -61,7 +61,8 @@
%color_g_mesg(C,G):- silent_loading,!.
color_g_mesg(C,G):- notrace((check_silent_loading,color_g_mesg_ok(C,G))).
color_g_mesg_ok(C,G):-
- notrace(( wots(S,user:call(G)),
+ notrace((
+ wots(S,user:call(G)),
(S == "" -> true ; our_ansi_format(C, '~w~n', [S])))),!.
our_ansi_format(C, Fmt,Args):- \+ atom(C), % set_stream(current_output,encoding(utf8)),
diff --git a/metta_vspace/pyswip_6l/metta_types.pl b/metta_vspace/pyswip_6l/metta_types.pl
index 139597f9..58c5b374 100755
--- a/metta_vspace/pyswip_6l/metta_types.pl
+++ b/metta_vspace/pyswip_6l/metta_types.pl
@@ -1,2 +1,1156 @@
+
+mnotrace(G):- once(G).
+
+is_decl_type(ST):- metta_type(_,_,Type),sub_sterm(T,Type),T=@=ST, \+ nontype(ST).
+is_decl_type([ST|_]):- !, atom(ST),is_decl_type_l(ST).
+is_decl_type(ST):- \+ atom(ST),!,fail.
+is_decl_type('%Undefined%'). is_decl_type('Number').
+is_decl_type('String'). is_decl_type('Bool').
+is_decl_type('Type'). is_decl_type('Symbol').
+is_decl_type('Expression').
+is_decl_type('Any'). is_decl_type('Atom').
+is_decl_type(Type):- is_decl_type_l(Type).
+is_decl_type_l('StateMonad'). is_decl_type_l('List').
+
+
+last_type(List,Type):- is_list(List),last(List,Type),is_type(Type).
+last_type(Type,Type):- is_type(Type),!.
+
+is_type(Type):- nontype(Type),!,fail.
+is_type(Type):- is_decl_type(Type).
+is_type(Type):- atom(Type).
+
+nontype(Type):- var(Type),!.
+nontype('->').
+nontype(N):- number(N).
+
+needs_eval(EvalMe):- is_list(EvalMe),!.
+
+
+args_violation(_Dpth,_Slf,Args,List):- ( \+ iz_conz(Args); \+ iz_conz(List)), !, fail.
+args_violation(Depth,Self,[A|Args],[L|List]):- once(arg_violation(Depth,Self,A,L) ; args_violation(Depth,Self,Args,List)).
+arg_violation(Depth,Self,A,L):- \+ (get_type0(Depth,Self,A,T), \+ type_violation(T,L)).
+%arg_violation(Depth,Self,A,_):- get_type(Depth,Self,A,_),!.
+
+type_violation(T,L):- \+ \+ (is_nonspecific_type(T);is_nonspecific_type(L)),!,fail.
+type_violation(T,L):- T\=L.
+
+
+not_arg_violation(Depth,Self,Arg,Type):-
+ \+ arg_violation(Depth,Self,Arg,Type),
+ arg_conform(Depth,Self,Arg,Type).
+
+
+args_conform(_Dpth,_Slf,Args,List):- ( \+ iz_conz(Args); \+ iz_conz(List)), !.
+args_conform(Depth,Self,[A|Args],[L|List]):- arg_conform(Depth,Self,A,L) , args_conform(Depth,Self,Args,List).
+arg_conform(Depth,Self,A,L):- get_type(Depth,Self,A,T), type_conform(T,L),!.
+arg_conform(_Dpth,_Slf,_,_).
+%arg_conform(Depth,Self,A,_):- get_type(Depth,Self,A,_),!.
+
+type_conform(T,L):- T=L,!.
+type_conform(T,L):- \+ \+ (is_nonspecific_type(T);is_nonspecific_type(L)),!.
+
+is_nonspecific_type(Var):- var(Var),!.
+is_nonspecific_type('%Undefined%').
+is_nonspecific_type([]).
+is_nonspecific_type('Atom').
+is_nonspecific_type('Any').
+
+%get_type(Depth,Self,Val,Type):- get_type01(Depth,Self,Val,Type).
+get_type(Depth,Self,Val,TypeO):- no_repeats(TypeT,(get_type9(Depth,Self,Val,Type),TypeT=Type)),Type=TypeO.
+
+get_type9(_Dpth,_Slf,Expr,'hyperon::space::DynSpace'):- is_dynaspace(Expr),!.
+get_type9(Depth,Self,Val,Type):- get_type0(Depth,Self,Val,Type).
+get_type9(Depth,Self,Val,Type):- get_type1(Depth,Self,Val,Type), ground(Type),Type\==[], Type\==Val,!.
+get_type9(Depth,Self,Val,Type):- get_type2(Depth,Self,Val,Type), ( is_list(Type)->! ; true).
+get_type9(_Dpth,_Slf,_Vl,[]).
+
+get_type2(Depth,_Slf,Type,Type):- Depth<1,!.
+%get_type(Depth,Self,Val,Type):- is_debugging(eval), !,
+% ftrace(get_type0(Depth,Self,Val,Type)).
+get_type2(Depth,Self,Val,Type):- get_type0(Depth,Self,Val,Type).
+get_type2(Depth,Self,Val,Type):- get_type1(Depth,Self,Val,Type).
+
+
+is_space_type(Space,is_asserted_space):- was_asserted_space(Space),!.
+is_space_type(Space,Test):- no_repeats(Test,space_type_method(Test,_,_)),call(Test,Space),!.
+
+is_state_type(State,Test):- no_repeats(Test,state_type_method(Test,_,_)),call(Test,State),!.
+
+%is_dynaspace(Expr):- \+ is_list(Expr), callable(Expr), is_space_type(Expr,_).
+is_dynaspace(S):- var(S),!,fail.
+is_dynaspace(S):- was_asserted_space(S).
+is_dynaspace(S):- py_named_space(S).
+is_dynaspace(S):- typed_list(S,'hyperon::space::DynSpace',_).
+% notrace( is_space_type(Expr,_)),!.
+get_type0(_Dpth,_Slf,Expr,'hyperon::space::DynSpace'):- is_dynaspace(Expr),!.
+get_type0(Depth,Self,Expr,['StateMonad',Type]):- notrace( is_valid_nb_state(Expr)),!, 'get-state'(Expr,Val),!,
+ ((state_decltype(Expr,Type),nonvar(Type)); (Depth2 is Depth-1, get_type(Depth2,Self,Val,Type))).
+get_type0(Depth,Self,Val,Type):- \+ compound(Val),!,get_type01(Depth,Self,Val,Type),!.
+get_type0(Depth,Self,Val,Type):- get_type03(Depth,Self,Val,Type),!.
+
+typed_list(Cmpd,Type,List):- compound(Cmpd), Cmpd\=[_|_], compound_name_arguments(Cmpd,Type,[List|_]),is_list(List).
+/*
+(: Left
+ (-> %Undefined% Either))
+
+(: (Left %Undefined%) Either)
+
+*/
+get_type01(_Dpth,_Slf,Var,'%Undefined%'):- var(Var),!.
+get_type01(_Dpth,_Slf, [],'%Undefined%'):- !.
+get_type01(_Dpth,_Slf,Val,'Number'):- number(Val).
+get_type01(_Dpth,_Slf,Val,'Integer'):- integer(Val).
+get_type01(_Dpth,_Slf,Val,'Decimal'):- float(Val).
+get_type01(_Dpth,_Slf,Val,'Rational'):- rational(Val).
+get_type01(_Dpth,_Slf,Val,'Bool'):- (Val=='False';Val=='True'),!.
+get_type01(_Dpth,_Slf,Val,Type):- string(Val),!,(Type='String';Type='Symbol').
+get_type01(_Dpth,_Slf,Expr,_):- \+ atom(Expr),!,fail.
+get_type01(_Dpth,Self,Op,Type):- metta_type(Self,Op,Type).
+get_type01(_Dpth,_Slf,Val,Type):- is_decl_type(Val),(Type=Val;Type='Type').
+get_type01(_Dpth,_Slf,Val,Type):- atomic_list_concat([Type,_|_],'@',Val).
+get_type01(_Dpth,_Slf,Val,Type):- atomic_list_concat([Type,_|_],':',Val).
+get_type01(Depth,Self,Op,Type):- Depth2 is Depth-1, eval_args(Depth2,Self,Op,Val),Op\=@=Val,!, get_type(Depth2,Self,Val,Type).
+%get_type01(_Dpth,_Slf,Expr,'hyperon::space::DynSpace'):- \+ is_list(Expr), callable(Expr), is_space_type(Expr,_).
+get_type01(_Dpth,_Slf,_Val,'String').
+get_type01(_Dpth,_Slf,_Val,'Symbol').
+
+
+
+get_type02(_Dpth,Self,Expr,Type):- metta_type(Self,TExpr,Type), TExpr == Expr.
+get_type02(_Dpth,Self,Expr,Type):- metta_type(Self,TExpr,Type), TExpr =@= Expr.
+get_type02(Depth,Self,[Op|Expr],Type):- maplist(get_type(Depth,Self),Expr,Types),
+ metta_type(Self,[Op|Types],Type).
+
+
+get_type03(Depth,Self,[[Op|Args]|Arg],Type):- symbol(Op),
+ get_type03(Depth,Self,[Op|Args],Type1),
+ get_type(Depth,Self,Arg,ArgType),
+ ignore(sub_var(ArgType,Type1)->true;(sub_term(ST,Type1),var(ST),ST=ArgType)),
+ last(Type1,Type).
+
+get_type03(_Dpth,_Slf,Cmpd,Type):-typed_list(Cmpd,Type,_List).
+get_type03(Depth,Self,[Op|Args],Type):- symbol(Op),
+ get_operator_typedef(Self,Op,Params,RetType),
+ % Fills in type variables when possible
+ ignore(args_conform(Depth,Self,Args,Params)),
+ % unitests: arg violations should return ()
+ (\+ args_violation(Depth,Self,Args,Params) -> Type=RetType ; (Type=[],!)).
+
+
+get_type03(Depth,Self,Expr,Type):- get_type02(Depth,Self,Expr,Type).
+
+get_type03(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),Depth2 is Depth-1,
+ eval_args(Depth2,Self,EvalMe,Val),
+ \+ needs_eval(Val),!,
+ get_type(Depth2,Self,Val,Type).
+
+get_type03(Depth,Self,Expr,Type):- Depth2 is Depth-1,
+ eval_args(Depth2, Self,Expr,Val), Expr\=@=Val,!,
+ get_type(Depth2,Self,Val,Type).
+
+get_type03(_Dpth,_Slf,Val,Type):- is_decl_type(Val),(Type=Val;Type='Type').
+
+get_type03(_Dpth,_Slf,Expr,'Expression'):- is_list(Expr),!.
+
+get_type03(Depth,Self,List,Types):- List\==[], is_list(List),
+ Depth2 is Depth-1,maplist(get_type(Depth2,Self),List,Types).
+
+
+get_type03(_Dpth,_Slf,Cmpd,Type):- compound(Cmpd),!, \+ ground(Cmpd),!,Type=[].
+
+%get_type0(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,Type,['->'|List]).
+%get_type(Depth,Self,Op,Type):- nonvar(Op),metta_type(Self,Op,Type2),Depth2 is Depth-1,get_type(Depth2,Self,Type2,Type).
+%get_type(Depth,Self,Op,Type):- Depth>0,nonvar(Op),metta_type(Self,Type,Op),!. %,!,last_element(List,Type).
+%get_type(Depth,Self,[T|List],['List',Type]):- Depth2 is Depth-1, is_list(List),get_type(Depth2,Self,T,Type),!,
+% forall((member(Ele,List),nonvar(Ele)),get_type(Depth2,Self,Ele,Type)),!.
+%get_type(Depth,_Slf,Cmpd,Type):- compound(Cmpd), functor(Cmpd,Type,1),!.
+%get_type0(_Dpth,_Slf,_,'%Undefined%'):- fail.
+
+state_decltype(Expr,Type):- functor(Expr,_,A),arg(A,Expr,Type),once(var(Type);is_decl_type(Type)).
+
+
+get_type1(_Dpth,_Slf,Var,'%Undefined%'):- var(Var),!.
+get_type1(_Dpth,_Slf,Val,'Number'):- number(Val),!.
+get_type1(Depth,Self,Expr,['StateMonad',Type]):- is_valid_nb_state(Expr),'get-state'(Expr,Val),!,
+ get_type1(Depth,Self,Val,Type).
+
+
+get_type1(Depth,Self,EvalMe,Type):- needs_eval(EvalMe),
+ eval_args(Depth,Self,EvalMe,Val), \+ needs_eval(Val),!,
+ get_type1(Depth,Self,Val,Type).
+
+get_type1(_Dpth,Self,[Fn|_],Type):- symbol(Fn),metta_type(Self,Fn,List),last_element(List,Type), nonvar(Type),
+ is_type(Type).
+get_type1(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,List,LType),last_element(LType,Type), nonvar(Type),
+ is_type(Type).
+
+get_type1(Depth,_Slf,Type,Type):- Depth<1,!.
+get_type1(_Dpth,Self,List,Type):- is_list(List),metta_type(Self,Type,['->'|List]).
+get_type1(Depth,Self,List,Types):- List\==[], is_list(List),Depth2 is Depth-1,maplist(get_type1(Depth2,Self),List,Types).
+get_type1(_Dpth,Self,Fn,Type):- symbol(Fn),metta_type(Self,Fn,Type),!.
+%get_type1(Depth,Self,Fn,Type):- nonvar(Fn),metta_type(Self,Fn,Type2),Depth2 is Depth-1,get_type1(Depth2,Self,Type2,Type).
+%get_type1(Depth,Self,Fn,Type):- Depth>0,nonvar(Fn),metta_type(Self,Type,Fn),!. %,!,last_element(List,Type).
+
+get_type1(Depth,Self,Expr,Type):-Depth2 is Depth-1,
+ eval_args(Depth2,Self,Expr,Val),
+ Expr\=@=Val,get_type1(Depth2,Self,Val,Type).
+
+
+get_type1(_Dpth,_Slf,Val,'String'):- string(Val),!.
+get_type1(_Dpth,_Slf,Val,Type):- is_decl_type(Val),Type=Val.
+get_type1(_Dpth,_Slf,Val,'Bool'):- (Val=='False';Val=='True'),!.
+get_type1(_Dpth,_Slf,Val,'Symbol'):- symbol(Val).
+%get_type1(Depth,Self,[T|List],['List',Type]):- Depth2 is Depth-1, is_list(List),get_type1(Depth2,Self,T,Type),!,
+% forall((member(Ele,List),nonvar(Ele)),get_type1(Depth2,Self,Ele,Type)),!.
+%get_type1(Depth,_Slf,Cmpd,Type):- compound(Cmpd), functor(Cmpd,Type,1),!.
+get_type1(_Dpth,_Slf,Cmpd,Type):- \+ ground(Cmpd),!,Type=[].
+get_type1(_Dpth,_Slf,_,'%Undefined%'):- fail.
+%get_type1(Depth,Self,Val,Type):- Depth2 is Depth-1, get_type0(Depth2,Self,Val,Type).
+
+
+
+as_prolog(_Dpth,_Slf,I,O):- \+ iz_conz(I),!,I=O.
+as_prolog(Depth,Self,[H|T],O):- H=='::',!,as_prolog(Depth,Self,T,O).
+as_prolog(Depth,Self,[H|T],[HH|TT]):- as_prolog(Depth,Self,H,HH),as_prolog(Depth,Self,T,TT).
+
+
+
+adjust_args(_Dpth,Self,F,X,X):- (is_special_op(Self,F); \+ iz_conz(X)),!.
+adjust_args(Depth,Self,Op,X,Y):-
+ get_operator_typedef(Self,Op,Params,RetType),
+ try_adjust_arg_types(RetType,Depth,Self,Params,X,Y).
+
+try_adjust_arg_types(RetType,Depth,Self,Params,X,Y):-
+ as_prolog(Depth,Self,X,M),
+ args_conform(Depth,Self,M,Params),!,
+ set_type(Depth,Self,Y,RetType),
+ into_typed_args(Depth,Self,Params,M,Y).
+%adjust_args(Depth,Self,_,X,Y):- is_list(X), !, maplist(eval_args(Depth,Self),X,Y).
+%adjust_args(Depth,Self,_,X,Y):- is_list(X), !, maplist(as_prolog(Depth,Self),X,Y),!.
+adjust_args(Depth,Self,_,X,Y):- as_prolog(Depth,Self,X,Y).
+
+into_typed_args(_Dpth,_Slf,T,M,Y):- (\+ iz_conz(T); \+ iz_conz(M)),!, M=Y.
+into_typed_args(Depth,Self,[T|TT],[M|MM],[Y|YY]):-
+ into_typed_arg(Depth,Self,T,M,Y),
+ into_typed_args(Depth,Self,TT,MM,YY).
+
+into_typed_arg(_Dpth,Self,T,M,Y):- var(M),!,put_attr(M,metta_type,Self=T),put_attr(Y,metta_type,Self=T),Y=M.
+into_typed_arg(Depth,Self,T,M,Y):- into_typed_arg0(Depth,Self,T,M,Y)*->true;M=Y.
+
+into_typed_arg0(Depth,Self,T,M,Y):- var(T), !, get_type(Depth,Self,M,T),
+ (wants_eval_kind(T)->eval_args(Depth,Self,M,Y);Y=M).
+
+into_typed_arg0(Depth,Self,T,M,Y):- is_pro_eval_kind(T),!,eval_args(Depth,Self,M,Y).
+into_typed_arg0(Depth,Self,T,M,Y):- ground(M),!, \+ arg_violation(Depth,Self,M,T),Y=M.
+into_typed_arg0(_Dpth,_Slf,T,M,Y):- is_non_eval_kind(T),!,M=Y.
+into_typed_arg0(Depth,Self,_,M,Y):- eval_args(Depth,Self,M,Y).
+
+set_type(Depth,Self,Var,Type):- nop(set_type(Depth,Self,Var,Type)),!.
+set_type(Depth,Self,Var,Type):- get_type(Depth,Self,Var,Was)
+ *->Was=Type
+ ; if_t(var(Var),put_attr(Var,metta_type,Self=Type)).
+
+metta_type:attr_unify_hook(Self=Type,NewValue):-
+ get_type(20,Self,NewValue,Was),
+ can_assign(Was,Type).
+
+can_assign(Was,Type):- Was=Type,!.
+can_assign(Was,Type):- (is_nonspecific_type(Was);is_nonspecific_type(Type)),!.
+can_assign(_Ws,_Typ).
+
+is_non_eval_kind(Type):- is_nonspecific_type(Type),!.
+is_non_eval_kind('Atom').
+
+is_pro_eval_kind('Number').
+is_pro_eval_kind('Symbol').
+is_pro_eval_kind('Bool').
+
+is_feo_f('Cons').
+
+is_seo_f('{...}').
+is_seo_f('[...]').
+is_seo_f('{}').
+is_seo_f('[]').
+is_seo_f('StateMonad').
+is_seo_f('State').
+is_seo_f('Event').
+is_seo_f('Concept').
+is_seo_f(N):- number(N),!.
+
+%is_user_defined_goal(Self,[H|_]):- is_user_defined_head(Self,H).
+
+is_user_defined_head(Other,H):- mnotrace(is_user_defined_head0(Other,H)).
+is_user_defined_head0(Other,[H|_]):- !, nonvar(H),!, is_user_defined_head_f(Other,H).
+is_user_defined_head0(Other,H):- callable(H),!,functor(H,F,_), is_user_defined_head_f(Other,F).
+is_user_defined_head0(Other,H):- is_user_defined_head_f(Other,H).
+
+is_user_defined_head_f(Other,H):- is_user_defined_head_f1(Other,H).
+is_user_defined_head_f(Other,H):- is_user_defined_head_f1(Other,[H|_]).
+
+%is_user_defined_head_f1(Other,H):- metta_type(Other,H,_).
+%s_user_defined_head_f1(Other,H):- metta_atom(Other,[H|_]).
+is_user_defined_head_f1(Other,H):- metta_defn(Other,[H|_],_).
+%is_user_defined_head_f(_,H):- is_metta_builtin(H).
+
+
+
+is_special_op(Op):- current_self(Self),is_special_op(Self,Op).
+
+is_special_op(_Slf,F):- \+ atom(F), \+ var(F), !, fail.
+is_special_op(Self,Op):- get_operator_typedef(Self,Op,Params,_RetType),
+ maplist(is_non_eval_kind,Params).
+is_special_op(_Slf,Op):- is_special_builtin(Op).
+
+is_syspred(H,Len,Pred):- notrace(is_syspred0(H,Len,Pred)).
+is_syspred0(H,_Ln,_Prd):- \+ atom(H),!,fail.
+is_syspred0(H,_Ln,_Prd):- upcase_atom(H,U),downcase_atom(H,U),!,fail.
+is_syspred0(H,Len,Pred):- current_predicate(H/Len),!,Pred=H.
+is_syspred0(H,Len,Pred):- atom_concat(Mid,'!',H), H\==Mid, is_syspred0(Mid,Len,Pred),!.
+is_syspred0(H,Len,Pred):- into_underscores(H,Mid), H\==Mid, is_syspred0(Mid,Len,Pred),!.
+%is_function(F):- atom(F).
+is_metta_data_functor(_Othr,H):- clause(is_data_functor(H),_).
+is_metta_data_functor(Other,H):- H\=='Right', H\=='Something',
+ % metta_type(Other,H,_), % fail,
+ \+ metta_atom(Other,[H|_]),
+ \+ metta_defn(Other,[H|_],_),
+ \+ is_metta_builtin(H),
+ \+ is_comp_op(H,_),
+ \+ is_math_op(H,_,_).
+
+
+get_operator_typedef(Self,Op,Params,RetType):-
+ get_operator_typedef1(Self,Op,Params,RetType)*->true;
+ get_operator_typedef2(Self,Op,Params,RetType).
+get_operator_typedef1(Self,Op,Params,RetType):-
+ metta_type(Self,Op,['->'|List]),
+ append(Params,[RetType],List).
+get_operator_typedef2(Self,Op,Params,RetType):-
+ nop(wdmsg(missing(get_operator_typedef2(Self,Op,Params,RetType)))),!,fail.
+
+is_metta_data_functor(F):-
+ current_self(Self),is_metta_data_functor(Self,F).
+
+
+is_special_builtin('case').
+is_special_builtin(':').
+
+%is_special_builtin('=').
+is_special_builtin('->').
+is_special_builtin('bind!').
+%is_special_builtin('new-space').
+is_special_builtin('let').
+is_special_builtin('let*').
+is_special_builtin('if').
+is_special_builtin('rtrace').
+is_special_builtin('or').
+is_special_builtin('and').
+is_special_builtin('not').
+is_special_builtin('match').
+is_special_builtin('call').
+is_special_builtin('let').
+is_special_builtin('let*').
+is_special_builtin('nop').
+is_special_builtin('assertEqual').
+is_special_builtin('assertEqualToResult').
+is_special_builtin('collapse').
+is_special_builtin('superpose').
+%is_special_builtin('==').
+
+is_metta_builtin(Special):- is_special_builtin(Special).
+
+is_metta_builtin('==').
+is_metta_builtin(F):- once(atom(F);var(F)), current_op(_,yfx,F).
+is_metta_builtin('println!').
+is_metta_builtin('transfer!').
+is_metta_builtin('compile!').
+is_metta_builtin('+').
+is_metta_builtin('-').
+is_metta_builtin('*').
+is_metta_builtin('/').
+is_metta_builtin('%').
+is_metta_builtin('==').
+is_metta_builtin('<').
+is_metta_builtin('>').
+is_metta_builtin('all').
+is_metta_builtin('import!').
+is_metta_builtin('pragma!').
+
+
+% Comparison Operators in Prolog
+% is_comp_op('=', 2). % Unification
+is_comp_op('\\=', 2). % Not unifiable
+is_comp_op('==', 2). % Strict equality
+is_comp_op('\\==', 2). % Strict inequality
+is_comp_op('@<', 2). % Term is before
+is_comp_op('@=<', 2). % Term is before or equal
+is_comp_op('@>', 2). % Term is after
+is_comp_op('@>=', 2). % Term is after or equal
+is_comp_op('=<', 2). % Less than or equal
+is_comp_op('<', 2). % Less than
+is_comp_op('>=', 2). % Greater than or equal
+is_comp_op('>', 2). % Greater than
+is_comp_op('is', 2). % Arithmetic equality
+is_comp_op('=:=', 2). % Arithmetic exact equality
+is_comp_op('=\\=', 2). % Arithmetic inequality
+
+% Arithmetic Operations
+is_math_op('*', 2, exists). % Multiplication
+is_math_op('**', 2, exists). % Exponentiation
+is_math_op('+', 1, exists). % Unary Plus
+is_math_op('+', 2, exists). % Addition
+is_math_op('-', 1, exists). % Unary Minus
+is_math_op('-', 2, exists). % Subtraction
+is_math_op('.', 2, exists). % Array Indexing or Member Access (Depends on Context)
+is_math_op('/', 2, exists). % Division
+is_math_op('//', 2, exists). % Floor Division
+is_math_op('///', 2, exists). % Alternative Division Operator (Language Specific)
+is_math_op('/\\', 2, exists). % Bitwise AND
+is_math_op('<<', 2, exists). % Bitwise Left Shift
+is_math_op('>>', 2, exists). % Bitwise Right Shift
+is_math_op('\\', 1, exists). % Bitwise NOT
+is_math_op('\\/', 2, exists). % Bitwise OR
+is_math_op('^', 2, exists). % Bitwise XOR
+is_math_op('abs', 1, exists). % Absolute Value
+is_math_op('acos', 1, exists). % Arc Cosine
+is_math_op('acosh', 1, exists). % Hyperbolic Arc Cosine
+is_math_op('asin', 1, exists). % Arc Sine
+is_math_op('asinh', 1, exists). % Hyperbolic Arc Sine
+is_math_op('atan', 1, exists). % Arc Tangent
+is_math_op('atan2', 2, exists). % Two-Argument Arc Tangent
+is_math_op('atanh', 1, exists). % Hyperbolic Arc Tangent
+is_math_op('cbrt', 1, exists). % Cube Root
+is_math_op('ceil', 1, exists). % Ceiling Function
+is_math_op('ceiling', 1, exists). % Ceiling Value
+is_math_op('cmpr', 2, exists). % Compare Two Values (Language Specific)
+is_math_op('copysign', 2, exists). % Copy the Sign of a Number
+is_math_op('cos', 1, exists). % Cosine Function
+is_math_op('cosh', 1, exists). % Hyperbolic Cosine
+is_math_op('cputime', 0, exists). % CPU Time
+is_math_op('degrees', 1, exists). % Convert Radians to Degrees
+is_math_op('denominator', 1, exists). % Get Denominator of Rational Number
+is_math_op('div', 2, exists). % Integer Division
+is_math_op('e', 0, exists). % Euler's Number
+is_math_op('epsilon', 0, exists). % Machine Epsilon
+is_math_op('erf', 1, exists). % Error Function
+is_math_op('erfc', 1, exists). % Complementary Error Function
+is_math_op('eval', 1, exists). % Evaluate Expression
+is_math_op('exp', 1, exists). % Exponential Function
+is_math_op('expm1', 1, exists). % exp(x) - 1
+is_math_op('fabs', 1, exists). % Absolute Value (Floating-Point)
+is_math_op('float', 1, exists). % Convert Rational to Float
+is_math_op('float_fractional_part', 1, exists). % Fractional Part of Float
+is_math_op('float_integer_part', 1, exists). % Integer Part of Float
+is_math_op('floor', 1, exists). % Floor Value
+is_math_op('fmod', 2, exists). % Floating-Point Modulo Operation
+is_math_op('frexp', 2, exists). % Get Mantissa and Exponent
+is_math_op('fsum', 1, exists). % Accurate Floating Point Sum
+is_math_op('gamma', 1, exists). % Gamma Function
+is_math_op('gcd', 2, exists). % Greatest Common Divisor
+is_math_op('getbit', 2, exists). % Get Bit at Position
+is_math_op('hypot', 2, exists). % Euclidean Norm, Square Root of Sum of Squares
+is_math_op('inf', 0, exists). % Positive Infinity
+is_math_op('integer', 1, exists). % Convert Float to Integer
+is_math_op('isinf', 1, exists). % Check for Infinity
+is_math_op('isnan', 1, exists). % Check for Not a Number
+is_math_op('lcm', 2, exists). % Least Common Multiple
+is_math_op('ldexp', 2, exists). % Load Exponent of a Floating Point Number
+is_math_op('lgamma', 1, exists). % Log Gamma
+is_math_op('log', 1, exists). % Logarithm Base e
+is_math_op('log10', 1, exists). % Base 10 Logarithm
+is_math_op('log1p', 1, exists). % log(1 + x)
+is_math_op('log2', 1, exists). % Base 2 Logarithm
+is_math_op('lsb', 1, exists). % Least Significant Bit
+is_math_op('max', 2, exists). % Maximum of Two Values
+is_math_op('maxr', 2, exists). % Maximum Rational Number (Language Specific)
+is_math_op('min', 2, exists). % Minimum of Two Values
+is_math_op('minr', 2, exists). % Minimum Rational Number (Language Specific)
+is_math_op('mod', 2, exists). % Modulo Operation
+is_math_op('modf', 2, exists). % Return Fractional and Integer Parts
+is_math_op('msb', 1, exists). % Most Significant Bit
+is_math_op('nan', 0, exists). % Not a Number
+is_math_op('nexttoward', 2, exists). % Next Representable Floating-Point Value
+is_math_op('numerator', 1, exists). % Get Numerator of Rational Number
+is_math_op('pi', 0, exists). % Pi
+is_math_op('popcount', 1, exists). % Count of Set Bits
+is_math_op('pow', 2, exists). % Exponentiation
+is_math_op('powm', 3, exists). % Modulo Exponentiation
+is_math_op('radians', 1, exists). % Convert Degrees to Radians
+is_math_op('remainder', 2, exists). % Floating-Point Remainder
+is_math_op('remquo', 3, exists). % Remainder and Part of Quotient
+is_math_op('round', 1, exists). % Round to Nearest Integer
+is_math_op('roundeven', 1, exists). % Round to Nearest Even Integer
+is_math_op('setbit', 2, exists). % Set Bit at Position
+is_math_op('signbit', 1, exists). % Sign Bit of Number
+is_math_op('sin', 1, exists). % Sine Function
+is_math_op('sinh', 1, exists). % Hyperbolic Sine
+is_math_op('sqrt', 1, exists). % Square Root
+is_math_op('tan', 1, exists). % Tangent Function
+is_math_op('tanh', 1, exists). % Hyperbolic Tangent
+is_math_op('testbit', 2, exists). % Test Bit at Position
+is_math_op('trunc', 1, exists). % Truncate Decimal to Integer
+is_math_op('ulogb', 1, exists). % Unbiased Exponent of a Floating-Point Value
+is_math_op('xor', 2, exists). % Exclusive OR
+is_math_op('zerop', 1, exists). % Test for Zero
+
+
+
+end_of_file.
+
+
+
+% # 1. Length of a List
+% % Normal Recursive
+% prolog
+len([], 0).
+len([_|T], N) :-
+ len(T, X),
+ N is X + 1.
+%
+
+% % With Accumulator
+% prolog
+len_acc(L, N) :-
+ len_acc(L, 0, N).
+
+len_acc([], Acc, Acc).
+len_acc([_|T], Acc, N) :-
+ NewAcc is Acc + 1,
+ len_acc(T, NewAcc, N).
+%
+
+% # 2. Sum of a List
+% % Normal Recursive
+% prolog
+sum([], 0).
+sum([H|T], S) :-
+ sum(T, X),
+ S is X + H.
+%
+
+% % With Accumulator
+% prolog
+sum_acc(L, S) :-
+ sum_acc(L, 0, S).
+
+sum_acc([], Acc, Acc).
+sum_acc([H|T], Acc, S) :-
+ NewAcc is Acc + H,
+ sum_acc(T, NewAcc, S).
+%
+
+% # 3. Factorial
+% % Normal Recursive
+% prolog
+factorial(0, 1).
+factorial(N, F) :-
+ N > 0,
+ X is N - 1,
+ factorial(X, Y),
+ F is N * Y.
+%
+
+% % With Accumulator
+% prolog
+factorial_acc(N, F) :-
+ factorial_acc(N, 1, F).
+
+factorial_acc(0, Acc, Acc).
+factorial_acc(N, Acc, F) :-
+ N > 0,
+ NewAcc is Acc * N,
+ NewN is N - 1,
+ factorial_acc(NewN, NewAcc, F).
+%
+
+% # 4. Reverse List
+% % Normal Recursive
+% prolog
+reverse_list([], []).
+reverse_list([H|T], R) :-
+ reverse_list(T, RevT),
+ append(RevT, [H], R).
+%
+
+% % With Accumulator
+% prolog
+reverse_list_acc(L, R) :-
+ reverse_list_acc(L, [], R).
+
+reverse_list_acc([], Acc, Acc).
+reverse_list_acc([H|T], Acc, R) :-
+ reverse_list_acc(T, [H|Acc], R).
+%
+
+% # 5. Fibonacci
+% % Normal Recursive
+% prolog
+fibonacci(0, 0).
+fibonacci(1, 1).
+fibonacci(N, F) :-
+ N > 1,
+ N1 is N - 1,
+ N2 is N - 2,
+ fibonacci(N1, F1),
+ fibonacci(N2, F2),
+ F is F1 + F2.
+%
+
+% % With Accumulator
+% prolog
+fibonacci_acc(N, F) :-
+ fibonacci_acc(N, 0, 1, F).
+
+fibonacci_acc(0, A, _, A).
+fibonacci_acc(N, A, B, F) :-
+ N > 0,
+ NewN is N - 1,
+ NewB is A + B,
+ fibonacci_acc(NewN, B, NewB, F).
+%
+
+
+
+% 6. Find an Element in a List
+% # Normal Recursive
+% prolog
+element_in_list(X, [X|_]).
+element_in_list(X, [_|T]) :- element_in_list(X, T).
+%
+
+% # With Accumulator
+% prolog
+element_in_list_acc(X, L) :- element_in_list_acc(X, L, false).
+
+element_in_list_acc(X, [], Acc) :- Acc.
+element_in_list_acc(X, [X|_], _) :- true.
+element_in_list_acc(X, [_|T], Acc) :- element_in_list_acc(X, T, Acc).
+%
+
+% 7. Check if a List is a Palindrome
+% # Normal Recursive
+% prolog
+is_palindrome(L) :- reverse(L, L).
+%
+
+% # With Accumulator
+% prolog
+is_palindrome_acc(L) :- reverse_acc(L, [], L).
+
+reverse_acc([], Acc, Acc).
+reverse_acc([H|T], Acc, R) :- reverse_acc(T, [H|Acc], R).
+%
+
+% 8. Calculate the Product of All Elements in a List
+% # Normal Recursive
+% prolog
+product_list([], 1).
+product_list([H|T], P) :-
+ product_list(T, Temp),
+ P is H * Temp.
+%
+
+% # With Accumulator
+% prolog
+product_list_acc(L, P) :- product_list_acc(L, 1, P).
+
+product_list_acc([], Acc, Acc).
+product_list_acc([H|T], Acc, P) :-
+ NewAcc is Acc * H,
+ product_list_acc(T, NewAcc, P).
+%
+
+% 9. Find the Nth Element of a List
+% # Normal Recursive
+% prolog
+nth_element(1, [H|_], H).
+nth_element(N, [_|T], X) :-
+ N > 1,
+ M is N - 1,
+ nth_element(M, T, X).
+%
+
+% # With Accumulator
+% prolog
+nth_element_acc(N, L, X) :- nth_element_acc(N, L, 1, X).
+
+nth_element_acc(N, [H|_], N, H).
+nth_element_acc(N, [_|T], Acc, X) :-
+ NewAcc is Acc + 1,
+ nth_element_acc(N, T, NewAcc, X).
+%
+
+% 10. Count the Occurrences of an Element in a List
+% # Normal Recursive
+% prolog
+count_occurrences(_, [], 0).
+count_occurrences(X, [X|T], N) :-
+ count_occurrences(X, T, M),
+ N is M + 1.
+count_occurrences(X, [Y|T], N) :-
+ X \= Y,
+ count_occurrences(X, T, N).
+%
+
+% # With Accumulator
+% prolog
+count_occurrences_acc(X, L, N) :- count_occurrences_acc(X, L, 0, N).
+
+count_occurrences_acc(_, [], Acc, Acc).
+count_occurrences_acc(X, [X|T], Acc, N) :-
+ NewAcc is Acc + 1,
+ count_occurrences_acc(X, T, NewAcc, N).
+count_occurrences_acc(X, [Y|T], Acc, N) :-
+ X \= Y,
+ count_occurrences_acc(X, T, Acc, N).
+%
+
+% 11. Calculate the Greatest Common Divisor of Two Numbers
+% # Normal Recursive
+% prolog
+gcd(A, 0, A) :- A > 0.
+gcd(A, B, GCD) :-
+ B > 0,
+ R is A mod B,
+ gcd(B, R, GCD).
+%
+
+% # With Accumulator
+% prolog
+gcd_acc(A, B, GCD) :- gcd_acc(A, B, 1, GCD).
+
+gcd_acc(A, 0, Acc, Acc) :- A > 0.
+gcd_acc(A, B, Acc, GCD) :-
+ B > 0,
+ R is A mod B,
+ NewAcc is B * Acc,
+ gcd_acc(B, R, NewAcc, GCD).
+%
+
+% 12. Check if a Number is Prime
+% # Normal Recursive
+% prolog
+is_prime(2).
+is_prime(N) :-
+ N > 2,
+ \+ (between(2, sqrt(N), X), N mod X =:= 0).
+%
+
+% # With Accumulator
+% prolog
+is_prime_acc(N) :- is_prime_acc(N, 2).
+
+is_prime_acc(2, 2).
+is_prime_acc(N, Acc) :-
+ N > 2,
+ (
+ (Acc * Acc > N, !);
+ (N mod Acc =\= 0, NewAcc is Acc + 1, is_prime_acc(N, NewAcc))
+ ).
+%
+
+% 13. Merge Two Sorted Lists into a Sorted List
+% # Normal Recursive
+% prolog
+merge_sorted([], L, L).
+merge_sorted(L, [], L).
+merge_sorted([H1|T1], [H2|T2], [H1|M]) :-
+ H1 =< H2,
+ merge_sorted(T1, [H2|T2], M).
+merge_sorted([H1|T1], [H2|T2], [H2|M]) :-
+ H1 > H2,
+ merge_sorted([H1|T1], T2, M).
+%
+
+% # With Accumulator
+% prolog
+merge_sorted_acc(L1, L2, L) :- merge_sorted_acc(L1, L2, [], L).
+
+merge_sorted_acc([], L, Acc, L) :- reverse(Acc, L), !.
+merge_sorted_acc(L, [], Acc, L) :- reverse(Acc, L), !.
+merge_sorted_acc([H1|T1], [H2|T2], Acc, [H|M]) :-
+ H1 =< H2,
+ merge_sorted_acc(T1, [H2|T2], [H1|Acc], M).
+merge_sorted_acc([H1|T1], [H2|T2], Acc, [H|M]) :-
+ H1 > H2,
+ merge_sorted_acc([H1|T1], T2, [H2|Acc], M).
+
+%
+
+% 14. Find the Last Element of a List
+% # Normal Recursive
+% prolog
+last_element([H], H).
+last_element([_|T], X) :- last_element(T, X).
+%
+
+% # With Accumulator
+% prolog
+last_element_acc([H|T], X) :- last_element_acc(T, H, X).
+
+last_element_acc([], Acc, Acc).
+last_element_acc([H|T], _, X) :- last_element_acc(T, H, X).
+%
+
+% 15. Remove Duplicate Elements from a List
+% # Normal Recursive
+% prolog
+remove_duplicates([], []).
+remove_duplicates([H|T], [H|T1]) :- \+ member(H, T), remove_duplicates(T, T1).
+remove_duplicates([_|T], T1) :- remove_duplicates(T, T1).
+%
+
+% # With Accumulator
+% prolog
+remove_duplicates_acc(L, R) :- remove_duplicates_acc(L, [], R).
+
+remove_duplicates_acc([], Acc, Acc).
+remove_duplicates_acc([H|T], Acc, R) :-
+ (member(H, Acc) -> remove_duplicates_acc(T, Acc, R);
+ remove_duplicates_acc(T, [H|Acc], R)).
+%
+
+% 16. Check if a Binary Tree is Balanced
+% # Normal Recursive
+% prolog
+is_balanced(null).
+is_balanced(tree(L, _, R)) :-
+ height(L, Hl),
+ height(R, Hr),
+ D is Hl - Hr,
+ abs(D) =< 1,
+ is_balanced(L),
+ is_balanced(R).
+%
+
+% # With Accumulator
+% prolog
+is_balanced_acc(T) :- is_balanced_acc(T, 0).
+
+is_balanced_acc(null, 0).
+is_balanced_acc(tree(L, _, R), H) :-
+ is_balanced_acc(L, Hl),
+ is_balanced_acc(R, Hr),
+ D is Hl - Hr,
+ abs(D) =< 1,
+ H is max(Hl, Hr) + 1.
+%
+
+% 17. Calculate the Height of a Binary Tree
+% # Normal Recursive
+% prolog
+height(null, 0).
+height(tree(L, _, R), H) :-
+ height(L, Hl),
+ height(R, Hr),
+ H is max(Hl, Hr) + 1.
+%
+
+% # With Accumulator
+% prolog
+height_acc(T, H) :- height_acc(T, 0, H).
+
+height_acc(null, Acc, Acc).
+height_acc(tree(L, _, R), Acc, H) :-
+ NewAcc is Acc + 1,
+ height_acc(L, NewAcc, Hl),
+ height_acc(R, NewAcc, Hr),
+ H is max(Hl, Hr).
+%
+
+% 18. Search for an Element in a Binary Search Tree
+% # Normal Recursive
+% prolog
+search_bst(tree(_, X, _), X).
+search_bst(tree(L, Y, _), X) :-
+ X < Y,
+ search_bst(L, X).
+search_bst(tree(_, Y, R), X) :-
+ X > Y,
+ search_bst(R, X).
+%
+
+% # With Accumulator
+% prolog
+% The accumulator is not very useful here, as the search path is already determined by the BST property.
+search_bst_acc(Tree, X) :- search_bst(Tree, X).
+%
+
+% 19. Insert an Element into a Binary Search Tree
+% # Normal Recursive
+% prolog
+insert_bst(null, X, tree(null, X, null)).
+insert_bst(tree(L, Y, R), X, tree(L1, Y, R)) :-
+ X < Y,
+ insert_bst(L, X, L1).
+insert_bst(tree(L, Y, R), X, tree(L, Y, R1)) :-
+ X > Y,
+ insert_bst(R, X, R1).
+%
+
+% # With Accumulator
+% prolog
+% The accumulator is not very useful here, as the insertion path is already determined by the BST property.
+insert_bst_acc(Tree, X, NewTree) :- insert_bst(Tree, X, NewTree).
+%
+
+% 20. Delete an Element from a Binary Search Tree
+% # Normal Recursive
+% prolog
+delete_bst(Tree, X, NewTree) :-
+ remove_bst(Tree, X, NewTree).
+
+remove_bst(tree(L, X, R), X, Merged) :- merge_trees(L, R, Merged), !.
+remove_bst(tree(L, Y, R), X, tree(L1, Y, R)) :-
+ X < Y,
+ remove_bst(L, X, L1).
+remove_bst(tree(L, Y, R), X, tree(L, Y, R1)) :-
+ X > Y,
+ remove_bst(R, X, R1).
+
+merge_trees(null, Tree, Tree).
+merge_trees(Tree, null, Tree).
+merge_trees(tree(L1, X, R1), tree(L2, Y, R2), tree(Merged, Y, R2)) :-
+ merge_trees(tree(L1, X, R1), L2, Merged).
+%
+
+% # With Accumulator
+% prolog
+% The accumulator is not very useful here, as the deletion path is already determined by the BST property.
+delete_bst_acc(Tree, X, NewTree) :- delete_bst(Tree, X, NewTree).
+%
+
+% 21. Find the Lowest Common Ancestor in a Binary Search Tree
+% # Normal Recursive
+% prolog
+lowest_common_ancestor(tree(_, Y, _), X, Z, Y) :-
+ X < Y, Z > Y;
+ X > Y, Z < Y.
+lowest_common_ancestor(tree(L, Y, _), X, Z, LCA) :-
+ X < Y, Z < Y,
+ lowest_common_ancestor(L, X, Z, LCA).
+lowest_common_ancestor(tree(_, Y, R), X, Z, LCA) :-
+ X > Y, Z > Y,
+
+
+ lowest_common_ancestor(R, X, Z, LCA).
+%
+
+% # With Accumulator
+% prolog
+% The accumulator is not very useful here, as the search path is already determined by the BST property.
+lowest_common_ancestor_acc(Tree, X, Z, LCA) :- lowest_common_ancestor(Tree, X, Z, LCA).
+%
+
+% 22. Check if a Graph is Cyclic
+% For graphs, it's better to represent them in a Prolog-friendly format, such as adjacency lists. I will use a representation where each node has a list of its neighbors.
+% # Normal Recursive
+% prolog
+is_cyclic(Graph) :-
+ member(Vertex-_, Graph),
+ dfs(Vertex, Graph, [Vertex], _), !.
+
+dfs(Vertex, Graph, Visited, [Vertex|Visited]) :-
+ member(Vertex-Neighbors, Graph),
+ member(Neighbor, Neighbors),
+ member(Neighbor, Visited), !.
+dfs(Vertex, Graph, Visited, FinalVisited) :-
+ member(Vertex-Neighbors, Graph),
+ member(Neighbor, Neighbors),
+ \+ member(Neighbor, Visited),
+ dfs(Neighbor, Graph, [Neighbor|Visited], FinalVisited).
+%
+
+% # With Accumulator
+% prolog
+% Due to the way depth-first search works, a typical accumulator wouldn't be very effective.
+% The visited list already acts like an accumulator.
+is_cyclic_acc(Graph) :- is_cyclic(Graph).
+%
+
+% 23. Perform a Depth-First Search on a Graph
+% # Normal Recursive
+% prolog
+dfs_graph(Vertex, Graph) :- dfs_vertex(Vertex, Graph, []).
+
+dfs_vertex(Vertex, _, Visited) :- member(Vertex, Visited), !.
+dfs_vertex(Vertex, Graph, Visited) :-
+ write(Vertex), nl,
+ member(Vertex-Neighbors, Graph),
+ dfs_neighbors(Neighbors, Graph, [Vertex|Visited]).
+
+dfs_neighbors([], _, _).
+dfs_neighbors([Neighbor|Neighbors], Graph, Visited) :-
+ dfs_vertex(Neighbor, Graph, Visited),
+ dfs_neighbors(Neighbors, Graph, Visited).
+%
+
+% # With Accumulator
+% prolog
+% The visited list acts as an accumulator.
+dfs_graph_acc(Vertex, Graph) :- dfs_graph(Vertex, Graph).
+%
+
+% 24. Perform a Breadth-First Search on a Graph
+% # Normal Recursive
+% prolog
+bfs_graph(Vertex, Graph) :-
+ bfs([Vertex], Graph, [Vertex]).
+
+bfs([], _, _).
+bfs([Vertex|Vertices], Graph, Visited) :-
+ write(Vertex), nl,
+ member(Vertex-Neighbors, Graph),
+ filter_unvisited(Neighbors, Visited, NewNeighbors, NewVisited),
+ append(Vertices, NewNeighbors, NewVertices),
+ bfs(NewVertices, Graph, NewVisited).
+
+filter_unvisited([], Visited, [], Visited).
+filter_unvisited([Neighbor|Neighbors], Visited, NewNeighbors, NewVisited) :-
+ (member(Neighbor, Visited) ->
+ filter_unvisited(Neighbors, Visited, NewNeighbors, NewVisited);
+ filter_unvisited(Neighbors, [Neighbor|Visited], NewNeighbors, [Neighbor|NewVisited])
+ ).
+%
+
+% # With Accumulator
+% prolog
+% The visited list acts as an accumulator.
+bfs_graph_acc(Vertex, Graph) :- bfs_graph(Vertex, Graph).
+%
+
+% 25. Check if a Graph is Connected
+% # Normal Recursive
+% prolog
+is_connected(Graph) :-
+ Graph = [Vertex-_|_],
+ dfs_graph(Vertex, Graph),
+ \+ (member(OtherVertex-_, Graph), \+ member(OtherVertex, Visited)), !.
+%
+
+% # With Accumulator
+% prolog
+% The visited list acts as an accumulator.
+is_connected_acc(Graph) :- is_connected(Graph).
+%
+
+% 26. Find the Shortest Path between Two Nodes in a Graph
+% # Normal Recursive
+% prolog
+shortest_path(Start, End, Graph, Path) :-
+ shortest_path([Start], End, Graph, [Start], Path).
+
+shortest_path(_, End, _, Visited, ReversePath) :-
+ reverse(ReversePath, [End|_]), !.
+shortest_path(Vertices, End, Graph, Visited, Path) :-
+ adjacent_unvisited(Vertices, Graph, Visited, Adjacent),
+ append(Visited, Adjacent, NewVisited),
+ append(Vertices, Adjacent, NewVertices),
+ shortest_path(NewVertices, End, Graph, NewVisited, Path).
+%
+
+% # With Accumulator
+% prolog
+% The visited list and the list of vertices to explore act as accumulators.
+shortest_path_acc(Start, End, Graph, Path) :- shortest_path(Start, End, Graph, Path).
+%
+
+% 27. Check if a String is a Palindrome
+% # Normal Recursive
+% prolog
+is_string_palindrome(Str) :- string_chars(Str, Chars), is_palindrome(Chars).
+%
+
+% # With Accumulator
+% prolog
+is_string_pal
+
+indrome_acc(Str) :- string_chars(Str, Chars), is_palindrome_acc(Chars, []).
+%
+
+% 28. Compute the Edit Distance between Two Strings
+% # Normal Recursive
+% prolog
+edit_distance([], [], 0).
+edit_distance([_|T1], [], D) :-
+ edit_distance(T1, [], D1),
+ D is D1 + 1.
+edit_distance([], [_|T2], D) :-
+ edit_distance([], T2, D1),
+ D is D1 + 1.
+edit_distance([H1|T1], [H2|T2], D) :-
+ edit_distance(T1, T2, D1),
+ D is D1 + (H1 \= H2).
+%
+
+% # With Accumulator
+% prolog
+edit_distance_acc(S1, S2, D) :- edit_distance_acc(S1, S2, 0, D).
+
+edit_distance_acc([], [], Acc, Acc).
+edit_distance_acc([_|T1], [], Acc, D) :- NewAcc is Acc + 1, edit_distance_acc(T1, [], NewAcc, D).
+edit_distance_acc([], [_|T2], Acc, D) :- NewAcc is Acc + 1, edit_distance_acc([], T2, NewAcc, D).
+edit_distance_acc([H1|T1], [H2|T2], Acc, D) :-
+ NewAcc is Acc + (H1 \= H2),
+ edit_distance_acc(T1, T2, NewAcc, D).
+%
+
+% 29. Find the Longest Common Subsequence of Two Strings
+% # Normal Recursive
+% prolog
+lcs([], _, []).
+lcs(_, [], []).
+lcs([H|T1], [H|T2], [H|Lcs]) :- lcs(T1, T2, Lcs), !.
+lcs(S1, [_|T2], Lcs) :- lcs(S1, T2, Lcs).
+lcs([_|T1], S2, Lcs) :- lcs(T1, S2, Lcs).
+%
+
+% # With Accumulator
+% prolog
+lcs_acc(S1, S2, Lcs) :- lcs_acc(S1, S2, [], Lcs).
+
+lcs_acc([], _, Acc, Lcs) :- reverse(Acc, Lcs).
+lcs_acc(_, [], Acc, Lcs) :- reverse(Acc, Lcs).
+lcs_acc([H|T1], [H|T2], Acc, Lcs) :- lcs_acc(T1, T2, [H|Acc], Lcs).
+lcs_acc(S1, [_|T2], Acc, Lcs) :- lcs_acc(S1, T2, Acc, Lcs).
+lcs_acc([_|T1], S2, Acc, Lcs) :- lcs_acc(T1, S2, Acc, Lcs).
+%
+
+% 30. Find the Longest Common Substring of Two Strings
+% # Normal Recursive
+% prolog
+longest_common_substring(S1, S2, Lcs) :-
+ findall(Sub, (substring(S1, Sub), substring(S2, Sub)), Subs),
+ longest_string(Subs, Lcs).
+
+substring(Str, Sub) :-
+ append(_, Rest, Str),
+ append(Sub, _, Rest).
+
+longest_string([H|T], Longest) :-
+ longest_string(T, H, Longest).
+
+longest_string([], Acc, Acc).
+longest_string([H|T], Acc, Longest) :-
+ length(H, LenH),
+ length(Acc, LenAcc),
+ (LenH > LenAcc -> longest_string(T, H, Longest); longest_string(T, Acc, Longest)).
+%
+
+% # With Accumulator
+% prolog
+longest_common_substring_acc(S1, S2, Lcs) :-
+ findall(Sub, (substring(S1, Sub), substring(S2, Sub)), Subs),
+ longest_string_acc(Subs, [], Lcs).
+
+longest_string_acc([], Acc, Acc).
+longest_string_acc([H|T], Acc, Longest) :-
+ length(H, LenH),
+ length(Acc, LenAcc),
+ (LenH > LenAcc -> longest_string_acc(T, H, Longest); longest_string_acc(T, Acc, Longest)).
+%
+
+
+
diff --git a/prebuilt_metta/Dmel_enzyme_data_fb_2023_04.tsv.metta b/prebuilt_metta/Dmel_enzyme_data_fb_2023_04.tsv.metta
index c1cb8f19..d416fe27 120000
--- a/prebuilt_metta/Dmel_enzyme_data_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/Dmel_enzyme_data_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/Dmel_enzyme_data_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/Dmel_enzyme_data_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/allele_genetic_interactions_fb_2023_04.tsv.metta b/prebuilt_metta/allele_genetic_interactions_fb_2023_04.tsv.metta
index 6e5e85a5..8c102569 120000
--- a/prebuilt_metta/allele_genetic_interactions_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/allele_genetic_interactions_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/alleles/allele_genetic_interactions_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/alleles/allele_genetic_interactions_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/automated_gene_summaries_fb_2023_04.tsv.metta b/prebuilt_metta/automated_gene_summaries_fb_2023_04.tsv.metta
index f81413a4..6e23a312 120000
--- a/prebuilt_metta/automated_gene_summaries_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/automated_gene_summaries_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/automated_gene_summaries_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/automated_gene_summaries_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/best_gene_summary_fb_2023_04.tsv.metta b/prebuilt_metta/best_gene_summary_fb_2023_04.tsv.metta
index 3e2a7932..1ba0ecbf 120000
--- a/prebuilt_metta/best_gene_summary_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/best_gene_summary_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/best_gene_summary_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/best_gene_summary_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/cDNA_clone_data_fb_2023_04.tsv.metta b/prebuilt_metta/cDNA_clone_data_fb_2023_04.tsv.metta
index 411d509c..0c617c59 120000
--- a/prebuilt_metta/cDNA_clone_data_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/cDNA_clone_data_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/clones/cDNA_clone_data_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/clones/cDNA_clone_data_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/chebi_fb_2023_04.obo.metta b/prebuilt_metta/chebi_fb_2023_04.obo.metta
index 3983eb45..aaaa87e4 120000
--- a/prebuilt_metta/chebi_fb_2023_04.obo.metta
+++ b/prebuilt_metta/chebi_fb_2023_04.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/chebi_fb_2023_04.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/chebi_fb_2023_04.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/cyto-genetic-seq.tsv.metta b/prebuilt_metta/cyto-genetic-seq.tsv.metta
index 3a73df4d..545cdb94 120000
--- a/prebuilt_metta/cyto-genetic-seq.tsv.metta
+++ b/prebuilt_metta/cyto-genetic-seq.tsv.metta
@@ -1 +1 @@
-../precomputed_files/map_conversion/cyto-genetic-seq.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/map_conversion/cyto-genetic-seq.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/cytotable.txt.metta b/prebuilt_metta/cytotable.txt.metta
index f9ca5577..cb122424 120000
--- a/prebuilt_metta/cytotable.txt.metta
+++ b/prebuilt_metta/cytotable.txt.metta
@@ -1 +1 @@
-../precomputed_files/map_conversion/cytotable.txt.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/map_conversion/cytotable.txt.metta
\ No newline at end of file
diff --git a/prebuilt_metta/dataset_metadata_fb_2023_04.tsv.metta b/prebuilt_metta/dataset_metadata_fb_2023_04.tsv.metta
index d0fc355b..8aa02a92 120000
--- a/prebuilt_metta/dataset_metadata_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/dataset_metadata_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/metadata/dataset_metadata_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/metadata/dataset_metadata_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/disease_model_annotations_fb_2023_04.tsv.metta b/prebuilt_metta/disease_model_annotations_fb_2023_04.tsv.metta
index 3b6623fb..0354e87e 120000
--- a/prebuilt_metta/disease_model_annotations_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/disease_model_annotations_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/human_disease/disease_model_annotations_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/human_disease/disease_model_annotations_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/dmel_gene_sequence_ontology_annotations_fb_2023_04.tsv.metta b/prebuilt_metta/dmel_gene_sequence_ontology_annotations_fb_2023_04.tsv.metta
index 3eee206a..cc182332 120000
--- a/prebuilt_metta/dmel_gene_sequence_ontology_annotations_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/dmel_gene_sequence_ontology_annotations_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/dmel_gene_sequence_ontology_annotations_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/dmel_gene_sequence_ontology_annotations_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/dmel_human_orthologs_disease_fb_2023_04.tsv.metta b/prebuilt_metta/dmel_human_orthologs_disease_fb_2023_04.tsv.metta
index 6dd07310..bfe22051 120000
--- a/prebuilt_metta/dmel_human_orthologs_disease_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/dmel_human_orthologs_disease_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/orthologs/dmel_human_orthologs_disease_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/orthologs/dmel_human_orthologs_disease_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/dmel_paralogs_fb_2023_04.tsv.metta b/prebuilt_metta/dmel_paralogs_fb_2023_04.tsv.metta
index add25767..da3b3476 120000
--- a/prebuilt_metta/dmel_paralogs_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/dmel_paralogs_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/orthologs/dmel_paralogs_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/orthologs/dmel_paralogs_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/dmel_unique_protein_isoforms_fb_2023_04.tsv.metta b/prebuilt_metta/dmel_unique_protein_isoforms_fb_2023_04.tsv.metta
index eea1ff26..b5c5bbfa 120000
--- a/prebuilt_metta/dmel_unique_protein_isoforms_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/dmel_unique_protein_isoforms_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/dmel_unique_protein_isoforms_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/dmel_unique_protein_isoforms_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/doid.obo.metta b/prebuilt_metta/doid.obo.metta
index ac71c344..79341796 120000
--- a/prebuilt_metta/doid.obo.metta
+++ b/prebuilt_metta/doid.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/doid.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/doid.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/entity_publication_fb_2023_04.tsv.metta b/prebuilt_metta/entity_publication_fb_2023_04.tsv.metta
index a39d5dd4..14218be7 120000
--- a/prebuilt_metta/entity_publication_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/entity_publication_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/references/entity_publication_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/references/entity_publication_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fb_synonym_fb_2023_04.tsv.metta b/prebuilt_metta/fb_synonym_fb_2023_04.tsv.metta
index 5f786395..2118e811 120000
--- a/prebuilt_metta/fb_synonym_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fb_synonym_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/synonyms/fb_synonym_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/synonyms/fb_synonym_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbal_to_fbgn_fb_2023_04.tsv.metta b/prebuilt_metta/fbal_to_fbgn_fb_2023_04.tsv.metta
index fed688b8..287cadc4 120000
--- a/prebuilt_metta/fbal_to_fbgn_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbal_to_fbgn_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/alleles/fbal_to_fbgn_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/alleles/fbal_to_fbgn_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_NAseq_Uniprot_fb_2023_04.tsv.metta b/prebuilt_metta/fbgn_NAseq_Uniprot_fb_2023_04.tsv.metta
index 2c93a8fc..221cfd22 120000
--- a/prebuilt_metta/fbgn_NAseq_Uniprot_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbgn_NAseq_Uniprot_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/fbgn_NAseq_Uniprot_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/fbgn_NAseq_Uniprot_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_annotation_ID_fb_2023_04.tsv.metta b/prebuilt_metta/fbgn_annotation_ID_fb_2023_04.tsv.metta
index 2e15b127..c0184f7b 120000
--- a/prebuilt_metta/fbgn_annotation_ID_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbgn_annotation_ID_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/fbgn_annotation_ID_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/fbgn_annotation_ID_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_exons2affy1_overlaps.tsv.metta b/prebuilt_metta/fbgn_exons2affy1_overlaps.tsv.metta
index ba9dd178..006d8dfa 120000
--- a/prebuilt_metta/fbgn_exons2affy1_overlaps.tsv.metta
+++ b/prebuilt_metta/fbgn_exons2affy1_overlaps.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/fbgn_exons2affy1_overlaps.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/fbgn_exons2affy1_overlaps.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_exons2affy2_overlaps.tsv.metta b/prebuilt_metta/fbgn_exons2affy2_overlaps.tsv.metta
index 3d25b6f0..d2a48a08 120000
--- a/prebuilt_metta/fbgn_exons2affy2_overlaps.tsv.metta
+++ b/prebuilt_metta/fbgn_exons2affy2_overlaps.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/fbgn_exons2affy2_overlaps.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/fbgn_exons2affy2_overlaps.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_fbtr_fbpp_expanded_fb_2023_04.tsv.metta b/prebuilt_metta/fbgn_fbtr_fbpp_expanded_fb_2023_04.tsv.metta
index 2bdb87f3..98a574c9 120000
--- a/prebuilt_metta/fbgn_fbtr_fbpp_expanded_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbgn_fbtr_fbpp_expanded_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/fbgn_fbtr_fbpp_expanded_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/fbgn_fbtr_fbpp_expanded_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_fbtr_fbpp_fb_2023_04.tsv.metta b/prebuilt_metta/fbgn_fbtr_fbpp_fb_2023_04.tsv.metta
index ffdd7e77..dc929dae 120000
--- a/prebuilt_metta/fbgn_fbtr_fbpp_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbgn_fbtr_fbpp_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/fbgn_fbtr_fbpp_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/fbgn_fbtr_fbpp_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_gleanr_fb_2023_04.tsv.metta b/prebuilt_metta/fbgn_gleanr_fb_2023_04.tsv.metta
index 8f7f5add..d7e70797 120000
--- a/prebuilt_metta/fbgn_gleanr_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbgn_gleanr_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/fbgn_gleanr_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/fbgn_gleanr_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbgn_uniprot_fb_2023_04.tsv.metta b/prebuilt_metta/fbgn_uniprot_fb_2023_04.tsv.metta
index 909de948..570530c8 120000
--- a/prebuilt_metta/fbgn_uniprot_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbgn_uniprot_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/collaborators/fbgn_uniprot_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/collaborators/fbgn_uniprot_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fbrf_pmid_pmcid_doi_fb_2023_04.tsv.metta b/prebuilt_metta/fbrf_pmid_pmcid_doi_fb_2023_04.tsv.metta
index 05255b5d..8d5308b1 120000
--- a/prebuilt_metta/fbrf_pmid_pmcid_doi_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/fbrf_pmid_pmcid_doi_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/references/fbrf_pmid_pmcid_doi_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/references/fbrf_pmid_pmcid_doi_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fly_anatomy.obo.metta b/prebuilt_metta/fly_anatomy.obo.metta
index 0361343f..70b6dd39 120000
--- a/prebuilt_metta/fly_anatomy.obo.metta
+++ b/prebuilt_metta/fly_anatomy.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/fly_anatomy.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/fly_anatomy.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fly_development.obo.metta b/prebuilt_metta/fly_development.obo.metta
index 69b4a8f5..0c0d2aba 120000
--- a/prebuilt_metta/fly_development.obo.metta
+++ b/prebuilt_metta/fly_development.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/fly_development.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/fly_development.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/flybase_controlled_vocabulary.obo.metta b/prebuilt_metta/flybase_controlled_vocabulary.obo.metta
index e5352165..a7526353 120000
--- a/prebuilt_metta/flybase_controlled_vocabulary.obo.metta
+++ b/prebuilt_metta/flybase_controlled_vocabulary.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/flybase_controlled_vocabulary.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/flybase_controlled_vocabulary.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/flybase_stock_vocabulary.obo.metta b/prebuilt_metta/flybase_stock_vocabulary.obo.metta
index 7bfc7452..04021918 120000
--- a/prebuilt_metta/flybase_stock_vocabulary.obo.metta
+++ b/prebuilt_metta/flybase_stock_vocabulary.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/flybase_stock_vocabulary.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/flybase_stock_vocabulary.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/fu_gal4_table_fb_2023_04.json.metta b/prebuilt_metta/fu_gal4_table_fb_2023_04.json.metta
index ae3fdf08..fbe15b04 120000
--- a/prebuilt_metta/fu_gal4_table_fb_2023_04.json.metta
+++ b/prebuilt_metta/fu_gal4_table_fb_2023_04.json.metta
@@ -1 +1 @@
-../precomputed_files/insertions/fu_gal4_table_fb_2023_04.json.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/insertions/fu_gal4_table_fb_2023_04.json.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_association.fb.metta b/prebuilt_metta/gene_association.fb.metta
index f048fe5e..cf74034e 120000
--- a/prebuilt_metta/gene_association.fb.metta
+++ b/prebuilt_metta/gene_association.fb.metta
@@ -1 +1 @@
-../precomputed_files/go/gene_association.fb.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/go/gene_association.fb.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_functional_complementation_fb_2023_04.tsv.metta b/prebuilt_metta/gene_functional_complementation_fb_2023_04.tsv.metta
index ac51e0af..2173d247 120000
--- a/prebuilt_metta/gene_functional_complementation_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_functional_complementation_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_functional_complementation_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_functional_complementation_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_genetic_interactions_fb_2023_04.tsv.metta b/prebuilt_metta/gene_genetic_interactions_fb_2023_04.tsv.metta
index 572fd935..282c7733 120000
--- a/prebuilt_metta/gene_genetic_interactions_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_genetic_interactions_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_genetic_interactions_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_genetic_interactions_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_group_FB2023_04.obo.metta b/prebuilt_metta/gene_group_FB2023_04.obo.metta
index 8e586688..cc97d46f 120000
--- a/prebuilt_metta/gene_group_FB2023_04.obo.metta
+++ b/prebuilt_metta/gene_group_FB2023_04.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/gene_group_FB2023_04.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/gene_group_FB2023_04.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_group_data_fb_2023_04.tsv.metta b/prebuilt_metta/gene_group_data_fb_2023_04.tsv.metta
index a099b855..76753ef4 120000
--- a/prebuilt_metta/gene_group_data_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_group_data_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_group_data_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_group_data_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_groups_HGNC_fb_2023_04.tsv.metta b/prebuilt_metta/gene_groups_HGNC_fb_2023_04.tsv.metta
index e77eb02a..1973691e 120000
--- a/prebuilt_metta/gene_groups_HGNC_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_groups_HGNC_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_groups_HGNC_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_groups_HGNC_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_map_table_fb_2023_04.tsv.metta b/prebuilt_metta/gene_map_table_fb_2023_04.tsv.metta
index 48f9266e..d0f39199 120000
--- a/prebuilt_metta/gene_map_table_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_map_table_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_map_table_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_map_table_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_rpkm_matrix_fb_2023_04.tsv.metta b/prebuilt_metta/gene_rpkm_matrix_fb_2023_04.tsv.metta
index c592a70d..a244209b 120000
--- a/prebuilt_metta/gene_rpkm_matrix_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_rpkm_matrix_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_rpkm_matrix_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_rpkm_matrix_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_rpkm_report_fb_2023_04.tsv.metta b/prebuilt_metta/gene_rpkm_report_fb_2023_04.tsv.metta
index 0633b48a..fb80d779 120000
--- a/prebuilt_metta/gene_rpkm_report_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_rpkm_report_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_rpkm_report_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_rpkm_report_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gene_snapshots_fb_2023_04.tsv.metta b/prebuilt_metta/gene_snapshots_fb_2023_04.tsv.metta
index 0665b65a..69b17ce1 120000
--- a/prebuilt_metta/gene_snapshots_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/gene_snapshots_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/gene_snapshots_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/gene_snapshots_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/genome-cyto-seq.txt.metta b/prebuilt_metta/genome-cyto-seq.txt.metta
index 72b2c720..4198a40b 120000
--- a/prebuilt_metta/genome-cyto-seq.txt.metta
+++ b/prebuilt_metta/genome-cyto-seq.txt.metta
@@ -1 +1 @@
-../precomputed_files/map_conversion/genome-cyto-seq.txt.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/map_conversion/genome-cyto-seq.txt.metta
\ No newline at end of file
diff --git a/prebuilt_metta/genomic_clone_data_fb_2023_04.tsv.metta b/prebuilt_metta/genomic_clone_data_fb_2023_04.tsv.metta
index cd0d3298..bf7d3785 120000
--- a/prebuilt_metta/genomic_clone_data_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/genomic_clone_data_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/clones/genomic_clone_data_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/clones/genomic_clone_data_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/genotype_phenotype_data_fb_2023_04.tsv.metta b/prebuilt_metta/genotype_phenotype_data_fb_2023_04.tsv.metta
index ef0c9a0a..84c11352 120000
--- a/prebuilt_metta/genotype_phenotype_data_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/genotype_phenotype_data_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/alleles/genotype_phenotype_data_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/alleles/genotype_phenotype_data_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/go-basic.obo.metta b/prebuilt_metta/go-basic.obo.metta
index e7278164..305da70a 120000
--- a/prebuilt_metta/go-basic.obo.metta
+++ b/prebuilt_metta/go-basic.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/go-basic.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/go-basic.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/gp_information.fb.metta b/prebuilt_metta/gp_information.fb.metta
index 25aa47bb..faf1d563 120000
--- a/prebuilt_metta/gp_information.fb.metta
+++ b/prebuilt_metta/gp_information.fb.metta
@@ -1 +1 @@
-../precomputed_files/collaborators/gp_information.fb.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/collaborators/gp_information.fb.metta
\ No newline at end of file
diff --git a/prebuilt_metta/image.obo.metta b/prebuilt_metta/image.obo.metta
index 836f5edb..e3adcc14 120000
--- a/prebuilt_metta/image.obo.metta
+++ b/prebuilt_metta/image.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/image.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/image.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/insertion_mapping_fb_2023_04.tsv.metta b/prebuilt_metta/insertion_mapping_fb_2023_04.tsv.metta
index 972192eb..dbe20670 120000
--- a/prebuilt_metta/insertion_mapping_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/insertion_mapping_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/insertions/insertion_mapping_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/insertions/insertion_mapping_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/ncRNA_genes_fb_2023_04.json.metta b/prebuilt_metta/ncRNA_genes_fb_2023_04.json.metta
index e03d54dc..70519546 120000
--- a/prebuilt_metta/ncRNA_genes_fb_2023_04.json.metta
+++ b/prebuilt_metta/ncRNA_genes_fb_2023_04.json.metta
@@ -1 +1 @@
-../precomputed_files/genes/ncRNA_genes_fb_2023_04.json.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/ncRNA_genes_fb_2023_04.json.metta
\ No newline at end of file
diff --git a/prebuilt_metta/organism_list_fb_2023_04.tsv.metta b/prebuilt_metta/organism_list_fb_2023_04.tsv.metta
index fc6050dd..65e25efe 120000
--- a/prebuilt_metta/organism_list_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/organism_list_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/species/organism_list_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/species/organism_list_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/pathway_group_data_fb_2023_04.tsv.metta b/prebuilt_metta/pathway_group_data_fb_2023_04.tsv.metta
index e97e3171..ce704a4b 120000
--- a/prebuilt_metta/pathway_group_data_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/pathway_group_data_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/pathway_group_data_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/pathway_group_data_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/physical_interactions_mitab_fb_2023_04.tsv.metta b/prebuilt_metta/physical_interactions_mitab_fb_2023_04.tsv.metta
index e7bb5672..c1a1e842 120000
--- a/prebuilt_metta/physical_interactions_mitab_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/physical_interactions_mitab_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/physical_interactions_mitab_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/physical_interactions_mitab_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/pmid_fbgn_uniprot_fb_2023_04.tsv.metta b/prebuilt_metta/pmid_fbgn_uniprot_fb_2023_04.tsv.metta
index 30bbba3b..2a857732 120000
--- a/prebuilt_metta/pmid_fbgn_uniprot_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/pmid_fbgn_uniprot_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/collaborators/pmid_fbgn_uniprot_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/collaborators/pmid_fbgn_uniprot_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/psi-mi.obo.metta b/prebuilt_metta/psi-mi.obo.metta
index ee6231b3..09ccc3bd 120000
--- a/prebuilt_metta/psi-mi.obo.metta
+++ b/prebuilt_metta/psi-mi.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/psi-mi.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/psi-mi.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/scRNA-Seq_gene_expression_fb_2023_04.tsv.metta b/prebuilt_metta/scRNA-Seq_gene_expression_fb_2023_04.tsv.metta
index 7027a49a..82c4ff6e 120000
--- a/prebuilt_metta/scRNA-Seq_gene_expression_fb_2023_04.tsv.metta
+++ b/prebuilt_metta/scRNA-Seq_gene_expression_fb_2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/genes/scRNA-Seq_gene_expression_fb_2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/genes/scRNA-Seq_gene_expression_fb_2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/slice.chebi.obo.metta b/prebuilt_metta/slice.chebi.obo.metta
index c0b536a4..ec1433bf 120000
--- a/prebuilt_metta/slice.chebi.obo.metta
+++ b/prebuilt_metta/slice.chebi.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/slice.chebi.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/slice.chebi.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/so-simple.obo.metta b/prebuilt_metta/so-simple.obo.metta
index 7956a9d7..b2079794 120000
--- a/prebuilt_metta/so-simple.obo.metta
+++ b/prebuilt_metta/so-simple.obo.metta
@@ -1 +1 @@
-../precomputed_files/ontologies/so-simple.obo.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/ontologies/so-simple.obo.metta
\ No newline at end of file
diff --git a/prebuilt_metta/stocks_FB2023_04.tsv.metta b/prebuilt_metta/stocks_FB2023_04.tsv.metta
index 5edd536e..ab3eec69 120000
--- a/prebuilt_metta/stocks_FB2023_04.tsv.metta
+++ b/prebuilt_metta/stocks_FB2023_04.tsv.metta
@@ -1 +1 @@
-../precomputed_files/stocks/stocks_FB2023_04.tsv.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/stocks/stocks_FB2023_04.tsv.metta
\ No newline at end of file
diff --git a/prebuilt_metta/transposon_sequence_set.fa.metta b/prebuilt_metta/transposon_sequence_set.fa.metta
index d3c1b7e3..aba70f45 120000
--- a/prebuilt_metta/transposon_sequence_set.fa.metta
+++ b/prebuilt_metta/transposon_sequence_set.fa.metta
@@ -1 +1 @@
-../precomputed_files/transposons/transposon_sequence_set.fa.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/transposons/transposon_sequence_set.fa.metta
\ No newline at end of file
diff --git a/prebuilt_metta/transposon_sequence_set.gff.metta b/prebuilt_metta/transposon_sequence_set.gff.metta
index 2c531e1b..1cfdbb0e 120000
--- a/prebuilt_metta/transposon_sequence_set.gff.metta
+++ b/prebuilt_metta/transposon_sequence_set.gff.metta
@@ -1 +1 @@
-../precomputed_files/transposons/transposon_sequence_set.gff.metta
\ No newline at end of file
+../data/ftp.flybase.org/releases/FB2023_04/metta_files/transposons/transposon_sequence_set.gff.metta
\ No newline at end of file
diff --git a/precomputed_files b/precomputed_files
index d7a782ed..5f93b125 120000
--- a/precomputed_files
+++ b/precomputed_files
@@ -1 +1 @@
-data/ftp.flybase.org/releases/FB2023_04/precomputed_files
\ No newline at end of file
+/opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/data/ftp.flybase.org/releases/FB2023_04/precomputed_files/
\ No newline at end of file