Last active
February 16, 2026 19:18
-
-
Save patham9/aec7c4f0ad0a55bccdf425602a082c5b to your computer and use it in GitHub Desktop.
Missing PLN examples (for lib_pln of PeTTa)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !(import! &self (library lib_pln)) | |
| (= (STV Sam) (stv 0.16 0.9)) | |
| (= (STV Pingu) (stv 0.16 0.9)) | |
| (= (STV Penguin) (stv 0.16 0.9)) | |
| (= (STV Raven) (stv 0.16 0.9)) | |
| (= (STV Bird) (stv 0.16 0.9)) | |
| (= (STV (IntSet flies)) (stv 0.16 0.9)) | |
| (= (kb) | |
| ((Sentence ((Inheritance Sam | |
| Raven) | |
| (stv 0.99 0.9)) (1)) | |
| (Sentence ((Inheritance Pingu | |
| Penguin) | |
| (stv 0.99 0.9)) (2)) | |
| (Sentence ((Inheritance Penguin | |
| (IntSet flies)) | |
| (stv 0.01 0.9)) (3)) | |
| (Sentence ((Inheritance Raven | |
| Bird) | |
| (stv 0.99 0.9)) (4)) | |
| (Sentence ((Inheritance Penguin | |
| Bird) | |
| (stv 0.99 0.9)) (5)) | |
| (Sentence ((Inheritance Bird | |
| (IntSet flies)) | |
| (stv 0.99 0.9)) (6)))) | |
| !(test (PLN.Query (kb) | |
| (Inheritance Sam | |
| (IntSet flies))) | |
| ((stv 0.9703557256235827 0.9) (1 4 6))) | |
| !(test (PLN.Query (kb) | |
| (Inheritance Pingu | |
| (IntSet flies))) | |
| ((stv 0.011785714285714288 0.9) (2 3))) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !(import! &self (library lib_pln)) | |
| (= (STV person) (stv 0.125 0.9)) | |
| (= (STV frisbee) (stv 0.125 0.9)) | |
| (= (STV sportsball) (stv 0.125 0.9)) | |
| (= (STV chair) (stv 0.125 0.9)) | |
| (= (STV toy) (stv 0.125 0.9)) | |
| (= (STV round) (stv 0.125 0.9)) | |
| (= (STV orange) (stv 0.125 0.9)) | |
| ;2. Static KB part | |
| (= (kb) | |
| ((Sentence ((Implication (Inheritance $1 | |
| toy) | |
| (Implication (Inheritance $1 | |
| see) | |
| (Inheritance $1 | |
| bring))) (stv 0.99 0.99)) (1)) | |
| (Sentence ((Inheritance frisbee | |
| toy) (stv 0.99 0.99)) (2)) | |
| (Sentence ((Inheritance sportsball | |
| toy) (stv 0.99 0.99)) (3)) | |
| (Sentence ((Inheritance orange | |
| round) (stv 0.99 0.99)) (4)) | |
| (Sentence ((Inheritance sportsball | |
| round) (stv 0.99 0.99)) (5)))) | |
| ;5. Categorize observation using all prior knowledge | |
| (= (PLNcategorizeObject $label $category) | |
| (PLN.Query (TupleConcat (kb) | |
| ((Sentence ((Inheritance $label | |
| see) (stv 0.99 0.99)) (99)))) | |
| (Inheritance $label | |
| $category) | |
| )) ;13 7 17)) ;uncomment for example-specific minimal resource usage | |
| ;6. Filter objects based on PLN reasoning | |
| (= (PLNobjectsOfCategoryHelper $objects $category) | |
| (let (detection $label $coord) (superpose $objects) | |
| (if (not (== (PLNcategorizeObject $label $category) ())) | |
| (detection $label $coord) | |
| (empty)))) | |
| ;7. Ensure uniquene mentioning of objects which are determined to be qualified | |
| (= (PLNobjectsOfCategory $objects $category) | |
| (let $tuple (collapse (PLNobjectsOfCategoryHelper $objects $category)) | |
| (unique-atom $tuple))) | |
| ;8. Determine which of the observed/remembered objects to bring: | |
| !(test (PLNobjectsOfCategory ((detection frisbee someCoords1) | |
| (detection {SELF} someCoords2) | |
| (detection person someCoords3) | |
| (detection orange someCoords4)) | |
| bring) | |
| ((detection frisbee someCoords1) (detection orange someCoords4))) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !(import! &self (library lib_pln)) | |
| (= (STV X) (stv 0.1 0.99)) | |
| (= (STV madeOfPlastic) (stv 0.1 0.99)) | |
| (= (STV heated) (stv 0.1 0.99)) | |
| (= (STV melted) (stv 0.1 0.99)) | |
| (= (STV pliable) (stv 0.1 0.99)) | |
| (= (STV screwlike) (stv 0.1 0.99)) | |
| (= (STV hardened) (stv 0.1 0.99)) | |
| (= (STV removed) (stv 0.1 0.99)) | |
| (= (STV opLighter) (stv 0.1 0.99)) | |
| (= (STV opReshape) (stv 0.1 0.99)) | |
| (= (STV opWait) (stv 0.1 0.99)) | |
| (= (STV opUnscrew) (stv 0.1 0.99)) | |
| (= (kb) | |
| (;Implications | |
| ; If something is made of plastic, applying the lighter on it will make it heatedIf something is made of plastic, applying the lighter on it will make it heated | |
| (Sentence ((Implication (Inheritance $X | |
| madeOfPlastic) | |
| (Implication (Operation $X | |
| opLighter) | |
| (Inheritance $X | |
| heated))) (stv 0.99 0.99)) (2)) | |
| ; If it's heated it will be melted | |
| (Sentence ((Implication (Inheritance $X | |
| heated) | |
| (Inheritance $X | |
| melted)) (stv 0.99 0.99)) (3)) | |
| ; If it's melted it will be pliable | |
| (Sentence ((Implication (Inheritance $X | |
| melted) | |
| (Inheritance $X | |
| pliable)) (stv 0.99 0.99)) (4)) | |
| ; If it's pliable and reshape is applied, it will be screwlike | |
| (Sentence ((Implication (Inheritance $X | |
| pliable) | |
| (Implication (Operation $X | |
| opReshape) | |
| (Inheritance $X | |
| screwlike))) (stv 0.99 0.99)) (5)) | |
| ; If it's screwlike and we opWait, it will be hardened | |
| (Sentence ((Implication (Inheritance $X | |
| screwlike) | |
| (Implication (Operation $X | |
| opWait) | |
| (Inheritance $X | |
| hardened))) (stv 0.99 0.99)) (6)) | |
| ; If it's hardened, we can use it for opUnscrewing to remove the screw | |
| (Sentence ((Implication (Inheritance $X | |
| hardened) | |
| (Implication (Operation $X | |
| opUnscrew) | |
| (Inheritance $X | |
| removed))) (stv 0.99 0.99)) (7)) | |
| (Sentence ((Inheritance X | |
| madeOfPlastic) (stv 0.99 0.99)) (10)) | |
| ; We apply the lighter to it | |
| (Sentence ((Operation X | |
| opLighter) (stv 0.99 0.99)) (11)) | |
| (Sentence ((Operation X | |
| opReshape) (stv 0.99 0.99)) (12)) | |
| (Sentence ((Operation X | |
| opWait) (stv 0.99 0.99)) (13)) | |
| (Sentence ((Operation X | |
| opUnscrew) (stv 0.99 0.99)) (14)))) | |
| !(test (PLN.Query (kb) | |
| (Inheritance X | |
| removed) | |
| ) ;10 2 12) ;uncomment for example-specific minimal resource usage | |
| ((stv 0.9013534742103302 0.8953382542587163) (2 3 4 5 6 7 10 11 12 13 14))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment