Weighted Resonance / HEG Experiment

This is a code-side experiment. It treats resonance as a finite weighted family of localized graph states, then computes observables that survive, or disappear, under averaging. Most legacy cards can be clicked to switch between EFG and refined HEG views; cards labelled native HEG are generated directly from HalfEdgeMol objects.

visual proof from executable graph objects

Charge-Shift Toy

A covalent/ionic family where mean formal charges vanish, but second moments do not.

The polar recombination rule is unavailable on the covalent contributor and available only on the two ionic contributors. The two ionic branches coalesce to the same covalent H-H product.

Atom moments

atom<q>Var(q)lone pairsradicals
1 H00.50.250
2 H00.50.250

Charge covariance

Cov(q)1 H2 H
1 H0.5-0.5
2 H-0.50.5

Bond moments

pair<bond order>Var(bond order)
1-20.50.25

Constructor checks

same labels: truesame sigma skeleton: falsesame total q: truesame electrons: true
contributorweighttotal qelectronsadmissiblestrictviolations
covalent0.502truetrue0
ionic_h1_minus_h2_plus0.2502falsefalse1
ionic_h1_plus_h2_minus0.2502falsefalse1

Contributors

h2_charge_shift_toy / covalent (w=0.5)click image to switch EFG / HEG
h2_charge_shift_toy / covalent (w=0.5)h2_charge_shift_toy / covalent (w=0.5)
h2_charge_shift_toy / ionic_h1_minus_h2_plus (w=0.25)click image to switch EFG / HEG
h2_charge_shift_toy / ionic_h1_minus_h2_plus (w=0.25)h2_charge_shift_toy / ionic_h1_minus_h2_plus (w=0.25)
h2_charge_shift_toy / ionic_h1_plus_h2_minus (w=0.25)click image to switch EFG / HEG
h2_charge_shift_toy / ionic_h1_plus_h2_minus (w=0.25)h2_charge_shift_toy / ionic_h1_plus_h2_minus (w=0.25)

Rule

The executable rule is drawn here as its toy graph schema. It consumes one lone pair on a formally negative donor and creates one shared pair to a formally positive acceptor.

Rule K: two atom interfaceclick image to switch EFG / HEG
Rule K: two atom interfaceRule K: two atom interface
Fitting reference. The directly matching chemical motivation is charge-shift bonding: covalent and ionic VB structures are not merely averaged away; their resonance interaction is the chemically relevant object. See Shaik et al., Charge-Shift Bonding: A New and Unique Form of Bonding, Angew. Chem. Int. Ed. 59, 984-1001, DOI 10.1002/anie.201910085. The local background PDF shaik_danovich_hiberty_2021_valence_bond_theory.pdf supplies the broader VB/Lewis context.

Minimal Julia

p = charge_shift_presentation()
rule = ionic_pair_recombination_rule()
push = product_pushforward(p, rule)
classes = coalesce_products(push.raw_products)

Polar rule availability

ruleavailable weightweighted matchesmatches by contributor
ionic_pair_recombination0.50.5covalent: 0; ionic_h1_minus_h2_plus: 1; ionic_h1_plus_h2_minus: 1

Push-forward and coalescing

available weight0.5
unavailable weight0.5
raw branches2
coalesced classes1
classweightbranchescontributorsrulessame product reached twice?
10.52ionic_h1_minus_h2_plus, ionic_h1_plus_h2_minusionic_pair_recombinationtrue
charge_shift product class 1 (w=0.5)click image to switch EFG / HEG
charge_shift product class 1 (w=0.5)charge_shift product class 1 (w=0.5)
Conclusion. The averaged formal charges are zero, but the weighted family still contains reactive ionic branches. Rule availability and product push-forward expose that hidden structure: only weight 0.5 reacts, and both reactive branches collapse to the same H-H product class.

Allyl Radical and Ions

Small Lewis/VB sanity examples: terminal densities split across two localized contributors.

This example is less about hidden selectivity and more about closure of a localized resonance family. The allyl radical shift moves the radical between terminal carbons while moving the pi bond; the weighted presentation then reports terminal radical density 0.5/0.5 and C-C bond orders 1.5/1.5.
Fitting reference. Linares, Humbel, and Braida apply a Lewis-structure-based valence-bond scheme to allyl ions and radical. See The Nature of Resonance in Allyl Ions and Radical, J. Phys. Chem. A 112, 13249-13255, DOI 10.1021/jp8038169. The local PDF is linares_humbel_braida_2008_resonance_allyl_ions_radical.pdf.

