Commit graph

1792 commits

Author SHA1 Message Date
Leonardo de Moura
94e2d0b313 feat: simp theorems for && and || 2021-03-31 08:12:24 -07:00
Daniel Fabian
ed75005422 feat: make proofs Hashable
change the `Hashable` class from taking a hash function of `Type u` to taking a
hash function from `Sort u`. This allows to implement `Hashable` for
propositions, which in turn is needed for inductives carrying proofs
2021-03-30 13:36:52 -07:00
Daniel Fabian
fee3390dd1 feat: add Hashable deriving
add support for the `Hashable` deriving by combining structural
hashes over fields
2021-03-30 13:36:52 -07:00
Leonardo de Moura
3db5b7e4ca chore: remove dead code 2021-03-29 20:37:49 -07:00
Leonardo de Moura
f75d9f50a6 feat: (try to) improve InfoTree.goalsAt? 2021-03-29 18:43:33 -07:00
Leonardo de Moura
efe67453ac chore: add Repr Lean.SourceInfo 2021-03-29 16:55:56 -07:00
Leonardo de Moura
564d0fe1cd chore: add getHeadPos? 2021-03-29 16:55:29 -07:00
Leonardo de Moura
558ed3da90 fix: missing argument
cc @Kha
2021-03-29 16:55:10 -07:00
Leonardo de Moura
08d865b475 chore: remove unnecessary generalizing 2021-03-27 15:03:13 -07:00
Leonardo de Moura
3176be136c feat: improve "discriminant refinement" 2021-03-24 21:05:08 -07:00
Leonardo de Moura
ec5afce45b feat: contextual := true at simp_all
cc @Kha
2021-03-24 15:49:31 -07:00
Leonardo de Moura
e4d4db45e9 feat: add missing simp lemmas for -> 2021-03-24 14:51:18 -07:00
Leonardo de Moura
b3ec00b00a chore: use "discriminant refinement" 2021-03-24 10:43:43 -07:00
Leonardo de Moura
592364270c chore: cleanup 2021-03-24 09:50:56 -07:00
Leonardo de Moura
d03f5fe318 feat: add trivial extensible (macro) tactic 2021-03-24 09:50:56 -07:00
Leonardo de Moura
2dfd262e4d chore: cleanup 2021-03-24 09:50:56 -07:00
Leonardo de Moura
b85c60aa75 chore: remove leftovers 2021-03-23 17:33:23 -07:00
Sebastian Ullrich
ed55fdfd3e chore: better error message when failing to find current package 2021-03-23 12:10:26 +01:00
Sebastian Ullrich
bbf6c717fc feat: introduce arg precedence 2021-03-22 16:33:37 +01:00
Sebastian Ullrich
725c0c1911 chore: implement lhs prec 2021-03-22 16:33:37 +01:00
Leonardo de Moura
d9273786c7 chore: remove when and «unless»
They are obsolete.

cc @Kha
2021-03-20 18:52:18 -07:00
Leonardo de Moura
9a5f239513 refactor: remove Monad Option and Alternative Option
We should use `OptionM` instead.
`Option` still implements `Functor` and `OrElse`.

