Introduction to Proofgramming

Gregory M. Kapfhammer

August 25, 2025

Theory of computation

  • What is theory of computation?
    • Understanding what can be computed
    • Analyzing computational complexity
    • Proving limits of computation
    • “Proofgrammers” combine proofs and programming
  • Why is it important?
    • Helps determine if problems are solvable
    • Reveals fundamental computational limits
    • Guides key algorithm design choices
    • Undergirds modern cryptography and security

Becoming a proofgrammer

  • Master Python programming
    • Implement theoretical concepts as code
    • Express mathematical proofs as programs
    • Analyze algorithmic complexity
  • Understand computational theory
    • Automata and formal languages
    • Decidability and undecidability
    • Complexity classes and reductions
  • Use programming to explore what can be computed!

What does a proofgrammer do?

  • Proofgrammer =
    • Proof (mathematical verification) +
    • Programming (code implementation)
  • Implement Turing machines and automata
  • Prove undecidability results with Python code
  • Analyze algorithmic complexity experimentally
  • Create computational models of theoretical concepts
  • Verify theoretical results through programming
  • Welcome to the proofgrammer team! How exciting!

Define the count_lines function

def count_lines(file_content: str) -> int:
    """Count the number of lines in the provided text content."""
    if not file_content:
        return 0
    lines = file_content.split('\n')
    return len(lines)
  • Computable problems: have clear, algorithmic solutions
  • Line counting: decidable and tractable for any finite input
  • Function input: various types of input strings possible
  • Important question: what makes this problem computable?
  • Translate to uncomputable: can you make this more difficult?
  • Differences in tractable, intractable, and uncomputable?

Computable problems with Python

# example source code content
sample_code = """def hello_world():
    print("Hello, Proofgrammers!")
    return True

def main():
    result = hello_world()
    print(f"Function executed: {result}")

if __name__ == "__main__":
    main()"""

# count lines in the sample code
line_count = count_lines(sample_code)
print(f"Number of lines in the sample code: {line_count}")
print(f"This is a computable problem - we can always determine the line count!")
Number of lines in the sample code: 10
This is a computable problem - we can always determine the line count!

Try the count_lines function

  • This function accepts the source code of a program as input
  • It processes the source code without running it directly

Universal computation with Python

Let’s discuss these examples!

  • Key insights from these code examples:
    • universal: demonstrates one program executing another program
    • Universal computation is central to general-purpose computers
    • Simple example to illustrate a powerful theoretical concept
  • Discuss in your teams:
    • What makes the line counting problem computable?
    • Universal computation’s relation to general-purpose computers?
    • What are the implications of programs executing programs?
    • What are the limits to implementing computer programs?

Don’t assume it is possible to implement every Python program! Start to think like a proofgrammer!

Computational challenges

  • Characterize computational problems
    • What makes a problem computable or non-computable?
    • How do we measure algorithmic complexity?
    • What are the fundamental limits of computation?
  • Compare and analyze algorithms
    • Which approach is more efficient for large inputs?
    • How do we prove correctness of our implementations?
    • What tools help us understand computational behavior?

Theory of computation challenges

  • Abstract concepts require concrete implementations
  • Proofs must be both rigorous and programmable
  • Complexity analysis involves theory and experimentation
  • Undecidability results challenge often intuition
  • Think you finished a proof that is actually incorrect
  • Connecting mathematical theory to practical programming
  • Make sure to regularly ask questions in Discord!
  • Frequently schedule office hours with the instructor!

Learn about theory of computation

Review computational examples like WCBC book’s code segments and slides

  • Key areas of focus:
    • Python programming for theoretical concepts
    • Automata theory and formal languages
    • Computational complexity and analysis
    • Decidability and undecidability proofs
    • Practical applications of theoretical machines

Essential tools

  • Terminal window for command-line operations
  • Git and GitHub for version control and collaboration
  • VS Code for writing and testing Python code
  • Uv for Python package and dependency management
  • Quarto for creating interactive documents with code

How do we implement theoretical concepts in code? How do we verify computational results? How do we document our proofs effectively? How do we apply these insights to real-world problems?

