Skip to content

Commit

Permalink
Add an example for simple boolean logic (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange-42 authored Jul 7, 2024
1 parent 555d3d2 commit a924847
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ jobs:
./bbn inference _examples/logic/bits.yml
./bbn inference _examples/logic/friends.yml
./bbn inference _examples/logic/knights.yml
./bbn inference _examples/logic/simple.yml
./bbn inference _examples/logic/weekday.yml
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

* Adds more documentation and code examples for library usage (#78, #79, #80, #81)
* Adds a decision example for selecting a diagnostic test (#82)
* Adds a binary/decimal converter logic example (#83)
* Adds more logic example (#83, #84)

## [[v0.5.0]](https://github.com/mlange-42/bbn/compare/v0.4.0...v0.5.0)

Expand Down
48 changes: 48 additions & 0 deletions _examples/logic/simple.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Simple boolean logic
info: >-
Example for simple boolean logic operators.
Play with setting the white nodes to some values by clicking the bars.
Observe which combinations of A, B and C result in which outcome of the right-most node.
Also try setting the right-most node's outcome to T (True), and observe which combinations of
A, B and C are valid when you set some of these incoming variables.
variables:

- variable: A
position: [1, 0]
outcomes: [T, F]
table:
- [1, 1]

- variable: B
position: [1, 6]
outcomes: [T, F]
table:
- [1, 1]

- variable: C
position: [1, 12]
outcomes: [T, F]
table:
- [1, 1]

- variable: A and B
position: [33, 3]
color: gray
outcomes: [T, F]
given: [A, B]
logic: and

- variable: "!B and C"
position: [33, 9]
color: gray
outcomes: [T, F]
given: [B, C]
logic: not-and

- variable: (A and B) or (!B and C)
position: [65, 6]
outcomes: [T, F]
given: [A and B, "!B and C"]
logic: or

0 comments on commit a924847

Please sign in to comment.