Allyl radical shift rule

The displayed rule shifts one electron-pair feature and one radical feature. The opposite shift is the inverse rule with L and R exchanged.

Rule L: pi left, radical rightclick image to switch EFG / HEG
Rule L: pi left, radical rightRule L: pi left, radical right
Rule R: radical left, pi rightclick image to switch EFG / HEG
Rule R: radical left, pi rightRule R: radical left, pi right

Minimal Julia

p = allyl_radical_presentation()
rules = [ER.allyl_shift_left_rule(), ER.allyl_shift_right_rule()]
push = product_pushforward(p, rules)
classes = coalesce_products(push.raw_products)

Radical-shift push-forward

ruleavailable weightweighted matchesmatches by contributor
allyl_radical_shift_left11radical_right: 1; radical_left: 1
allyl_radical_shift_right11radical_right: 1; radical_left: 1
available weight1
unavailable weight0
raw branches4
coalesced classes1
classweightbranchescontributorsrulessame product reached twice?
114radical_left, radical_rightallyl_radical_shift_left, allyl_radical_shift_righttrue
allyl_radical product class 1 (w=1)click image to switch EFG / HEG
allyl_radical product class 1 (w=1)allyl_radical product class 1 (w=1)

Executable trapping example

To make executability matter, the allyl system is made asymmetric and given an external methyl radical trap. Now the same radical recombination rule produces two non-isomorphic regioisomeric product classes.

Rule L: two carbon radicalsclick image to switch EFG / HEG
Rule L: two carbon radicalsRule L: two carbon radicals

EFG trapping code

p = substituted_allyl_methyl_trap_presentation()
rule = ER.radical_recombination_rule()
push = product_pushforward(p, rule)
classes = coalesce_products(push.raw_products)

Trapping observables

atom<q>Var(q)lone pairsradicals
1 C0000.5
2 C0000
3 C0000.5
4 Cl6000
5 H0000
6 H0000
7 H0000
8 H0000
9 C0001
10 H0000
11 H0000
12 H0000
pair<bond order>Var(bond order)
1-21.50.25
1-410
1-510
2-31.50.25
2-610
3-710
3-810
9-1010
9-1110
9-1210

Trapping checks

same labels: truesame sigma skeleton: truesame total q: truesame electrons: true
contributorweighttotal qelectronsadmissiblestrictviolations
left_radical0.5624falsefalse3
right_radical0.5624falsefalse3

Trapping contributors

substituted_allyl_methyl_trap / left_radical (w=0.5)click image to switch EFG / HEG
substituted_allyl_methyl_trap / left_radical (w=0.5)substituted_allyl_methyl_trap / left_radical (w=0.5)
substituted_allyl_methyl_trap / right_radical (w=0.5)click image to switch EFG / HEG
substituted_allyl_methyl_trap / right_radical (w=0.5)substituted_allyl_methyl_trap / right_radical (w=0.5)

Trapping push-forward

ruleavailable weightweighted matchesmatches by contributor
radical_recombination12left_radical: 2; right_radical: 2
available weight1
unavailable weight0
raw branches4
coalesced classes2
classweightbranchescontributorsrulessame product reached twice?
10.52left_radicalradical_recombinationfalse
20.52right_radicalradical_recombinationfalse
substituted_allyl_trap product class 1 (w=0.5)click image to switch EFG / HEG
substituted_allyl_trap product class 1 (w=0.5)substituted_allyl_trap product class 1 (w=0.5)
substituted_allyl_trap product class 2 (w=0.5)click image to switch EFG / HEG
substituted_allyl_trap product class 2 (w=0.5)substituted_allyl_trap product class 2 (w=0.5)

Native HEG execution

This is the native HEG version. The contributors, rule, matches, products, and product coalescing below are HalfEdgeMol objects and use half_edge_cat(), not EFG execution with an HEG rendering.
Native HEG rule L: two unpaired half-edgesnative HEG
Native HEG rule L: two unpaired half-edges
Native HEG rule K: preserved half-edgesnative HEG
Native HEG rule K: preserved half-edges
Native HEG rule R: new pair objectnative HEG
Native HEG rule R: new pair object

Native HEG code

include("ElectronHEGResonance.jl")
using .ElectronHEGResonance

p = native_substituted_allyl_methyl_trap_presentation()
rule = HEG.native_radical_recombination_rule()
push = native_product_pushforward(p, rule)
classes = native_coalesce_products(push.raw_products)

