deep_causality/types/context_node_types/symbol_spacetime/conformal_spacetime/mod.rs
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5
6use std::collections::BTreeSet;
7use std::fmt::Display;
8
9/// A minimal spacetime model preserving only causal and angular structure,
10/// based on conformal geometry.
11///
12/// `ConformalSpacetime` models **causal relationships** (what can influence what)
13/// without assigning meaning to distances or durations. This is useful for:
14/// - **Conformal diagrams** (Penrose diagrams)
15/// - **Asymptotic analysis** (e.g., black hole horizons, AdS boundaries)
16/// - **Symbolic causal inference** when exact metrics are unknown or irrelevant
17///
18/// # Fields
19/// - `id`: Unique identifier for this event or node
20/// - `label`: Optional symbolic annotation (e.g., "i+", "scri−", "origin")
21/// - `causal_links`: IDs of other nodes reachable via causal paths
22///
23/// # Notes
24/// - This type ignores units, curvature, and absolute scale
25/// - It encodes **who can affect whom**, not how or when
26/// - Useful when embedding causal graphs inside bounded spacetime representations
27///
28/// # Example
29/// ```
30/// use deep_causality::*;
31///
32/// let mut n1 = ConformalSpacetime::new(1, Some("Origin".into()));
33/// let mut n2 = ConformalSpacetime::new(2, Some("Infinity".into()));
34///
35/// n1.link_to(2); // n1 can influence n2
36///
37/// assert!(n1.can_affect(2));
38/// ```
39#[derive(Debug, Clone, PartialEq)]
40pub struct ConformalSpacetime {
41 /// Unique identifier for this event
42 pub id: u64,
43
44 /// Optional symbolic label (e.g., "i+", "scri", "horizon")
45 pub label: Option<String>,
46
47 /// Causally reachable nodes (light cone structure only)
48 pub causal_links: std::collections::BTreeSet<u64>,
49}
50
51impl ConformalSpacetime {
52 pub fn new(id: u64, label: Option<String>) -> Self {
53 Self {
54 id,
55 label,
56 causal_links: BTreeSet::new(),
57 }
58 }
59}
60
61impl ConformalSpacetime {
62 /// Adds a forward causal connection (like drawing a light ray)
63 pub fn link_to(&mut self, other_id: u64) {
64 self.causal_links.insert(other_id);
65 }
66
67 /// Checks if this node can causally influence the other node
68 pub fn can_affect(&self, other_id: u64) -> bool {
69 self.causal_links.contains(&other_id)
70 }
71
72 /// Returns number of causal outputs (fanout of light cone)
73 pub fn fanout(&self) -> usize {
74 self.causal_links.len()
75 }
76}
77
78impl Display for ConformalSpacetime {
79 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80 write!(
81 f,
82 "ConformalSpacetime {{ id: {}, label: {:?} }}",
83 self.id, self.label
84 )
85 }
86}