Commit graph

58 commits

Author SHA1 Message Date
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
Leonardo de Moura
3b6d65c3c3 chore: use deriving Inhabited 2020-12-13 10:09:20 -08:00
Leonardo de Moura
baabfc13e0 chore: remove occurrences of Append.append 2020-12-01 15:44:03 -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
a7563a0ec2 feat: forIn for RBTree and RBMap 2020-11-30 16:42:47 -08:00
Leonardo de Moura
d734a2605b chore: adjust stdlib 2020-11-29 17:01:56 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
6f0919f08d chore: fix places that require erewrite 2020-11-25 11:02:26 -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
cb9574b086 chore: test unboundImplicitLocals and cleanup 2020-11-22 10:33:28 -08:00
Leonardo de Moura
c9cbe35916 fix: adjust code to optional , at structure instances
@Kha I implemented the optional `,` at structure instances.
You have suggested it a few weeks/months ago. F# also implements this
feature. I got back to it while write documentation for Lean.
It looks quite nice when we are packing many functions into a structure.

BTW, F# also has optional separators for list literals :)
This is a much simpler change for us since `[...]` is defined using
the `syntax/macro_rules` commands, but I didn't find optional ','
would very useful since our list literals are usually in a single
line.
2020-11-20 15:43:35 -08:00
Leonardo de Moura
c305c2691f chore: use := 2020-11-19 07:22:31 -08:00
Leonardo de Moura
7e533b4650 refactor: use Lists for Array reference implementation
Motivation: better reduction in the kernel.

cc @Kha
2020-11-17 17:05:53 -08:00
Leonardo de Moura
ffc4abed32 fix: UInt* and USize Inhabited instances 2020-11-13 16:30:48 -08:00
Leonardo de Moura
c665d5e20a chore: cleanup 2020-11-10 15:40:00 -08:00
Leonardo de Moura
2d2d39c78e chore: use mut 2020-11-07 17:32:13 -08:00
Leonardo de Moura
81d6e065e7 chore: adjust files and tests 2020-11-07 17:32:12 -08:00
Leonardo de Moura
0f3bd8abb4 feat: add rfl and decide! tactic macros 2020-10-29 16:42:22 -07:00
Leonardo de Moura
63a5baafac chore: cleanup 2020-10-28 22:03:50 -07:00
Leonardo de Moura
4ba21ea10c chore: cleanup src/Array/Basic.lean 2020-10-28 19:35:42 -07:00
Leonardo de Moura
898a08a0c1 chore: avoid Has prefix in type classes
closes #203
2020-10-27 18:29:19 -07:00
Leonardo de Moura
5fed774461 chore: HasRepr ==> Repr 2020-10-27 16:15:10 -07:00
Leonardo de Moura
10c32fcf94 chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
1d338c4fc4 chore: move Core.lean to new frontend 2020-10-25 08:54:37 -07:00
Leonardo de Moura
70bf755938 chore: cleanup 2020-10-24 14:15:56 -07:00
Leonardo de Moura
a5a153d1fb refactor: remove foldlFrom from PersistentArray and LocalContext 2020-10-22 16:30:05 -07:00
Leonardo de Moura
43fbfec1fd chore: avoid Array.iterate and Array.iterateM 2020-10-22 16:30:04 -07:00
Leonardo de Moura
93f7b1d7bc chore: move to new frontend 2020-10-20 16:13:07 -07:00
Leonardo de Moura
6d122eda49 chore: move to new frontend 2020-10-20 15:34:45 -07:00
Leonardo de Moura
1a5e2fd0f0 chore: move to new frontend 2020-10-20 13:34:01 -07:00
Leonardo de Moura
b98fa56419 chore: add workaround to control IR size
@Kha
the new dependent pattern matching compiler assumes the eager inlining
at `csimp` will be fixed. Each alternative should produce a
joinpoint, but `csimp` is currently inlining all of them.
Without this workaround the .C file is 30K lines bigger.
2020-10-20 13:28:31 -07:00
Leonardo de Moura
d4872f5cb7 chore: move to new frontend 2020-10-20 12:50:17 -07:00
Leonardo de Moura
fac2849e50 feat: forIn for PersistentArray 2020-10-20 09:33:50 -07:00
Leonardo de Moura
7fa43216f5 chore: argument name 2020-10-18 16:19:44 -07:00
Leonardo de Moura
e667c9e519 chore: move to new frontend 2020-10-18 09:47:42 -07:00
Leonardo de Moura
1ce2cde099 chore: move to new frontend 2020-10-17 14:01:25 -07:00
Leonardo de Moura
e02a06ad1c chore: move to new frontend 2020-10-16 08:40:42 -07:00
Leonardo de Moura
ca0b11137a chore: add ShareCommonM.run, and remove workaround 2020-10-13 09:29:10 -07:00
Leonardo de Moura
98f7e9b3e4 chore: naming convention 2020-09-24 19:22:24 -07:00
Leonardo de Moura
9c8f57f322 fix: preserve info messages from candidates that failed to be elaborated
@Kha Not sure whether we should have an option for supressing this
information or not.
We need this information for diagnosing problems. For example, I was trying to
understand why the elaborator was looping. I suspected it was the
TC module, but I was not getting any trace messages since the symbol
was overloaded, and the case that did not work was the expensive one :(
2020-09-17 17:08:14 -07:00
Leonardo de Moura
b025c1c623 chore: remove HasEmptyc workarounds 2020-09-11 14:28:42 -07:00
Leonardo de Moura
ed976027fe chore: naming convention 2020-08-26 20:24:33 -07:00
Leonardo de Moura
6be71b337f refactor: add prototype2.lean 2020-08-04 18:35:11 -07:00
Leonardo de Moura
943446f1b3 fix: FVarSubst must be a mapping from FVarId to Expr
Reason: `subst` tactic must store the `x |-> e` when substituting `x`
with `e`.
2020-08-04 13:06:08 -07:00
Leonardo de Moura
b291c36a1f chore: cleanup 2020-06-25 13:30:47 -07:00
Leonardo de Moura
cbb14673ef chore: move RBTree and RBMap to Std 2020-06-25 13:26:16 -07:00
Leonardo de Moura
11ed7c6195 chore: move PersistentArray to Std 2020-06-25 13:02:21 -07:00