Commit graph

40 commits

Author SHA1 Message Date
Adrien Champion
39f0fa670a
doc: document Int and its basic operations (#2167) 2023-03-28 14:54:14 +02:00
Mario Carneiro
7358df2f7e chore: remove Int.natMod 2022-11-13 14:59:26 -08:00
Gabriel Ebner
fc304d95c0 feat: Min/Max typeclasses 2022-10-21 14:36:38 -07:00
Mario Carneiro
583e023314 chore: snake-case attributes (part 2) 2022-10-19 09:28:08 -07:00
pcpthm
bc9c14a080 fix: remove duplicate OfNat Int instance 2022-08-25 11:57:13 -07:00
Mario Carneiro
f6211b1a74
chore: convert doc/mod comments from /- to /--//-! (#1354) 2022-07-22 12:05:31 -07:00
François G. Dorais
bc206b2992 fix: LawfulBEq class
make arguments implicit and protect `LawfulBEq.rfl`
2022-06-16 15:33:32 -07:00
Sebastian Ullrich
ae7b895f7a refactor: unname some unused variables 2022-06-07 16:37:45 -07:00
Leonardo de Moura
bb3fc358c9 feat: add LawfulBEq Int instance 2022-04-20 14:52:41 -07:00
Leonardo de Moura
f9fa24435d chore: remove problematic instance hasOfNatOfCoe
See #403
See https://github.com/leanprover-community/mathport/issues/94
2022-01-20 14:47:25 -08:00
François G. Dorais
29dc5c5b1b fix: duplicate namespace prefix 2021-05-31 13:31:57 +02:00
Leonardo de Moura
3a80e87793 chore: #405 step 1 2021-04-22 20:03:48 -07:00
Leonardo de Moura
5f704b6b6f chore: fix option name 2021-01-26 18:30:46 -08:00
Leonardo de Moura
d408c835d2 fix: defaultInstance priorities for Neg Int and OfScientific Float 2021-01-25 13:21:07 -08:00
Leonardo de Moura
40bfafdadb refactor: dependencies 2020-12-18 11:21:30 -08:00
Leonardo de Moura
5b588b5984 fix: defaultInstance priorities 2020-12-16 06:52:55 -08:00
Leonardo de Moura
42a28261fd chore: temporarily use 100000 as priority 2020-12-15 20:21:27 -08:00
Leonardo de Moura
ebf4a8877e chore: mark Neg Int as a default instance 2020-12-08 10:09:58 -08:00
Leonardo de Moura
e31b17484a feat: add instances from coe + homogeneous operator to heterogeneous operator
@Kha The new `rational.lean` test shows their usefulness. We just
define the monorphic version and a coercion, and get a bunch of `HAdd`
instances for free.
2020-12-01 15:30: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
1e84fa1eed refactor: more general OfNat, remove One and Zero classes 2020-12-01 07:49:52 -08:00
Leonardo de Moura
0869f38de4 chore: update structure, class, inductive 2020-11-27 15:09:30 -08:00
Leonardo de Moura
304c80d610 feat: use <| 2020-11-19 09:03:38 -08:00
Leonardo de Moura
c305c2691f chore: use := 2020-11-19 07:22:31 -08:00
Leonardo de Moura
2daeb195b5 chore: use new names 2020-11-10 10:15:19 -08: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
3941b55bb8 chore: remove old HasCoe 2020-10-24 16:22:52 -07:00
Leonardo de Moura
8bc90bc48d chore: move to new frontend 2020-10-23 11:19:50 -07:00
Leonardo de Moura
e3e89b4945 chore: add coercion for new frontend 2020-10-16 15:39:00 -07:00
Leonardo de Moura
749e2063cf feat: add interpolated string for toString 2020-10-09 14:38:24 -07:00
Sebastian Ullrich
8630d78b3f fix: Int.add spec 2020-08-24 13:55:14 +02:00
Leonardo de Moura
41949ee801 refactor: String.toNat ==> String.toNat? and String.toNat! 2020-03-23 14:29:48 -07:00
Leonardo de Moura
7809274c3a chore: Coe.lean ==> HasCoe.lean 2020-01-28 08:55:22 -08:00
Leonardo de Moura
b8257f2317 feat: add HasOfNat
It is used to encode numerical literals in the new frontend.
2019-12-16 10:28:28 -08:00
Leonardo de Moura
2809cea147 chore: remove DecidableEq workaround
We have better indexing now.
2019-11-26 17:30:18 -08:00
Leonardo de Moura
c445199747 chore: library/Init ==> src/Init
cc @Kha @dselsam @cipher1024
2019-11-22 06:06:05 -08:00
Renamed from library/Init/Data/Int/Basic.lean (Browse further)