Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bswck/brahmagupta


https://github.com/bswck/brahmagupta

Last synced: 23 days ago
JSON representation

Awesome Lists containing this project

README

        

# brahmagupta

Coding @ birthday.

This project is an attempt to re-design my previous try at solving the "high school math deduction" problem.
Given a set of known facts and a well-described goal, we need to find all the possible scenarios of coming to the solution, which we usually don't know much about.

That kind of deduction is what we are taught at school, but still happen to have problems with.
This project aims to answer why, and, more importantly, consider the question:

> Can high school math be entirely solved without heuristics?

## Examples

### Query 1. Combinatorics.

For instance, imagine this exam problem:

> Let's consider all natural numbers in which no digit repeats, exactly three digits are odd, and exactly two digits are even. Find the number of such numbers.

Here, we have a precisely described outcome: a natural integer that represents the number of all natural numbers matching the constraints that are:
- no digit in the number repeats,
- 3 digits ONLY are odd,
- 2 digits ONLY are even.

Trying to solve this problem 100% by machine, we need to serialize it in a machine-understandable way.
How about:

```py
op.len(
sets.natural.where.all(
op.none(digit.seen for digit in digits),
op.len(digits.filter("% 2")) == 3,
op.len(digits.filterfalse("% 2")) == 2,
),
)
```

This description of the problem arises from the following assumptions:
- Digits of the number are finite.
- All odd numbers fulfill the `k % 2` constraint, where `k` is the number in question.
- All even numbers fulfill the `not (k % 2)` constraint, where `k` is the number in question.

More to come in this description later.

#### Machine Digestion of the Query

The machine can simply identify the nature of the problem.

- The first conclusion it should draw is that all the numbers are computable,
they are finite, and we can fit all of them in memory.

- The number of digits is always 5 because sets `filter("% 2")` and `filterfalse("% 2")` make up the whole number and their expected lengths add up to 5.

Similar conclusions could also be drawn from more complex set of constraints, for instance

```py
op.len(
sets.natural.where.all(
op.any(
op.all(
op.len(digits.filter("% 2")) == 3,
op.len(digits.filterfalse("% 2")) == 3,
),
op.all(
op.len(digits.filter("% 2")) == 6,
op.len(digits.filterfalse("% 2")) == 6,
),
),
),
)
```

absolutely implies that the number of digits must be either 6 (3 odd + 3 even) or 12 (6 odd + 6 even).

## Guidelines

We are bounded to implementing [concepts included in the core curriculum for general secondary schools of Poland](https://cke.gov.pl/images/_EGZAMIN_MATURALNY_OD_2023/podstawa_programowa/matematyka.pdf) (PL).
This library ought to treat the curriculum as a reference standard and every logical unit providing new functionality should reference the proper part of that document to prove its compliance with the "standard".