Skip to content

Commit

Permalink
a helper to aid in induction on boards
Browse files Browse the repository at this point in the history
  • Loading branch information
dianne committed Jan 13, 2019
1 parent eab3e42 commit 63eab71
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Minesweeper/Moves.agda
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ open import Relation.Binary.Construct.Closure.Reflexive as Refl renaming (Refl t
open import Induction
open import Induction.WellFounded as WF
open import Induction.Nat using (<-wellFounded)
open import Function

open import Minesweeper.Coords
open import Minesweeper.Coords as Coords
open import Minesweeper.Board
open import Minesweeper.Rules

Expand Down Expand Up @@ -147,3 +148,18 @@ module _ {ℓ bounds} where
open WF.All (>-wellFounded {bounds}) ℓ public
renaming ( wfRecBuilder to >-recBuilder
; wfRec to >-rec )

-- in order to use this, a helper: filling in an unknown tile results in a more specific board
fill-> : {bounds} coords (grid : Board Tile bounds) tile lookup coords grid ≡ unknown
(grid [ coords ]≔ known tile) > grid
fill-> coords grid tile coords↦unknown = record
{ >⇒≥ = fill-≥
; >-strict = coords , fill-≻ }
where
fill-≻ : lookup coords (grid [ coords ]≔ known tile) ≻ lookup coords grid
fill-≻ rewrite lookup∘update coords grid (known tile) | coords↦unknown = known≻unknown

fill-≥ : (grid [ coords ]≔ known tile) ≥ grid
fill-≥ coords′ with coords Coords.≟ coords′
... | yes refl = [ fill-≻ ]
... | no coords≢coords′ rewrite lookup∘update′ (coords≢coords′ ∘ sym) grid (known tile) = refl

0 comments on commit 63eab71

Please sign in to comment.