| … | … | @@ -0,0 +1,93 @@ |
| 1 | /* coemerge.c — the hard one: can COMPARTMENTS and the REPLICASE co-emerge from ONE physics, unaided? |
| 2 | * |
| 3 | * ribozyme needed supplied compartments; bridges.c showed compartmentalized privatization is the |
| 4 | * load-bearing ingredient and the decreed catalysis-map is not (emergent binding suffices). The remaining |
| 5 | * edge: make the COMPARTMENT emerge too. Idea: let BINDING do double duty. Complementarity (the same physics |
| 6 | * that gives catalysis) also gives COHESION -- mutually-binding strands stick together into a spatial cluster |
| 7 | * (an emergent compartment), while poor binders (parasites) don't stick and DIFFUSE AWAY, excluding |
| 8 | * themselves. One supplied physics (complementarity + diffusion + template copying); compartments, catalysis, |
| 9 | * and parasite exclusion are all MEASURED, not decreed. No walls, no group-selection machinery, no phi->f map. |
| 10 | * |
| 11 | * Local binding b(c) = best complementarity of strand c to an occupied neighbour. It does BOTH: |
| 12 | * - COHESION: if b(c) >= THETA the strand is held (immobile); else it random-walks away (parasites shed). |
| 13 | * - CATALYSIS: copy fidelity for a birth near c = F0 + (F1-F0)*b(c)/PHIMAX. |
| 14 | * Control: MOBILITY OFF (strands frozen = the failed bridge-A surface regime) vs ON (cohesion active), to |
| 15 | * isolate whether cohesion is what makes compartments emerge. Razor: nothing rewards a sequence; phi/binding |
| 16 | * are emergent; whether phi RISES and clusters FORM is measured. |
| 17 | * |
| 18 | * build: cc -O2 -Wall -std=c11 -o coemerge coemerge.c -lm |
| 19 | */ |
| 20 | #include <math.h> |
| 21 | #include <stdio.h> |
| 22 | #include <stdint.h> |
| 23 | |
| 24 | #define G 56 |
| 25 | #define NC (G*G) |
| 26 | #define L 24 |
| 27 | #define PHIMAX (L/2) |
| 28 | #define F0 0.85 |
| 29 | #define F1 0.999 |
| 30 | #define BETA 2.0 |
| 31 | #define THETA 8 /* binding needed to be held (immobile). below -> diffuse away */ |
| 32 | #define DEG 0.08 |
| 33 | #define EMPTY 0xffffffffu |
| 34 | |
| 35 | static unsigned long long RNG; |
| 36 | static unsigned long long xs(void){ RNG^=RNG<<13; RNG^=RNG>>7; RNG^=RNG<<17; return RNG; } |
| 37 | static double urand(void){ return (double)(xs()>>11)*(1.0/9007199254740992.0); } |
| 38 | static int phi(uint32_t s){ int c=0; for(int i=0;i<PHIMAX;i++){ int a=(s>>i)&1,b=(s>>(L-1-i))&1; if(a!=b)c++; } return c; } |
| 39 | static int bind(uint32_t a,uint32_t b){ int c=0; for(int i=0;i<PHIMAX;i++){ int x=(a>>i)&1,y=(b>>(L-1-i))&1; if(x!=y)c++; } return c; } |
| 40 | static uint32_t replicate(uint32_t t,double f){ uint32_t c=0; for(int i=0;i<L;i++){ int b=(t>>i)&1; int nb=(urand()<f)?(1-b):b; if(nb)c|=(1u<<i);} return c; } |
| 41 | static uint32_t randstrand(void){ uint32_t s=0; for(int b=0;b<L;b++) if(urand()<0.5) s|=(1u<<b); return s; } |
| 42 | |
| 43 | static uint32_t grd[NC]; |
| 44 | static int bestbind(int x,int y){ int best=0; uint32_t s=grd[y*G+x]; for(int dy=-1;dy<=1;dy++)for(int dx=-1;dx<=1;dx++){ if(!dx&&!dy)continue; uint32_t n=grd[((y+dy+G)%G)*G+((x+dx+G)%G)]; if(n!=EMPTY){ int v=bind(s,n); if(v>best)best=v; } } return best; } |
| 45 | |
| 46 | /* one run. mobile=1 enables cohesion/diffusion. returns final mean phi; writes final mean binding + start phi. */ |
| 47 | static double run(int mobile,double *meanbind,double *start){ |
| 48 | for(int i=0;i<NC;i++) grd[i]= (urand()<0.5)? randstrand() : EMPTY; |
| 49 | { double s=0;int c=0; for(int i=0;i<NC;i++) if(grd[i]!=EMPTY){ s+=phi(grd[i]); c++; } *start=c?s/c:0; } |
| 50 | for(int g=0;g<300;g++){ |
| 51 | /* mobility: unbound strands (low local binding) random-walk into an adjacent empty cell */ |
| 52 | if(mobile){ |
| 53 | for(int t=0;t<NC;t++){ int x=(int)(xs()%G),y=(int)(xs()%G),c=y*G+x; if(grd[c]==EMPTY)continue; |
| 54 | if(bestbind(x,y)>=THETA) continue; /* held by binding -> stays */ |
| 55 | int dx=(int)(xs()%3)-1,dy=(int)(xs()%3)-1,nx=(x+dx+G)%G,ny=(y+dy+G)%G,nc=ny*G+nx; |
| 56 | if(grd[nc]==EMPTY){ grd[nc]=grd[c]; grd[c]=EMPTY; } /* wander */ |
| 57 | } |
| 58 | } |
| 59 | /* replication into an adjacent empty cell; fidelity from LOCAL binding; parasites faster */ |
| 60 | for(int t=0;t<NC;t++){ int x=(int)(xs()%G),y=(int)(xs()%G),c=y*G+x; if(grd[c]==EMPTY)continue; |
| 61 | double w=1.0+BETA*(1.0-(double)phi(grd[c])/PHIMAX); if(urand()> w/(1.0+BETA)) continue; |
| 62 | int dx=(int)(xs()%3)-1,dy=(int)(xs()%3)-1,nx=(x+dx+G)%G,ny=(y+dy+G)%G,nc=ny*G+nx; if(grd[nc]!=EMPTY)continue; |
| 63 | int b=bestbind(x,y); double f=F0+(F1-F0)*((double)b/PHIMAX); |
| 64 | grd[nc]=replicate(grd[c],f); |
| 65 | } |
| 66 | for(int i=0;i<NC;i++) if(grd[i]!=EMPTY && urand()<DEG) grd[i]=EMPTY; |
| 67 | } |
| 68 | double s=0,mb=0; int c=0; for(int y=0;y<G;y++)for(int x=0;x<G;x++){ if(grd[y*G+x]!=EMPTY){ s+=phi(grd[y*G+x]); mb+=bestbind(x,y); c++; } } |
| 69 | *meanbind=c?mb/c:0; return c?s/c:0; |
| 70 | } |
| 71 | |
| 72 | int main(void){ |
| 73 | printf("=== Co-emergence: can compartments + replicase arise from ONE physics (binding)? ===\n"); |
| 74 | printf(" Binding does double duty: COHESION (held if >=%d) + CATALYSIS (fidelity from local binding).\n",THETA); |
| 75 | printf(" %dx%d grid, random start phi~6 (max 12). MOBILITY OFF = frozen (bridge-A surface control).\n\n",G,G); |
| 76 | printf(" arm | phi start->end | mean local-binding end | verdict\n"); |
| 77 | printf(" ---------------+----------------+------------------------+--------\n"); |
| 78 | |
| 79 | unsigned long long seeds[]={0x9e3779b97f4a7c15ULL,0xd1b54a32d192ed03ULL,0x2545f4914f6cdd1dULL}; |
| 80 | int NS=3; double mb,st,en, offS=0,offE=0,offB=0, onS=0,onE=0,onB=0; |
| 81 | for(int s=0;s<NS;s++){ RNG=seeds[s]; en=run(0,&mb,&st); offS+=st;offE+=en;offB+=mb; } |
| 82 | for(int s=0;s<NS;s++){ RNG=seeds[s]; en=run(1,&mb,&st); onS+=st;onE+=en;onB+=mb; } |
| 83 | offS/=NS;offE/=NS;offB/=NS; onS/=NS;onE/=NS;onB/=NS; |
| 84 | printf(" MOBILITY OFF | %.2f -> %.2f | %.2f | %s\n", offS,offE,offB, offE>offS+2?"IGNITES":(offE>offS+0.5?"partial":(offE<offS-0.5?"falls":"~flat"))); |
| 85 | int ig = onE>onS+2; st=onS;en=onE;mb=onB; |
| 86 | printf(" MOBILITY ON | %.2f -> %.2f | %.2f | %s\n", onS,onE,onB, ig?"IGNITES":(onE>onS+0.5?"partial":(onE<onS-0.5?"falls":"~flat"))); |
| 87 | printf("\n"); |
| 88 | if(ig) |
| 89 | printf(" => CO-EMERGENCE. From ONE supplied physics (complementarity + diffusion + template copying),\n binding self-organizes cohesive high-fidelity CLUSTERS (emergent compartments) that shed parasites\n by diffusion, and fidelity bootstraps -- with NO decreed walls, group-selection machinery, or phi->f\n map. Mobility (cohesion) is what does it: the frozen control (bridge-A surface) does NOT ignite.\n HONEST BOUND: I still supplied the complementarity/diffusion/copy PHYSICS; whether THAT chemistry\n exists is the pre-biotic given, not shown to arise from nothing.\n"); |
| 90 | else |
| 91 | printf(" => Honest NULL: binding-cohesion did NOT ignite the bootstrap here. Compartments did not emerge\n strongly enough to privatize catalysis against parasites in this regime. Co-emergence not shown; the\n supplied-compartment result (ribozyme) still stands as the only crossing. Do not tune to force it.\n"); |
| 92 | return 0; |
| 93 | } |