Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updates for nightly 2024-09-17 #46

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- "nightly-2024-08-09"
- "nightly-2024-08-29"
- "nightly-2024-09-03"
- "nightly-2024-09-17"
platform:
- os: ubuntu-latest
installer: |
Expand Down
4 changes: 2 additions & 2 deletions InternalTests.lean
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ elab "#evalString" s:str e:term : command => do
modify ({· with messages := msgs})

#evalString "[[\"n * 1 = n\"]]\n"
(proofEx.highlighted[0].proofStates.data.filter (·.fst == "by") |>.map (·.snd.data.map (·.conclusion)))
(proofEx.highlighted[0].proofStates.toList.filter (·.fst == "by") |>.map (·.snd.toList.map (·.conclusion)))

#evalString "[[some `zero], [some `succ], [none], [some `succ.succ], [none]]\n"
(proofEx.highlighted[0].proofStates.data.filter (·.fst == "=>") |>.map (·.snd.data.map (·.name)))
(proofEx.highlighted[0].proofStates.toList.filter (·.fst == "=>") |>.map (·.snd.toList.map (·.name)))



Expand Down
22 changes: 17 additions & 5 deletions src/highlighting/SubVerso/Highlighting/Code.lean
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,26 @@ def insert [Monad m] [MonadState (State α) m] [BEq α] [Hashable α] (x : α) :
}
pure i

partial def find [Inhabited α] [Monad m] [MonadState (State α) m] [BEq α] [Hashable α] (x : α) : m (Nat × α × Nat) := do
loop <| ← insert x
where
loop (i : Nat) : m (Nat × α × Nat) := do
match (← get).contents[i]! with
instance [h1 : Nonempty α] [h2 : Nonempty β] : Nonempty (α × β) :=
h1.elim fun x =>
h2.elim fun y =>
⟨(x, y)⟩


example [Inhabited α] [Monad m] [MonadState (State α) m] [BEq α] [Hashable α] (x : α) : Inhabited (m (Nat × α × Nat)) := inferInstance

-- Lifted from find's where block to make sure the Inhabited instance is found
partial def find.loop [Inhabited α] [Monad m] [MonadState (State α) m] (i : Nat) : m (Nat × α × Nat) := do
-- Instance needed in Lean 4.12 and onwards, where there's Nonempty but not Inhabited instances
-- for Sum
let _ : Inhabited (Nat ⊕ α × Nat) := ⟨.inl default⟩
match (← get).contents[i]?.get! with
| .inl j => loop j
| .inr (v, sz) => return (i, v, sz)

def find [Inhabited α] [Monad m] [MonadState (State α) m] [BEq α] [Hashable α] (x : α) : m (Nat × α × Nat) := do
find.loop <| ← insert x

def equate [Inhabited α] [Monad m] [MonadState (State α) m] [BEq α] [Hashable α] (x y : α) : m Unit := do
let mut x' ← find x
let mut y' ← find y
Expand Down
Loading