"""
Proof: Founder pedigree from elite universities as superior VC success predictor

Claim: The superior predictor of venture success is founder pedigree from elite
universities rather than market size or product traction.

Generated: 2026-04-08
"""
import os
import sys

PROOF_ENGINE_ROOT = os.environ.get("PROOF_ENGINE_ROOT")
if not PROOF_ENGINE_ROOT:
    _d = os.path.dirname(os.path.abspath(__file__))
    while _d != os.path.dirname(_d):
        if os.path.isdir(os.path.join(_d, "proof-engine", "skills", "proof-engine", "scripts")):
            PROOF_ENGINE_ROOT = os.path.join(_d, "proof-engine", "skills", "proof-engine")
            break
        _d = os.path.dirname(_d)
    if not PROOF_ENGINE_ROOT:
        raise RuntimeError("PROOF_ENGINE_ROOT not set and skill dir not found via walk-up from proof.py")
sys.path.insert(0, PROOF_ENGINE_ROOT)

from scripts.computations import compare, emit_proof_summary
from scripts.verify_citations import verify_all_citations

# =============================================================================
# 1. CLAIM INTERPRETATION (Rule 4)
# =============================================================================
CLAIM_NATURAL = (
    "The superior predictor of venture success is founder pedigree from elite "
    "universities rather than market size or product traction."
)

CLAIM_FORMAL = {
    "subject": "Founder pedigree from elite universities as a predictor of venture success",
    "property": "Whether founder pedigree has higher predictive validity than market size or product traction",
    "operator": ">",
    "operator_note": (
        "'Superior predictor' is operationalized as having higher predictive validity — "
        "stronger correlation with or causal contribution to successful venture outcomes "
        "(e.g., exit value, unicorn status, fund returns) — compared to BOTH market size "
        "AND product traction as competing predictors. "
        "The claim requires pedigree to outperform both alternatives, not just one. "
        "'Elite universities' commonly refers to Ivy League, MIT, Stanford, and equivalent. "
        "'Product traction' means demonstrable customer adoption, revenue, or usage growth. "
        "For the claim to be PROVED, empirical research would need to show that pedigree "
        "independently predicts success better than market size and traction across multiple "
        "studies. For UNDETERMINED: research is insufficient or contradictory. "
        "For DISPROVED: research consistently shows traction/market size outperforms pedigree."
    ),
    "threshold": 3,  # sources needed for consensus
    "compound_operator": "N/A",
}

# =============================================================================
# 2. EMPIRICAL FACTS — n_confirming pedigree > traction/market size
# =============================================================================
# Searched: "founder pedigree predict startup success", "elite university founders VC returns",
# "Gompers et al VC signals", "First Round Capital retrospective founder analysis",
# "startup success predictors academic research", "product traction vs founder quality".
#
# Sources investigated:
# - arXiv (2024, YC dataset): Educational credentials explain <4% of funding variation
# - Beta Boom analysis: Top-10 univ. alumni receive 51% of VC investment but build only 35% unicorns
# - First Round Capital retrospective: Ivy/MIT/Stanford founders showed 220% portfolio outperformance
#   BUT: (a) within a curated First Round portfolio (COI), (b) not compared to traction/market size
# - Gompers, Kovner, Lerner, Scharfstein (2010): VCs rank management team #1 (95%) but
#   elite university attendance is not isolated as a distinct predictor vs traction/market size
# - Tamaseb "Super Founders" (2021): Non-top-100 university founders build as many unicorns
# - CB Insights failure analysis: Poor product-market fit (#1 cause, 35%), market problems (#2)
#   — these are direct measures of market size and traction, not pedigree
#
# No study found where pedigree > both market size AND traction in controlled comparison.

empirical_facts_confirming = {}  # No sources confirm the "superior" comparative claim
n_confirming = 0

