Add verified Connect Four with alpha-beta AI#5
Open
CharlesCNorton wants to merge 4 commits intobloomberg:pruningfrom
Open
Add verified Connect Four with alpha-beta AI#5CharlesCNorton wants to merge 4 commits intobloomberg:pruningfrom
CharlesCNorton wants to merge 4 commits intobloomberg:pruningfrom
Conversation
920de29 to
df048bc
Compare
- 7x6 Connect Four with alpha-beta AI, threat detection, certificates - Lazy cotree alpha-beta with equivalence proof to minimax - PArray-backed certificate checker for DAG-compressed winning strategy - Soundness proof: check_packed = true -> check_cert (decode) = true -> red_wins - All proofs complete, no Admitted. Compiles clean on Rocq 9.0. - Certificate data and final red_wins theorem still to come.
df048bc to
9c2abcb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Formalizes Connect Four as a two-player game over a 7×6 board with gravity, following the same patterns as TicTacToe.v. The complete game tree (~4.5 trillion nodes) is defined via well-founded recursion on empty slots, proving finiteness. Execution uses depth-limited cotree search with alpha-beta pruning from AlphaBeta.v.
Game model
list player(bottom-to-top), gravity = appendfilterover columns with height < 6; game halts on win/drawVerified properties
all_lines_soundall_linesis geometrically validall_lines_completeall_linesall_lines_NoDuphas_won_correcthas_won b p = trueiff ∃ a valid winning line with all four cells occupied bypvalid_movesmoves gsatisfiesvalid_movemoves_completevalid_moveappears inmoves gvalid_board_apply_movecomplete_tree_soundcomplete_tree_completeat_most_one_winnerc4_eval_ab_correcteval_ab_correctinstantiation)ai_subtree_reachableExecution
Cotrees.unfold_cotree+tree_of_cotree, rebuilt from current position each AI turneval_ab players_le_ge, picks optimal moveprint_board,read_line, column input (1–7)make c4runs the gameLibrary reuse
tree,unfold_tree,In_tree,root,childrenunfold_cotree,tree_of_cotree,colist_of_listeval_ab,players_le_gemax,comparingIO,SimpleIO, extraction setupTest plan
makecompiles all files including ConnectFour.v (Rocq 9.0)connectfour.ml;make c4runs the interactive game