Using AI in theoretical machines

  • GitHub Copilot, Google Gemini CLI, or OpenCode assist with code:
    • Generated code theoretically correct and well-implemented?
    • Can the generated code help verify mathematical proofs?
    • Does the generated code follow programming best practices?
    • Can you integrate AI-generated code into your proof workflows?

Proofgrammers who use AI coding tools are responsible for ensuring correctness, theoretical accuracy, and ethical use. Do not assume that the explanation or a proof of a theoretical concept is correct. Although these tools can be helpful, you must use them with skepticism and care.

Let’s set up your proofgramming environment!

  • Classroom session on Tuesday
  • Laboratory session on Tuesday
  • Classroom session on Thursday

Proofgramming environment

  • Terminal with command-line access for tool execution
  • Version control system (Git with GitHub)
  • Python development environment (UV + Python 3.12+)
  • Code editor with syntax highlighting (VS Code + extensions)
  • Documentation system (Quarto for interactive code/text)
  • Assistants (GitHub Copilot, Google Gemini CLI, OpenCode)
  • Make sure that every member of your team for the first presentation can effectively setup and use all of these tools!
  • Schedule office hours with the course instructor for help!

Development environment setup

  • Installing essential tools for prosegrammers
  • Configuring development environment for proofgramming
    • Complete these tasks during the first and second weeks
    • All skill-check and examinations assume working setup
    • Please attend the SOS Week events to learn more
    • Work with instructor and student technical leaders
    • Don’t hesitate to regularly ask questions in Discord
    • Keep working and don’t give up with setup tasks

Essential tools for proofgrammers

Tips for effective theoretical machines setup

GitHub student benefits and copilot

  • GitHub Student Developer Pack
    • Free access to premium developer tools and services
    • Apply at education.github.com
    • Requires verification with .edu email or student ID
  • GitHub Copilot Pro for Students
    • AI-powered code completion and generation
    • Free for verified students and educators
    • Integrates with VS Code and other editors
  • Why GitHub tools? Essential for collaboration!

Checking your proofgrammer setup

# Run these commands in your terminal window
git --version                   # Check Git installation
python --version                # Check Python (via UV)
quarto --version                # Check Quarto installation
code --version                  # Check VS Code installation
uv --version                    # Check UV package manager
  • Test each tool individually before starting projects
  • Create a test document with code and text to verify integration
  • Consult documentation links when troubleshooting
  • Schedule office hours with the course instructor
  • Visit office hours with the student technical leaders
  • Have these setup by the end of this week!

Coding Agents Use Node.js tools

# Install node.js and npm and npx from nodejs.org
# Then use npx to run tools without permanent installation
# You can also use npm to install them permanently
npx https://github.com/google-gemini/gemini-cli  # google gemini cli
npx opencode-ai@latest                           # opencode ai assistant
  • node.js: javascript runtime enabling AI-powered coding assistants
  • npx: run packages without installing globally, keeps system clean
  • Runtime: use node for delivery, may be built in another language
  • Testing: authentication with GitHub or Google and work with the coding agent to determine whether or not a problem is tractable or intractable. Ask the agent to explain one of the code segments from the book, without stating whether or not the code is a correct.

can you clone the course website to your laptop and run quarto preview? Output?

  • Fork the website’s repository for your team
  • Commit your presentation materials
  • Create a PR request and ask for its review

Overall proofgramming setup

Tips for effective theoretical machines setup

  • Devote time outside class to installing and configuring tools

  • Confirm that most tools work during the first lab session

  • Successfully get all tools to work during the first lab session

  • Create and render test documents with the provided examples

  • Complete the first proofgrammer presentation on time

  • Contribute to collaborative presentation projects

  • Prepare for first proofgrammer charette session

  • Get ready for an exciting journey into theoretical machines!

  • If you are having trouble, publicly ask for help on Discord!

Course goals

  • Computational Implementation:
    • Design and implement theoretical concepts as Python programs
    • Create frameworks for running proofs as Python programs
    • Test all aspects of implementations to ensure correctness
  • Communicate theoretical insights through code and documentation
  • Explain and evaluate insights during presentation sessions
  • Participate in charette sessions to discuss and learn from each other
  • Key next steps: