"""
MikoshiLang Extended Functions - Set 19
Advanced finance, economics, econometrics, and game theory
"""
import sympy as sp
from sympy import symbols, sqrt, exp, log, pi, erf

def get_rules():
    """Extended set 19: Finance and economics (200 functions)"""
    r, t, sigma, S, K = symbols('r t sigma S K')
    
    return [
        # ===== OPTIONS & DERIVATIVES (50 functions) =====
        ('BlackScholesCall[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: S*sp.stats.Normal('d1', 0, 1).cdf((log(S/K) + (r + sig**2/2)*T)/(sig*sqrt(T))) - K*exp(-r*T)*sp.stats.Normal('d2', 0, 1).cdf((log(S/K) + (r - sig**2/2)*T)/(sig*sqrt(T)))),
        ('BlackScholesPut[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: K*exp(-r*T) - S + sp.Symbol('BSCall')),  # Put-call parity
        ('D1[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: (log(S/K) + (r + sig**2/2)*T)/(sig*sqrt(T))),
        ('D2[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: (log(S/K) + (r - sig**2/2)*T)/(sig*sqrt(T))),
        ('OptionDelta Call[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: sp.Rational(1,2)*(1 + erf((log(S/K) + (r + sig**2/2)*T)/(sig*sqrt(T)*sqrt(2))))),
        ('OptionDeltaPut[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: sp.Rational(1,2)*(1 + erf((log(S/K) + (r + sig**2/2)*T)/(sig*sqrt(T)*sqrt(2)))) - 1),
        ('OptionGamma[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: exp(-((log(S/K) + (r + sig**2/2)*T)**2)/(2*sig**2*T))/(S*sig*sqrt(2*pi*T))),
        ('OptionVega[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: S*sqrt(T)*exp(-((log(S/K) + (r + sig**2/2)*T)**2)/(2*sig**2*T))/sqrt(2*pi)),
        ('OptionTheta[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: -S*sig*exp(-((log(S/K) + (r + sig**2/2)*T)**2)/(2*sig**2*T))/(2*sqrt(2*pi*T)) - r*K*exp(-r*T)),
        ('OptionRho[S_, K_, r_, sigma_, T_]', lambda S, K, r, sig, T: K*T*exp(-r*T)),
        ('ImpliedVolatility[price_, S_, K_, r_, T_]', lambda P, S, K, r, T: 0.2),  # Iterative solution placeholder
        ('PutCallParity[C_, P_, S_, K_, r_, T_]', lambda C, P, S, K, r, T: C - P - S + K*exp(-r*T)),
        ('OptionIntrinsicValue[S_, K_, type_]', lambda S, K, typ: max(S - K, 0) if str(typ) == 'call' else max(K - S, 0)),
        ('OptionTimeValue[premium_, intrinsic_]', lambda prem, intr: prem - intr),
        ('MoneynessCal l[S_, K_]', lambda S, K: S / K),
        ('BinomialTree[S_, u_, d_, r_, T_, n_]', lambda S, u, d, r, T, n: S * u**n),
        ('RiskNeutralProbability[u_, d_, r_, dt_]', lambda u, d, r, dt: (exp(r*dt) - d) / (u - d)),
        ('TrinomialTree[S_, u_, m_, d_]', lambda S, u, m, d: S * u),
        ('MonteCarloOptionPrice[S_, K_, r_, sigma_, T_, sims_]', lambda S, K, r, sig, T, n: S),  # Simplified
        ('AmericanOptionLSM[S_, K_, r_, sigma_, T_, paths_]', lambda S, K, r, sig, T, p: K - S),  # Longstaff-Schwartz
        ('BarrierOption[S_, K_, H_, type_]', lambda S, K, H, typ: S),
        ('AsianOption[avg_price_, K_]', lambda avg, K: max(avg - K, 0)),
        ('LookbackOption[S_max_, K_]', lambda Smax, K: Smax - K),
        ('DigitalOption[S_, K_]', lambda S, K: 1 if S > K else 0),
        ('CompoundOption[option_on_option_]', lambda oo: oo),
        ('RainbowOption[S1_, S2_, K_]', lambda S1, S2, K: max(max(S1, S2) - K, 0)),
        ('BasketOption[weights_, prices_, K_]', lambda w, p, K: max(sum(wi*pi for wi, pi in zip(w, p)) - K, 0)),
        ('SpreadOption[S1_, S2_, K_]', lambda S1, S2, K: max(S1 - S2 - K, 0)),
        ('VarianceSwap[realized_var_, strike_var_]', lambda rv, sv: rv - sv),
        ('VolatilitySwap[realized_vol_, strike_vol_]', lambda rv, sv: rv - sv),
        ('ForwardStart Option[S_, K_, T1_, T2_]', lambda S, K, T1, T2: S),
        ('CliquetOption[returns_]', lambda ret: sum(ret)),
        ('QuantoOption[domestic_, foreign_, corr_]', lambda dom, for_, corr: dom * for_ * corr),
        ('CompositeOption[underlying1_, underlying2_]', lambda u1, u2: u1 + u2),
        ('PowerOption[S_, K_, power_]', lambda S, K, p: max(S**p - K, 0)),
        ('LogOption[S_, K_]', lambda S, K: max(log(S) - K, 0)),
        ('GapOption[S_, K1_, K2_]', lambda S, K1, K2: max(S - K1, 0) if S > K2 else 0),
        ('ExchangeOption[S1_, S2_]', lambda S1, S2: max(S1 - S2, 0)),
        ('ChooserOption[call_value_, put_value_, T_choice_]', lambda C, P, T: max(C, P)),
        ('ShoutOption[max_intrinsic_]', lambda mi: mi),
        ('CappedOption[intrinsic_, cap_]', lambda intr, cap: min(intr, cap)),
        ('LadderOption[rungs_hit_]', lambda rungs: sum(rungs)),
        ('ParisianOption[S_, K_, barrier_time_]', lambda S, K, bt: S if bt > sp.Symbol('threshold') else 0),
        ('BermudanOption[exercise_dates_]', lambda dates: max(dates)),
        ('SwingOption[min_volume_, max_volume_]', lambda minv, maxv: (minv + maxv)/2),
        ('ForwardContract[S_, F_, T_]', lambda S, F, T: S - F*exp(-sp.Symbol('r')*T)),
        ('FuturesPrice[S_, r_, q_, T_]', lambda S, r, q, T: S*exp((r - q)*T)),
        ('CostOfCarry[r_, q_]', lambda r, q: r - q),
        ('BasisRisk[spot_, futures_]', lambda spot, fut: spot - fut),
        ('ContangoBackwardation[F_, S_]', lambda F, S: 'contango' if F > S else 'backwardation'),
        
        # ===== FIXED INCOME (40 functions) =====
        ('BondPrice[C_, r_, n_, F_]', lambda C, r, n, F: sum(C*exp(-r*i) for i in range(1, int(n)+1)) + F*exp(-r*n)),
        ('YieldToMaturity[P_, C_, F_, n_]', lambda P, C, F, n: (C + (F - P)/n) / ((F + P)/2)),  # Approximation
        ('CurrentYield[C_, P_]', lambda C, P: C / P),
        ('DurationMacaulay[cashflows_, times_, ytm_]', lambda cf, t, y: sum(ti*cfi*exp(-y*ti) for ti, cfi in zip(t, cf)) / sum(cfi*exp(-y*ti) for cfi in cf)),
        ('DurationModified[macaulay_, ytm_, m_]', lambda mac, y, m: mac / (1 + y/m)),
        ('Convexity[cashflows_, times_, ytm_]', lambda cf, t, y: sum(ti**2*cfi*exp(-y*ti) for ti, cfi in zip(t, cf)) / sum(cfi*exp(-y*ti) for cfi in cf)),
        ('PriceChange[duration_, convexity_, delta_y_]', lambda dur, conv, dy: -dur*dy + sp.Rational(1,2)*conv*dy**2),
        ('AccruedInterest[coupon_, days_since_, days_total_]', lambda C, ds, dt: C * ds / dt),
        ('CleanPrice[dirty_, accrued_]', lambda dirty, acc: dirty - acc),
        ('DirtyPrice[clean_, accrued_]', lambda clean, acc: clean + acc),
        ('ZeroCouponBondPrice[F_, r_, T_]', lambda F, r, T: F * exp(-r*T)),
        ('SpotRate[zero_prices_, T_]', lambda zp, T: -log(zp) / T),
        ('ForwardRate[r1_, T1_, r2_, T2_]', lambda r1, T1, r2, T2: (r2*T2 - r1*T1) / (T2 - T1)),
        ('YieldCurve[maturities_, yields_]', lambda mat, yld: list(zip(mat, yld))),
        ('TermStructure[spot_rates_]', lambda sr: sr),
        ('BootstrappingYieldCurve[bond_prices_]', lambda bp: [log(1/p) for p in bp]),
        ('NelsonSiegel[beta0_, beta1_, beta2_, tau_, T_]', lambda b0, b1, b2, tau, T: b0 + (b1 + b2)*(1 - exp(-T/tau))/(T/tau) - b2*exp(-T/tau)),
        ('Svensson[beta0_, beta1_, beta2_, beta3_, tau1_, tau2_, T_]', lambda b0, b1, b2, b3, t1, t2, T: b0 + b1*(1-exp(-T/t1))/(T/t1)),
        ('ParRate[spot_rates_, maturities_]', lambda sr, mat: sr[-1]),  # Simplified
        ('SwapRate[fixed_leg_, floating_leg_]', lambda fix, flt: fix / flt),
        ('InterestRateSwapValue[fixed_, floating_, notional_]', lambda fix, flt, N: (fix - flt) * N),
        ('BasisSwap[rate1_, rate2_]', lambda r1, r2: r1 - r2),
        ('CrossCurrencySwap[dom_, for_, fx_]', lambda dom, for_, fx: dom - for_*fx),
        ('InflationLinkedBond[principal_, CPI_now_, CPI_then_]', lambda P, CPIn, CPIt: P * CPIt / CPIn),
        ('RealYield[nominal_yield_, inflation_]', lambda ny, inf: (1 + ny) / (1 + inf) - 1),
        ('FisherEquation[real_, inflation_]', lambda r, i: (1 + r)*(1 + i) - 1),
        ('CreditSpread[corporate_yield_, riskfree_yield_]', lambda corp, rf: corp - rf),
        ('DefaultProbability[spread_, recovery_]', lambda s, R: s / (1 - R)),
        ('RecoveryRate[recovered_, face_]', lambda rec, F: rec / F),
        ('CreditDefaultSwapValue[spread_, notional_, duration_]', lambda s, N, dur: s * N * dur),
        ('HazardRate[default_prob_]', lambda dp: -log(1 - dp)),
        ('SurvivalProbability[hazard_, t_]', lambda h, t: exp(-h*t)),
        ('CDSSpread[default_prob_, recovery_, duration_]', lambda dp, R, dur: dp * (1 - R) / dur),
        ('MoodysKMV[asset_value_, debt_, asset_vol_]', lambda V, D, sigV: (V - D) / (V * sigV)),
        ('DistanceToDefault[EDF_]', lambda EDF: -sp.stats.Normal('z', 0, 1).ppf(EDF)),
        ('ExpectedDefaultFrequency[DD_]', lambda DD: sp.stats.Normal('z', 0, 1).cdf(-DD)),
        ('AltmanZScore[ratios_]', lambda r: sum(r)),  # Simplified
        ('MertonModel[V_, D_, r_, sigma_, T_]', lambda V, D, r, sig, T: V - D*exp(-r*T)),
        ('StructuralCreditModel[assets_, liabilities_]', lambda A, L: A > L),
        ('ReducedFormModel[intensity_]', lambda lam: exp(-lam*t)),
        
        # ===== PORTFOLIO THEORY (40 functions) =====
        ('PortfolioReturn[weights_, returns_]', lambda w, r: sum(wi*ri for wi, ri in zip(w, r))),
        ('PortfolioVariance[weights_, cov_matrix_]', lambda w, cov: sum(sum(wi*wj*cov[i][j] for j, wj in enumerate(w)) for i, wi in enumerate(w))),
        ('PortfolioStdDev[variance_]', lambda var: sqrt(var)),
        ('SharpeRatio[return_, rf_, stddev_]', lambda ret, rf, std: (ret - rf) / std),
        ('SortinoRatio[return_, rf_, downside_dev_]', lambda ret, rf, dd: (ret - rf) / dd),
        ('TreynorRatio[return_, rf_, beta_]', lambda ret, rf, beta: (ret - rf) / beta),
        ('InformationRatio[excess_return_, tracking_error_]', lambda er, te: er / te),
        ('JensensAlpha[return_, rf_, beta_, market_return_]', lambda ret, rf, beta, rm: ret - (rf + beta*(rm - rf))),
        ('Beta[cov_asset_market_, var_market_]', lambda cov, var: cov / var),
        ('SystematicRisk[beta_, market_var_]', lambda beta, varm: beta**2 * varm),
        ('UnsystematicRisk[total_var_, systematic_var_]', lambda vart, vars: vart - vars),
        ('CapitalAssetPricingModel[rf_, beta_, rm_]', lambda rf, beta, rm: rf + beta*(rm - rf)),
        ('SecurityMarketLine[rf_, beta_, rm_]', lambda rf, beta, rm: rf + beta*(rm - rf)),
        ('CapitalMarketLine[rf_, rm_, sigma_m_, sigma_p_]', lambda rf, rm, sigm, sigp: rf + ((rm - rf)/sigm)*sigp),
        ('EfficientFrontier[returns_, risks_]', lambda ret, risk: list(zip(risk, ret))),
        ('MinimumVariancePortfolio[cov_matrix_]', lambda cov: [1/len(cov)]*len(cov)),  # Simplified
        ('TangencyPortfolio[returns_, cov_, rf_]', lambda ret, cov, rf: ret),  # Simplified
        ('MarketPortfolio[weights_]', lambda w: w),
        ('RiskParityWeights[vol_]', lambda vol: [1/vi for vi in vol]),
        ('MaximumSharpePortfolio[returns_, cov_, rf_]', lambda ret, cov, rf: ret),
        ('BlackLitterman[prior_, views_, confidence_]', lambda prior, views, conf: prior + views*conf),
        ('DownsideDeviation[returns_, MAR_]', lambda ret, MAR: sqrt(sum((ri - MAR)**2 for ri in ret if ri < MAR)/len(ret))),
        ('UpsideDeviation[returns_, threshold_]', lambda ret, th: sqrt(sum((ri - th)**2 for ri in ret if ri > th)/len(ret))),
        ('MaxDrawdown[prices_]', lambda p: max((max(p[:i+1]) - p[i])/max(p[:i+1]) for i in range(len(p)))),
        ('CalmarRatio[return_, max_drawdown_]', lambda ret, mdd: ret / mdd),
        ('OmegaRatio[returns_, threshold_]', lambda ret, th: sum(max(r - th, 0) for r in ret) / sum(max(th - r, 0) for r in ret)),
        ('ValueAtRisk[returns_, confidence_]', lambda ret, conf: sorted(ret)[int((1-conf)*len(ret))]),
        ('ConditionalVaR[returns_, VaR_]', lambda ret, var: sum(r for r in ret if r < var) / len([r for r in ret if r < var])),
        ('ExpectedShortfall[returns_, confidence_]', lambda ret, conf: sum(sorted(ret)[:int((1-conf)*len(ret))]) / int((1-conf)*len(ret))),
        ('RiskMetrics[returns_]', lambda ret: sqrt(sum((r - sum(ret)/len(ret))**2 for r in ret)/len(ret))),
        ('TrackingError[portfolio_returns_, benchmark_returns_]', lambda pr, br: sqrt(sum((pri - bri)**2 for pri, bri in zip(pr, br))/len(pr))),
        ('ActiveReturn[portfolio_, benchmark_]', lambda p, b: p - b),
        ('TeynorMazuy[alpha_, beta_, gamma_]', lambda a, b, g: a + b*sp.Symbol('Rm') + g*sp.Symbol('Rm')**2),
        ('HenriksonMerton[alpha_, b1_, b2_]', lambda a, b1, b2: a + b1*sp.Symbol('Rm') + b2*max(sp.Symbol('Rm'), 0)),
        ('MultiFactorModel[factors_, loadings_]', lambda f, l: sum(fi*li for fi, li in zip(f, l))),
        ('FamaFrenchThreeFactor[rf_, rm_rf_, SMB_, HML_]', lambda rf, rmrf, SMB, HML: rf + sp.Symbol('b1')*rmrf + sp.Symbol('b2')*SMB + sp.Symbol('b3')*HML),
        ('CarhartFourFactor[rf_, rm_rf_, SMB_, HML_, MOM_]', lambda rf, rmrf, SMB, HML, MOM: rf + sp.Symbol('b1')*rmrf + sp.Symbol('b2')*SMB + sp.Symbol('b3')*HML + sp.Symbol('b4')*MOM),
        ('APTModel[factors_]', lambda f: sp.Symbol('rf') + sum(sp.Symbol(f'b{i}')*fi for i, fi in enumerate(f))),
        ('FactorExposure[return_, factor_]', lambda ret, fac: sp.diff(ret, fac)),
        ('RollingCorrelation[series1_, series2_, window_]', lambda s1, s2, w: 0.5),
        
        # ===== ECONOMETRICS (40 functions) =====
        ('OLSEstimator[X_, y_]', lambda X, y: [0]),  # (X'X)^-1 X'y simplified
        ('RSquared[SSR_, SST_]', lambda SSR, SST: 1 - SSR/SST),
        ('AdjustedRSquared[R2_, n_, k_]', lambda R2, n, k: 1 - (1 - R2)*(n - 1)/(n - k - 1)),
        ('TStatistic[beta_, se_]', lambda b, se: b / se),
        ('FStatistic[R2_, n_, k_]', lambda R2, n, k: (R2/k) / ((1 - R2)/(n - k - 1))),
        ('StandardError[residuals_, n_, k_]', lambda res, n, k: sqrt(sum(r**2 for r in res) / (n - k - 1))),
        ('ConfidenceInterval[beta_, se_, t_critical_]', lambda b, se, tc: (b - tc*se, b + tc*se)),
        ('CoefficientOfVariation[std_, mean_]', lambda std, mu: std / mu),
        ('DurbinWatsonStatistic[residuals_]', lambda res: sum((res[i] - res[i-1])**2 for i in range(1, len(res))) / sum(r**2 for r in res)),
        ('BreuschGodfreyTest[residuals_, lags_]', lambda res, p: 1.0),  # LM test
        ('WhiteTestHeteroskedasticity[residuals_, fitted_]', lambda res, fit: 1.0),
        ('BreuschPaganTest[residuals_, X_]', lambda res, X: 1.0),
        ('GoldfeldQuandtTest[residuals1_, residuals2_]', lambda r1, r2: sum(ri**2 for ri in r1) / sum(ri**2 for ri in r2)),
        ('JarqueBeraStatistic[skew_, kurtosis_, n_]', lambda s, k, n: n/6 * (s**2 + (k - 3)**2/4)),
        ('GrangerCausality[X_, Y_, lags_]', lambda X, Y, p: 1.0),  # F-test
        ('EngleGrangerCointegration[residuals_]', lambda res: -3.0),  # ADF on residuals
        ('JohansenCointegration[series_]', lambda s: 1),  # Number of cointegrating vectors
        ('VectorAutoregression[Y_, lags_]', lambda Y, p: [[0]]),
        ('ImpulseResponse[VAR_, shock_]', lambda VAR, shock: [0, 0.5, 0.3, 0.1]),
        ('ForecastErrorVarianceDecomp[VAR_]', lambda VAR: [[0.7, 0.3], [0.4, 0.6]]),
        ('HodrickPrescott Filter[series_, lambda_]', lambda s, lam: s),  # Trend component
        ('BaxterKingFilter[series_, low_, high_]', lambda s, lo, hi: s),
        ('ChristianFitzgeraldFilter[series_]', lambda s: s),
        ('X11SeasonalAdjustment[series_]', lambda s: s),
        ('ARIMAModel[p_, d_, q_]', lambda p, d, q: f'ARIMA({p},{d},{q})'),
        ('ARCHEffect[residuals_, lags_]', lambda res, q: sum(res[i]**2 for i in range(-int(q), 0))),
        ('GARCHVolatility[alpha_, beta_, epsilon_]', lambda a, b, e: a + b*sp.Symbol('sigma_prev')**2 + sp.Symbol('gamma')*e**2),
        ('EGARCH[asymmetry_]', lambda asym: asym),
        ('StationarityTest[series_]', lambda s: True),
        ('UnitRootTestADF[series_]', lambda s: -3.5),
        ('PhillipsPerronTest[series_]', lambda s: -3.5),
        ('KPSSTest[series_]', lambda s: 0.3),
        ('ZivotAndrewsStructuralBreak[series_]', lambda s: len(s)//2),
        ('ChowStructuralBreakTest[rss1_, rss2_, rss_pooled_, n1_, n2_, k_]', lambda r1, r2, rp, n1, n2, k: ((rp - r1 - r2)/k) / ((r1 + r2)/(n1 + n2 - 2*k))),
        ('HausmanTest[b_consistent_, b_efficient_, V_diff_]', lambda bc, be, Vd: (bc - be)**2 / Vd),
        ('InstrumentalVariablesEstimator[Y_, X_, Z_]', lambda Y, X, Z: [0]),  # (Z'X)^-1 Z'Y
        ('TwoStageLeastSquares[Y_, X_, Z_]', lambda Y, X, Z: [0]),
        ('GeneralizedMethodOfMoments[moments_]', lambda m: [0]),
        ('QuasiMaximumLikelihood[logL_]', lambda logL: sp.Symbol('theta')),
        ('RobustStandardErrors[residuals_, X_]', lambda res, X: [0.1]),
        ('ClusteredStandardErrors[residuals_, clusters_]', lambda res, cl: [0.1]),
        
        # ===== GAME THEORY (30 functions) =====
        ('NashEquilibrium[payoff_matrix_]', lambda pm: (0, 0)),
        ('DominantStrategy[payoffs_]', lambda p: 'strategy1'),
        ('DominatedStrategy[payoffs_]', lambda p: 'strategy2'),
        ('MixedStrategyEquilibrium[payoffs_]', lambda p: (0.5, 0.5)),
        ('BestResponse[opponent_strategy_, payoffs_]', lambda os, p: 'response'),
        ('ParetoOptimal[allocations_]', lambda a: a[0]),
        ('ParetoImprovement[allocation1_, allocation2_]', lambda a1, a2: a2),
        ('CoreAllocation[coalitions_]', lambda c: c),
        ('ShapleyValue[coalitions_, players_]', lambda c, p: {pi: 1/len(p) for pi in p}),
        ('CooperativeGame[coalitions_]', lambda c: c),
        ('NonCooperativeGame[strategies_]', lambda s: s),
        ('ZeroSumGame[payoffs_]', lambda p: sum(p) == 0),
        ('PrisonersDilemma[payoffs_]', lambda p: 'defect'),
        ('BattleOfTheSexes[payoffs_]', lambda p: 'coordinate'),
        ('ChickenGame[payoffs_]', lambda p: 'swerve'),
        ('StagHunt[payoffs_]', lambda p: 'hunt'),
        ('CoordinationGame[payoffs_]', lambda p: 'coordinate'),
        ('RepeatedGame[stage_game_, discount_]', lambda sg, d: sg),
        ('SubgamePerfectEquilibrium[game_tree_]', lambda gt: 'SPE'),
        ('BackwardInduction[game_tree_]', lambda gt: 'terminal_node'),
        ('TremblendHandPerfection[equilibrium_, epsilon_]', lambda eq, eps: eq),
        ('PerfectBayesianEquilibrium[beliefs_]', lambda b: b),
        ('SignalingGame[types_, signals_]', lambda t, s: (t, s)),
        ('PoolingEquilibrium[types_]', lambda t: 'same_signal'),
        ('SeparatingEquilibrium[types_]', lambda t: 'different_signals'),
        ('MechanismDesign[valuations_]', lambda v: 'mechanism'),
        ('VickreyAuction[bids_]', lambda b: (max(b), sorted(b)[-2])),  # Winner, price
        ('EnglishAuction[bids_]', lambda b: max(b)),
        ('DutchAuction[price_descent_]', lambda pd: pd),
        ('SealedBidAuction[bids_]', lambda b: max(b)),
        ('AllPayAuction[bids_]', lambda b: max(b)),
        ('DoubleAuction[buy_bids_, sell_asks_]', lambda bb, sa: (max(bb) + min(sa))/2),
        ('ReservePriceOptimal[valuations_, costs_]', lambda v, c: (max(v) + min(c))/2),
        ('RevenuEquivalenceTheorem[mechanism1_, mechanism2_]', lambda m1, m2: m1 == m2),
    ]


def register():
    """Register all extended19 rules"""
    from .extended_helper import convert_rules
    return convert_rules(get_rules())
