A Discrete Mathematics Python application and interactive web interface for parsing, testing, and visualizing binary relations on a given set
🌐 Live Web Application: https://relations-liart.vercel.app/
The application evaluates fundamental mathematical properties, determines whether a relation is an Equivalence Relation or a Partial Order (Poset), generates adjacency relation matrices, and renders SVG directed graph diagrams.
-
Six Fundamental Relation Properties:
-
Reflexive:
$\forall x \in A, (x, x) \in R$ -
Irreflexive:
$\forall x \in A, (x, x) \notin R$ -
Symmetric:
$\forall x, y \in A, (x, y) \in R \implies (y, x) \in R$ -
Antisymmetric:
$\forall x, y \in A, (x, y) \in R \land (y, x) \in R \implies x = y$ -
Asymmetric:
$\forall x, y \in A, (x, y) \in R \implies (y, x) \notin R$ -
Transitive:
$\forall x, y, z \in A, (x, y) \in R \land (y, z) \in R \implies (x, z) \in R$
-
Reflexive:
-
Separate Classification Cards:
-
Equivalence Relation: Evaluates
$\text{Reflexive} + \text{Symmetric} + \text{Transitive}$ . -
Partial Order (Poset): Evaluates
$\text{Reflexive} + \text{Antisymmetric} + \text{Transitive}$ . - Includes a requirement checklist with green (
✓) and red (✗) indicators for each condition.
-
Equivalence Relation: Evaluates
-
Dynamic Preset Relation Generator:
- Generates relation pairs directly from the elements currently typed in Set A:
-
Equality (
$=$ ): Pairs where$a = b$ . -
Divides (
$\mid$ ): Pairs where$a \mid b$ ($b \bmod a = 0$ ). -
Less than (
$<$ ): Pairs where$a < b$ . -
Greater than (
$>$ ): Pairs where$a > b$ . -
Greater or Equal (
$\ge$ ): Pairs where$a \ge b$ . -
Empty (
$\emptyset$ ): Fills empty relation$R = \emptyset$ .
-
Equality (
- Generates relation pairs directly from the elements currently typed in Set A:
-
Visual Representations:
-
Adjacency Relation Matrix: Grid table showing
$1$ for pairs in$R$ and$0$ otherwise, with highlighted diagonal self-loop cells. - SVG Directed Graph: SVG graph diagram arranging nodes on a circle with directed arrows and curved self-loops.
-
Adjacency Relation Matrix: Grid table showing
-
User Experience & Themes:
-
Live Preview: Formats
$R = {(1,2), (3,1)}$ in real-time as you type flat space-separated pairs. -
Dark & Light Mode: Theme toggle button with
localStoragememory and OS theme detection. - Error Validation: Displays inline warnings for odd element counts or elements not present in set A.
-
Live Preview: Formats
RELATONS/
├── relations.py # Core mathematical parsing & property checking functions
├── app.py # Flask web server, matrix builder, & SVG graph generator
├── main.py # Interactive CLI terminal application
├── test_relations.py # Unit test suite built with Python's unittest module
├── templates/
│ └── index.html # Web app HTML template with theme switcher & live preview JS
├── static/
│ └── style.css # CSS design system supporting Dark & Light themes
├── requirements.txt # Python dependencies for Vercel deployment
├── vercel.json # Vercel serverless build configuration
└── README.md # Project documentation
The app is deployed on Vercel: 👉 https://relations-liart.vercel.app/
Start the local Flask development server:
pip install -r requirements.txt
python app.pyOpen your browser and navigate to http://127.0.0.1:5000.
Run the interactive terminal app:
python main.pyExample terminal interaction:
Enter set A: 1, 2, 3
Enter relation R: 1 1 2 2 3 3 1 2 2 3 1 3
R = {(1,1), (1,2), (1,3), (2,2), (2,3), (3,3)}
-----------------------------------------------------------------
ANALYSIS RESULTS:
- Reflexive: YES
- Irreflexive: NO
- Symmetric: NO
- Antisymmetric: YES
- Asymmetric: NO
- Transitive: YES
Execute the unit test suite built with Python's built-in unittest module:
python test_relations.pyTests cover:
- Equality Relation (
$=$ ) - Strict Order Relation (
$<$ ) - Symmetric Non-Transitive Relation
- Divides Relation (
$\mid$ ) - Empty Relation on Non-Empty Set
- Empty Set (
$A = \emptyset$ ) - Input errors (odd element count, element not in A, duplicate pairs)
- Python: Core logic & algorithms (no external third-party math libraries)
- Flask: Lightweight Web Server
- Vercel: Serverless Cloud Hosting
- HTML5 & Vanilla CSS3: Responsive UI, CSS Variables, Glassmorphism, Dark/Light Mode
- SVG: Pure vector graph rendering
- unittest: Native Python test suite