Comments (4)
A trick I learned from @digama0 is to liberally apply Array → List
transfer theorems which reduce problems about Array
s to problems about List
s. For example foldl_eq_foldl_data
. This works very well because functions on Lists
usually have a simple inductive structure whereas functions on Array
s tend not to (using indexed accesses and so on), so the List
-based proofs are often simpler. So from this perspective, it is actually better not to have those lemmas and rather encourage applying transfer whenever possible. The lemmas that are still necessary are those for when you really need to reason about something involving indices. For example, foldl_induction
.
from std4.
There may be other ones, but some of the remaining incongruities between the List
and Array
interfaces:
List | Array | notes |
---|---|---|
List.replicate | Array.mkArray | Mathlib also defines List.repeat |
List.modifyNth | Array.modify | |
List.insertNth | Array.insertAt(!) | These have sort of a confusing relationship |
List.length | Array.size | This seems purposeful, but it may be helpful to document it |
List.splitOn/List.splitAt | Array.split | They're different, so I guess the goal is to have splitOn , splitAt and split for both types? |
It may be helpful to document the difference (if any) between functions like .elem
/.contains
and Array.modify
/Array.modifyOp
as well.
@digama0 if at some point you decide any changes are appropriate, let me know if I can help.
from std4.
I am doing some "practical program" proving with lean4, and I have found the following lemma really helpful
lemma Array.data_injective : Function.Injective (Array.data (α:=α)) := by sorry
If I want to prove some equality of arrays, I use apply Array.data_injective; simp
which works pretty well.
However, it still feels like something is missing, because if I have some List
subexpression in my goal, simp
will simplify it away no problem, but if I have some Array
subexpression, it won't.
I need to manually use this technique on each Array
subexpression to get it to simplify. It feels like this could probably be automated some way?
from std4.
lemma Array.data_injective : Function.Injective (Array.data (α:=α)) := by sorry
That is Array.ext'
already defined in the prelude.
from std4.
Related Issues (20)
- Missing release tag for v4.3.0-rc2 HOT 1
- Document std4#232
- After import Std, the behavior of HMod.hMod of Int changed without warning. HOT 5
- Update stable branch to v4.3.0 HOT 1
- Int.ofNat_natAbs_eq_of_nonneg and Int.natAbs_of_nonneg seem duplicates HOT 2
- bug: MVarId.isIndependentOf doesn't check local context.
- False positive from the unusedHavesSuffices linter HOT 5
- Array.minX functions are buggy HOT 4
- Usage examples for HashMap.lean HOT 2
- Fixed width signed integer datatypes. HOT 2
- `omega` doesn't understand `n ≠ 0` HOT 2
- `omega` only wants constants on one side.
- `omega` does not support powers. HOT 2
- `omega` has issues with `mdata` handling HOT 1
- `omega` fails when an extra divisibility hypothesis is added HOT 1
- Add docker / gitpod integrations HOT 2
- Bugs in `ext` tactic HOT 2
- simpNF complains if LHS contains higher-order function
- Missing lemma about `Sum.elim` HOT 6
- Installation instruction confusion HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from std4.