Antifragile
A Rust library attempting to implement Nassim Nicholas Taleb's antifragility theory.
Overview
This library provides a trait-based system for analyzing how systems respond to stress and volatility, classifying them into three categories:
- Antifragile: Benefits from volatility (convex response)
- Fragile: Harmed by volatility (concave response)
- Robust: Unaffected by volatility (linear response)
Installation
[]
= "0.0.1"
Quick Start
use ;
// Define a system with convex response (benefits from volatility)
;
let system = ConvexSystem;
assert_eq!;
Core Concepts
The Antifragile Trait
Implement the Antifragile trait to define how your system responds to stress:
use Antifragile;
;
The Triad Classification
The Triad enum represents the three categories:
use Triad;
let classification = Antifragile;
// Check classification
assert!;
// Ordering: Fragile < Robust < Antifragile
assert!;
assert!;
// Convert to/from strings
let s: &str = classification.into; // "antifragile"
let parsed: Triad = "robust".parse.unwrap;
// Convert to/from u8 (Fragile=0, Robust=1, Antifragile=2)
let n: u8 = classification.into; // 2
let from_n = try_from.unwrap; // Triad::Robust
The Verified Wrapper
Use Verified to wrap a system with its verified classification:
use ;
;
let verified = check;
println!;
Mathematical Foundation
The classification is based on second-order effects (convexity):
For a payoff function f(x) at operating point x with perturbation δ:
- Convex (Antifragile): f(x+δ) + f(x-δ) > 2·f(x)
- Concave (Fragile): f(x+δ) + f(x-δ) < 2·f(x)
- Linear (Robust): f(x+δ) + f(x-δ) = 2·f(x)
This is Jensen's inequality applied to volatility.
When to Use This Library
Good fit:
- Analyzing financial instruments (options, insurance)
- Evaluating system resilience in chaos engineering
- Comparing algorithms under varying load
- Educational purposes (demonstrating Taleb's theory)
Not a good fit:
- Real-time trading decisions (too abstract)
- Systems where "stress" is not mathematically quantifiable
- Cases requiring probabilistic analysis (use Monte Carlo instead)
Feature Flags
| Feature | Default | Description |
|---|---|---|
std |
Yes | Enable standard library support. Disable for no_std environments. |
serde |
No | Enable serialization/deserialization for Triad and Verified. |
Using in no_std environments
[]
= { = "0.0.1", = false }
Enabling serde support
[]
= { = "0.0.1", = ["serde"] }
Minimum Supported Rust Version
This crate requires Rust 1.85 or later (edition 2024).
License
Licensed under the MIT License. See LICENSE for details.