lean4-htt/tests
Sebastian Graf ae8dc414c3
feat: mvcgen invariants? to scaffold initial invariants (#10456)
This PR implements `mvcgen invariants?` for providing initial invariant
skeletons for the user to flesh out. When the loop body has an early
return, it will helpfully suggest `Invariant.withEarlyReturn ...` as a
skeleton.

```lean
def mySum (l : List Nat) : Nat := Id.run do
  let mut acc := 0
  for x in l do
    acc := acc + x
  return acc

/--
info: Try this:
  invariants
    · ⇓⟨xs, acc⟩ => _
-/
#guard_msgs (info) in
theorem mySum_suggest_invariant (l : List Nat) : mySum l = l.sum := by
  generalize h : mySum l = r
  apply Id.of_wp_run_eq h
  mvcgen invariants?
  all_goals admit

def nodup (l : List Int) : Bool := Id.run do
  let mut seen : HashSet Int := ∅
  for x in l do
    if x ∈ seen then
      return false
    seen := seen.insert x
  return true

/--
info: Try this:
  invariants
    · Invariant.withEarlyReturn (onReturn := fun r acc => _) (onContinue := fun xs acc => _)
-/
#guard_msgs (info) in
theorem nodup_suggest_invariant (l : List Int) : nodup l ↔ l.Nodup := by
  generalize h : nodup l = r
  apply Id.of_wp_run_eq h
  mvcgen invariants?
  all_goals admit
```
2025-09-19 14:05:24 +00:00
..
bench perf: mkNoConfusionCtors: cheaper inferType (#10455) 2025-09-19 10:51:17 +00:00
compiler fix: Unicode path support for Lean Windows executables (#10133) 2025-08-27 11:28:55 +00:00
elabissues
ir
lean feat: mvcgen invariants? to scaffold initial invariants (#10456) 2025-09-19 14:05:24 +00:00
pkg fix: check that compiler does not infer inconsistent types between modules (#10418) 2025-09-19 12:36:47 +00:00
playground feat: linear-size DecidableEq instance (#10152) 2025-09-03 06:31:49 +00:00
plugin
simpperf
.gitignore
common.sh
lakefile.toml
lean-toolchain