{"id":15592283,"url":"https://github.com/caknoooo/clips_rule","last_synced_at":"2026-02-13T01:37:25.947Z","repository":{"id":198597485,"uuid":"701128139","full_name":"Caknoooo/CLIPS_RULE","owner":"Caknoooo","description":"The Repository was created by implementation the CLIPS language in lecture Knowledge Based Programming","archived":false,"fork":false,"pushed_at":"2023-10-06T03:05:27.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T10:31:39.142Z","etag":null,"topics":["clips","rules"],"latest_commit_sha":null,"homepage":"","language":"CLIPS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Caknoooo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-06T01:31:38.000Z","updated_at":"2023-10-06T01:36:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"33f04818-33e3-4c2f-9560-ac936d657d71","html_url":"https://github.com/Caknoooo/CLIPS_RULE","commit_stats":null,"previous_names":["caknoooo/clips_rule"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Caknoooo/CLIPS_RULE","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caknoooo%2FCLIPS_RULE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caknoooo%2FCLIPS_RULE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caknoooo%2FCLIPS_RULE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caknoooo%2FCLIPS_RULE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Caknoooo","download_url":"https://codeload.github.com/Caknoooo/CLIPS_RULE/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Caknoooo%2FCLIPS_RULE/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272641165,"owners_count":24968801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clips","rules"],"created_at":"2024-10-03T00:00:27.886Z","updated_at":"2026-02-13T01:37:20.902Z","avatar_url":"https://github.com/Caknoooo.png","language":"CLIPS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLIPS \n\n`(exit)` shutdown\n\n`(clear)` clear rules and facts\n\n`(reset)` removes facts but not rules\n\n`(run)` start execute\n\n### Facts\n\nfacts declaration \n`(assert (colour green))`\n\nevery assert create a fact `\u003cFact-0\u003e`, the number will increment\n\nfacts retract -\u003e cancel a fact\n\n`(retract 0)`\n\nthis means retracting facts at index 0\n\n\n`(facts)` to list all facts inserted\n\n### Rules\n\n`(rules)` to list all rules inserted\n\n```\n(defrule duck\n    (animal-is duck)\n    =\u003e\n    (assert (sound-is quack))\n)\n```\n\n`defrule duck` -\u003e duck is rules name\n\n`animal-is duck` -\u003e similar to IF 'if duck bla bla bla'\n\n`=\u003e` -\u003e then\n\n`assert (sound-is quack)` -\u003e this is the action taken if the condition true\n\n\ntry run the program using `(run)`\n\nnothing will appear, but the there is new facts. \ncheck it out with `(facts)`\n\n### chaining rules\n\nwe already have the `duck` rules\n\nnow add 1 more rules \n```\n(defrule is-it-a-duck\n    (animal-has webbed-feet)\n    (animal-has feathers)\n    =\u003e\n    (assert (animal-is duck))\n)\n```\n\ntry `(reset)` the facts to restart. \n\nnow assert 2 facts the `webbed-feet` and `feathers`\n\nafter run there should be 4 facts\n\nfrom this examples we know that this program producing facts\nand governed by rules.\n\n\n### print out something !\n\nredeclare the rules and try it on your own!\n\n```\n(defrule duck\n    (animal-is duck)\n    =\u003e\n    (assert (sound-is quack))\n    (printout t \"it’s a duck\" crlf)\n)\n```\n\n## Persistent facts\n\nwith this we can always get the same fact even after reset\n\n`(deffacts startup (animal dog) (animal duck) (animal haddock))`\n\nnow populate facts with more facts\n\n```\n(deffacts startup (animal dog) (animal cat) (animal duck) (animal turtle) (warm-blooded dog) (warm-blooded cat)\n(warm-blooded duck) (lays-eggs duck) (lays-eggs turtle) (child-of dog puppy) (child-of cat kitten)\n(child-of turtle hatchling))\n```\n\n### wild cards\n\n```\n(defrule animal\n(animal ?)\n=\u003e\n(printout t \"animal found\" crlf))\n```\nthose wildcards can be used to check multiple condition\n\ntry and run it\n\n### variables\n\nwhile utilizing wild card add identifier to declare it as variables\n\n`?name`\n\nwhile calling `?name` again it will act as variables\n\ncalling rules and get the facts\n\nfirst rules\n\n```\n(defrule mammal\n(animal ?name)\n(warm-blooded ?name)\n(not (lays-eggs ?name))\n=\u003e\n(assert (mammal ?name))\n(printout t ?name \" is a mammal\" crlf))\n```\n\nsecond rule\n```\n(defrule remove-mammals\n?fact \u003c- (mammal ?)\n=\u003e\n(printout t \"retracting \" ?fact crlf)\n(retract ?fact))\n```\n\non this second rule, the result from `mammals` rule is injected to a variable called `?fact`\n\n\n### logic and math\n\n```\n(defrule take-umbrella\n(or (weather raining)\n(weather snowing))\n=\u003e\n(assert (umbrella required)))\n```\n\nmath ...\n\n```\n(+ 5 7) -\u003e 12\n\n(- 5 7) -\u003e -2\n\n(* 5 7) -\u003e 35\n\n(/5 7) -\u003e 0.714...\n```\n\n### user input\n\nit will prompt user to input if there is `read` keyword\n\n```\n(defrule what-is-child\n(animal ?name)\n(not (child-of ?name ?))\n=\u003e\n(printout t \"What do you call the child of a \" ?name \"?\")\n(assert (child-of ?name (read))))\n```\n\nmulti wild cards `$?`\n\nmulti-field variables `$?members`\n\nassigning value to variables `bind ?total (+ ?x ?y)`\n\nall these variables are local\n\nthis is global variable\n```\n(defglobal\n?*var1* = 17\n?*oranges* = \"seven\"\n)\n```\n\n### multi information \n\n```\n(age Andrew 20)\n(weight Andrew 80)\n(height Andrew 188)\n(blood-pressure Andrew 130 80)\n(age brenda 23)\n(weight brenda 50)\n(height brenda 140)\n(blood-pressure brenda 120 60)\n```\n\nthis can pretty much do the job to hold multiple information,\nbut i think template could do that more neatly\n\nhere how to create template\n\n```\n(deftemplate personal-data\n    (slot name)\n    (slot age)\n    (slot weight)\n    (slot height)\n    (multislot blood-pressure)\n)\n```\n\nand here how to create fact from template \n\n```\n(assert (personal-data (name Andrew) (age 20) (weight 80)\n(height 188) (blood-pressure 130 80)))\n```\n\nyou dont have to put all the info\n\n```\n(assert (personal-data (weight 150) (age 23) (name Brenda)))\n```\n\ninformation inside template can be altered using `modify`\n\n```\n(defrule birthday\n?birthday \u003c- (birthday ?name)\n?data-fact \u003c- (personal-data (name ?name) (age ?age))\n=\u003e\n(modify ?data-fact (age (+ ?age 1)))\n(retract ?birthday)\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaknoooo%2Fclips_rule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaknoooo%2Fclips_rule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaknoooo%2Fclips_rule/lists"}