Terms are the basic building blocks of the deductive system. A term can be:
Variable: Prefixed with backtick, e.g., `X, `P
Item: Constants or functors, e.g., a, father, !
List: Ordered sequences in parentheses, e.g., (a b c)
1 2 3 4 5 6 7 8 9101112
importapyds# Create different types of termsvar=apyds.Variable("`X")item=apyds.Item("hello")lst=apyds.List("(a b c)")term=apyds.Term("(f `x a)")print(f"Variable: {var}")# `Xprint(f"Item: {item}")# helloprint(f"List: {lst}")# (a b c)print(f"Term: {term}")# (f `x a)
1 2 3 4 5 6 7 8 9101112
import{Variable,Item,List,Term}from"atsds";// Create different types of termsconstvar1=newVariable("`X");constitem=newItem("hello");constlst=newList("(a b c)");constterm=newTerm("(f `x a)");console.log(`Variable: ${var1.toString()}`);// `Xconsole.log(`Item: ${item.toString()}`);// helloconsole.log(`List: ${lst.toString()}`);// (a b c)console.log(`Term: ${term.toString()}`);// (f `x a)
Rules represent logical inference steps. A rule has premises (conditions) and a conclusion.
1 2 3 4 5 6 7 8 91011
importapyds# A fact (rule with no premises)fact=apyds.Rule("(parent john mary)")print(f"Fact: {fact}")# A rule with premises# Format: premise1\npremise2\nconclusion\nrule=apyds.Rule("(father `X `Y)\n----------\n(parent `X `Y)\n")print(f"Rule premises: {len(rule)}")print(f"Rule conclusion: {rule.conclusion}")
1 2 3 4 5 6 7 8 910
import{Rule}from"atsds";// A fact (rule with no premises)constfact=newRule("(parent john mary)");console.log(`Fact: ${fact.toString()}`);// A rule with premisesconstrule=newRule("(father `X `Y)\n----------\n(parent `X `Y)\n");console.log(`Rule premises: ${rule.length()}`);console.log(`Rule conclusion: ${rule.conclusion().toString()}`);