-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
match
discriminant reduction should not unfold irreducible defs
- Loading branch information
Showing
3 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
structure Foo where num : Nat deriving DecidableEq | ||
|
||
namespace Foo | ||
|
||
instance : OfNat Foo n := ⟨⟨n⟩⟩ | ||
|
||
/-! # Example 1 -/ | ||
|
||
@[irreducible] def mul (a b : Foo) : Foo := | ||
let d := Nat.gcd a.num 1 | ||
⟨(a.num.div d) * (b.num.div d)⟩ | ||
|
||
-- should fail fast; exact heartbeat count at time of writing is 31 | ||
set_option maxHeartbeats 310 | ||
example : ((Foo.mul 4 1).mul 1).mul 1 = 4 := by decide | ||
|
||
/-! # Example 2 -/ | ||
|
||
@[irreducible] def add (a b : Foo) : Foo := ⟨a.num * b.num⟩ | ||
|
||
-- should not succeed (and fail fast); exact heartbeat count at time of writing is 21 | ||
example : ((Foo.add 4 1).add 1).add 1 = 4 := by decide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
2161.lean:14:48-14:54: error: failed to reduce to 'true' | ||
Decidable.rec (fun h => (fun x => false) h) (fun h => (fun x => true) h) | ||
(instDecidableEqFoo (mul (mul (mul 4 1) 1) 1) 4) | ||
2161.lean:22:48-22:54: error: failed to reduce to 'true' | ||
Decidable.rec (fun h => (fun x => false) h) (fun h => (fun x => true) h) | ||
(instDecidableEqFoo (add (add (add 4 1) 1) 1) 4) |