Lawfare Group → Knowledge Institute → Lawfare Academy
Reproduce the worked examples
Copy the complete code below into a UTF-8 file named verify.py and run python verify.py with Python 3. It uses only the standard library and performs exact or rational synthetic calculations. It does not access a network or learner records. Assertions fail if the expected synthetic results change.
These checks verify the stated arithmetic and query behavior, not independent academic acceptance or production migration safety.
"""Original synthetic startup models. Standard library, no network or records.
These checks do not establish real demand, competence, authorization, causal
effects, financing commitments or independent academic acceptance.
"""
from fractions import Fraction as F
from itertools import product
import json
results={}
def eq(name,value,target,tol=0.000001):
assert abs(float(value)-target)<tol,(name,float(value),target)
results[name]=float(value)
def finite(m,r,h):return m*sum(r**t for t in range(h))
eq('six_month_contribution_r80',finite(25,F(4,5),6),92.232)
eq('six_month_contribution_r60',finite(25,F(3,5),6),59.584)
assert F(25)/(1-F(4,5))==125
assert F(25)/(1-F(3,5))==F(125,2)
eq('twenty_margin_six_month',finite(20,F(4,5),6)-80,-6.2144)
eq('thirtyfive_margin_r60_six_month',finite(35,F(3,5),6)-80,3.4176)
assert 100*80-100*25==5500
assert 30<24+10 and 24+4==28
options={'P':(12,30,9),'Q':(18,20,11),'R':(10,25,8)}
def select(hours=50,pvalue=9):
out=[]
for flags in product((0,1),repeat=3):
names=[n for n,b in zip(options,flags) if b]
cash=sum(options[n][0] for n in names);staff=sum(options[n][1] for n in names)
if cash<=30 and staff<=hours:out.append((sum(pvalue if n=='P' else options[n][2] for n in names),''.join(names) or 'none'))
return sorted(out,reverse=True)
assert select()[0]==(20,'PQ')
assert select(hours=45)[0]==(19,'QR')
assert select(pvalue=7)[0]==(19,'QR')
assert 10-7-3-2==-2
assert F(4+1,50)==F(1,10) and F(5,40)==F(1,8)
assert F(60)/(1+F(1,5))==50
eq('reduced_repeat_capacity',F(60)/(1+F(1,20)),57.142857142857)
eq('delegated_review_capacity',F(60)/(F(1,2)+F(1,5)),85.714285714)
eq('delegated_high_repeat',F(60)/(F(1,2)+F(2,5)),66.666666667)
assert 96/F(6,5)==80
base=[30-18-5];base.extend([base[0]-6,base[0]-12,base[0]-18,base[0]-18+24])
assert base==[7,1,-5,-11,13]
assert 3-min(base)==14
financed=[21,15,9,3,27,12];assert min(financed)>=3
assert 3-15==-12 and 12-6==6
def path(n,r=F(4,5),pause=False,setup=0):
active=F(0);cash=F(80000-setup);rows=[]
for month in range(1,7):
new=n if not pause or month==1 else 0
active=new+r*active;contribution=25*active;change=contribution-80*new-10000;cash+=change
rows.append(dict(month=month,new=new,active=active,contribution=contribution,change=change,cash=cash))
return rows
p100=path(100);p80=path(80);pause=path(100,pause=True)
assert [x['active'] for x in p100]==list(map(F,['100','180','244','295.2','336.16','368.928']))
assert [x['cash'] for x in p100]==list(map(F,['64500','51000','39100','28480','18884','10107.2']))
assert [x['cash'] for x in p80]==list(map(F,['65600','52800','41280','30784','21107.2','12085.76']))
assert [x['cash'] for x in pause]==list(map(F,['64500','56500','48100','39380','30404','21223.2']))
def feasible(n,reserve=10000,capacity=300):return all(x['cash']>=reserve and x['active']<=capacity for x in path(n))
allowed=[n for n in range(151) if feasible(n)]
assert max(allowed)==81 and not feasible(82)
assert max(n for n in range(151) if feasible(n,reserve=15000))==50
eq('cohort81_month6_active',path(81)[-1]['active'],298.83168)
eq('cohort81_month6_cash',path(81)[-1]['cash'],11986.832)
eq('retention60_month6_cash',path(100,F(3,5))[-1]['cash'],562.4)
eq('setup_added_month6_cash',path(100,setup=12000)[-1]['cash'],-1892.8)
# Preserve and reconstruct complete retained numerical examples.
assert 4*(30-25)-40==-20 and 4*(30-15)-40==20
cash=50-20;first=[]
for _ in range(3):cash-=13;first.append(cash)
assert first==[17,4,-9]
cash=50+10-20;fin=[]
for _ in range(3):cash-=13;fin.append(cash)
cash=cash-5+25-F(21,2)
assert fin==[27,14,1] and cash==F(21,2)
cash=40-15;retained=[]
for t in range(1,7):cash-=10;cash+=4 if t>=3 else 0;retained.append(cash)
assert retained==[15,5,-1,-7,-13,-19]
cash=25;earlier=[]
for t in range(1,7):cash-=6;earlier.append(cash)
assert earlier==[19,13,7,1,-5,-11]
print(json.dumps(dict(passed=True,scope='Synthetic cohort, finite resource and ordered cash checks; not real competence or academic acceptance',results=results,maximumConditionalMonthlyCohort=max(allowed),continued100=[{k:float(v) for k,v in x.items()} for x in p100],continued80=[{k:float(v) for k,v in x.items()} for x in p80],pause=[{k:float(v) for k,v in x.items()} for x in pause]),indent=2))
Related chapters
- Test a repeatable value proposition through acquisition, service and retention
- Allocate scarce cash and capability through feasible growth packages
- Turn founder intentions into usable authority and a capable team
- Grow accepted service capacity without rewarding a misleading activity count
- Separate foreign entry, entity design and funded service access
- Integrate cohort economics, runway and milestone choices
- Cumulative clinic: funded, repeatable and deliverable growth