Native HEG observables

atom<q>lone pairsradicals
1 C000.5
2 C000
3 C000.5
4 Cl600
5 H000
6 H000
7 H000
8 H000
9 C001
10 H000
11 H000
12 H000
pair<bond order>
1-21.5
1-41
1-51
2-31.5
2-61
3-71
3-81
9-101
9-111
9-121

Native HEG push-forward

native HEG ruleavailable weightweighted matchesmatches by contributor
native_radical_recombination12left_radical: 2; right_radical: 2
available weight1
unavailable weight0
raw branches4
coalesced classes2
classweightbranchescontributorsrulessame product reached twice?
10.52left_radicalnative_radical_recombinationfalse
20.52right_radicalnative_radical_recombinationfalse

Native HEG contributors

native_substituted_allyl_methyl_trap / left_radical (w=0.5)native HEG
native_substituted_allyl_methyl_trap / left_radical (w=0.5)
native_substituted_allyl_methyl_trap / right_radical (w=0.5)native HEG
native_substituted_allyl_methyl_trap / right_radical (w=0.5)

Native HEG product classes

native_substituted_allyl_trap native product class 1 (w=0.5)native HEG
native_substituted_allyl_trap native product class 1 (w=0.5)
native_substituted_allyl_trap native product class 2 (w=0.5)native HEG
native_substituted_allyl_trap native product class 2 (w=0.5)

Allyl radical observables

atom<q>Var(q)lone pairsradicals
1 C0000.5
2 C0000
3 C0000.5
4 H0000
5 H0000
6 H0000
7 H0000
8 H0000
pair<bond order>Var(bond order)
1-21.50.25
1-410
1-510
2-31.50.25
2-610
3-710
3-810

Rule availability

ruleavailable weightweighted matchesmatches by contributor
allyl_radical_shift_left11radical_right: 1; radical_left: 1
allyl_radical_shift_right11radical_right: 1; radical_left: 1
allyl_radical / radical_right (w=0.5)click image to switch EFG / HEG
allyl_radical / radical_right (w=0.5)allyl_radical / radical_right (w=0.5)
allyl_radical / radical_left (w=0.5)click image to switch EFG / HEG
allyl_radical / radical_left (w=0.5)allyl_radical / radical_left (w=0.5)

Allyl cation

atom<q>Var(q)lone pairsradicals
1 C0.50.2500
2 C0000
3 C0.50.2500
4 H0000
5 H0000
6 H0000
7 H0000
8 H0000
pair<bond order>Var(bond order)
1-21.50.25
1-410
1-510
2-31.50.25
2-610
3-710
3-810
allyl_cation / cation_left (w=0.5)click image to switch EFG / HEG
allyl_cation / cation_left (w=0.5)allyl_cation / cation_left (w=0.5)
allyl_cation / cation_right (w=0.5)click image to switch EFG / HEG
allyl_cation / cation_right (w=0.5)allyl_cation / cation_right (w=0.5)

Allyl anion

atom<q>Var(q)lone pairsradicals
1 C-0.50.250.50
2 C0000
3 C-0.50.250.50
4 H0000
5 H0000
6 H0000
7 H0000
8 H0000
pair<bond order>Var(bond order)
1-21.50.25
1-410
1-510
2-31.50.25
2-610
3-710
3-810
allyl_anion / anion_left (w=0.5)click image to switch EFG / HEG
allyl_anion / anion_left (w=0.5)allyl_anion / anion_left (w=0.5)
allyl_anion / anion_right (w=0.5)click image to switch EFG / HEG
allyl_anion / anion_right (w=0.5)allyl_anion / anion_right (w=0.5)
Conclusion. Plain allyl shifting is mostly a closure sanity check. The asymmetric trapping variant is the first useful executable result: radical density is converted into explicit product classes. The push-forward has available weight 1, four raw branches, and two non-isomorphic coalesced products with weights 0.5 and 0.5.

DPO Push-Forward

Existing diazomethane EGML/DPO proton-transfer rules are applied contributor-wise and their products are coalesced.

The ylide proton-transfer rule and azo proton-transfer rule are distinct localized DPO spans. In this weighted presentation, both routes reach one protonated intermediate product class.

Diazomethane observables

atom<q>Var(q)lone pairsradicals
1 C-0.50.250.50
2 N1000
3 N-0.50.251.50
4 H0000
5 H0000
6 C0000
7 H0000
8 H0000
9 H0000
10 C0000
11 O0020
12 O0020
13 H0000
pair<bond order>Var(bond order)
1-21.50.25
1-410
1-510
2-32.50.25
6-710
6-810
6-910
6-1010
10-1120
10-1210
12-1310