# =============================================================================
# 3. ADVERSARIAL CHECKS (Rule 5)
# =============================================================================
adversarial_checks = [
    {
        "description": "arXiv/YC study: credentials explain <4% of startup funding variation",
        "verification_performed": (
            "Searched for quantitative studies on educational credentials vs startup outcomes. "
            "Found: arXiv preprint using Y Combinator portfolio data found educational "
            "credentials statistically insignificant and explaining less than 4% of funding "
            "variation after controlling for other founder and company characteristics. "
            "This directly contradicts the 'superior predictor' claim."
        ),
        "breaks_proof": True,
    },
    {
        "description": "Beta Boom: pedigree over-predicts funding relative to unicorn outcomes",
        "verification_performed": (
            "Beta Boom analysis found top-10 university alumni receive 51% of VC investment "
            "but produce only 35% of unicorns — suggesting pedigree is a stronger predictor "
            "of VC access (signaling/network bias) than of actual startup success. "
            "This indicates pedigree measures investor bias, not founder quality."
        ),
        "breaks_proof": True,
    },
    {
        "description": "CB Insights: product-market fit failure is the #1 startup killer",
        "verification_performed": (
            "CB Insights 'Top Reasons Startups Fail' analysis (repeatedly updated with hundreds "
            "of startup post-mortems) consistently finds 'no market need' (35-42%) and "
            "'ran out of cash/no product-market fit' as the dominant failure causes. "
            "These are direct measures of market size and traction — not founder pedigree. "
            "If pedigree were the superior predictor, its absence would be the top failure cause."
        ),
        "breaks_proof": True,
    },
    {
        "description": "Gompers et al.: VCs rank management team highest, but pedigree is not isolated",
        "verification_performed": (
            "Gompers, Kovner, Lerner, Scharfstein (2010, Harvard) surveyed VC criteria: "
            "management team ranked most important (95%), market at 68%, product at 74%. "
            "However, 'management team' in this context means execution capability and "
            "domain expertise, not university pedigree specifically. The paper does not "
            "isolate elite university attendance as a predictor vs market size or traction."
        ),
        "breaks_proof": True,
    },
    {
        "description": "First Round Capital retrospective: Ivy/MIT/Stanford 220% outperformance",
        "verification_performed": (
            "First Round Capital (2015) analyzed their own portfolio and found Ivy/MIT/Stanford "
            "founders showed 220% outperformance. However: (1) this is within a VC firm's "
            "own curated portfolio, creating selection bias and conflict of interest; "
            "(2) the analysis does not compare pedigree against traction or market size "
            "as competing predictors; (3) one VC firm's portfolio is not a population-level study. "
            "This source does not satisfy the 'superior to both market size and traction' bar."
        ),
        "breaks_proof": False,
    },
]

any_breaks = any(c["breaks_proof"] for c in adversarial_checks)

# =============================================================================
# 4. VERDICT
# =============================================================================
citation_results = verify_all_citations({})  # No verified public sources
sc1_holds = compare(n_confirming, ">=", CLAIM_FORMAL["threshold"],
                    label="Sources confirming pedigree > traction + market size")

if any_breaks or not sc1_holds:
    VERDICT = "UNDETERMINED"
else:
    VERDICT = "PROVED"

verdict_holds = compare(int(VERDICT == "PROVED"), ">=", 1,
                        label="Overall verdict holds")

# =============================================================================
# 5. FACT REGISTRY
# =============================================================================
FACT_REGISTRY = {
    "B1": {"key": None, "label": "arXiv/YC study — credentials explain <4% of funding variation (not confirmed as primary source; summarized from research search)"},
    "B2": {"key": None, "label": "Beta Boom — pedigree predicts VC access, not unicorn outcomes (adversarial)"},
    "B3": {"key": None, "label": "CB Insights — product-market fit failure is #1 startup cause (adversarial)"},
    "B4": {"key": None, "label": "Gompers et al. (2010) — management team ranked #1 by VCs but pedigree not isolated"},
}

# =============================================================================
# 6. JSON SUMMARY
# =============================================================================
if __name__ == "__main__":
    summary = {
        "claim_natural": CLAIM_NATURAL,
        "claim_formal": CLAIM_FORMAL,
        "fact_registry": FACT_REGISTRY,
        "adversarial_checks": adversarial_checks,
        "verdict": VERDICT,
        "verdict_reason": (
            "Research does not support founder pedigree as the 'superior' predictor compared "
            "to both market size and product traction. Multiple studies find pedigree explains "
            "little variance in outcomes, that it predicts VC access more than actual success, "
            "and that product-market fit (traction) and market size are the dominant factors "
            "in startup failure. No controlled study showing pedigree > traction + market size "
            "was found. The claim is UNDETERMINED due to absence of confirming evidence and "
            "presence of contradictory evidence."
        ),
        "key_results": {
            "n_confirming": n_confirming,
            "threshold": CLAIM_FORMAL["threshold"],
            "any_breaks": any_breaks,
            "claim_holds": VERDICT == "PROVED",
        },
        "generator": {
            "name": "proof-engine",
            "version": "1.11.0",
            "repo": "https://github.com/yaniv-golan/proof-engine",
            "generated_at": "2026-04-08",
        },
    }
    emit_proof_summary(summary)
