Commit graph

109 commits

Author SHA1 Message Date
Leonardo de Moura
041827bed5 chore: unused variables 2022-06-07 17:54:10 -07:00
Sebastian Ullrich
ae7b895f7a refactor: unname some unused variables 2022-06-07 16:37:45 -07:00
Leonardo de Moura
de2e2447d2 chore: style 2022-04-07 17:35:05 -07:00
Leonardo de Moura
cfb4e306f7 refactor: replace length_dropLast theorem 2022-04-01 16:44:24 -07:00
zygi
ac793ce196 fix: forward start and stop in Array.allM 2022-03-17 10:08:40 +01:00
Sebastian Ullrich
82c682d385 chore: remove redundant proof 2022-03-12 11:12:56 +01:00
Leonardo de Moura
5845002e8c feat: use WF at anyM 2022-03-03 16:43:05 -08:00
Leonardo de Moura
02d7cedba8 chore: remove unnecessary termination_by annotations 2022-03-03 11:24:06 -08:00
Leonardo de Moura
19bcb5fb31 feat: add Array.popWhile and Array.takeWhile 2022-02-19 07:04:52 -08:00
Sebastian Ullrich
54522006f4 refactor: List.get: take Fin to align with Array.get
/cc @leodemoura
2022-02-15 18:41:22 +01:00
Leonardo de Moura
1d5da63482 chore: simplify Array.isEqvAux 2022-02-10 16:51:47 -08:00
Leonardo de Moura
12e2a79170 chore: fix codebase after removing auto pure 2022-02-03 18:08:14 -08:00
Gabriel Ebner
561a869e49 fix: provide reference implementation for Array.modify 2022-01-17 12:41:12 -08:00
Leonardo de Moura
bac91b9b5b chore: remove arbitrary 2022-01-15 12:14:27 -08:00
Leonardo de Moura
acd482c5f2 feat: define Array.modify without using Inhabited 2022-01-14 19:47:42 -08:00
Leonardo de Moura
7fe6881c42 feat: use new termination_by syntax 2022-01-12 16:23:25 -08:00
Leonardo de Moura
381f66428a chore: use termination_by'
We are going to define a higher level syntax for `termination_by`.
2022-01-11 15:00:53 -08:00
Leonardo de Moura
dae3489fe2 feat: remove partials from Init/Data/Array/Basic.lean 2022-01-10 16:05:33 -08:00
Leonardo de Moura
68bd55af32 chore: fix codebase 2021-12-10 13:12:09 -08:00
Leonardo de Moura
2fd024c26f feat: add support for foldlM, foldl, ForIn instances for byte/float arrays 2021-10-18 16:54:56 -07:00
Leonardo de Moura
7066619123 refactor: define Nat.le using inductive type 2021-08-20 19:39:45 -07:00
Leonardo de Moura
9cc94296e5 chore: remove staging workaround theorems 2021-08-07 12:52:31 -07:00
Leonardo de Moura
a821dcbff2 chore: enforce naming convention for theorems
see issue #402

fix: `ElabTerm.lean`
2021-08-07 12:48:38 -07:00
Wojciech Nawrocki
a937fa26ba chore: fewer explicit types 2021-08-01 09:58:44 +02:00
Wojciech Nawrocki
f51b80060d feat: generic tagged Format 2021-08-01 09:58:44 +02:00
Leonardo de Moura
f4a7ffd8c8 chore: fix codebase and tests 2021-06-29 17:14:52 -07:00
Sebastian Ullrich
a02c6fd3eb chore: adapt stdlib & tests 2021-05-20 15:17:36 -07:00
Sebastian Ullrich
7c3101a51c chore: produce more efficient/pp-able array code from quotations 2021-05-19 09:52:35 +02:00
Leonardo de Moura
157ef80c5a feat: match auto generalization 2021-04-16 21:48:38 -07:00
Leonardo de Moura
3176be136c feat: improve "discriminant refinement" 2021-03-24 21:05:08 -07:00
Leonardo de Moura
0720a53a9d chore: refactoring and cleanup 2021-03-17 14:56:08 -07:00
Leonardo de Moura
9f88ea8047 chore: remove old decide!, nativeRefl!, and nativeDecide! 2021-03-11 08:06:20 -08:00
Leonardo de Moura
b9ef6f89a4 chore: cleanup 2021-02-26 19:34:39 -08:00
Leonardo de Moura
d1009e8405 chore: add simp lemmas, theorem naming convention 2021-02-16 11:53:49 -08:00
Leonardo de Moura
d0ffecd419 chore: consistency
Make sure `Array.all` and `Array.any` parameter order is similar to
`List.all` and `List.any`.
2021-02-04 20:39:28 -08:00
Leonardo de Moura
aae8a35150 feat: add ForIn type class 2021-02-04 17:59:44 -08:00
Leonardo de Moura
d956f0ae9f feat: use destructTuple to compile for in notation instead of pattern matchin 2021-02-04 17:17:51 -08:00
Sebastian Ullrich
446f953461 feat: allow hygienic capture of section variables in quotations 2021-01-24 11:46:04 -08:00
Sebastian Ullrich
0c91b3769e chore: replace variables in src/ 2021-01-22 14:36:05 +01:00
Leonardo de Moura
5f6e66a53f refactor: Repr
Modifications:
- Result type is `Format`
- It takes the context precedence like Haskell `Show`
2020-12-18 11:21:30 -08:00
Leonardo de Moura
04a07c15b9 chore: use deriving Inhabited 2020-12-13 11:57:59 -08:00
Sebastian Ullrich
554d0b4d4c chore: adapt stdlib to new antiquotation splices 2020-12-12 17:20:03 +01:00
Sebastian Ullrich
f4267c9bf8 chore: revise Syntax.Traverser changes 2020-12-09 10:38:22 +01:00
Leonardo de Moura
702c258773 fix: index out of bounds
@Kha Please take a look at `Traverser` and check whether the
workaround is appropriate or not.
2020-12-08 11:44:10 -08:00
Leonardo de Moura
2120883307 refactor: heterogeneous operators
@Kha I had some unexpected surprises, but it is a good change.
Here is the summary.

