generated from okp4/template-oss
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(predicates): add axone-protocol/axoned v11.0.0 predicates docume…
…ntation
- Loading branch information
Showing
35 changed files
with
2,403 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# abolish/1 | ||
|
||
## Description | ||
|
||
`abolish/1` is a predicate that abolishes a predicate from the database. Removes all clauses of the predicate designated by given predicate indicator Name/Arity. | ||
|
||
## Signature | ||
|
||
```text | ||
abolish(+PredicateIndicator) | ||
``` | ||
|
||
Where: | ||
|
||
- PredicateIndicator is the indicator of the predicate to abolish. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# asserta/1 | ||
|
||
## Description | ||
|
||
`asserta/1` is a predicate that asserts a clause into the database as the first clause of the predicate. | ||
|
||
## Signature | ||
|
||
```text | ||
asserta(+Clause) | ||
``` | ||
|
||
Where: | ||
|
||
- Clause is the clause to assert into the database. | ||
|
||
## Examples | ||
|
||
### Assert a fact into the database | ||
|
||
This scenario demonstrates the process of asserting a new fact into a Prolog database. In Prolog, asserting a fact means | ||
adding a new piece of information or *knowledge* into the database, allowing it to be referenced in subsequent queries. | ||
This is particularly useful when you want to dynamically extend the knowledge base with facts or rules based on conditions | ||
or interactions during runtime. | ||
|
||
Here are the steps of the scenario: | ||
|
||
- **Given** the program: | ||
|
||
``` prolog | ||
assert_fact :- asserta(father(john, pete)). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
assert_fact, father(X, Y). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3977 | ||
answer: | ||
has_more: false | ||
variables: ["X", "Y"] | ||
results: | ||
- substitutions: | ||
- variable: X | ||
expression: john | ||
- variable: 'Y' | ||
expression: pete | ||
``` | ||
### Only dynamic predicates can be asserted | ||
This scenario demonstrates that only dynamic predicates can be asserted. In Prolog, dynamic predicates are those that can be | ||
modified during runtime. This is in contrast to static predicates, which are fixed and cannot be modified. | ||
Here are the steps of the scenario: | ||
- **Given** the program: | ||
``` prolog | ||
parent(jane, alice). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
asserta(parent(john, alice)). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3975 | ||
answer: | ||
has_more: false | ||
results: | ||
- error: "error(permission_error(modify,static_procedure,parent/2),asserta/1)" | ||
``` | ||
### Show that the fact is asserted at the beginning of the database | ||
This scenario demonstrates that the asserta/1 predicate adds the fact to the beginning of the database. This means that | ||
the fact is the first fact to be matched when a query is run. | ||
This is in contrast to the assertz/1 predicate, which adds the fact to the end of the database. | ||
Here are the steps of the scenario: | ||
- **Given** the program: | ||
``` prolog | ||
:- dynamic(parent/2). | ||
|
||
parent(jane, alice). | ||
|
||
assert_fact :- asserta(parent(john, alice)). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
assert_fact, parent(X, alice). | ||
``` | ||
|
||
- **When** the query is run (limited to 2 solutions) | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3977 | ||
answer: | ||
has_more: false | ||
variables: ["X"] | ||
results: | ||
- substitutions: | ||
- variable: X | ||
expression: john | ||
- substitutions: | ||
- variable: X | ||
expression: jane | ||
``` | ||
### Shows a simple counter example | ||
This scenario demonstrates a simple counter example using the `asserta/1` and `retract/1` predicates. | ||
In this example, we represent the value of the counter as a dynamic predicate `counter/1` that is asserted and retracted | ||
to each time the value of the counter is incremented or decremented. | ||
|
||
Here are the steps of the scenario: | ||
|
||
- **Given** the program: | ||
|
||
``` prolog | ||
:- dynamic(counter/1). | ||
counter(0). | ||
increment_counter :- retract(counter(X)), Y is X + 1, asserta(counter(Y)). | ||
decrement_counter :- retract(counter(X)), Y is X - 1, asserta(counter(Y)). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
counter(InitialValue), increment_counter, increment_counter, counter(IncrementedValue), decrement_counter, counter(DecrementedValue). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3989 | ||
answer: | ||
has_more: false | ||
variables: ["InitialValue", "IncrementedValue", "DecrementedValue"] | ||
results: | ||
- substitutions: | ||
- variable: InitialValue | ||
expression: 0 | ||
- variable: IncrementedValue | ||
expression: 2 | ||
- variable: DecrementedValue | ||
expression: 1 | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# assertz/1 | ||
|
||
## Description | ||
|
||
`assertz/1` is a predicate that asserts a clause into the database as the last clause of the predicate. | ||
|
||
## Signature | ||
|
||
```text | ||
assertz(+Clause) | ||
``` | ||
|
||
Where: | ||
|
||
- Clause is the clause to assert into the database. | ||
|
||
## Examples | ||
|
||
### Assert a fact into the database | ||
|
||
This scenario demonstrates the process of asserting a new fact into a Prolog database. In Prolog, asserting a fact means | ||
adding a new piece of information or *knowledge* into the database, allowing it to be referenced in subsequent queries. | ||
This is particularly useful when you want to dynamically extend the knowledge base with facts or rules based on conditions | ||
or interactions during runtime. | ||
|
||
Here are the steps of the scenario: | ||
|
||
- **Given** the program: | ||
|
||
``` prolog | ||
assert_fact :- assertz(father(john, pete)). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
assert_fact, father(X, Y). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3977 | ||
answer: | ||
has_more: false | ||
variables: ["X", "Y"] | ||
results: | ||
- substitutions: | ||
- variable: X | ||
expression: john | ||
- variable: 'Y' | ||
expression: pete | ||
``` | ||
### Only dynamic predicates can be asserted | ||
This scenario demonstrates that only dynamic predicates can be asserted. In Prolog, dynamic predicates are those that can be | ||
modified during runtime. This is in contrast to static predicates, which are fixed and cannot be modified. | ||
Here are the steps of the scenario: | ||
- **Given** the program: | ||
``` prolog | ||
parent(jane, alice). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
assertz(parent(john, alice)). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3975 | ||
answer: | ||
has_more: false | ||
results: | ||
- error: "error(permission_error(modify,static_procedure,parent/2),assertz/1)" | ||
``` | ||
### Show that the fact is asserted at the end of the database | ||
This scenario demonstrates that the assertz/1 predicate adds the fact to the end of the database. This means that | ||
the fact is the last fact to be matched when a query is run. | ||
This is in contrast to the asserta/1 predicate, which adds the fact to the beginning of the database. | ||
Here are the steps of the scenario: | ||
- **Given** the program: | ||
``` prolog | ||
:- dynamic(parent/2). | ||
|
||
parent(jane, alice). | ||
|
||
assert_fact :- assertz(parent(john, alice)). | ||
``` | ||
|
||
- **Given** the query: | ||
|
||
``` prolog | ||
assert_fact, parent(X, alice). | ||
``` | ||
|
||
- **When** the query is run (limited to 2 solutions) | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3977 | ||
answer: | ||
has_more: false | ||
variables: ["X"] | ||
results: | ||
- substitutions: | ||
- variable: X | ||
expression: jane | ||
- substitutions: | ||
- variable: X | ||
expression: john | ||
``` | ||
### Add and remove items in an inventory | ||
This scenario demonstrates how to maintain a dynamic list of items (like in an inventory system) by representing each item | ||
as a fact in the Prolog knowledge base. By using dynamic predicates, we can add items to the inventory and remove them on demand. | ||
Here are the steps of the scenario: | ||
- **Given** the program: | ||
``` prolog | ||
:- dynamic(inventory/1). | ||
|
||
add_item(Item) :- assertz(inventory(Item)). | ||
remove_item(Item) :- retract(inventory(Item)). | ||
``` | ||
|
||
- **And** the query: | ||
|
||
``` prolog | ||
add_item('apple'), | ||
add_item('banana'), | ||
add_item('orange'), | ||
remove_item('banana'), | ||
findall(I, inventory(I), CurrentInventory). | ||
``` | ||
|
||
- **When** the query is run | ||
- **Then** the answer we get is: | ||
|
||
``` yaml | ||
height: 42 | ||
gas_used: 3984 | ||
answer: | ||
has_more: false | ||
variables: ["I","CurrentInventory"] | ||
results: | ||
- substitutions: | ||
- variable: CurrentInventory | ||
expression: "[apple,orange]" | ||
``` |
21 changes: 21 additions & 0 deletions
21
predicates_versioned_docs/version-v11.0.0/atomic_list_concat_2.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
[//]: # (This file is auto-generated. Please do not modify it yourself.) | ||
|
||
# atomic_list_concat/2 | ||
|
||
## Description | ||
|
||
`atomic_list_concat/2` is a predicate that unifies an Atom with the concatenated elements of a List. | ||
|
||
## Signature | ||
|
||
```text | ||
atomic_list_concat(+List, ?Atom) | ||
``` | ||
|
||
where: | ||
|
||
- List is a list of strings, atoms, integers, floating point numbers or non\-integer rationals | ||
- Atom is an Atom representing the concatenation of the elements of List |
Oops, something went wrong.