Commit graph

285 commits

Author SHA1 Message Date
Kim Morrison
5d2bd1e2e4
chore: deprecate Array.split in favour of identical Array.partition (#5970) 2024-11-06 00:37:33 +00:00
Kim Morrison
128b049904
feat: relate Array.eraseIdx with List.eraseIdx (#5952) 2024-11-05 06:13:29 +00:00
Kim Morrison
0e3f26e6df
feat: relate Array.takeWhile with List.takeWhile (#5950) 2024-11-05 05:05:53 +00:00
Kim Morrison
c779f3a039
feat: List.mapFinIdx, lemmas, relate to Array version (#5941) 2024-11-04 05:29:41 +00:00
Kim Morrison
fc17468f78
chore: upstream List.ofFn and relate to Array.ofFn (#5938) 2024-11-04 01:35:29 +00:00
Kyle Miller
b75cc35db2
feat: update omega/solve_by_elim to use new tactic syntax, use new tactic syntax (#5932)
Following up #5928, updates the syntax for `omega` and `solve_by_elim`
and restores the syntax quotations in their implementations.

Following up #5898, uses the new tactic syntax in the library, replacing
all uses of `(config := ...)`.
2024-11-03 16:23:37 +00:00
Kim Morrison
6922832327
chore: minor tweaks to Array lemmas (#5912) 2024-11-01 02:20:16 +00:00
Kim Morrison
218601009b
chore: rename Array.back to back! (#5897) 2024-10-31 09:18:18 +00:00
Kim Morrison
4af93813f2
chore: move @[simp] from back_eq_back? to back_push (#5896) 2024-10-31 08:25:19 +00:00
Kim Morrison
34be25620f
feat: LawfulBEq (Array α) ↔ LawfulBEq α (#5895) 2024-10-31 08:00:06 +00:00
Kim Morrison
a826de8a3d
chore: remove duplicated ForIn instances (#5892)
I'd previously added an instance from `ForIn'` to `ForIn`, but this then
caused some non-defeq duplication. It seems fine to just remove the
concrete `ForIn` instances in cases where the `ForIn'` instance exists
too. We can even remove a number of type-specific lemmas in favour of
the general ones.
2024-10-31 07:40:09 +00:00
Joachim Breitner
8f0328b777
fix: deprecations in Init.Data.Array.Basic (#5848) 2024-10-26 10:33:47 +00:00
Kim Morrison
07ea626560
feat: Array.forIn', and relate to List (#5833)
Adds support for `for h : x in my_array do`, and relates this to the
existing `List` version.
2024-10-25 07:24:39 +00:00
Kim Morrison
059674d967
chore: minor fixes in Array lemmas (#5832) 2024-10-25 04:28:41 +00:00
Kim Morrison
07c09ee579
feat: relate Array.forIn and List.forIn (#5799) 2024-10-22 01:20:13 +00:00
Kim Morrison
919f64b2e6
chore: upstream List.modify, add lemmas, relate to Array.modify (#5798)
Note that the order of arguments still differs between `List.modify` and
`Array.modify`. I'll settle this later.
2024-10-22 01:01:32 +00:00
Kim Morrison
71122696a1
feat: rename Array.shrink to take, and relate to List.take (#5796) 2024-10-21 23:35:32 +00:00
Kim Morrison
51377afd6c
feat: simp lemmas for Array.isEqv and beq (#5786)
- [ ] depends on: #5785
2024-10-21 07:37:40 +00:00
Kim Morrison
8151ac79d6
chore: Array cleanup (#5782)
More cleanup of Array API. More to come.
2024-10-21 06:00:37 +00:00
Kim Morrison
5d155d8b02
chore: simplify signature of Array.mapIdx (#5749)
This PR simplifies the signature of `Array.mapIdx`, to take a function
`f : Nat \to \a \to \b` rather than a function `f : Fin as.size \to \a
\to \b`.

Lean doesn't actually use the extra generality anywhere (so in fact this
change *simplifies* all the call sites of `Array.mapIdx`, since we no
longer need to throw away the proof).

This change would make the function signature equivalent to
`List.mapIdx`, hence making it easier to write verification lemmas.

We keep the original behaviour as `Array.mapFinIdx`.
2024-10-21 05:48:42 +00:00
Kim Morrison
a6243f6076
chore: deprecation for Array.data (#5687) 2024-10-18 03:16:38 +00:00
Kim Morrison
51ab162a5a
chore: upstream Array.reduceOption (#5758) 2024-10-18 00:41:09 +00:00
Kim Morrison
3a34a8e0d1
chore: move Array.mapIdx lemmas to new file (#5748) 2024-10-17 05:54:25 +00:00
Kim Morrison
69e8cd3d8a
chore: cleanup in Array/Lemmas (#5744) 2024-10-17 03:36:26 +00:00
Kim Morrison
ef05bdc449
chore: rename List.bind and Array.concatMap to flatMap (#5731) 2024-10-16 11:30:49 +00:00
Henrik Böving
19e06acc65
refactor: redefine unsigned fixed width integers in terms of BitVec (#5323)
I made a few choices so far that can probably be discussed:
- got rid of `modn` on `UInt`, nobody seems to use it apart from the
definition of `shift` which can use normal `mod`
- removed the previous defeq optimized definition of `USize.size` in
favor for a normal one. The motivation was to allow `OfNat` to work
which doesn't seem to be necessary anymore afaict.
- Minimized uses of `.val`, should we maybe mark it deprecated?
- Mostly got rid of `.val` in basically all theorems as the proper next
level of API would now be `.toBitVec`. We could probably re-prove them
but it would be more annoying given the change of definition.
- Did not yet redefine `log2` in terms of `BitVec` as this would require
a `log2` in `BitVec` as well, do we want this?
- I added a couple of theorems around the relation of `<` on `UInt` and
`Nat`. These were previously not needed because defeq was used all over
the place to save us. I did not yet generalize these to all types as I
wasn't sure if they are the appropriate lemma that we want to have.
2024-10-16 07:28:23 +00:00
Kim Morrison
0bfe1a8c1a
chore: better default value for Array.swapAt! (#5705) 2024-10-15 01:18:51 +00:00
Kim Morrison
aa2360a41d chore: rename List.join to List.flatten
one more

one more

one more

fix test
2024-10-14 22:28:12 +11:00
Henrik Böving
53c5470200
perf: remove List.redLength (#5605) 2024-10-03 14:57:33 +00:00
Kim Morrison
a4fda010f3
feat: Array/Option.unattach (#5586)
More support for automatically removing `.attach`, for `Array` and
`Option`.
2024-10-03 07:29:00 +00:00
Kim Morrison
6cd80c28b7
chore: add missing simp to Array.size_feraseIdx (#5577) 2024-10-02 01:07:54 +00:00
Kim Morrison
f202469c8a
chore: upstream Array.flatten lemmas (#5551)
Just the upstreaming part of #5535 while we wait on a naming decision.
2024-10-02 00:54:30 +00:00
Kim Morrison
5e8718dff9
chore: fix Array.modify lemmas (#5536)
Generally works best to pick up the proofs by unification with the lhs.

pinging @hargoniX as this goes by, as it changes some proofs in
bv_decide (nothing interesting, just a bit simpler)
2024-09-30 06:31:10 +00:00
Kim Morrison
4f2c4c7bd1
chore: cleanup of Array GetElem lemmas (#5534) 2024-09-30 05:42:53 +00:00
Kim Morrison
36c29bee31
chore: fix name of Array.length_toList (#5526) 2024-09-30 04:08:56 +00:00
Kim Morrison
a4dfa83af5
chore: reduce use of deprecated lemmas in Array (#5527) 2024-09-30 02:59:15 +00:00
Kim Morrison
40e97bd566
chore: upstream Subarray.empty (#5516) 2024-09-29 05:53:12 +00:00
Kim Morrison
3bd01de384
feat: upstream Array.qsortOrd (#5515) 2024-09-29 05:50:25 +00:00
Kim Morrison
8835ab46ad
feat: Array.eraseReps (#5514)
Just an `Array` version of `List.eraseReps`. These functions are for now
outside of scope for verification, so there's just a simple `example` in
the tests.
2024-09-29 05:44:14 +00:00
Kim Morrison
c38c07e1a1
chore: reverse simp direction for toArray_concat (#5485)
This is mistakenly pushing a `toArray` inwards rather than outwards.
2024-09-27 01:24:12 +00:00
Kim Morrison
5dea30f169
feat: @[simp] lemmas about List.toArray (#5472)
We make sure that we can pull `List.toArray` out through all operations
(well, for now "most" rather than "all"). As we also push `Array.toList`
inwards, this hopefully has the effect of them cancelling as they meet,
and `simp` naturally rewriting Array operations into List operations
wherever possible.

This is not at all complete yet.
2024-09-26 00:59:13 +00:00
Kim Morrison
c2f6297554
feat: adjust simp attributes on monad lemmas (#5464) 2024-09-25 10:21:18 +00:00
Kim Morrison
145c9efb32
feat: Array.foldX lemmas (#5466) 2024-09-25 07:17:19 +00:00
Kim Morrison
e4f2de0a53
feat: improve Array GetElem lemmas (#5465)
This should be tested against Mathlib, but there are conflicts with the
`nightly-with-mathlib` branch right now, so I'll wait until tomorrow.
2024-09-25 07:17:13 +00:00
Kim Morrison
974cc3306c
chore: restore @[simp] on Array.swapAt!_def (#5461) 2024-09-25 01:33:53 +00:00
Kim Morrison
65f4b92505
chore: cleanup of Array docstrings after refactor (#5458)
Sorry this is coming through in tiny pieces; I'm still hitting a
bootstrapping problem and getting things through piecemeal to localise
it.
2024-09-24 23:16:49 +00:00
Kim Morrison
a6f0112fc5
feat: refactor of Array (#5452)
This is a second attempt at #5446, first reverting parts of #5403.
2024-09-24 12:57:55 +00:00
Kim Morrison
e551a366a0
feat: theorems about List.toArray (#5403) 2024-09-23 05:24:03 +00:00
Kim Morrison
8c8585536c
feat: refactor DecidableEq (Array α) (#5422) 2024-09-23 03:49:03 +00:00
Kim Morrison
738435b90a
chore: make Array functions either semireducible or use structural recursion (#5420)
Previously, it was not possible to use `decide` with most Array
functions (including `==`).

Later, we may replace some of these functions with defeqs that go via
the `List` operations, and use `csimp` lemmas for fast runtime
behaviour. In the meantime, this allows using `decide`.
2024-09-23 02:41:41 +00:00