Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/perf/irrelevance-refutes.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/-!
Two proofs of different propositions, each a recursion over a literal, as the
last arguments of two applications of one function. A checker that reaches the
proofs must take proof irrelevance's negative answer as final: two proofs of
propositions that are not defeq are not defeq. Unfolding the proofs instead
evaluates the recursions.

Distilled from `decide +kernel` on `Rat` arithmetic, where the proofs are
`Nat.gcd_dvd` terms by well-founded recursion.
-/

-- Θ(m) to unfold to `rfl`
noncomputable def slowRefl (m : Nat) : m = m :=
Nat.rec (motive := fun _ => m = m) rfl (fun _ ih => ih) m

-- ignores both arguments
def f (m : Nat) (_h : m = m) : Nat := 0

theorem irrelevance_refutes : f 100000 (slowRefl 100000) = f 100001 (slowRefl 100001) := rfl
28 changes: 28 additions & 0 deletions tests/perf/irrelevance-refutes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description: |
The declaration to check is

f 100000 (slowRefl 100000) = f 100001 (slowRefl 100001)

proved by `rfl`, where `f` ignores its arguments and `slowRefl m : m = m`
is a `Nat.rec` over `m`, so unfolding it to `rfl` takes Θ(m) steps.

Both sides apply `f`, so a checker may first compare the arguments, find
them different, and then unfold `f`. Comparing the literals refutes for
**Θ(1)**. Comparing the proofs, proof irrelevance refutes them by their
types, `100000 = 100000` against `100001 = 100001`, also for **Θ(1)**: two
proofs of propositions that are not defeq are not defeq. A checker that
takes only proof irrelevance's positive answer, and otherwise unfolds the
proofs, evaluates both recursions for **Θ(m)**. Official compares the
arguments left to right and stops at the literals, but `is_def_eq_core`
would also stop on `is_def_eq_proof_irrel`'s `l_false` had it reached the
proofs first.

Distilled from `decide +kernel` on `Rat` arithmetic, e.g.
`(1 : Rat) / 1000000000 * ((1000000 : Int) : Rat) = 1 / 1000`, where the
proofs are `Nat.gcd_dvd` terms by well-founded recursion and the
comparison that reaches them is `Int.divExact`'s arguments, right to left.
leanfile: tests/perf/irrelevance-refutes.lean
export-decls: ["irrelevance_refutes"]
outcome: accept
compare-perf: true
timeout: 50
Loading