gaia.core.fuzzy module

Module: fuzzy Implements fuzzy sets and fuzzy simplicial sets for the GAIA framework.

Following Spivak’s theory and Mahadevan (2024), this implements: 1. Fuzzy sets as sheaves on the unit interval I=[0,1] 2. Morphisms preserving membership strengths 3. Fuzzy simplicial sets as functors S: Δᵒᵖ → Fuz 4. Membership coherence constraints 5. Strength preservation by degeneracies

Key principles: 1. Fuzzy sets are sheaves with injective restriction maps 2. Membership functions η: X → [0,1] define classical fuzzy sets 3. Morphisms preserve membership: ξ(f(x)) ≥ η(x) 4. Fuzzy simplicial sets generalize weighted graphs to higher-order relations

class gaia.core.fuzzy.FuzzySet(elements, membership_function, name='')[source]

Bases: object

Fuzzy set as sheaf on unit interval I=[0,1].

Following Definition 2.1 from the theoretical framework: - Sheaf on I=[0,1] with injective restriction maps - Equivalent to classical fuzzy set (X,η) where η: X→[0,1] - Morphisms preserve membership strengths

elements: Set[Any]
membership_function: Callable[[Any], float]
name: str
id: UUID
__post_init__()[source]

Validate membership function values are in [0,1].

membership(element)[source]

Get membership strength of element.

support(threshold=0.0)[source]

Get support set with membership > threshold.

alpha_cut(alpha)[source]

Get α-cut: {x ∈ X | η(x) ≥ α}.

height()[source]

Get height: max membership value.

is_normal()[source]

Check if fuzzy set is normal (height = 1.0).

__init__(elements, membership_function, name='')
class gaia.core.fuzzy.FuzzySetMorphism(source, target, mapping, name='')[source]

Bases: object

Morphism between fuzzy sets preserving membership strengths.

For f: (X,η) → (Y,ξ), requires ξ(f(x)) ≥ η(x) for all x ∈ X.

__init__(source, target, mapping, name='')[source]
apply(element)[source]

Apply morphism to element.

__call__(element)[source]

Make morphism callable.

class gaia.core.fuzzy.FuzzyCategory(name='Fuz')[source]

Bases: object

Category Fuz of fuzzy sets with membership-preserving morphisms.

Objects: Fuzzy sets Morphisms: Membership-preserving functions

__init__(name='Fuz')[source]
add_object(fuzzy_set)[source]

Add fuzzy set as object.

add_morphism(morphism)[source]

Add morphism between fuzzy sets.

compose(f_id, g_id)[source]

Compose morphisms g ∘ f.

identity(obj_id)[source]

Get identity morphism for object.

class gaia.core.fuzzy.FuzzySimplicialSet(name, dimension, fuzzy_sets=<factory>, face_maps=<factory>, degeneracy_maps=<factory>)[source]

Bases: object

Fuzzy simplicial set as contravariant functor S: Δᵒᵖ → Fuz.

Following Section 2.3 of the theoretical framework: - Maps each [n] ∈ Δ to fuzzy set S_n - Face maps preserve membership coherence - Degeneracies preserve strength - Generalizes weighted graphs to higher-order relations

name: str
dimension: int
fuzzy_sets: Dict[int, FuzzySet]
face_maps: Dict[Tuple[int, int], FuzzySetMorphism]
degeneracy_maps: Dict[Tuple[int, int], FuzzySetMorphism]
id: UUID
__post_init__()[source]

Initialize empty fuzzy sets for each dimension if not provided.

add_simplex(level, simplex, membership)[source]

Add simplex with membership strength.

get_membership(level, simplex)[source]

Get membership strength of simplex at level.

add_face_map(source_level, target_level, face_index, mapping)[source]

Add face map δᵢ: S_{n-1} → S_n.

add_degeneracy_map(source_level, target_level, deg_index, mapping)[source]

Add degeneracy map σᵢ: S_{n+1} → S_n.

verify_membership_coherence()[source]

Verify membership coherence: strength of simplex ≤ min(strength of faces).

For each n-simplex σ, check that membership(σ) ≤ min(membership(∂ᵢσ))

verify_degeneracy_preservation()[source]

Verify degeneracies preserve strength.

__init__(name, dimension, fuzzy_sets=<factory>, face_maps=<factory>, degeneracy_maps=<factory>)
class gaia.core.fuzzy.FuzzySimplicialFunctor(name, fuzzy_category)[source]

Bases: object

Contravariant functor S: Δᵒᵖ → Fuz mapping simplicial category to fuzzy sets.

This extends SimplicialFunctor to work with fuzzy sets instead of classical sets.

__init__(name, fuzzy_category)[source]
add_fuzzy_simplicial_set(fss)[source]

Add fuzzy simplicial set.

natural_transformation(source_id, target_id)[source]

Get natural transformation between fuzzy simplicial sets.

verify_functoriality(fss_id)[source]

Verify functor laws for fuzzy simplicial set.

gaia.core.fuzzy.create_discrete_fuzzy_set(elements_with_membership, name='')[source]

Create fuzzy set from discrete elements with membership values.

gaia.core.fuzzy.create_gaussian_fuzzy_set(center, sigma, domain, name='')[source]

Create Gaussian fuzzy set over continuous domain.

gaia.core.fuzzy.create_triangular_fuzzy_set(a, b, c, domain, name='')[source]

Create triangular fuzzy set with parameters (a, b, c).

class gaia.core.fuzzy.TConorm[source]

Bases: object

T-conorm operations for merging fuzzy simplicial sets.

static maximum(a, b)[source]

Maximum t-conorm: T(a,b) = max(a,b).

static algebraic_sum(a, b)[source]

Algebraic sum t-conorm: T(a,b) = a + b - ab.

static bounded_sum(a, b)[source]

Bounded sum t-conorm: T(a,b) = min(1, a + b).

static drastic_sum(a, b)[source]

Drastic sum t-conorm.

gaia.core.fuzzy.merge_fuzzy_simplicial_sets(fss1, fss2, t_conorm=TConorm.maximum, name='')[source]

Merge two fuzzy simplicial sets using t-conorm.

This implements step (F4) of the UMAP-adapted pipeline.