Checks

same labels: truesame sigma skeleton: truesame total q: truesame electrons: true
contributorweighttotal qelectronsadmissiblestrictviolations
diazo_ylide0.5040truetrue0
azo_form0.5040truetrue0

Contributors

diazomethane_acid_forms / diazo_ylide (w=0.5)click image to switch EFG / HEG
diazomethane_acid_forms / diazo_ylide (w=0.5)diazomethane_acid_forms / diazo_ylide (w=0.5)
diazomethane_acid_forms / azo_form (w=0.5)click image to switch EFG / HEG
diazomethane_acid_forms / azo_form (w=0.5)diazomethane_acid_forms / azo_form (w=0.5)

Rule availability

ruleavailable weightweighted matchesmatches by contributor
diazomethane_proton_transfer0.53diazo_ylide: 6; azo_form: 0
diazomethane_azo_proton_transfer0.54diazo_ylide: 0; azo_form: 8

Push-forward and coalescing

available weight1
unavailable weight0
raw branches14
coalesced classes1
classweightbranchescontributorsrulessame product reached twice?
1114azo_form, diazo_ylidediazomethane_azo_proton_transfer, diazomethane_proton_transfertrue
diazomethane product class 1 (w=1)click image to switch EFG / HEG
diazomethane product class 1 (w=1)diazomethane product class 1 (w=1)

Minimal Julia

include("ElectronResonance.jl")
using .ElectronResonance

p = diazomethane_acid_presentation()
rules = [ER.diazomethane_proton_transfer_rule(), ER.diazomethane_azo_proton_transfer_rule()]
push = product_pushforward(p, rules; branch_policy=:uniform_matches)
classes = coalesce_products(push.raw_products)

Literature Anchors

These are motivation anchors for the executable model, not fitted numerical claims.

Summary output

charge-shift toy mean charges: 0, 0
charge-shift toy charge variances: 0.5, 0.5; covariance H1,H2=-0.5
charge-shift toy H-H mean bond order: 0.5; variance=0.25
ionic_pair_recombination: covalent=0 matches at w=0.5; ionic_h1_minus_h2_plus=1 matches at w=0.25; ionic_h1_plus_h2_minus=1 matches at w=0.25; available weight=0.5; weighted match count=0.5
charge-shift toy coalesced polar products: 1 with raw weight 0.5
benzene C-C ring orders: 1.5, 1.5, 1.5, 1.5, 1.5, 1.5
benzene radical density sum: 0
formate C-O orders: 1.5, 1.5
formate O charges: -0.5, -0.5
allyl C-C orders: 1.5, 1.5
allyl radical densities C1,C2,C3: 0.5, 0, 0.5
allyl_radical_shift_left: radical_right=1 matches at w=0.5; radical_left=1 matches at w=0.5; available weight=1; weighted match count=1
allyl_radical_shift_right: radical_right=1 matches at w=0.5; radical_left=1 matches at w=0.5; available weight=1; weighted match count=1
allyl cation C-C orders: 1.5, 1.5
allyl cation terminal charge means: 0.5, 0.5
allyl anion C-C orders: 1.5, 1.5
allyl anion terminal charge means: -0.5, -0.5
substituted allyl trap radical densities C1,C3,methyl: 0.5, 0.5, 1
radical_recombination: left_radical=2 matches at w=0.5; right_radical=2 matches at w=0.5; available weight=1; weighted match count=2
substituted allyl trap coalesced product classes: 2 with weights 0.5, 0.5
formamide C-N order: 1.2
formamide O,N charges: -0.2, 0.2
diazomethane_proton_transfer: diazo_ylide=1 matches at w=0.5; azo_form=0 matches at w=0.5; available weight=0.5; weighted match count=0.5
diazomethane_azo_proton_transfer: diazo_ylide=0 matches at w=0.5; azo_form=1 matches at w=0.5; available weight=0.5; weighted match count=0.5
diazomethane DPO push-forward available weight: 1
diazomethane coalesced product classes: 1 with weight 1
diazomethane coalesced from contributors: azo_form, diazo_ylide; rules: diazomethane_azo_proton_transfer, diazomethane_proton_transfer
assessment: executable analysis layer now; candidate appendix proposition for weighted observables and rule availability, not yet a strong theorem.