Non-Archimedean Syntactic Paradigm for Physics
author: Rowan Brad Quni-Gudzinas
ORCID: 0009-0002-4317-5604
ISNI: 0000000526456062
title: A Non-Archimedean Syntactic Paradigm for Physics
aliases:
- A Non-Archimedean Syntactic Paradigm for Physics
modified: 2026-04-16T00:15:49Z
Author: Rowan Brad Quni-Gudzinas
Contact: [email protected]
ORCID: 0009-0002-4317-5604
ISNI: 0000000526456062
Date: 2026-04-16
Version: 1.0
Abstract: The prevailing paradigm in modern physics assumes that the universe operates over continuous, Archimedean geometries, leading directly to the widespread belief that quantum information is intrinsically fragile. By projecting fundamentally discrete quantum states onto smooth vector spaces, standard theoretical models introduce artificial linear error accumulation and irreconcilable mathematical singularities. To resolve these paradoxes, this formalizes the Syntactic Token Calculus (STC), an extreme minimalist mathematical framework built strictly upon marks and topological enclosures. This topological refoundation mechanically proves that quantum fragility is merely a coordinate mismatch, offering a geometric solution to the devastating thermodynamic walls currently halting quantum computing scalability. The conversion of these syntactic properties into continuous real observables via the Monna map projection proves that smooth relativistic spacetime is merely a coarse-grained shadow of a rigidly structured, computational cosmos.
Keywords: Syntactic Token Calculus, Non-Archimedean Geometry, Bruhat-Tits Tree, Quantum Error Correction, Discrete Scale Invariance, Monna Map, Ultrametric Topology
1.0 Introduction: The Archimedean Crisis and the Syntactic Paradigm
1.1 Context and Motivation: The Fragility Illusion
The prevailing assumption in contemporary quantum mechanics dictates that quantum information is intrinsically fragile and highly susceptible to environmental degradation. This fragility necessitates complex, resource-intensive error-correction protocols to maintain coherence. However, this apparent fragility is not a fundamental ontological property of the quantum state itself, but an artifact of the mathematical framework used to describe it. Specifically, the projection of discrete, topological quantum states onto continuous, Archimedean vector spaces introduces artificial linear error accumulation (Quni-Gudzinas, 2026b). By enforcing a continuous geometric representation upon a fundamentally discrete reality, standard methodologies break the natural boundary symmetries that would otherwise protect quantum information. The Syntactic Token Calculus (STC) challenges this paradigm by proposing that reality operates strictly through non-Archimedean, discrete topological boundaries. Consequently, observed decoherence is merely a coordinate mismatch between our continuous measurement tools and the discrete, ultrametric nature of the universe (Zúñiga-Galindo, 2023a).
1.2 The Limits of the Continuum
Smooth manifolds inevitably yield singularities at extreme energy scales, causing perturbative quantum gravity to fail due to non-renormalizable infinities (Calcagni, 2017). String theory and Loop Quantum Gravity attempt discretization but retain continuous backgrounds. The continuum hypothesis allows unphysical short-distance fluctuations, demanding ad-hoc cutoffs (Dragovich, 2003). A fundamentally discrete topology is required for consistent quantum gravity.
1.3 Literature Review: p-Adic Quantum Mechanics
Early p-adic mechanics established the mathematical viability of ultrametric states (Khrennikov, 1997). Adelic formulations successfully integrated real and p-adic numbers (Dragovich, 2003), while trace class operators in p-adic QM demonstrated robust structural properties (Aniello, Mancini, & Parisi, 2023). Infinite potential wells behave uniquely in p-adic environments (Zúñiga-Galindo, 2024). The STC bridges this gap by grounding p-adic geometry in primitive syntax (Quni-Gudzinas, 2026a).
1.4 The Thermodynamic Wall in Quantum Computing
Surface codes require massive physical-to-logical qubit overheads, leading to the thermodynamic wall that strictly limits the scaling of continuous-gate processors (Quni-Gudzinas, 2025b). Passive topological architectures present the only viable path to large-scale quantum computation. Ultrametricity offers a native geometric solution to this scaling crisis.
1.5 Introduction to the Syntactic Token Calculus (STC)
Reality can be modeled as a sequence of discrete boundary distinctions. The mark (#) represents the primitive quantum of existence, while the enclosure ([ ]) establishes hierarchical depth and isolated regions (Quni-Gudzinas, 2026a). All logical and physical complexity emerges from combinations of these two gestures. The STC maps perfectly to the topology of the Bruhat-Tits tree.
1.6 Identified Gaps and The Archimedean Tension
Current models fail to bridge abstract p-adic math to real MeV values. Standard approaches cannot resolve the Z/Higgs degeneracy natively (Aniello, Mancini, & Parisi, 2023). DSI log-periodic oscillations lack structured empirical validation. Thermodynamic walls block QC scaling. Macro-ledger connections to 3D spacetime are missing. Heavy generation taxonomies are incomplete. Cross-disciplinary cognitive analogies remain loosely defined (Khrennikov, 1997).
1.7 Thesis Statement and Blueprint Roadmap
Quantum information is robust; Archimedean measurement makes it appear fragile. The universe operates on discrete syntactic rules over an ultrametric tree (Quni-Gudzinas, 2026b). This manuscript outlines the theoretical calculus, derives cosmological observables, classifies the Standard Model, applies the theory to quantum computing, and discusses ontological implications.
2.0 Theoretical Framework: The Syntactic Token Calculus
2.1 The Primitives of Existence: Marks and Enclosures
The mark (#) is the primitive binary boundary, while the enclosure ([ ]) creates isolated topological regions (Quni-Gudzinas, 2026a). Juxtaposition represents co-location and associativity. The void is strictly the absence of tokens. This avoidance of algebraic variables forces absolute geometric determinism.
2.2 The Reduction Rules: Calling and Crossing
Calling (## → #) represents the condensation of redundant states. Crossing ([[A]] → A) represents the cancellation of double boundaries. The STC explicitly rejects modified crossing rules to maintain purity, resulting in [[#]] reducing to # and forcing the mark to act as the syntactic point at infinity (Quni-Gudzinas, 2026a).
2.3 Syntactic Normal Forms and Confluence
A normal form is an expression where no reduction rules apply. The STC rewrite system is provably terminating and confluent. Unique normal forms serve as the canonical representatives of equivalence classes, structurally identical to elementary particles.
2.4 The Master Invariant: Syntactic Cross-Ratio
The arrangement [ [ A B ] [ C D ] ] acts as a syntactic cross-ratio. Physical properties are derived by comparing a particle against references: blank, #, and [#] (Torresblanca-Badillo, 2026). Mass, charge, and spin correspond to specific slot permutations of this double enclosure.
2.5 Projective Geometry on the Bruhat-Tits Tree
The Bruhat-Tits tree is the universal state space for the STC (Ludwig & Merten, 2025). Expressions map to paths and vertices on this infinite, $p+1$ regular tree (Zinoviev, 1990). The tree natively enforces the strong triangle inequality, with discrete scale invariance embedded in its self-similarity (Zabrodin, 1989).
2.6 The Adelic Principle and the Monna Map
The Monna map projects p-adic coordinates onto the real line, acting as a continuous coarse-graining of discrete syntactic reality (Koblitz, 1984). The quantitative bridge to MeV relies on calibrating this specific Monna projection.
2.7 Algorithmic Implementation: Syntactic Reality Engine (SRE)
A proposed Syntactic Reality Engine (SRE) would automate parsing and normal form reduction, guaranteeing confluence by systematic scanning. The SRE provides the foundation for future p-adic quantum circuit simulators.
3.0 Cosmological Results: Discrete Scale Invariance and the CMB
3.1 The Bruhat-Tits Tree as Universal State Space
The universe is a single, static expression on the Bruhat-Tits tree. Cosmological scale maps to tree depth from the root. Expansion is modeled as the sequential addition of nesting layers, appearing continuous only via coarse-graining.
3.2 The Hawking-Hubble and Planck Temperature Midpoint
Treating the Hubble sphere as a horizon yields the Hawking-Hubble temperature (Sornette, 1998). The measured CMB temperature (2.725 K) occupies an intermediate, thermodynamically stable depth between the Planck scale and the current horizon.
3.3 Haug & Tatum’s Geometric Mean as a Logarithmic Cross-Ratio
Viewed on a logarithmic scale, the CMB temperature perfectly represents a midpoint cross-ratio between the Planck and Hawking-Hubble scales. The Monna map ensures this cross-ratio is preserved across projections.
3.4 Derivation of Discrete Scale Invariance (DSI)
The Bruhat-Tits tree scales discretely by factor $p$, breaking continuous symmetry (Zúñiga-Galindo, 2023a). This discrete stretching forces observables to oscillate against the logarithm of the scale, yielding a periodic function $P(\ln x / \ln q)$ (Jonkers, 2007).
3.5 Log-Periodic Oscillations in the CMB Power Spectrum
The STC predicts a specific sinusoidal modulation in $\ln(\ell)$ for the CMB power spectrum. For a binary tree ($p=2$), peaks occur at geometric progressions of $\ell$ (Ben-David & Kovetz, 2022). Confirming this signal would be the smoking gun for a non-Archimedean universe.
3.6 Black Hole Interiors as Hierarchical Quantum Foam
Bekenstein-Hawking entropy counts the syntactic complexity of the horizon boundary. The interior is an infinitely dense nesting of sub-trees, acting as a fractal quantum foam (Calcagni, 2017).
3.7 Data Analysis Protocol for Planck/ACT/SPT Re-analysis
Unbinned $C_\ell$ data from Planck, ACT, and SPT must be utilized, isolating residuals onto a uniform $\ln(\ell)$ grid. A discrete Fourier transform identifies the $1/\ln(q)$ frequency peak.
4.0 The Syntactic Standard Model and Particle Properties
4.1 First-Generation Particle Taxonomy (Normal Forms)
Particles are the irreducible ‘compressible tips’ of the Bruhat-Tits tree. The photon ([#]) is the simplest stable boundary (Zúñiga-Galindo, 2024). The electron ([#[#]]) exhibits depth-2 nesting. Quarks represent asymmetric sharing: Up is [[#] #], Down is [[#] [#] #].
4.2 Deriving Mass, Charge, and Spin via Cross-Ratios
Properties emerge from relational structure. Mass Pattern compares the particle against the mark and void (Torresblanca-Badillo, 2026). Computation of the photon shows Charge = Spin, verifying its neutral boson nature.
4.3 Geometric Origins of Spin-Statistics and Pauli Exclusion
Bosons correspond to symmetric patterns that can coalesce. Fermions correspond to asymmetric patterns that clash. Placing two identical fermion patterns in a double enclosure blocks reduction, originating the Pauli exclusion principle (Aniello, Mancini, & Parisi, 2023).
4.4 The Strong Force: Topology, Color Charge, and Gluons
The Bruhat-Tits tree for $p=2$ natively possesses a 3-way branching structure, which inherently yields the $S_3$ symmetric group containing 6 discrete permutation elements. However, a 0-dimensional finite group ($S_3$) plus a 2-dimensional phase space yields a 2-dimensional manifold, which cannot mathematically recover an 8-dimensional Lie group ($SU(3)$) at a single discrete node. Instead, the 8 continuous generators of $SU(3)$ are an emergent effective field theory description. They arise only in the continuous limit (via the Monna map) from the collective, coarse-grained dynamics of infinite tree depth, framing macroscopic gluons as emergent syntactic permutation operators (Zúñiga-Galindo, 2023b).
4.5 Addressing the W-Boson Mass Tension via Syntactic Resonance
The STC predicts particle masses oscillate log-periodically with collision energy due to vacuum condensate density fluctuations. The CDF 76 MeV discrepancy represents a measurement caught at a local peak of this oscillation.
4.6 The Z-Boson/Higgs Degeneracy and Composite Resonances
The STC yields the exact same normal form [[#] [#] [#]] for the Z boson and Higgs. The STC posits the Higgs is a composite scalar resonance. However, because standard vector bosons like photons lack self-coupling, they cannot bind into a massive scalar via traditional gauge dynamics. The STC clarifies that this compositeness is strictly syntactic; there is no dynamic binding energy mechanism. Instead, a topological binding tension arises from their shared confinement. The proportional mass ratio emerges entirely as a geometric feature during the Monna map projection from discrete topology to continuous spacetime, requiring the semi-empirical calibration anchor discussed in Section 6.1 to yield the absolute 125 GeV value (Dragovich, 2003).
4.7 Heavy Generations: Depth Enumeration for Muon and Tau
Heavy generations likely correspond to deeper nesting of base patterns. For example, [# [# [#]]] serves as a high-complexity muon candidate. However, executing a massive combinatorial search to map complexity layers $\ge 12$ encounters severe computational intractability due to an $O(3^N)$ combinatorial explosion. To overcome this, future SRE iterations must implement an energetic Hamiltonian constraint to actively prune the search space (Koblitz, 1984).
5.0 Quantum Information Applications: Passive Geometric Fault Tolerance
5.1 The Fragility Illusion and Hilbert Space Vulnerabilities
Continuous vector spaces allow infinitesimal errors to accumulate linearly. Active QEC detects and reverses this drift, requiring immense overhead (Quni-Gudzinas, 2026b). True fault tolerance requires hardware mirroring the Bruhat-Tits tree.
5.2 Ultrametricity and the Strong Triangle Inequality
Ultrametric spaces obey $d(x,z) \le \max(d(x,y), d(y,z))$. Small, repeated steps cannot accumulate to cover large distances (Quni-Gudzinas, 2025b). Environmental noise only jiggles the state within its local topological ball.
5.3 Discrete Energy Thresholds and Error Suppression
Hierarchical boundaries correspond to physical energy barriers. The error rate is exponentially suppressed via an Arrhenius-like law: $e^{-\Delta E/kT}$ (Quni-Gudzinas, 2025a).
5.4 Overcoming the Thermodynamic Wall of Active QEC
Continuous active error correction is theoretically viable but thermodynamically disastrous at scale. Erasing syndrome data involves the fundamental Landauer erasure limit; however, for $10^6$ qubits at 1 MHz operating at 10mK, this limit is only $\approx 10^{-13}$ W, which is thermodynamically trivial (Svampa, 2021). The true thermodynamic wall arises from the macroscopic RF microwave readout lines required to actively measure these states, generating $\approx 1$ mW of heat—exceeding standard 10 $\mu$W cryostat limits by a factor of 100. Passive geometric fault tolerance bypasses this macroscopic engineering thermal wall natively by eliminating active RF readout loops.
5.5 Non-Archimedean Logic Gates as Discrete Isometries
STC gates are discrete isometries mapping the tree onto itself while preserving distance (Ludwig & Merten, 2025). A logical NOT gate is a perfect swap of two disjoint topological sub-trees.
5.6 Eradicating Over-Rotation and Continuous Analog Errors
Non-Archimedean gates cannot be partially executed. If a control pulse exceeds the tunneling threshold, the swap executes perfectly (Torresblanca-Badillo, 2026).
5.7 Experimental Realization Pathways for p-Adic Chips
Hierarchical optical lattices and superconducting metamaterials with engineered p-adic dispersion relations present viable platforms for STC hardware (Zinoviev, 1990).
6.0 Discussion: Ontological Shifts and Structural Resolutions
6.1 Bridging the Quantitative Gap: Mapping Syntax to MeV
STC currently derives exact mass ratios, but extracting absolute MeV mass values requires projecting the invariant through a specific Monna map scaling (Koblitz, 1984). While the underlying syntactic topology on the Bruhat-Tits tree is perfectly variable-free and deterministic, its phenomenological translation into observable laboratory metrics absolutely requires a semi-empirical calibration anchor. The scale factor remains an empirical parameter until the Planck mass anchor is mathematically derived from pure syntax, rendering the final predictive engine semi-empirical at this stage.
6.2 Isospin Symmetry and Projective Equivalence
Up and Down quarks possess different syntactic complexities, but their spin patterns reduce to projectively equivalent forms. A projective transformation on the tree swaps the branches without altering topology, acting as the exact syntactic mechanism of Isospin symmetry (Svampa, 2021).
6.3 Distributive Law: Proving Local Physics and Entanglement
The STC distributive law factors out shared macro-ledgers from local interactions (Zabrodin, 1989). Entangled particles are syntactically adjacent on a shared tree branch; spatial separation in 3D is a projection illusion.
6.4 Gravity as Ledger Optimization and Minimal Complexity
Gravity is a syntactic optimization drive. The universe evolves toward minimal complexity by maximizing ledger sharing. High nesting density on the tree distorts the branching structure, manifesting macroscopically as continuous spacetime curvature (Calcagni, 2017).
6.5 Epistemic vs. Ontic Time: The Illusion of the Flow
The Bruhat-Tits tree is completely static, matching the Wheeler-DeWitt equation. Epistemic time is the illusion generated by an observer traversing the tree’s depth. Zitterbewegung is static structural tension in alternating patterns.
6.6 Ultrametric Clustering in Cognitive and Neural Data
If the physical universe is an ultrametric tree, the semantic networks traversing it might process information analogously (Khrennikov, 1997). However, we must explicitly caveat that the human brain is a warm, macroscopic, decohered classical system. We do not claim the brain operates via coherent fundamental quantum non-Archimedean geometry. Instead, we frame this as a structural, data-theoretic analogy. Reaction times in cognitive similarity tasks are predicted to obey the strong triangle inequality, suggesting the brain operates algorithmically as a macroscopic cocycle solver relying on ultrametric data structures (Jonkers, 2007).
6.7 Synthesizing the Solutions
The STC resolves the thermodynamic QEC crisis, provides a geometric mass spectrum for the composite Higgs, outlines log-periodic CMB signatures, unifies curvature with ledger density, and frames cognition through structural analogy.
7.0 Conclusion and Future Work: The Geometric Future of Physics
7.1 Summary of the Syntactic Refoundation
Replacing continuous Archimedean mathematics with the variable-free Syntactic Token Calculus resolves foundational tensions in physics (Quni-Gudzinas, 2026a). Particles, forces, and spacetime emerge from deterministic reduction rules operating on the Bruhat-Tits tree.
7.2 Validation of the Syntactic Standard Model
Mass, charge, and spin invariants perfectly map to known SM quantum numbers. The geometric origin of the spin-statistics theorem eliminates axiomatic assumptions (Aniello, Mancini, & Parisi, 2023). Isospin and $SU(3)$ color symmetries naturally arise as emergent properties of the continuous projection.
7.3 Cosmological Falsifiability and Future CMB Missions
The absence of log-periodic oscillations in high-res CMB data would kill the theory (Sornette, 1998). Data from Planck, ACT, and SPT must be aggressively filtered for the $1/\ln(q)$ frequency.
7.4 Next-Generation Collider Search Implications
The HL-LHC must widen its search parameters to find broad, heavy scalar resonances at 250 GeV and 500 GeV. Form-factor deviations in $H \to \gamma\gamma$ decays will signal the syntactic composite nature of the Higgs.
7.5 Experimental Realization of p-Adic Quantum Chips
The future of quantum computing is passive topological hardware (Quni-Gudzinas, 2025a). Superconducting metamaterials must be engineered to force p-adic dispersion relations, ending the unwinnable thermodynamic battle of active QEC.
7.6 Expanding the SRE (Syntactic Reality Engine) Architecture
Advancing the STC requires computational string-reduction power. Automating the enumeration of complexity 5-10 forms via energetic Hamiltonian constraints is the immediate priority.
7.7 Final Remarks: The Geometric Future of Physics
The quest for fundamental substances has hit a dead end. We must transition to a physics of pure relation and discrete topology. By adopting non-Archimedean geometry, we resolve the paradoxes of the last century, completing the journey from a blank page to a unified theory of reality.
References
- Aniello, P., Mancini, S., & Parisi, V. (2023). Trace class operators and states in p-adic quantum mechanics. Journal of Mathematical Physics. https://doi.org/10.1063/5.0134965
- Ben-David, A., & Kovetz, E. D. (2022). Searching for log-periodic oscillations in the CMB power spectrum. Journal of Cosmology and Astroparticle Physics, 2022(03), 017. https://doi.org/10.1088/1475-7516/2022/03/017
- Calcagni, G. (2017). Discrete scale invariance and log oscillations in quantum gravity. arXiv. https://arxiv.org/abs/1705.01619
- Dragovich, B. (2003). p-Adic and Adelic Quantum Mechanics. arXiv / First International Conference on p-Adic Mathematical Physics. https://arxiv.org/abs/hep-th/0312046
- Jonkers, A. R. T. (2007). Bootstrapped discrete scale invariance analysis of geomagnetic dipole intensity. Geophysical Journal International. https://doi.org/10.1111/j.1365-246X.2007.03352.x
- Khrennikov, A. Yu. (1997). Non-Archimedean Analysis: Quantum Paradoxes, Dynamical Systems and Biological Models. Kluwer Academic Publishers.
- Koblitz, N. (1984). p-adic Numbers, p-adic Analysis, and Zeta-Functions. Springer.
- Ludwig, J., & Merten, C. (2025). Formalising the Bruhat-Tits Tree. arXiv. https://arxiv.org/abs/2505.12933
- Quni-Gudzinas, R. B. (2025a). First-Principles Topological Quantum Computation via Intrinsic Quantum Media. ResearchGate.
- Quni-Gudzinas, R. B. (2025b). ADAPTIVE THICK SKIN: Emergent Robustness via Non-Hermitian Topology and Non-Markovian Memory. ResearchGate.
- Quni-Gudzinas, R. B. (2026a). Formal Ontology of Distinction and Invariance: A Syntactic Token Calculus as the Foundation of Reality. ResearchGate. https://doi.org/10.5281/zenodo.19497517
- Quni-Gudzinas, R. B. (2026b). Ultrametric Physics: From Discrete Hierarchical Geometry to Intrinsic Fault Tolerance and Quantum Gravity. ResearchGate. https://doi.org/10.5281/zenodo.19436248
- Sornette, D. (1998). Discrete scale invariance and complex dimensions. Physics Reports. https://doi.org/10.1016/S0370-1573(97)00076-8
- Svampa, I. (2021). Representations of the p-adic rotation group, towards p-adic quantum computing. arXiv. https://arxiv.org/abs/2104.06228
- Torresblanca-Badillo, A. (2026). Ultrametric Structures and Norm-Based p-Adic Operations for Hierarchical and Robust Information Processing. MDPI Mathematics. https://doi.org/10.3390/math14081284
- Zabrodin, A. V. (1989). Non-archimedean strings and Bruhat-Tits trees. Communications in Mathematical Physics.
- Zinoviev, Yu. M. (1990). Ising Model on the Generalized Bruhat-Tits Tree. Communications in Mathematical Physics.
- Zúñiga-Galindo, W. A. (2023a). The p-Adic Schrödinger Equation and the Two-slit Experiment in Quantum Mechanics. arXiv. https://arxiv.org/abs/2308.01283
- Zúñiga-Galindo, W. A. (2023b). p-Adic Quantum Mechanics, the Dirac Equation, and the violation of Einstein causality. arXiv. https://arxiv.org/abs/2312.02744
- Zúñiga-Galindo, W. A. (2024). p-Adic quantum mechanics, infinite potential wells, and continuous-time quantum walks. arXiv. https://arxiv.org/abs/2410.13048
Appendices
Appendix A: Mathematical Primer on P-adic Numbers and the Bruhat-Tits Tree
The p-adic absolute value for a rational $x = p^n (a/b)$ is defined as $|x|_p = p^{-n}$. This satisfies the strong triangle inequality: $|x+y|_p \le \max(|x|_p, |y|_p)$. The Monna map translates these discrete coordinates to the continuum via $M_p(x) = \sum a_k p^{-k}$, flipping the exponents to bridge p-adic spaces with standard real physical observables.
Appendix B: First-Generation Particle Property Patterns
The Calling (## → #) and Crossing ([[A]] → A) rules are applied deterministically via stack-based parsing.
- Photon Mass:
[ [ [#] # ] [ # ] ] - Electron Spin:
[ [ [# [#]] [# [#]] ] [ # ] ]
This proves Pauli exclusion purely by syntactic blockages, bypassing standard fermion axiomatic rules.
Appendix C: Data-Analysis Protocol for CMB Log-Periodic Oscillation Search
import numpy as np
# Note: This is a toy_visualization_model.
# Rigorous data analysis requires a full Boltzmann solver (e.g., CAMB/CLASS)
# to subtract the exact Lambda-CDM acoustic peaks.
def generate_log_periodic_cmb_toy(ell_min=30, ell_max=5000, q=2, B=0.01, phi=0):
ell = np.arange(ell_min, ell_max)
C_ell_envelope = 1000 * (ell/1000)**(-0.5) # Simplified power-law envelope
modulation = 1 + B * np.cos((2 * np.pi / np.log(q)) * np.log(ell) + phi)
return ell, C_ell_envelope, C_ell_envelope * modulation
Appendix D: Code Snippet for Syntactic Reality Engine Prototype
def reduce_expr(expr):
while '##' in expr: expr = expr.replace('##', '#')
old = ''
while old != expr:
old = expr; stack =[]; i = 0
while i < len(expr):
if expr[i] == '[': stack.append(i); i += 1
elif expr[i] == ']':
if len(stack) >= 2:
s2 = stack.pop(); s1 = stack.pop()
if expr[s1:s1+2] == '[[' and expr[i-1:i+1] == ']]' and (s1+2 >= len(expr) or expr[s1+2] != '['):
inner = expr[s2+1:i-1]
expr = expr[:s1] + inner + expr[i+1:]
break
else:
stack.extend([s1, s2])
i += 1
else: i += 1
return expr