lean4-htt/tests/lean/run/lcnfCache.lean
Cameron Zwarich 2929d547dc
fix: make the lcnf expr cache depend on the value of root, not just… (#8156)
This PR fixes a bug where the old compiler's lcnf conversion expr cache
was not including all of the relevant information in the key, leading to
terms inadvertently being erased. The `root` variable is used to
determine whether lambda arguments to applications should get let
bindings or not, which in turn affects later decisions about type
erasure (erase_irrelevant assumes that any non-atomic argument is
irrelevant).
2025-04-29 00:37:52 +00:00

38 lines
1.3 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def List.pwFilter {α} (R : αα → Prop) [DecidableRel R] (l : List α) : List α :=
l.foldr (fun x IH => if ∀ y ∈ IH, R x y then x :: IH else IH) []
def List.dedup {α} [DecidableEq α] : List α → List α :=
List.pwFilter (· ≠ ·)
def Multiset.{u} : Type u → Type u :=
fun α => Quotient (List.isSetoid α)
def Multiset.ofList {α} : List α → Multiset α :=
Quot.mk _
def Multiset.map {α β} (f : α → β) (s : Multiset α) : Multiset β :=
Quot.liftOn s (fun l : List α => Multiset.ofList (l.map f)) fun _l₁ _l₂ p => Quot.sound (p.map f)
def Multiset.dedup {α} [DecidableEq α] (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => Multiset.ofList l.dedup) fun l₁ l₂ p => Quot.sound (by sorry)
def Multiset.card {α} : Multiset α → Nat := Quot.lift List.length fun _l₁ _l₂ => List.Perm.length_eq
def test (_ : Unit) : Bool :=
let m := Multiset.ofList [0, 1]
let m := Multiset.map (fun i => i) m
let m := m.dedup
m.card < 2
/--
error: tactic 'native_decide' evaluated that the proposition
(let p := fun i => i;
(Multiset.map (fun i => i) (Multiset.ofList [0, 1])).dedup).card <
2
is false
-/
#guard_msgs in
theorem claim :
( let p : Nat → Nat := fun i => i;
(Multiset.map (fun i => i) (Multiset.ofList [0,1])).dedup).card < 2 := by
native_decide