cc @Kha
2021-03-20 18:25:25 -07:00
Leonardo de Moura
04e3f21783 chore: add OptionM monad
Motivation: `Option` is data, `OptionM` is control.
2021-03-20 17:50:45 -07:00
Sebastian Ullrich
e62542ed29 feat: CoeSort Bool Prop 2021-03-20 14:52:16 +01:00
Leonardo de Moura
86a204d8a1 feat: add simp_all tactic
cc @Kha
2021-03-19 22:34:35 -07:00
Leonardo de Moura
d70740fef2 fix: location notation and simp 2021-03-19 19:54:22 -07:00
Leonardo de Moura
205b42a397 feat: proper syntax for configuring simp 2021-03-17 16:37:04 -07:00
Leonardo de Moura
0720a53a9d chore: refactoring and cleanup 2021-03-17 14:56:08 -07:00
pcpthm
f645429df4 chore: slightly nicer UInt shift definition 2021-03-17 10:08:02 +01:00
pcpthm
419a6190e8 fix: bitwise shift overflow of UInt types
It is an undefined behavior in C when the right operand of a shift operation exceeds the bit-width of the left operand.
We define the shift operation to be `x << (y % B)` where `B` is the bit-width of the left operand.
2021-03-17 10:08:02 +01:00
Leonardo de Moura
89797c4485 chore: improve congrDefault
We don't need `congrMatch` anymore.
2021-03-16 15:59:11 -07:00
Leonardo de Moura
0fd9b493fa chore: add helper congruence lemma 2021-03-16 15:40:28 -07:00
Leonardo de Moura
c54a7c8ccc chore: make HasEquiv more general 2021-03-13 07:02:35 -08:00
Leonardo de Moura
a30a256123 refactor: remove Tactic/Binders.lean
These macro expansion functions can be now implemented using `macro` and `macro_rules`.
2021-03-12 17:59:21 -08:00
Leonardo de Moura
d330f1e2e2 feat: rotateLeft and rotateRight tactics 2021-03-12 17:13:03 -08:00
Leonardo de Moura
091fadbf64 feat: add List.rotateLeft and List.rotateRight 2021-03-12 17:09:22 -08:00
Leonardo de Moura
3d58c4d115 chore: remove old notation 2021-03-12 15:05:06 -08:00
Leonardo de Moura
bf8119a5cd chore: convert keywords to snake_case
Again `!` is only for functions that can panic.
2021-03-12 13:34:51 -08:00
Leonardo de Moura
472c5fb900 fix: indentation issues 2021-03-12 11:09:28 -08:00
Leonardo de Moura
df994fd16f fix: add checkColGe to matchAlt
@Kha this is a fix for the example that @gebner posted on Zulip.
There are other possible workarounds, but I think this one is
"intuitive".

Here is the problem description and workaround.
We currently use the `withPosition` combinator at `matchAlts`. The
original motivation was nested `match`-expressions without
parenthesis.
We also have the `checkColGt` in the application parser.

Thus, `frob 5` is not parsed as an application. That is, the term
parser after the `then` keyword stops at `frob`.
Then, we get the weird "expected 'else'" error message at `5` :)

In this commit, I add a `checkColGe` check at the beginning of each
alternative right-hand-side.

The effect on the stdlib was minimal. It basically affected old code
that used the Lean 3 workaround for partial functions
```
partial def f : N -> N | i =>
  ...
```
In Lean 4, we can use the more natural
```
partial def f (i : N) : N :=
...
```
or
```
partial def f : N -> N := fun i =>
...
```

It also affected code such as
```
instance : Repr String.Iterator where
  reprPrec | ⟨s, pos⟩, prec =>
    Repr.addAppParen ("String.Iterator.mk " ++ reprArg s ++ " " ++ reprArg pos) prec
```
This is a workaround for a missing feature. We really wanted to write
```
instance : Repr String.Iterator where
  reprPrec ⟨s, pos⟩ prec :=
    Repr.addAppParen ("String.Iterator.mk " ++ reprArg s ++ " " ++ reprArg pos) prec
```
2021-03-12 11:06:07 -08:00
Leonardo de Moura
1112ab6eff chore: use new notation 2021-03-11 11:19:33 -08:00
Leonardo de Moura
e7140959c4 chore: add elaborator for let_fun and let_delayed 2021-03-11 10:40:25 -08:00
Leonardo de Moura
9f88ea8047 chore: remove old decide!, nativeRefl!, and nativeDecide! 2021-03-11 08:06:20 -08:00
Leonardo de Moura
904c23e901 chore: add annotations
We need these extra annotations after we fix a bug a `commitWhen`.
In the `commitWhen` bug, we were "losing" postponed constraints.
2021-03-10 14:11:03 -08:00
Leonardo de Moura
9901898258 feat: add Nat.gcd
This commit also fix some theorem names to new naming convention.
2021-03-07 18:47:02 -08:00
Leonardo de Moura
51e7f45af2 refactor: cases
remove dead `induction/cases` code
2021-03-07 12:37:02 -08:00
Leonardo de Moura
e5f1bd2eb9 chore: fix Core.lean 2021-03-07 12:08:37 -08:00
Leonardo de Moura
55115a4a1b feat: add inferInstance tactic 2021-03-07 12:08:25 -08:00
Leonardo de Moura
dfa5cf9282 chore: add optional preprocessing tactic 2021-03-07 12:03:54 -08:00
Leonardo de Moura
66f1a88f2c feat: simp [-decl] 2021-03-04 17:50:44 -08:00