lean4-htt/tests/lean/run/forInListSpecUnivPoly.lean
Sebastian Graf 916125ae1c
fix: make Std.Do.Spec.forIn'_list and friends more universe polymorphic (#10865)
This PR makes the spec `Std.Do.Spec.forIn'_list` and friends more
universe polymorphic.

The regression test came from a dicussion on the public Zulip.
2025-10-21 09:04:52 +00:00

27 lines
1 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.

import Std.Tactic.Do
open Std.Do
set_option mvcgen.warning false
set_option warn.sorry false
def BubbleSort {α} [LT α] [DecidableLT α] (a: Array α) : Array α := Id.run do
let n := a.size
let mut a : Vector α n := a.toVector
for i in List.range (n - 1) do
for hj : j in List.range (n - i - 1) do
have := List.mem_range.mp hj
if a[j] > a[j + 1] then
a := a.swap j (j+1)
return a.toArray
theorem BubbleSortSameElements [LT α] [DecidableLT α] (A : Array α) : List.Perm A.toList (BubbleSort A).toList := by
generalize h : BubbleSort A = x
apply Id.of_wp_run_eq h
set_option trace.Elab.Tactic.Do.spec true in
mvcgen
-- This should be able to apply the universe polymorphic Spec.forIn_list so that we get to
-- provide invariant goals below. Back when the spec wasn't sufficiently universe polymorphic,
-- the defeq check after instantiation used to fail for this program, because the level of `Nat`
-- was not the same as the level of `α`.
case inv1 => sorry
case inv2 => sorry
all_goals sorry