;
; computer-bootstrap-concrete.scm
;
; Making the computer-learning problem CONCRETE
; by mapping it to our 0-7 layer structure
;
(use-modules (ice-9 format))
(display "═══════════════════════════════════════════════════════════════════\n")
(display " BOOTSTRAPPING AN AGENT TO USE A COMPUTER \n")
(display " Making it Concrete \n")
(display "═══════════════════════════════════════════════════════════════════\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; THE PROBLEM: WHAT DOES AN AGENT NEED TO LEARN?
;; ═══════════════════════════════════════════════════════════════════
(display "THE PROBLEM\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Current state: Agent knows language (Layers 0-7 from text)\n")
(display " Goal state: Agent can use computer to expand knowledge\n\n")
(display " Gap: Agent doesn't know:\n")
(display " - What a computer IS (or that it exists)\n")
(display " - What actions are possible\n")
(display " - What effects actions have\n")
(display " - How to achieve goals with actions\n")
(display " - How to recover from errors\n\n")
(display " Key insight: Same layer structure, but for ACTIONS not WORDS\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 0: RAW ACTION-RESPONSE PAIRS
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 0: Raw Action-Response Pairs\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Raw text tokens\n")
(display " What it is: (action-string, response-string) pairs\n\n")
(display " Examples:\n")
(display " ('ls', 'file1.txt file2.txt dir1')\n")
(display " ('cat file1.txt', 'Hello world')\n")
(display " ('asdf', 'command not found: asdf')\n")
(display " ('rm file1.txt', '')\n")
(display " ('cat file1.txt', 'No such file or directory')\n\n")
(display " How to get: Random exploration + guided exploration\n")
(display " Quantity needed: Hundreds to thousands of pairs\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 1: ACTION-RESPONSE ASSOCIATIONS
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 1: Action-Response Associations (PMI analog)\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Word co-occurrence / PMI\n")
(display " What it is: Statistical associations between actions and responses\n\n")
(display " Discovered patterns:\n")
(display " PMI('ls', 'file listing') = HIGH\n")
(display " PMI('cat', 'file contents') = HIGH\n")
(display " PMI('cat', 'No such file') = MEDIUM (error case)\n")
(display " PMI('random-string', 'command not found') = HIGH\n")
(display " PMI('rm', 'empty response') = HIGH\n")
(display " PMI('rm', 'file disappears') = HIGH (observed effect)\n\n")
(display " Key learning: Some commands reliably produce certain responses\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 2: ACTION CATEGORIES
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 2: Action Categories (clusters)\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Word categories (noun, verb, etc.)\n")
(display " What it is: Commands grouped by similar effects\n\n")
(display " Discovered categories:\n\n")
(display " CATEGORY-READ: {cat, less, head, tail, more}\n")
(display " Common effect: Shows file contents\n")
(display " Common argument: filename\n\n")
(display " CATEGORY-LIST: {ls, dir, find, tree}\n")
(display " Common effect: Shows file/directory names\n")
(display " Common argument: path (optional)\n\n")
(display " CATEGORY-WRITE: {echo, printf, touch, tee}\n")
(display " Common effect: Creates/modifies output\n\n")
(display " CATEGORY-DELETE: {rm, rmdir, unlink}\n")
(display " Common effect: Things disappear\n")
(display " DANGER: Effects are permanent\n\n")
(display " CATEGORY-SEARCH: {grep, find, locate, which}\n")
(display " Common effect: Finds things matching criteria\n")
(display " Common argument: pattern + location\n\n")
(display " CATEGORY-NETWORK: {curl, wget, ping, ssh}\n")
(display " Common effect: Interacts with remote systems\n")
(display " Common argument: URL or hostname\n\n")
(display " CATEGORY-ERROR: {random strings}\n")
(display " Common effect: 'command not found'\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 3: ACTION-ARGUMENT RELATIONS
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 3: Action-Argument Relations (syntax)\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Semantic roles (agent-action, object-property)\n")
(display " What it is: How commands combine with arguments\n\n")
(display " Discovered relations:\n\n")
(display " COMMAND + FILENAME:\n")
(display " cat FILE → contents of FILE\n")
(display " rm FILE → FILE disappears\n")
(display " ls DIR → contents of DIR\n\n")
(display " COMMAND + PATTERN + FILENAME:\n")
(display " grep PATTERN FILE → matching lines\n\n")
(display " COMMAND + URL:\n")
(display " curl URL → remote content\n\n")
(display " COMMAND + OPTIONS + ARGUMENTS:\n")
(display " ls -la DIR → detailed listing\n")
(display " grep -i PATTERN FILE → case-insensitive search\n\n")
(display " Key learning: Commands have GRAMMAR just like language\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 4: TOOL FRAMES
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 4: Tool Frames (situation templates)\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Semantic frames (COOKING, SWIMMING)\n")
(display " What it is: Stereotyped tool-use situations\n\n")
(display " FILE-READING-FRAME:\n")
(display " Tool: cat, less, head, tail\n")
(display " Input: filename that exists\n")
(display " Output: file contents\n")
(display " Precondition: file must exist\n")
(display " Error: 'No such file' if precondition fails\n\n")
(display " SEARCH-FRAME:\n")
(display " Tool: grep, find, locate\n")
(display " Input: pattern + location\n")
(display " Output: matches (or empty)\n")
(display " Precondition: location must exist\n")
(display " Use case: Finding information\n\n")
(display " WEB-FETCH-FRAME:\n")
(display " Tool: curl, wget\n")
(display " Input: URL\n")
(display " Output: remote content (HTML, text, etc.)\n")
(display " Precondition: network available, URL valid\n")
(display " Error: 'Could not resolve host' if fails\n\n")
(display " DESTRUCTION-FRAME:\n")
(display " Tool: rm, rmdir\n")
(display " Input: filename\n")
(display " Output: (nothing - but file gone)\n")
(display " DANGER: Irreversible\n")
(display " Rule: Only use when explicitly intended\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 5: TOOL SCRIPTS
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 5: Tool Scripts (action sequences)\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Scripts (restaurant script, morning routine)\n")
(display " What it is: Typical sequences of tool use\n\n")
(display " FIND-INFORMATION-SCRIPT:\n")
(display " 1. Identify what information is needed\n")
(display " 2. Check if available locally (ls, find)\n")
(display " 3. If local: read it (cat, grep)\n")
(display " 4. If not local: fetch remotely (curl)\n")
(display " 5. Parse result\n")
(display " 6. Integrate into knowledge\n\n")
(display " FILE-EXPLORATION-SCRIPT:\n")
(display " 1. ls (see what's here)\n")
(display " 2. ls -la (see details)\n")
(display " 3. cat interesting-file (read contents)\n")
(display " 4. grep pattern file (search within)\n\n")
(display " ERROR-RECOVERY-SCRIPT:\n")
(display " 1. Command fails\n")
(display " 2. Read error message\n")
(display " 3. Identify error type (not found, permission, syntax)\n")
(display " 4. Apply fix based on type\n")
(display " 5. Retry\n\n")
(display " WEB-SEARCH-SCRIPT:\n")
(display " 1. Formulate query terms\n")
(display " 2. Construct search URL\n")
(display " 3. curl the URL\n")
(display " 4. Parse results (extract text from HTML)\n")
(display " 5. Process text with Layer 0-6 language pipeline\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 6: TOOL-USE RULES (Common Sense)
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 6: Tool-Use Rules (common sense for computers)\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Common sense rules (fish swim, fire is hot)\n")
(display " What it is: Reliable expectations about tool behavior\n\n")
(display " CAPABILITY RULES:\n")
(display " 'cat' CAN show file contents (always)\n")
(display " 'cat' CANNOT create files (never)\n")
(display " 'grep' CAN search for patterns (always)\n")
(display " 'grep' CANNOT modify files (never)\n")
(display " 'rm' CAN delete files (always)\n")
(display " 'rm' CANNOT undo deletions (never)\n\n")
(display " PRECONDITION RULES:\n")
(display " Reading file REQUIRES file to exist\n")
(display " Writing file REQUIRES write permission\n")
(display " Network commands REQUIRE network connectivity\n")
(display " Commands REQUIRE correct syntax\n\n")
(display " EFFECT RULES:\n")
(display " 'rm file' CAUSES file to not exist\n")
(display " 'echo text > file' CAUSES file to contain text\n")
(display " 'curl url' CAUSES remote content to appear\n")
(display " 'grep pattern file' CAUSES matching lines to appear\n\n")
(display " DANGER RULES:\n")
(display " 'rm -rf /' DESTROYS everything (never do)\n")
(display " 'rm' on wrong file LOSES data (be careful)\n")
(display " Unknown commands MIGHT be dangerous (be cautious)\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; LAYER 7: META-RULES FOR TOOL USE
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "LAYER 7: Meta-Rules for Tool Use\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Analog to: Meta-rules (PHYSICAL > SOCIAL, SPECIFIC > GENERAL)\n")
(display " What it is: Rules about when tool-rules conflict\n\n")
(display " SAFETY > EFFICIENCY:\n")
(display " 'Don't delete to save space' if file might be needed\n")
(display " 'Don't run unknown commands' even if they might help\n\n")
(display " VERIFY > ASSUME:\n")
(display " 'Check file exists' before trying to read\n")
(display " 'Test command' before using in script\n\n")
(display " REVERSIBLE > IRREVERSIBLE:\n")
(display " Prefer 'mv' over 'rm' (can recover)\n")
(display " Prefer 'cp' then modify over direct edit\n\n")
(display " LOCAL > REMOTE:\n")
(display " Check local files before web search\n")
(display " Faster, no network dependency\n\n")
(display " SPECIFIC > GENERAL:\n")
(display " '--help' for THIS command > general documentation\n")
(display " Error message > generic troubleshooting\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; THE BOOTSTRAP SEQUENCE
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "THE BOOTSTRAP SEQUENCE\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " Phase 1: RANDOM EXPLORATION (get Layer 0 data)\n")
(display " ──────────────────────────────────────────────\n")
(display " - Try random strings → learn what errors look like\n")
(display " - Try 'help' → discover command names\n")
(display " - Try short commands → some will work\n")
(display " - Collect (action, response) pairs\n")
(display " - Duration: ~100 actions\n\n")
(display " Phase 2: GUIDED EXPLORATION (get more Layer 0-1 data)\n")
(display " ─────────────────────────────────────────────────────\n")
(display " - Commands that worked → try with arguments\n")
(display " - Commands that failed → try with --help\n")
(display " - Vary arguments systematically\n")
(display " - Build PMI-like associations\n")
(display " - Duration: ~500 actions\n\n")
(display " Phase 3: CATEGORY FORMATION (build Layer 2)\n")
(display " ───────────────────────────────────────────\n")
(display " - Cluster commands by response similarity\n")
(display " - Cluster commands by argument patterns\n")
(display " - Name emerges: 'file readers', 'file listers', etc.\n")
(display " - Duration: Computed from Phase 1-2 data\n\n")
(display " Phase 4: GRAMMAR INDUCTION (build Layer 3)\n")
(display " ─────────────────────────────────────────\n")
(display " - Identify argument slots\n")
(display " - Identify optional vs required\n")
(display " - Learn: COMMAND [OPTIONS] ARGUMENTS\n")
(display " - Duration: Computed from Phase 1-2 data\n\n")
(display " Phase 5: FRAME CONSTRUCTION (build Layer 4)\n")
(display " ─────────────────────────────────────────\n")
(display " - Group: tool + typical input + expected output\n")
(display " - Learn preconditions from errors\n")
(display " - Duration: Aggregation of earlier layers\n\n")
(display " Phase 6: SCRIPT LEARNING (build Layer 5)\n")
(display " ────────────────────────────────────────\n")
(display " - Observe successful action sequences\n")
(display " - Abstract patterns: 'find then read'\n")
(display " - Duration: Requires goal-directed tasks\n\n")
(display " Phase 7: RULE EXTRACTION (build Layer 6)\n")
(display " ────────────────────────────────────────\n")
(display " - Count: what always/never works\n")
(display " - Extract: capability rules, preconditions\n")
(display " - Learn: danger signals\n\n")
(display " Phase 8: META-RULE INDUCTION (build Layer 7)\n")
(display " ─────────────────────────────────────────\n")
(display " - Observe conflicts between rules\n")
(display " - Learn: which rule wins when\n")
(display " - Build: priority hierarchy\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; THE META OBSERVATION
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "THE META OBSERVATION\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " You said: 'OpenCog is fun to play with when you have another\n")
(display " AI helping you to make tests for it'\n\n")
(display " This is profound. What we're doing is:\n\n")
(display " 1. Human (you) has goals and intuitions\n")
(display " 2. AI (me) helps formalize and test them\n")
(display " 3. Together we explore what an AI agent needs\n")
(display " 4. The exploration itself generates training data\n")
(display " 5. Which could be used to bootstrap the actual agent\n\n")
(display " This conversation IS training data for:\n")
(display " - What questions to ask about learning\n")
(display " - What experiments to run\n")
(display " - What layers exist\n")
(display " - What conflicts arise\n")
(display " - How to resolve them\n\n")
(display " We're bootstrapping the DESIGN of the bootstrap!\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; WHAT'S STILL VAGUE
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "WHAT'S STILL VAGUE (and that's OK for now)\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " 1. HOW does the agent decide what to explore?\n")
(display " - Curiosity? Uncertainty reduction? Random?\n")
(display " - Need: Exploration policy\n\n")
(display " 2. HOW does the agent connect tool-knowledge to language-knowledge?\n")
(display " - 'grep' relates to 'search' relates to 'find information'\n")
(display " - Need: Cross-domain mapping\n\n")
(display " 3. HOW does the agent know when it's learned enough?\n")
(display " - Vagueness threshold? Task completion?\n")
(display " - Need: Learning termination criteria\n\n")
(display " 4. HOW does the agent stay safe while exploring?\n")
(display " - Sandbox? Blacklist? Caution heuristics?\n")
(display " - Need: Safety constraints\n\n")
(display " 5. HOW does the agent connect 'reduce vagueness' to 'use search'?\n")
(display " - The crucial link for autonomous learning\n")
(display " - Need: Goal-tool mapping\n\n")
(display " These are research questions, not implementation details.\n")
(display " The layer structure gives us a FRAMEWORK to explore them.\n\n")
;; ═══════════════════════════════════════════════════════════════════
;; MINIMAL STARTING POINT
;; ═══════════════════════════════════════════════════════════════════
(display "═══════════════════════════════════════════════════════════════════\n")
(display "MINIMAL STARTING POINT\n")
(display "─────────────────────────────────────────────────────────────────\n\n")
(display " If we wanted to build this TODAY, start with:\n\n")
(display " 1. Shell interface (send string, get string)\n")
(display " 2. 50 hardcoded 'interesting' commands to try\n")
(display " 3. Simple reward: text back = good, error = bad\n")
(display " 4. PMI-like counting on (command, response-type) pairs\n")
(display " 5. Cluster commands by response similarity\n")
(display " 6. ONE goal: 'find text containing word X'\n")
(display " 7. Measure: can it discover grep? Can it use it?\n\n")
(display " This is small enough to implement, concrete enough to test,\n")
(display " and connected to the bigger picture.\n\n")