1- We could get rid of `a %ₙ b` and `ModN` class. We can use `HMod`
instead. It was a positive surprise since I didn't remember we had
this `ModN` class.

2- Coercions are never used in heterogeneous operators. This is
expected since `a * b` is now notation for `HMul.hMul a b`, and
`a` and `b` may have different types. I manually added instances such
as `HMul Nat Int Int`. However, I did not try to add generic instances
such as
```
instance [Coe a b] [Mul b] : HMul a b b where
  hMul x y := mul (coe x) y
```
I will try later.

3- Give `h : cs.size > 0`, I got a type error at
```
let idx : Fin cs.size := ⟨cs.size - 1, Nat.predLt h⟩
```
`Nat.predLt h` has type `Nat.pred cs.size < cs.size`
However, `Nat.pred cs.size` doesn't unify with `cs.size - 1`.
The problem is that we can't synthesize the `HSub` instance until
we apply the default instances.
It worked before because `isDefEq` would force the pending TC
problem `Sub Nat` to be resolved, and after that we would be able
to reduce `cs.size - 1` and establish that it is definitionally
equal to `Nat.pred cs.size`.
I considered two possible workarounds
a) `let idx : Fin cs.size := ⟨cs.size - (1:Nat), Nat.predLt h⟩`
b) `let idx : Fin cs.size := ⟨cs.size - 1, by exact Nat.predLt h⟩`
The first one works because we are not providing enough information
for synthesizing the `HSub` instance. The second works because it
postpones the elaboration of `Nat.predLt h`. The default instances
will be applied before we start applying tactics.

4- The `.` notation is affected too. For example, `(x + 1).toUInt8`
doesn't work since we don't know the type of `x+1` until we apply
default instances. I fixed it by using `(x + (1:Nat)).toUInt8`.
Another possible fix is `Nat.toUInt8 (x + 1)`.
Similarly, `(x+1).fold ...` doesn't work.

5- The following code failed to be elaborated
```
indent (push s!"{ss'}\n") (some (0 - Format.getIndent (← getOptions)))
```
It was working before, but it relied on how the expected type is
propagated. The elaborator process
```
some (0 - Format.getIndent (← getOptions))
```
with expected type `(Option Int)`. So, the `-` is interpreted as
`Int.sub` although `Format.getIndent (← getOptions)` has type `Nat`.
In the new `HSub`, the expected type doesn't really influence TC
resolution since it is an `outparam`. So, we failed with the error
failed to synthesize `HSub Nat Nat Int`.
One possible fix was to add the instance `HSub Nat Nat Int` with
`Int.sub`, but I used the following fix
```
some ((0 : Int) - Format.getIndent (← getOptions))
```
which makes it clear that we want the `Int.sub` operator instead of
`Nat.sub`.
2020-12-01 14:02:46 -08:00
Leonardo de Moura
d734a2605b chore: adjust stdlib 2020-11-29 17:01:56 -08:00
Leonardo de Moura
9023e93b3e refactor: move Array.set to Prelude 2020-11-25 11:02:25 -08:00
Leonardo de Moura
d6f778bec4 refactor: arbitrary without explicit arguments
@Kha I was tired of writing `arbitrary _` :)
There 0 places in the stdlib where the type needs to be provided.
If in the future we need to specify the type we can use
`arbitrary (α := <type>)`
2020-11-25 09:07:38 -08:00
Leonardo de Moura
b72a3c69b6 fix: ambiguity at induction/cases
See efc3a320fe
2020-11-24 14:59:12 -08:00
Leonardo de Moura
29303f17f3 chore: test unboundImplicitLocals 2020-11-22 09:48:15 -08:00