"<!DOCTYPE html>\n<html lang=\"zh\" data-theme=\"light\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>fulltext.txt — Vercel Design System</title>\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap\" rel=\"stylesheet\">\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css\">\n<style>\n\n:root {\n  /* Vercel Palette */\n  --geist-foreground: #171717;\n  --geist-background: #ffffff;\n  --geist-secondary: #4d4d4d;\n  --geist-tertiary: #666666;\n  --geist-quaternary: #808080;\n  --geist-border: #ebebeb;\n  --geist-surface-tint: #fafafa;\n  \n  /* Workflow Accents */\n  --develop-blue: #0a72ef;\n  --preview-pink: #de1d8d;\n  --ship-red: #ff5b4f;\n  \n  /* Interactive & Status */\n  --link-blue: #0072f5;\n  --ds-focus-color: hsla(212, 100%, 48%, 1);\n  --badge-blue-bg: #ebf5ff;\n  --badge-blue-text: #0068d6;\n  \n  /* Shadow-as-Border Philosophy */\n  --shadow-border: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;\n  --shadow-border-hover: rgba(0, 0, 0, 0.16) 0px 0px 0px 1px;\n  --shadow-card: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 2px 2px, #fafafa 0px 0px 0px 1px;\n  --shadow-card-hover: rgba(0, 0, 0, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.06) 0px 4px 6px, #fafafa 0px 0px 0px 1px;\n  --shadow-card-full: rgba(0, 0, 0, 0.08) 0px 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 2px 2px, rgba(0, 0, 0, 0.04) 0px 8px 8px -8px, #fafafa 0px 0px 0px 1px;\n  --shadow-ring: rgb(235, 235, 235) 0px 0px 0px 1px;\n  \n  /* Radius Scale */\n  --radius-xs: 2px;\n  --radius-sm: 4px;\n  --radius-md: 6px;\n  --radius-lg: 8px;\n  --radius-xl: 12px;\n  --radius-pill: 9999px;\n}\n\n[data-theme=\"dark\"] {\n  --geist-foreground: #ededed;\n  --geist-background: #000000;\n  --geist-secondary: #a1a1a1;\n  --geist-tertiary: #888888;\n  --geist-quaternary: #666666;\n  --geist-border: #222222;\n  --geist-surface-tint: #0a0a0a;\n  \n  --shadow-border: rgba(255, 255, 255, 0.14) 0px 0px 0px 1px;\n  --shadow-border-hover: rgba(255, 255, 255, 0.28) 0px 0px 0px 1px;\n  --shadow-card: rgba(255, 255, 255, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.4) 0px 2px 4px, #111111 0px 0px 0px 1px;\n  --shadow-card-hover: rgba(255, 255, 255, 0.2) 0px 0px 0px 1px, rgba(0, 0, 0, 0.5) 0px 6px 12px, #111111 0px 0px 0px 1px;\n  --shadow-card-full: rgba(255, 255, 255, 0.12) 0px 0px 0px 1px, rgba(0, 0, 0, 0.5) 0px 8px 16px -4px, #111111 0px 0px 0px 1px;\n  --shadow-ring: rgb(40, 40, 40) 0px 0px 0px 1px;\n  \n  --badge-blue-bg: rgba(10, 114, 239, 0.15);\n  --badge-blue-text: #70b5ff;\n}\n\n* { box-sizing: border-box; }\nhtml { scroll-behavior: smooth; }\nbody {\n  margin: 0;\n  font-family: \"Geist\", Arial, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n  background-color: var(--geist-background);\n  color: var(--geist-foreground);\n  font-feature-settings: \"liga\" 1;\n  -webkit-font-smoothing: antialiased;\n  min-height: 100vh;\n}\n\na {\n  color: inherit;\n  text-decoration: none;\n  transition: color 0.15s ease;\n}\n\n/* 导航栏 (Vercel Clean Sticky Nav) */\n.vercel-nav {\n  position: sticky;\n  top: 0;\n  background-color: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  z-index: 100;\n  padding: 0 24px;\n  height: 64px;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n}\n.nav-brand {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n.vercel-triangle {\n  width: 22px;\n  height: 19px;\n  fill: var(--geist-foreground);\n}\n.nav-title {\n  font-size: 16px;\n  font-weight: 600;\n  letter-spacing: -0.32px;\n  color: var(--geist-foreground);\n}\n.nav-badge-pill {\n  font-family: \"Geist Mono\", ui-monospace, monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  background: var(--badge-blue-bg);\n  color: var(--badge-blue-text);\n  padding: 2px 8px;\n  border-radius: var(--radius-pill);\n}\n\n.nav-links {\n  display: flex;\n  align-items: center;\n  gap: 24px;\n}\n.nav-link {\n  font-size: 14px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  text-decoration: none;\n  transition: color 0.15s;\n}\n.nav-link:hover, .nav-link.active {\n  color: var(--geist-foreground);\n}\n.nav-link.active {\n  font-weight: 600;\n}\n\n.nav-actions {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n\n/* 按钮规范 */\n.btn-primary-dark {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border: none;\n  padding: 8px 16px;\n  border-radius: var(--radius-md);\n  font-size: 14px;\n  font-weight: 500;\n  cursor: pointer;\n  text-decoration: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  transition: opacity 0.15s;\n}\n.btn-primary-dark:hover {\n  opacity: 0.9;\n}\n.btn-secondary-white {\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  box-shadow: var(--shadow-border);\n  border: none;\n  padding: 8px 16px;\n  border-radius: var(--radius-md);\n  font-size: 14px;\n  font-weight: 500;\n  cursor: pointer;\n  text-decoration: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  transition: background 0.15s, box-shadow 0.15s;\n}\n.btn-secondary-white:hover {\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border-hover);\n}\n.theme-toggle-btn {\n  background: transparent;\n  border: none;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  width: 36px;\n  height: 36px;\n  cursor: pointer;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  color: var(--geist-foreground);\n}\n\n/* 核心容器 */\n.vercel-container {\n  max-width: 1200px;\n  margin: 0 auto;\n  padding: 56px 24px 100px;\n}\n\n/* Hero Section (Gallery Emptiness + Negative Letter-spacing) */\n.vercel-hero {\n  text-align: center;\n  max-width: 860px;\n  margin: 0 auto 56px;\n}\n.hero-stage-badge {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  padding: 4px 14px;\n  border-radius: var(--radius-pill);\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  margin-bottom: 24px;\n}\n.stage-dot {\n  width: 7px;\n  height: 7px;\n  border-radius: 50%;\n}\n.vercel-hero h1 {\n  font-size: 48px;\n  font-weight: 600;\n  line-height: 1.05;\n  letter-spacing: -2.4px;\n  color: var(--geist-foreground);\n  margin: 0 0 16px;\n}\n.vercel-hero p {\n  font-size: 20px;\n  font-weight: 400;\n  line-height: 1.80;\n  color: var(--geist-secondary);\n  margin: 0 auto 28px;\n}\n\n/* Workflow Pipeline (Develop -> Preview -> Ship) */\n.workflow-pipeline {\n  display: grid;\n  grid-template-columns: repeat(3, 1fr);\n  gap: 16px;\n  margin-bottom: 48px;\n}\n@media (max-width: 768px) {\n  .workflow-pipeline { grid-template-columns: 1fr; }\n}\n.workflow-step {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px 22px;\n  transition: box-shadow 0.2s;\n}\n.workflow-step:hover {\n  box-shadow: var(--shadow-card-hover);\n}\n.step-mono-label {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 12px;\n  font-weight: 500;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  margin-bottom: 8px;\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n.step-title {\n  font-size: 20px;\n  font-weight: 600;\n  letter-spacing: -0.96px;\n  color: var(--geist-foreground);\n  margin-bottom: 6px;\n}\n.step-desc {\n  font-size: 14px;\n  color: var(--geist-secondary);\n  line-height: 1.5;\n}\n\n/* Metric Cards (Section 4 Spec) */\n.metric-grid {\n  display: grid;\n  grid-template-columns: repeat(4, 1fr);\n  gap: 16px;\n  margin-bottom: 48px;\n}\n@media (max-width: 900px) {\n  .metric-grid { grid-template-columns: repeat(2, 1fr); }\n}\n.metric-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n}\n.metric-number {\n  font-size: 40px;\n  font-weight: 600;\n  line-height: 1.0;\n  letter-spacing: -2.4px;\n  color: var(--geist-foreground);\n  margin-bottom: 8px;\n  font-feature-settings: \"tnum\" 1;\n}\n.metric-label {\n  font-size: 14px;\n  color: var(--geist-secondary);\n  line-height: 1.4;\n}\n\n/* VAD 专栏 Banner (Ship Red & Vercel Clean) */\n.vad-showcase {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-xl);\n  padding: 32px;\n  margin-bottom: 48px;\n  position: relative;\n}\n.vad-header-row {\n  display: flex;\n  align-items: baseline;\n  justify-content: space-between;\n  flex-wrap: wrap;\n  gap: 12px;\n  margin-bottom: 12px;\n}\n.vad-header-row h2 {\n  font-size: 32px;\n  font-weight: 600;\n  letter-spacing: -1.28px;\n  color: var(--geist-foreground);\n  margin: 0;\n}\n.vad-pillars-grid {\n  display: grid;\n  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));\n  gap: 14px;\n  margin-top: 24px;\n}\n.vad-pillar-item {\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  padding: 14px 16px;\n}\n.vad-pillar-title {\n  font-size: 14px;\n  font-weight: 600;\n  color: var(--ship-red);\n  margin-bottom: 4px;\n}\n.vad-pillar-text {\n  font-size: 13px;\n  color: var(--geist-secondary);\n  line-height: 1.5;\n}\n.vad-filter-bar {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  margin: 24px 0 16px;\n  padding: 12px 16px;\n  background: var(--geist-surface-tint);\n  border-radius: var(--radius-md);\n  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);\n}\n.vad-filter-btn {\n  font-family: 'Geist', sans-serif;\n  font-size: 13px;\n  font-weight: 500;\n  padding: 6px 14px;\n  border-radius: 9999px;\n  border: none;\n  background: transparent;\n  color: var(--geist-secondary);\n  cursor: pointer;\n  transition: all 0.15s ease;\n}\n.vad-filter-btn:hover {\n  color: var(--geist-foreground);\n  background: rgba(0,0,0,0.05);\n}\n.vad-filter-btn.active {\n  background: #171717;\n  color: #ffffff;\n}\n.vad-search-input {\n  font-family: 'Geist', sans-serif;\n  font-size: 13px;\n  padding: 7px 12px;\n  border-radius: 6px;\n  border: 1px solid var(--geist-border);\n  background: #ffffff;\n  color: var(--geist-foreground);\n  width: 280px;\n  outline: none;\n  transition: border-color 0.15s, box-shadow 0.15s;\n}\n.vad-search-input:focus {\n  border-color: #0a72ef;\n  box-shadow: 0 0 0 2px rgba(10, 114, 239, 0.2);\n}\n\n/* 控制栏：搜索、视图、筛选 */\n.control-bar {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  margin-bottom: 24px;\n  flex-wrap: wrap;\n}\n.search-input-wrap {\n  position: relative;\n  flex: 1;\n  max-width: 480px;\n}\n.search-input {\n  width: 100%;\n  height: 40px;\n  padding: 0 38px 0 14px;\n  font-family: \"Geist\", sans-serif;\n  font-size: 14px;\n  color: var(--geist-foreground);\n  background: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  border: none;\n  border-radius: var(--radius-md);\n  outline: none;\n  transition: box-shadow 0.15s;\n}\n.search-input:focus {\n  outline: 2px solid var(--ds-focus-color);\n  box-shadow: none;\n}\n.search-kbd {\n  position: absolute;\n  right: 12px;\n  top: 50%;\n  transform: translateY(-50%);\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  color: var(--geist-quaternary);\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  padding: 2px 6px;\n  border-radius: var(--radius-sm);\n}\n\n.view-switcher {\n  display: flex;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  background: var(--geist-background);\n  padding: 2px;\n}\n.view-btn {\n  background: transparent;\n  border: none;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-tertiary);\n  padding: 6px 12px;\n  border-radius: var(--radius-sm);\n  cursor: pointer;\n  transition: color 0.15s, background 0.15s;\n}\n.view-btn.active {\n  background: var(--geist-surface-tint);\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n/* 筛选芯片行 (Filter Pill Strip) */\n.filter-group-strip {\n  display: flex;\n  flex-direction: column;\n  gap: 12px;\n  margin-bottom: 28px;\n  padding: 16px 20px;\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-lg);\n}\n.filter-row {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  flex-wrap: wrap;\n}\n.filter-label-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  color: var(--geist-quaternary);\n  min-width: 68px;\n}\n.pill-badge {\n  background: var(--geist-background);\n  color: var(--geist-secondary);\n  box-shadow: var(--shadow-border);\n  border: none;\n  padding: 3px 12px;\n  border-radius: var(--radius-pill);\n  font-size: 12px;\n  font-weight: 500;\n  cursor: pointer;\n  transition: all 0.15s;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n}\n.pill-badge:hover {\n  color: var(--geist-foreground);\n  box-shadow: var(--shadow-border-hover);\n}\n.pill-badge.active {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  font-weight: 600;\n  box-shadow: none;\n}\n.pill-badge.active-blue {\n  background: var(--develop-blue);\n  color: #ffffff;\n  box-shadow: none;\n}\n.pill-badge.active-red {\n  background: var(--ship-red);\n  color: #ffffff;\n  box-shadow: none;\n}\n\n/* Bento Grid Cards (Section 4 & 6 Spec) */\n.card-grid-bento {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n  gap: 16px;\n}\n.vercel-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  transition: box-shadow 0.2s, transform 0.2s;\n  text-decoration: none;\n  color: inherit;\n  overflow: hidden;\n  min-width: 0;\n  word-break: break-word;\n}\n.vercel-card:hover {\n  box-shadow: var(--shadow-card-hover);\n  transform: translateY(-2px);\n}\n.card-top {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  margin-bottom: 12px;\n  gap: 8px;\n}\n.card-tag-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  font-weight: 500;\n  text-transform: uppercase;\n  color: var(--geist-quaternary);\n  letter-spacing: 0.5px;\n}\n.status-pill-badge {\n  padding: 2px 8px;\n  border-radius: var(--radius-pill);\n  font-size: 11px;\n  font-weight: 500;\n  flex-shrink: 0;\n}\n.pub-accepted { background: #ebfdf2; color: #027a48; }\n.pub-workshop { background: #eff8ff; color: #175cd3; }\n.pub-submitted { background: #fff8e6; color: #b54708; }\n.pub-preprint { background: #f2f4f7; color: #475467; }\n.pub-other { background: #f9f5ff; color: #6941c6; }\n\n[data-theme=\"dark\"] .pub-accepted { background: rgba(2, 122, 72, 0.2); color: #32d583; }\n[data-theme=\"dark\"] .pub-workshop { background: rgba(23, 92, 211, 0.2); color: #84caff; }\n[data-theme=\"dark\"] .pub-submitted { background: rgba(181, 71, 8, 0.2); color: #fec84b; }\n[data-theme=\"dark\"] .pub-preprint { background: rgba(71, 84, 103, 0.2); color: #98a2b3; }\n[data-theme=\"dark\"] .pub-other { background: rgba(105, 65, 198, 0.2); color: #d6bbfb; }\n\n/* 必读标杆徽章 (Vercel Amber Accent) */\n.milestone-badge {\n  display: inline-flex;\n  align-items: center;\n  gap: 3px;\n  padding: 2px 7px;\n  border-radius: var(--radius-pill);\n  font-size: 11px;\n  font-weight: 600;\n  white-space: nowrap;\n  flex-shrink: 0;\n  transition: all 0.15s ease;\n}\n.milestone-badge.ms-idea, .milestone-badge:not([class*=\"ms-\"]) {\n  color: #b54708;\n  background: #fff8e6;\n  border: 1px solid rgba(247, 144, 9, 0.35);\n  box-shadow: 0 1px 2px rgba(181, 71, 8, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-idea, [data-theme=\"dark\"] .milestone-badge:not([class*=\"ms-\"]) {\n  color: #fec84b;\n  background: rgba(181, 71, 8, 0.22);\n  border-color: rgba(254, 200, 75, 0.35);\n}\n.milestone-badge.ms-writing {\n  color: #6941c6;\n  background: #f9f5ff;\n  border: 1px solid rgba(105, 65, 198, 0.3);\n  box-shadow: 0 1px 2px rgba(105, 65, 198, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-writing {\n  color: #d6bbfb;\n  background: rgba(105, 65, 198, 0.22);\n  border-color: rgba(214, 187, 251, 0.35);\n}\n.milestone-badge.ms-value {\n  color: #027a48;\n  background: #ebfdf2;\n  border: 1px solid rgba(2, 122, 72, 0.3);\n  box-shadow: 0 1px 2px rgba(2, 122, 72, 0.05);\n}\n[data-theme=\"dark\"] .milestone-badge.ms-value {\n  color: #32d583;\n  background: rgba(2, 122, 72, 0.22);\n  border-color: rgba(50, 213, 131, 0.35);\n}\n\n/* 论文正文图表与插图卡片样式 (Geist Design) */\n.paper-figure, .article-body figure {\n  margin: 32px auto;\n  text-align: center;\n  max-width: 100%;\n}\n.paper-figure img, .article-body img {\n  max-width: 96%;\n  height: auto;\n  border-radius: var(--radius-md);\n  border: 1px solid var(--geist-border);\n  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);\n  background: #ffffff;\n  transition: transform 0.2s ease, box-shadow 0.2s ease;\n  display: block;\n  margin: 0 auto;\n}\n.paper-figure img:hover, .article-body img:hover {\n  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);\n}\n.paper-figure figcaption, .article-body figcaption {\n  font-size: 13px;\n  color: var(--geist-secondary);\n  margin-top: 10px;\n  line-height: 1.6;\n  font-style: italic;\n  max-width: 850px;\n  margin-left: auto;\n  margin-right: auto;\n}\n\n/* VAD 视图切换器 View Switcher */\n.vad-view-switcher {\n  display: inline-flex;\n  padding: 3px;\n  background: var(--geist-secondary-bg);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  margin-bottom: 20px;\n  gap: 2px;\n}\n.view-switch-btn {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 6px 14px;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-secondary);\n  border-radius: 6px;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.view-switch-btn:hover {\n  color: var(--geist-foreground);\n  background: rgba(0, 0, 0, 0.04);\n}\n[data-theme=\"dark\"] .view-switch-btn:hover {\n  background: rgba(255, 255, 255, 0.06);\n}\n.view-switch-btn.active {\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  font-weight: 600;\n  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n/* 关系图谱 Graph View Styles */\n.graph-container {\n  position: relative;\n  width: 100%;\n  height: 720px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: var(--radius-lg);\n  overflow: hidden;\n  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);\n  margin-bottom: 40px;\n}\n.graph-toolbar {\n  position: absolute;\n  top: 14px;\n  left: 14px;\n  right: 14px;\n  z-index: 10;\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  padding: 8px 14px;\n  border-radius: 8px;\n  box-shadow: 0 4px 16px rgba(0,0,0,0.06);\n  flex-wrap: wrap;\n  gap: 8px;\n}\n.graph-tool-title {\n  font-size: 13px;\n  font-weight: 700;\n  display: flex;\n  align-items: center;\n  gap: 6px;\n  color: var(--geist-foreground);\n}\n.graph-filter-group {\n  display: flex;\n  gap: 6px;\n  align-items: center;\n  flex-wrap: wrap;\n}\n.graph-chip {\n  font-size: 11px;\n  padding: 3px 8px;\n  border-radius: 4px;\n  border: 1px solid var(--geist-border);\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  cursor: pointer;\n  transition: all 0.15s ease;\n}\n.graph-chip:hover { background: var(--geist-secondary-bg); }\n.graph-chip.active {\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border-color: var(--geist-foreground);\n}\n.graph-search-input {\n  padding: 3px 8px;\n  font-size: 11px;\n  border-radius: 4px;\n  border: 1px solid var(--geist-border);\n  background: var(--geist-background);\n  color: var(--geist-foreground);\n  outline: none;\n  width: 150px;\n}\n#vad-graph-svg {\n  width: 100%;\n  height: 100%;\n  cursor: grab;\n}\n#vad-graph-svg:active { cursor: grabbing; }\n.graph-legend {\n  position: absolute;\n  bottom: 14px;\n  left: 14px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  padding: 10px 14px;\n  font-size: 11px;\n  box-shadow: 0 4px 16px rgba(0,0,0,0.06);\n  z-index: 10;\n  line-height: 1.6;\n  pointer-events: none;\n}\n.graph-legend-row { display: flex; align-items: center; gap: 8px; }\n.graph-legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }\n.graph-info-drawer {\n  position: absolute;\n  top: 66px;\n  right: 14px;\n  width: 310px;\n  max-height: 620px;\n  background: var(--geist-background);\n  border: 1px solid var(--geist-border);\n  border-radius: 8px;\n  box-shadow: 0 8px 30px rgba(0,0,0,0.12);\n  z-index: 10;\n  padding: 16px;\n  overflow-y: auto;\n  display: none;\n  backdrop-filter: blur(10px);\n  transition: transform 0.2s ease, opacity 0.2s ease;\n}\n.graph-drawer-close {\n  position: absolute;\n  top: 10px;\n  right: 12px;\n  cursor: pointer;\n  font-size: 16px;\n  color: var(--geist-tertiary);\n}\n.graph-drawer-badge {\n  display: inline-block;\n  padding: 2px 6px;\n  border-radius: 4px;\n  font-size: 10px;\n  font-weight: 600;\n  margin-bottom: 6px;\n}\n.graph-drawer-title {\n  font-size: 13px;\n  font-weight: 700;\n  line-height: 1.4;\n  margin-bottom: 8px;\n  color: var(--geist-foreground);\n}\n.graph-drawer-meta {\n  font-size: 11px;\n  color: var(--geist-secondary);\n  margin-bottom: 12px;\n}\n.graph-drawer-core {\n  font-size: 12px;\n  line-height: 1.6;\n  color: var(--geist-foreground);\n  background: var(--geist-secondary-bg);\n  padding: 8px 10px;\n  border-radius: 6px;\n  margin-bottom: 12px;\n  border: 1px solid var(--geist-border);\n}\n.graph-drawer-link {\n  display: block;\n  text-align: center;\n  padding: 7px 12px;\n  background: var(--geist-foreground);\n  color: var(--geist-background);\n  border-radius: 6px;\n  font-size: 12px;\n  font-weight: 600;\n  text-decoration: none;\n  transition: opacity 0.15s ease;\n  margin-bottom: 6px;\n}\n.graph-drawer-link:hover { opacity: 0.85; }\n.graph-drawer-pdf-link {\n  display: block;\n  text-align: center;\n  padding: 6px 12px;\n  background: var(--geist-secondary-bg);\n  color: var(--geist-foreground);\n  border: 1px solid var(--geist-border);\n  border-radius: 6px;\n  font-size: 11px;\n  font-weight: 500;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.graph-drawer-pdf-link:hover { background: var(--geist-border); }\n.node-circle {\n  cursor: pointer;\n  transition: r 0.2s, stroke-width 0.2s;\n}\n.node-label {\n  font-size: 10px;\n  font-weight: 600;\n  fill: var(--geist-foreground);\n  pointer-events: none;\n  text-shadow: 0 1px 2px var(--geist-background);\n}\n.link-line {\n  stroke: var(--geist-border);\n  stroke-opacity: 0.6;\n  stroke-width: 1.2;\n  transition: stroke 0.2s, stroke-width 0.2s, stroke-opacity 0.2s;\n}\n.link-label {\n  font-size: 9px;\n  fill: var(--geist-tertiary);\n  pointer-events: none;\n  text-anchor: middle;\n}\n\n/* 引用框与警示框 Alerts */\n.callout-alert {\n  margin: 20px 0;\n  padding: 14px 18px;\n  border-radius: var(--radius-md);\n  transition: all 0.15s ease;\n}\n.callout-important, .callout-idea {\n  border-left: 4px solid #b54708;\n  background: rgba(181, 71, 8, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(247, 144, 9, 0.3);\n}\n[data-theme=\"dark\"] .callout-important, [data-theme=\"dark\"] .callout-idea {\n  border-left-color: #fec84b;\n  background: rgba(181, 71, 8, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(254, 200, 75, 0.25);\n}\n.callout-writing {\n  border-left: 4px solid #6941c6;\n  background: rgba(105, 65, 198, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(105, 65, 198, 0.3);\n}\n[data-theme=\"dark\"] .callout-writing {\n  border-left-color: #d6bbfb;\n  background: rgba(105, 65, 198, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(214, 187, 251, 0.25);\n}\n.callout-value {\n  border-left: 4px solid #027a48;\n  background: rgba(2, 122, 72, 0.06);\n  box-shadow: inset 0 0 0 1px rgba(2, 122, 72, 0.3);\n}\n[data-theme=\"dark\"] .callout-value {\n  border-left-color: #32d583;\n  background: rgba(2, 122, 72, 0.18);\n  box-shadow: inset 0 0 0 1px rgba(50, 213, 131, 0.25);\n}\n\n.card-title {\n  font-size: 16.5px;\n  font-weight: 600;\n  line-height: 1.42;\n  letter-spacing: -0.4px;\n  color: var(--geist-foreground);\n  margin: 0 0 10px;\n  word-break: break-word;\n  overflow-wrap: anywhere;\n  hyphens: auto;\n}\n.card-title a {\n  color: var(--geist-foreground);\n  text-decoration: none;\n  display: inline;\n  transition: color 0.15s ease;\n}\n.card-title a:hover {\n  color: var(--develop-blue);\n  text-decoration: none;\n}\n.card-id-mono {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-quaternary);\n  margin-right: 5px;\n}\n.card-meta-row {\n  display: flex;\n  gap: 6px;\n  flex-wrap: wrap;\n  margin-bottom: 12px;\n}\n.meta-token {\n  font-size: 12px;\n  color: var(--geist-tertiary);\n  background: var(--geist-surface-tint);\n  box-shadow: var(--shadow-ring);\n  padding: 2px 7px;\n  border-radius: var(--radius-sm);\n  white-space: nowrap;\n}\n.card-body-text {\n  font-size: 13.5px;\n  color: var(--geist-secondary);\n  line-height: 1.6;\n  margin-bottom: 16px;\n  flex-grow: 1;\n  word-break: break-word;\n  overflow-wrap: anywhere;\n}\n.card-body-text strong {\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n.card-footer {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  border-top: 1px solid var(--geist-border);\n  padding-top: 14px;\n}\n.card-link-action {\n  font-size: 13.5px;\n  font-weight: 500;\n  color: var(--link-blue);\n  display: inline-flex;\n  align-items: center;\n  gap: 4px;\n  text-decoration: none;\n  transition: all 0.15s ease;\n}\n.card-link-action:hover {\n  opacity: 0.85;\n  transform: translateX(2px);\n}\na.meta-token {\n  transition: all 0.15s ease;\n  cursor: pointer;\n  text-decoration: none;\n}\na.meta-token:hover {\n  background: var(--geist-selection);\n  color: var(--geist-foreground);\n  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);\n}\n\n/* 紧凑列表视图 (List View) */\n.card-list-view {\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n}\n.list-row-item {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-md);\n  padding: 12px 18px;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 16px;\n  transition: box-shadow 0.15s;\n}\n.list-row-item:hover {\n  box-shadow: var(--shadow-card-hover);\n}\n\n/* 阅读详情页 (Report Detail) */\n.reading-container {\n  display: grid;\n  grid-template-columns: minmax(0, 1fr) 260px;\n  gap: 40px;\n  align-items: start;\n}\n@media (max-width: 960px) {\n  .reading-container { grid-template-columns: 1fr; }\n  .reading-sidebar { display: none; }\n}\n\n.report-header-card {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 28px 32px;\n  margin-bottom: 28px;\n}\n.crumb-bar {\n  font-size: 13px;\n  color: var(--geist-tertiary);\n  margin-bottom: 10px;\n}\n.report-title {\n  font-size: 32px;\n  font-weight: 600;\n  letter-spacing: -1.28px;\n  margin: 0 0 16px;\n  color: var(--geist-foreground);\n}\n.report-action-buttons {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  flex-wrap: wrap;\n  border-top: 1px solid var(--geist-border);\n  padding-top: 16px;\n  margin-top: 16px;\n}\n\n.article-body {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-lg);\n  padding: 36px 42px 80px;\n  font-size: 16px;\n  line-height: 1.75;\n  color: var(--geist-foreground);\n}\n.article-body h1, .article-body h2, .article-body h3 {\n  color: var(--geist-foreground);\n  scroll-margin-top: 80px;\n}\n.article-body h1 { font-size: 28px; font-weight: 600; letter-spacing: -1.28px; border-bottom: 1px solid var(--geist-border); padding-bottom: 8px; margin-top: 32px; }\n.article-body h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.96px; border-bottom: 1px solid var(--geist-border); padding-bottom: 6px; margin-top: 36px; }\n.article-body h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.32px; margin-top: 26px; }\n.article-body table {\n  width: 100%;\n  border-collapse: collapse;\n  margin: 24px 0;\n  font-size: 14px;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  overflow: hidden;\n}\n.article-body th, .article-body td {\n  padding: 10px 14px;\n  text-align: left;\n  border-bottom: 1px solid var(--geist-border);\n}\n.article-body th {\n  background: var(--geist-surface-tint);\n  font-weight: 600;\n  color: var(--geist-foreground);\n}\n.article-body blockquote {\n  border-left: 2px solid var(--geist-foreground);\n  margin: 20px 0;\n  padding: 8px 18px;\n  color: var(--geist-secondary);\n  font-style: normal;\n}\n.article-body code {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 13.5px;\n  box-shadow: var(--shadow-ring);\n  background: var(--geist-surface-tint);\n  padding: 2px 6px;\n  border-radius: var(--radius-sm);\n}\n.article-body pre {\n  position: relative;\n  background: #000000;\n  color: #ededed;\n  box-shadow: var(--shadow-border);\n  border-radius: var(--radius-md);\n  padding: 18px;\n  margin: 24px 0;\n  overflow-x: auto;\n}\n.article-body pre code {\n  background: transparent;\n  box-shadow: none;\n  padding: 0;\n  color: inherit;\n  font-size: 13px;\n}\n.copy-code-btn {\n  position: absolute;\n  top: 8px;\n  right: 10px;\n  font-family: \"Geist Mono\", monospace;\n  font-size: 11px;\n  background: #171717;\n  color: #ffffff;\n  border: 1px solid #333333;\n  padding: 3px 8px;\n  border-radius: var(--radius-sm);\n  cursor: pointer;\n}\n\n/* 侧边大纲 (TOC) */\n.reading-sidebar {\n  position: sticky;\n  top: 80px;\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card);\n  border-radius: var(--radius-lg);\n  padding: 20px;\n  max-height: calc(100vh - 100px);\n  overflow-y: auto;\n}\n.sidebar-toc-title {\n  font-family: \"Geist Mono\", monospace;\n  font-size: 12px;\n  font-weight: 500;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  color: var(--geist-quaternary);\n  margin-bottom: 12px;\n}\n.reading-sidebar ul {\n  list-style: none;\n  padding-left: 0;\n  margin: 0;\n  font-size: 13px;\n}\n.reading-sidebar li {\n  margin: 6px 0;\n}\n.reading-sidebar ul ul {\n  padding-left: 14px;\n}\n.reading-sidebar a {\n  color: var(--geist-secondary);\n  text-decoration: none;\n  transition: color 0.15s;\n}\n.reading-sidebar a:hover, .reading-sidebar a.active {\n  color: var(--geist-foreground);\n  font-weight: 600;\n}\n\n/* 后台管理 (/admin) */\n.admin-card-container {\n  background: var(--geist-background);\n  box-shadow: var(--shadow-card-full);\n  border-radius: var(--radius-lg);\n  padding: 32px;\n  margin-bottom: 32px;\n}\n.form-row-2 {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 16px;\n  margin-bottom: 16px;\n}\n@media (max-width: 600px) {\n  .form-row-2 { grid-template-columns: 1fr; }\n}\n.form-field {\n  display: flex;\n  flex-direction: column;\n  gap: 6px;\n  margin-bottom: 16px;\n}\n.form-field label {\n  font-size: 13px;\n  font-weight: 500;\n  color: var(--geist-foreground);\n}\n.form-field input, .form-field select, .form-field textarea {\n  font-family: \"Geist\", sans-serif;\n  font-size: 14px;\n  padding: 9px 12px;\n  background: var(--geist-background);\n  box-shadow: var(--shadow-border);\n  border: none;\n  border-radius: var(--radius-md);\n  color: var(--geist-foreground);\n  outline: none;\n}\n.form-field input:focus, .form-field select:focus, .form-field textarea:focus {\n  outline: 2px solid var(--ds-focus-color);\n  box-shadow: none;\n}\n\n/* 语法高亮 (Console Blue / Purple / Pink) */\n.codehilite .k, .codehilite .kd, .codehilite .kn { color: #eb367f; font-weight: 500; }\n.codehilite .s, .codehilite .s1, .codehilite .s2 { color: #0070f3; }\n.codehilite .nf, .codehilite .na { color: #7928ca; font-weight: 500; }\n.codehilite .c, .codehilite .c1 { color: #666666; font-style: italic; }\n.codehilite .mi, .codehilite .mf { color: #ff5b4f; }\n\n</style>\n\n</head>\n<body>\n\n    <nav class=\"vercel-nav\">\n      <div class=\"nav-brand\">\n        <a href=\"/\" style=\"display:flex;align-items:center;gap:10px;text-decoration:none\">\n          <svg class=\"vercel-triangle\" viewBox=\"0 0 76 65\" fill=\"none\">\n            <path d=\"M37.5274 0L75.0548 65H0L37.5274 0Z\" fill=\"currentColor\"/>\n          </svg>\n          <span class=\"nav-title\">Agent Harness KB</span>\n        </a>\n        <span class=\"nav-badge-pill\">Geist 2.0</span>\n      </div>\n\n      <div class=\"nav-links\">\n        <a class=\"nav-link \" href=\"/\">全景总览</a>\n        <a class=\"nav-link \" href=\"/vad\" style=\"color:var(--ship-red)\">🎯 VAD 专栏 (144)</a>\n        <a class=\"nav-link\" href=\"https://m0rtzz.github.io/paper-notes/\" target=\"_blank\" rel=\"noopener\">顶会 669 篇 ↗</a>\n        <a class=\"nav-link\" href=\"/download/all\">整库打包</a>\n        \n      </div>\n\n      <div class=\"nav-actions\">\n        \n        <button class=\"theme-toggle-btn\" id=\"theme-toggle-btn\" onclick=\"toggleTheme()\" title=\"切换亮暗主题\">🌙</button>\n      </div>\n    </nav>\n    \n<main class=\"vercel-container\">\n\n        <div class=\"report-header-card\">\n          <div class=\"crumb-bar\"><a href=\"/\">Home</a> / <b>fulltext.txt</b></div>\n          <h1 class=\"report-title\">fulltext.txt</h1>\n          <div class=\"report-action-buttons\">\n            <a class=\"btn-primary-dark\" href=\"?dl=1\">Download Text</a>\n          </div>\n        </div>\n        <article class=\"article-body\"><pre><code>arXiv:cs/0309048v5 [cs.LO] 17 Dec 2006\n\nTR IDSIA-19-03, Version 5\nDecember 2006, arXiv:cs.LO/0309048 v5\n(v1: 25 September 2003)\n\nGödel Machines: Self-Referential\nUniversal Problem Solvers Making\nProvably Optimal Self-Improvements\nJürgen Schmidhuber\nIDSIA, Galleria 2, 6928 Manno-Lugano, Switzerland &amp;\nTU München, Boltzmannstr. 3, 85748 Garching, München, Germany\njuergen@idsia.ch - http://www.idsia.ch/˜juergen\n\nAbstract\nWe present the first class of mathematically rigorous, general, fully self-referential, selfimproving, optimally efficient problem solvers. Inspired by Kurt Gödel’s celebrated selfreferential formulas (1931), such a problem solver rewrites any part of its own code as soon\nas it has found a proof that the rewrite is useful, where the problem-dependent utility function and the hardware and the entire initial code are described by axioms encoded in an initial\nproof searcher which is also part of the initial code. The searcher systematically and in an\nasymptotically optimally efficient way tests computable proof techniques (programs whose\noutputs are proofs) until it finds a provably useful, computable self-rewrite. We show that such\na self-rewrite is globally optimal—no local maxima!—since the code first had to prove that it\nis not useful to continue the proof search for alternative self-rewrites. Unlike Hutter’s previous\nnon-self-referential methods based on hardwired proof searchers, ours not only boasts an optimal order of complexity but can optimally reduce any slowdowns hidden by the O()-notation,\nprovided the utility of such speed-ups is provable at all.\nKeywords: self-reference, reinforcement learning, problem solving, proof techniques, optimal\nuniversal search, self-improvement\nGödel machine publications up to 2006 (100 years after Kurt Gödel’s birth, and 75 years\nafter his landmark paper [11] laying the foundations of theoretical computer science): [45, 47,\n48, 49, 50, 51].\n\n\fContents\n1 Introduction and Outline\n\n2\n\n2 Overview / Basic Ideas / Limitations\n2.1 Set-up and Formal Goal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n2.2 Basic Idea of Gödel Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n2.3 Proof Techniques and an O()-Optimal Initial Proof Searcher . . . . . . . . . . . .\n2.4 Limitations of Gödel Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n\n2\n3\n4\n4\n5\n\n3 Essential Details of One Representative Gödel Machine\n3.1 Proof Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n3.2 Important Instructions Used by Proof Techniques . . . . . . . . . . . . . . . . . .\n\n6\n6\n6\n\n4 Global Optimality Theorem\n4.1 Globally Optimal Self-Changes, Given u and A Encoded in p . . . . . . . . . . . .\n4.2 Alternative Relaxed Target Theorem . . . . . . . . . . . . . . . . . . . . . . . . .\n4.3 Global Optimality and Recursive Meta-Levels . . . . . . . . . . . . . . . . . . . .\n4.4 How Difficult is it to Prove Target Theorems? . . . . . . . . . . . . . . . . . . . .\n\n11\n11\n12\n12\n12\n\n5 Bias-Optimal Proof Search (BIOPS)\n13\n5.1 Online Universal Search in Proof Space . . . . . . . . . . . . . . . . . . . . . . . 13\n5.2 How a Surviving Proof Searcher May Use the Optimal Ordered Problem Solver to\nSolve Remaining Proof Search Tasks . . . . . . . . . . . . . . . . . . . . . . . . . 14\n6 Discussion &amp; Previous Work\n6.1 Possible Types of Gödel Machine Self-Improvements . . . . . . . . . . . . . . . .\n6.2 Example Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n6.3 Probabilistic Gödel Machine Hardware . . . . . . . . . . . . . . . . . . . . . . . .\n6.4 Relations to Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n6.5 Are Humans Probabilistic Gödel Machines? . . . . . . . . . . . . . . . . . . . . .\n6.6 Gödel Machines and Consciousness . . . . . . . . . . . . . . . . . . . . . . . . .\n6.7 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n\n15\n15\n17\n17\n18\n21\n22\n22\n\n7 Conclusion\n\n24\n\n8 Acknowledgments\n\n24\n\n1\n\n\f1 Introduction and Outline\nAll traditional algorithms for problem solving / machine learning / reinforcement learning [20] are\nhardwired. Some are designed to improve some limited type of policy through experience, but\nare not part of the modifiable policy, and cannot improve themselves in a theoretically sound way.\nHumans are needed to create new / better problem solving algorithms and to prove their usefulness\nunder appropriate assumptions.\nHere we will eliminate the restrictive need for human effort in the most general way possible,\nleaving all the work including the proof search to a system that can rewrite and improve itself\nin arbitrary computable ways and in a most efficient fashion. To attack this “Grand Problem\nof Artificial Intelligence” [46], we introduce a novel class of optimal, fully self-referential [11]\ngeneral problem solvers called Gödel machines [45, 47, 49, 51, 50].1 They are universal problem\nsolving systems that interact with some (partially observable) environment and can in principle\nmodify themselves without essential limits apart from the limits of computability. Their initial\nalgorithm is not hardwired; it can completely rewrite itself, but only if a proof searcher embedded\nwithin the initial algorithm can first prove that the rewrite is useful, given a formalized utility\nfunction reflecting computation time and expected future success (e.g., rewards). We will see that\nself-rewrites due to this approach are actually globally optimal (Theorem 4.1, Section 4), relative\nto Gödel’s well-known fundamental restrictions of provability [11]. These restrictions should not\nworry us; if there is no proof of some self-rewrite’s utility, then humans cannot do much either.\nThe initial proof searcher is O()-optimal (has an optimal order of complexity) in the sense of\nTheorem 5.1, Section 5. Unlike hardwired systems such as Hutter’s [16, 17] and Levin’s [24, 26]\n(Section 6.4), however, a Gödel machine can in principle speed up any part of its initial software, including its proof searcher, to meet arbitrary formalizable notions of optimality beyond\nthose expressible in the O()-notation. Our approach yields the first theoretically sound, fully selfreferential, optimal, general problem solvers.\nOutline. Section 2 presents basic concepts and fundamental limitations, Section 3 the essential\ndetails of a self-referential axiomatic system, Section 4 the Global Optimality Theorem 4.1, and\nSection 5 the O()-optimal (Theorem 5.1) initial proof searcher. Section 6 provides examples and\nrelations to previous work, briefly discusses issues such as a technical justification of consciousness, and lists answers to several frequently asked questions about Gödel machines.\n\n2 Overview / Basic Ideas / Limitations\nMany traditional problems of computer science require just one problem-defining input at the beginning of the problem solving process. For example, the initial input may be a large integer, and\nthe goal may be to factorize it. In what follows, however, we will also consider the more general\ncase where the problem solution requires interaction with a dynamic, initially unknown environment that produces a continual stream of inputs and feedback signals, such as in autonomous robot\ncontrol tasks, where the goal may be to maximize expected cumulative future reward [20]. This\n1\n\nOr ‘Goedel machine’, to avoid the Umlaut. But ‘Godel machine’ would not be quite correct. Not to be confused\nwith what Penrose calls, in a different context, ‘Gödel’s putative theorem-proving machine’ [30]!\n\n2\n\n\fmay require the solution of essentially arbitrary problems (examples in Section 6.2 formulate traditional problems as special cases).\n\n2.1 Set-up and Formal Goal\nOur hardware (e.g., a universal or space-bounded Turing machine [61] or the abstract model of a\npersonal computer) has a single life which consists of discrete cycles or time steps t = 1, 2, . . ..\nIts total lifetime T may or may not be known in advance. In what follows, the value of any timevarying variable Q at time t will be denoted by Q(t).\nDuring each cycle our hardware executes an elementary operation which affects its variable\nstate s ∈ S ⊂ B∗ (without loss of generality, B ∗ is the set of possible bitstrings over the binary\nalphabet B = {0, 1}) and possibly also the variable environmental state Env ∈ E (here we need\nnot yet specify the problem-dependent set E). There is a hardwired state transition function F :\nS × E → S. For t &gt; 1, s(t) = F (s(t − 1), Env(t − 1)) is the state at a point where the hardware\noperation of cycle t − 1 is finished, but the one of t has not started yet. Env(t) may depend on past\noutput actions encoded in s(t − 1) and is simultaneously updated or (probabilistically) computed\nby the possibly reactive environment.\nIn order to talk conveniently about programs and data, we will often attach names to certain\nstring variables encoded as components or substrings of s. Of particular interest are the three\nvariables called time, x, y, and p:\n1. At time t, variable time holds a unique binary representation of t. We initialize time(1) =\n‘1’, the bitstring consisting only of a one. The hardware increments time from one cycle to\nthe next. This requires at most O(log t) and on average only O(1) computational steps.\n2. Variable x holds the inputs from the environment to the Gödel machine. For t &gt; 1, x(t) may\ndiffer from x(t − 1) only if a program running on the Gödel machine has executed a special\ninput-requesting instruction at time t−1. Generally speaking, the delays between successive\ninputs should be sufficiently large so that programs can perform certain elementary computations on an input, such as copying it into internal storage (a reserved part of s) before the\nnext input arrives.\n3. Variable y holds the outputs of the Gödel machine. y(t) is an output bitstring which may\nsubsequently influence the environment, where y(1) = ‘0’ by default. For example, y(t)\ncould be interpreted as a control signal for an environment-manipulating robot whose actions\nmay have an effect on future inputs.\n4. p(1) is the initial software: a program implementing the original (sub-optimal) policy for\ninteracting with the environment, represented as a substring e(1) of p(1), plus the original\npolicy for searching proofs. Details will be discussed below.\nAt any given time t (1 ≤ t ≤ T ) the goal is to maximize future success or utility. A typical\n“value to go” utility function is of the form u(s, Env) : S × E → R, where R is the set of real\nnumbers:\n#\n\"\nu(s, Env) = Eµ\n\nT\nX\n\nτ =time\n\n3\n\nr(τ )\n\ns, Env ,\n\n(1)\n\n\fwhere r(t) is a real-valued reward input (encoded within s(t)) at time t, Eµ (· | ·) denotes the\nconditional expectation operator with respect to some possibly unknown distribution µ from a\nset M of possible distributions (M reflects whatever is known about the possibly probabilistic\nreactions of the environment), and the above-mentioned time = time(s) is a function of state\ns which uniquely identifies the current cycle. Note that we take into account the possibility of\nextending the expected lifespan through appropriate actions.\nAlternative formalizable utility functions could favor improvement of worst case instead of\nexpected future performance, or higher reward intake per time interval etc. Clearly, most classic\nproblems of computer science can be formulated in this framework—see examples in Section 6.2.\n\n2.2 Basic Idea of Gödel Machine\nOur machine becomes a self-referential [11] Gödel machine by loading it with a particular form\nof machine-dependent, self-modifying code p. The initial code p(1) at time step 1 includes a\n(typically sub-optimal) problem solving subroutine e(1) for interacting with the environment, such\nas any traditional reinforcement learning algorithm [20], and a general proof searcher subroutine\n(Section 5) that systematically makes pairs (switchprog, proof) (variable substrings of s) until\nit finds a proof of a target theorem which essentially states: ‘the immediate rewrite of p through\ncurrent program switchprog on the given machine implies higher utility than leaving p as is’. Then\nit executes switchprog, which may completely rewrite p, including the proof searcher. Section 3\nwill explain details of the necessary initial axiomatic system A encoded in p(1). Compare Fig. 1.\nThe Global Optimality Theorem (Theorem 4.1, Section 4) shows this self-improvement strategy\nis not greedy: since the utility of ‘leaving p as is’ implicitly evaluates all possible alternative\nswitchprogs which an unmodified p might find later, we obtain a globally optimal self-change—\nthe current switchprog represents the best of all possible relevant self-changes, relative to the given\nresource limitations and initial proof search strategy.\n\n2.3 Proof Techniques and an O()-Optimal Initial Proof Searcher\nSection 5 will present an O()-optimal initialization of the proof searcher, that is, one with an optimal order of complexity (Theorem 5.1). Still, there will remain a lot of room for self-improvement\nhidden by the O()-notation. The searcher uses an online extension of Universal Search [24, 26]\nto systematically test online proof techniques, which are proof-generating programs that may read\nparts of state s (similarly, mathematicians are often more interested in proof techniques than in\ntheorems). To prove target theorems as above, proof techniques may invoke special instructions\nfor generating axioms and applying inference rules to prolong the current proof by theorems. Here\nan axiomatic system A encoded in p(1) includes axioms describing (a) how any instruction invoked by a program running on the given hardware will change the machine’s state s (including\ninstruction pointers etc.) from one step to the next (such that proof techniques can reason about the\neffects of any program including the proof searcher), (b) the initial program p(1) itself (Section 3\nwill show that this is possible without introducing circularity), (c) stochastic environmental properties, (d) the formal utility function u, e.g., equation (1), which takes into account computational\ncosts of all actions including proof search.\n\n4\n\n\fproof\n\ntemporary storage\nof proof technique\n\ninitial software p(1)\n\nENVIRONMENT\n\ncurrently tested\nproof technique\ninitial\nproof\nsearcher:\n\nproof technique\ntester\naxioms for hard−\nware, initial soft−\nware, environment,\ncosts &amp; goals\n\nstorage readable by proof techniques\n\nswitchbit\n\nwritable by switchprog\n\nswitchprog\n\nwritable by\nproof techniques\n\nstorage\nwritable\nby proof\nsearcher:\n\ninitial problem solver e(1) for\ninteraction with environment\ntemporary storage of e(1)\n\ninput x\ntime\nother hardware variables\n\nhardware−\nwritable\n\noutput y\n\nFigure 1: Storage snapshot of a not yet self-improved example Gödel machine, with the initial software\nstill intact. See text for details.\n\n2.4 Limitations of Gödel Machines\nThe fundamental limitations are closely related to those first identified by Gödel’s celebrated paper on self-referential formulae [11]. Any formal system that encompasses arithmetics (or ZFC\netc) is either flawed or allows for unprovable but true statements. Hence even a Gödel machine\nwith unlimited computational resources must ignore those self-improvements whose effectiveness\nit cannot prove, e.g., for lack of sufficiently powerful axioms in A. In particular, one can construct\npathological examples of environments and utility functions that make it impossible for the machine to ever prove a target theorem. Compare Blum’s speed-up theorem [3, 4] based on certain\nincomputable predicates. Similarly, a realistic Gödel machine with limited resources cannot profit\nfrom self-improvements whose usefulness it cannot prove within its time and space constraints.\nNevertheless, unlike previous methods, it can in principle exploit at least the provably good\nspeed-ups of any part of its initial software, including those parts responsible for huge (but problem\nclass-independent) slowdowns ignored by the earlier approaches [16, 17] (Section 6.4).\n\n5\n\n\f3 Essential Details of One Representative Gödel Machine\nNotation. Unless stated otherwise or obvious, throughout the paper newly introduced variables\nand functions are assumed to cover the range implicit in the context. l(q) denotes the number of\nbits in a bitstring q; qn the n-th bit of q; λ the empty string (where l(λ) = 0); qm:n = λ if m &gt; n\nand qm qm+1 . . . qn otherwise (where q0 := q0:0 := λ).\nTheorem proving requires an axiom scheme yielding an enumerable set of axioms of a formal\nlogic system A whose formulas and theorems are symbol strings over some finite alphabet that\nmay include traditional symbols of logic (such as →, ∧, =, (, ), ∀, ∃, . . ., c1 , c2 , . . . , f1 , f2 , . . .),\nP\nprobability theory (such as E(·), the expectation operator), arithmetics (+, −, /, =, , &lt;, . . .),\nstring manipulation (in particular, symbols for representing any part of state s at any time, such as\ns7:88 (5555)). A proof is a sequence of theorems, each either an axiom or inferred from previous\ntheorems by applying one of the inference rules such as modus ponens combined with unification,\ne.g., [10].\nThe remainder of this paper will omit standard knowledge to be found in any proof theory\ntextbook. Instead of listing all axioms of a particular A in a tedious fashion, we will focus on the\nnovel and critical details: how to overcome potential problems with self-reference and how to deal\nwith the potentially delicate online generation of proofs that talk about and affect the currently\nrunning proof generator itself.\n\n3.1 Proof Techniques\nBrute force proof searchers (used in Hutter’s work [16, 17]; see Section 6.4 for a review) systematically generate all proofs in order of their sizes. To produce a certain proof, this takes time\nexponential in proof size. Instead our O()-optimal p(1) will produce many proofs with low algorithmic complexity [57, 22, 27] much more quickly. It systematically tests (see Section 5) programs\ncalled proof techniques written in universal language L implemented within p(1). For example,\nL may be a variant of PROLOG [7] or the universal F ORTH[29]-inspired programming language\nused in recent work on optimal search [48]. A proof technique is composed of instructions that\nallow any part of s to be read, such as inputs encoded in variable x (a substring of s) or the code of\np(1). It may write on sp , a part of s reserved for temporary results. It also may rewrite switchprog,\nand produce an incrementally growing proof placed in the string variable proof stored somewhere\nin s. proof and sp are reset to the empty string at the beginning of each new proof technique\ntest. Apart from standard arithmetic and function-defining instructions [48] that modify sp , the\nprogramming language L includes special instructions (details in Section 3.2) for prolonging the\ncurrent proof by correct theorems, for setting switchprog, and for checking whether a provably\noptimal p-modifying program was found and should be executed now. Certain long proofs can be\nproduced by short proof techniques.\n\n3.2 Important Instructions Used by Proof Techniques\nThe nature of the six proof-modifying instructions below (there are no others) makes it impossible\nto insert an incorrect theorem into proof, thus trivializing proof verification. Let us first provide a\n\n6\n\n\fbrief overview of the most important instructions: get-axiom(n) appends the n-th possible axiom to\nthe current proof, apply-rule(k, m, n) applies the k-th inference rule to the m-th and n-th theorem\nin the current proof (appending the result), set-switchprog(m,n) sets switchprog := spm:n , and\ncheck() tests whether the last theorem in proof is a target theorem showing that a self-rewrite\nthrough switchprog would be useful. The details are as follows.\n1. get-axiom(n) takes as argument an integer n computed by a prefix of the currently tested\nproof technique with the help of arithmetic instructions such as those used in previous work\n[48]. Then it appends the n-th axiom (if it exists, according to the axiom scheme below) as\na theorem to the current theorem sequence in proof. The initial axiom scheme encodes:\n(a) Hardware axioms describing the hardware, formally specifying how certain components of s (other than environmental inputs x) may change from one cycle to the next.\nFor example, if the hardware is a Turing machine2 (TM) [61], then s(t) is a bitstring that\nencodes the current contents of all tapes of the TM, the positions of its scanning heads,\nand the current internal state of the TM’s finite state automaton, while F specifies\nthe TM’s look-up table which maps any possible combination of internal state and bits\nabove scanning heads to a new internal state and an action such as: replace some head’s\ncurrent bit by 1/0, increment (right shift) or decrement (left shift) some scanning head,\nread and copy next input bit to cell above input tape’s scanning head, etc.\nAlternatively, if the hardware is given by the abstract model of a modern microprocessor with limited storage, s(t) will encode the current storage contents, register values,\ninstruction pointers etc.\nFor instance, the following axiom could describe how some 64-bit hardware’s instruction pointer stored in s1:64 is continually incremented as long as there is no overflow\nand the value of s65 does not indicate that a jump to some other address should take\nplace:\n(∀t∀n : [(n &lt; 264 − 1) ∧ (n &gt; 0) ∧ (t &gt; 1) ∧ (t &lt; T )\n∧(string2num(s1:64 (t)) = n) ∧ (s65 (t) = ‘0’)]\n→ (string2num(s1:64 (t + 1)) = n + 1))\nHere the semantics of used symbols such as ‘(’ and ‘&gt;’ and ‘→’ (implies) are the\ntraditional ones, while ‘string2num’ symbolizes a function translating bitstrings into\nnumbers. It is clear that any abstract hardware model can be fully axiomatized in a\nsimilar way.\n(b) Reward axioms defining the computational costs of any hardware instruction, and\nphysical costs of output actions, such as control signals y(t) encoded in s(t). Related axioms assign values to certain input events (encoded in variable x, a substring\nof s) representing reward or punishment (e.g., when a Gödel machine-controlled robot\n2\nTuring reformulated Gödel’s unprovability results in terms of Turing machines (TMs) [61] which subsequently\nbecame the most widely used abstract model of computation. It is well-known that there are universal TMs that in a\ncertain sense can emulate any other TM or any other known computer. Gödel’s integer-based formal language can be\nused to describe any universal TM, and vice versa.\n\n7\n\n\fbumps into an obstacle). Additional axioms define the total value of the Gödel machine’s life as a scalar-valued function of all rewards (e.g., their sum) and costs experienced between cycles 1 and T , etc. For example, assume that s17:18 can be changed\nonly through external inputs; the following example axiom says that the total reward\nincreases by 3 whenever such an input equals ‘11’ (unexplained symbols carry the obvious meaning):\n(∀t1 ∀t2 : [(t1 &lt; t2 ) ∧ (t1 ≥ 1) ∧ (t2 ≤ T ) ∧ (s17:18 (t2 ) = ‘11’)]\n→ [R(t1 , t2 ) = R(t1 , t2 − 1) + 3]),\nwhere R(t1 , t2 ) is interpreted as the cumulative reward between times t1 and t2 . It\nis clear that any formal scheme for producing rewards can be fully axiomatized in a\nsimilar way.\n(c) Environment axioms restricting the way the environment will produce new inputs (encoded within certain substrings of s) in reaction to sequences of outputs y encoded in\ns. For example, it may be known in advance that the environment is sampled from an\nunknown probability distribution µ contained in a given set M of possible distributions\n(compare equation 1). E.g., M may contain all distributions that are computable, given\nthe previous history [57, 58, 16], or at least limit-computable [41, 42]. Or, more restrictively, the environment may be some unknown but deterministic computer program\n[63, 39] sampled from the Speed Prior [43] which assigns low probability to environments that are hard to compute by any method. Or the interface to the environment is\nMarkovian [35], that is, the current input always uniquely identifies the environmental\nstate—a lot of work has already been done on this special case [33, 2, 60]. Even more\nrestrictively, the environment may evolve in completely predictable fashion known in\nadvance. All such prior assumptions are perfectly formalizable in an appropriate A\n(otherwise we could not write scientific papers about them).\n(d) Uncertainty axioms; string manipulation axioms: Standard axioms for arithmetics\nand calculus and probability theory [21] and statistics and string manipulation that (in\nconjunction with the hardware axioms and environment axioms) allow for constructing\nproofs concerning (possibly uncertain) properties of future values of s(t) as well as\nbounds on expected remaining lifetime / costs / rewards, given some time τ and certain\nhypothetical values for components of s(τ ) etc. An example theorem saying something\nabout expected properties of future inputs x might look like this:\n(∀t1 ∀µ ∈ M : [(1 ≤ t1 ) ∧ (t1 + 15597 &lt; T ) ∧ (s5:9 (t1 ) = ‘01011’)\n∧(x40:44 (t1 ) = ‘00000’)] → (∃t : [(t1 &lt; t &lt; t1 + 15597)\n998\n∧(Pµ (x17:22 (t) = ‘011011’ | s(t1 )) &gt;\n)])),\n1000\nwhere Pµ (. | .) represents a conditional probability with respect to an axiomatized prior\ndistribution µ from a set of distributions M described by the environment axioms (Item\n1c).\nGiven a particular formalizable hardware (Item 1a) and formalizable assumptions about\nthe possibly probabilistic environment (Item 1c), obviously one can fully axiomatize\n8\n\n\feverything that is needed for proof-based reasoning about past and future machine\nstates.\n(e) Initial state axioms: Information about how to reconstruct the initial state s(1) or parts\nthereof, such that the proof searcher can build proofs including axioms of the type\n(sm:n (1) = z), e.g. : (s7:9 (1) = ‘010’).\nHere and in the remainder of the paper we use bold font in formulas to indicate syntactic\nplace holders (such as m,n,z) for symbol strings representing variables (such as m,n,z)\nwhose semantics are explained in the text—in the present context z is the bitstring\nsm:n (1).\nNote that it is no fundamental problem to fully encode both the hardware description\nand the initial hardware-describing p within p itself. To see this, observe that some\nsoftware may include a program that can print the software.\n(f) Utility axioms describing the overall goal in the form of utility function u; e.g., equation (1) in Section 2.1.\n2. apply-rule(k, m, n) takes as arguments the index k (if it exists) of an inference rule such\nas modus ponens (stored in a list of possible inference rules encoded within p(1)) and the\nindices m, n of two previously proven theorems (numbered in order of their creation) in the\ncurrent proof. If applicable, the corresponding inference rule is applied to the addressed\ntheorems and the resulting theorem appended to proof. Otherwise the currently tested proof\ntechnique is interrupted. This ensures that proof is never fed with invalid proofs.\n3. delete-theorem(m) deletes the m-th theorem in the currently stored proof, thus freeing storage such that proof-storing parts of s can be reused and the maximal proof size is not necessarily limited by storage constraints. Theorems deleted from proof, however, cannot be\naddressed any more by apply-rule to produce further prolongations of proof.\n4. set-switchprog(m,n) replaces switchprog by spm:n , provided that spm:n is indeed a non-empty\nsubstring of sp , the storage writable by proof techniques.\n5. check() verifies whether the goal of the proof search has been reached. First it tests whether\nthe last theorem (if any) in proof has the form of a target theorem. A target theorem states\nthat given the current axiomatized utility function u (Item 1f), the utility of a switch from\np to the current switchprog would be higher than the utility of continuing the execution of\np (which would keep searching for alternative switchprogs). Target theorems are symbol\nstrings (encoded in s) of the (decoded) form\n(u[s(t1 ) ⊕ (switchbit(t1 ) = ‘1’), Env(t1 )] &gt;\nu[s(t1 ) ⊕ (switchbit(t1 ) = ‘0’), Env(t1 )])\n\n(2)\n\nwhere the variable t1 (represented by syntactic place holder t1 ) stands for a time step, while\nall other symbols belong to the alphabet of the theorem-proving calculus, that is, the set\nof possible target theorems is parameterized only by t1 . Here the calculus should permit\n9\n\n\fthe notation s(t1 ) ⊕ (switchbit(t1 ) = ‘b’) as a shortcut for the state obtained when we\nreplace switchbit(t1), the true value of the variable bit switchbit (encoded in s) at time t1 , by\nb ∈ {0, 1}. This will facilitate the formulation of theorems that compare values conditioned\non various alternative hypothetical properties of s(t1 ). (Note that s(t1 ) may be only partially\nknown by the current proof technique even in environments where s(t1 ) and switchbit(t1)\nare fully predetermined for all valid t1 .)\nThe purpose of introducing t1 is to deal with hardware-specific temporal delays that may\nbe involved in checking and switching—it may take a significant amount of time to match\nabstract symbol strings found during proof search to the Gödel machine’s real current state.\nIf a target theorem has been found, check() uses a simple prewired subroutine (also encoded\nin p(1), of course) to check whether there is enough time left to set variable switchbit (originally 0) to 1 before the continually increasing time will equal t1 . If this subroutine returns\na negative result, check() exits. Otherwise it sets switchbit := 1 (there is no other way of\nchanging switchbit). Then it repeatedly tests time until time &gt; t1 , to make sure the condition of formula (2) was fulfilled at t1 . Then it transfers control to switchprog (there is no\nother way of calling switchprog). The switchprog may subsequently rewrite all parts of s,\nexcluding hardware-reserved parts such as time and x, but including p.\n6. state2theorem(m, n) takes two integer arguments m, n and tries to transform the current\ncontents of sm:n into a theorem of the form\n(sm:n(t1 ) = z), e.g. : (s6:9 (7775555) = ‘1001’),\nwhere t1 represents a time measured (by checking time) shortly after state2theorem was\ninvoked, and z the bistring sm:n (t1 ) (recall the special case t1 = 1 of Item 1e). So we accept\nthe time-labeled current observable contents of any part of s as a theorem that does not have\nto be proven in an alternative way from, say, the initial state s(1), because the computation\nso far has already demonstrated that the theorem is true. Thus we may exploit information\nconveyed by environmental inputs, and the fact that sometimes (but not always) the fastest\nway to determine the output of a program is to run it.\nThis non-traditional online interface between syntax and semantics requires special care\nthough. We must avoid inconsistent results through parts of s that change while being read.\nFor example, the present value of a quickly changing instruction pointer IP (continually\nupdated by the hardware) may be essentially unreadable in the sense that the execution of the\nreading subroutine itself will already modify IP many times. For convenience, the (typically\nlimited) hardware could be set up such that it stores the contents of fast hardware variables\nevery c cycles in a reserved part of s, such that an appropriate variant of state2theorem()\ncould at least translate certain recent values of fast variables into theorems. This, however,\nwill not abolish all problems associated with self-observations. For example, the sm:n to\nbe read might also contain the reading procedure’s own, temporary, constantly changing\nstring pointer variables, etc.3 To address such problems on computers with limited memory,\n3\nWe see that certain parts of the current s may not be directly observable without changing the observable itself.\nSometimes, however, axioms and previous observations will allow the Gödel machine to deduce time-dependent storage contents that are not directly observable. For instance, by analyzing the code being executed through instruction\npointer IP in the example above, the value of IP at certain times may be predictable (or postdictable, after the fact).\n\n10\n\n\fstate2theorem first uses some fixed protocol (encoded in p(1), of course) to check whether\nthe current sm:n is readable at all or whether it might change if it were read by the remaining\ncode of state2theorem. If so, or if m, n, are not in the proper range, then the instruction has\nno further effect. Otherwise it appends an observed theorem of the form (sm:n (t1 ) = z) to\nproof. For example, if the current time is 7770000, then the invocation of state2theorem(6,9)\nmight return the theorem (s6:9 (7775555) = ‘1001’), where 7775555 − 7770000 = 5555\nreflects the time needed by state2theorem to perform the initial check and to read leading\nbits off the continually increasing time (reading time also costs time) such that it can be\nsure that 7775555 is a recent proper time label following the start of state2theorem.\nThe axiomatic system A is a defining parameter of a given Gödel machine. Clearly, A must be\nstrong enough to permit proofs of target theorems. In particular, the theory of uncertainty axioms\n(Item 1d) must be sufficiently rich. This is no fundamental problem: we simply insert all traditional\naxioms of probability theory [21].\n\n4 Global Optimality Theorem\nIntuitively, at any given time p should execute some self-modification algorithm (via instruction\ncheck()—Item 5 above) only if it is the ‘best’ of all possible self-modifications, given the utility\nfunction, which typically depends on available resources, such as storage size and remaining lifetime. At first glance, however, target theorem (2) seems to implicitly talk about just one single\nmodification algorithm, namely, switchprog(t1) as set by the systematic proof searcher at time t1 .\nIsn’t this type of local search greedy? Couldn’t it lead to a local optimum instead of a global one?\nNo, it cannot, according to the following global optimality theorem.\n\n4.1 Globally Optimal Self-Changes, Given u and A Encoded in p\nTheorem 4.1 Given any formalizable utility function u (Item 1f), and assuming consistency of the\nunderlying formal system A, any self-change of p obtained through execution of some program\nswitchprog identified through the proof of a target theorem (2) is globally optimal in the following\nsense: the utility of starting the execution of the present switchprog is higher than the utility of\nwaiting for the proof searcher to produce an alternative switchprog later.\nProof. Target theorem (2) implicitly talks about all the other switchprogs that the proof searcher\ncould produce in the future. To see this, consider the two alternatives of the binary decision:\n(1) either execute the current switchprog (set switchbit = 1), or (2) keep searching for proofs\nand switchprogs (set switchbit = 0) until the systematic searcher comes up with an even better\nswitchprog. Obviously the second alternative concerns all (possibly infinitely many) potential\nswitchprogs to be considered later. That is, if the current switchprog were not the ‘best’, then\nThe values of other variables at given times, however, may not be deducible at all. Such limits of self-observability\nare reminiscent of Heisenberg’s celebrated uncertainty principle [12], which states that certain physical measurements\nare necessarily imprecise, since the measuring process affects the measured quantity.\n\n11\n\n\fthe proof searcher would not be able to prove that setting switchbit and executing switchprog will\ncause higher expected reward than discarding switchprog, assuming consistency of A. Q.E.D.\nThe initial proof searcher of Section 5 already generates all possible proofs and switchprogs\nin O()-optimal fashion. Nevertheless, since it is part of p(1), its proofs can speak about the proof\nsearcher itself, possibly triggering proof searcher rewrites resulting in better than merely O()optimal performance.\n\n4.2 Alternative Relaxed Target Theorem\nWe may replace the target theorem (2) (Item 5) by the following alternative target theorem:\n(u[s(t1 ) ⊕ (switchbit(t1 ) = ‘1’), Env(t1 )] ≥\nu[s(t1 ) ⊕ (switchbit(t1 ) = ‘0’), Env(t1 )])\n\n(3)\n\nThe only difference to the original target theorem (2) is that the “&gt;” sign became a “≥” sign. That\nis, the Gödel machine will change itself as soon as it has found a proof that the change will not\nmake things worse. A Global Optimality Theorem similar to Theorem 4.1 holds; simply replace\nthe last phrase in Theorem 4.1 by: the utility of starting the execution of the present switchprog is\nat least as high as the utility of waiting for the proof searcher to produce an alternative switchprog\nlater.\n\n4.3 Global Optimality and Recursive Meta-Levels\nOne of the most important aspects of our fully self-referential set-up is the following. Any proof\nof a target theorem automatically proves that the corresponding self-modification is good for all\nfurther self-modifications affected by the present one, in recursive fashion. In that sense all possible\n“meta-levels” of the self-referential system are collapsed into one.\n\n4.4 How Difficult is it to Prove Target Theorems?\nThis depends on the tasks and the initial axioms A, of course. It is straight-forward to devise\nsimple tasks and corresponding consistent A such that there are short and trivial proofs of target\ntheorems.\nEven when we initialize the initial problem solver e(1) by an asymptotically optimal, rather\ngeneral method such as Hutter’s A IXI(t,l) [16, 19], it may be straight-forward to prove that switching to another strategy is useful, especially when A contains additional prior knowledge in form of\naxiomatic assumptions beyond those made by A IXI(t,l). The latter needs a very time-consuming\nbut constant set-up phase whose costs disappear in the O()-notation but not in a utility function\nsuch as the u of equation (1). For example, simply construct an environment where maximal reward is achieved by performing a never-ending sequence of simple but rewarding actions, say,\nrepeatedly pressing a lever, plus a very simple axiomatic system A that permits a short proof\nshowing that it is useful to interrupt the non-rewarding set-up phase and start pressing the lever.\n\n12\n\n\fOn the other hand, it is possible to construct situations where it is impossible to prove target\ntheorems, for example, by using results of undecidability theory, e.g., [11, 32, 3, 4]. In particular,\nadopting the extreme notion of triviality embodied by Rice’s theorem [32] (any nontrivial property\nover general functions is undecidable), only trivial improvements of a given strategy may be provably useful. This notion of triviality, however, clearly does not reflect what is intuitively regarded\nas trivial by scientists. Although many theorems of the machine learning literature in particular,\nand the computer science literature in general, are limited to functional properties that are trivial in\nthe sense of Rice, they are widely regarded as non-trivial in an intuitive sense. In fact, the infinite\ndomains of function classes addressed by Rice’s theorem are irrelevant not only for most scientists dealing with real world problems but also for a typical Gödel machine dealing with a limited\nnumber of events that may occur within its limited life time. Generally speaking, in between the\nobviously trivial and the obviously non-trivial cases there are many less obvious ones. The point is:\nusually we do not know in advance whether it is possible or not to change a given initial problem\nsolver in a provably good way. The traditional approach is to invest human research effort into\nfinding out. A Gödel machine, however, can do this by itself, without essential limits apart from\nthose of computability and provability.\nNote that to prove a target theorem, a proof technique does not necessarily have to compute the\ntrue expected utilities of switching and not switching—it just needs to determine which is higher.\nFor example, it may be easy to prove that speeding up a subroutine of the proof searcher by a\nfactor of 2 will certainly be worth the negligible (compared to lifetime T ) time needed to execute\nthe subroutine-changing algorithm, no matter what is the precise utility of the switch.\n\n5 Bias-Optimal Proof Search (BIOPS)\nHere we construct an initial p(1) that is O()-optimal in a certain limited sense to be described\nbelow, but still might be improved as it is not necessarily optimal in the sense of the given u (for\nexample, the u of equation (1) neither mentions nor cares for O()-optimality). Our Bias-Optimal\nProof Search (BIOPS) is essentially an application of Universal Search [24, 26] to proof search.\nOne novelty, however, is this: Previous practical variants and extensions of Universal Search have\nbeen applied [38, 40, 55, 48] to offline program search tasks where the program inputs are fixed\nsuch that the same program always produces the same results. In our online setting, however,\nBIOPS has to take into account that the same proof technique started at different times may yield\ndifferent proofs, as it may read parts of s (e.g., inputs) that change as the machine’s life proceeds.\n\n5.1 Online Universal Search in Proof Space\nBIOPS starts with a probability distribution P (the initial bias) on the proof techniques w that\none can write in L, e.g., P (w) = K −l(w) for programs composed from K possible instructions\n[26]. BIOPS is near-bias-optimal [48] in the sense that it will not spend much more time on any\nproof technique than it deserves, according to its probabilistic bias, namely, not much more than\nits probability times the total search time:\nDefinition 5.1 (Bias-Optimal Searchers [48]) Let R be a problem class, C be a search space of\nsolution candidates (where any problem r ∈ R should have a solution in C), P (q | r) be a task13\n\n\fdependent bias in the form of conditional probability distributions on the candidates q ∈ C. Suppose that we also have a predefined procedure that creates and tests any given q on any r ∈ R\nwithin time t(q, r) (typically unknown in advance). Then a searcher is n-bias-optimal (n ≥ 1) if\nfor any maximal total search time Ttotal &gt; 0 it is guaranteed to solve any problem r ∈ R if it has\na solution p ∈ C satisfying t(p, r) ≤ P (p | r) Ttotal /n. It is bias-optimal if n = 1.\nMethod 5.1 (BIOPS) In phase (i = 1, 2, 3, . . .) D O: F OR all self-delimiting [26] proof techniques\nw ∈ L satisfying P (w) ≥ 2−i D O:\n1. Run w until halt or error (such as division by zero) or 2iP (w) steps consumed.\n2. Undo effects of w on sp (does not cost significantly more time than executing w).\nA proof technique w can interrupt Method 5.1 only by invoking instruction check() (Item 5), which\nmay transfer control to switchprog (which possibly even will delete or rewrite Method 5.1). Since\nthe initial p runs on the formalized hardware, and since proof techniques tested by p can read p and\nother parts of s, they can produce proofs concerning the (expected) performance of p and BIOPS\nitself. Method 5.1 at least has the optimal order of computational complexity in the following\nsense.\nTheorem 5.1 If independently of variable time(s) some unknown fast proof technique w would\nrequire at most f (k) steps to produce a proof of difficulty measure k (an integer depending on the\nnature of the task to be solved), then Method 5.1 will need at most O(f (k)) steps.\nProof. It is easy to see that Method 5.1 will need at most O(f (k)/P (w)) = O(f (k)) steps—the\nconstant factor 1/P (w) does not depend on k. Q.E.D.\nThe initial proof search itself is merely O()-optimal. Note again, however, that the proofs\nthemselves may concern quite different, arbitrary formalizable notions of optimality (stronger than\nthose expressible in the O()-notation) embodied by the given, problem-specific, formalized utility\nfunction u, in particular, the maximum future reward in the sense of equation (1). This may provoke\nuseful, constant-affecting rewrites of the initial proof searcher despite its limited (yet popular and\nwidely used) notion of O()-optimality. Once a useful rewrite has been found and executed after\nsome initial fraction of the Gödel machine’s total lifetime, the restrictions of O()-optimality need\nnot be an issue any more.\n\n5.2 How a Surviving Proof Searcher May Use the Optimal Ordered Problem Solver to Solve Remaining Proof Search Tasks\nThe following is not essential for this paper. Let us assume that the execution of the switchprog\ncorresponding to the first found target theorem has not rewritten the code of p itself—the current\np is still equal to p(1)—and has reset switchbit and returned control to p such that it can continue\nwhere it was interrupted. In that case the B IOPS subroutine of p(1) can use the Optimal Ordered\nProblem Solver O OPS [48] to accelerate the search for the n-th target theorem (n &gt; 1) by reusing\nproof techniques for earlier found target theorems where possible. The basic ideas are as follows\n(details: [48]).\n14\n\n\fWhenever a target theorem has been proven, p(1) freezes the corresponding proof technique: it\nbecomes non-writable by proof techniques to be tested in later proof search tasks, but remains readable, such that it can be copy-edited and/or invoked as a subprogram by future proof techniques.\nWe also allow prefixes of proof techniques to temporarily rewrite the probability distribution on\ntheir suffixes [48], thus essentially rewriting the probability-based search procedure (an incremental extension of Method 5.1) based on previous experience. As a side-effect we metasearch for\nfaster search procedures, which can greatly accelerate the learning of new tasks [48].\nGiven a new proof search task, B IOPS performs O OPS by spending half the total search time on\na variant of Method 5.1 that searches only among self-delimiting [25, 6] proof techniques starting\nwith the most recently frozen proof technique. The rest of the time is spent on fresh proof techniques with arbitrary prefixes (which may reuse previously frozen proof techniques though) [48].\n(We could also search for a generalizing proof technique solving all proof search tasks so far. In\nthe first half of the search we would not have to test proof techniques on tasks other than the most\nrecent one, since we already know that their prefixes solve the previous tasks [48].)\nIt can be shown that O OPS is essentially 8-bias-optimal (see Def. 5.1), given either the initial\nbias or intermediate biases due to frozen solutions to previous tasks [48]. This result immediately\ncarries over to B IOPS. To summarize, B IOPS essentially allocates part of the total search time for\na new task to proof techniques that exploit previous successful proof techniques in computable\nways. If the new task can be solved faster by copy-editing / invoking previously frozen proof\ntechniques than by solving the new proof search task from scratch, then B IOPS will discover this\nand profit thereof. If not, then at least it will not be significantly slowed down by the previous\nsolutions—B IOPS will remain 8-bias-optimal.\nRecall, however, that B IOPS is not the only possible way of initializing the Gödel machine’s\nproof searcher. The Global Optimality Theorem 4.1 (Section 4) expresses optimality with respect\nto whichever initial proof searcher we choose.\n\n6 Discussion &amp; Previous Work\nHere we list a few examples of possible types of self-improvements (Section 6.1), Gödel machine\napplicability to various tasks defined by various utility functions and environments (Section 6.2),\nprobabilistic hardware (Section 6.3), and relations to previous work (Section 6.4). We also briefly\ndiscuss self-reference and consciousness (Section 6.6), and provide a list of answers to frequently\nasked questions (Section 6.7).\n\n6.1 Possible Types of Gödel Machine Self-Improvements\nWhich provably useful self-modifications are possible? There are few limits to what a Gödel\nmachine might do.\n1. In one of the simplest cases it might leave its basic proof searcher intact and just change\nthe ratio of time-sharing between the proof searching subroutine and the subpolicy e—those\nparts of p responsible for interaction with the environment.\n\n15\n\n\f2. Or the Gödel machine might modify e only. For example, the initial e(1) may be a program\nthat regularly stores limited memories of past events somewhere in s; this might allow p to\nderive that it would be useful to modify e such that e will conduct certain experiments to\nincrease the knowledge about the environment, and use the resulting information to increase\nreward intake. In this sense the Gödel machine embodies a principled way of dealing with\nthe exploration vs exploitation problem [20]. Note that the expected utility (equation (1))\nof conducting some experiment may exceed the one of not conducting it, even when the\nexperimental outcome later suggests to keep acting in line with the previous e.\n3. The Gödel machine might also modify its very axioms to speed things up. For example, it\nmight find a proof that the original axioms should be replaced or augmented by theorems\nderivable from the original axioms.\n4. The Gödel machine might even change its own utility function and target theorem, but can\ndo so only if their new values are provably better according to the old ones.\n5. In many cases we do not expect the Gödel machine to replace its proof searcher by code that\ncompletely abandons the search for proofs. Instead we expect that only certain subroutines\nof the proof searcher will be sped up—compare the example in Section 4.4—or that perhaps\njust the order of generated proofs will be modified in problem-specific fashion. This could\nbe done by modifying the probability distribution on the proof techniques of the initial biasoptimal proof searcher from Section 5.\n6. Generally speaking, the utility of limited rewrites may often be easier to prove than the one of\ntotal rewrites. For example, suppose it is 8.00pm and our Gödel machine-controlled agent’s\npermanent goal is to maximize future expected reward, using the (alternative) target theorem\n(3). Part thereof is to avoid hunger. There is nothing in its fridge, and shops close down at\n8.30pm. It does not have time to optimize its way to the supermarket in every little detail,\nbut if it does not get going right now it will stay hungry tonight (in principle such near-future\nconsequences of actions should be easily provable, possibly even in a way related to how\nhumans prove advantages of potential actions to themselves). That is, if the agent’s previous\npolicy did not already include, say, an automatic daily evening trip to the supermarket, the\npolicy provably should be rewritten at least in a very limited and simple way right now, while\nthere is still time, such that the agent will surely get some food tonight, without affecting less\nurgent future behavior that can be optimized / decided later, such as details of the route to\nthe food, or of tomorrow’s actions.\n7. In certain uninteresting environments reward is maximized by becoming dumb. For example, a given task may require to repeatedly and forever execute the same pleasure centeractivating action, as quickly as possible. In such cases the Gödel machine may delete most\nof its more time-consuming initial software including the proof searcher.\n8. Note that there is no reason why a Gödel machine should not augment its own hardware.\nSuppose its lifetime is known to be 100 years. Given a hard problem and axioms restricting\nthe possible behaviors of the environment, the Gödel machine might find a proof that its\nexpected cumulative reward will increase if it invests 10 years into building faster computational hardware, by exploiting the physical resources of its environment.\n16\n\n\f6.2 Example Applications\nTraditional examples that do not involve significant interaction with a probabilistic environment\nare easily dealt with in our reward-based framework:\nExample 6.1 (Time-limited NP-hard optimization) The initial input to the Gödel machine is the\nrepresentation of a connected graph with a large number of nodes linked by edges of various\nlengths. Within given time T it should find a cyclic path connecting all nodes. The only realvalued reward will occur at time T . It equals 1 divided by the length of the best path found so far\n(0 if none was found). There are no other inputs. The by-product of maximizing expected reward\nis to find the shortest path findable within the limited time, given the initial bias.\nExample 6.2 (Fast theorem proving) Prove or disprove as quickly as possible that all even integers &gt; 2 are the sum of two primes (Goldbach’s conjecture). The reward is 1/t, where t is the time\nrequired to produce and verify the first such proof.\nMore general cases are:\nExample 6.3 (Maximizing expected reward with bounded resources) A robot that needs at least\n1 liter of gasoline per hour interacts with a partially unknown environment, trying to find hidden,\nlimited gasoline depots to occasionally refuel its tank. It is rewarded in proportion to its lifetime, and dies after at most 100 years or as soon as its tank is empty or it falls off a cliff etc.\nThe probabilistic environmental reactions are initially unknown but assumed to be sampled from\nthe axiomatized Speed Prior [43], according to which hard-to-compute environmental reactions\nare unlikely. This permits a computable strategy for making near-optimal predictions [43]. One\nby-product of maximizing expected reward is to maximize expected lifetime.\nExample 6.4 (Optimize any suboptimal problem solver) Given any formalizable problem, implement a suboptimal but known problem solver as software on the Gödel machine hardware, and\nlet the proof searcher of Section 5 run in parallel.\n\n6.3 Probabilistic Gödel Machine Hardware\nAbove we have focused on an example deterministic machine living in a possibly probabilistic\nenvironment. It is straight-forward to extend this to computers whose actions are computed in\nprobabilistic fashion, given the current state. Then the expectation calculus used for probabilistic\naspects of the environment simply has to be extended to the hardware itself, and the mechanism\nfor verifying proofs has to take into account that there is no such thing as a certain theorem—at\nbest there are formal statements which are true with such and such probability. In fact, this may\nbe the most realistic approach as any physical hardware is error-prone, which should be taken into\naccount by realistic probabilistic Gödel machines.\nProbabilistic settings also automatically avoid certain issues of axiomatic consistency. For\nexample, predictions proven to come true with probability less than 1.0 do not necessarily cause\ncontradictions even when they do not match the observations.\n17\n\n\f6.4 Relations to Previous Work\nDespite (or maybe because of) the ambitiousness and potential power of self-improving machines,\nthere has been little work in this vein outside our own labs at IDSIA and TU München. Here we\nwill list essential differences between the Gödel machine and our previous approaches to ‘learning\nto learn,’ ‘metalearning,’ self-improvement, self-optimization, etc.\nThe most closely related approaches are Hutter’s H SEARCH and A IXI(t,l) (Item 3 below). For\nhistorical reasons, however, we will first discuss Levin’s Universal Search and Hutter’s A IXI.\n1. Gödel Machine vs Universal Search\nUnlike the fully self-referential Gödel machine, Levin’s Universal Search [24, 26] has a\nhardwired, unmodifiable meta-algorithm that cannot improve itself. It is asymptotically optimal for inversion problems whose solutions can be quickly verified in O(n) time (where\nn is the solution size), but it will always suffer from the same huge constant slowdown factors (typically &gt;&gt; 101000 ) buried in the O()-notation. The self-improvements of a Gödel\nmachine, however, can be more than merely O()-optimal, since its utility function may formalize a stonger type of optimality that does not ignore huge constants just because they are\nconstant—compare the utility function of equation (1).\nFurthermore, the Gödel machine is applicable to general lifelong reinforcement learning\n(RL) tasks [20] where Universal Search is not asymptotically optimal, and not even applicable, since in RL the evaluation of some behavior’s value in principle consumes the learner’s\nentire life! So the naive test of whether a program is good or not would consume the entire\nlife. That is, we could test only one program; afterwards life would be over.\nTherefore, to achieve their objective, general RL machines must do things that Universal\nSearch does not do, such as predicting future tasks and rewards. This partly motivates Hutter’s universal RL machine AIXI, to be discussed next.\n2. Gödel Machine vs A IXI\nUnlike Gödel machines, Hutter’s recent A IXI model [16, 19] generally needs unlimited computational resources per input update. It combines Solomonoff’s universal prediction scheme\n[57, 58] with an expectimax computation. In discrete cycle k = 1, 2, 3, . . ., action y(k) results in perception x(k) and reward r(k), both sampled from the unknown (reactive) environmental probability distribution µ. A IXI defines a mixture distribution ξ as a weighted\nsum of distributions ν ∈ M, where M is any class of distributions that includes the true environment µ. For example, M may be a sum of all computable distributions [57, 58], where\nthe sum of the weights does not exceed 1. In cycle k + 1, A IXI selects as next action the\nfirst in an action sequence maximizing ξ-predicted reward up to some given horizon. Recent\nwork [18] demonstrated A IXI ’s optimal use of observations as follows. The Bayes-optimal\npolicy pξ based on the mixture ξ is self-optimizing in the sense that its average utility value\nconverges asymptotically for all µ ∈ M to the optimal value achieved by the (infeasible)\nBayes-optimal policy pµ which knows µ in advance. The necessary condition that M admits\nself-optimizing policies is also sufficient. Furthermore, pξ is Pareto-optimal in the sense that\n\n18\n\n\fthere is no other policy yielding higher or equal value in all environments ν ∈ M and a\nstrictly higher value in at least one [18].\nWhile A IXI clarifies certain theoretical limits of machine learning, it is computationally\nintractable, especially when M includes all computable distributions. This drawback motivated work on the time-bounded, asymptotically optimal A IXI(t,l) system [16] and the\nrelated H SEARCH [17], both to be discussed next.\n3. Gödel Machine vs H SEARCH and A IXI(t,l)\nNow we come to the most closely related previous work; so we will go an extra length to\npoint out the main novelties of the Gödel machine.\nHutter’s non-self-referential but still O()-optimal ‘fastest’ algorithm for all well-defined\nproblems H SEARCH [17] uses a hardwired brute force proof searcher and ignores the costs\nof proof search. Assume discrete input/output domains X/Y , a formal problem specification f : X → Y (say, a functional description of how integers are decomposed into their\nprime factors), and a particular x ∈ X (say, an integer to be factorized). H SEARCH orders all\nproofs of an appropriate axiomatic system by size to find programs q that for all z ∈ X provably compute f (z) within time bound tq (z). Simultaneously it spends most of its time on\nexecuting the q with the best currently proven time bound tq (x). It turns out that H SEARCH\nis as fast as the fastest algorithm that provably computes f (z) for all z ∈ X, save for a constant factor smaller than 1 + ǫ (arbitrary ǫ &gt; 0) and an f -specific but x-independent additive\nconstant [17]. This constant may be enormous though.\nHutter’s A IXI(t,l) [16] is related. In discrete cycle k = 1, 2, 3, . . . of A IXI(t,l)’s lifetime,\naction y(k) results in perception x(k) and reward r(k), where all quantities may depend on\nthe complete history. Using a universal computer such as a Turing machine, A IXI(t,l) needs\nan initial offline setup phase (prior to interaction with the environment) where it uses a hardwired brute force proof searcher to examine all proofs of length at most L, filtering out those\nthat identify programs (of maximal size l and maximal runtime t per cycle) which not only\ncould interact with the environment but which for all possible interaction histories also correctly predict a lower bound of their own expected future reward. In cycle k, A IXI(t,l) then\nruns all programs identified in the setup phase (at most 2l ), finds the one with highest selfrating, and executes its corresponding action. The problem-independent setup time (where\nalmost all of the work is done) is O(L · 2L ). The online time per cycle is O(t · 2l ). Both are\nconstant but typically huge.\nAdvantages and Novelty of the Gödel Machine. There are major differences between the\nGödel machine and Hutter’s H SEARCH [17] and A IXI(t,l) [16], including:\n(a) The theorem provers of H SEARCH and A IXI(t,l) are hardwired, non-self-referential,\nunmodifiable meta-algorithms that cannot improve themselves. That is, they will always suffer from the same huge constant slowdowns (typically ≫ 101000 ) buried in the\nO()-notation. But there is nothing in principle that prevents the truly self-referential\ncode of a Gödel machine from proving and exploiting drastic reductions of such constants, in the best possible way that provably constitutes an improvement, if there is\nany.\n19\n\n\f(b) The demonstration of the O()-optimality of H SEARCH and A IXI(t,l) depends on a\nclever allocation of computation time to some of their unmodifiable meta-algorithms.\nOur Global Optimality Theorem (Theorem 4.1, Section 4), however, is justified through\na quite different type of reasoning which indeed exploits and crucially depends on the\nfact that there is no unmodifiable software at all, and that the proof searcher itself\nis readable, modifiable, and can be improved. This is also the reason why its selfimprovements can be more than merely O()-optimal.\n(c) H SEARCH uses a “trick” of proving more than is necessary which also disappears in\nthe sometimes quite misleading O()-notation: it wastes time on finding programs that\nprovably compute f (z) for all z ∈ X even when the current f (x)(x ∈ X) is the only\nobject of interest. A Gödel machine, however, needs to prove only what is relevant to\nits goal formalized by u. For example, the general u of eq. (1) completely ignores the\nlimited concept of O()-optimality, but instead formalizes a stronger type of optimality\nthat does not ignore huge constants just because they are constant.\n(d) Both the Gödel machine and A IXI(t,l) can maximize expected reward (H SEARCH cannot). But the Gödel machine is more flexible as we may plug in any type of formalizable utility function (e.g., worst case reward), and unlike A IXI(t,l) it does not require\nan enumerable environmental distribution.\nNevertheless, we may use A IXI(t,l) or H SEARCH or other less general methods to initialize\nthe substring e of p which is responsible for interaction with the environment. The Gödel\nmachine will replace e(1) as soon as it finds a provably better strategy.\nIt is the self-referential aspects of the Gödel machine that relieve us of much of the burden\nof careful algorithm design required for A IXI(t,l) and H SEARCH. They make the Gödel machine both conceptually simpler and more general.\n4. Gödel Machine vs O OPS\nThe Optimal Ordered Problem Solver O OPS [48, 44] (used by B IOPS in Section 5.2) extends\nUniversal Search (Item 1). It is a bias-optimal (see Def. 5.1) way of searching for a program that solves each problem in an ordered sequence of problems of a rather general type,\ncontinually organizing and managing and reusing earlier acquired knowledge. Solomonoff\nrecently also proposed related ideas for a scientist’s assistant [59] that modifies the probability distribution of Universal Search [24] based on experience.\nLike Universal Search (Item 1), O OPS is not directly applicable to RL problems. A provably optimal RL machine must somehow prove properties of otherwise un-testable behaviors\n(such as: what is the expected reward of this behavior which one cannot naively test as there\nis not enough time). That is part of what the Gödel machine does: it tries to greatly cut\ntesting time, replacing naive time-consuming tests by much faster proofs of predictable test\noutcomes whenever this is possible.\nProof verification itself can be performed very quickly. In particular, verifying the correctness of a found proof typically does not consume the remaining life. Hence the Gödel\nmachine may use O OPS as a bias-optimal proof-searching submodule (Section 5.2). Since\n20\n\n\fthe proofs themselves may concern quite different, arbitrary notions of optimality (not just\nbias-optimality), the Gödel machine is more general than plain O OPS. But it is not just an\nextension of O OPS. Instead of O OPS it may as well use non-bias-optimal alternative methods to initialize its proof searcher. On the other hand, O OPS is not just a precursor of the\nGödel machine. It is a stand-alone, incremental, bias-optimal way of allocating runtime to\nprograms that reuse previously successful programs, and is applicable to many traditional\nproblems, including but not limited to proof search.\n5. Gödel Machine vs Success-Story Algorithm and Other Metalearners\nA learner’s modifiable components are called its policy. An algorithm that modifies the policy is a learning algorithm. If the learning algorithm has modifiable components represented\nas part of the policy, then we speak of a self-modifying policy (SMP) [53]. SMPs can modify\nthe way they modify themselves etc. The Gödel machine has an SMP.\nIn previous practical work we used the success-story algorithm (SSA) to force some (stochastic) SMP to trigger better and better self-modifications [37, 54, 53, 55]. During the learner’s\nlife-time, SSA is occasionally called at times computed according to SMP itself. SSA uses\nbacktracking to undo those SMP-generated SMP-modifications that have not been empirically observed to trigger lifelong reward accelerations (measured up until the current SSA\ncall—this evaluates the long-term effects of SMP-modifications setting the stage for later\nSMP-modifications). SMP-modifications that survive SSA represent a lifelong success history. Until the next SSA call, they build the basis for additional SMP-modifications. Solely\nby self-modifications our SMP/SSA-based learners solved a complex task in a partially observable environment whose state space is far bigger than most found in the literature [53].\nThe Gödel machine’s training algorithm is theoretically much more powerful than SSA\nthough. SSA empirically measures the usefulness of previous self-modifications, and does\nnot necessarily encourage provably optimal ones. Similar drawbacks hold for Lenat’s humanassisted, non-autonomous, self-modifying learner [23], our Meta-Genetic Programming [34]\nextending Cramer’s Genetic Programming [8, 1], our metalearning economies [34] extending Holland’s machine learning economies [15], and gradient-based metalearners for continuous program spaces of differentiable recurrent neural networks [36, 13]. All these methods,\nhowever, could be used to seed p(1) with an initial policy.\n\n6.5 Are Humans Probabilistic Gödel Machines?\nWe do not know. We think they better be. Their initial underlying formal system for dealing with\nuncertainty seems to differ substantially from those of traditional expectation calculus and logic\nthough—compare Items 1c and 1d in Section 3.2 as well as the supermarket example (Item 6 in\nSection 6.1).\n\n21\n\n\f6.6 Gödel Machines and Consciousness\nIn recent years the topic of consciousness has gained some credibility as a serious research issue, at\nleast in philosophy and neuroscience, e.g., [9]. However, there is a lack of technical justifications\nof consciousness: so far nobody has shown that consciousness is really useful for solving problems,\nalthough problem solving is considered of central importance in philosophy [31].\nThe fully self-referential Gödel machine may be viewed as providing just such a technical\njustification [50]. It is “conscious” or “self-aware” in the sense that its entire behavior is open to\nself-introspection, and modifiable. It may ‘step outside of itself’ [14] by executing self-changes\nthat are provably good, where the proof searcher itself is subject to analysis and change through\nthe proof techniques it tests. And this type of total self-reference is precisely the reason for its\noptimality as a problem solver, in the sense of Theorem 4.1.\n\n6.7 Frequently Asked Questions\nIn the past year the author frequently fielded questions about the Gödel machine. Here a list of\nanswers to typical ones.\n1. Q: Does the exact business of formal proof search really make sense in the uncertain real\nworld?\nA: Yes, it does. We just need to insert into p(1) the standard axioms for representing uncertainty and for dealing with probabilistic settings and expected rewards etc. Compare items\n1d and 1c in Section 3.2, and the definition of utility as an expected value in equation (1).\nAlso note that the machine learning literature is full of human-generated proofs of properties\nof methods for dealing with stochastic environments.\n2. Q: The target theorem (2) seems to refer only to the very first self-change, which may completely rewrite the proof-search subroutine—doesn’t this make the proof of Theorem 4.1 invalid? What prevents later self-changes from being destructive?\nA: This is fully taken care of. Please have a look once more at the proof of Theorem 4.1, and\nnote that the first self-change will be executed only if it is provably useful (in the sense of the\npresent untility function u) for all future self-changes (for which the present self-change is\nsetting the stage). This is actually one of the main points of the whole self-referential set-up.\n3. Q (related to the previous item): The Gödel machine implements a meta-learning behavior:\nwhat about a meta-meta, and a meta-meta-meta level?\nA: The beautiful thing is that all meta-levels are automatically collapsed into one: any proof\nof a target theorem automatically proves that the corresponding self-modification is good for\nall further self-modifications affected by the present one, in recursive fashion. Recall Section\n4.3.\n4. Q: The Gödel machine software can produce only computable mappings from input sequences to output sequences. What if the environment is non-computable?\n\n22\n\n\fA: Many physicists and other scientists (exceptions: [63, 39]) actually seem to assume the\nreal world makes use of all the real numbers, most of which are incomputable. Nevertheless,\ntheorems and proofs are just finite symbol strings, and all treatises of physics contain only\ncomputable axioms and theorems, even when some of the theorems can be interpreted as\nmaking statements about uncountably many objects, such as all the real numbers. (Note\nthough that the Löwenheim-Skolem Theorem [28, 56] implies that any first order theory\nwith an uncountable model such as the real numbers also has a countable model.) Generally\nspeaking, formal descriptions of non-computable objects do not at all present a fundamental\nproblem—they may still allow for finding a strategy that provably maximizes utility. If so, a\nGödel machine can exploit this. If not, then humans will not have a fundamental advantage\nover Gödel machines.\n5. Q: Isn’t automated theorem-proving very hard? Current AI systems cannot prove nontrivial\ntheorems without human intervention at crucial decision points.\nA: More and more important mathematical proofs (four color theorem etc) heavily depend\non automated proof search. And traditional theorem provers do not even make use of our\nnovel notions of proof techniques and O()-optimal proof search. Of course, some proofs\nare indeed hard to find, but here humans and Gödel machines face the same fundamental\nlimitations.\n6. Q: Don’t the “no free lunch theorems” [62] say that it is impossible to construct universal\nproblem solvers?\nA: No, they do not. They refer to the very special case of problems sampled from i.i.d.\nuniform distributions on finite problem spaces. See the discussion of no free lunch theorems\nin an earlier paper [48].\n7. Q: Can’t the Gödel machine switch to a program switchprog that rewrites the utility function\nto a “bogus” utility function that makes unfounded promises of big rewards in the near\nfuture?\nA: No, it cannot. It should be obvious that rewrites of the utility function can happen only\nif the Gödel machine first can prove that the rewrite is useful according to the present utility\nfunction.\n8. Q: Aren’t there problems with undecidability? For example, doesn’t Rice’s theorem [32] or\nBlum’s speed-up theorem [3, 4] pose problems?\nA: Not at all. Of course, the Gödel machine cannot profit from a hypothetical useful selfimprovement whose utility is undecidable, and will therefore simply ignore it. Compare\nSection 2.4 on fundamental limitations of Gödel machines (and humans, for that matter).\nNevertheless, unlike previous methods, a Gödel machine can in principle exploit at least the\nprovably good improvements and speed-ups of any part of its initial software.\n\n23\n\n\f7 Conclusion\nIn 1931, Kurt Gödel laid the foundations of theoretical computer science, using elementary arithmetics to build a universal programming language for encoding arbitrary proofs, given an arbitrary\nenumerable set of axioms. He went on to construct self-referential formal statements that claim\ntheir own unprovability, using Cantor’s diagonalization trick [5] to demonstrate that formal systems such as traditional mathematics are either flawed in a certain sense or contain unprovable but\ntrue statements [11]. Since Gödel’s exhibition of the fundamental limits of proof and computation,\nand Konrad Zuse’s subsequent construction of the first working programmable computer (19351941), there has been a lot of work on specialized algorithms solving problems taken from more or\nless general problem classes. Apparently, however, one remarkable fact has so far escaped the attention of computer scientists: it is possible to use self-referential proof systems to build optimally\nefficient yet conceptually very simple universal problem solvers.\nThe initial software p(1) of our Gödel machine runs an initial, typically sub-optimal problem\nsolver, e.g., one of Hutter’s approaches [16, 17] which have at least an optimal order of complexity,\nor some less general method [20]. Simultaneously, it runs an O()-optimal initial proof searcher\nusing an online variant of Universal Search to test proof techniques, which are programs able to\ncompute proofs concerning the system’s own future performance, based on an axiomatic system A\nencoded in p(1), describing a formal utility function u, the hardware and p(1) itself. If there is no\nprovably good, globally optimal way of rewriting p(1) at all, then humans will not find one either.\nBut if there is one, then p(1) itself can find and exploit it. This approach yields the first class of\ntheoretically sound, fully self-referential, optimally efficient, general problem solvers.\nAfter the theoretical discussion in Sections 1-5, one practical question remains: to build a\nparticular, especially practical Gödel machine with small initial constant overhead, which generally\nuseful theorems should one add as axioms to A (as initial bias) such that the initial searcher does\nnot have to prove them from scratch?\n\n8 Acknowledgments\nThanks to Alexey Chernov, Marcus Hutter, Jan Poland, Ray Solomonoff, Sepp Hochreiter, Shane\nLegg, Leonid Levin, Alex Graves, Matteo Gagliolo, Viktor Zhumatiy, Ben Goertzel, Will Pearson,\nand Faustino Gomez, for useful comments on drafts or summaries or earlier versions of this paper. I\nam also grateful to many others who asked questions during Gödel machine talks or sent comments\nby email. Their input helped to shape Section 6.7 on frequently asked questions.\n\n24\n\n\fReferences\n[1] W. Banzhaf, P. Nordin, R. E. Keller, and F. D. Francone. Genetic Programming – An Introduction. Morgan Kaufmann Publishers, San Francisco, CA, USA, 1998.\n[2] R. Bellman. Adaptive Control Processes. Princeton University Press, 1961.\n[3] M. Blum. A machine-independent theory of the complexity of recursive functions. Journal\nof the ACM, 14(2):322–336, 1967.\n[4] M. Blum. On effective procedures for speeding up algorithms.\n18(2):290–305, 1971.\n\nJournal of the ACM,\n\n[5] G. Cantor. Über eine Eigenschaft des Inbegriffes aller reellen algebraischen Zahlen. Crelle’s\nJournal für Mathematik, 77:258–263, 1874.\n[6] G. J. Chaitin. A theory of program size formally identical to information theory. Journal of\nthe ACM, 22:329–340, 1975.\n[7] W. F. Clocksin and C. S. Mellish. Programming in Prolog (3rd ed.). Springer-Verlag, 1987.\n[8] N. L. Cramer. A representation for the adaptive generation of simple sequential programs. In\nJ.J. Grefenstette, editor, Proceedings of an International Conference on Genetic Algorithms\nand Their Applications, Carnegie-Mellon University, July 24-26, 1985, Hillsdale NJ, 1985.\nLawrence Erlbaum Associates.\n[9] F. Crick and C. Koch. Consciousness and neuroscience. Cerebral Cortex, 8:97–107, 1998.\n[10] M. C. Fitting. First-Order Logic and Automated Theorem Proving. Graduate Texts in Computer Science. Springer-Verlag, Berlin, 2nd edition, 1996.\n[11] K. Gödel. Über formal unentscheidbare Sätze der Principia Mathematica und verwandter\nSysteme I. Monatshefte für Mathematik und Physik, 38:173–198, 1931.\n[12] W. Heisenberg. Über den anschaulichen Inhalt der quantentheoretischen Kinematik und\nMechanik. Zeitschrift für Physik, 33:879–893, 1925.\n[13] S. Hochreiter, A. S. Younger, and P. R. Conwell. Learning to learn using gradient descent. In\nLecture Notes on Comp. Sci. 2130, Proc. Intl. Conf. on Artificial Neural Networks (ICANN2001), pages 87–94. Springer: Berlin, Heidelberg, 2001.\n[14] D. R. Hofstadter. Gödel, Escher, Bach: an Eternal Golden Braid. Basic Books, 1979.\n[15] J. H. Holland. Properties of the bucket brigade. In Proceedings of an International Conference on Genetic Algorithms. Lawrence Erlbaum, Hillsdale, NJ, 1985.\n[16] M. Hutter. Towards a universal theory of artificial intelligence based on algorithmic probability and sequential decisions. Proceedings of the 12th European Conference on Machine\nLearning (ECML-2001), pages 226–238, 2001. (On J. Schmidhuber’s SNF grant 20-61847).\n25\n\n\f[17] M. Hutter. The fastest and shortest algorithm for all well-defined problems. International\nJournal of Foundations of Computer Science, 13(3):431–443, 2002. (On J. Schmidhuber’s\nSNF grant 20-61847).\n[18] M. Hutter. Self-optimizing and Pareto-optimal policies in general environments based on\nBayes-mixtures. In J. Kivinen and R. H. Sloan, editors, Proceedings of the 15th Annual\nConference on Computational Learning Theory (COLT 2002), Lecture Notes in Artificial\nIntelligence, pages 364–379, Sydney, Australia, 2002. Springer. (On J. Schmidhuber’s SNF\ngrant 20-61847).\n[19] M. Hutter. Universal Artificial Intelligence: Sequential Decisions based on Algorithmic\nProbability. Springer, Berlin, 2004. (On J. Schmidhuber’s SNF grant 20-61847).\n[20] L. P. Kaelbling, M. L. Littman, and A. W. Moore. Reinforcement learning: a survey. Journal\nof AI research, 4:237–285, 1996.\n[21] A. N. Kolmogorov. Grundbegriffe der Wahrscheinlichkeitsrechnung. Springer, Berlin, 1933.\n[22] A. N. Kolmogorov. Three approaches to the quantitative definition of information. Problems\nof Information Transmission, 1:1–11, 1965.\n[23] D. Lenat. Theory formation by heuristic search. Machine Learning, 21, 1983.\n[24] L. A. Levin. Universal sequential search problems. Problems of Information Transmission,\n9(3):265–266, 1973.\n[25] L. A. Levin. Laws of information (nongrowth) and aspects of the foundation of probability\ntheory. Problems of Information Transmission, 10(3):206–210, 1974.\n[26] L. A. Levin. Randomness conservation inequalities: Information and independence in mathematical theories. Information and Control, 61:15–37, 1984.\n[27] M. Li and P. M. B. Vitányi. An Introduction to Kolmogorov Complexity and its Applications\n(2nd edition). Springer, 1997.\n[28] L. Löwenheim. Über Möglichkeiten im Relativkalkül. Mathematische Annalen, 76:447–470,\n1915.\n[29] C. H. Moore and G. C. Leach. FORTH - a language for interactive computing, 1970.\n[30] R. Penrose. Shadows of the mind. Oxford University Press, 1994.\n[31] K. R. Popper. All Life Is Problem Solving. Routledge, London, 1999.\n[32] H. G. Rice. Classes of recursively enumerable sets and their decision problems. Trans. Amer.\nMath. Soc., 74:358–366, 1953.\n[33] A. L. Samuel. Some studies in machine learning using the game of checkers. IBM Journal\non Research and Development, 3:210–229, 1959.\n\n26\n\n\f[34] J. Schmidhuber. Evolutionary principles in self-referential learning. Diploma thesis, Institut\nfür Informatik, Technische Universität München, 1987.\n[35] J. Schmidhuber. Reinforcement learning in Markovian and non-Markovian environments. In\nD. S. Lippman, J. E. Moody, and D. S. Touretzky, editors, Advances in Neural Information\nProcessing Systems 3 (NIPS 3), pages 500–506. Morgan Kaufmann, 1991.\n[36] J. Schmidhuber. A self-referential weight matrix. In Proceedings of the International Conference on Artificial Neural Networks, Amsterdam, pages 446–451. Springer, 1993.\n[37] J. Schmidhuber. On learning how to learn learning strategies. Technical Report FKI-198-94,\nFakultät für Informatik, Technische Universität München, 1994. See [55, 53].\n[38] J. Schmidhuber. Discovering solutions with low Kolmogorov complexity and high generalization capability. In A. Prieditis and S. Russell, editors, Machine Learning: Proceedings\nof the Twelfth International Conference, pages 488–496. Morgan Kaufmann Publishers, San\nFrancisco, CA, 1995.\n[39] J. Schmidhuber. A computer scientist’s view of life, the universe, and everything. In\nC. Freksa, M. Jantzen, and R. Valk, editors, Foundations of Computer Science: Potential\n- Theory - Cognition, volume 1337, pages 201–208. Lecture Notes in Computer Science,\nSpringer, Berlin, 1997.\n[40] J. Schmidhuber. Discovering neural nets with low Kolmogorov complexity and high generalization capability. Neural Networks, 10(5):857–873, 1997.\n[41] J. Schmidhuber. Algorithmic theories of everything. Technical Report IDSIA-20-00, quantph/0011122, IDSIA, Manno (Lugano), Switzerland, 2000. Sections 1-5: see [42]; Section 6:\nsee [43].\n[42] J. Schmidhuber. Hierarchies of generalized Kolmogorov complexities and nonenumerable\nuniversal measures computable in the limit. International Journal of Foundations of Computer Science, 13(4):587–612, 2002.\n[43] J. Schmidhuber. The Speed Prior: a new simplicity measure yielding near-optimal computable predictions. In J. Kivinen and R. H. Sloan, editors, Proceedings of the 15th Annual\nConference on Computational Learning Theory (COLT 2002), Lecture Notes in Artificial\nIntelligence, pages 216–228. Springer, Sydney, Australia, 2002.\n[44] J. Schmidhuber. Bias-optimal incremental problem solving. In S. Becker, S. Thrun, and\nK. Obermayer, editors, Advances in Neural Information Processing Systems 15 (NIPS 15),\npages 1571–1578, Cambridge, MA, 2003. MIT Press.\n[45] J. Schmidhuber. Gödel machines: self-referential universal problem solvers making provably\noptimal self-improvements. Technical Report IDSIA-19-03, arXiv:cs.LO/0309048, IDSIA,\nManno-Lugano, Switzerland, 2003.\n\n27\n\n\f[46] J. Schmidhuber. Towards solving the grand problem of AI. In P. Quaresma, A. Dourado,\nE. Costa, and J. F. Costa, editors, Soft Computing and complex systems, pages 77–97. Centro\nInternacional de Mathematica, Coimbra, Portugal, 2003. Based on [52].\n[47] J. Schmidhuber. Gödel machine home page, with frequently asked questions, 2004.\nhttp://www.idsia.ch/˜juergen/goedelmachine.html.\n[48] J. Schmidhuber. Optimal ordered problem solver. Machine Learning, 54:211–254, 2004.\n[49] J. Schmidhuber. Completely self-referential optimal reinforcement learners. In W. Duch,\nJ. Kacprzyk, E. Oja, and S. Zadrozny, editors, Artificial Neural Networks: Biological Inspirations - ICANN 2005, LNCS 3697, pages 223–233. Springer-Verlag Berlin Heidelberg,\n2005. Plenary talk.\n[50] J. Schmidhuber. Gödel machines: Towards a technical justification of consciousness. In\nD. Kudenko, D. Kazakov, and E. Alonso, editors, Adaptive Agents and Multi-Agent Systems\nIII (LNCS 3394), pages 1–23. Springer Verlag, 2005.\n[51] J. Schmidhuber. Gödel machines: fully self-referential optimal universal problem solvers.\nIn B. Goertzel and C. Pennachin, editors, Artificial General Intelligence. Springer Verlag, in\npress, 2006.\n[52] J. Schmidhuber. The new AI: General &amp; sound &amp; relevant for physics. In B. Goertzel and\nC. Pennachin, editors, Artificial General Intelligence. Springer, in press, 2006. Also available\nas TR IDSIA-04-03, cs.AI/0302012.\n[53] J. Schmidhuber, J. Zhao, and N. Schraudolph. Reinforcement learning with self-modifying\npolicies. In S. Thrun and L. Pratt, editors, Learning to learn, pages 293–309. Kluwer, 1997.\n[54] J. Schmidhuber, J. Zhao, and M. Wiering. Simple principles of metalearning. Technical\nReport IDSIA-69-96, IDSIA, 1996. See [55, 53].\n[55] J. Schmidhuber, J. Zhao, and M. Wiering. Shifting inductive bias with success-story algorithm, adaptive Levin search, and incremental self-improvement. Machine Learning, 28:105–\n130, 1997.\n[56] T. Skolem. Logisch-kombinatorische Untersuchungen über Erfüllbarkeit oder Beweisbarkeit\nmathematischer Sätze nebst einem Theorem über dichte Mengen. Skrifter utgit av Videnskapsselskapet in Kristiania, I, Mat.-Nat. Kl., N4:1–36, 1919.\n[57] R. J. Solomonoff. A formal theory of inductive inference. Part I. Information and Control,\n7:1–22, 1964.\n[58] R. J. Solomonoff. Complexity-based induction systems. IEEE Transactions on Information\nTheory, IT-24(5):422–432, 1978.\n[59] R. J. Solomonoff. Progress in incremental machine learning—Preliminary Report for NIPS\n2002 Workshop on Universal Learners and Optimal Search; revised Sept 2003. Technical\nReport IDSIA-16-03, IDSIA, Lugano, 2003.\n28\n\n\f[60] R. Sutton and A. Barto. Reinforcement learning: An introduction. Cambridge, MA, MIT\nPress, 1998.\n[61] A. M. Turing. On computable numbers, with an application to the Entscheidungsproblem.\nProceedings of the London Mathematical Society, Series 2, 41:230–267, 1936.\n[62] D. H. Wolpert and W. G. Macready. No free lunch theorems for search. IEEE Transactions\non Evolutionary Computation, 1, 1997.\n[63] K. Zuse. Rechnender Raum. Friedrich Vieweg &amp; Sohn, Braunschweig, 1969. English translation: Calculating Space, MIT Technical Translation AZT-70-164-GEMIT, Massachusetts\nInstitute of Technology (Proj. MAC), Cambridge, Mass. 02139, Feb. 1970.\n\n29\n\n\f</code></pre></article>\n        \n</main>\n\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js\"></script>\n<script>\n\nfunction initTheme() {\n  const saved = localStorage.getItem('kb-theme') || 'light';\n  document.documentElement.setAttribute('data-theme', saved);\n  updateThemeIcon(saved);\n}\nfunction toggleTheme() {\n  const cur = document.documentElement.getAttribute('data-theme') || 'light';\n  const next = cur === 'light' ? 'dark' : 'light';\n  document.documentElement.setAttribute('data-theme', next);\n  localStorage.setItem('kb-theme', next);\n  updateThemeIcon(next);\n}\nfunction updateThemeIcon(t) {\n  const btn = document.getElementById('theme-toggle-btn');\n  if (btn) btn.innerHTML = t === 'dark' ? '☀️' : '🌙';\n}\ndocument.addEventListener('DOMContentLoaded', initTheme);\n\nfunction setViewMode(m) {\n  const grid = document.getElementById('bento-grid-view');\n  const list = document.getElementById('list-table-view');\n  const bGrid = document.getElementById('view-grid-btn');\n  const bList = document.getElementById('view-list-btn');\n  if (m === 'list') {\n    if (grid) grid.style.display = 'none';\n    if (list) list.style.display = 'flex';\n    if (bGrid) bGrid.classList.remove('active');\n    if (bList) bList.classList.add('active');\n  } else {\n    if (grid) grid.style.display = 'grid';\n    if (list) list.style.display = 'none';\n    if (bGrid) bGrid.classList.add('active');\n    if (bList) bList.classList.remove('active');\n  }\n  localStorage.setItem('kb-view', m);\n}\ndocument.addEventListener('DOMContentLoaded', () => {\n  const s = localStorage.getItem('kb-view') || 'grid';\n  setViewMode(s);\n});\n\ndocument.addEventListener('DOMContentLoaded', () => {\n  document.querySelectorAll('pre').forEach(pre => {\n    const b = document.createElement('button');\n    b.className = 'copy-code-btn';\n    b.innerText = 'Copy';\n    b.onclick = () => {\n      const c = pre.querySelector('code') ? pre.querySelector('code').innerText : pre.innerText;\n      navigator.clipboard.writeText(c).then(() => {\n        b.innerText = 'Copied!';\n        setTimeout(() => { b.innerText = 'Copy'; }, 2000);\n      });\n    };\n    pre.appendChild(b);\n  });\n});\n\nwindow.addEventListener('keydown', (e) => {\n  if ((e.key === '/' || (e.metaKey && e.key === 'k')) && document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') {\n    e.preventDefault();\n    const q = document.getElementById('global-search-input');\n    if (q) q.focus();\n  }\n});\n\n// Scrollspy for TOC\nwindow.addEventListener('scroll', () => {\n  const headers = document.querySelectorAll('.article-body h1, .article-body h2, .article-body h3');\n  const scrollPos = window.scrollY + 100;\n  headers.forEach(h => {\n    if (h.offsetTop <= scrollPos) {\n      const id = h.getAttribute('id');\n      if (id) {\n        document.querySelectorAll('.reading-sidebar a').forEach(a => {\n          a.classList.toggle('active', a.getAttribute('href') === '#' + id);\n        });\n      }\n    }\n  });\n});\n\ndocument.addEventListener(\"DOMContentLoaded\", function() {\n  if (window.renderMathInElement) {\n    renderMathInElement(document.body, {\n      delimiters: [\n        {left: '$$', right: '$$', display: true},\n        {left: '$', right: '$', display: false},\n      ],\n      throwOnError : false\n    });\n  }\n});\n</script>\n\n</body>\n</html>\n"