Skip to content

Commit e7e75ef

Browse files
committed
feat(logic): implement comprehensive boolean simplification rules
- Added absorption rules for conjunction and disjunction: - A ∧ (A ∨ B) → A - A ∨ (A ∧ B) → A - Implemented idempotence, complementation, identity, domination, and double negation simplifications. - Updated logic-utils.ts with new functions for absorption. - Enhanced logic.test.ts with extensive tests for all new simplification rules.
1 parent dc3482c commit e7e75ef

5 files changed

Lines changed: 441 additions & 117 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@
281281
This uses u-substitution: since `1/x = d/dx(ln(x))`, the integral becomes
282282
`∫ h'(x)/h(x) dx = ln|h(x)|`.
283283

284+
#### Logic
285+
286+
- **Boolean Simplification Rules**: Added absorption laws and improved boolean
287+
expression simplification:
288+
- **Absorption**: `A ∧ (A ∨ B) → A` and `A ∨ (A ∧ B) → A`
289+
- **Idempotence**: `A ∧ A → A` and `A ∨ A → A`
290+
- **Complementation**: `A ∧ ¬A → False` and `A ∨ ¬A → True`
291+
- **Identity**: `A ∧ True → A` and `A ∨ False → A`
292+
- **Domination**: `A ∧ False → False` and `A ∨ True → True`
293+
- **Double negation**: `¬¬A → A`
294+
295+
These rules are applied automatically during simplification:
296+
```javascript
297+
ce.box(['And', 'A', ['Or', 'A', 'B']]).simplify(); // → A
298+
ce.box(['Or', 'A', ['And', 'A', 'B']]).simplify(); // → A
299+
```
300+
284301
#### Linear Algebra
285302

286303
- **Matrix Decompositions**: Added four matrix decomposition functions for

requirements/DONE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,51 @@ ce.box(['Eigen', ['List', ['List', 4, 2], ['List', 1, 3]]]).evaluate();
435435

436436
---
437437

438+
## Logic Enhancements (Completed)
439+
440+
### L-1. Logic Simplification Rules ✅
441+
442+
**IMPLEMENTED:** Added comprehensive boolean simplification rules:
443+
444+
1. **Absorption** (NEW):
445+
- `A ∧ (A ∨ B) → A`
446+
- `A ∨ (A ∧ B) → A`
447+
448+
2. **Idempotence** (already implemented):
449+
- `A ∧ A → A`
450+
- `A ∨ A → A`
451+
452+
3. **Complementation** (already implemented):
453+
- `A ∧ ¬A → False`
454+
- `A ∨ ¬A → True`
455+
456+
4. **Identity** (already implemented):
457+
- `A ∧ True → A`
458+
- `A ∨ False → A`
459+
460+
5. **Domination** (already implemented):
461+
- `A ∧ False → False`
462+
- `A ∨ True → True`
463+
464+
6. **Double negation** (already implemented via involution):
465+
- `¬¬A → A`
466+
467+
**Examples:**
468+
```typescript
469+
ce.box(['And', 'A', ['Or', 'A', 'B']]).simplify(); // → A
470+
ce.box(['Or', 'A', ['And', 'A', 'B']]).simplify(); // → A
471+
ce.box(['And', 'A', 'A']).simplify(); // → A
472+
ce.box(['And', 'A', ['Not', 'A']]).simplify(); // → False
473+
ce.box(['Or', 'A', ['Not', 'A']]).simplify(); // → True
474+
ce.box(['Not', ['Not', 'A']]).simplify(); // → A
475+
```
476+
477+
**Files modified:**
478+
- `src/compute-engine/library/logic-utils.ts` - Added `applyAbsorptionAnd` and `applyAbsorptionOr` functions
479+
- `test/compute-engine/logic.test.ts` - Added "Logic Simplification Rules" describe block with 18 new tests
480+
481+
---
482+
438483
## Medium Priority (Completed)
439484

440485
### 9. Implicit Multiplication Between `\exp` Function Calls ✅

0 commit comments

Comments
 (0)