lean4-htt/src
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
..
bin
cmake chore: fix spelling errors (#10042) 2025-08-22 07:23:12 +00:00
include/lean feat: add array access functions that return a borrowed result (#9864) 2025-08-12 04:25:14 +00:00
Init fix: check that compiler does not infer inconsistent types between modules (#10418) 2025-09-19 12:36:47 +00:00
initialize feat: remove the old compiler (#9275) 2025-07-09 06:00:46 +00:00
kernel chore: kernel changes ahead of String redefinition (#10330) 2025-09-17 09:12:07 +00:00
lake fix: check that compiler does not infer inconsistent types between modules (#10418) 2025-09-19 12:36:47 +00:00
Lean feat: mvcgen invariants? to scaffold initial invariants (#10456) 2025-09-19 14:05:24 +00:00
library perf: implement jumping to native [export] decls in the interpreter (#10345) 2025-09-11 11:41:16 +00:00
runtime feat: add signal handling support using libuv (#9258) 2025-09-15 13:09:50 +00:00
shell feat: docstrings with Verso syntax (#10307) 2025-09-10 07:03:57 +00:00
Std feat: mvcgen invariants? to scaffold initial invariants (#10456) 2025-09-19 14:05:24 +00:00
util refactor: port more of shell.cpp to Lean (#10086) 2025-08-26 20:02:42 +00:00
cadical.mk
CMakeLists.txt chore: begin development cycle for v4.25.0 (#10402) 2025-09-16 00:25:06 +00:00
config.h.in
githash.h.in
Init.lean feat: overhaul meta system (#10362) 2025-09-17 21:04:29 +00:00
lakefile.toml.in refactor: import Lake.Util.* from Lake (#10371) 2025-09-13 13:56:54 +00:00
lean-toolchain
Lean.lean refactor: module-ize Lean (#9330) 2025-07-25 12:02:51 +00:00
lean.mk.in chore: further split libleanshared on Windows to avoid symbol limit (#10136) 2025-08-26 16:01:57 +00:00
Leanc.lean fix: Unicode path support for Lean Windows executables (#10133) 2025-08-27 11:28:55 +00:00
out feat: ac normalization in grind (#10146) 2025-08-27 03:28:30 +00:00
Std.lean chore: add module keyword to grind tests (#10036) 2025-08-21 22:02:08 +00:00
stdlib.make.in chore: further split libleanshared on Windows to avoid symbol limit (#10136) 2025-08-26 16:01:57 +00:00
stdlib_flags.h chore: remove comment from src/stdlib_flags.h (#10409) 2025-09-16 10:39:27 +00:00
version.h.in