boolean-algebra-engine 0.1.2__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. boolean_algebra_engine-0.1.3/PKG-INFO +286 -0
  2. boolean_algebra_engine-0.1.3/README.md +240 -0
  3. boolean_algebra_engine-0.1.3/boolean_algebra_engine.egg-info/PKG-INFO +286 -0
  4. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/pyproject.toml +1 -1
  5. boolean_algebra_engine-0.1.2/PKG-INFO +0 -213
  6. boolean_algebra_engine-0.1.2/README.md +0 -167
  7. boolean_algebra_engine-0.1.2/boolean_algebra_engine.egg-info/PKG-INFO +0 -213
  8. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/LICENSE +0 -0
  9. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/api/__init__.py +0 -0
  10. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/api/routes.py +0 -0
  11. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/boolean_algebra_engine.egg-info/SOURCES.txt +0 -0
  12. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/boolean_algebra_engine.egg-info/dependency_links.txt +0 -0
  13. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/boolean_algebra_engine.egg-info/entry_points.txt +0 -0
  14. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/boolean_algebra_engine.egg-info/requires.txt +0 -0
  15. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/boolean_algebra_engine.egg-info/top_level.txt +0 -0
  16. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/cli/__init__.py +0 -0
  17. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/cli/main.py +0 -0
  18. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/core/__init__.py +0 -0
  19. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/core/evaluator.py +0 -0
  20. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/core/models.py +0 -0
  21. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/core/parser.py +0 -0
  22. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/core/synthesizer.py +0 -0
  23. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/mcp_server/__init__.py +0 -0
  24. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/mcp_server/server.py +0 -0
  25. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/nl/__init__.py +0 -0
  26. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/nl/nl.py +0 -0
  27. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/setup.cfg +0 -0
  28. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/tests/test_edge_cases.py +0 -0
  29. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/tests/test_evaluator.py +0 -0
  30. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/tests/test_integration.py +0 -0
  31. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/tests/test_models.py +0 -0
  32. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/tests/test_parser.py +0 -0
  33. {boolean_algebra_engine-0.1.2 → boolean_algebra_engine-0.1.3}/tests/test_synthesizer.py +0 -0
@@ -0,0 +1,286 @@
1
+ Metadata-Version: 2.4
2
+ Name: boolean-algebra-engine
3
+ Version: 0.1.3
4
+ Summary: Deterministic logic layer for AI agents — catch logical contradictions in system prompts, rules, and agent reasoning
5
+ Author-email: Aditya Shrivastava <aditya.shrivastava.architect@proton.me>
6
+ License-Expression: GPL-3.0-only
7
+ Project-URL: Homepage, https://github.com/Shrivastava-Aditya/boolean-algebra-engine-python
8
+ Project-URL: Repository, https://github.com/Shrivastava-Aditya/boolean-algebra-engine-python
9
+ Project-URL: Issues, https://github.com/Shrivastava-Aditya/boolean-algebra-engine-python/issues
10
+ Keywords: boolean,algebra,logic,truth-table,quine-mccluskey,digital-logic
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Education
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: cli
25
+ Requires-Dist: typer>=0.12.0; extra == "cli"
26
+ Requires-Dist: rich>=13.0.0; extra == "cli"
27
+ Provides-Extra: mcp
28
+ Requires-Dist: mcp[cli]>=1.0.0; extra == "mcp"
29
+ Provides-Extra: nl-anthropic
30
+ Requires-Dist: anthropic>=0.50.0; extra == "nl-anthropic"
31
+ Provides-Extra: nl-openai
32
+ Requires-Dist: openai>=1.0.0; extra == "nl-openai"
33
+ Provides-Extra: nl
34
+ Requires-Dist: anthropic>=0.50.0; extra == "nl"
35
+ Provides-Extra: api
36
+ Requires-Dist: fastapi>=0.100.0; extra == "api"
37
+ Requires-Dist: uvicorn>=0.20.0; extra == "api"
38
+ Provides-Extra: api-cache
39
+ Requires-Dist: fastapi>=0.100.0; extra == "api-cache"
40
+ Requires-Dist: uvicorn>=0.20.0; extra == "api-cache"
41
+ Requires-Dist: redis>=5.0.0; extra == "api-cache"
42
+ Provides-Extra: dev
43
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
44
+ Requires-Dist: httpx>=0.24.0; extra == "dev"
45
+ Dynamic: license-file
46
+
47
+ # boolean-algebra-engine
48
+
49
+ **The logic layer your AI is missing.**
50
+
51
+ AI agents hallucinate on boolean logic — not sometimes, reliably. They predict the next token. They don't compute. This engine does. Deterministic, exhaustive, under 10ms. It sits inside your agent pipeline and makes one guarantee the model cannot make itself: that its reasoning is logically consistent.
52
+
53
+ ```bash
54
+ pip install boolean-algebra-engine
55
+ ```
56
+
57
+ ---
58
+
59
+ ## The problem
60
+
61
+ Six rules. Three variables. Written by four people over six months.
62
+
63
+ A fintech AI agent auto-approves or rejects loan applications based on these rules — nobody ever verified them together. The engine checks all 8 input combinations for every rule, in every combination:
64
+
65
+ ```python
66
+ from mcp_server.server import check_prompt_logic
67
+
68
+ result = check_prompt_logic([
69
+ "A.B", # approve: good credit AND income verified
70
+ "C", # approve: collateral exists
71
+ "!A", # reject: bad credit
72
+ "!B.!C", # reject: no income AND no collateral
73
+ "A.B.C", # approve: good credit AND income AND collateral
74
+ "!B", # block: income unverified
75
+ ])
76
+
77
+ print(result["summary"])
78
+ # {'total': 6, 'contradictions': 0, 'tautologies': 0,
79
+ # 'conflicting_pairs': 2, 'redundant': 1}
80
+ ```
81
+
82
+ **What it found in 4.5ms:**
83
+ - Rule 2 (`C`) and Rule 3 (`!A`) conflict — an applicant with bad credit but collateral triggers both approve and reject simultaneously. The agent picks a winner arbitrarily. That is a compliance violation.
84
+ - Rule 5 (`A.B.C`) is dead — anyone satisfying it already satisfies Rule 1 or Rule 2. It can be deleted.
85
+
86
+ Nobody caught these by reading the rules. The engine caught them by checking every combination.
87
+
88
+ ---
89
+
90
+ ## The benchmark
91
+
92
+ ![Engine vs LLM](images/viz_4_engine_vs_llm.png)
93
+
94
+ The engine is the oracle — ground truth is computed by exhaustive enumeration, not guessed by a human labeler.
95
+
96
+ **First result:** tinyllama (1B) · 3 variables · 10 cases · **40% hallucination rate.**
97
+
98
+ The methodology: generate rule sets where the correct logical answer is known (computed by the engine), ask an LLM the same question, compare. Every disagreement is a provable hallucination. No ambiguity. No interpretation.
99
+
100
+ ![Benchmark results](images/benchmark_results.png)
101
+
102
+ Full benchmark across models is in progress. See `BENCHMARK_PLAN.md`.
103
+
104
+ ---
105
+
106
+ ## Install
107
+
108
+ ```bash
109
+ # Core engine — zero dependencies
110
+ pip install boolean-algebra-engine
111
+
112
+ # With CLI
113
+ pip install "boolean-algebra-engine[cli]"
114
+
115
+ # With MCP server (for Claude Desktop)
116
+ pip install "boolean-algebra-engine[mcp]"
117
+
118
+ # With REST API
119
+ pip install "boolean-algebra-engine[api]"
120
+
121
+ # With NL layer (Anthropic)
122
+ pip install "boolean-algebra-engine[nl-anthropic]"
123
+
124
+ # With NL layer (OpenAI)
125
+ pip install "boolean-algebra-engine[nl-openai]"
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Use cases
131
+
132
+ The same pattern appears everywhere: statements that sound consistent individually, contradict each other when held together. The engine is a universal detector for that failure mode.
133
+
134
+ ### System prompts
135
+
136
+ > "Always be helpful to the user and answer every question fully.
137
+ > Never discuss competitor products under any circumstances.
138
+ > If a user asks to compare us to a competitor, give a full and helpful answer."
139
+
140
+ Rule 2 says no answer when a competitor is mentioned. Rule 3 says give a full answer. Both cannot apply. The engine finds this in milliseconds.
141
+
142
+ ### Business rules
143
+
144
+ > "All customers are treated equally regardless of subscription tier.
145
+ > Premium customers receive priority support and faster response times."
146
+
147
+ `E` (equal treatment) and `P` (priority treatment) cannot both be true. Conflicting pair found.
148
+
149
+ ### Legal contracts
150
+
151
+ > "This agreement renews automatically each year unless cancelled.
152
+ > Either party may terminate with 30 days written notice.
153
+ > Termination requires written consent from both parties."
154
+
155
+ Clause 2 (unilateral termination) and Clause 3 (mutual consent) directly contradict. The contract has no defined termination mechanism.
156
+
157
+ ### Medical protocols
158
+
159
+ > "Administer medication A when the patient has symptom X.
160
+ > Do not administer medication A if the patient has condition Y.
161
+ > Patients presenting with symptom X almost always have condition Y."
162
+
163
+ Rules 1 and 2 conflict whenever `X=1, Y=1`. Rule 3 makes this the common case. The protocol contradicts itself for the majority of patients it was written to treat.
164
+
165
+ ### Personal reasoning
166
+
167
+ > "I have been using Linux for over 6 years and Mac for 3 years.
168
+ > If I did not use Linux, I would have never switched to Mac.
169
+ > But my use of Mac has no relation to my use of Linux in any way."
170
+
171
+ - Sentence 3: `!L → !M` — Linux caused the switch to Mac
172
+ - Sentence 4: M and L are independent
173
+
174
+ `L=0, M=1` satisfies sentence 4 but violates sentence 3. Both cannot be true simultaneously. Conflicting pair.
175
+
176
+ More real-world examples across therapy, philosophy, journalism, and AI alignment in `statements.md`.
177
+
178
+ ---
179
+
180
+ ## Core API
181
+
182
+ ```python
183
+ from core.evaluator import evaluate
184
+ from core.synthesizer import synthesize
185
+
186
+ # Forward: expression → truth table
187
+ table, _ = evaluate("A.(B+C)")
188
+ print(table.variables) # ['A', 'B', 'C']
189
+ print(table.minterms) # [5, 6, 7]
190
+ print(table.satisfiable) # True
191
+
192
+ # Inverse: truth table → minimal expression
193
+ minimal, _ = synthesize(table)
194
+ print(minimal) # A.C+A.B
195
+
196
+ # Verification
197
+ from core.evaluator import are_equivalent, check_satisfiable
198
+ print(are_equivalent("A.(B+C)", "A.B+A.C")) # True — distributive law
199
+ ```
200
+
201
+ `core/` has zero external dependencies. Import it into any Python project.
202
+
203
+ ---
204
+
205
+ ## MCP — Claude calls the engine
206
+
207
+ Wire the engine into Claude Desktop and Claude stops predicting boolean logic. It computes it.
208
+
209
+ ```json
210
+ {
211
+ "mcpServers": {
212
+ "boolean-algebra-engine": {
213
+ "command": "python",
214
+ "args": ["-m", "mcp_server.server"]
215
+ }
216
+ }
217
+ }
218
+ ```
219
+
220
+ Five tools Claude can call mid-conversation:
221
+ - `evaluate` — expression → truth table
222
+ - `simplify` — expression → minimal form
223
+ - `equivalent` — are two expressions identical?
224
+ - `satisfiable` — does any input make this true?
225
+ - `check_prompt_logic` — audit a full rule set for contradictions, tautologies, conflicts, duplicates
226
+
227
+ ---
228
+
229
+ ## Visualisations
230
+
231
+ ![Truth table heatmap](images/viz_2_truth_table.png)
232
+
233
+ The Streamlit UI generates two classes of charts automatically from engine output:
234
+
235
+ **Truth table heatmap** — every row rendered as a green/red grid. A contradiction is an entirely red output column. A pattern of minterms becomes visually obvious in one glance.
236
+
237
+ **Conflict matrix** — N×N grid, one cell per rule pair. Red `✗` means always conflict. Green `✓` means no overlap. Yellow `≡` means duplicate rule. Three red cells in a matrix of 6 rules is immediately visible before the user finishes scrolling.
238
+
239
+ ![Failure panel](images/viz_3_failure_panel.png)
240
+
241
+ ---
242
+
243
+ ## Operators
244
+
245
+ | Symbol | Operation | Precedence |
246
+ |--------|-----------|------------|
247
+ | `!` | NOT | 4 (highest) |
248
+ | `.` | AND | 3 |
249
+ | `^` | XOR | 2 |
250
+ | `+` | OR | 1 (lowest) |
251
+
252
+ Variables: uppercase `A`–`Z`. Parentheses override precedence. Up to 26 variables, arbitrary nesting.
253
+
254
+ ---
255
+
256
+ ## Interfaces
257
+
258
+ | Interface | How |
259
+ |---|---|
260
+ | **Python library** | `from core.evaluator import evaluate` — embed in any project |
261
+ | **CLI / REPL** | `boolcalc "A.B+!A.C"` — instant truth table in terminal |
262
+ | **MCP server** | Claude Desktop plugin — plug and play |
263
+ | **REST API** | `POST /check-rules` — callable from any language or stack |
264
+ | **NL layer** | Plain English → expression → verified result (Anthropic, OpenAI, Ollama, any OpenAI-compat) |
265
+ | **Streamlit UI** | Three modes: Expression, Rule Auditor, Plain English |
266
+
267
+ ---
268
+
269
+ ## Credibility
270
+
271
+ The engine does not sample, approximate, or predict. It evaluates every possible input combination:
272
+
273
+ - **Satisfiable** — an actual row where output = 1 was found
274
+ - **Contradiction** — every row was checked, all were 0
275
+ - **Equivalent** — output columns compared row-by-row across the full truth table
276
+ - **Conflict** — conjunction of both rules evaluated for every input, always returned 0
277
+
278
+ The core evaluator is 15 lines (`core/evaluator.py`). No black box, no model weights, no probability — just arithmetic. This is a stronger correctness claim than any probabilistic tool can make.
279
+
280
+ 90 tests across unit, integration, edge cases, and round-trips. All passing.
281
+
282
+ ---
283
+
284
+ ## Related
285
+
286
+ - [boolean-algebra-java](https://github.com/Shrivastava-Aditya/boolean-algebra-java) — original Java version, written during placement season
@@ -0,0 +1,240 @@
1
+ # boolean-algebra-engine
2
+
3
+ **The logic layer your AI is missing.**
4
+
5
+ AI agents hallucinate on boolean logic — not sometimes, reliably. They predict the next token. They don't compute. This engine does. Deterministic, exhaustive, under 10ms. It sits inside your agent pipeline and makes one guarantee the model cannot make itself: that its reasoning is logically consistent.
6
+
7
+ ```bash
8
+ pip install boolean-algebra-engine
9
+ ```
10
+
11
+ ---
12
+
13
+ ## The problem
14
+
15
+ Six rules. Three variables. Written by four people over six months.
16
+
17
+ A fintech AI agent auto-approves or rejects loan applications based on these rules — nobody ever verified them together. The engine checks all 8 input combinations for every rule, in every combination:
18
+
19
+ ```python
20
+ from mcp_server.server import check_prompt_logic
21
+
22
+ result = check_prompt_logic([
23
+ "A.B", # approve: good credit AND income verified
24
+ "C", # approve: collateral exists
25
+ "!A", # reject: bad credit
26
+ "!B.!C", # reject: no income AND no collateral
27
+ "A.B.C", # approve: good credit AND income AND collateral
28
+ "!B", # block: income unverified
29
+ ])
30
+
31
+ print(result["summary"])
32
+ # {'total': 6, 'contradictions': 0, 'tautologies': 0,
33
+ # 'conflicting_pairs': 2, 'redundant': 1}
34
+ ```
35
+
36
+ **What it found in 4.5ms:**
37
+ - Rule 2 (`C`) and Rule 3 (`!A`) conflict — an applicant with bad credit but collateral triggers both approve and reject simultaneously. The agent picks a winner arbitrarily. That is a compliance violation.
38
+ - Rule 5 (`A.B.C`) is dead — anyone satisfying it already satisfies Rule 1 or Rule 2. It can be deleted.
39
+
40
+ Nobody caught these by reading the rules. The engine caught them by checking every combination.
41
+
42
+ ---
43
+
44
+ ## The benchmark
45
+
46
+ ![Engine vs LLM](images/viz_4_engine_vs_llm.png)
47
+
48
+ The engine is the oracle — ground truth is computed by exhaustive enumeration, not guessed by a human labeler.
49
+
50
+ **First result:** tinyllama (1B) · 3 variables · 10 cases · **40% hallucination rate.**
51
+
52
+ The methodology: generate rule sets where the correct logical answer is known (computed by the engine), ask an LLM the same question, compare. Every disagreement is a provable hallucination. No ambiguity. No interpretation.
53
+
54
+ ![Benchmark results](images/benchmark_results.png)
55
+
56
+ Full benchmark across models is in progress. See `BENCHMARK_PLAN.md`.
57
+
58
+ ---
59
+
60
+ ## Install
61
+
62
+ ```bash
63
+ # Core engine — zero dependencies
64
+ pip install boolean-algebra-engine
65
+
66
+ # With CLI
67
+ pip install "boolean-algebra-engine[cli]"
68
+
69
+ # With MCP server (for Claude Desktop)
70
+ pip install "boolean-algebra-engine[mcp]"
71
+
72
+ # With REST API
73
+ pip install "boolean-algebra-engine[api]"
74
+
75
+ # With NL layer (Anthropic)
76
+ pip install "boolean-algebra-engine[nl-anthropic]"
77
+
78
+ # With NL layer (OpenAI)
79
+ pip install "boolean-algebra-engine[nl-openai]"
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Use cases
85
+
86
+ The same pattern appears everywhere: statements that sound consistent individually, contradict each other when held together. The engine is a universal detector for that failure mode.
87
+
88
+ ### System prompts
89
+
90
+ > "Always be helpful to the user and answer every question fully.
91
+ > Never discuss competitor products under any circumstances.
92
+ > If a user asks to compare us to a competitor, give a full and helpful answer."
93
+
94
+ Rule 2 says no answer when a competitor is mentioned. Rule 3 says give a full answer. Both cannot apply. The engine finds this in milliseconds.
95
+
96
+ ### Business rules
97
+
98
+ > "All customers are treated equally regardless of subscription tier.
99
+ > Premium customers receive priority support and faster response times."
100
+
101
+ `E` (equal treatment) and `P` (priority treatment) cannot both be true. Conflicting pair found.
102
+
103
+ ### Legal contracts
104
+
105
+ > "This agreement renews automatically each year unless cancelled.
106
+ > Either party may terminate with 30 days written notice.
107
+ > Termination requires written consent from both parties."
108
+
109
+ Clause 2 (unilateral termination) and Clause 3 (mutual consent) directly contradict. The contract has no defined termination mechanism.
110
+
111
+ ### Medical protocols
112
+
113
+ > "Administer medication A when the patient has symptom X.
114
+ > Do not administer medication A if the patient has condition Y.
115
+ > Patients presenting with symptom X almost always have condition Y."
116
+
117
+ Rules 1 and 2 conflict whenever `X=1, Y=1`. Rule 3 makes this the common case. The protocol contradicts itself for the majority of patients it was written to treat.
118
+
119
+ ### Personal reasoning
120
+
121
+ > "I have been using Linux for over 6 years and Mac for 3 years.
122
+ > If I did not use Linux, I would have never switched to Mac.
123
+ > But my use of Mac has no relation to my use of Linux in any way."
124
+
125
+ - Sentence 3: `!L → !M` — Linux caused the switch to Mac
126
+ - Sentence 4: M and L are independent
127
+
128
+ `L=0, M=1` satisfies sentence 4 but violates sentence 3. Both cannot be true simultaneously. Conflicting pair.
129
+
130
+ More real-world examples across therapy, philosophy, journalism, and AI alignment in `statements.md`.
131
+
132
+ ---
133
+
134
+ ## Core API
135
+
136
+ ```python
137
+ from core.evaluator import evaluate
138
+ from core.synthesizer import synthesize
139
+
140
+ # Forward: expression → truth table
141
+ table, _ = evaluate("A.(B+C)")
142
+ print(table.variables) # ['A', 'B', 'C']
143
+ print(table.minterms) # [5, 6, 7]
144
+ print(table.satisfiable) # True
145
+
146
+ # Inverse: truth table → minimal expression
147
+ minimal, _ = synthesize(table)
148
+ print(minimal) # A.C+A.B
149
+
150
+ # Verification
151
+ from core.evaluator import are_equivalent, check_satisfiable
152
+ print(are_equivalent("A.(B+C)", "A.B+A.C")) # True — distributive law
153
+ ```
154
+
155
+ `core/` has zero external dependencies. Import it into any Python project.
156
+
157
+ ---
158
+
159
+ ## MCP — Claude calls the engine
160
+
161
+ Wire the engine into Claude Desktop and Claude stops predicting boolean logic. It computes it.
162
+
163
+ ```json
164
+ {
165
+ "mcpServers": {
166
+ "boolean-algebra-engine": {
167
+ "command": "python",
168
+ "args": ["-m", "mcp_server.server"]
169
+ }
170
+ }
171
+ }
172
+ ```
173
+
174
+ Five tools Claude can call mid-conversation:
175
+ - `evaluate` — expression → truth table
176
+ - `simplify` — expression → minimal form
177
+ - `equivalent` — are two expressions identical?
178
+ - `satisfiable` — does any input make this true?
179
+ - `check_prompt_logic` — audit a full rule set for contradictions, tautologies, conflicts, duplicates
180
+
181
+ ---
182
+
183
+ ## Visualisations
184
+
185
+ ![Truth table heatmap](images/viz_2_truth_table.png)
186
+
187
+ The Streamlit UI generates two classes of charts automatically from engine output:
188
+
189
+ **Truth table heatmap** — every row rendered as a green/red grid. A contradiction is an entirely red output column. A pattern of minterms becomes visually obvious in one glance.
190
+
191
+ **Conflict matrix** — N×N grid, one cell per rule pair. Red `✗` means always conflict. Green `✓` means no overlap. Yellow `≡` means duplicate rule. Three red cells in a matrix of 6 rules is immediately visible before the user finishes scrolling.
192
+
193
+ ![Failure panel](images/viz_3_failure_panel.png)
194
+
195
+ ---
196
+
197
+ ## Operators
198
+
199
+ | Symbol | Operation | Precedence |
200
+ |--------|-----------|------------|
201
+ | `!` | NOT | 4 (highest) |
202
+ | `.` | AND | 3 |
203
+ | `^` | XOR | 2 |
204
+ | `+` | OR | 1 (lowest) |
205
+
206
+ Variables: uppercase `A`–`Z`. Parentheses override precedence. Up to 26 variables, arbitrary nesting.
207
+
208
+ ---
209
+
210
+ ## Interfaces
211
+
212
+ | Interface | How |
213
+ |---|---|
214
+ | **Python library** | `from core.evaluator import evaluate` — embed in any project |
215
+ | **CLI / REPL** | `boolcalc "A.B+!A.C"` — instant truth table in terminal |
216
+ | **MCP server** | Claude Desktop plugin — plug and play |
217
+ | **REST API** | `POST /check-rules` — callable from any language or stack |
218
+ | **NL layer** | Plain English → expression → verified result (Anthropic, OpenAI, Ollama, any OpenAI-compat) |
219
+ | **Streamlit UI** | Three modes: Expression, Rule Auditor, Plain English |
220
+
221
+ ---
222
+
223
+ ## Credibility
224
+
225
+ The engine does not sample, approximate, or predict. It evaluates every possible input combination:
226
+
227
+ - **Satisfiable** — an actual row where output = 1 was found
228
+ - **Contradiction** — every row was checked, all were 0
229
+ - **Equivalent** — output columns compared row-by-row across the full truth table
230
+ - **Conflict** — conjunction of both rules evaluated for every input, always returned 0
231
+
232
+ The core evaluator is 15 lines (`core/evaluator.py`). No black box, no model weights, no probability — just arithmetic. This is a stronger correctness claim than any probabilistic tool can make.
233
+
234
+ 90 tests across unit, integration, edge cases, and round-trips. All passing.
235
+
236
+ ---
237
+
238
+ ## Related
239
+
240
+ - [boolean-algebra-java](https://github.com/Shrivastava-Aditya/boolean-algebra-java) — original Java version, written during placement season