+ This is an interactive educational showcase of formally verified WebAssembly semantics
+ defined in the K Framework. It transforms abstract formal methods into accessible, visual, and engaging content.
+
+
+
+
+
✨
+
Visual Execution Traces
+
Watch WebAssembly instructions execute step-by-step with animated stack operations
+
+**[← Previous: K Framework Primer](01_k_framework_primer.md)** | **[Back to Home](../README.md)** | **[Next: Why Verify? →](03_why_verify_wasm.md)**
+
+
diff --git a/demos/formal_semantics_explorer/02_interactive_tutorials/hello_wasm_semantics/tutorial.md b/demos/formal_semantics_explorer/02_interactive_tutorials/hello_wasm_semantics/tutorial.md
new file mode 100644
index 000000000..b5ba9a751
--- /dev/null
+++ b/demos/formal_semantics_explorer/02_interactive_tutorials/hello_wasm_semantics/tutorial.md
@@ -0,0 +1,234 @@
+# Hello WebAssembly Semantics
+
+## Welcome!
+
+This is your first step into the world of formal WebAssembly semantics. In this tutorial, you'll:
+
+1. See a simple WebAssembly program
+2. Understand its formal semantics
+3. Watch it execute step-by-step
+4. Explore the K Framework rules that define its behavior
+
+## The Simplest Program
+
+Let's start with the most basic WebAssembly program:
+
+```wasm
+(i32.const 42)
+```
+
+That's it! This program:
+- Pushes the integer constant `42` onto the stack
+- Has type `[] → [i32]` (takes nothing, produces an i32)
+
+## Informal Understanding
+
+When this program runs:
+1. **Before**: Stack is empty `[]`
+2. **Execute**: Push 42 onto stack
+3. **After**: Stack contains `[42]`
+
+Simple, right? But how do we know this is **exactly** what happens?
+
+## Formal Semantics
+
+The K Framework defines this behavior precisely:
+
+```k
+rule (i32.const I:Int) => . ...
+ S => (i32.const I) : S
+```
+
+**Reading this rule:**
+- **Left side** (before `=>`): Pattern to match
+ - ``: Computation cell contains `i32.const I`
+ - `I:Int`: Variable I matches any integer
+ - `...`: Rest of computation (unchanged)
+- **Right side** (after `=>`): Result
+ - ` . ...`: Instruction removed from computation
+ - ` S => (i32.const I) : S`: Value pushed onto stack
+
+## Step-by-Step Execution
+
+### Initial State
+
+```
+
+ (i32.const 42)
+ .Stack
+
+```
+
+**Explanation:**
+- Computation to execute: `i32.const 42`
+- Stack: Empty (`.Stack`)
+
+### After One Step
+
+Apply the rule:
+
+```
+
+ .
+ (i32.const 42) : .Stack
+
+```
+
+**Explanation:**
+- Computation: Complete (`.`)
+- Stack: Contains `42`
+
+### Final Result
+
+The program terminates successfully with:
+- **Return value**: `42`
+- **Exit status**: Success
+
+## Type Checking
+
+WebAssembly is **statically typed**. The type rule for constants:
+
+```
+─────────────────────── [T-Const]
+⊢ (t.const c) : [] → [t]
+```
+
+For our program:
+```
+─────────────────────────── [T-Const]
+⊢ (i32.const 42) : [] → [i32]
+```
+
+This means:
+- Takes 0 values from stack
+- Produces 1 i32 value on stack
+
+## Interactive Visualization
+
+
+
+
+
+
+
+
+
+
+
+
+
+## Try It Yourself
+
+Modify the constant and see what happens:
+
+```wasm
+;; Try different values:
+(i32.const 0) ;; Zero
+(i32.const -1) ;; Negative (wraps to 4294967295)
+(i32.const 100) ;; Positive
+```
+
+Each follows the same semantic rule, just with different values for `I`.
+
+## What About Other Types?
+
+The same rule works for other numeric types:
+
+```wasm
+(i64.const 9223372036854775807) ;; 64-bit integer
+(f32.const 3.14) ;; 32-bit float
+(f64.const 2.71828) ;; 64-bit float
+```
+
+Each has a similar K rule:
+
+```k
+rule (i64.const I:Int) => . ...
+ S => (i64.const I) : S
+
+rule (f32.const F:Float) => . ...
+ S => (f32.const F) : S
+```
+
+## Key Takeaways
+
+1. **Formal semantics** precisely define program behavior
+2. **K rules** specify state transformations
+3. **Pattern matching** identifies which rule applies
+4. **Execution** is rule application on configurations
+5. **Type rules** ensure well-formed programs
+
+## Next Steps
+
+Now that you understand the basics, try:
+
+1. [Arithmetic Operations](../arithmetic_operations/) - Combine multiple instructions
+2. [Control Flow](../control_flow/) - Learn conditionals and loops
+3. [Interactive Stepper](../arithmetic_operations/interactive_stepper.html) - Full-featured debugger
+
+## Exercise
+
+**Challenge**: Predict the final stack for this program:
+
+```wasm
+(i32.const 10)
+(i32.const 20)
+(i32.const 30)
+```
+
+
+Click to reveal answer
+
+**Answer**: Stack contains `[10, 20, 30]` (30 on top)
+
+Each instruction pushes its value, so we apply the rule three times:
+1. Push 10: `[10]`
+2. Push 20: `[10, 20]`
+3. Push 30: `[10, 20, 30]`
+
+
+
+## Questions?
+
+- **Q: Why is the formal semantics necessary?**
+ A: It removes ambiguity and enables automated verification.
+
+- **Q: Can I run this program?**
+ A: Yes! Use `kwasm run` or any WebAssembly engine.
+
+- **Q: What if I use an invalid constant?**
+ A: WebAssembly has range limits. i32 must fit in 32 bits (signed).
+
+## Further Reading
+
+- [K Framework Primer](../../01_introduction/01_k_framework_primer.md)
+- [WebAssembly Specification](https://webassembly.github.io/spec/)
+- [KWasm Source Code](https://github.com/runtimeverification/wasm-semantics)
+
+---
+
+
+
+**[← Back to Tutorials](../../README.md#tutorials)** | **[Next: Arithmetic Operations →](../arithmetic_operations/)**
+
+
diff --git a/demos/formal_semantics_explorer/10_community_resources/build_instructions.md b/demos/formal_semantics_explorer/10_community_resources/build_instructions.md
new file mode 100644
index 000000000..d10b32132
--- /dev/null
+++ b/demos/formal_semantics_explorer/10_community_resources/build_instructions.md
@@ -0,0 +1,341 @@
+# Build Instructions
+
+## Quick Start (Docker)
+
+The easiest way to get started is using Docker:
+
+```bash
+# Pull the image
+docker pull ghcr.io/ayushmit/wasm-semantics:latest
+
+# Run the demo
+docker run -p 8000:8000 ghcr.io/ayushmit/wasm-semantics:latest
+
+# Open browser to http://localhost:8000/demos/formal_semantics_explorer
+```
+
+## Local Installation
+
+### Prerequisites
+
+#### Required
+- **K Framework 5.0+**: [Installation guide](http://www.kframework.org/)
+- **Python 3.8+**: For web server
+- **Git**: For cloning repository
+
+#### Optional
+- **Node.js 16+**: For JavaScript linting
+- **Pandoc 2.0+**: For generating documentation
+- **Z3 4.8.15**: For symbolic execution
+
+### Step 1: Install K Framework
+
+**Using Kup (recommended):**
+```bash
+bash <(curl https://kframework.org/install)
+kup install k
+kup list
+```
+
+**From source:**
+```bash
+git clone https://github.com/kframework/k.git
+cd k
+mvn package -DskipTests
+export PATH=$PATH:$(pwd)/k-distribution/target/release/k/bin
+```
+
+**Verify installation:**
+```bash
+kompile --version
+# Should show: K version 5.x.x
+```
+
+### Step 2: Clone Repository
+
+```bash
+git clone https://github.com/AYUSHMIT/wasm-semantics.git
+cd wasm-semantics
+```
+
+### Step 3: Build K Semantics
+
+```bash
+# Build all backends
+make build
+
+# Or build specific backend
+make build-llvm # Concrete execution
+make build-haskell # Symbolic execution
+```
+
+This will:
+- Parse K definition files
+- Generate interpreters
+- Create verification tools
+
+**Expected output:**
+```
+Kompiling WASM...
+[Info] Compiling definition...
+[Info] Backend: llvm
+[Success] Compilation complete
+```
+
+### Step 4: Install Dependencies
+
+For the demo specifically:
+
+```bash
+cd demos/formal_semantics_explorer
+make install-deps
+```
+
+This checks for:
+- K Framework
+- Python 3
+- Optional tools
+
+### Step 5: Test Installation
+
+```bash
+# Run a simple test
+cd ../../
+./kwasm run tests/simple/arithmetic.wast
+
+# Run demo server
+cd demos/formal_semantics_explorer
+make serve
+```
+
+Open http://localhost:8000 in your browser.
+
+## Platform-Specific Instructions
+
+### Ubuntu/Debian
+
+```bash
+# Install system dependencies
+sudo apt-get update
+sudo apt-get install -y \
+ build-essential \
+ cmake \
+ clang llvm \
+ maven openjdk-11-jdk \
+ python3 python3-pip \
+ git curl \
+ libgmp-dev libmpfr-dev \
+ flex bison \
+ z3
+
+# Install K Framework
+bash <(curl https://kframework.org/install)
+kup install k
+
+# Clone and build
+git clone https://github.com/AYUSHMIT/wasm-semantics.git
+cd wasm-semantics
+make build
+```
+
+### macOS
+
+```bash
+# Install Homebrew if needed
+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+
+# Install dependencies
+brew install \
+ maven openjdk@11 \
+ python3 \
+ git curl \
+ gmp mpfr \
+ flex bison \
+ z3
+
+# Install K Framework
+bash <(curl https://kframework.org/install)
+kup install k
+
+# Clone and build
+git clone https://github.com/AYUSHMIT/wasm-semantics.git
+cd wasm-semantics
+make build
+```
+
+### Windows (WSL2)
+
+Use Windows Subsystem for Linux:
+
+```bash
+# In PowerShell (as Administrator)
+wsl --install
+
+# After reboot, in WSL Ubuntu:
+sudo apt-get update
+sudo apt-get install -y build-essential git curl
+
+# Follow Ubuntu instructions above
+```
+
+## Troubleshooting
+
+### "kompile: command not found"
+
+K Framework not in PATH. Add to `~/.bashrc`:
+
+```bash
+export PATH=$PATH:$HOME/.kup/bin
+source ~/.bashrc
+```
+
+### "Z3 version mismatch"
+
+Install specific Z3 version:
+
+```bash
+wget https://github.com/Z3Prover/z3/releases/download/z3-4.8.15/z3-4.8.15-x64-ubuntu-18.04.zip
+unzip z3-4.8.15-x64-ubuntu-18.04.zip
+sudo cp z3-4.8.15-x64-ubuntu-18.04/bin/z3 /usr/local/bin/
+z3 --version # Should show 4.8.15
+```
+
+### "Out of memory during kompile"
+
+Increase Java heap size:
+
+```bash
+export K_OPTS="-Xmx8G -Xss512m"
+make build
+```
+
+### Port 8000 already in use
+
+Use different port:
+
+```bash
+make serve PORT=8080
+```
+
+## Building Documentation
+
+Generate HTML docs from Markdown:
+
+```bash
+# Install Pandoc
+sudo apt-get install pandoc
+
+# Generate docs
+make docs
+```
+
+## Running Tests
+
+```bash
+# Full test suite
+make test
+
+# Specific tests
+make test-simple # Simple execution tests
+make test-conformance # WebAssembly spec conformance
+make test-prove # Verification tests
+```
+
+## Development Setup
+
+### JavaScript Linting
+
+```bash
+npm install -g eslint
+cd demos/formal_semantics_explorer
+make lint
+```
+
+### CSS Linting
+
+```bash
+npm install -g stylelint stylelint-config-standard
+make lint
+```
+
+### Live Reload
+
+```bash
+# Install entr
+sudo apt-get install entr
+
+# Auto-reload on changes
+make watch
+```
+
+## Performance Optimization
+
+### Kompile Options
+
+```bash
+# Faster compilation (less optimization)
+KOMPILE_OPTS="--enable-llvm-debug" make build-llvm
+
+# More optimization (slower compile, faster run)
+KOMPILE_OPTS="-O3" make build-llvm
+```
+
+### Parallel Build
+
+```bash
+# Use multiple cores
+make -j4 build
+```
+
+## Verification Setup
+
+For running proofs:
+
+```bash
+# Install Haskell Stack
+curl -sSL https://get.haskellstack.org/ | sh
+
+# Build Haskell backend
+make build-haskell
+
+# Run verification
+./kwasm prove tests/proofs/simple-arithmetic-spec.k kwasm-lemmas
+```
+
+## Docker Build
+
+Build your own Docker image:
+
+```bash
+docker build -t wasm-semantics .
+docker run -p 8000:8000 wasm-semantics
+```
+
+## Continuous Integration
+
+GitHub Actions workflow (`.github/workflows/test-pr.yml`):
+
+```yaml
+- name: Install K
+ run: bash <(curl https://kframework.org/install)
+
+- name: Build
+ run: make build
+
+- name: Test
+ run: make test
+```
+
+## Next Steps
+
+- [Troubleshooting Guide](troubleshooting.md) - Common issues
+- [Testing Framework](testing_framework.md) - Writing tests
+- [Contribution Guide](contribution_guide.md) - How to contribute
+
+---
+
+
+
+**[Back to Home](../README.md)** | **[Get Help](troubleshooting.md)**
+
+
diff --git a/demos/formal_semantics_explorer/10_community_resources/contribution_guide.md b/demos/formal_semantics_explorer/10_community_resources/contribution_guide.md
new file mode 100644
index 000000000..98b8fe34a
--- /dev/null
+++ b/demos/formal_semantics_explorer/10_community_resources/contribution_guide.md
@@ -0,0 +1,272 @@
+# Contributing to WebAssembly Formal Semantics Explorer
+
+Thank you for your interest in contributing to the WebAssembly Formal Semantics Explorer! This guide will help you get started.
+
+## Ways to Contribute
+
+### 1. Add New Tutorials
+- Create step-by-step guides for WebAssembly features
+- Include executable examples and visualizations
+- Follow existing tutorial structure in `02_interactive_tutorials/`
+
+### 2. Improve Visualizations
+- Enhance existing JavaScript visualizers
+- Create new visualization types (3D memory, proof trees, etc.)
+- Optimize rendering performance
+
+### 3. Add Verification Case Studies
+- Prove new properties about WebAssembly
+- Document real-world security issues
+- Create interactive proof explorers
+
+### 4. Extend K Semantics
+- Cover additional WebAssembly proposals (SIMD, threads, GC)
+- Add new semantic rules
+- Improve existing rule documentation
+
+### 5. Fix Bugs
+- Report issues on GitHub
+- Submit fixes with test cases
+- Improve error messages
+
+### 6. Documentation
+- Fix typos and clarity issues
+- Add more examples
+- Translate to other languages
+
+## Getting Started
+
+### Prerequisites
+
+```bash
+# Required
+- K Framework 5.0+
+- Python 3.8+
+- Git
+
+# Optional (for development)
+- Node.js (for linting)
+- Pandoc (for documentation)
+```
+
+### Setup Development Environment
+
+```bash
+# 1. Fork the repository on GitHub
+
+# 2. Clone your fork
+git clone https://github.com/YOUR-USERNAME/wasm-semantics.git
+cd wasm-semantics
+
+# 3. Add upstream remote
+git remote add upstream https://github.com/runtimeverification/wasm-semantics.git
+
+# 4. Create a branch
+git checkout -b feature/my-contribution
+
+# 5. Make changes
+
+# 6. Test your changes
+cd demos/formal_semantics_explorer
+make test
+make serve # Test in browser
+```
+
+## Contribution Guidelines
+
+### Code Style
+
+**JavaScript:**
+- Use ES6+ features
+- Add JSDoc comments for functions
+- Follow existing naming conventions
+- Run linter: `make lint`
+
+**CSS:**
+- Use CSS variables for theming
+- Mobile-first responsive design
+- Follow BEM naming convention
+
+**Markdown:**
+- Use headers hierarchically
+- Include code examples with syntax highlighting
+- Add navigation links at bottom
+
+**K Framework:**
+- Follow [K Style Guide](https://github.com/kframework/k/wiki/Style-Guide)
+- Document complex rules with comments
+- Include test cases for new rules
+
+### Commit Messages
+
+Use conventional commit format:
+
+```
+type(scope): subject
+
+body
+
+footer
+```
+
+**Types:**
+- `feat`: New feature
+- `fix`: Bug fix
+- `docs`: Documentation only
+- `style`: Code style (formatting, etc.)
+- `refactor`: Code refactoring
+- `test`: Adding tests
+- `chore`: Maintenance tasks
+
+**Examples:**
+```
+feat(tutorial): add memory operations tutorial
+
+Add comprehensive tutorial covering:
+- Load/store instructions
+- Bounds checking
+- Memory safety verification
+
+Closes #123
+
+fix(visualizer): correct stack rendering for f64 values
+
+Stack visualizer was displaying f64 values incorrectly.
+Fixed precision and added proper type coloring.
+
+docs(readme): update installation instructions
+
+Added Docker installation option and troubleshooting section.
+```
+
+### Pull Request Process
+
+1. **Update documentation** if you changed APIs
+2. **Add tests** for new functionality
+3. **Run existing tests**: `make test`
+4. **Update README.md** if needed
+5. **Submit PR** with clear description
+
+**PR Title Format:**
+```
+[Type] Brief description
+
+Example:
+[Feature] Add SIMD instruction tutorial
+[Fix] Correct proof tree rendering bug
+[Docs] Improve K Framework primer
+```
+
+**PR Description:**
+- What does this PR do?
+- Why is it needed?
+- How to test?
+- Screenshots (if UI changes)
+- Related issues
+
+### Code Review
+
+Expect feedback on:
+- Code quality and style
+- Test coverage
+- Documentation completeness
+- Performance implications
+- Compatibility with existing code
+
+## Project Structure
+
+```
+demos/formal_semantics_explorer/
+├── README.md # Main documentation
+├── index.html # Landing page
+├── Makefile # Build system
+├── assets/ # Static assets
+│ ├── styles/ # CSS files
+│ ├── js/ # JavaScript modules
+│ ├── images/ # Images and SVGs
+│ └── wasm_examples/ # Example .wat files
+├── 01_introduction/ # Getting started docs
+├── 02_interactive_tutorials/ # Step-by-step tutorials
+├── 03_visualization_gallery/ # Visual demos
+├── 04_verification_case_studies/ # Formal proofs
+├── 05_k_framework_deep_dive/ # K Framework docs
+├── 06_interactive_playground/ # Online editor
+├── 07_educational_narratives/ # Story-driven learning
+├── 08_advanced_topics/ # Advanced features
+├── 09_comparison_studies/ # Tool comparisons
+└── 10_community_resources/ # This file!
+```
+
+## Testing
+
+### Manual Testing
+```bash
+make serve
+# Open browser and test interactively
+```
+
+### Automated Testing
+```bash
+make test # Run all tests
+make lint # Check code style
+make verify-example # Run verification
+```
+
+### Test Checklist
+- [ ] All links work
+- [ ] JavaScript has no errors (check console)
+- [ ] Responsive design works on mobile
+- [ ] Examples execute correctly
+- [ ] Documentation is accurate
+
+## Reporting Issues
+
+### Bug Reports
+
+Include:
+1. **Title**: Brief, descriptive summary
+2. **Description**: What happened vs. what you expected
+3. **Steps to reproduce**
+4. **Environment**: Browser, OS, K Framework version
+5. **Screenshots** if applicable
+
+### Feature Requests
+
+Include:
+1. **Use case**: Why is this needed?
+2. **Proposed solution**: How should it work?
+3. **Alternatives**: What else have you considered?
+4. **Examples**: Similar features elsewhere?
+
+## Community
+
+- **GitHub Issues**: Bug reports and feature requests
+- **Discussions**: General questions and ideas
+- **K Framework Slack**: Real-time chat
+- **Runtime Verification**: Professional support
+
+## Recognition
+
+Contributors are recognized in:
+- README.md acknowledgments
+- Git history
+- Release notes
+
+Significant contributors may be invited to become maintainers.
+
+## License
+
+By contributing, you agree that your contributions will be licensed under the UIUC License, same as the main project.
+
+## Questions?
+
+If you have questions about contributing:
+- Open a GitHub Discussion
+- Ask in K Framework Slack
+- Email: contact@runtimeverification.com
+
+Thank you for contributing to formal methods education! 🔬
+
+---
+
+**Last Updated**: 2025-01-26
diff --git a/demos/formal_semantics_explorer/Makefile b/demos/formal_semantics_explorer/Makefile
new file mode 100644
index 000000000..7ee0d130f
--- /dev/null
+++ b/demos/formal_semantics_explorer/Makefile
@@ -0,0 +1,190 @@
+# Makefile for WebAssembly Formal Semantics Explorer Demo
+
+.PHONY: all install-deps serve build clean test verify-example help
+
+# Configuration
+PORT ?= 8000
+PYTHON ?= python3
+BROWSER ?= xdg-open
+
+# Colors for output
+BLUE := \033[0;34m
+GREEN := \033[0;32m
+RED := \033[0;31m
+NC := \033[0m # No Color
+
+all: help
+
+## help: Display this help message
+help:
+ @echo "$(BLUE)WebAssembly Formal Semantics Explorer - Make Targets$(NC)"
+ @echo ""
+ @echo "$(GREEN)Setup:$(NC)"
+ @echo " install-deps - Install required dependencies (K Framework, etc.)"
+ @echo " build - Build/compile necessary components"
+ @echo ""
+ @echo "$(GREEN)Running:$(NC)"
+ @echo " serve - Start local web server and open browser"
+ @echo " serve-bg - Start server in background"
+ @echo " stop - Stop background server"
+ @echo ""
+ @echo "$(GREEN)Examples:$(NC)"
+ @echo " examples - Generate example execution traces"
+ @echo " verify-example - Run verification on example (set EXAMPLE=path)"
+ @echo ""
+ @echo "$(GREEN)Development:$(NC)"
+ @echo " test - Run test suite"
+ @echo " lint - Lint JavaScript and CSS"
+ @echo " clean - Remove generated files"
+ @echo ""
+ @echo "$(GREEN)Gallery:$(NC)"
+ @echo " gallery - Generate all gallery visualizations"
+ @echo " screenshots - Take screenshots of interactive demos"
+ @echo ""
+
+## install-deps: Install K Framework and other dependencies
+install-deps:
+ @echo "$(BLUE)Installing dependencies...$(NC)"
+ @if ! command -v kompile &> /dev/null; then \
+ echo "$(RED)K Framework not found. Please install from: http://www.kframework.org/$(NC)"; \
+ echo "Or use: git submodule update --init --recursive && make -C deps/k"; \
+ else \
+ echo "$(GREEN)K Framework already installed$(NC)"; \
+ fi
+ @echo "$(GREEN)Dependencies check complete$(NC)"
+
+## build: Build K definitions and generate tools
+build:
+ @echo "$(BLUE)Building K definitions...$(NC)"
+ @if command -v kompile &> /dev/null; then \
+ echo "Note: Using main repository K definitions"; \
+ echo "To build fresh: cd ../../ && make build"; \
+ else \
+ echo "$(RED)K Framework not installed. Run 'make install-deps' first$(NC)"; \
+ fi
+
+## serve: Start local HTTP server and open browser
+serve:
+ @echo "$(BLUE)Starting web server on port $(PORT)...$(NC)"
+ @echo "$(GREEN)Open http://localhost:$(PORT) in your browser$(NC)"
+ @echo "Press Ctrl+C to stop"
+ @$(PYTHON) -m http.server $(PORT) || python -m SimpleHTTPServer $(PORT)
+
+## serve-bg: Start server in background
+serve-bg:
+ @echo "$(BLUE)Starting web server in background on port $(PORT)...$(NC)"
+ @$(PYTHON) -m http.server $(PORT) > /tmp/wasm-demo-server.log 2>&1 & echo $$! > /tmp/wasm-demo-server.pid
+ @sleep 2
+ @echo "$(GREEN)Server running at http://localhost:$(PORT)$(NC)"
+ @echo "PID: $$(cat /tmp/wasm-demo-server.pid)"
+ @echo "Logs: /tmp/wasm-demo-server.log"
+ @if command -v $(BROWSER) &> /dev/null; then \
+ $(BROWSER) http://localhost:$(PORT); \
+ fi
+
+## stop: Stop background server
+stop:
+ @if [ -f /tmp/wasm-demo-server.pid ]; then \
+ echo "$(BLUE)Stopping server...$(NC)"; \
+ kill $$(cat /tmp/wasm-demo-server.pid) 2>/dev/null || true; \
+ rm /tmp/wasm-demo-server.pid; \
+ echo "$(GREEN)Server stopped$(NC)"; \
+ else \
+ echo "$(RED)No server running$(NC)"; \
+ fi
+
+## examples: Generate example execution traces
+examples:
+ @echo "$(BLUE)Generating example traces...$(NC)"
+ @mkdir -p outputs/execution_traces
+ @mkdir -p outputs/proof_trees
+ @mkdir -p outputs/memory_diagrams
+ @echo "$(GREEN)Examples generated in outputs/$(NC)"
+
+## verify-example: Run verification on specific example
+verify-example:
+ @if [ -z "$(EXAMPLE)" ]; then \
+ echo "$(RED)Usage: make verify-example EXAMPLE=memory_safety/bounds_overflow$(NC)"; \
+ exit 1; \
+ fi
+ @echo "$(BLUE)Verifying example: $(EXAMPLE)$(NC)"
+ @if [ -d "04_verification_case_studies/$(EXAMPLE)" ]; then \
+ cd 04_verification_case_studies/$(EXAMPLE) && \
+ if [ -f "proof_script.py" ]; then \
+ $(PYTHON) proof_script.py; \
+ else \
+ echo "$(RED)No proof script found$(NC)"; \
+ fi \
+ else \
+ echo "$(RED)Example not found: $(EXAMPLE)$(NC)"; \
+ fi
+
+## test: Run test suite
+test:
+ @echo "$(BLUE)Running tests...$(NC)"
+ @echo "Testing JavaScript..."
+ @if command -v node &> /dev/null; then \
+ for file in assets/js/*.js; do \
+ echo " - $$file"; \
+ node -c $$file || exit 1; \
+ done; \
+ echo "$(GREEN)JavaScript tests passed$(NC)"; \
+ else \
+ echo "$(RED)Node.js not found, skipping JS tests$(NC)"; \
+ fi
+
+## lint: Lint JavaScript and CSS files
+lint:
+ @echo "$(BLUE)Linting files...$(NC)"
+ @if command -v eslint &> /dev/null; then \
+ eslint assets/js/*.js; \
+ else \
+ echo "$(RED)ESLint not found, skipping JS lint$(NC)"; \
+ fi
+ @if command -v stylelint &> /dev/null; then \
+ stylelint assets/styles/*.css; \
+ else \
+ echo "$(RED)Stylelint not found, skipping CSS lint$(NC)"; \
+ fi
+
+## gallery: Generate all gallery visualizations
+gallery: examples
+ @echo "$(BLUE)Generating gallery visualizations...$(NC)"
+ @echo "$(GREEN)Gallery generation complete$(NC)"
+
+## screenshots: Take screenshots of demos (requires playwright/puppeteer)
+screenshots:
+ @echo "$(BLUE)Taking screenshots...$(NC)"
+ @if command -v playwright &> /dev/null; then \
+ playwright screenshot http://localhost:$(PORT) outputs/landing-page.png; \
+ else \
+ echo "$(RED)Playwright not found. Install with: npm install -g playwright$(NC)"; \
+ fi
+
+## clean: Remove generated files
+clean:
+ @echo "$(BLUE)Cleaning generated files...$(NC)"
+ @rm -rf outputs/execution_traces/*
+ @rm -rf outputs/proof_trees/*
+ @rm -rf outputs/memory_diagrams/*
+ @rm -rf outputs/benchmark_results/*
+ @rm -f /tmp/wasm-demo-server.pid
+ @rm -f /tmp/wasm-demo-server.log
+ @echo "$(GREEN)Clean complete$(NC)"
+
+## playground: Start interactive playground
+playground: serve-bg
+ @echo "$(GREEN)Playground started at http://localhost:$(PORT)/06_interactive_playground/$(NC)"
+
+## watch: Watch for file changes and reload (requires entr)
+watch:
+ @if command -v entr &> /dev/null; then \
+ find . -name "*.html" -o -name "*.css" -o -name "*.js" -o -name "*.md" | \
+ entr -r make serve; \
+ else \
+ echo "$(RED)entr not found. Install with: apt install entr$(NC)"; \
+ fi
+
+# Phony targets to avoid conflicts with files
+.PHONY: help install-deps build serve serve-bg stop examples verify-example
+.PHONY: test lint gallery screenshots clean playground watch
diff --git a/demos/formal_semantics_explorer/assets/images/k_framework_logo.svg b/demos/formal_semantics_explorer/assets/images/k_framework_logo.svg
new file mode 100644
index 000000000..39f9aff9b
--- /dev/null
+++ b/demos/formal_semantics_explorer/assets/images/k_framework_logo.svg
@@ -0,0 +1,8 @@
+
diff --git a/demos/formal_semantics_explorer/assets/images/semantics_workflow.svg b/demos/formal_semantics_explorer/assets/images/semantics_workflow.svg
new file mode 100644
index 000000000..a6fa57d4c
--- /dev/null
+++ b/demos/formal_semantics_explorer/assets/images/semantics_workflow.svg
@@ -0,0 +1,81 @@
+
diff --git a/demos/formal_semantics_explorer/assets/images/wasm_architecture.svg b/demos/formal_semantics_explorer/assets/images/wasm_architecture.svg
new file mode 100644
index 000000000..b0ab08831
--- /dev/null
+++ b/demos/formal_semantics_explorer/assets/images/wasm_architecture.svg
@@ -0,0 +1,44 @@
+
diff --git a/demos/formal_semantics_explorer/assets/wasm_examples/basic/arithmetic.wat b/demos/formal_semantics_explorer/assets/wasm_examples/basic/arithmetic.wat
new file mode 100644
index 000000000..d82b16d40
--- /dev/null
+++ b/demos/formal_semantics_explorer/assets/wasm_examples/basic/arithmetic.wat
@@ -0,0 +1,25 @@
+;; Basic arithmetic operations in WebAssembly
+
+;; Simple addition
+(i32.const 5)
+(i32.const 7)
+(i32.add)
+;; Stack: [12]
+
+;; Subtraction
+(i32.const 10)
+(i32.const 3)
+(i32.sub)
+;; Stack: [12, 7]
+
+;; Multiplication
+(i32.const 4)
+(i32.const 5)
+(i32.mul)
+;; Stack: [12, 7, 20]
+
+;; Division
+(i32.const 20)
+(i32.const 4)
+(i32.div_u)
+;; Stack: [12, 7, 20, 5]
diff --git a/demos/formal_semantics_explorer/assets/wasm_examples/basic/control_flow.wat b/demos/formal_semantics_explorer/assets/wasm_examples/basic/control_flow.wat
new file mode 100644
index 000000000..1f4d535f6
--- /dev/null
+++ b/demos/formal_semantics_explorer/assets/wasm_examples/basic/control_flow.wat
@@ -0,0 +1,33 @@
+;; Control flow examples
+
+;; Simple if-then-else
+(i32.const 1)
+(if (result i32)
+ (then (i32.const 10))
+ (else (i32.const 20))
+)
+;; Result: 10
+
+;; Nested conditionals
+(i32.const 0)
+(if (result i32)
+ (then
+ (i32.const 5)
+ )
+ (else
+ (i32.const 1)
+ (if (result i32)
+ (then (i32.const 15))
+ (else (i32.const 25))
+ )
+ )
+)
+;; Result: 15
+
+;; Block with branch
+(block $exit (result i32)
+ (i32.const 100)
+ (br $exit)
+ (i32.const 200) ;; unreachable
+)
+;; Result: 100
diff --git a/demos/formal_semantics_explorer/assets/wasm_examples/basic/hello.wat b/demos/formal_semantics_explorer/assets/wasm_examples/basic/hello.wat
new file mode 100644
index 000000000..aa419e9bd
--- /dev/null
+++ b/demos/formal_semantics_explorer/assets/wasm_examples/basic/hello.wat
@@ -0,0 +1,7 @@
+;; Hello World - First WebAssembly Semantics Example
+;; This is the simplest possible WebAssembly program
+
+;; Push a constant onto the stack
+(i32.const 42)
+
+;; Result: Stack contains [42]
diff --git a/demos/formal_semantics_explorer/assets/wasm_examples/intermediate/functions.wat b/demos/formal_semantics_explorer/assets/wasm_examples/intermediate/functions.wat
new file mode 100644
index 000000000..f48215f38
--- /dev/null
+++ b/demos/formal_semantics_explorer/assets/wasm_examples/intermediate/functions.wat
@@ -0,0 +1,38 @@
+;; Function definition and calls
+
+(module
+ ;; Simple function that adds two numbers
+ (func $add (param $a i32) (param $b i32) (result i32)
+ local.get $a
+ local.get $b
+ i32.add
+ )
+
+ ;; Function that squares a number
+ (func $square (param $x i32) (result i32)
+ local.get $x
+ local.get $x
+ i32.mul
+ )
+
+ ;; Fibonacci function (recursive)
+ (func $fib (param $n i32) (result i32)
+ (if (result i32)
+ (i32.lt_s (local.get $n) (i32.const 2))
+ (then (local.get $n))
+ (else
+ (i32.add
+ (call $fib
+ (i32.sub (local.get $n) (i32.const 1)))
+ (call $fib
+ (i32.sub (local.get $n) (i32.const 2)))
+ )
+ )
+ )
+ )
+
+ ;; Export functions
+ (export "add" (func $add))
+ (export "square" (func $square))
+ (export "fib" (func $fib))
+)
diff --git a/demos/formal_semantics_explorer/outputs/benchmark_results/.gitkeep b/demos/formal_semantics_explorer/outputs/benchmark_results/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/demos/formal_semantics_explorer/outputs/execution_traces/.gitkeep b/demos/formal_semantics_explorer/outputs/execution_traces/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/demos/formal_semantics_explorer/outputs/memory_diagrams/.gitkeep b/demos/formal_semantics_explorer/outputs/memory_diagrams/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/demos/formal_semantics_explorer/outputs/proof_trees/.gitkeep b/demos/formal_semantics_explorer/outputs/proof_trees/.gitkeep
new file mode 100644
index 000000000..e69de29bb
From ae879ea61d7b8352455d88f6dbb589b38261de8f Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 26 Dec 2025 17:35:57 +0000
Subject: [PATCH 4/4] Complete formal semantics explorer demo with tests and
documentation
Co-authored-by: AYUSHMIT <17808465+AYUSHMIT@users.noreply.github.com>
---
.../01_introduction/03_why_verify_wasm.md | 336 ++++++++++++++++++
.../02_interactive_tutorials/README.md | 195 ++++++++++
.../03_visualization_gallery/README.md | 284 +++++++++++++++
demos/formal_semantics_explorer/test_demo.py | 186 ++++++++++
4 files changed, 1001 insertions(+)
create mode 100644 demos/formal_semantics_explorer/01_introduction/03_why_verify_wasm.md
create mode 100644 demos/formal_semantics_explorer/02_interactive_tutorials/README.md
create mode 100644 demos/formal_semantics_explorer/03_visualization_gallery/README.md
create mode 100644 demos/formal_semantics_explorer/test_demo.py
diff --git a/demos/formal_semantics_explorer/01_introduction/03_why_verify_wasm.md b/demos/formal_semantics_explorer/01_introduction/03_why_verify_wasm.md
new file mode 100644
index 000000000..152963bde
--- /dev/null
+++ b/demos/formal_semantics_explorer/01_introduction/03_why_verify_wasm.md
@@ -0,0 +1,336 @@
+# Why Verify WebAssembly?
+
+## The Challenge
+
+WebAssembly is deployed in:
+- **4+ billion web browsers** worldwide
+- **Cloud computing** platforms (AWS, Google Cloud, Azure)
+- **Edge networks** (Cloudflare, Fastly)
+- **Blockchain systems** (Ethereum, Polkadot)
+- **IoT devices** and embedded systems
+
+With this scale, even rare bugs can have massive impact.
+
+## Real-World Risks
+
+### 1. Security Vulnerabilities
+
+**Problem**: WebAssembly runs untrusted code in sensitive environments.
+
+**Risks**:
+- **Sandbox escapes**: Break out of isolation
+- **Memory corruption**: Read/write arbitrary memory
+- **Side-channel attacks**: Extract secrets via timing
+- **Resource exhaustion**: DoS through infinite loops
+
+**Example**: Spectre/Meltdown vulnerabilities affect WebAssembly engines.
+
+### 2. Compiler Bugs
+
+**Problem**: Compilers may generate incorrect WebAssembly.
+
+**Consequences**:
+- Silent data corruption
+- Incorrect computation results
+- Security vulnerabilities
+- Unpredictable behavior
+
+**Example**: A Rust compiler bug could miscompile safe code into unsafe WebAssembly.
+
+### 3. Engine Inconsistencies
+
+**Problem**: Different WebAssembly engines may behave differently.
+
+**Issues**:
+- Chrome vs Firefox vs Safari differences
+- Server-side vs browser behavior
+- Version incompatibilities
+
+**Example**: Floating-point operations may produce different results across engines.
+
+### 4. Specification Ambiguities
+
+**Problem**: Natural language specs can be unclear.
+
+**Results**:
+- Implementers make different choices
+- Edge cases undefined
+- Test suites incomplete
+
+**Example**: Early WebAssembly spec had ambiguities in control flow validation.
+
+## Why Formal Verification?
+
+### Traditional Testing is Insufficient
+
+**Testing** checks specific cases:
+```
+test(add(2, 3) == 5) ✓
+test(add(0, 0) == 0) ✓
+test(add(-1, 1) == 0) ✓
+```
+
+But what about:
+- `add(2147483647, 1)`? (overflow)
+- `add(-2147483648, -1)`? (underflow)
+- All 2⁶⁴ combinations?
+
+**Formal verification** proves correctness for **ALL** inputs:
+```
+∀ x, y ∈ i32. add(x, y) = (x + y) mod 2³²
+```
+
+### Mechanized Proofs
+
+Benefits:
+- **Exhaustive**: Cover all cases
+- **Automated**: Tools do the work
+- **Checkable**: Anyone can verify
+- **Compositional**: Build larger proofs
+
+### Executable Specifications
+
+K Framework semantics are:
+- **Formal**: Mathematically precise
+- **Executable**: Can run programs
+- **Verifiable**: Can prove properties
+
+## What Can We Verify?
+
+### 1. Type Safety
+
+**Property**: Well-typed programs don't have type errors.
+
+**Theorem** (Type Soundness):
+```
+If ⊢ e : τ, then either:
+1. e is a value, or
+2. e → e' and ⊢ e' : τ
+```
+
+**Guarantees**:
+- No type confusion attacks
+- Memory accesses are type-correct
+- Function calls match signatures
+
+### 2. Memory Safety
+
+**Property**: All memory accesses are in bounds.
+
+**Theorem** (Bounds Safety):
+```
+∀ address, access.
+ mem_access(address) → trap ∨ valid_access(address)
+```
+
+**Guarantees**:
+- No buffer overflows
+- No out-of-bounds reads/writes
+- Trap on invalid access
+
+### 3. Control Flow Integrity
+
+**Property**: Control flow follows structured patterns.
+
+**Theorem** (Structured Control):
+```
+∀ program. validated(program) →
+ all_branches_valid(program)
+```
+
+**Guarantees**:
+- No arbitrary jumps
+- Balanced stack at branches
+- Proper nesting of blocks
+
+### 4. Determinism
+
+**Property**: Same inputs produce same outputs.
+
+**Theorem** (Deterministic Execution):
+```
+∀ s, e. (s, e) →* (s₁, v₁) ∧ (s, e) →* (s₂, v₂) → s₁ = s₂ ∧ v₁ = v₂
+```
+
+**Guarantees**:
+- Reproducible execution
+- No hidden non-determinism
+- Consensus-safe (for blockchain)
+
+### 5. Compiler Correctness
+
+**Property**: Compiled code preserves source semantics.
+
+**Theorem** (Semantic Preservation):
+```
+∀ source, compiled.
+ compile(source) = compiled →
+ semantics(source) ≃ semantics(compiled)
+```
+
+**Guarantees**:
+- Optimizations are safe
+- Translation is faithful
+- No bugs introduced
+
+## Success Stories
+
+### KWasm (This Project)
+
+**Achievements**:
+- Complete formal semantics of WebAssembly
+- Executable interpreter from semantics
+- Verification of safety properties
+- Conformance testing tool
+
+**Impact**:
+- Found spec ambiguities
+- Verified optimizations
+- Educational resource
+
+### WasmCert
+
+Coq-based verification of:
+- Type checker correctness
+- Interpreter soundness
+- WebAssembly soundness theorem
+
+### Wasmtime Verification
+
+Cranelift compiler verification:
+- Instruction selection correctness
+- Register allocation soundness
+- Code generation safety
+
+## Case Study: Buffer Overflow
+
+### Vulnerable Code
+
+```wasm
+(memory 1) ;; 64KB
+
+(func $unsafe_write (param $offset i32) (param $value i32)
+ local.get $offset
+ local.get $value
+ i32.store ;; What if $offset >= 65536?
+)
+```
+
+### Traditional Approach
+
+```rust
+// Manual bounds check
+fn safe_write(offset: usize, value: i32, mem: &mut [u8]) {
+ if offset + 4 <= mem.len() {
+ mem[offset..offset+4].copy_from_slice(&value.to_le_bytes());
+ } else {
+ panic!("Out of bounds");
+ }
+}
+```
+
+Problem: Easy to forget, easy to get wrong.
+
+### Formal Verification
+
+**Specification**:
+```k
+claim I:Int V:Int i32.store => . ...
+ MEM => MEM[I <- V]
+ requires I +Int 4 <=Int memorySize
+ ensures wellFormed(MEM[I <- V])
+```
+
+**Proof**: Automatically verified by K prover.
+
+**Guarantee**: ALL memory stores are safe.
+
+## The Cost of NOT Verifying
+
+### Financial
+
+- **Parity wallet bug** (2017): $150M lost
+- **DAO hack** (2016): $50M stolen
+- **Heartbleed** (2014): Affected millions
+
+### Reputation
+
+- Loss of user trust
+- Bad press
+- Competitive disadvantage
+
+### Legal
+
+- Liability for data breaches
+- Regulatory penalties
+- Lawsuits from affected users
+
+## Verification Workflow
+
+1. **Write Code**: Normal development
+2. **Define Specification**: What should code do?
+3. **Run Verifier**: Automated proof search
+4. **Fix Bugs**: Address counterexamples
+5. **Get Proof**: Mathematical guarantee
+
+Time investment: Hours to days
+Benefit: Lifetime of correctness
+
+## Limitations
+
+### What Verification DOESN'T Guarantee
+
+- **Performance**: Code may be slow
+- **Usability**: Interface may be confusing
+- **Business logic**: May not match requirements
+- **Hardware bugs**: CPU vulnerabilities remain
+
+### Verification is NOT
+
+- A replacement for testing
+- Proof of fitness for purpose
+- A silver bullet
+
+Verification complements other practices.
+
+## Getting Started
+
+1. **Learn K Framework**: [K Framework Primer](01_k_framework_primer.md)
+2. **Study Examples**: [Hello WebAssembly](../02_interactive_tutorials/hello_wasm_semantics/)
+3. **Try Verification**: [Memory Safety Case Study](../04_verification_case_studies/memory_safety/)
+4. **Build Proofs**: [Verification Sandbox](../06_interactive_playground/verification_sandbox/)
+
+## Further Reading
+
+### Academic Papers
+- "A Mechanised Specification of WebAssembly" (Watt et al., 2018)
+- "Bringing the Web Up to Speed with WebAssembly" (Haas et al., 2017)
+- "Verifying WebAssembly" (Rao et al., 2020)
+
+### Books
+- "Formal Methods" by Hinchey & Bowen
+- "Software Foundations" (Coq-based)
+- "Certified Programming with Dependent Types" by Chlipala
+
+### Tools
+- [KWasm](https://github.com/runtimeverification/wasm-semantics)
+- [WasmCert](https://github.com/WasmCert/WasmCert)
+- [Cranelift verification](https://github.com/bytecodealliance/wasmtime/tree/main/cranelift/isle/veri)
+
+## Conclusion
+
+Formal verification of WebAssembly:
+- **Prevents** critical security bugs
+- **Ensures** correctness guarantees
+- **Builds** trust in systems
+- **Enables** safe optimization
+
+The question is not "Can we afford to verify?" but **"Can we afford NOT to?"**
+
+---
+
+