From 2de57fcd89388e411352a6671ace0558eddfa56f Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Tue, 21 Jul 2026 14:42:25 +0200 Subject: [PATCH 01/40] in progress... --- backends/lean/Aeneas.lean | 13 +- backends/lean/Aeneas/Command.lean | 9 +- backends/lean/Aeneas/Command/Decompose.lean | 12 +- .../lean/Aeneas/Command/Decompose/Tests.lean | 10 +- .../Aeneas/Command/Decompose/TestsBig.lean | 10 +- .../Aeneas/Command/Decompose/TestsRec.lean | 10 +- backends/lean/Aeneas/Data.lean | 23 +-- backends/lean/Aeneas/Data/Array.lean | 6 +- backends/lean/Aeneas/Data/BitVec.lean | 36 ++--- backends/lean/Aeneas/Data/Byte.lean | 8 +- backends/lean/Aeneas/Data/Discriminant.lean | 8 +- backends/lean/Aeneas/Data/Fin.lean | 8 +- backends/lean/Aeneas/Data/Int.lean | 4 +- backends/lean/Aeneas/Data/List.lean | 3 +- backends/lean/Aeneas/Data/List/List.lean | 24 +-- backends/lean/Aeneas/Data/Nat.lean | 4 +- backends/lean/Aeneas/Data/Range.lean | 11 +- backends/lean/Aeneas/Data/Range/DivRange.lean | 7 +- .../Aeneas/Data/Range/DivRange/Basic.lean | 8 +- .../Aeneas/Data/Range/DivRange/Lemmas.lean | 8 +- .../Aeneas/Data/Range/DivRange/Notations.lean | 6 +- backends/lean/Aeneas/Data/Range/Lemmas.lean | 6 +- backends/lean/Aeneas/Data/Range/MulRange.lean | 7 +- .../Aeneas/Data/Range/MulRange/Basic.lean | 8 +- .../Aeneas/Data/Range/MulRange/Lemmas.lean | 12 +- .../Aeneas/Data/Range/MulRange/Notations.lean | 6 +- .../lean/Aeneas/Data/Range/Notations.lean | 4 +- backends/lean/Aeneas/Data/Range/SRRange.lean | 7 +- .../lean/Aeneas/Data/Range/SRRange/Basic.lean | 6 +- .../Aeneas/Data/Range/SRRange/Lemmas.lean | 10 +- .../Aeneas/Data/Range/SRRange/Notations.lean | 6 +- backends/lean/Aeneas/Data/Tuples.lean | 6 +- backends/lean/Aeneas/Data/Vector.lean | 4 +- backends/lean/Aeneas/Do.lean | 7 +- backends/lean/Aeneas/Do/Delab.lean | 8 +- backends/lean/Aeneas/Do/Elab.lean | 8 +- backends/lean/Aeneas/Do/Tests.lean | 8 +- backends/lean/Aeneas/Extract.lean | 3 +- backends/lean/Aeneas/Extract/Extract.lean | 4 +- backends/lean/Aeneas/Std.lean | 37 ++--- backends/lean/Aeneas/Std/Alloc.lean | 8 +- backends/lean/Aeneas/Std/Array.lean | 9 +- backends/lean/Aeneas/Std/Array/Array.lean | 10 +- .../lean/Aeneas/Std/Array/ArrayDebug.lean | 6 +- .../lean/Aeneas/Std/Array/ArraySlice.lean | 16 +- backends/lean/Aeneas/Std/Array/Core.lean | 6 +- backends/lean/Aeneas/Std/Core.lean | 37 ++--- backends/lean/Aeneas/Std/Core/Atomic.lean | 4 +- backends/lean/Aeneas/Std/Core/Cmp.lean | 12 +- backends/lean/Aeneas/Std/Core/Convert.lean | 10 +- backends/lean/Aeneas/Std/Core/Core.lean | 12 +- backends/lean/Aeneas/Std/Core/CoreOption.lean | 6 +- backends/lean/Aeneas/Std/Core/Default.lean | 4 +- .../lean/Aeneas/Std/Core/Discriminant.lean | 10 +- backends/lean/Aeneas/Std/Core/Error.lean | 4 +- backends/lean/Aeneas/Std/Core/Fmt.lean | 10 +- .../lean/Aeneas/Std/Core/FmtWithSlice.lean | 8 +- backends/lean/Aeneas/Std/Core/Hash.lean | 6 +- backends/lean/Aeneas/Std/Core/Iter.lean | 20 +-- backends/lean/Aeneas/Std/Core/Marker.lean | 4 +- backends/lean/Aeneas/Std/Core/Ops.lean | 6 +- backends/lean/Aeneas/Std/Core/Panic.lean | 4 +- backends/lean/Aeneas/Std/Core/Pin.lean | 4 +- backends/lean/Aeneas/Std/Core/Ptr.lean | 6 +- backends/lean/Aeneas/Std/Core/Result.lean | 4 +- backends/lean/Aeneas/Std/Delab.lean | 6 +- backends/lean/Aeneas/Std/Global.lean | 4 +- backends/lean/Aeneas/Std/Primitives.lean | 10 +- .../lean/Aeneas/Std/PrimitivesLemmas.lean | 8 +- backends/lean/Aeneas/Std/Range.lean | 16 +- backends/lean/Aeneas/Std/RangeIter.lean | 8 +- backends/lean/Aeneas/Std/RawPtr.lean | 4 +- backends/lean/Aeneas/Std/Scalar.lean | 41 +++--- backends/lean/Aeneas/Std/Scalar/Bitwise.lean | 10 +- backends/lean/Aeneas/Std/Scalar/BvComp.lean | 4 +- backends/lean/Aeneas/Std/Scalar/Casts.lean | 8 +- .../lean/Aeneas/Std/Scalar/CheckedOps.lean | 11 +- .../Aeneas/Std/Scalar/CheckedOps/Add.lean | 6 +- .../Aeneas/Std/Scalar/CheckedOps/Div.lean | 6 +- .../Aeneas/Std/Scalar/CheckedOps/Mul.lean | 6 +- .../Aeneas/Std/Scalar/CheckedOps/Rem.lean | 6 +- .../Aeneas/Std/Scalar/CheckedOps/Sub.lean | 6 +- .../lean/Aeneas/Std/Scalar/CloneCopy.lean | 6 +- backends/lean/Aeneas/Std/Scalar/Core.lean | 22 +-- .../Aeneas/Std/Scalar/CoreConvertNum.lean | 30 ++-- backends/lean/Aeneas/Std/Scalar/Default.lean | 10 +- backends/lean/Aeneas/Std/Scalar/Display.lean | 6 +- backends/lean/Aeneas/Std/Scalar/Elab.lean | 25 ++-- backends/lean/Aeneas/Std/Scalar/EqOrd.lean | 8 +- backends/lean/Aeneas/Std/Scalar/Fmt.lean | 6 +- .../lean/Aeneas/Std/Scalar/LeadingZeros.lean | 8 +- backends/lean/Aeneas/Std/Scalar/Misc.lean | 8 +- .../lean/Aeneas/Std/Scalar/Notations.lean | 14 +- backends/lean/Aeneas/Std/Scalar/Ops.lean | 13 +- backends/lean/Aeneas/Std/Scalar/Ops/Add.lean | 12 +- backends/lean/Aeneas/Std/Scalar/Ops/Div.lean | 12 +- backends/lean/Aeneas/Std/Scalar/Ops/Mul.lean | 14 +- backends/lean/Aeneas/Std/Scalar/Ops/Neg.lean | 12 +- backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean | 12 +- backends/lean/Aeneas/Std/Scalar/Ops/Sub.lean | 12 +- .../Aeneas/Std/Scalar/OverflowingOps.lean | 9 +- .../Aeneas/Std/Scalar/OverflowingOps/Add.lean | 8 +- .../Aeneas/Std/Scalar/OverflowingOps/Div.lean | 8 +- .../Aeneas/Std/Scalar/OverflowingOps/Mul.lean | 8 +- .../Aeneas/Std/Scalar/OverflowingOps/Sub.lean | 8 +- backends/lean/Aeneas/Std/Scalar/Pow.lean | 4 +- backends/lean/Aeneas/Std/Scalar/Rotate.lean | 6 +- .../lean/Aeneas/Std/Scalar/SaturatingOps.lean | 6 +- .../lean/Aeneas/Std/Scalar/WrappingOps.lean | 11 +- .../Aeneas/Std/Scalar/WrappingOps/Add.lean | 6 +- .../Aeneas/Std/Scalar/WrappingOps/Mul.lean | 6 +- .../Aeneas/Std/Scalar/WrappingOps/Shl.lean | 6 +- .../Aeneas/Std/Scalar/WrappingOps/Shr.lean | 6 +- .../Aeneas/Std/Scalar/WrappingOps/Sub.lean | 6 +- backends/lean/Aeneas/Std/Slice.lean | 16 +- backends/lean/Aeneas/Std/SliceDef.lean | 4 +- backends/lean/Aeneas/Std/SliceIter.lean | 8 +- backends/lean/Aeneas/Std/Spec.lean | 6 +- backends/lean/Aeneas/Std/Std.lean | 3 +- backends/lean/Aeneas/Std/Std/Io.lean | 4 +- backends/lean/Aeneas/Std/String.lean | 8 +- backends/lean/Aeneas/Std/StringDef.lean | 6 +- backends/lean/Aeneas/Std/StringIter.lean | 8 +- backends/lean/Aeneas/Std/Vec.lean | 16 +- backends/lean/Aeneas/Std/VecIter.lean | 6 +- backends/lean/Aeneas/Std/WP.lean | 12 +- backends/lean/Aeneas/Tactic.lean | 21 +-- backends/lean/Aeneas/Tactic/Conv.lean | 9 +- backends/lean/Aeneas/Tactic/Conv/Bvify.lean | 5 +- .../lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean | 18 ++- .../lean/Aeneas/Tactic/Conv/Bvify/Init.lean | 4 +- .../lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean | 6 +- .../lean/Aeneas/Tactic/Conv/Bvify/Tests.lean | 6 +- backends/lean/Aeneas/Tactic/Conv/Natify.lean | 3 +- .../lean/Aeneas/Tactic/Conv/Natify/Init.lean | 4 +- .../Aeneas/Tactic/Conv/Natify/Natify.lean | 20 +-- backends/lean/Aeneas/Tactic/Conv/ZModify.lean | 3 +- .../lean/Aeneas/Tactic/Conv/ZModify/Init.lean | 4 +- .../Aeneas/Tactic/Conv/ZModify/ZModify.lean | 20 +-- backends/lean/Aeneas/Tactic/Conv/Zify.lean | 6 +- backends/lean/Aeneas/Tactic/Elab.lean | 3 +- .../lean/Aeneas/Tactic/Elab/TraitDefault.lean | 5 +- .../Aeneas/Tactic/Elab/TraitDefault/Init.lean | 16 +- .../Aeneas/Tactic/Elab/TraitDefault/Test.lean | 4 +- backends/lean/Aeneas/Tactic/Misc.lean | 7 +- .../lean/Aeneas/Tactic/Misc/FApplyExact.lean | 8 +- backends/lean/Aeneas/Tactic/Misc/FCongr.lean | 3 +- .../Aeneas/Tactic/Misc/FCongr/FCongr.lean | 7 +- backends/lean/Aeneas/Tactic/Misc/Let.lean | 3 +- backends/lean/Aeneas/Tactic/Misc/Let/Let.lean | 6 +- .../lean/Aeneas/Tactic/RustAttributes.lean | 4 +- backends/lean/Aeneas/Tactic/Setup.lean | 6 +- backends/lean/Aeneas/Tactic/Simp.lean | 15 +- .../lean/Aeneas/Tactic/Simp/RingEqNF.lean | 5 +- .../Aeneas/Tactic/Simp/RingEqNF/Tactic.lean | 30 ++-- .../Aeneas/Tactic/Simp/RingEqNF/Tests.lean | 4 +- .../lean/Aeneas/Tactic/Simp/SimpBoolProp.lean | 3 +- .../Aeneas/Tactic/Simp/SimpBoolProp/Init.lean | 4 +- .../Simp/SimpBoolProp/SimpBoolProp.lean | 6 +- backends/lean/Aeneas/Tactic/Simp/SimpIfs.lean | 3 +- .../lean/Aeneas/Tactic/Simp/SimpIfs/Init.lean | 4 +- .../Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean | 8 +- .../lean/Aeneas/Tactic/Simp/SimpLemmas.lean | 4 +- .../lean/Aeneas/Tactic/Simp/SimpLists.lean | 5 +- .../Aeneas/Tactic/Simp/SimpLists/Init.lean | 4 +- .../Tactic/Simp/SimpLists/SimpLists.lean | 10 +- .../Aeneas/Tactic/Simp/SimpLists/Tests.lean | 14 +- .../Aeneas/Tactic/Simp/SimpListsScalar.lean | 6 +- .../lean/Aeneas/Tactic/Simp/SimpScalar.lean | 7 +- .../Aeneas/Tactic/Simp/SimpScalar/Init.lean | 4 +- .../Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean | 6 +- .../Tactic/Simp/SimpScalar/SimpScalar.lean | 12 +- .../Aeneas/Tactic/Simp/SimpScalar/Tests.lean | 4 +- backends/lean/Aeneas/Tactic/Simproc.lean | 9 +- .../Aeneas/Tactic/Simproc/BvSimprocs.lean | 4 +- .../lean/Aeneas/Tactic/Simproc/ReduceFin.lean | 3 +- .../Aeneas/Tactic/Simproc/ReduceFin/Init.lean | 4 +- .../Tactic/Simproc/ReduceFin/ReduceFin.lean | 6 +- .../lean/Aeneas/Tactic/Simproc/ReduceNat.lean | 6 +- .../Aeneas/Tactic/Simproc/ReduceZMod.lean | 3 +- .../Tactic/Simproc/ReduceZMod/Init.lean | 4 +- .../Tactic/Simproc/ReduceZMod/ReduceZMod.lean | 8 +- backends/lean/Aeneas/Tactic/Solver.lean | 11 +- backends/lean/Aeneas/Tactic/Solver/Arith.lean | 3 +- .../Aeneas/Tactic/Solver/Arith/Lemmas.lean | 10 +- backends/lean/Aeneas/Tactic/Solver/BvTac.lean | 7 +- .../Aeneas/Tactic/Solver/BvTac/BvTac.lean | 8 +- .../lean/Aeneas/Tactic/Solver/BvTac/Init.lean | 4 +- .../Aeneas/Tactic/Solver/BvTac/Lemmas.lean | 4 +- .../Aeneas/Tactic/Solver/BvTac/Tests.lean | 6 +- backends/lean/Aeneas/Tactic/Solver/Grind.lean | 3 +- .../Aeneas/Tactic/Solver/Grind/Attribute.lean | 2 +- .../lean/Aeneas/Tactic/Solver/Grind/Init.lean | 9 +- .../Aeneas/Tactic/Solver/ScalarDecrTac.lean | 10 +- .../lean/Aeneas/Tactic/Solver/ScalarTac.lean | 9 +- .../Tactic/Solver/ScalarTac/CondSimpTac.lean | 4 +- .../Aeneas/Tactic/Solver/ScalarTac/Core.lean | 6 +- .../Aeneas/Tactic/Solver/ScalarTac/Init.lean | 6 +- .../Tactic/Solver/ScalarTac/Lemmas.lean | 10 +- .../Tactic/Solver/ScalarTac/ScalarTac.lean | 24 +-- .../Aeneas/Tactic/Solver/ScalarTac/Tests.lean | 4 +- backends/lean/Aeneas/Tactic/Step.lean | 13 +- .../lean/Aeneas/Tactic/Step/Deprecated.lean | 8 +- .../Aeneas/Tactic/Step/DspecInduction.lean | 22 +-- .../lean/Aeneas/Tactic/Step/GrindState.lean | 10 +- .../lean/Aeneas/Tactic/Step/InferPost.lean | 14 +- backends/lean/Aeneas/Tactic/Step/Init.lean | 16 +- backends/lean/Aeneas/Tactic/Step/Step.lean | 24 +-- .../Aeneas/Tactic/Step/StepArraySpec.lean | 4 +- .../lean/Aeneas/Tactic/Step/StepStar.lean | 6 +- backends/lean/Aeneas/Tactic/Step/Tests.lean | 13 +- .../Aeneas/Tactic/Step/Tests/HigherOrder.lean | 6 +- .../Tactic/Step/Tests/IntroOutputs.lean | 8 +- .../Tactic/Step/Tests/MaxRecDepthMetavar.lean | 8 +- .../Aeneas/Tactic/Step/Tests/MvcgenSpec.lean | 8 +- .../Tactic/Step/Tests/TupleDestruct.lean | 8 +- .../Aeneas/Tactic/Step/Tests/UncurryBind.lean | 8 +- backends/lean/Aeneas/Tactic/Step/Trace.lean | 4 +- backends/lean/Aeneas/Tactic/Tests.lean | 13 +- backends/lean/AeneasExtract.lean | 4 +- backends/lean/AeneasMeta.lean | 15 +- backends/lean/AeneasMeta/Async.lean | 7 +- backends/lean/AeneasMeta/Async/Async.lean | 4 +- backends/lean/AeneasMeta/Async/Test.lean | 4 +- .../lean/AeneasMeta/Async/TestTactics.lean | 8 +- backends/lean/AeneasMeta/BvEnumToBitVec.lean | 14 +- backends/lean/AeneasMeta/Extensions.lean | 10 +- backends/lean/AeneasMeta/OptionConfig.lean | 22 +-- backends/lean/AeneasMeta/Saturate.lean | 3 +- .../lean/AeneasMeta/Saturate/Attribute.lean | 8 +- backends/lean/AeneasMeta/Saturate/Tactic.lean | 4 +- backends/lean/AeneasMeta/Simp.lean | 7 +- .../lean/AeneasMeta/Simp/RegisterCommand.lean | 6 +- backends/lean/AeneasMeta/Simp/Simp.lean | 4 +- .../AeneasMeta/Simp/SimpAllAssumptions.lean | 10 +- backends/lean/AeneasMeta/Split.lean | 6 +- backends/lean/AeneasMeta/Utils.lean | 138 +++++++++--------- backends/lean/AeneasMeta/UtilsCore.lean | 4 +- src/Translate.ml | 22 ++- tests/lean/Constants.lean | 4 +- 240 files changed, 1344 insertions(+), 895 deletions(-) diff --git a/backends/lean/Aeneas.lean b/backends/lean/Aeneas.lean index 6fc8d91f1..955624161 100644 --- a/backends/lean/Aeneas.lean +++ b/backends/lean/Aeneas.lean @@ -1,6 +1,7 @@ -import Aeneas.Command -import Aeneas.Data -import Aeneas.Do -import Aeneas.Extract -import Aeneas.Std -import Aeneas.Tactic +module +public import Aeneas.Command +public import Aeneas.Data +public import Aeneas.Do +public import Aeneas.Extract +public import Aeneas.Std +public import Aeneas.Tactic diff --git a/backends/lean/Aeneas/Command.lean b/backends/lean/Aeneas/Command.lean index dc50083d6..750416ad9 100644 --- a/backends/lean/Aeneas/Command.lean +++ b/backends/lean/Aeneas/Command.lean @@ -1,4 +1,5 @@ -import Aeneas.Command.Decompose -import Aeneas.Command.Decompose.Tests -import Aeneas.Command.Decompose.TestsBig -import Aeneas.Command.Decompose.TestsRec +module +public import Aeneas.Command.Decompose +public import Aeneas.Command.Decompose.Tests +public import Aeneas.Command.Decompose.TestsBig +public import Aeneas.Command.Decompose.TestsRec diff --git a/backends/lean/Aeneas/Command/Decompose.lean b/backends/lean/Aeneas/Command/Decompose.lean index 36f7b519b..cca83801e 100644 --- a/backends/lean/Aeneas/Command/Decompose.lean +++ b/backends/lean/Aeneas/Command/Decompose.lean @@ -2,11 +2,13 @@ Copyright (c) 2025. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ -import Lean -import Aeneas.Std.Primitives -import Aeneas.Std.WP -import AeneasMeta.Simp.Simp -import AeneasMeta.Utils +module +public import Lean +public import Aeneas.Std.Primitives +public import Aeneas.Std.WP +public import AeneasMeta.Simp.Simp +public import AeneasMeta.Utils +public section /-! # The `#decompose` command diff --git a/backends/lean/Aeneas/Command/Decompose/Tests.lean b/backends/lean/Aeneas/Command/Decompose/Tests.lean index 6752bdee3..a6dfb96b1 100644 --- a/backends/lean/Aeneas/Command/Decompose/Tests.lean +++ b/backends/lean/Aeneas/Command/Decompose/Tests.lean @@ -1,10 +1,12 @@ /- Tests for the #decompose command -/ -import Aeneas.Command.Decompose -import Aeneas.Std -import Aeneas.Do.Elab -import Aeneas.Do.Delab +module +public import Aeneas.Command.Decompose +public import Aeneas.Std +public import Aeneas.Do.Elab +public import Aeneas.Do.Delab +public section open Aeneas.Std open Aeneas.Command.Decompose diff --git a/backends/lean/Aeneas/Command/Decompose/TestsBig.lean b/backends/lean/Aeneas/Command/Decompose/TestsBig.lean index fa24aab0d..326dd4e3f 100644 --- a/backends/lean/Aeneas/Command/Decompose/TestsBig.lean +++ b/backends/lean/Aeneas/Command/Decompose/TestsBig.lean @@ -1,10 +1,12 @@ /- Big tests for the #decompose command (performance/stress tests) -/ -import Aeneas.Command.Decompose -import Aeneas.Std -import Aeneas.Do.Elab -import Aeneas.Do.Delab +module +public import Aeneas.Command.Decompose +public import Aeneas.Std +public import Aeneas.Do.Elab +public import Aeneas.Do.Delab +public section open Aeneas.Std open Aeneas.Command.Decompose diff --git a/backends/lean/Aeneas/Command/Decompose/TestsRec.lean b/backends/lean/Aeneas/Command/Decompose/TestsRec.lean index 7317f51a3..d23ba56bb 100644 --- a/backends/lean/Aeneas/Command/Decompose/TestsRec.lean +++ b/backends/lean/Aeneas/Command/Decompose/TestsRec.lean @@ -2,10 +2,12 @@ Tests for `#decompose` on recursive functions (WF recursion, partial_fixpoint, structural recursion). -/ -import Aeneas.Command.Decompose -import Aeneas.Std -import Aeneas.Do.Elab -import Aeneas.Do.Delab +module +public import Aeneas.Command.Decompose +public import Aeneas.Std +public import Aeneas.Do.Elab +public import Aeneas.Do.Delab +public section open Aeneas.Std open Aeneas.Command.Decompose diff --git a/backends/lean/Aeneas/Data.lean b/backends/lean/Aeneas/Data.lean index 825cb5c00..3ed32d8fe 100644 --- a/backends/lean/Aeneas/Data.lean +++ b/backends/lean/Aeneas/Data.lean @@ -1,11 +1,12 @@ -import Aeneas.Data.Array -import Aeneas.Data.BitVec -import Aeneas.Data.Byte -import Aeneas.Data.Discriminant -import Aeneas.Data.Fin -import Aeneas.Data.Int -import Aeneas.Data.List -import Aeneas.Data.Nat -import Aeneas.Data.Range -import Aeneas.Data.Tuples -import Aeneas.Data.Vector +module +public import Aeneas.Data.Array +public import Aeneas.Data.BitVec +public import Aeneas.Data.Byte +public import Aeneas.Data.Discriminant +public import Aeneas.Data.Fin +public import Aeneas.Data.Int +public import Aeneas.Data.List +public import Aeneas.Data.Nat +public import Aeneas.Data.Range +public import Aeneas.Data.Tuples +public import Aeneas.Data.Vector diff --git a/backends/lean/Aeneas/Data/Array.lean b/backends/lean/Aeneas/Data/Array.lean index 0930b95b8..63938a02e 100644 --- a/backends/lean/Aeneas/Data/Array.lean +++ b/backends/lean/Aeneas/Data/Array.lean @@ -1,5 +1,7 @@ -import Aeneas.Data.List -import Aeneas.Tactic.Simp.SimpIfs +module +public import Aeneas.Data.List +public import Aeneas.Tactic.Simp.SimpIfs +public section namespace Array diff --git a/backends/lean/Aeneas/Data/BitVec.lean b/backends/lean/Aeneas/Data/BitVec.lean index f463138aa..54c082943 100644 --- a/backends/lean/Aeneas/Data/BitVec.lean +++ b/backends/lean/Aeneas/Data/BitVec.lean @@ -1,20 +1,22 @@ -import Init.Data.List.OfFn -import Init.Data.BitVec.Lemmas -import Batteries.Data.BitVec.Lemmas -import Mathlib.Data.Nat.Basic -import Mathlib.Data.Fin.Basic -import Mathlib.Data.Nat.Cast.Basic -import Mathlib.Data.BitVec -import Mathlib.Tactic.Ring -import Mathlib.Data.Nat.Bitwise -import Aeneas.Data.Byte -import Aeneas.Tactic.Conv.Bvify.Init -import Aeneas.Tactic.Simp.SimpLists.SimpLists -import Aeneas.Tactic.Conv.Natify.Natify -import Aeneas.Tactic.Conv.ZModify.ZModify -import Aeneas.Data.List -import Aeneas.Tactic.Simp.SimpScalar -import Aeneas.Tactic.Solver.Grind.Init +module +public import Init.Data.List.OfFn +public import Init.Data.BitVec.Lemmas +public import Batteries.Data.BitVec.Lemmas +public import Mathlib.Data.Nat.Basic +public import Mathlib.Data.Fin.Basic +public import Mathlib.Data.Nat.Cast.Basic +public import Mathlib.Data.BitVec +public import Mathlib.Tactic.Ring +public import Mathlib.Data.Nat.Bitwise +public import Aeneas.Data.Byte +public import Aeneas.Tactic.Conv.Bvify.Init +public import Aeneas.Tactic.Simp.SimpLists.SimpLists +public import Aeneas.Tactic.Conv.Natify.Natify +public import Aeneas.Tactic.Conv.ZModify.ZModify +public import Aeneas.Data.List +public import Aeneas.Tactic.Simp.SimpScalar +public import Aeneas.Tactic.Solver.Grind.Init +public section open Lean diff --git a/backends/lean/Aeneas/Data/Byte.lean b/backends/lean/Aeneas/Data/Byte.lean index 88e2aa7ac..f151db3e4 100644 --- a/backends/lean/Aeneas/Data/Byte.lean +++ b/backends/lean/Aeneas/Data/Byte.lean @@ -1,6 +1,8 @@ -import Lean -import Aeneas.Tactic.Simp.SimpLists.Init -import Aeneas.Tactic.Simp.SimpScalar.Init +module +public import Lean +public import Aeneas.Tactic.Simp.SimpLists.Init +public import Aeneas.Tactic.Simp.SimpScalar.Init +public section abbrev Byte := BitVec 8 abbrev Byte.ofNat := BitVec.ofNat 8 diff --git a/backends/lean/Aeneas/Data/Discriminant.lean b/backends/lean/Aeneas/Data/Discriminant.lean index 8a8b38f2b..3c4a34067 100644 --- a/backends/lean/Aeneas/Data/Discriminant.lean +++ b/backends/lean/Aeneas/Data/Discriminant.lean @@ -1,6 +1,8 @@ -import Lean -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Notations +module +public import Lean +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Notations +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Fin.lean b/backends/lean/Aeneas/Data/Fin.lean index 649a61b43..23bc91c82 100644 --- a/backends/lean/Aeneas/Data/Fin.lean +++ b/backends/lean/Aeneas/Data/Fin.lean @@ -1,6 +1,8 @@ -import Lean -import Mathlib.Tactic.OfNat -import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +module +public import Lean +public import Mathlib.Tactic.OfNat +public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public section attribute [scalar_tac_simps] Fin.val_ofNat diff --git a/backends/lean/Aeneas/Data/Int.lean b/backends/lean/Aeneas/Data/Int.lean index 53d7c5896..163df43af 100644 --- a/backends/lean/Aeneas/Data/Int.lean +++ b/backends/lean/Aeneas/Data/Int.lean @@ -1,4 +1,6 @@ -import Lean +module +public import Lean +public section /-- Small helper diff --git a/backends/lean/Aeneas/Data/List.lean b/backends/lean/Aeneas/Data/List.lean index 54754e95b..c17937f7b 100644 --- a/backends/lean/Aeneas/Data/List.lean +++ b/backends/lean/Aeneas/Data/List.lean @@ -1 +1,2 @@ -import Aeneas.Data.List.List +module +public import Aeneas.Data.List.List diff --git a/backends/lean/Aeneas/Data/List/List.lean b/backends/lean/Aeneas/Data/List/List.lean index b731dedae..d8c976a07 100644 --- a/backends/lean/Aeneas/Data/List/List.lean +++ b/backends/lean/Aeneas/Data/List/List.lean @@ -1,15 +1,17 @@ /- Complementary functions and lemmas for the `List` type -/ - -import Mathlib.Data.List.GetD -import Aeneas.Tactic.Solver.ScalarTac -import AeneasMeta.Utils -import Aeneas.Tactic.Simp.SimpLemmas -import Aeneas.Data.Nat -import Aeneas.Tactic.Simp.SimpLists.Init -import Aeneas.Std.Primitives -import Aeneas.Tactic.Simp.SimpLists.SimpLists -import Aeneas.Tactic.Simp.SimpScalar.SimpScalar -import Aeneas.Tactic.Solver.Grind.Init +module + +public import Mathlib.Data.List.GetD +public import Aeneas.Tactic.Solver.ScalarTac +public import AeneasMeta.Utils +public import Aeneas.Tactic.Simp.SimpLemmas +public import Aeneas.Data.Nat +public import Aeneas.Tactic.Simp.SimpLists.Init +public import Aeneas.Std.Primitives +public import Aeneas.Tactic.Simp.SimpLists.SimpLists +public import Aeneas.Tactic.Simp.SimpScalar.SimpScalar +public import Aeneas.Tactic.Solver.Grind.Init +public section namespace List -- We do not use the `Aeneas` namespace on purpose diff --git a/backends/lean/Aeneas/Data/Nat.lean b/backends/lean/Aeneas/Data/Nat.lean index c7fb0494e..df8844a94 100644 --- a/backends/lean/Aeneas/Data/Nat.lean +++ b/backends/lean/Aeneas/Data/Nat.lean @@ -1,4 +1,6 @@ -import Lean +module +public import Lean +public section /-- Small helper diff --git a/backends/lean/Aeneas/Data/Range.lean b/backends/lean/Aeneas/Data/Range.lean index 218c7244c..ce1632c78 100644 --- a/backends/lean/Aeneas/Data/Range.lean +++ b/backends/lean/Aeneas/Data/Range.lean @@ -1,5 +1,6 @@ -import Aeneas.Data.Range.DivRange -import Aeneas.Data.Range.Lemmas -import Aeneas.Data.Range.MulRange -import Aeneas.Data.Range.Notations -import Aeneas.Data.Range.SRRange +module +public import Aeneas.Data.Range.DivRange +public import Aeneas.Data.Range.Lemmas +public import Aeneas.Data.Range.MulRange +public import Aeneas.Data.Range.Notations +public import Aeneas.Data.Range.SRRange diff --git a/backends/lean/Aeneas/Data/Range/DivRange.lean b/backends/lean/Aeneas/Data/Range/DivRange.lean index 6490b61b6..36341f254 100644 --- a/backends/lean/Aeneas/Data/Range/DivRange.lean +++ b/backends/lean/Aeneas/Data/Range/DivRange.lean @@ -1,3 +1,4 @@ -import Aeneas.Data.Range.DivRange.Basic -import Aeneas.Data.Range.DivRange.Lemmas -import Aeneas.Data.Range.DivRange.Notations +module +public import Aeneas.Data.Range.DivRange.Basic +public import Aeneas.Data.Range.DivRange.Lemmas +public import Aeneas.Data.Range.DivRange.Notations diff --git a/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean b/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean index 287f0dc8e..8fcc16569 100644 --- a/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean +++ b/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean @@ -1,6 +1,8 @@ -import Mathlib.Data.Nat.Basic -import Mathlib.Algebra.Group.Basic -import AeneasMeta.Utils +module +public import Mathlib.Data.Nat.Basic +public import Mathlib.Algebra.Group.Basic +public import AeneasMeta.Utils +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean b/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean index 25c593cf8..fa49616ab 100644 --- a/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean +++ b/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean @@ -1,6 +1,8 @@ -import Mathlib.Data.Nat.Log -import Mathlib.Algebra.Order.Sub.Defs -import Aeneas.Data.Range.DivRange.Basic +module +public import Mathlib.Data.Nat.Log +public import Mathlib.Algebra.Order.Sub.Defs +public import Aeneas.Data.Range.DivRange.Basic +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Range/DivRange/Notations.lean b/backends/lean/Aeneas/Data/Range/DivRange/Notations.lean index d40172d78..66642d6e4 100644 --- a/backends/lean/Aeneas/Data/Range/DivRange/Notations.lean +++ b/backends/lean/Aeneas/Data/Range/DivRange/Notations.lean @@ -1,5 +1,7 @@ -import Aeneas.Data.Range.Notations -import Aeneas.Data.Range.DivRange.Basic +module +public import Aeneas.Data.Range.Notations +public import Aeneas.Data.Range.DivRange.Basic +public section namespace Aeneas.Notations diff --git a/backends/lean/Aeneas/Data/Range/Lemmas.lean b/backends/lean/Aeneas/Data/Range/Lemmas.lean index 85c62a910..07b64576e 100644 --- a/backends/lean/Aeneas/Data/Range/Lemmas.lean +++ b/backends/lean/Aeneas/Data/Range/Lemmas.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Solver.Grind.Init -import Aeneas.Tactic.Solver.ScalarTac.Init +module +public import Aeneas.Tactic.Solver.Grind.Init +public import Aeneas.Tactic.Solver.ScalarTac.Init +public section -- TODO: add a namepsace diff --git a/backends/lean/Aeneas/Data/Range/MulRange.lean b/backends/lean/Aeneas/Data/Range/MulRange.lean index 60a8c6aa2..8e7b8297b 100644 --- a/backends/lean/Aeneas/Data/Range/MulRange.lean +++ b/backends/lean/Aeneas/Data/Range/MulRange.lean @@ -1,3 +1,4 @@ -import Aeneas.Data.Range.MulRange.Basic -import Aeneas.Data.Range.MulRange.Lemmas -import Aeneas.Data.Range.MulRange.Notations +module +public import Aeneas.Data.Range.MulRange.Basic +public import Aeneas.Data.Range.MulRange.Lemmas +public import Aeneas.Data.Range.MulRange.Notations diff --git a/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean b/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean index 44b394d54..d2b7d22b2 100644 --- a/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean +++ b/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean @@ -1,6 +1,8 @@ -import Mathlib.Data.Nat.Basic -import Mathlib.Algebra.Group.Basic -import AeneasMeta.Utils +module +public import Mathlib.Data.Nat.Basic +public import Mathlib.Algebra.Group.Basic +public import AeneasMeta.Utils +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean b/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean index 6ebb6446e..fbce447de 100644 --- a/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean +++ b/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean @@ -1,8 +1,10 @@ -import Mathlib.Data.Nat.Log -import Mathlib.Algebra.Order.Ring.Canonical -import Mathlib.Tactic.Ring.RingNF -import Aeneas.Data.Range.MulRange.Basic -import Aeneas.Data.Range.DivRange.Lemmas +module +public import Mathlib.Data.Nat.Log +public import Mathlib.Algebra.Order.Ring.Canonical +public import Mathlib.Tactic.Ring.RingNF +public import Aeneas.Data.Range.MulRange.Basic +public import Aeneas.Data.Range.DivRange.Lemmas +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Range/MulRange/Notations.lean b/backends/lean/Aeneas/Data/Range/MulRange/Notations.lean index e4efb7c46..d1ed93594 100644 --- a/backends/lean/Aeneas/Data/Range/MulRange/Notations.lean +++ b/backends/lean/Aeneas/Data/Range/MulRange/Notations.lean @@ -1,5 +1,7 @@ -import Aeneas.Data.Range.Notations -import Aeneas.Data.Range.MulRange.Basic +module +public import Aeneas.Data.Range.Notations +public import Aeneas.Data.Range.MulRange.Basic +public section namespace Aeneas.Notations diff --git a/backends/lean/Aeneas/Data/Range/Notations.lean b/backends/lean/Aeneas/Data/Range/Notations.lean index 1629f4c6e..6a0cf3c60 100644 --- a/backends/lean/Aeneas/Data/Range/Notations.lean +++ b/backends/lean/Aeneas/Data/Range/Notations.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +module +public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public section namespace Aeneas.Notations.Range diff --git a/backends/lean/Aeneas/Data/Range/SRRange.lean b/backends/lean/Aeneas/Data/Range/SRRange.lean index cbb7fe788..20eabd3d6 100644 --- a/backends/lean/Aeneas/Data/Range/SRRange.lean +++ b/backends/lean/Aeneas/Data/Range/SRRange.lean @@ -1,3 +1,4 @@ -import Aeneas.Data.Range.SRRange.Basic -import Aeneas.Data.Range.SRRange.Lemmas -import Aeneas.Data.Range.SRRange.Notations +module +public import Aeneas.Data.Range.SRRange.Basic +public import Aeneas.Data.Range.SRRange.Lemmas +public import Aeneas.Data.Range.SRRange.Notations diff --git a/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean b/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean index d827e8a41..1ee48d0a0 100644 --- a/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean +++ b/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean @@ -1,5 +1,7 @@ -import Mathlib.Data.Nat.Basic -import AeneasMeta.Utils +module +public import Mathlib.Data.Nat.Basic +public import AeneasMeta.Utils +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Range/SRRange/Lemmas.lean b/backends/lean/Aeneas/Data/Range/SRRange/Lemmas.lean index db5bf61b8..dad30fa5b 100644 --- a/backends/lean/Aeneas/Data/Range/SRRange/Lemmas.lean +++ b/backends/lean/Aeneas/Data/Range/SRRange/Lemmas.lean @@ -1,7 +1,9 @@ -import Mathlib.Tactic.Ring.RingNF -import Mathlib.Algebra.Order.Sub.Basic -import Aeneas.Data.Range.SRRange.Basic -import Aeneas.Data.List.List +module +public import Mathlib.Tactic.Ring.RingNF +public import Mathlib.Algebra.Order.Sub.Basic +public import Aeneas.Data.Range.SRRange.Basic +public import Aeneas.Data.List.List +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Range/SRRange/Notations.lean b/backends/lean/Aeneas/Data/Range/SRRange/Notations.lean index efb3c5bdc..b4228934c 100644 --- a/backends/lean/Aeneas/Data/Range/SRRange/Notations.lean +++ b/backends/lean/Aeneas/Data/Range/SRRange/Notations.lean @@ -1,5 +1,7 @@ -import Aeneas.Data.Range.Notations -import Aeneas.Data.Range.SRRange.Basic +module +public import Aeneas.Data.Range.Notations +public import Aeneas.Data.Range.SRRange.Basic +public section namespace Aeneas.Notations diff --git a/backends/lean/Aeneas/Data/Tuples.lean b/backends/lean/Aeneas/Data/Tuples.lean index be9232896..7ecbd6ee1 100644 --- a/backends/lean/Aeneas/Data/Tuples.lean +++ b/backends/lean/Aeneas/Data/Tuples.lean @@ -1,5 +1,7 @@ -import Lean -import AeneasMeta.Utils +module +public import Lean +public import AeneasMeta.Utils +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Data/Vector.lean b/backends/lean/Aeneas/Data/Vector.lean index 42118e3bb..bf260fb31 100644 --- a/backends/lean/Aeneas/Data/Vector.lean +++ b/backends/lean/Aeneas/Data/Vector.lean @@ -1,4 +1,6 @@ -import Aeneas.Data.Array +module +public import Aeneas.Data.Array +public section namespace Vector diff --git a/backends/lean/Aeneas/Do.lean b/backends/lean/Aeneas/Do.lean index 8cd4a8403..b304455e5 100644 --- a/backends/lean/Aeneas/Do.lean +++ b/backends/lean/Aeneas/Do.lean @@ -1,3 +1,4 @@ -import Aeneas.Do.Delab -import Aeneas.Do.Elab -import Aeneas.Do.Tests +module +public import Aeneas.Do.Delab +public import Aeneas.Do.Elab +public import Aeneas.Do.Tests diff --git a/backends/lean/Aeneas/Do/Delab.lean b/backends/lean/Aeneas/Do/Delab.lean index 50e22ba33..b5e85fd6a 100644 --- a/backends/lean/Aeneas/Do/Delab.lean +++ b/backends/lean/Aeneas/Do/Delab.lean @@ -1,6 +1,8 @@ -import Lean -import Aeneas.Do.Elab -import Aeneas.Std.Delab +module +public import Lean +public import Aeneas.Do.Elab +public import Aeneas.Std.Delab +public section /-! # Delaborator for new `do` pattern matching logic -/ diff --git a/backends/lean/Aeneas/Do/Elab.lean b/backends/lean/Aeneas/Do/Elab.lean index f717e4b6b..22dc8f3ee 100644 --- a/backends/lean/Aeneas/Do/Elab.lean +++ b/backends/lean/Aeneas/Do/Elab.lean @@ -1,6 +1,8 @@ -import Lean -import Mathlib.Control.Monad.Cont -import Aeneas.Std +module +public import Lean +public import Mathlib.Control.Monad.Cont +public import Aeneas.Std +public section /-! # New `do` Elaborator diff --git a/backends/lean/Aeneas/Do/Tests.lean b/backends/lean/Aeneas/Do/Tests.lean index f34c136e8..9352f7098 100644 --- a/backends/lean/Aeneas/Do/Tests.lean +++ b/backends/lean/Aeneas/Do/Tests.lean @@ -1,6 +1,8 @@ -import Aeneas.Do.Elab -import Aeneas.Do.Delab -import Aeneas.Std +module +public import Aeneas.Do.Elab +public import Aeneas.Do.Delab +public import Aeneas.Std +public section namespace Do namespace Tests diff --git a/backends/lean/Aeneas/Extract.lean b/backends/lean/Aeneas/Extract.lean index b8b885685..493c37708 100644 --- a/backends/lean/Aeneas/Extract.lean +++ b/backends/lean/Aeneas/Extract.lean @@ -1 +1,2 @@ -import Aeneas.Extract.Extract +module +public import Aeneas.Extract.Extract diff --git a/backends/lean/Aeneas/Extract/Extract.lean b/backends/lean/Aeneas/Extract/Extract.lean index 377130a8d..d6354c24b 100644 --- a/backends/lean/Aeneas/Extract/Extract.lean +++ b/backends/lean/Aeneas/Extract/Extract.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Extensions +module +public import AeneasMeta.Extensions +public section /-! Helpers to provide informations about the models for the Rust standard library -/ open Lean diff --git a/backends/lean/Aeneas/Std.lean b/backends/lean/Aeneas/Std.lean index 9bb253180..1fc483d62 100644 --- a/backends/lean/Aeneas/Std.lean +++ b/backends/lean/Aeneas/Std.lean @@ -1,18 +1,19 @@ -import Aeneas.Std.Alloc -import Aeneas.Std.Array -import Aeneas.Std.Core -import Aeneas.Std.Primitives -import Aeneas.Std.PrimitivesLemmas -import Aeneas.Std.RawPtr -import Aeneas.Std.Scalar -import Aeneas.Std.Slice -import Aeneas.Std.SliceDef -import Aeneas.Std.SliceIter -import Aeneas.Std.Std -import Aeneas.Std.String -import Aeneas.Std.StringDef -import Aeneas.Std.StringIter -import Aeneas.Std.Vec -import Aeneas.Std.VecIter -import Aeneas.Data.Tuples -import Aeneas.Std.RangeIter +module +public import Aeneas.Std.Alloc +public import Aeneas.Std.Array +public import Aeneas.Std.Core +public import Aeneas.Std.Primitives +public import Aeneas.Std.PrimitivesLemmas +public import Aeneas.Std.RawPtr +public import Aeneas.Std.Scalar +public import Aeneas.Std.Slice +public import Aeneas.Std.SliceDef +public import Aeneas.Std.SliceIter +public import Aeneas.Std.Std +public import Aeneas.Std.String +public import Aeneas.Std.StringDef +public import Aeneas.Std.StringIter +public import Aeneas.Std.Vec +public import Aeneas.Std.VecIter +public import Aeneas.Data.Tuples +public import Aeneas.Std.RangeIter diff --git a/backends/lean/Aeneas/Std/Alloc.lean b/backends/lean/Aeneas/Std/Alloc.lean index e11492cd5..956ad4f1f 100644 --- a/backends/lean/Aeneas/Std/Alloc.lean +++ b/backends/lean/Aeneas/Std/Alloc.lean @@ -1,6 +1,8 @@ -import Lean -import Aeneas.Extract -import Aeneas.Std.Primitives +module +public import Lean +public import Aeneas.Extract +public import Aeneas.Std.Primitives +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/Array.lean b/backends/lean/Aeneas/Std/Array.lean index aec41b73e..ace0a7553 100644 --- a/backends/lean/Aeneas/Std/Array.lean +++ b/backends/lean/Aeneas/Std/Array.lean @@ -1,4 +1,5 @@ -import Aeneas.Std.Array.Array -import Aeneas.Std.Array.ArraySlice -import Aeneas.Std.Array.ArrayDebug -import Aeneas.Std.Array.Core +module +public import Aeneas.Std.Array.Array +public import Aeneas.Std.Array.ArraySlice +public import Aeneas.Std.Array.ArrayDebug +public import Aeneas.Std.Array.Core diff --git a/backends/lean/Aeneas/Std/Array/Array.lean b/backends/lean/Aeneas/Std/Array/Array.lean index 32b402354..9aeeacb9a 100644 --- a/backends/lean/Aeneas/Std/Array/Array.lean +++ b/backends/lean/Aeneas/Std/Array/Array.lean @@ -1,8 +1,10 @@ /- Arrays -/ -import Aeneas.Data.List -import Aeneas.Tactic.Step.Init -import Aeneas.Std.Array.Core -import Aeneas.Std.Core.Default +module +public import Aeneas.Data.List +public import Aeneas.Tactic.Step.Init +public import Aeneas.Std.Array.Core +public import Aeneas.Std.Core.Default +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Array/ArrayDebug.lean b/backends/lean/Aeneas/Std/Array/ArrayDebug.lean index 453f0140d..78539baf7 100644 --- a/backends/lean/Aeneas/Std/Array/ArrayDebug.lean +++ b/backends/lean/Aeneas/Std/Array/ArrayDebug.lean @@ -1,6 +1,8 @@ /- Arrays -/ -import Aeneas.Std.Array.Array -import Aeneas.Std.Core.Fmt +module +public import Aeneas.Std.Array.Array +public import Aeneas.Std.Core.Fmt +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Array/ArraySlice.lean b/backends/lean/Aeneas/Std/Array/ArraySlice.lean index 32b7f7417..3a3f5322f 100644 --- a/backends/lean/Aeneas/Std/Array/ArraySlice.lean +++ b/backends/lean/Aeneas/Std/Array/ArraySlice.lean @@ -1,10 +1,12 @@ -import Aeneas.Std.Core.Fmt -import Aeneas.Std.Array.Array -import Aeneas.Std.Slice -import Aeneas.Std.Range -import Aeneas.Data.List.List -import Aeneas.Std.Core.Convert -import Aeneas.Std.Core.Cmp +module +public import Aeneas.Std.Core.Fmt +public import Aeneas.Std.Array.Array +public import Aeneas.Std.Slice +public import Aeneas.Std.Range +public import Aeneas.Data.List.List +public import Aeneas.Std.Core.Convert +public import Aeneas.Std.Core.Cmp +public section /-! Array definitions which mention slices -/ diff --git a/backends/lean/Aeneas/Std/Array/Core.lean b/backends/lean/Aeneas/Std/Array/Core.lean index 9d2cdf044..e11490489 100644 --- a/backends/lean/Aeneas/Std/Array/Core.lean +++ b/backends/lean/Aeneas/Std/Array/Core.lean @@ -1,6 +1,8 @@ /- Arrays/Slices -/ -import Aeneas.Std.Scalar.Core -import Aeneas.Data.List.List +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Data.List.List +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core.lean b/backends/lean/Aeneas/Std/Core.lean index 39b9f5340..5babb1473 100644 --- a/backends/lean/Aeneas/Std/Core.lean +++ b/backends/lean/Aeneas/Std/Core.lean @@ -1,18 +1,19 @@ -import Aeneas.Std.Core.Atomic -import Aeneas.Std.Core.Cmp -import Aeneas.Std.Core.Convert -import Aeneas.Std.Core.Core -import Aeneas.Std.Core.CoreOption -import Aeneas.Std.Core.Default -import Aeneas.Std.Core.Discriminant -import Aeneas.Std.Core.Error -import Aeneas.Std.Core.Fmt -import Aeneas.Std.Core.FmtWithSlice -import Aeneas.Std.Core.Hash -import Aeneas.Std.Core.Iter -import Aeneas.Std.Core.Marker -import Aeneas.Std.Core.Ops -import Aeneas.Std.Core.Panic -import Aeneas.Std.Core.Pin -import Aeneas.Std.Core.Ptr -import Aeneas.Std.Core.Result +module +public import Aeneas.Std.Core.Atomic +public import Aeneas.Std.Core.Cmp +public import Aeneas.Std.Core.Convert +public import Aeneas.Std.Core.Core +public import Aeneas.Std.Core.CoreOption +public import Aeneas.Std.Core.Default +public import Aeneas.Std.Core.Discriminant +public import Aeneas.Std.Core.Error +public import Aeneas.Std.Core.Fmt +public import Aeneas.Std.Core.FmtWithSlice +public import Aeneas.Std.Core.Hash +public import Aeneas.Std.Core.Iter +public import Aeneas.Std.Core.Marker +public import Aeneas.Std.Core.Ops +public import Aeneas.Std.Core.Panic +public import Aeneas.Std.Core.Pin +public import Aeneas.Std.Core.Ptr +public import Aeneas.Std.Core.Result diff --git a/backends/lean/Aeneas/Std/Core/Atomic.lean b/backends/lean/Aeneas/Std/Core/Atomic.lean index d686f3154..aa1b3c60f 100644 --- a/backends/lean/Aeneas/Std/Core/Atomic.lean +++ b/backends/lean/Aeneas/Std/Core/Atomic.lean @@ -1,4 +1,6 @@ -import Aeneas.Extract +module +public import Aeneas.Extract +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Cmp.lean b/backends/lean/Aeneas/Std/Core/Cmp.lean index f955cdeed..13ee214b1 100644 --- a/backends/lean/Aeneas/Std/Core/Cmp.lean +++ b/backends/lean/Aeneas/Std/Core/Cmp.lean @@ -1,8 +1,10 @@ -import Aeneas.Extract -import Aeneas.Std.Primitives -import Aeneas.Std.WP -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Elab.TraitDefault.Init +module +public import Aeneas.Extract +public import Aeneas.Std.Primitives +public import Aeneas.Std.WP +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Elab.TraitDefault.Init +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Convert.lean b/backends/lean/Aeneas/Std/Core/Convert.lean index bdcdca1ac..17380eca7 100644 --- a/backends/lean/Aeneas/Std/Core/Convert.lean +++ b/backends/lean/Aeneas/Std/Core/Convert.lean @@ -1,7 +1,9 @@ -import Aeneas.Std.Core.Core -import Aeneas.Std.Core.Result -import Aeneas.Std.Core.Ops -import Aeneas.Tactic.Step.Init +module +public import Aeneas.Std.Core.Core +public import Aeneas.Std.Core.Result +public import Aeneas.Std.Core.Ops +public import Aeneas.Tactic.Step.Init +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Core.lean b/backends/lean/Aeneas/Std/Core/Core.lean index 52ee1e605..893f3b8be 100644 --- a/backends/lean/Aeneas/Std/Core/Core.lean +++ b/backends/lean/Aeneas/Std/Core/Core.lean @@ -1,8 +1,10 @@ -import Lean -import Aeneas.Std.Primitives -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Elab.TraitDefault.Init -import Aeneas.Std.Alloc +module +public import Lean +public import Aeneas.Std.Primitives +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Elab.TraitDefault.Init +public import Aeneas.Std.Alloc +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/Core/CoreOption.lean b/backends/lean/Aeneas/Std/Core/CoreOption.lean index 5a22429d7..23a78020e 100644 --- a/backends/lean/Aeneas/Std/Core/CoreOption.lean +++ b/backends/lean/Aeneas/Std/Core/CoreOption.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Core.Core -import Aeneas.Std.String +module +public import Aeneas.Std.Core.Core +public import Aeneas.Std.String +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Default.lean b/backends/lean/Aeneas/Std/Core/Default.lean index a4d55bc3b..d6fcda33b 100644 --- a/backends/lean/Aeneas/Std/Core/Default.lean +++ b/backends/lean/Aeneas/Std/Core/Default.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Primitives +module +public import Aeneas.Std.Primitives +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Discriminant.lean b/backends/lean/Aeneas/Std/Core/Discriminant.lean index cb8b0e383..530c41ea1 100644 --- a/backends/lean/Aeneas/Std/Core/Discriminant.lean +++ b/backends/lean/Aeneas/Std/Core/Discriminant.lean @@ -1,7 +1,9 @@ -import Aeneas.Std.Core.Core -import Aeneas.Std.Core.Fmt -import Aeneas.Std.Core.Cmp -import Aeneas.Std.Core.Hash +module +public import Aeneas.Std.Core.Core +public import Aeneas.Std.Core.Fmt +public import Aeneas.Std.Core.Cmp +public import Aeneas.Std.Core.Hash +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Error.lean b/backends/lean/Aeneas/Std/Core/Error.lean index 62d6350f9..a9b6052b3 100644 --- a/backends/lean/Aeneas/Std/Core/Error.lean +++ b/backends/lean/Aeneas/Std/Core/Error.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Core.Fmt +module +public import Aeneas.Std.Core.Fmt +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Fmt.lean b/backends/lean/Aeneas/Std/Core/Fmt.lean index e681e35a2..159dc501b 100644 --- a/backends/lean/Aeneas/Std/Core/Fmt.lean +++ b/backends/lean/Aeneas/Std/Core/Fmt.lean @@ -1,7 +1,9 @@ -import Aeneas.Std.Core.Core -import Aeneas.Std.Core.Result -import Aeneas.Std.Array.Array -import Aeneas.Std.StringDef +module +public import Aeneas.Std.Core.Core +public import Aeneas.Std.Core.Result +public import Aeneas.Std.Array.Array +public import Aeneas.Std.StringDef +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/FmtWithSlice.lean b/backends/lean/Aeneas/Std/Core/FmtWithSlice.lean index c6cac0bc6..9d382d4f1 100644 --- a/backends/lean/Aeneas/Std/Core/FmtWithSlice.lean +++ b/backends/lean/Aeneas/Std/Core/FmtWithSlice.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Slice -import Aeneas.Std.Core.Fmt -import Aeneas.Std.String +module +public import Aeneas.Std.Slice +public import Aeneas.Std.Core.Fmt +public import Aeneas.Std.String +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Hash.lean b/backends/lean/Aeneas/Std/Core/Hash.lean index 21c79d108..62e38c8ce 100644 --- a/backends/lean/Aeneas/Std/Core/Hash.lean +++ b/backends/lean/Aeneas/Std/Core/Hash.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Core.Core -import Aeneas.Std.Slice +module +public import Aeneas.Std.Core.Core +public import Aeneas.Std.Slice +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Iter.lean b/backends/lean/Aeneas/Std/Core/Iter.lean index 06c4325c1..32b54ed61 100644 --- a/backends/lean/Aeneas/Std/Core/Iter.lean +++ b/backends/lean/Aeneas/Std/Core/Iter.lean @@ -1,12 +1,14 @@ -import Aeneas.Std.Core.Cmp -import Aeneas.Std.Primitives -import Aeneas.Std.Range -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Notations -import Aeneas.Std.Scalar.CloneCopy -import Aeneas.Std.Scalar.EqOrd -import Aeneas.Std.Scalar.CheckedOps -import Aeneas.Std.Core.Core +module +public import Aeneas.Std.Core.Cmp +public import Aeneas.Std.Primitives +public import Aeneas.Std.Range +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Notations +public import Aeneas.Std.Scalar.CloneCopy +public import Aeneas.Std.Scalar.EqOrd +public import Aeneas.Std.Scalar.CheckedOps +public import Aeneas.Std.Core.Core +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Marker.lean b/backends/lean/Aeneas/Std/Core/Marker.lean index 0888b0328..845b6d180 100644 --- a/backends/lean/Aeneas/Std/Core/Marker.lean +++ b/backends/lean/Aeneas/Std/Core/Marker.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Core.Core +module +public import Aeneas.Std.Core.Core +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Ops.lean b/backends/lean/Aeneas/Std/Core/Ops.lean index 2063c3e3d..58134834d 100644 --- a/backends/lean/Aeneas/Std/Core/Ops.lean +++ b/backends/lean/Aeneas/Std/Core/Ops.lean @@ -1,5 +1,7 @@ -import Lean -import Aeneas.Std.Alloc +module +public import Lean +public import Aeneas.Std.Alloc +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/Core/Panic.lean b/backends/lean/Aeneas/Std/Core/Panic.lean index 9b68b3420..41dbae43e 100644 --- a/backends/lean/Aeneas/Std/Core/Panic.lean +++ b/backends/lean/Aeneas/Std/Core/Panic.lean @@ -1,4 +1,6 @@ -import Aeneas.Extract +module +public import Aeneas.Extract +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Pin.lean b/backends/lean/Aeneas/Std/Core/Pin.lean index 6b9986ee9..0df488ae2 100644 --- a/backends/lean/Aeneas/Std/Core/Pin.lean +++ b/backends/lean/Aeneas/Std/Core/Pin.lean @@ -1,4 +1,6 @@ -import Aeneas.Extract +module +public import Aeneas.Extract +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Ptr.lean b/backends/lean/Aeneas/Std/Core/Ptr.lean index d7207d7f1..7e824e1dd 100644 --- a/backends/lean/Aeneas/Std/Core/Ptr.lean +++ b/backends/lean/Aeneas/Std/Core/Ptr.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Core.Core -import Aeneas.Std.RawPtr +module +public import Aeneas.Std.Core.Core +public import Aeneas.Std.RawPtr +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Result.lean b/backends/lean/Aeneas/Std/Core/Result.lean index e7cd9f5c7..9ff7e2c16 100644 --- a/backends/lean/Aeneas/Std/Core/Result.lean +++ b/backends/lean/Aeneas/Std/Core/Result.lean @@ -1,4 +1,6 @@ -import Aeneas.Extract +module +public import Aeneas.Extract +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Delab.lean b/backends/lean/Aeneas/Std/Delab.lean index 2efc1cd10..b8df08cac 100644 --- a/backends/lean/Aeneas/Std/Delab.lean +++ b/backends/lean/Aeneas/Std/Delab.lean @@ -1,5 +1,7 @@ -import Lean -import Aeneas.Std.Primitives +module +public import Lean +public import Aeneas.Std.Primitives +public section /-! # Shared delaboration helpers for uncurry chains diff --git a/backends/lean/Aeneas/Std/Global.lean b/backends/lean/Aeneas/Std/Global.lean index a2922f2e6..52e111df8 100644 --- a/backends/lean/Aeneas/Std/Global.lean +++ b/backends/lean/Aeneas/Std/Global.lean @@ -1,4 +1,6 @@ -import Lean +module +public import Lean +public section open Lean Meta Meta.Simp namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index e7712225d..dd7ba373d 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -1,7 +1,9 @@ -import Lean -import Aeneas.Std.Global -import Aeneas.Extract -import AeneasMeta.BvEnumToBitVec +module +public import Lean +public import Aeneas.Std.Global +public import Aeneas.Extract +public import AeneasMeta.BvEnumToBitVec +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/PrimitivesLemmas.lean b/backends/lean/Aeneas/Std/PrimitivesLemmas.lean index 079f45dd3..663e7f8e7 100644 --- a/backends/lean/Aeneas/Std/PrimitivesLemmas.lean +++ b/backends/lean/Aeneas/Std/PrimitivesLemmas.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Primitives -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Conv.Bvify.Init +module +public import Aeneas.Std.Primitives +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Conv.Bvify.Init +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Range.lean b/backends/lean/Aeneas/Std/Range.lean index 14f63a663..015631bf2 100644 --- a/backends/lean/Aeneas/Std/Range.lean +++ b/backends/lean/Aeneas/Std/Range.lean @@ -1,11 +1,13 @@ /- Arrays/slices -/ -import Lean -import Lean.Meta.Tactic.Simp -import Init.Data.List.Basic -import Mathlib.Tactic.Linarith -import Aeneas.Std.Scalar.Core -import Aeneas.Tactic.Solver.ScalarTac -import Aeneas.Tactic.Step.Init +module +public import Lean +public import Lean.Meta.Tactic.Simp +public import Init.Data.List.Basic +public import Mathlib.Tactic.Linarith +public import Aeneas.Std.Scalar.Core +public import Aeneas.Tactic.Solver.ScalarTac +public import Aeneas.Tactic.Step.Init +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/RangeIter.lean b/backends/lean/Aeneas/Std/RangeIter.lean index 3771dcb4e..ee96b540d 100644 --- a/backends/lean/Aeneas/Std/RangeIter.lean +++ b/backends/lean/Aeneas/Std/RangeIter.lean @@ -1,8 +1,10 @@ /- Step specs for Range/StepBy iterators on Usize. These use WP.spec_bind directly to avoid importing the step tactic. -/ -import Aeneas.Std.Core.Iter -import Aeneas.Std.Scalar -import Aeneas.Std.SliceIter +module +public import Aeneas.Std.Core.Iter +public import Aeneas.Std.Scalar +public import Aeneas.Std.SliceIter +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/RawPtr.lean b/backends/lean/Aeneas/Std/RawPtr.lean index ebe8e092c..79de0729e 100644 --- a/backends/lean/Aeneas/Std/RawPtr.lean +++ b/backends/lean/Aeneas/Std/RawPtr.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Scalar.Core +module +public import Aeneas.Std.Scalar.Core +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar.lean b/backends/lean/Aeneas/Std/Scalar.lean index 20b82839e..5c6f38794 100644 --- a/backends/lean/Aeneas/Std/Scalar.lean +++ b/backends/lean/Aeneas/Std/Scalar.lean @@ -1,20 +1,21 @@ -import Aeneas.Std.Scalar.Bitwise -import Aeneas.Std.Scalar.BvComp -import Aeneas.Std.Scalar.Casts -import Aeneas.Std.Scalar.CheckedOps -import Aeneas.Std.Scalar.CloneCopy -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.CoreConvertNum -import Aeneas.Std.Scalar.Default -import Aeneas.Std.Scalar.Display -import Aeneas.Std.Scalar.EqOrd -import Aeneas.Std.Scalar.Fmt -import Aeneas.Std.Scalar.LeadingZeros -import Aeneas.Std.Scalar.Misc -import Aeneas.Std.Scalar.Notations -import Aeneas.Std.Scalar.Ops -import Aeneas.Std.Scalar.OverflowingOps -import Aeneas.Std.Scalar.Pow -import Aeneas.Std.Scalar.Rotate -import Aeneas.Std.Scalar.SaturatingOps -import Aeneas.Std.Scalar.WrappingOps +module +public import Aeneas.Std.Scalar.Bitwise +public import Aeneas.Std.Scalar.BvComp +public import Aeneas.Std.Scalar.Casts +public import Aeneas.Std.Scalar.CheckedOps +public import Aeneas.Std.Scalar.CloneCopy +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.CoreConvertNum +public import Aeneas.Std.Scalar.Default +public import Aeneas.Std.Scalar.Display +public import Aeneas.Std.Scalar.EqOrd +public import Aeneas.Std.Scalar.Fmt +public import Aeneas.Std.Scalar.LeadingZeros +public import Aeneas.Std.Scalar.Misc +public import Aeneas.Std.Scalar.Notations +public import Aeneas.Std.Scalar.Ops +public import Aeneas.Std.Scalar.OverflowingOps +public import Aeneas.Std.Scalar.Pow +public import Aeneas.Std.Scalar.Rotate +public import Aeneas.Std.Scalar.SaturatingOps +public import Aeneas.Std.Scalar.WrappingOps diff --git a/backends/lean/Aeneas/Std/Scalar/Bitwise.lean b/backends/lean/Aeneas/Std/Scalar/Bitwise.lean index c3e7821c3..33e9bebe4 100644 --- a/backends/lean/Aeneas/Std/Scalar/Bitwise.lean +++ b/backends/lean/Aeneas/Std/Scalar/Bitwise.lean @@ -1,7 +1,9 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/BvComp.lean b/backends/lean/Aeneas/Std/Scalar/BvComp.lean index d95679d05..2dceb64e0 100644 --- a/backends/lean/Aeneas/Std/Scalar/BvComp.lean +++ b/backends/lean/Aeneas/Std/Scalar/BvComp.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Scalar.Core +module +public import Aeneas.Std.Scalar.Core +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Casts.lean b/backends/lean/Aeneas/Std/Scalar/Casts.lean index 9ddacfc03..24465432a 100644 --- a/backends/lean/Aeneas/Std/Scalar/Casts.lean +++ b/backends/lean/Aeneas/Std/Scalar/Casts.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/CheckedOps.lean b/backends/lean/Aeneas/Std/Scalar/CheckedOps.lean index a33a03f72..c78265439 100644 --- a/backends/lean/Aeneas/Std/Scalar/CheckedOps.lean +++ b/backends/lean/Aeneas/Std/Scalar/CheckedOps.lean @@ -1,5 +1,6 @@ -import Aeneas.Std.Scalar.CheckedOps.Add -import Aeneas.Std.Scalar.CheckedOps.Div -import Aeneas.Std.Scalar.CheckedOps.Mul -import Aeneas.Std.Scalar.CheckedOps.Rem -import Aeneas.Std.Scalar.CheckedOps.Sub +module +public import Aeneas.Std.Scalar.CheckedOps.Add +public import Aeneas.Std.Scalar.CheckedOps.Div +public import Aeneas.Std.Scalar.CheckedOps.Mul +public import Aeneas.Std.Scalar.CheckedOps.Rem +public import Aeneas.Std.Scalar.CheckedOps.Sub diff --git a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Add.lean b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Add.lean index 8bf6c9a9d..69752d66c 100644 --- a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Add.lean +++ b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Add.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Ops.Add -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Ops.Add +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Div.lean b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Div.lean index 08b792f25..78005628b 100644 --- a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Div.lean +++ b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Div.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Ops.Div -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Ops.Div +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Mul.lean b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Mul.lean index 45988ed41..4bb6be15c 100644 --- a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Mul.lean +++ b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Mul.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Ops.Mul -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Ops.Mul +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Rem.lean b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Rem.lean index 743ce092e..5e1514031 100644 --- a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Rem.lean +++ b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Rem.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Ops.Rem -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Ops.Rem +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Sub.lean b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Sub.lean index 8e7a316fc..72eafb11d 100644 --- a/backends/lean/Aeneas/Std/Scalar/CheckedOps/Sub.lean +++ b/backends/lean/Aeneas/Std/Scalar/CheckedOps/Sub.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Ops.Sub -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Ops.Sub +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean b/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean index da58fafc6..bfdc9c26b 100644 --- a/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean +++ b/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Core.lean b/backends/lean/Aeneas/Std/Scalar/Core.lean index 831484534..91cefac0e 100644 --- a/backends/lean/Aeneas/Std/Scalar/Core.lean +++ b/backends/lean/Aeneas/Std/Scalar/Core.lean @@ -1,13 +1,15 @@ -import Lean -import Lean.Meta.Tactic.Simp -import Aeneas.Std.Core.Core -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Solver.ScalarTac.ScalarTac -import Aeneas.Tactic.Conv.Bvify.Init -import Aeneas.Data.Nat -import Aeneas.Data.Int -import Aeneas.Tactic.Simp.SimpLists.Init -import AeneasMeta.BvEnumToBitVec +module +public import Lean +public import Lean.Meta.Tactic.Simp +public import Aeneas.Std.Core.Core +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public import Aeneas.Tactic.Conv.Bvify.Init +public import Aeneas.Data.Nat +public import Aeneas.Data.Int +public import Aeneas.Tactic.Simp.SimpLists.Init +public import AeneasMeta.BvEnumToBitVec +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean b/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean index fac90e77e..63f69819d 100644 --- a/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean +++ b/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean @@ -1,17 +1,19 @@ -import Lean -import Lean.Meta.Tactic.Simp -import Init.Data.List.Basic -import Mathlib.Tactic.Linarith -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Notations -import Aeneas.Std.Scalar.Elab -import Aeneas.Std.Scalar.Casts -import Aeneas.Std.Core.Result -import Aeneas.Std.Array.Array -import Aeneas.Tactic.Solver.ScalarTac -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Solver.Arith.Lemmas -import Aeneas.Data.BitVec +module +public import Lean +public import Lean.Meta.Tactic.Simp +public import Init.Data.List.Basic +public import Mathlib.Tactic.Linarith +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Notations +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Std.Scalar.Casts +public import Aeneas.Std.Core.Result +public import Aeneas.Std.Array.Array +public import Aeneas.Tactic.Solver.ScalarTac +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Solver.Arith.Lemmas +public import Aeneas.Data.BitVec +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/Scalar/Default.lean b/backends/lean/Aeneas/Std/Scalar/Default.lean index c1eb33b2e..dda6072cd 100644 --- a/backends/lean/Aeneas/Std/Scalar/Default.lean +++ b/backends/lean/Aeneas/Std/Scalar/Default.lean @@ -1,7 +1,9 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Aeneas.Std.Core.Default -import Aeneas.Std.Scalar.Notations +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Std.Core.Default +public import Aeneas.Std.Scalar.Notations +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Display.lean b/backends/lean/Aeneas/Std/Scalar/Display.lean index 952ea4e3e..2a707cd25 100644 --- a/backends/lean/Aeneas/Std/Scalar/Display.lean +++ b/backends/lean/Aeneas/Std/Scalar/Display.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Core.Fmt +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Core.Fmt +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Elab.lean b/backends/lean/Aeneas/Std/Scalar/Elab.lean index b594ced13..85889297c 100644 --- a/backends/lean/Aeneas/Std/Scalar/Elab.lean +++ b/backends/lean/Aeneas/Std/Scalar/Elab.lean @@ -1,4 +1,7 @@ -import Lean +module +public import Lean +public meta import Lean.Elab.Declaration +public section namespace Aeneas.Std.ScalarElab @@ -49,7 +52,7 @@ with either "U8", or "U16", etc. -/ -def isSubstring (sub str : List Char) : Option (List Char) := +meta def isSubstring (sub str : List Char) : Option (List Char) := match sub, str with | [], _ => some str | hd :: sub, hd' :: str => @@ -57,7 +60,7 @@ def isSubstring (sub str : List Char) : Option (List Char) := else none | _, _ => none -partial def elabString (ty : String) (str : String) : String := +meta partial def elabString (ty : String) (str : String) : String := let rec replace (str : List Char) : List Char := match isSubstring "'S".toList str with | some str => ty.toList ++ replace str @@ -67,7 +70,7 @@ partial def elabString (ty : String) (str : String) : String := | c :: str => c :: replace str String.ofList (replace str.toList) -def elabSpecialName (ty : String) (n : Name) : CommandElabM Name := do +meta def elabSpecialName (ty : String) (n : Name) : CommandElabM Name := do trace[ScalarElabSubst] "elabSpecialName: {n}" match n with | .anonymous => pure .anonymous @@ -77,7 +80,7 @@ def elabSpecialName (ty : String) (n : Name) : CommandElabM Name := do pure (.str (← elabSpecialName ty pre) str) | .num pre i => pure (.num (← elabSpecialName ty pre) i) -partial def elabSpecial (ty : String) (bw size : Syntax) (stx : Syntax) : CommandElabM Syntax := do +meta partial def elabSpecial (ty : String) (bw size : Syntax) (stx : Syntax) : CommandElabM Syntax := do trace[ScalarElabSubst] "elabSpecial: stx: {stx}" match stx with | .missing => pure .missing @@ -101,7 +104,7 @@ partial def elabSpecial (ty : String) (bw size : Syntax) (stx : Syntax) : Comman let val ← elabSpecialName ty val pure (.ident info rawVal val preresolved) -def elabCommand (tysBws : List (String × Syntax × Syntax)) (cmd : TSyntax `command) : CommandElabM Unit := do +meta def elabCommand (tysBws : List (String × Syntax × Syntax)) (cmd : TSyntax `command) : CommandElabM Unit := do let elabOne (tyBw : String × Syntax × Syntax) : CommandElabM Unit := do let (ty, bw, size) := tyBw ---let cmd0 := cmd @@ -118,7 +121,7 @@ scoped syntax "%Size" : term scoped syntax (name := uscalarCommand) "uscalar" command : command @[command_elab uscalarCommand] -def uscalarCommandImpl : CommandElab := fun stx => do +meta def uscalarCommandImpl : CommandElab := fun stx => do trace[ScalarElab] "uscalar_command (stx): {stx}" match stx with | `(uscalarCommand| uscalar $cmd) => @@ -130,7 +133,7 @@ def uscalarCommandImpl : CommandElab := fun stx => do scoped syntax (name := uscalarNoUsizeCommand) "uscalar_no_usize" command : command @[command_elab uscalarNoUsizeCommand] -def uscalarNoUsizeCommandImpl : CommandElab := fun stx => do +meta def uscalarNoUsizeCommandImpl : CommandElab := fun stx => do trace[ScalarElab] "uscalar_no_usize_command (stx): {stx}" match stx with | `(uscalarNoUsizeCommand| uscalar_no_usize $cmd) => @@ -141,7 +144,7 @@ def uscalarNoUsizeCommandImpl : CommandElab := fun stx => do scoped syntax (name := iscalarCommand) "iscalar" command : command @[command_elab iscalarCommand] -def iscalarCommandImpl : CommandElab := fun stx => do +meta def iscalarCommandImpl : CommandElab := fun stx => do trace[ScalarElab] "iscalar_command (stx): {stx}" match stx with | `(iscalarCommand| iscalar $cmd) => @@ -153,7 +156,7 @@ def iscalarCommandImpl : CommandElab := fun stx => do scoped syntax (name := iscalarNoIsizeCommand) "iscalar_no_isize" command : command @[command_elab iscalarNoIsizeCommand] -def iscalarNoIsizeNoIsizeCommandImpl : CommandElab := fun stx => do +meta def iscalarNoIsizeNoIsizeCommandImpl : CommandElab := fun stx => do trace[ScalarElab] "iscalar_no_usize_command (stx): {stx}" match stx with | `(iscalarNoIsizeCommand| iscalar_no_isize $cmd) => @@ -164,7 +167,7 @@ def iscalarNoIsizeNoIsizeCommandImpl : CommandElab := fun stx => do scoped syntax (name := scalarCommand) "scalar" command : command @[command_elab scalarCommand] -def scalarCommandImpl : CommandElab := fun stx => do +meta def scalarCommandImpl : CommandElab := fun stx => do trace[ScalarElab] "scalar_command (stx): {stx}" match stx with | `(scalarCommand| scalar $cmd) => diff --git a/backends/lean/Aeneas/Std/Scalar/EqOrd.lean b/backends/lean/Aeneas/Std/Scalar/EqOrd.lean index 35251aa7f..346300349 100644 --- a/backends/lean/Aeneas/Std/Scalar/EqOrd.lean +++ b/backends/lean/Aeneas/Std/Scalar/EqOrd.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Aeneas.Std.Core.Cmp +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Std.Core.Cmp +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Fmt.lean b/backends/lean/Aeneas/Std/Scalar/Fmt.lean index c856f6b47..0872610ee 100644 --- a/backends/lean/Aeneas/Std/Scalar/Fmt.lean +++ b/backends/lean/Aeneas/Std/Scalar/Fmt.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Core.Fmt +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Core.Fmt +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean b/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean index 2fc31d0ed..bcd61feca 100644 --- a/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean +++ b/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Mathlib.Data.Nat.Log +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Mathlib.Data.Nat.Log +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Misc.lean b/backends/lean/Aeneas/Std/Scalar/Misc.lean index e1734c00f..de0360e50 100644 --- a/backends/lean/Aeneas/Std/Scalar/Misc.lean +++ b/backends/lean/Aeneas/Std/Scalar/Misc.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Notations.lean b/backends/lean/Aeneas/Std/Scalar/Notations.lean index f8b068e3e..30d0ffb83 100644 --- a/backends/lean/Aeneas/Std/Scalar/Notations.lean +++ b/backends/lean/Aeneas/Std/Scalar/Notations.lean @@ -1,9 +1,11 @@ -import Lean -import Lean.Meta.Tactic.Simp -import Mathlib.Tactic.Linarith -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Ops.Add -- we need to use addition in some of the tests below -import Aeneas.Tactic.Solver.ScalarTac +module +public import Lean +public import Lean.Meta.Tactic.Simp +public import Mathlib.Tactic.Linarith +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Ops.Add -- we need to use addition in some of the tests below +public import Aeneas.Tactic.Solver.ScalarTac +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/Scalar/Ops.lean b/backends/lean/Aeneas/Std/Scalar/Ops.lean index 5cc473da0..9e34259bc 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops.lean @@ -1,6 +1,7 @@ -import Aeneas.Std.Scalar.Ops.Add -import Aeneas.Std.Scalar.Ops.Div -import Aeneas.Std.Scalar.Ops.Mul -import Aeneas.Std.Scalar.Ops.Neg -import Aeneas.Std.Scalar.Ops.Rem -import Aeneas.Std.Scalar.Ops.Sub +module +public import Aeneas.Std.Scalar.Ops.Add +public import Aeneas.Std.Scalar.Ops.Div +public import Aeneas.Std.Scalar.Ops.Mul +public import Aeneas.Std.Scalar.Ops.Neg +public import Aeneas.Std.Scalar.Ops.Rem +public import Aeneas.Std.Scalar.Ops.Sub diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Add.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Add.lean index a4e909a1c..40f6ea5fe 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Add.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Add.lean @@ -1,8 +1,10 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Misc -import Aeneas.Std.Scalar.Elab -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Misc +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean index 682a0dddd..28da617c5 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean @@ -1,8 +1,10 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Misc -import Aeneas.Std.Scalar.Elab -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Misc +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Mul.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Mul.lean index fc1ab6f61..42fcb34fc 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Mul.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Mul.lean @@ -1,9 +1,11 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Misc -import Aeneas.Std.Scalar.Elab -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec -import Mathlib.Data.Int.Init +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Misc +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public import Mathlib.Data.Int.Init +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Neg.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Neg.lean index 6b72d5ada..508439e42 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Neg.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Neg.lean @@ -1,8 +1,10 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Misc -import Aeneas.Std.Scalar.Elab -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Misc +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean index 460262a56..5ccb7ef08 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean @@ -1,8 +1,10 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Misc -import Aeneas.Std.Scalar.Elab -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Misc +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Sub.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Sub.lean index 060181a6c..e9764bbf2 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Sub.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Sub.lean @@ -1,8 +1,10 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Misc -import Aeneas.Std.Scalar.Elab -import Aeneas.Tactic.Solver.ScalarTac -import Mathlib.Data.BitVec +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Misc +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Tactic.Solver.ScalarTac +public import Mathlib.Data.BitVec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/OverflowingOps.lean b/backends/lean/Aeneas/Std/Scalar/OverflowingOps.lean index 763891332..eda072f3a 100644 --- a/backends/lean/Aeneas/Std/Scalar/OverflowingOps.lean +++ b/backends/lean/Aeneas/Std/Scalar/OverflowingOps.lean @@ -1,4 +1,5 @@ -import Aeneas.Std.Scalar.OverflowingOps.Add -import Aeneas.Std.Scalar.OverflowingOps.Sub -import Aeneas.Std.Scalar.OverflowingOps.Mul -import Aeneas.Std.Scalar.OverflowingOps.Div +module +public import Aeneas.Std.Scalar.OverflowingOps.Add +public import Aeneas.Std.Scalar.OverflowingOps.Sub +public import Aeneas.Std.Scalar.OverflowingOps.Mul +public import Aeneas.Std.Scalar.OverflowingOps.Div diff --git a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Add.lean b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Add.lean index b872aaf41..37effc07d 100644 --- a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Add.lean +++ b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Add.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Aeneas.Std.Scalar.Notations +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Std.Scalar.Notations +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Div.lean b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Div.lean index 6119bd94b..a65f66848 100644 --- a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Div.lean +++ b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Div.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Aeneas.Std.Scalar.Ops +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Std.Scalar.Ops +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Mul.lean b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Mul.lean index 0f4b6be2d..725333733 100644 --- a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Mul.lean +++ b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Mul.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Aeneas.Std.Scalar.Notations +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Std.Scalar.Notations +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Sub.lean b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Sub.lean index db4ed5990..577626490 100644 --- a/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Sub.lean +++ b/backends/lean/Aeneas/Std/Scalar/OverflowingOps/Sub.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab -import Aeneas.Std.Scalar.Notations +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public import Aeneas.Std.Scalar.Notations +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Pow.lean b/backends/lean/Aeneas/Std/Scalar/Pow.lean index 3e48e8b50..c505e99d2 100644 --- a/backends/lean/Aeneas/Std/Scalar/Pow.lean +++ b/backends/lean/Aeneas/Std/Scalar/Pow.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Scalar.Core +module +public import Aeneas.Std.Scalar.Core +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Rotate.lean b/backends/lean/Aeneas/Std/Scalar/Rotate.lean index 398dc2009..e6472eec1 100644 --- a/backends/lean/Aeneas/Std/Scalar/Rotate.lean +++ b/backends/lean/Aeneas/Std/Scalar/Rotate.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/SaturatingOps.lean b/backends/lean/Aeneas/Std/Scalar/SaturatingOps.lean index e0bd93dac..fad4eed08 100644 --- a/backends/lean/Aeneas/Std/Scalar/SaturatingOps.lean +++ b/backends/lean/Aeneas/Std/Scalar/SaturatingOps.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps.lean index 3dfb5f1b3..2be4d0f3c 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps.lean @@ -1,5 +1,6 @@ -import Aeneas.Std.Scalar.WrappingOps.Add -import Aeneas.Std.Scalar.WrappingOps.Mul -import Aeneas.Std.Scalar.WrappingOps.Shl -import Aeneas.Std.Scalar.WrappingOps.Shr -import Aeneas.Std.Scalar.WrappingOps.Sub +module +public import Aeneas.Std.Scalar.WrappingOps.Add +public import Aeneas.Std.Scalar.WrappingOps.Mul +public import Aeneas.Std.Scalar.WrappingOps.Shl +public import Aeneas.Std.Scalar.WrappingOps.Shr +public import Aeneas.Std.Scalar.WrappingOps.Sub diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean index 2b051daaf..e685d1773 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean index 3aacdb0a1..b74e8c4e8 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shl.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shl.lean index b3e9fec1d..133f93116 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shl.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shl.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shr.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shr.lean index 0211b82df..50eace725 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shr.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Shr.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean index 37397ef74..d946c0287 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.Scalar.Elab +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.Scalar.Elab +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Slice.lean b/backends/lean/Aeneas/Std/Slice.lean index 16da42b2a..eaaac1920 100644 --- a/backends/lean/Aeneas/Std/Slice.lean +++ b/backends/lean/Aeneas/Std/Slice.lean @@ -1,11 +1,13 @@ /- Arrays/Slices -/ -import Aeneas.Data.List -import Aeneas.Std.Array.Core -import Aeneas.Std.Range -import Aeneas.Std.Core.Ops -import Aeneas.Std.RawPtr -import Aeneas.Tactic.Simp.SimpScalar.SimpScalar -import Aeneas.Std.SliceDef +module +public import Aeneas.Data.List +public import Aeneas.Std.Array.Core +public import Aeneas.Std.Range +public import Aeneas.Std.Core.Ops +public import Aeneas.Std.RawPtr +public import Aeneas.Tactic.Simp.SimpScalar.SimpScalar +public import Aeneas.Std.SliceDef +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/SliceDef.lean b/backends/lean/Aeneas/Std/SliceDef.lean index ecf5d7051..4b1e80224 100644 --- a/backends/lean/Aeneas/Std/SliceDef.lean +++ b/backends/lean/Aeneas/Std/SliceDef.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Scalar.Core +module +public import Aeneas.Std.Scalar.Core +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/SliceIter.lean b/backends/lean/Aeneas/Std/SliceIter.lean index 51215f384..c78c01ff1 100644 --- a/backends/lean/Aeneas/Std/SliceIter.lean +++ b/backends/lean/Aeneas/Std/SliceIter.lean @@ -1,7 +1,9 @@ /- Arrays/Slices -/ -import Aeneas.Std.Slice -import Aeneas.Std.Array.Array -import Aeneas.Std.Core.Iter +module +public import Aeneas.Std.Slice +public import Aeneas.Std.Array.Array +public import Aeneas.Std.Core.Iter +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Spec.lean b/backends/lean/Aeneas/Std/Spec.lean index 0204383a6..05420f359 100644 --- a/backends/lean/Aeneas/Std/Spec.lean +++ b/backends/lean/Aeneas/Std/Spec.lean @@ -1,5 +1,7 @@ -import Lean -import AeneasMeta.Extensions +module +public import Lean +public import AeneasMeta.Extensions +public section -- import Aeneas.Tactic.Step.Init open Lean Elab Term Meta diff --git a/backends/lean/Aeneas/Std/Std.lean b/backends/lean/Aeneas/Std/Std.lean index eb8a13f68..ea50d934e 100644 --- a/backends/lean/Aeneas/Std/Std.lean +++ b/backends/lean/Aeneas/Std/Std.lean @@ -1 +1,2 @@ -import Aeneas.Std.Std.Io +module +public import Aeneas.Std.Std.Io diff --git a/backends/lean/Aeneas/Std/Std/Io.lean b/backends/lean/Aeneas/Std/Std/Io.lean index c32f89b32..ca8f1fc16 100644 --- a/backends/lean/Aeneas/Std/Std/Io.lean +++ b/backends/lean/Aeneas/Std/Std/Io.lean @@ -1,4 +1,6 @@ -import Aeneas.Std.Core.Fmt +module +public import Aeneas.Std.Core.Fmt +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/String.lean b/backends/lean/Aeneas/Std/String.lean index 5a2ac0024..1ea9b4ae1 100644 --- a/backends/lean/Aeneas/Std/String.lean +++ b/backends/lean/Aeneas/Std/String.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar -import Aeneas.Std.Slice -import Aeneas.Std.StringDef +module +public import Aeneas.Std.Scalar +public import Aeneas.Std.Slice +public import Aeneas.Std.StringDef +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/StringDef.lean b/backends/lean/Aeneas/Std/StringDef.lean index 5c3122192..668336dfc 100644 --- a/backends/lean/Aeneas/Std/StringDef.lean +++ b/backends/lean/Aeneas/Std/StringDef.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Scalar.Core -import Aeneas.Std.SliceDef +module +public import Aeneas.Std.Scalar.Core +public import Aeneas.Std.SliceDef +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/StringIter.lean b/backends/lean/Aeneas/Std/StringIter.lean index 8d2ccefc2..a331112ac 100644 --- a/backends/lean/Aeneas/Std/StringIter.lean +++ b/backends/lean/Aeneas/Std/StringIter.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.String -import Aeneas.Std.Core.Iter -import Aeneas.Std.SliceIter +module +public import Aeneas.Std.String +public import Aeneas.Std.Core.Iter +public import Aeneas.Std.SliceIter +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Vec.lean b/backends/lean/Aeneas/Std/Vec.lean index c58199c4b..992d2287d 100644 --- a/backends/lean/Aeneas/Std/Vec.lean +++ b/backends/lean/Aeneas/Std/Vec.lean @@ -1,11 +1,13 @@ /- Vectors -/ -import Lean -import Lean.Meta.Tactic.Simp -import Init.Data.List.Basic -import Aeneas.Std.Scalar -import Aeneas.Std.Slice -import Aeneas.Tactic.Solver.ScalarTac -import Aeneas.Tactic.Step.Init +module +public import Lean +public import Lean.Meta.Tactic.Simp +public import Init.Data.List.Basic +public import Aeneas.Std.Scalar +public import Aeneas.Std.Slice +public import Aeneas.Tactic.Solver.ScalarTac +public import Aeneas.Tactic.Step.Init +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Std/VecIter.lean b/backends/lean/Aeneas/Std/VecIter.lean index d89b86420..ac8b57d05 100644 --- a/backends/lean/Aeneas/Std/VecIter.lean +++ b/backends/lean/Aeneas/Std/VecIter.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Core.Iter -import Aeneas.Std.Vec +module +public import Aeneas.Std.Core.Iter +public import Aeneas.Std.Vec +public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/WP.lean b/backends/lean/Aeneas/Std/WP.lean index 84b6a8404..5c5d0ea35 100644 --- a/backends/lean/Aeneas/Std/WP.lean +++ b/backends/lean/Aeneas/Std/WP.lean @@ -1,8 +1,10 @@ -import Aeneas.Std.Primitives -import Aeneas.Std.Delab -import Std.Do -import Aeneas.Tactic.Solver.Grind.Init -import Aeneas.Std.Spec +module +public import Aeneas.Std.Primitives +public import Aeneas.Std.Delab +public import Std.Do +public import Aeneas.Tactic.Solver.Grind.Init +public import Aeneas.Std.Spec +public section namespace Aeneas.Std.WP diff --git a/backends/lean/Aeneas/Tactic.lean b/backends/lean/Aeneas/Tactic.lean index fc7a52a9f..5bf51f50c 100644 --- a/backends/lean/Aeneas/Tactic.lean +++ b/backends/lean/Aeneas/Tactic.lean @@ -1,10 +1,11 @@ -import Aeneas.Tactic.Conv -import Aeneas.Tactic.Elab -import Aeneas.Tactic.Misc -import Aeneas.Tactic.RustAttributes -import Aeneas.Tactic.Setup -import Aeneas.Tactic.Simp -import Aeneas.Tactic.Simproc -import Aeneas.Tactic.Solver -import Aeneas.Tactic.Step -import Aeneas.Tactic.Tests +module +public import Aeneas.Tactic.Conv +public import Aeneas.Tactic.Elab +public import Aeneas.Tactic.Misc +public import Aeneas.Tactic.RustAttributes +public import Aeneas.Tactic.Setup +public import Aeneas.Tactic.Simp +public import Aeneas.Tactic.Simproc +public import Aeneas.Tactic.Solver +public import Aeneas.Tactic.Step +public import Aeneas.Tactic.Tests diff --git a/backends/lean/Aeneas/Tactic/Conv.lean b/backends/lean/Aeneas/Tactic/Conv.lean index 099667dda..a674d9775 100644 --- a/backends/lean/Aeneas/Tactic/Conv.lean +++ b/backends/lean/Aeneas/Tactic/Conv.lean @@ -1,4 +1,5 @@ -import Aeneas.Tactic.Conv.Bvify -import Aeneas.Tactic.Conv.Natify -import Aeneas.Tactic.Conv.ZModify -import Aeneas.Tactic.Conv.Zify +module +public import Aeneas.Tactic.Conv.Bvify +public import Aeneas.Tactic.Conv.Natify +public import Aeneas.Tactic.Conv.ZModify +public import Aeneas.Tactic.Conv.Zify diff --git a/backends/lean/Aeneas/Tactic/Conv/Bvify.lean b/backends/lean/Aeneas/Tactic/Conv/Bvify.lean index 17f56b714..9b8228af7 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Bvify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Bvify.lean @@ -1,2 +1,3 @@ -import Aeneas.Tactic.Conv.Bvify.Bvify -import Aeneas.Tactic.Conv.Bvify.Lemmas +module +public import Aeneas.Tactic.Conv.Bvify.Bvify +public import Aeneas.Tactic.Conv.Bvify.Lemmas diff --git a/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean b/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean index da2d80c41..3e91bd17f 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean @@ -1,11 +1,13 @@ -import Aeneas.Tactic.Conv.Bvify.Init -import Aeneas.Tactic.Solver.Arith.Lemmas -import Aeneas.Std.Scalar -import Aeneas.Std.PrimitivesLemmas -import Aeneas.Std.Scalar.CoreConvertNum -- we need this for the tests -import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac -import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp -import Aeneas.Tactic.Solver.Grind.Init +module +public import Aeneas.Tactic.Conv.Bvify.Init +public import Aeneas.Tactic.Solver.Arith.Lemmas +public import Aeneas.Std.Scalar +public import Aeneas.Std.PrimitivesLemmas +public import Aeneas.Std.Scalar.CoreConvertNum -- we need this for the tests +public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +public import Aeneas.Tactic.Solver.Grind.Init +public section /-! # `bvify` tactic diff --git a/backends/lean/Aeneas/Tactic/Conv/Bvify/Init.lean b/backends/lean/Aeneas/Tactic/Conv/Bvify/Init.lean index 12a699021..89fcf88dc 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Bvify/Init.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Bvify/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.Bvify diff --git a/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean b/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean index 484328360..528028f80 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Conv.Bvify.Bvify -import Aeneas.Tactic.Simp.SimpScalar +module +public import Aeneas.Tactic.Conv.Bvify.Bvify +public import Aeneas.Tactic.Simp.SimpScalar +public section @[bvify] theorem BitVec.ofNat_mod_two_pow (n a k : Nat) : diff --git a/backends/lean/Aeneas/Tactic/Conv/Bvify/Tests.lean b/backends/lean/Aeneas/Tactic/Conv/Bvify/Tests.lean index 94164c883..7b9b675f8 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Bvify/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Bvify/Tests.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Conv.Bvify.Bvify -import Aeneas.Std +module +public import Aeneas.Tactic.Conv.Bvify.Bvify +public import Aeneas.Std +public section /-! # bvify regression tests diff --git a/backends/lean/Aeneas/Tactic/Conv/Natify.lean b/backends/lean/Aeneas/Tactic/Conv/Natify.lean index 75abc336d..6ce50c1a9 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Natify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Natify.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Conv.Natify.Natify +module +public import Aeneas.Tactic.Conv.Natify.Natify diff --git a/backends/lean/Aeneas/Tactic/Conv/Natify/Init.lean b/backends/lean/Aeneas/Tactic/Conv/Natify/Init.lean index ddf8f552c..c275ddb18 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Natify/Init.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Natify/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.Natify diff --git a/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean b/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean index c67eafb28..03e1cbaf3 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean @@ -1,12 +1,14 @@ -import Mathlib.Tactic.Basic -import Mathlib.Tactic.Attr.Register -import Mathlib.Data.Int.Cast.Basic -import Mathlib.Order.Basic -import Aeneas.Tactic.Conv.Natify.Init -import Aeneas.Tactic.Solver.Arith.Lemmas -import Aeneas.Std.Scalar.Core -import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp -import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +module +public import Mathlib.Tactic.Basic +public import Mathlib.Tactic.Attr.Register +public import Mathlib.Data.Int.Cast.Basic +public import Mathlib.Order.Basic +public import Aeneas.Tactic.Conv.Natify.Init +public import Aeneas.Tactic.Solver.Arith.Lemmas +public import Aeneas.Std.Scalar.Core +public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public section /-! # `natify` tactic diff --git a/backends/lean/Aeneas/Tactic/Conv/ZModify.lean b/backends/lean/Aeneas/Tactic/Conv/ZModify.lean index 3000dabe0..e354ecb33 100644 --- a/backends/lean/Aeneas/Tactic/Conv/ZModify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/ZModify.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Conv.ZModify.ZModify +module +public import Aeneas.Tactic.Conv.ZModify.ZModify diff --git a/backends/lean/Aeneas/Tactic/Conv/ZModify/Init.lean b/backends/lean/Aeneas/Tactic/Conv/ZModify/Init.lean index c4d331f46..01e275fec 100644 --- a/backends/lean/Aeneas/Tactic/Conv/ZModify/Init.lean +++ b/backends/lean/Aeneas/Tactic/Conv/ZModify/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.ZModify diff --git a/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean b/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean index d4847fc4c..c0351fda1 100644 --- a/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean @@ -1,12 +1,14 @@ -import Mathlib.Tactic.Basic -import Mathlib.Tactic.Attr.Register -import Mathlib.Data.Int.Cast.Basic -import Mathlib.Order.Basic -import Aeneas.Tactic.Conv.ZModify.Init -import Aeneas.Tactic.Solver.Arith.Lemmas -import Aeneas.Std.Scalar.Core -import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac -import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +module +public import Mathlib.Tactic.Basic +public import Mathlib.Tactic.Attr.Register +public import Mathlib.Data.Int.Cast.Basic +public import Mathlib.Order.Basic +public import Aeneas.Tactic.Conv.ZModify.Init +public import Aeneas.Tactic.Solver.Arith.Lemmas +public import Aeneas.Std.Scalar.Core +public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +public section /-! # ZMod-ify tactic diff --git a/backends/lean/Aeneas/Tactic/Conv/Zify.lean b/backends/lean/Aeneas/Tactic/Conv/Zify.lean index 708874925..e2d437b08 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Zify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Zify.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Solver.Arith.Lemmas -import Aeneas.Std.Scalar.Core +module +public import Aeneas.Tactic.Solver.Arith.Lemmas +public import Aeneas.Std.Scalar.Core +public section open Aeneas Arith Std attribute [zify_simps] ZMod.val_natCast ZMod.val_intCast ZMod.castInt_val_sub ZMod.natCast_val diff --git a/backends/lean/Aeneas/Tactic/Elab.lean b/backends/lean/Aeneas/Tactic/Elab.lean index 7c2d0b259..c056a906b 100644 --- a/backends/lean/Aeneas/Tactic/Elab.lean +++ b/backends/lean/Aeneas/Tactic/Elab.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Elab.TraitDefault +module +public import Aeneas.Tactic.Elab.TraitDefault diff --git a/backends/lean/Aeneas/Tactic/Elab/TraitDefault.lean b/backends/lean/Aeneas/Tactic/Elab/TraitDefault.lean index a3c1309bc..a976559d9 100644 --- a/backends/lean/Aeneas/Tactic/Elab/TraitDefault.lean +++ b/backends/lean/Aeneas/Tactic/Elab/TraitDefault.lean @@ -1,2 +1,3 @@ -import Aeneas.Tactic.Elab.TraitDefault.Init -import Aeneas.Tactic.Elab.TraitDefault.Test +module +public import Aeneas.Tactic.Elab.TraitDefault.Init +public import Aeneas.Tactic.Elab.TraitDefault.Test diff --git a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean index 3f3b50b2f..d296c3ed9 100644 --- a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean +++ b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean @@ -1,4 +1,8 @@ -import Lean +module +public import Lean.Elab.PreDefinition.Basic +public meta import Lean.Elab.DefView +public meta import Lean.Elab.PreDefinition.Basic +public section /-! # `impl_def` and `@[trait_default]` @@ -120,7 +124,7 @@ open Lean.Parser.Term Lean.Parser.Command /-- Register the `@[trait_default]` tag attribute. Functions marked with this attribute are eligible for automatic unfolding by `impl_def` during field resolution. -/ -initialize traitDefaultAttr : TagAttribute ← +meta initialize traitDefaultAttr : TagAttribute ← registerTagAttribute `trait_default "Marks a function as a trait default that can be unfolded by `impl_def`." @@ -134,7 +138,7 @@ initialize registerTraceClass `Aeneas.implDef Used to decide whether a field value still depends on the self-reference and therefore needs further resolution. -/ -def exprContainsFVar (e : Expr) (fvarId : FVarId) : Bool := +meta def exprContainsFVar (e : Expr) (fvarId : FVarId) : Bool := Option.isSome <| e.find? fun | .fvar id => id == fvarId | _ => false @@ -147,7 +151,7 @@ def exprContainsFVar (e : Expr) (fvarId : FVarId) : Bool := The traversal uses `.visit` (not `.done`) after unfolding so that nested `@[trait_default]` calls exposed by the unfolding are also processed. -/ -partial def unfoldTraitDefaults (e : Expr) : MetaM Expr := do +meta partial def unfoldTraitDefaults (e : Expr) : MetaM Expr := do let env ← getEnv Core.transform e (pre := fun e => do let fn := e.getAppFn @@ -175,7 +179,7 @@ partial def unfoldTraitDefaults (e : Expr) : MetaM Expr := do The `projMap` maps each projection function name to its field index, built from `StructureInfo.getProjFn?`. -/ -def substituteProjections (e : Expr) (selfFvarId : FVarId) (structName : Name) +meta def substituteProjections (e : Expr) (selfFvarId : FVarId) (structName : Name) (resolvedFields : Std.HashMap Nat Expr) : MetaM Expr := do let env ← getEnv let some structInfo := getStructureInfo? env structName @@ -243,7 +247,7 @@ def substituteProjections (e : Expr) (selfFvarId : FVarId) (structName : Name) - Stop early if an iteration makes no progress. 4. Error if any fields remain unresolved. 5. Reassemble the constructor application with resolved field values. -/ -def resolveStructFields (value : Expr) (selfFvarId : FVarId) (type : Expr) : MetaM Expr := do +meta def resolveStructFields (value : Expr) (selfFvarId : FVarId) (type : Expr) : MetaM Expr := do let env ← getEnv let typeFn := type.getAppFn let .const structName _ := typeFn diff --git a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Test.lean b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Test.lean index 81a2b4d72..14fc94b6a 100644 --- a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Test.lean +++ b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Test.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Elab.TraitDefault.Init +module +public import Aeneas.Tactic.Elab.TraitDefault.Init +public section namespace Aeneas.TraitDefault.Test diff --git a/backends/lean/Aeneas/Tactic/Misc.lean b/backends/lean/Aeneas/Tactic/Misc.lean index 37fe23ab9..e3f488553 100644 --- a/backends/lean/Aeneas/Tactic/Misc.lean +++ b/backends/lean/Aeneas/Tactic/Misc.lean @@ -1,3 +1,4 @@ -import Aeneas.Tactic.Misc.FApplyExact -import Aeneas.Tactic.Misc.FCongr -import Aeneas.Tactic.Misc.Let +module +public import Aeneas.Tactic.Misc.FApplyExact +public import Aeneas.Tactic.Misc.FCongr +public import Aeneas.Tactic.Misc.Let diff --git a/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean b/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean index f09fe4f3a..e17e0d80e 100644 --- a/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean +++ b/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean @@ -5,7 +5,9 @@ Analogous to `fcongr` (which is `congr` with reducible transparency). -/ -import Lean +module +public import ImportGraph.Tools.MinImports +public section open Lean Meta Parser Elab Tactic @@ -15,14 +17,14 @@ syntax (name := fapply) "fapply " term : tactic syntax (name := fexact) "fexact " term : tactic @[tactic fapply] -def evalFApply : Tactic +meta def evalFApply : Tactic | `(tactic| fapply $e) => withMainContext do withTransparency .instances do evalTactic (← `(tactic| apply $e)) | _ => throwUnsupportedSyntax @[tactic fexact] -def evalFExact : Tactic +meta def evalFExact : Tactic | `(tactic| fexact $e) => withMainContext do withTransparency .instances do evalTactic (← `(tactic| exact $e)) diff --git a/backends/lean/Aeneas/Tactic/Misc/FCongr.lean b/backends/lean/Aeneas/Tactic/Misc/FCongr.lean index 1df3c68e2..43707aedf 100644 --- a/backends/lean/Aeneas/Tactic/Misc/FCongr.lean +++ b/backends/lean/Aeneas/Tactic/Misc/FCongr.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Misc.FCongr.FCongr +module +public import Aeneas.Tactic.Misc.FCongr.FCongr diff --git a/backends/lean/Aeneas/Tactic/Misc/FCongr/FCongr.lean b/backends/lean/Aeneas/Tactic/Misc/FCongr/FCongr.lean index 0fbb5aed8..a8719bf8a 100644 --- a/backends/lean/Aeneas/Tactic/Misc/FCongr/FCongr.lean +++ b/backends/lean/Aeneas/Tactic/Misc/FCongr/FCongr.lean @@ -1,4 +1,7 @@ -import Lean +module +public meta import Lean.Elab.Tactic.Basic +public meta import Lean.Meta.Tactic.Congr +public section open Lean Meta Parser Elab Tactic @@ -7,7 +10,7 @@ namespace FCongr syntax (name := fcongr) "fcongr" (ppSpace num)? : tactic @[tactic fcongr] -def evalFCongr : Tactic +meta def evalFCongr : Tactic | `(tactic| fcongr $[$n?]?) => withMainContext do let hugeDepth := 1000000 let depth := n?.map (·.getNat) |>.getD hugeDepth diff --git a/backends/lean/Aeneas/Tactic/Misc/Let.lean b/backends/lean/Aeneas/Tactic/Misc/Let.lean index c9884135b..6fcee18d8 100644 --- a/backends/lean/Aeneas/Tactic/Misc/Let.lean +++ b/backends/lean/Aeneas/Tactic/Misc/Let.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Misc.Let.Let +module +public import Aeneas.Tactic.Misc.Let.Let diff --git a/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean b/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean index 4c363fa20..fa0e40f2f 100644 --- a/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean +++ b/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean @@ -1,5 +1,7 @@ -import AeneasMeta.Utils -import Mathlib.Tactic.DefEqTransformations +module +public import AeneasMeta.Utils +public import Mathlib.Tactic.DefEqTransformations +public section namespace Aeneas.Let diff --git a/backends/lean/Aeneas/Tactic/RustAttributes.lean b/backends/lean/Aeneas/Tactic/RustAttributes.lean index 0ae77372d..1f1084120 100644 --- a/backends/lean/Aeneas/Tactic/RustAttributes.lean +++ b/backends/lean/Aeneas/Tactic/RustAttributes.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.RustAttributes diff --git a/backends/lean/Aeneas/Tactic/Setup.lean b/backends/lean/Aeneas/Tactic/Setup.lean index 96752bcbb..1db6124b4 100644 --- a/backends/lean/Aeneas/Tactic/Setup.lean +++ b/backends/lean/Aeneas/Tactic/Setup.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Slice -import Aeneas.Data.Vector +module +public import Aeneas.Std.Slice +public import Aeneas.Data.Vector +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Simp.lean b/backends/lean/Aeneas/Tactic/Simp.lean index 7d220579e..aadca546d 100644 --- a/backends/lean/Aeneas/Tactic/Simp.lean +++ b/backends/lean/Aeneas/Tactic/Simp.lean @@ -1,7 +1,8 @@ -import Aeneas.Tactic.Simp.SimpBoolProp -import Aeneas.Tactic.Simp.SimpIfs -import Aeneas.Tactic.Simp.SimpLemmas -import Aeneas.Tactic.Simp.SimpLists -import Aeneas.Tactic.Simp.SimpListsScalar -import Aeneas.Tactic.Simp.RingEqNF -import Aeneas.Tactic.Simp.SimpScalar +module +public import Aeneas.Tactic.Simp.SimpBoolProp +public import Aeneas.Tactic.Simp.SimpIfs +public import Aeneas.Tactic.Simp.SimpLemmas +public import Aeneas.Tactic.Simp.SimpLists +public import Aeneas.Tactic.Simp.SimpListsScalar +public import Aeneas.Tactic.Simp.RingEqNF +public import Aeneas.Tactic.Simp.SimpScalar diff --git a/backends/lean/Aeneas/Tactic/Simp/RingEqNF.lean b/backends/lean/Aeneas/Tactic/Simp/RingEqNF.lean index e296fdf86..c0b2ee747 100644 --- a/backends/lean/Aeneas/Tactic/Simp/RingEqNF.lean +++ b/backends/lean/Aeneas/Tactic/Simp/RingEqNF.lean @@ -1,2 +1,3 @@ -import Aeneas.Tactic.Simp.RingEqNF.Tactic -import Aeneas.Tactic.Simp.RingEqNF.Tests +module +public import Aeneas.Tactic.Simp.RingEqNF.Tactic +public import Aeneas.Tactic.Simp.RingEqNF.Tests diff --git a/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tactic.lean b/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tactic.lean index 70d0abeb9..7e007be76 100644 --- a/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tactic.lean +++ b/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tactic.lean @@ -2,8 +2,10 @@ Copyright (c) 2024 Aeneas contributors. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ -import Lean -import Mathlib.Tactic.Ring.RingNF +module +public import Lean +public import Mathlib.Tactic.Ring.RingNF +public section /-! # `ring_eq_nf` Tactic @@ -56,7 +58,7 @@ theorem eq_cancel_right_iff {α : Type*} [AddRightCancelMonoid α] /-! ## Expression parsing utilities -/ -private def exprToNat? (e : Expr) : Option Nat := +private meta def exprToNat? (e : Expr) : Option Nat := let e := e.consumeMData if let some n := e.nat? then some n else if let some n := e.rawNatLit? then some n @@ -64,7 +66,7 @@ private def exprToNat? (e : Expr) : Option Nat := /-- Flatten a left-associated addition tree into a list of additive terms (e.g., `((x₀ + x₁) + ... xₙ)` to `[x₀, x₁, ..., xₙ]` -/ -private partial def flattenAdd (e : Expr) : List Expr := +private meta partial def flattenAdd (e : Expr) : List Expr := match e.consumeMData.getAppFnArgs with | (``HAdd.hAdd, #[_, _, _, _, lhs, rhs]) => flattenAdd lhs ++ [rhs] @@ -98,7 +100,7 @@ private structure CMonomial where `ring_nf` normalises products so that the numeric coefficient is on the left (`n * base`). We also handle the `base * n` case for robustness. When no numeric factor is found, the coefficient defaults to 1. -/ -private def parseTerm (e : Expr) : CMonomial := +private meta def parseTerm (e : Expr) : CMonomial := let e := e.consumeMData match e.getAppFnArgs with | (``HMul.hMul, #[_, _, _, _, a, b]) => @@ -115,7 +117,7 @@ private def parseTerm (e : Expr) : CMonomial := /-- Flatten a `ring_nf`-normalized expression (a left-associated sum) and parse each summand into a `CMonomial`. -/ -private def parseNormExpr (e : Expr) : List CMonomial := +private meta def parseNormExpr (e : Expr) : List CMonomial := (flattenAdd e).map parseTerm /-! ## Cancellation algorithm -/ @@ -123,7 +125,7 @@ private def parseNormExpr (e : Expr) : List CMonomial := /-- Check whether two `CMonomial`s have the same base expression. Uses structural equality (`==`), which is safe here because both expressions come from the same `ring_nf` pass and are therefore already in a canonical form. -/ -private def sameBase (a b : CMonomial) : MetaM Bool := +private meta def sameBase (a b : CMonomial) : MetaM Bool := match a.base, b.base with | none, none => return true | some x, some y => return x == y @@ -143,7 +145,7 @@ private structure CancelResult where The algorithm iterates over each LHS monomial and searches for a matching base in the (shrinking) RHS remainder. When a match is found, the minimum coefficient is moved to `common` and any excess stays in the respective remainder. -/ -private def cancelCommon (lhs rhs : List CMonomial) : MetaM CancelResult := do +private meta def cancelCommon (lhs rhs : List CMonomial) : MetaM CancelResult := do let mut lhsRem : List CMonomial := [] let mut rhsRem := rhs let mut common : List CMonomial := [] @@ -177,15 +179,15 @@ private def cancelCommon (lhs rhs : List CMonomial) : MetaM CancelResult := do /-! ## Expression construction -/ -private def mkOfNat (ty : Expr) (n : Nat) : MetaM Expr := +private meta def mkOfNat (ty : Expr) (n : Nat) : MetaM Expr := mkAppOptM ``OfNat.ofNat #[some ty, some (mkRawNatLit n), none] -private def getCoeffExpr (ty : Expr) (m : CMonomial) : MetaM Expr := +private meta def getCoeffExpr (ty : Expr) (m : CMonomial) : MetaM Expr := match m.coeffExpr with | some e => return e | none => mkOfNat ty m.coeff -private def buildMonomialExpr (ty : Expr) (m : CMonomial) : MetaM Expr := do +private meta def buildMonomialExpr (ty : Expr) (m : CMonomial) : MetaM Expr := do match m.base with | none => getCoeffExpr ty m | some base => @@ -194,7 +196,7 @@ private def buildMonomialExpr (ty : Expr) (m : CMonomial) : MetaM Expr := do let coeffExpr ← getCoeffExpr ty m mkAppM ``HMul.hMul #[base, coeffExpr] -private def buildSumExpr (ty : Expr) (terms : List CMonomial) : MetaM Expr := do +private meta def buildSumExpr (ty : Expr) (terms : List CMonomial) : MetaM Expr := do match terms with | [] => mkOfNat ty 0 | [t] => buildMonomialExpr ty t @@ -212,7 +214,7 @@ private def buildSumExpr (ty : Expr) (terms : List CMonomial) : MetaM Expr := do directly would require `AtomM.run` + `Mathlib.Tactic.Ring.proveEq`. We go through `runTactic` for simplicity; the cost is negligible because `ring` is fast on the small rearrangement goals produced by `cancelEq`. -/ -private def proveByRing (goalType : Expr) : MetaM (Option Expr) := do +private meta def proveByRing (goalType : Expr) : MetaM (Option Expr) := do let mvar ← mkFreshExprMVar (some goalType) let (goals, _) ← Elab.runTactic mvar.mvarId! (← `(tactic| ring)) {} {} -- `ring` (not `ring_nf`): we need to *prove* the equality, not just normalize it @@ -223,7 +225,7 @@ private def proveByRing (goalType : Expr) : MetaM (Option Expr) := do /-- Core cancellation logic, operating on a `ring_nf`-normalized equality expression. Returns a `Simp.Result` rewriting the equality to a simpler one. -/ -private def cancelEq (e : Expr) : MetaM Simp.Result := do +private meta def cancelEq (e : Expr) : MetaM Simp.Result := do let some (ty, lhs, rhs) := e.eq? | return { expr := e } -- We assume the lhs and rhs have already been normalized diff --git a/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tests.lean b/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tests.lean index 6e18b48ee..f195ce151 100644 --- a/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Simp/RingEqNF/Tests.lean @@ -2,7 +2,9 @@ Copyright (c) 2024 Aeneas contributors. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ -import Aeneas.Tactic.Simp.RingEqNF.Tactic +module +public import Aeneas.Tactic.Simp.RingEqNF.Tactic +public section /-! # Tests for `ring_eq_nf` diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp.lean b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp.lean index 7a338703c..33fee64d1 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Simp.SimpIfs.SimpIfs +module +public import Aeneas.Tactic.Simp.SimpIfs.SimpIfs diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/Init.lean b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/Init.lean index f654f8693..3d5b25659 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/Init.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.SimpBoolProp diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean index cd51d5427..d344eb154 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean @@ -1,5 +1,7 @@ -import Mathlib.Tactic.Tauto -import Aeneas.Tactic.Simp.SimpBoolProp.Init +module +public import Mathlib.Tactic.Tauto +public import Aeneas.Tactic.Simp.SimpBoolProp.Init +public section /-! # `simp_bool_prop` lemmas and simp procedures diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpIfs.lean b/backends/lean/Aeneas/Tactic/Simp/SimpIfs.lean index 7a338703c..33fee64d1 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpIfs.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpIfs.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Simp.SimpIfs.SimpIfs +module +public import Aeneas.Tactic.Simp.SimpIfs.SimpIfs diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpIfs/Init.lean b/backends/lean/Aeneas/Tactic/Simp/SimpIfs/Init.lean index fbb6d424e..d16bdb0c3 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpIfs/Init.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpIfs/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.SimpIfs diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean b/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean index 25333b8bd..1ed876747 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean @@ -1,6 +1,8 @@ -import Aeneas.Tactic.Simp.SimpIfs.Init -import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp -import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +module +public import Aeneas.Tactic.Simp.SimpIfs.Init +public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public section /-! # `simp_ifs` tactic diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpLemmas.lean b/backends/lean/Aeneas/Tactic/Simp/SimpLemmas.lean index 7723733ac..190c54594 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpLemmas.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpLemmas.lean @@ -1,4 +1,6 @@ -import Lean +module +public import Lean +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpLists.lean b/backends/lean/Aeneas/Tactic/Simp/SimpLists.lean index 0a4c85257..4b3ce40f5 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpLists.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpLists.lean @@ -1,2 +1,3 @@ -import Aeneas.Tactic.Simp.SimpLists.SimpLists -import Aeneas.Tactic.Simp.SimpLists.Tests +module +public import Aeneas.Tactic.Simp.SimpLists.SimpLists +public import Aeneas.Tactic.Simp.SimpLists.Tests diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpLists/Init.lean b/backends/lean/Aeneas/Tactic/Simp/SimpLists/Init.lean index 8fe26066e..aacd43b40 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpLists/Init.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpLists/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.SimpLists diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean b/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean index ed6699f5c..be0528a76 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean @@ -1,7 +1,9 @@ -import Mathlib.Data.Nat.Bitwise -import Aeneas.Tactic.Simp.SimpLists.Init -import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac -import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +module +public import Mathlib.Data.Nat.Bitwise +public import Aeneas.Tactic.Simp.SimpLists.Init +public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +public section /-! # `simp_lists` tactic diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpLists/Tests.lean b/backends/lean/Aeneas/Tactic/Simp/SimpLists/Tests.lean index bdff74b39..71ce6d308 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpLists/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpLists/Tests.lean @@ -1,9 +1,11 @@ -import Aeneas.Tactic.Simp.SimpLists.SimpLists -import Aeneas.Data.List.List -import Aeneas.Data.Vector -import Aeneas.Std.Array -import Aeneas.Std.Slice -import Aeneas.Std +module +public import Aeneas.Tactic.Simp.SimpLists.SimpLists +public import Aeneas.Data.List.List +public import Aeneas.Data.Vector +public import Aeneas.Std.Array +public import Aeneas.Std.Slice +public import Aeneas.Std +public section local macro_rules | `(tactic| get_elem_tactic) => `(tactic| grind) diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean b/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean index fab81a262..6a50811b4 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Simp.SimpLists -import Aeneas.Tactic.Simp.SimpScalar +module +public import Aeneas.Tactic.Simp.SimpLists +public import Aeneas.Tactic.Simp.SimpScalar +public section namespace Aeneas.SimpListsScalar diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar.lean index 5b74adc5a..67fec18a5 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar.lean @@ -1,3 +1,4 @@ -import Aeneas.Tactic.Simp.SimpScalar.Lemmas -import Aeneas.Tactic.Simp.SimpScalar.SimpScalar -import Aeneas.Tactic.Simp.SimpScalar.Tests +module +public import Aeneas.Tactic.Simp.SimpScalar.Lemmas +public import Aeneas.Tactic.Simp.SimpScalar.SimpScalar +public import Aeneas.Tactic.Simp.SimpScalar.Tests diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Init.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Init.lean index 6931828b1..216e78a4b 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Init.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Simp +module +public import AeneasMeta.Simp +public section open Lean Meta namespace Aeneas.SimpScalar diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean index b8e88f921..68ac1df1c 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Simp.SimpScalar.SimpScalar -import Aeneas.Tactic.Simproc.ReduceNat +module +public import Aeneas.Tactic.Simp.SimpScalar.SimpScalar +public import Aeneas.Tactic.Simproc.ReduceNat +public section section diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean index 9d89458e4..d7a5b702e 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean @@ -1,8 +1,10 @@ -import Mathlib.Data.Nat.Bitwise -import Aeneas.Tactic.Simp.SimpScalar.Init -import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac -import Aeneas.Tactic.Simp.SimpLists.Init -- We need to mark some lemmas as `simp_lists_safe` -import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +module +public import Mathlib.Data.Nat.Bitwise +public import Aeneas.Tactic.Simp.SimpScalar.Init +public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public import Aeneas.Tactic.Simp.SimpLists.Init -- We need to mark some lemmas as `simp_lists_safe` +public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +public section /-! # `simp_scalar` tactic diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Tests.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Tests.lean index ed5c8e96b..8ef3f4618 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Tests.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Simp.SimpScalar.Lemmas +module +public import Aeneas.Tactic.Simp.SimpScalar.Lemmas +public section /-! # simp_scalar regression tests diff --git a/backends/lean/Aeneas/Tactic/Simproc.lean b/backends/lean/Aeneas/Tactic/Simproc.lean index 7a0fef770..a1b5ab08d 100644 --- a/backends/lean/Aeneas/Tactic/Simproc.lean +++ b/backends/lean/Aeneas/Tactic/Simproc.lean @@ -1,4 +1,5 @@ -import Aeneas.Tactic.Simproc.BvSimprocs -import Aeneas.Tactic.Simproc.ReduceFin -import Aeneas.Tactic.Simproc.ReduceNat -import Aeneas.Tactic.Simproc.ReduceZMod +module +public import Aeneas.Tactic.Simproc.BvSimprocs +public import Aeneas.Tactic.Simproc.ReduceFin +public import Aeneas.Tactic.Simproc.ReduceNat +public import Aeneas.Tactic.Simproc.ReduceZMod diff --git a/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean b/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean index bec9ee42a..2cf23d519 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Solver.BvTac.BvTac +module +public import Aeneas.Tactic.Solver.BvTac.BvTac +public section /-! # Simprocs for scalar bitwise operations diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin.lean index 39b7e8d59..f74a1f37e 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Simproc.ReduceFin.ReduceFin +module +public import Aeneas.Tactic.Simproc.ReduceFin.ReduceFin diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/Init.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/Init.lean index 62618b547..0d72c2e78 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/Init.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Extensions +module +public import AeneasMeta.Extensions +public section open Lean Meta namespace Aeneas.ReduceFin diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean index 752b5ef52..f0aa48f55 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Simproc.ReduceFin.Init -import AeneasMeta.Utils +module +public import Aeneas.Tactic.Simproc.ReduceFin.Init +public import AeneasMeta.Utils +public section namespace Aeneas.ReduceFin diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean index 4214f4c6b..615fc7ecf 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean @@ -1,5 +1,7 @@ -import AeneasMeta.Utils -import Aeneas.Tactic.Solver.ScalarTac.Init +module +public import AeneasMeta.Utils +public import Aeneas.Tactic.Solver.ScalarTac.Init +public section namespace Aeneas.ReduceNat diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod.lean index 89f8065fb..06b22289b 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Simproc.ReduceZMod.ReduceZMod +module +public import Aeneas.Tactic.Simproc.ReduceZMod.ReduceZMod diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/Init.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/Init.lean index 181550bda..b5b3abaf6 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/Init.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/Init.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Extensions +module +public import AeneasMeta.Extensions +public section open Lean Meta namespace Aeneas.ReduceZMod diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean index 4e63f80b2..242d172a9 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean @@ -1,6 +1,8 @@ -import Aeneas.Tactic.Simproc.ReduceZMod.Init -import Mathlib.Algebra.Algebra.ZMod -import AeneasMeta.Utils +module +public import Aeneas.Tactic.Simproc.ReduceZMod.Init +public import Mathlib.Algebra.Algebra.ZMod +public import AeneasMeta.Utils +public section namespace Aeneas.ReduceZMod diff --git a/backends/lean/Aeneas/Tactic/Solver.lean b/backends/lean/Aeneas/Tactic/Solver.lean index 18d80fd2a..decb6fbce 100644 --- a/backends/lean/Aeneas/Tactic/Solver.lean +++ b/backends/lean/Aeneas/Tactic/Solver.lean @@ -1,5 +1,6 @@ -import Aeneas.Tactic.Solver.Arith -import Aeneas.Tactic.Solver.BvTac -import Aeneas.Tactic.Solver.Grind -import Aeneas.Tactic.Solver.ScalarDecrTac -import Aeneas.Tactic.Solver.ScalarTac +module +public import Aeneas.Tactic.Solver.Arith +public import Aeneas.Tactic.Solver.BvTac +public import Aeneas.Tactic.Solver.Grind +public import Aeneas.Tactic.Solver.ScalarDecrTac +public import Aeneas.Tactic.Solver.ScalarTac diff --git a/backends/lean/Aeneas/Tactic/Solver/Arith.lean b/backends/lean/Aeneas/Tactic/Solver/Arith.lean index 42010f12a..48155cba8 100644 --- a/backends/lean/Aeneas/Tactic/Solver/Arith.lean +++ b/backends/lean/Aeneas/Tactic/Solver/Arith.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Solver.Arith.Lemmas +module +public import Aeneas.Tactic.Solver.Arith.Lemmas diff --git a/backends/lean/Aeneas/Tactic/Solver/Arith/Lemmas.lean b/backends/lean/Aeneas/Tactic/Solver/Arith/Lemmas.lean index f55a0301b..b918c1c1e 100644 --- a/backends/lean/Aeneas/Tactic/Solver/Arith/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Solver/Arith/Lemmas.lean @@ -1,7 +1,9 @@ -import Aeneas.Tactic.Solver.ScalarTac.ScalarTac -import Mathlib.Algebra.Algebra.ZMod -import Mathlib.RingTheory.Int.Basic -import Init.Data.BitVec.Lemmas +module +public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public import Mathlib.Algebra.Algebra.ZMod +public import Mathlib.RingTheory.Int.Basic +public import Init.Data.BitVec.Lemmas +public section namespace Aeneas.Arith diff --git a/backends/lean/Aeneas/Tactic/Solver/BvTac.lean b/backends/lean/Aeneas/Tactic/Solver/BvTac.lean index 8ee13a48d..a67b82f95 100644 --- a/backends/lean/Aeneas/Tactic/Solver/BvTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/BvTac.lean @@ -1,3 +1,4 @@ -import Aeneas.Tactic.Solver.BvTac.BvTac -import Aeneas.Tactic.Solver.BvTac.Lemmas -import Aeneas.Tactic.Simproc.BvSimprocs +module +public import Aeneas.Tactic.Solver.BvTac.BvTac +public import Aeneas.Tactic.Solver.BvTac.Lemmas +public import Aeneas.Tactic.Simproc.BvSimprocs diff --git a/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean b/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean index 65d1fca39..dc9f5f552 100644 --- a/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean @@ -1,6 +1,8 @@ -import Aeneas.Tactic.Conv.Bvify -import Aeneas.Std -import Aeneas.Tactic.Solver.BvTac.Init +module +public import Aeneas.Tactic.Conv.Bvify +public import Aeneas.Std +public import Aeneas.Tactic.Solver.BvTac.Init +public section namespace Aeneas.BvTac diff --git a/backends/lean/Aeneas/Tactic/Solver/BvTac/Init.lean b/backends/lean/Aeneas/Tactic/Solver/BvTac/Init.lean index 76e1b3ea2..a36281b9a 100644 --- a/backends/lean/Aeneas/Tactic/Solver/BvTac/Init.lean +++ b/backends/lean/Aeneas/Tactic/Solver/BvTac/Init.lean @@ -1,4 +1,6 @@ -import Lean +module +public import Lean +public section namespace Aeneas.BvTac diff --git a/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean b/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean index b7cf13303..7be728fa6 100644 --- a/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Solver.BvTac.BvTac +module +public import Aeneas.Tactic.Solver.BvTac.BvTac +public section /-! # Bitwise identity lemmas for scalar types diff --git a/backends/lean/Aeneas/Tactic/Solver/BvTac/Tests.lean b/backends/lean/Aeneas/Tactic/Solver/BvTac/Tests.lean index 138fab2e4..3ae508658 100644 --- a/backends/lean/Aeneas/Tactic/Solver/BvTac/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Solver/BvTac/Tests.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Solver.BvTac.BvTac -import Aeneas.Std +module +public import Aeneas.Tactic.Solver.BvTac.BvTac +public import Aeneas.Std +public section /-! # bv_tac regression tests diff --git a/backends/lean/Aeneas/Tactic/Solver/Grind.lean b/backends/lean/Aeneas/Tactic/Solver/Grind.lean index f1c9adef5..593879c3f 100644 --- a/backends/lean/Aeneas/Tactic/Solver/Grind.lean +++ b/backends/lean/Aeneas/Tactic/Solver/Grind.lean @@ -1 +1,2 @@ -import Aeneas.Tactic.Solver.Grind.Init +module +public import Aeneas.Tactic.Solver.Grind.Init diff --git a/backends/lean/Aeneas/Tactic/Solver/Grind/Attribute.lean b/backends/lean/Aeneas/Tactic/Solver/Grind/Attribute.lean index fd2042f77..78bf8b7c9 100644 --- a/backends/lean/Aeneas/Tactic/Solver/Grind/Attribute.lean +++ b/backends/lean/Aeneas/Tactic/Solver/Grind/Attribute.lean @@ -18,7 +18,7 @@ macro (name := _root_.AeneasMeta.Parser.Command.registerGrindAttr) doc:(docComme let idParser3 := mkIdentFrom id (`Lean.Parser.Attr ++ (id.getId.appendAfter "?")) let str4 := id.getId.toString ++ "!?" let idParser4 := mkIdentFrom id (`Lean.Parser.Attr ++ (id.getId.appendAfter "!?")) - `($[$doc:docComment]? initialize $extId : Extension ← registerAttr $(quote id.getId) (ref := $(quote id.getId)) + `($[$doc:docComment]? meta initialize $extId : Extension ← registerAttr $(quote id.getId) (ref := $(quote id.getId)) $[$doc:docComment]? syntax (name := $idParser1:ident) $(quote str1):str (ppSpace Lean.Parser.Attr.grindMod)? : attr $[$doc:docComment]? syntax (name := $idParser2:ident) $(quote str2):str (ppSpace Lean.Parser.Attr.grindMod)? : attr $[$doc:docComment]? syntax (name := $idParser3:ident) $(quote str3):str (ppSpace Lean.Parser.Attr.grindMod)? : attr diff --git a/backends/lean/Aeneas/Tactic/Solver/Grind/Init.lean b/backends/lean/Aeneas/Tactic/Solver/Grind/Init.lean index 354029e6a..3b5e5373f 100644 --- a/backends/lean/Aeneas/Tactic/Solver/Grind/Init.lean +++ b/backends/lean/Aeneas/Tactic/Solver/Grind/Init.lean @@ -1,5 +1,10 @@ -import Lean -import Aeneas.Tactic.Solver.Grind.Attribute +module +public meta import Aeneas.Tactic.Solver.Grind.Attribute +public meta import Lean.Elab.ConfigEval.Commands +public meta import Lean.Elab.ConfigEval.DeriveEvalConfigItem +public meta import Lean.Elab.Tactic.Grind.Param +public meta import Lean.Meta.Tactic.Grind.SimpUtil +public meta section namespace Aeneas.Grind diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean index d4e08f012..fb61669b3 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean @@ -1,8 +1,10 @@ /- Some utilities to prove termination -/ -import Lean -import Mathlib.Tactic.Core -import AeneasMeta.Utils -import Aeneas.Tactic.Solver.ScalarTac +module +public import Lean +public import Mathlib.Tactic.Core +public import AeneasMeta.Utils +public import Aeneas.Tactic.Solver.ScalarTac +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac.lean index 38a7226fa..36ce2c453 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac.lean @@ -1,4 +1,5 @@ -import Aeneas.Tactic.Solver.ScalarTac.ScalarTac -import Aeneas.Tactic.Solver.ScalarTac.Lemmas -import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac -import Aeneas.Tactic.Solver.Arith.Lemmas +module +public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public import Aeneas.Tactic.Solver.ScalarTac.Lemmas +public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public import Aeneas.Tactic.Solver.Arith.Lemmas diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean index 5514a46fd..0ade41c1f 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +module +public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public section namespace Aeneas.ScalarTac diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Core.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Core.lean index 8da79eaf0..3c9aa2d8f 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Core.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Core.lean @@ -1,5 +1,7 @@ -import Lean -import Mathlib.Tactic.Linarith -- Introduces a lot of useful lemmas +module +public import Lean +public import Mathlib.Tactic.Linarith -- Introduces a lot of useful lemmas +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean index df9e4e4e9..e26d2e484 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean @@ -1,5 +1,7 @@ -import AeneasMeta.Saturate.Attribute -import AeneasMeta.Simp +module +public import AeneasMeta.Saturate.Attribute +public import AeneasMeta.Simp +public section open Lean Meta Meta.Simp namespace Aeneas.ScalarTac diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Lemmas.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Lemmas.lean index 11350f107..37c656bf4 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Lemmas.lean @@ -1,7 +1,9 @@ -import Mathlib.Data.ZMod.Basic -import Aeneas.Tactic.Solver.ScalarTac.ScalarTac -import Aeneas.Std.Scalar.Core -import Aeneas.Tactic.Simproc.ReduceZMod.ReduceZMod +module +public import Mathlib.Data.ZMod.Basic +public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public import Aeneas.Std.Scalar.Core +public import Aeneas.Tactic.Simproc.ReduceZMod.ReduceZMod +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean index e3946a0e6..e5749892a 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean @@ -1,14 +1,16 @@ -import Lean -import Lean.Meta.Tactic.Simp -import Init.Data.List.Basic -import Mathlib.Tactic.Ring.RingNF -import AeneasMeta.Utils -import Aeneas.Tactic.Solver.ScalarTac.Core -import Aeneas.Tactic.Solver.ScalarTac.Init -import AeneasMeta.Saturate -import Aeneas.Tactic.Simp.SimpScalar.Init -import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp -import AeneasMeta.Simp +module +public import Lean +public import Lean.Meta.Tactic.Simp +public import Init.Data.List.Basic +public import Mathlib.Tactic.Ring.RingNF +public import AeneasMeta.Utils +public import Aeneas.Tactic.Solver.ScalarTac.Core +public import Aeneas.Tactic.Solver.ScalarTac.Init +public import AeneasMeta.Saturate +public import Aeneas.Tactic.Simp.SimpScalar.Init +public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp +public import AeneasMeta.Simp +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Tests.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Tests.lean index 23b49907b..481f4410e 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Tests.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Solver.ScalarTac.Lemmas +module +public import Aeneas.Tactic.Solver.ScalarTac.Lemmas +public section namespace Aeneas.Std.ScalarTac.Tests diff --git a/backends/lean/Aeneas/Tactic/Step.lean b/backends/lean/Aeneas/Tactic/Step.lean index 16fe78ea1..f38c94efe 100644 --- a/backends/lean/Aeneas/Tactic/Step.lean +++ b/backends/lean/Aeneas/Tactic/Step.lean @@ -1,6 +1,7 @@ -import Aeneas.Tactic.Step.InferPost -import Aeneas.Tactic.Step.Step -import Aeneas.Tactic.Step.StepArraySpec -import Aeneas.Tactic.Step.StepStar -import Aeneas.Tactic.Step.Deprecated -import Aeneas.Tactic.Step.DspecInduction +module +public import Aeneas.Tactic.Step.InferPost +public import Aeneas.Tactic.Step.Step +public import Aeneas.Tactic.Step.StepArraySpec +public import Aeneas.Tactic.Step.StepStar +public import Aeneas.Tactic.Step.Deprecated +public import Aeneas.Tactic.Step.DspecInduction diff --git a/backends/lean/Aeneas/Tactic/Step/Deprecated.lean b/backends/lean/Aeneas/Tactic/Step/Deprecated.lean index 7808c2a94..b869b99ae 100644 --- a/backends/lean/Aeneas/Tactic/Step/Deprecated.lean +++ b/backends/lean/Aeneas/Tactic/Step/Deprecated.lean @@ -3,9 +3,11 @@ Copyright (c) 2024-2025 Inria. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Son Ho -/ -import Aeneas.Tactic.Step.Step -import Aeneas.Tactic.Step.StepStar -import Aeneas.Tactic.Step.StepArraySpec +module +public import Aeneas.Tactic.Step.Step +public import Aeneas.Tactic.Step.StepStar +public import Aeneas.Tactic.Step.StepArraySpec +public section /-! # Deprecated `progress` syntax and attributes diff --git a/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean b/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean index 25ee63dd1..c1d8e9176 100644 --- a/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean +++ b/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean @@ -1,13 +1,15 @@ -import Lean -import Aeneas.Tactic.Solver.ScalarTac -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Step.GrindState -import Aeneas.Std -import Aeneas.Tactic.Simp.SimpLemmas -import AeneasMeta.Async -import Aeneas.Tactic.Solver.Grind.Init -import Aeneas.Tactic.Step.InferPost -import Aeneas.Tactic.Step.Step +module +public import Lean +public import Aeneas.Tactic.Solver.ScalarTac +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Step.GrindState +public import Aeneas.Std +public import Aeneas.Tactic.Simp.SimpLemmas +public import AeneasMeta.Async +public import Aeneas.Tactic.Solver.Grind.Init +public import Aeneas.Tactic.Step.InferPost +public import Aeneas.Tactic.Step.Step +public section /- Tactic for unfolding partial_fixpoint definitions with fixpoint_induct. Normally you would use the normal unfold tactic, but that requires the proof to be terminating. diff --git a/backends/lean/Aeneas/Tactic/Step/GrindState.lean b/backends/lean/Aeneas/Tactic/Step/GrindState.lean index 8dad2f5bc..ecca764da 100644 --- a/backends/lean/Aeneas/Tactic/Step/GrindState.lean +++ b/backends/lean/Aeneas/Tactic/Step/GrindState.lean @@ -3,10 +3,12 @@ Copyright (c) 2025 Aeneas contributors Released under Apache 2.0 license as described in the file LICENSE. Authors: Son Ho -/ -import Lean -import Aeneas.Tactic.Solver.ScalarTac -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Solver.Grind.Init +module +public import Lean +public import Aeneas.Tactic.Solver.ScalarTac +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Solver.Grind.Init +public section /-! # Grind State Threading for `step` / `step*` diff --git a/backends/lean/Aeneas/Tactic/Step/InferPost.lean b/backends/lean/Aeneas/Tactic/Step/InferPost.lean index 13043f9c0..c5fe8b21b 100644 --- a/backends/lean/Aeneas/Tactic/Step/InferPost.lean +++ b/backends/lean/Aeneas/Tactic/Step/InferPost.lean @@ -1,9 +1,11 @@ -import Lean -import AeneasMeta.Utils -import AeneasMeta.Simp.Simp -import Mathlib.Tactic.Simproc.ExistsAndEq -import Aeneas.Tactic.Solver.Grind.Init -import Aeneas.Tactic.Step.Init +module +public import Lean +public import AeneasMeta.Utils +public import AeneasMeta.Simp.Simp +public import Mathlib.Tactic.Simproc.ExistsAndEq +public import Aeneas.Tactic.Solver.Grind.Init +public import Aeneas.Tactic.Step.Init +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Step/Init.lean b/backends/lean/Aeneas/Tactic/Step/Init.lean index bd90cd489..44967a32b 100644 --- a/backends/lean/Aeneas/Tactic/Step/Init.lean +++ b/backends/lean/Aeneas/Tactic/Step/Init.lean @@ -1,10 +1,12 @@ -import Lean -import AeneasMeta.Utils -import Aeneas.Std.Primitives -import AeneasMeta.Extensions -import Aeneas.Tactic.Step.Trace -import Aeneas.Std.WP -import AeneasMeta.OptionConfig +module +public import Lean +public import AeneasMeta.Utils +public import Aeneas.Std.Primitives +public import AeneasMeta.Extensions +public import Aeneas.Tactic.Step.Trace +public import Aeneas.Std.WP +public import AeneasMeta.OptionConfig +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Step/Step.lean b/backends/lean/Aeneas/Tactic/Step/Step.lean index 2c4312fb2..531649fc0 100644 --- a/backends/lean/Aeneas/Tactic/Step/Step.lean +++ b/backends/lean/Aeneas/Tactic/Step/Step.lean @@ -1,14 +1,16 @@ -import Lean -import Aeneas.Tactic.Solver.ScalarTac -import Aeneas.Tactic.Step.Init -import Aeneas.Tactic.Step.GrindState -import Aeneas.Std -import Aeneas.Tactic.Simp.SimpLemmas -import AeneasMeta.Async -import Aeneas.Tactic.Solver.Grind.Init -import Aeneas.Tactic.Step.InferPost -import Aeneas.Std.WP -import Aeneas.Do +module +public import Lean +public import Aeneas.Tactic.Solver.ScalarTac +public import Aeneas.Tactic.Step.Init +public import Aeneas.Tactic.Step.GrindState +public import Aeneas.Std +public import Aeneas.Tactic.Simp.SimpLemmas +public import AeneasMeta.Async +public import Aeneas.Tactic.Solver.Grind.Init +public import Aeneas.Tactic.Step.InferPost +public import Aeneas.Std.WP +public import Aeneas.Do +public section namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean b/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean index 715196f73..849e1a34c 100644 --- a/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean +++ b/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Step.Step +module +public import Aeneas.Tactic.Step.Step +public section /-! # Step Array Spec diff --git a/backends/lean/Aeneas/Tactic/Step/StepStar.lean b/backends/lean/Aeneas/Tactic/Step/StepStar.lean index e1313f0be..ccca5ff21 100644 --- a/backends/lean/Aeneas/Tactic/Step/StepStar.lean +++ b/backends/lean/Aeneas/Tactic/Step/StepStar.lean @@ -1,5 +1,7 @@ -import Aeneas.Tactic.Step.Step -import AeneasMeta.Split +module +public import Aeneas.Tactic.Step.Step +public import AeneasMeta.Split +public section open Lean Meta Elab Tactic namespace Aeneas diff --git a/backends/lean/Aeneas/Tactic/Step/Tests.lean b/backends/lean/Aeneas/Tactic/Step/Tests.lean index 017241bb2..79454f949 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests.lean @@ -1,6 +1,7 @@ -import Aeneas.Tactic.Step.Tests.HigherOrder -import Aeneas.Tactic.Step.Tests.IntroOutputs -import Aeneas.Tactic.Step.Tests.MaxRecDepthMetavar -import Aeneas.Tactic.Step.Tests.MvcgenSpec -import Aeneas.Tactic.Step.Tests.TupleDestruct -import Aeneas.Tactic.Step.Tests.UncurryBind +module +public import Aeneas.Tactic.Step.Tests.HigherOrder +public import Aeneas.Tactic.Step.Tests.IntroOutputs +public import Aeneas.Tactic.Step.Tests.MaxRecDepthMetavar +public import Aeneas.Tactic.Step.Tests.MvcgenSpec +public import Aeneas.Tactic.Step.Tests.TupleDestruct +public import Aeneas.Tactic.Step.Tests.UncurryBind diff --git a/backends/lean/Aeneas/Tactic/Step/Tests/HigherOrder.lean b/backends/lean/Aeneas/Tactic/Step/Tests/HigherOrder.lean index 250a8e426..9776c366f 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests/HigherOrder.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests/HigherOrder.lean @@ -1,5 +1,7 @@ -import Aeneas.Std.Slice -import Aeneas.Tactic.Step +module +public import Aeneas.Std.Slice +public import Aeneas.Tactic.Step +public section open Aeneas Aeneas.Std Result ControlFlow Error diff --git a/backends/lean/Aeneas/Tactic/Step/Tests/IntroOutputs.lean b/backends/lean/Aeneas/Tactic/Step/Tests/IntroOutputs.lean index 03c801cc8..cc0c143de 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests/IntroOutputs.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests/IntroOutputs.lean @@ -1,6 +1,8 @@ -import Aeneas.Do -import Aeneas.Std.Slice -import Aeneas.Tactic.Step +module +public import Aeneas.Do +public import Aeneas.Std.Slice +public import Aeneas.Tactic.Step +public section /-! # `introOutputs` tests -/ diff --git a/backends/lean/Aeneas/Tactic/Step/Tests/MaxRecDepthMetavar.lean b/backends/lean/Aeneas/Tactic/Step/Tests/MaxRecDepthMetavar.lean index e3d4c56f4..7ca79fb6a 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests/MaxRecDepthMetavar.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests/MaxRecDepthMetavar.lean @@ -1,6 +1,8 @@ -import Aeneas.Do -import Aeneas.Std.Slice -import Aeneas.Tactic.Step +module +public import Aeneas.Do +public import Aeneas.Std.Slice +public import Aeneas.Tactic.Step +public section open Aeneas Aeneas.Std Result diff --git a/backends/lean/Aeneas/Tactic/Step/Tests/MvcgenSpec.lean b/backends/lean/Aeneas/Tactic/Step/Tests/MvcgenSpec.lean index ab18dc289..99b4d5311 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests/MvcgenSpec.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests/MvcgenSpec.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Scalar -import Aeneas.Std.Array -import Aeneas.Tactic.Step +module +public import Aeneas.Std.Scalar +public import Aeneas.Std.Array +public import Aeneas.Tactic.Step +public section open Aeneas Aeneas.Std Result Std.Do set_option mvcgen.warning false diff --git a/backends/lean/Aeneas/Tactic/Step/Tests/TupleDestruct.lean b/backends/lean/Aeneas/Tactic/Step/Tests/TupleDestruct.lean index c2fe9364b..02a347cef 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests/TupleDestruct.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests/TupleDestruct.lean @@ -1,6 +1,8 @@ -import Aeneas.Do -import Aeneas.Std.Slice -import Aeneas.Tactic.Step +module +public import Aeneas.Do +public import Aeneas.Std.Slice +public import Aeneas.Tactic.Step +public section open Aeneas Aeneas.Std Result diff --git a/backends/lean/Aeneas/Tactic/Step/Tests/UncurryBind.lean b/backends/lean/Aeneas/Tactic/Step/Tests/UncurryBind.lean index 030453bec..4c554038a 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests/UncurryBind.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests/UncurryBind.lean @@ -1,6 +1,8 @@ -import Aeneas.Std.Slice -import Aeneas.Tactic.Step -import Aeneas.Do +module +public import Aeneas.Std.Slice +public import Aeneas.Tactic.Step +public import Aeneas.Do +public section open Aeneas Aeneas.Std Result diff --git a/backends/lean/Aeneas/Tactic/Step/Trace.lean b/backends/lean/Aeneas/Tactic/Step/Trace.lean index 6212fbe80..a2c297f2c 100644 --- a/backends/lean/Aeneas/Tactic/Step/Trace.lean +++ b/backends/lean/Aeneas/Tactic/Step/Trace.lean @@ -1,4 +1,6 @@ -import Lean +module +public import Lean +public section open Lean Elab Term Meta namespace Aeneas.Step diff --git a/backends/lean/Aeneas/Tactic/Tests.lean b/backends/lean/Aeneas/Tactic/Tests.lean index 9c6f01d26..c3ef8d560 100644 --- a/backends/lean/Aeneas/Tactic/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Tests.lean @@ -1,6 +1,7 @@ -import Aeneas.Tactic.Solver.ScalarTac.Tests -import Aeneas.Tactic.Solver.BvTac.Tests -import Aeneas.Tactic.Conv.Bvify.Tests -import Aeneas.Tactic.Simp.SimpLists.Tests -import Aeneas.Tactic.Simp.SimpScalar.Tests -import Aeneas.Tactic.Step.Tests +module +public import Aeneas.Tactic.Solver.ScalarTac.Tests +public import Aeneas.Tactic.Solver.BvTac.Tests +public import Aeneas.Tactic.Conv.Bvify.Tests +public import Aeneas.Tactic.Simp.SimpLists.Tests +public import Aeneas.Tactic.Simp.SimpScalar.Tests +public import Aeneas.Tactic.Step.Tests diff --git a/backends/lean/AeneasExtract.lean b/backends/lean/AeneasExtract.lean index 6a3c168b5..11a78e5a3 100644 --- a/backends/lean/AeneasExtract.lean +++ b/backends/lean/AeneasExtract.lean @@ -1,4 +1,6 @@ -import Aeneas +module +public import Aeneas +public section open Lean Aeneas Extract diff --git a/backends/lean/AeneasMeta.lean b/backends/lean/AeneasMeta.lean index 256c4f7cc..75e6098b4 100644 --- a/backends/lean/AeneasMeta.lean +++ b/backends/lean/AeneasMeta.lean @@ -1,7 +1,8 @@ -import AeneasMeta.Async -import AeneasMeta.BvEnumToBitVec -import AeneasMeta.Extensions -import AeneasMeta.OptionConfig -import AeneasMeta.Saturate -import AeneasMeta.Simp -import AeneasMeta.Utils +module +public import AeneasMeta.Async +public import AeneasMeta.BvEnumToBitVec +public import AeneasMeta.Extensions +public import AeneasMeta.OptionConfig +public import AeneasMeta.Saturate +public import AeneasMeta.Simp +public import AeneasMeta.Utils diff --git a/backends/lean/AeneasMeta/Async.lean b/backends/lean/AeneasMeta/Async.lean index 659e801b6..79da0c95c 100644 --- a/backends/lean/AeneasMeta/Async.lean +++ b/backends/lean/AeneasMeta/Async.lean @@ -1,3 +1,4 @@ -import AeneasMeta.Async.Async -import AeneasMeta.Async.Test -import AeneasMeta.Async.TestTactics +module +public import AeneasMeta.Async.Async +public import AeneasMeta.Async.Test +public import AeneasMeta.Async.TestTactics diff --git a/backends/lean/AeneasMeta/Async/Async.lean b/backends/lean/AeneasMeta/Async/Async.lean index 80eff56b8..d952a2edf 100644 --- a/backends/lean/AeneasMeta/Async/Async.lean +++ b/backends/lean/AeneasMeta/Async/Async.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Utils +module +public import AeneasMeta.Utils +public section namespace Aeneas.Async diff --git a/backends/lean/AeneasMeta/Async/Test.lean b/backends/lean/AeneasMeta/Async/Test.lean index c83ed7b55..104dc6b80 100644 --- a/backends/lean/AeneasMeta/Async/Test.lean +++ b/backends/lean/AeneasMeta/Async/Test.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Async.TestTactics +module +public import AeneasMeta.Async.TestTactics +public section namespace Aeneas.Async.Test diff --git a/backends/lean/AeneasMeta/Async/TestTactics.lean b/backends/lean/AeneasMeta/Async/TestTactics.lean index 0bf08c679..f23077fe5 100644 --- a/backends/lean/AeneasMeta/Async/TestTactics.lean +++ b/backends/lean/AeneasMeta/Async/TestTactics.lean @@ -1,6 +1,8 @@ -import AeneasMeta.Async.Async -import AeneasMeta.Simp -import Lean +module +public import AeneasMeta.Async.Async +public import AeneasMeta.Simp +public import Lean +public section /-! We're putting the tactics used in the tests in a file different from the tests themselves because running tactics from the current file waits on compilation of all definitions. diff --git a/backends/lean/AeneasMeta/BvEnumToBitVec.lean b/backends/lean/AeneasMeta/BvEnumToBitVec.lean index 2fadf4bc0..c900236a1 100644 --- a/backends/lean/AeneasMeta/BvEnumToBitVec.lean +++ b/backends/lean/AeneasMeta/BvEnumToBitVec.lean @@ -2,8 +2,10 @@ Copyright (c) 2025. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -/ -import Lean -import Lean.Elab.Tactic.BVDecide.Frontend.Normalize.Enums +module +public meta import Lean.Elab.Deriving.Basic +public meta import Lean.Elab.Tactic.BVDecide.Frontend.Normalize.Enums +public section /-! # Eagerly realizing `bv_decide`'s enum conversion constants @@ -63,7 +65,7 @@ all constructors nullary), otherwise the underlying `bv_decide` realisers throw. Idempotent: if the constants are already present (e.g. realised by an imported module) the realisers reuse them rather than failing. -/ -def realizeBvEnumToBitVec (declName : Name) : CoreM Unit := do +meta def realizeBvEnumToBitVec (declName : Name) : CoreM Unit := do unless ← isEnumType declName do throwError m!"{.ofConstName declName} is not an enum inductive \ (parameter-free with only nullary constructors); \ @@ -88,7 +90,7 @@ syntax (name := defineBvDecideToBitVec) open Lean.Elab.Command in @[command_elab defineBvDecideToBitVec] -def elabDefineBvDecideToBitVec : CommandElab := fun stx => +meta def elabDefineBvDecideToBitVec : CommandElab := fun stx => match stx with | `(#define_bv_decide_toBitVec $id:ident) => liftCoreM do @@ -99,14 +101,14 @@ def elabDefineBvDecideToBitVec : CommandElab := fun stx => open Lean.Elab.Command in /-- `deriving` handler for `BvEnumToBitVec`: realises `bv_decide`'s enum conversion constants for each derived type and registers a marker instance. -/ -def mkBvEnumToBitVecInstance (declNames : Array Name) : CommandElabM Bool := do +meta def mkBvEnumToBitVecInstance (declNames : Array Name) : CommandElabM Bool := do for declName in declNames do liftCoreM <| realizeBvEnumToBitVec declName let typeId := mkIdent declName elabCommand (← `(command| instance : BvEnumToBitVec $typeId := ⟨⟩)) return true -initialize +meta initialize registerDerivingHandler ``BvEnumToBitVec mkBvEnumToBitVecInstance end Aeneas diff --git a/backends/lean/AeneasMeta/Extensions.lean b/backends/lean/AeneasMeta/Extensions.lean index 33a25095d..fa5fd190e 100644 --- a/backends/lean/AeneasMeta/Extensions.lean +++ b/backends/lean/AeneasMeta/Extensions.lean @@ -1,8 +1,10 @@ -import Lean -import AeneasMeta.Utils +module +public import Lean +public import AeneasMeta.Utils -import Lean.Meta.DiscrTree -import Lean.Meta.Tactic.Simp +public import Lean.Meta.DiscrTree +public import Lean.Meta.Tactic.Simp +public section namespace Aeneas diff --git a/backends/lean/AeneasMeta/OptionConfig.lean b/backends/lean/AeneasMeta/OptionConfig.lean index 6a91fa6ab..a346f149d 100644 --- a/backends/lean/AeneasMeta/OptionConfig.lean +++ b/backends/lean/AeneasMeta/OptionConfig.lean @@ -1,6 +1,8 @@ -import Lean -import Lean.Elab.Tactic.Config -import Lean.Elab.Eval +module +public meta import Lean.Meta.Reduce +public meta import Lean.Elab.Tactic.Config +public import Lean.Elab.Eval +public section namespace Aeneas.Meta.OptionConfig @@ -13,7 +15,7 @@ open Lean Elab Command Term Meta PrettyPrinter /-- Decompose a `Lean.Parser.Tactic.optConfig` into an array of (fieldName, valueSyntax) pairs. For instance: with input `+b (value := 3) -c`, it outputs: `#[("b", true), (value, 3), ("c", false)]` -/ -partial def decomposeOptConfig (cfg : TSyntax `Lean.Parser.Tactic.optConfig) : Array (Name × Syntax) := +meta partial def decomposeOptConfig (cfg : TSyntax `Lean.Parser.Tactic.optConfig) : Array (Name × Syntax) := go cfg.raw #[] where go (s : Syntax) (acc : Array (Name × Syntax)) : Array (Name × Syntax) := @@ -88,7 +90,7 @@ The command `declare_partial_config_elab Config elabConfig optionPrefix` generat /-- Given a structure name, output the array (fieldName, fieldType, defaultValue) -/ -private def collectFieldInfo (structName : Name) : +private meta def collectFieldInfo (structName : Name) : MetaM (Array (Name × Expr × Expr)) := do let env ← getEnv let some si := getStructureInfo? env structName @@ -126,7 +128,7 @@ elab_rules : command let defSx : Term ← liftTermElabM (delab defVal) let descr := "Default value for field " ++ structName.toString ++ "." ++ field.toString elabCommand (← `(command| - initialize $(mkIdent optName) : Lean.Option $tySx ← + meta initialize $(mkIdent optName) : Lean.Option $tySx ← Lean.Option.register $(Lean.quote optName) { defValue := $defSx, descr := $(Lean.quote descr) })) @@ -210,11 +212,11 @@ elab_rules : command ``` -/ elabCommand (← `(command| - private unsafe def $(mkIdent implName) + private meta unsafe def $(mkIdent implName) (cfg : $optConfigTy) : $helperTy := $implBody)) elabCommand (← `(command| @[implemented_by $(mkIdent implName)] - opaque $(mkIdent elabFnName) + meta opaque $(mkIdent elabFnName) (cfg : $optConfigTy) : $helperTy)) /-! @@ -230,13 +232,13 @@ structure Config where declare_option_config_elab Config elabConfig exampleOptionPrefix /-- -info: opaque Aeneas.Meta.OptionConfig.Example.elabConfig : TSyntax `Lean.Parser.Tactic.optConfig → TermElabM Config +info: meta opaque Aeneas.Meta.OptionConfig.Example.elabConfig : TSyntax `Lean.Parser.Tactic.optConfig → TermElabM Config -/ #guard_msgs in #print elabConfig /-- -info: unsafe private def Aeneas.Meta.OptionConfig.Example.elabConfig.impl : TSyntax `Lean.Parser.Tactic.optConfig → +info: unsafe private meta def Aeneas.Meta.OptionConfig.Example.elabConfig.impl : TSyntax `Lean.Parser.Tactic.optConfig → TermElabM Config := fun cfg => let pairs := decomposeOptConfig cfg; diff --git a/backends/lean/AeneasMeta/Saturate.lean b/backends/lean/AeneasMeta/Saturate.lean index 5ea9564f1..d49f7054b 100644 --- a/backends/lean/AeneasMeta/Saturate.lean +++ b/backends/lean/AeneasMeta/Saturate.lean @@ -1 +1,2 @@ -import AeneasMeta.Saturate.Tactic +module +public import AeneasMeta.Saturate.Tactic diff --git a/backends/lean/AeneasMeta/Saturate/Attribute.lean b/backends/lean/AeneasMeta/Saturate/Attribute.lean index 6a5f750c6..dcc61a3e3 100644 --- a/backends/lean/AeneasMeta/Saturate/Attribute.lean +++ b/backends/lean/AeneasMeta/Saturate/Attribute.lean @@ -1,6 +1,8 @@ -import Lean -import AeneasMeta.Utils -import AeneasMeta.Extensions +module +public import Lean +public import AeneasMeta.Utils +public import AeneasMeta.Extensions +public section open Lean Lean.Meta Lean.Elab Lean.Elab.Term Lean.Elab.Tactic diff --git a/backends/lean/AeneasMeta/Saturate/Tactic.lean b/backends/lean/AeneasMeta/Saturate/Tactic.lean index d5e4c7a5c..a45c2bd44 100644 --- a/backends/lean/AeneasMeta/Saturate/Tactic.lean +++ b/backends/lean/AeneasMeta/Saturate/Tactic.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Saturate.Attribute +module +public import AeneasMeta.Saturate.Attribute +public section open Lean Lean.Meta Lean.Elab Lean.Elab.Term Lean.Elab.Tactic diff --git a/backends/lean/AeneasMeta/Simp.lean b/backends/lean/AeneasMeta/Simp.lean index ebf0e8845..987e8e2d9 100644 --- a/backends/lean/AeneasMeta/Simp.lean +++ b/backends/lean/AeneasMeta/Simp.lean @@ -1,3 +1,4 @@ -import AeneasMeta.Simp.Simp -import AeneasMeta.Simp.SimpAllAssumptions -import AeneasMeta.Simp.RegisterCommand +module +public import AeneasMeta.Simp.Simp +public import AeneasMeta.Simp.SimpAllAssumptions +public import AeneasMeta.Simp.RegisterCommand diff --git a/backends/lean/AeneasMeta/Simp/RegisterCommand.lean b/backends/lean/AeneasMeta/Simp/RegisterCommand.lean index 1c3c250f5..12cbb2c0f 100644 --- a/backends/lean/AeneasMeta/Simp/RegisterCommand.lean +++ b/backends/lean/AeneasMeta/Simp/RegisterCommand.lean @@ -1,6 +1,8 @@ /- Adapated from `Lean/Meta/Tactic/Simp/RegisterCommand.lean` -/ -import Lean.Meta.Tactic.Simp.Simproc -import Lean.Meta.Tactic.Simp.Attr +module +public meta import Lean.Meta.Tactic.Simp.Simproc +public import Lean.Meta.Tactic.Simp.Attr +public section namespace Aeneas.Simp diff --git a/backends/lean/AeneasMeta/Simp/Simp.lean b/backends/lean/AeneasMeta/Simp/Simp.lean index 322ea73a5..b64f95ff0 100644 --- a/backends/lean/AeneasMeta/Simp/Simp.lean +++ b/backends/lean/AeneasMeta/Simp/Simp.lean @@ -1,4 +1,6 @@ -import AeneasMeta.Utils +module +public import AeneasMeta.Utils +public section namespace Aeneas.Simp diff --git a/backends/lean/AeneasMeta/Simp/SimpAllAssumptions.lean b/backends/lean/AeneasMeta/Simp/SimpAllAssumptions.lean index a799324be..2040f718c 100644 --- a/backends/lean/AeneasMeta/Simp/SimpAllAssumptions.lean +++ b/backends/lean/AeneasMeta/Simp/SimpAllAssumptions.lean @@ -1,7 +1,9 @@ -import Lean.Meta.Tactic.Clear -import Lean.Meta.Tactic.Util -import Lean.Meta.Tactic.Simp.Main -import AeneasMeta.Simp.Simp +module +public import Lean.Meta.Tactic.Clear +public import Lean.Meta.Tactic.Util +public import Lean.Meta.Tactic.Simp.Main +public import AeneasMeta.Simp.Simp +public section /-! This file is adapted from Lean.Meta.Tactic.Simp.SimpAll.lean diff --git a/backends/lean/AeneasMeta/Split.lean b/backends/lean/AeneasMeta/Split.lean index 44a892040..c6969cd23 100644 --- a/backends/lean/AeneasMeta/Split.lean +++ b/backends/lean/AeneasMeta/Split.lean @@ -1,5 +1,7 @@ -import AeneasMeta.Utils -import AeneasMeta.Simp +module +public import AeneasMeta.Utils +public import AeneasMeta.Simp +public section namespace Aeneas.Split diff --git a/backends/lean/AeneasMeta/Utils.lean b/backends/lean/AeneasMeta/Utils.lean index 1d3d2d303..dcbb77039 100644 --- a/backends/lean/AeneasMeta/Utils.lean +++ b/backends/lean/AeneasMeta/Utils.lean @@ -1,5 +1,10 @@ -import Lean -import AeneasMeta.UtilsCore +module +public import Lean +public meta import Lean.Elab.Tactic.Location +public meta import Lean.Meta.Tactic.Rewrite +public meta import Lean.Elab.Tactic.NormCast +public import AeneasMeta.UtilsCore +public section namespace Lean @@ -9,16 +14,16 @@ namespace LocalContext -- Small utility: return the list of declarations in the context, from -- the last to the first. - def getAllDecls (lctx : Lean.LocalContext) : MetaM (List Lean.LocalDecl) := + meta def getAllDecls (lctx : Lean.LocalContext) : MetaM (List Lean.LocalDecl) := lctx.foldrM (fun d ls => do let d ← instantiateLocalDeclMVars d; pure (d :: ls)) [] -- Return the list of declarations in the context, but filter the -- declarations which are considered as implementation details - def getDecls (lctx : Lean.LocalContext) : MetaM (List Lean.LocalDecl) := do + meta def getDecls (lctx : Lean.LocalContext) : MetaM (List Lean.LocalDecl) := do let ls ← lctx.getAllDecls pure (ls.filter (fun d => not d.isImplementationDetail)) - def getAssumptions (lctx : Lean.LocalContext) : MetaM (List Lean.LocalDecl) := do + meta def getAssumptions (lctx : Lean.LocalContext) : MetaM (List Lean.LocalDecl) := do let ls ← lctx.getDecls ls.filterM (fun d => isProp d.type) @@ -34,7 +39,7 @@ open Lean Elab Term Meta Tactic -- Useful helper to explore definitions and figure out the variant -- of their sub-expressions. -def explore_term (incr : String) (e : Expr) : MetaM Unit := +meta def explore_term (incr : String) (e : Expr) : MetaM Unit := match e with | .bvar _ => do logInfo m!"{incr}bvar: {e}"; return () | .fvar _ => do logInfo m!"{incr}fvar: {e}"; return () @@ -66,7 +71,7 @@ def explore_term (incr : String) (e : Expr) : MetaM Unit := logInfo m!"{incr}proj: {e}" explore_term (incr ++ " ") struct -def explore_decl (n : Name) : TermElabM Unit := do +meta def explore_decl (n : Name) : TermElabM Unit := do logInfo m!"Name: {n}" let env ← getEnv let decl := env.constants.find! n @@ -89,7 +94,8 @@ syntax (name := printDecl) "print_decl " ident : command open Lean.Elab.Command -@[command_elab printDecl] def elabPrintDecl : CommandElab := fun stx => do +@[command_elab printDecl] +meta def elabPrintDecl : CommandElab := fun stx => do liftTermElabM do let id := stx[1] addCompletionInfo <| CompletionInfo.id id id.getId (danglingDot := false) {} none @@ -97,7 +103,7 @@ open Lean.Elab.Command let name := cs.constName! explore_decl name -def printDecls (decls : List LocalDecl) : MetaM Unit := do +meta def printDecls (decls : List LocalDecl) : MetaM Unit := do let decls ← decls.foldrM (λ decl msg => do pure (m!"\n{decl.toExpr} : {← inferType decl.toExpr}" ++ msg)) m!"" logInfo m!"# Ctx decls:{decls}" @@ -118,7 +124,7 @@ elab "print_ctx_decls" : tactic => do -- The continuation takes as parameters: -- - the current depth of the expression (useful for printing/debugging) -- - the expression to explore -partial def mapreduceVisit {a : Type} (k : Nat → a → Expr → MetaM (a × Expr)) +meta partial def mapreduceVisit {a : Type} (k : Nat → a → Expr → MetaM (a × Expr)) (state : a) (e : Expr) : MetaM (a × Expr) := do let mapreduceVisitBinders (state : a) (xs : Array Expr) (k2 : a → MetaM (a × Expr)) : MetaM (a × Expr) := do @@ -190,7 +196,7 @@ partial def mapreduceVisit {a : Type} (k : Nat → a → Expr → MetaM (a × Ex -- The continuation takes as parameters: -- - the current depth of the expression (useful for printing/debugging) -- - the expression to explore -partial def mapVisit (k : Nat → Expr → MetaM Expr) (e : Expr) : MetaM Expr := do +meta partial def mapVisit (k : Nat → Expr → MetaM Expr) (e : Expr) : MetaM Expr := do let k' i (_ : Unit) e := do let e ← k i e pure ((), e) @@ -198,7 +204,7 @@ partial def mapVisit (k : Nat → Expr → MetaM Expr) (e : Expr) : MetaM Expr : pure e -- A reduce visitor -partial def reduceVisit {a : Type} (k : Nat → a → Expr → MetaM a) (s : a) (e : Expr) : MetaM a := do +meta partial def reduceVisit {a : Type} (k : Nat → a → Expr → MetaM a) (s : a) (e : Expr) : MetaM a := do let k' i (s : a) e := do let s ← k i s e pure (s, e) @@ -207,14 +213,14 @@ partial def reduceVisit {a : Type} (k : Nat → a → Expr → MetaM a) (s : a) -- Generate a fresh user name for an anonymous proposition to introduce in the -- assumptions -def mkFreshAnonPropUserName := mkFreshUserName `_ +meta def mkFreshAnonPropUserName := mkFreshUserName `_ section Methods variable [MonadLiftT MetaM m] [MonadControlT MetaM m] [Monad m] [MonadError m] variable {a : Type} /- Like `lambdaTelescopeN` but only destructs a fixed number of lambdas -/ - def lambdaTelescopeN (e : Expr) (n : Nat) (k : Array Expr → Expr → m a) : m a := + meta def lambdaTelescopeN (e : Expr) (n : Nat) (k : Array Expr → Expr → m a) : m a := lambdaTelescope e fun xs body => do if xs.size < n then throwError "lambdaTelescopeN: not enough lambdas" let xs := xs.extract 0 n @@ -225,14 +231,14 @@ section Methods /- Like `lambdaTelescope`, but only destructs one lambda TODO: is there an equivalent of this function somewhere in the standard library? -/ - def lambdaOne (e : Expr) (k : Expr → Expr → m a) : m a := + meta def lambdaOne (e : Expr) (k : Expr → Expr → m a) : m a := lambdaTelescopeN e 1 λ xs b => k (xs[0]!) b - def isExists (e : Expr) : Bool := e.getAppFn.isConstOf ``Exists ∧ e.getAppNumArgs = 2 + meta def isExists (e : Expr) : Bool := e.getAppFn.isConstOf ``Exists ∧ e.getAppNumArgs = 2 -- Remark: Lean doesn't find the inhabited and nonempty instances if we don' -- put them explicitely in the signature - partial def existsTelescopeProcess [Inhabited (m a)] [Nonempty (m a)] + meta partial def existsTelescopeProcess [Inhabited (m a)] [Nonempty (m a)] (fvars : Array Expr) (e : Expr) (k : Array Expr → Expr → m a) : m a := do -- Attempt to deconstruct an existential if isExists e then do @@ -243,7 +249,7 @@ section Methods -- No existential: call the continuation k fvars e - def existsTelescope [Inhabited (m a)] [Nonempty (m a)] (e : Expr) (k : Array Expr → Expr → m a) : m a := do + meta def existsTelescope [Inhabited (m a)] [Nonempty (m a)] (e : Expr) (k : Array Expr → Expr → m a) : m a := do existsTelescopeProcess #[] e k end Methods @@ -254,7 +260,7 @@ inductive Location where /-- Same as Location -/ | targets (hypotheses : Array FVarId) (type : Bool) -def addDeclTac {α} (name : Name) (val : Expr) (type : Expr) (asLet : Bool) (m : Expr → TacticM α) : +meta def addDeclTac {α} (name : Name) (val : Expr) (type : Expr) (asLet : Bool) (m : Expr → TacticM α) : TacticM α := -- I don't think we need that withMainContext do @@ -278,7 +284,7 @@ def addDeclTac {α} (name : Name) (val : Expr) (type : Expr) (asLet : Bool) (m : -- after the declaration was added, so it will persist m nval -def addDeclTacSyntax (name : Name) (val : Syntax) (asLet : Bool) : TacticM Unit := +meta def addDeclTacSyntax (name : Name) (val : Syntax) (asLet : Bool) : TacticM Unit := -- I don't think we need that withMainContext do -- @@ -306,7 +312,7 @@ example (x : Bool) : Nat := by cases x <;> custom_let x := 3 <;> apply x -- Attempt to apply a tactic -def tryTac (tac : TacticM Unit) : TacticM Unit := do +meta def tryTac (tac : TacticM Unit) : TacticM Unit := do let _ ← tryTactic tac /-- Copy/pasted from Mathlib because we do not want to add it as a dependency for this module @@ -333,7 +339,7 @@ def allGoals (tac : TacticM Unit) : TacticM Unit := do We sometimes use this rather than `allGoals`, because when the tactic throws an exception that we attempt to catch outside, the behavior can be quite surprising. -/ -def allGoalsNoRecover (tac : TacticM Unit) : TacticM Unit := do +meta def allGoalsNoRecover (tac : TacticM Unit) : TacticM Unit := do let mvarIds ← getGoals let mut mvarIdsNew := #[] for mvarId in mvarIds do @@ -344,7 +350,7 @@ def allGoalsNoRecover (tac : TacticM Unit) : TacticM Unit := do setGoals mvarIdsNew.toList -- Repeatedly apply a tactic -partial def repeatTac (tac : TacticM Unit) : TacticM Unit := do +meta partial def repeatTac (tac : TacticM Unit) : TacticM Unit := do try tac allGoalsNoRecover (focus (repeatTac tac)) @@ -362,19 +368,19 @@ def firstTacSolve (tacl : List (TacticM Unit)) : TacticM Unit := do if ¬ gl.isEmpty then throwError "tactic failed" catch _ => firstTacSolve tacl -def isConj (e : Expr) : MetaM Bool := +meta def isConj (e : Expr) : MetaM Bool := e.consumeMData.withApp fun f args => pure (f.isConstOf ``And ∧ args.size = 2) -- Return the first conjunct if the expression is a conjunction, or the -- expression itself otherwise. Also return the second conjunct if it is a -- conjunction. -def optSplitConj (e : Expr) : Expr × Option Expr := +meta def optSplitConj (e : Expr) : Expr × Option Expr := e.consumeMData.withApp fun f args => if f.isConstOf ``And ∧ args.size = 2 then (args[0]!, some (args[1]!)) else (e, none) -- Tactic to split on a conjunction. -partial def splitConjs (e : Expr) : List Expr := +meta partial def splitConjs (e : Expr) : List Expr := let (e, optE) := optSplitConj e.consumeMData match optE with | none => [e] @@ -382,7 +388,7 @@ partial def splitConjs (e : Expr) : List Expr := e :: splitConjs e' -- Split the goal if it is a conjunction -def splitConjTarget : TacticM Unit := do +meta def splitConjTarget : TacticM Unit := do withMainContext do let g ← getMainTarget trace[Utils] "splitConjTarget: goal: {g}" @@ -441,13 +447,13 @@ partial def destProdsVal (x : Expr) : List Expr := -- Return the set of FVarIds in the expression -- TODO: this collects fvars introduced in the inner bindings -partial def getFVarIds (e : Expr) (hs : Std.HashSet FVarId := Std.HashSet.emptyWithCapacity) : MetaM (Std.HashSet FVarId) := do +meta partial def getFVarIds (e : Expr) (hs : Std.HashSet FVarId := Std.HashSet.emptyWithCapacity) : MetaM (Std.HashSet FVarId) := do reduceVisit (fun _ (hs : Std.HashSet FVarId) e => if e.isFVar then pure (hs.insert e.fvarId!) else pure hs) hs e -- Return the set of MVarIds in the expression -partial def getMVarIds (e : Expr) (hs : Std.HashSet MVarId := Std.HashSet.emptyWithCapacity) : MetaM (Std.HashSet MVarId) := do +meta partial def getMVarIds (e : Expr) (hs : Std.HashSet MVarId := Std.HashSet.emptyWithCapacity) : MetaM (Std.HashSet MVarId) := do reduceVisit (fun _ (hs : Std.HashSet MVarId) e => if e.isMVar then pure (hs.insert e.mvarId!) else pure hs) hs e @@ -456,14 +462,14 @@ partial def getMVarIds (e : Expr) (hs : Std.HashSet MVarId := Std.HashSet.emptyW def assumptionTac : TacticM Unit := liftMetaTactic fun mvarId => do mvarId.assumption; pure [] -def filterAssumptionTacPreprocess : TacticM (DiscrTree FVarId) := do +meta def filterAssumptionTacPreprocess : TacticM (DiscrTree FVarId) := do let mut dtree := DiscrTree.empty for decl in (← (← getLCtx).getDecls) do dtree ← dtree.insert decl.type decl.fvarId pure dtree /-- Return `true` if managed to close goal `mvarId` using an assumption. -/ -def filterAssumptionTacCore (dtree : DiscrTree FVarId) : TacticM Bool := do +meta def filterAssumptionTacCore (dtree : DiscrTree FVarId) : TacticM Bool := do withMainContext do let g ← getMainGoal let type ← instantiateMVars (← g.getType) @@ -485,7 +491,7 @@ def filterAssumptionTacCore (dtree : DiscrTree FVarId) : TacticM Bool := do easily triggers "maximum recursion reached" errors when there are big integer constants in the context. -/ -def filterAssumptionTac : TacticM Bool := do +meta def filterAssumptionTac : TacticM Bool := do let dtree ← filterAssumptionTacPreprocess filterAssumptionTacCore dtree @@ -508,7 +514,7 @@ example (x y : Nat) (_ : y * 3000 ≤ 1) (_ : x * 3000 ≤ 1) : y * 3000 ≤ 1 : fassumption /- List all the local declarations matching the goal. -/ -def getMatchingAssumptions (type : Expr) (transparency : Meta.TransparencyMode := .reducible) : +meta def getMatchingAssumptions (type : Expr) (transparency : Meta.TransparencyMode := .reducible) : MetaM (List (LocalDecl × Name)) := withTransparency transparency do let typeType ← inferType type @@ -526,10 +532,10 @@ def getMatchingAssumptions (type : Expr) (transparency : Meta.TransparencyMode : restoreState s pure x -def singleAssumptionTacPreprocess := filterAssumptionTacPreprocess +meta def singleAssumptionTacPreprocess := filterAssumptionTacPreprocess /-- `instMVars`: if `true`, we allow instantiating meta-variables -/ -def singleAssumptionTacCore (dtree : DiscrTree FVarId) (instMVars : Bool) : TacticM Unit := do +meta def singleAssumptionTacCore (dtree : DiscrTree FVarId) (instMVars : Bool) : TacticM Unit := do withMainContext do let mvarId ← getMainGoal mvarId.checkNotAssigned `sassumption @@ -569,7 +575,7 @@ def singleAssumptionTacCore (dtree : DiscrTree FVarId) (instMVars : Bool) : Tact We implement this behaviour to make sure we do not trigger spurious instantiations of meta-variables. -/ -def singleAssumptionTac : TacticM Unit := do +meta def singleAssumptionTac : TacticM Unit := do let dtree ← singleAssumptionTacPreprocess singleAssumptionTacCore dtree true @@ -586,7 +592,7 @@ example (x y z w : Int) (h0 : x < y) (_ : x < w) (h1 : y < z) : x < z := by TODO: there must be simpler. Use use _root_.Lean.MVarId.cases for instance. On the other hand this tactic is a good reference for this kind of manipulations. -/ -def splitDisjTac (h : Expr) (kleft kright : Expr → TacticM Unit) : TacticM Unit := do +meta def splitDisjTac (h : Expr) (kleft kright : Expr → TacticM Unit) : TacticM Unit := do trace[Utils] "assumption on which to split: {h}" -- Retrieve the main goal withMainContext do @@ -642,7 +648,7 @@ def splitDisjTac (h : Expr) (kleft kright : Expr → TacticM Unit) : TacticM Uni setGoals (leftGoals ++ rightGoals ++ goals) trace[Utils] "new goals: {← getUnsolvedGoals}" -partial def splitDisjsTac (h : Expr) : TacticM Unit := +meta partial def splitDisjsTac (h : Expr) : TacticM Unit := tryTac (splitDisjTac h splitDisjsTac splitDisjsTac) elab "split_disj" " at " n:ident : tactic => do @@ -667,7 +673,7 @@ example (x : Int) (h : x = 0 ∨ x = 1 ∨ x = 2) : x ≤ 2 := by -- Tactic to split on an exists. -- `h` must be an FVar -def splitExistsTac (h : Expr) (optId : Option Name) (k : Expr → Expr → TacticM α) : TacticM α := do +meta def splitExistsTac (h : Expr) (optId : Option Name) (k : Expr → Expr → TacticM α) : TacticM α := do withMainContext do let goal ← getMainGoal let hTy ← inferType h @@ -708,7 +714,7 @@ def listTryPopHead (ls : List α) : Option α × List α := If `ids` is not empty, we use it to name the introduced variables. We transmit the stripped expression and the remaining ids to the continuation. -/ -partial def splitAllExistsTac [Inhabited α] (h : Expr) (ids : List (Option Name)) +meta partial def splitAllExistsTac [Inhabited α] (h : Expr) (ids : List (Option Name)) (k : Array Expr → Expr → List (Option Name) → TacticM α) : TacticM α := do let rec run (fvars : Array Expr) h ids := do if isExists (← inferType h) then do @@ -721,7 +727,7 @@ partial def splitAllExistsTac [Inhabited α] (h : Expr) (ids : List (Option Name run #[] h ids -- Tactic to split on a conjunction. -def splitConjTac (h : Expr) (optIds : Option (Name × Name)) (k : Expr → Expr → TacticM α) : TacticM α := do +meta def splitConjTac (h : Expr) (optIds : Option (Name × Name)) (k : Expr → Expr → TacticM α) : TacticM α := do withMainContext do let goal ← getMainGoal let hTy ← inferType h @@ -752,7 +758,7 @@ def splitConjTac (h : Expr) (optIds : Option (Name × Name)) (k : Expr → Expr throwError "Not a conjunction" -- Tactic to fully split a conjunction -partial def splitFullConjTacAux [Inhabited α] [Nonempty α] (keepCurrentName : Bool) (l : List Expr) (h : Expr) (k : List Expr → TacticM α) : TacticM α := do +meta partial def splitFullConjTacAux [Inhabited α] [Nonempty α] (keepCurrentName : Bool) (l : List Expr) (h : Expr) (k : List Expr → TacticM α) : TacticM α := do try let ids ← do if keepCurrentName then do @@ -770,12 +776,12 @@ partial def splitFullConjTacAux [Inhabited α] [Nonempty α] (keepCurrentName : -- Tactic to fully split a conjunction -- `keepCurrentName`: if `true`, then the first conjunct has the name of the original assumption -def splitFullConjTac [Inhabited α] [Nonempty α] (keepCurrentName : Bool) (h : Expr) (k : List Expr → TacticM α) : TacticM α := do +meta def splitFullConjTac [Inhabited α] [Nonempty α] (keepCurrentName : Bool) (h : Expr) (k : List Expr → TacticM α) : TacticM α := do splitFullConjTacAux keepCurrentName [] h (λ l => k l.reverse) syntax optAtArgs := ("at" ident)? -def elabOptAtArgs (args : TSyntax `Aeneas.Utils.optAtArgs) : TacticM (Option Expr) := do +meta def elabOptAtArgs (args : TSyntax `Aeneas.Utils.optAtArgs) : TacticM (Option Expr) := do withMainContext do let args := (args.raw.getArgs[0]!).getArgs if args.size > 0 then do @@ -822,14 +828,14 @@ example (h : ∃ x y z, x + y + z ≥ 0) : ∃ x, x ≥ 0 := by exists x + y + z /- Adapted from Elab.Tactic.Rewrite -/ -def rewriteTarget (eqThm : Expr) (symm : Bool) (config : Rewrite.Config := {}) : TacticM Unit := do +meta def rewriteTarget (eqThm : Expr) (symm : Bool) (config : Rewrite.Config := {}) : TacticM Unit := do Term.withSynthesize <| withMainContext do let r ← (← getMainGoal).rewrite (← getMainTarget) eqThm symm (config := config) let mvarId' ← (← getMainGoal).replaceTargetEq r.eNew r.eqProof replaceMainGoal (mvarId' :: r.mvarIds) /- Adapted from Elab.Tactic.Rewrite -/ -def rewriteLocalDecl (eqThm : Expr) (symm : Bool) (fvarId : FVarId) (config : Rewrite.Config := {}) : +meta def rewriteLocalDecl (eqThm : Expr) (symm : Bool) (fvarId : FVarId) (config : Rewrite.Config := {}) : TacticM Unit := withMainContext do -- Note: we cannot execute `replaceLocalDecl` inside `Term.withSynthesize`. -- See issues #2711 and #2727. @@ -840,7 +846,7 @@ def rewriteLocalDecl (eqThm : Expr) (symm : Bool) (fvarId : FVarId) (config : Re replaceMainGoal (replaceResult.mvarId :: rwResult.mvarIds) /- Adapted from Elab.Tactic.Rewrite -/ -def rewriteWithThms +meta def rewriteWithThms (thms : List (Bool × Expr)) (rewrite : (symm : Bool) → (thm : Expr) → TacticM Unit) : TacticM Unit := do @@ -852,7 +858,7 @@ def rewriteWithThms go thms /- Adapted from Elab.Tactic.Rewrite -/ -def evalRewriteSeqAux (cfg : Rewrite.Config) (thms : List (Bool × Expr)) (loc : Tactic.Location) : TacticM Unit := +meta def evalRewriteSeqAux (cfg : Rewrite.Config) (thms : List (Bool × Expr)) (loc : Tactic.Location) : TacticM Unit := rewriteWithThms thms fun symm term => do withLocation loc (rewriteLocalDecl term symm · cfg) @@ -860,7 +866,7 @@ def evalRewriteSeqAux (cfg : Rewrite.Config) (thms : List (Bool × Expr)) (loc : (throwTacticEx `rewrite · "did not find instance of the pattern in the current goal") /-- `rpt`: if `true`, repeatedly rewrite -/ -def rewriteAt (cfg : Rewrite.Config) (rpt : Bool) +meta def rewriteAt (cfg : Rewrite.Config) (rpt : Bool) (thms : List (Bool × Name)) (loc : Tactic.Location) : TacticM Unit := do -- Lookup the theorems let lookupThm (x : Bool × Name) : TacticM (List (Bool × Expr)) := do @@ -882,7 +888,7 @@ def rewriteAt (cfg : Rewrite.Config) (rpt : Bool) else evalRewriteSeqAux cfg thms loc -@[inline] def liftMetaTactic2 (tactic : MVarId → MetaM (Option (α × MVarId))) : TacticM (Option α) := +@[inline] meta def liftMetaTactic2 (tactic : MVarId → MetaM (Option (α × MVarId))) : TacticM (Option α) := withMainContext do if let some (res, mvarId) ← tactic (← getMainGoal) then replaceMainGoal [mvarId] @@ -892,14 +898,14 @@ def rewriteAt (cfg : Rewrite.Config) (rpt : Bool) pure none /-- Copy/paster from `norm_cast`: we need to retrieve the new fvar id -/ -def normCastHyp (cfg : Simp.NormCastConfig) (fvarId : FVarId) : TacticM (Option FVarId) := +meta def normCastHyp (cfg : Simp.NormCastConfig) (fvarId : FVarId) : TacticM (Option FVarId) := liftMetaTactic2 fun goal => do let hyp ← instantiateMVars (← fvarId.getDecl).type let prf ← NormCast.derive hyp cfg return (← applySimpResultToLocalDecl goal fvarId prf false) /- Return `none` if the goal was closed, otherwise return the modified fvar ids -/ -def normCastAt (loc : Location) : TacticM (Option (Array (FVarId))) := do +meta def normCastAt (loc : Location) : TacticM (Option (Array (FVarId))) := do withMainContext do match loc with | .targets asms tgt => @@ -982,7 +988,7 @@ end /-- Split anything in the context, and return the resulting set of subgoals. Raise an exception if we couldn't split. -/ -def splitAny : TacticM (List MVarId) := do +meta def splitAny : TacticM (List MVarId) := do -- This is taken from `evalSplit` let mvarId ← getMainGoal let fvarIds ← mvarId.getNondepPropHyps @@ -1005,7 +1011,7 @@ def splitLocalDecl (mvarId : MVarId) (fvarId : FVarId) : TacticM (Option (List ( pure (mvarId, nfvarIds) /-- Repeteadly split the disjunctions in the context, then apply a tactic when we can't split anymore -/ -partial def splitAll (endTac : TacticM Unit) : TacticM Unit := do +meta partial def splitAll (endTac : TacticM Unit) : TacticM Unit := do withMainContext do try let mvarIds ← splitAny @@ -1059,7 +1065,7 @@ example (x y : Int) : True := by dcases h: x = y <;> simp /-- Inspired by the `clear` tactic -/ -def clearFVarIds (fvarIds : Array FVarId) : TacticM Unit := do +meta def clearFVarIds (fvarIds : Array FVarId) : TacticM Unit := do let fvarIds ← withMainContext <| sortFVarIds fvarIds for fvarId in fvarIds.reverse do withMainContext do @@ -1070,11 +1076,11 @@ def clearFVarIds (fvarIds : Array FVarId) : TacticM Unit := do namespace MathlibDuplicate /-- Given a local context and an array of `FVarIds` assumed to be in that local context, remove all implementation details. -/ - def filterOutImplementationDetails (lctx : LocalContext) (fvarIds : Array FVarId) : Array FVarId := + meta def filterOutImplementationDetails (lctx : LocalContext) (fvarIds : Array FVarId) : Array FVarId := fvarIds.filter (fun fvar => ! (lctx.fvarIdToDecl.find! fvar).isImplementationDetail) /-- Elaborate syntax for an `FVarId` in the local context of the given goal. -/ - def getFVarIdAt (goal : MVarId) (id : Syntax) : TacticM FVarId := withRef id do + meta def getFVarIdAt (goal : MVarId) (id : Syntax) : TacticM FVarId := withRef id do -- use apply-like elaboration to suppress insertion of implicit arguments let e ← goal.withContext do elabTermForApply id (mayPostpone := false) @@ -1089,7 +1095,7 @@ namespace MathlibDuplicate If `includeImplementationDetails` is `false` (the default), we filter out implementation details (`implDecl`s and `auxDecl`s) from the resulting list of `FVarId`s. -/ - def getFVarIdsAt (goal : MVarId) (ids : Option (Array Syntax) := none) + meta def getFVarIdsAt (goal : MVarId) (ids : Option (Array Syntax) := none) (includeImplementationDetails : Bool := false) : TacticM (Array FVarId) := goal.withContext do let lctx := (← goal.getDecl).lctx @@ -1103,7 +1109,7 @@ namespace MathlibDuplicate end MathlibDuplicate /-- Minimize the goal by removing all the unnecessary variables and assumptions -/ -partial def minimizeGoal : TacticM Unit := do +meta partial def minimizeGoal : TacticM Unit := do withMainContext do /- Retrieve the goal -/ let goalTy ← instantiateMVars (← (← getMainGoal).getType) @@ -1186,7 +1192,7 @@ elab "minimize_goal" : tactic => do minimizeGoal /-- Print the goal as an auxiliary lemma that can be copy-pasted by the user -/ -def extractGoal (ref : Syntax) (fullGoal : Bool) : TacticM Unit := do +meta def extractGoal (ref : Syntax) (fullGoal : Bool) : TacticM Unit := do /- First minimize the goal, if necessary -/ if ¬ fullGoal then minimizeGoal @@ -1337,7 +1343,7 @@ example (i : Nat) (h : i ≤ 7) : apply h /-- Introduce an auxiliary assertion for the goal -/ -def extractAssert (ref : Syntax) : TacticM Unit := do +meta def extractAssert (ref : Syntax) : TacticM Unit := do withMainContext do let goal ← (← getMainGoal).getType let goal ← Lean.Meta.Tactic.TryThis.delabToRefinableSyntax goal @@ -1380,7 +1386,7 @@ def mkProd (x y : Expr) : MetaM Expr := For instance, deconstructs `(a : Type) × List a` into `Type` and `λ a => List a`. -/ -def getSigmaTypes (ty : Expr) : MetaM (Expr × Expr) := do +meta def getSigmaTypes (ty : Expr) : MetaM (Expr × Expr) := do ty.withApp fun f args => do if ¬ f.isConstOf ``Sigma ∨ args.size ≠ 2 then throwError "Invalid argument to getSigmaTypes: {ty}" @@ -1456,7 +1462,7 @@ def mkProdsType (xl : List Expr) : MetaM Expr := Also, we stop at the first input that we treat as an input type. -/ -def splitInputArgs (in_tys : Array Expr) (out_ty : Expr) : MetaM (Array Expr × Array Expr) := do +meta def splitInputArgs (in_tys : Array Expr) (out_ty : Expr) : MetaM (Array Expr × Array Expr) := do -- Look for the first parameter which appears in the subsequent parameters let rec splitAux (in_tys : List Expr) : MetaM (Std.HashSet FVarId × List Expr × List Expr) := match in_tys with @@ -1485,7 +1491,7 @@ def splitInputArgs (in_tys : Array Expr) (out_ty : Expr) : MetaM (Array Expr × pure (Array.mk in_tys, Array.mk in_args) /- Apply a lambda expression to some arguments, simplifying the lambdas -/ -def applyLambdaToArgs (e : Expr) (xs : Array Expr) : MetaM Expr := do +meta def applyLambdaToArgs (e : Expr) (xs : Array Expr) : MetaM Expr := do lambdaTelescopeN e xs.size fun vars body => -- Create the substitution let s : Std.HashMap FVarId Expr := Std.HashMap.ofList (List.zip (vars.toList.map Expr.fvarId!) xs.toList) @@ -1510,7 +1516,7 @@ def applyLambdaToArgs (e : Expr) (xs : Array Expr) : MetaM Expr := do Example: `⟨ True, 3 ⟩ : (x : Bool) × (if x then Int else Unit)` -/ -def mkSigmasVal (ty : Expr) (xl : List Expr) : MetaM Expr := +meta def mkSigmasVal (ty : Expr) (xl : List Expr) : MetaM Expr := match xl with | [] => do trace[Utils] "mkSigmasVal: []" @@ -1693,7 +1699,7 @@ def mkProdsMatchOrUnit (xl : List Expr) (out : Expr) : MetaM Expr := We return the pair: (original assumptions, new assumptions) -/ -def duplicateAssumptions (toDuplicate : Option (Array FVarId) := none) : +meta def duplicateAssumptions (toDuplicate : Option (Array FVarId) := none) : TacticM (Array FVarId × Array FVarId) := withMainContext do let decls ← do diff --git a/backends/lean/AeneasMeta/UtilsCore.lean b/backends/lean/AeneasMeta/UtilsCore.lean index 15d9caaca..d79506754 100644 --- a/backends/lean/AeneasMeta/UtilsCore.lean +++ b/backends/lean/AeneasMeta/UtilsCore.lean @@ -1,4 +1,6 @@ -import Lean +module +public import Lean +public section namespace Aeneas diff --git a/src/Translate.ml b/src/Translate.ml index 6d471f280..778840305 100644 --- a/src/Translate.ml +++ b/src/Translate.ml @@ -1312,6 +1312,9 @@ let extract_file (config : gen_config) (ctx : gen_ctx) (fi : extract_file_info) (* Create the header *) (match Config.backend () with | Lean -> + (* Opt into the Lean module system (the [module] keyword must be the first + command of the file). *) + Printf.fprintf out "module\n"; Printf.fprintf out "-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS\n"; Printf.fprintf out "-- [%s]%s\n" fi.rust_module_name fi.custom_msg | Coq | FStar | HOL4 -> @@ -1365,11 +1368,18 @@ let extract_file (config : gen_config) (ctx : gen_ctx) (fi : extract_file_info) fi.custom_includes; Printf.fprintf out "Module %s.\n" fi.module_name | Lean -> - Printf.fprintf out "import Aeneas\n"; + Printf.fprintf out "public import Aeneas\n"; (* Add the custom imports *) - List.iter (fun m -> Printf.fprintf out "import %s\n" m) fi.custom_imports; + List.iter + (fun m -> Printf.fprintf out "public import %s\n" m) + fi.custom_imports; (* Add the custom includes *) - List.iter (fun m -> Printf.fprintf out "import %s\n" m) fi.custom_includes; + List.iter + (fun m -> Printf.fprintf out "public import %s\n" m) + fi.custom_includes; + (* Everything below is part of the module's public interface (module + system). *) + Printf.fprintf out "public section\n"; (* Always open the Primitives namespace *) Printf.fprintf out "open Aeneas Aeneas.Std Result ControlFlow Error\n"; (* It happens that we generate duplicated namespaces, like `betree.betree`. @@ -2146,8 +2156,10 @@ let extract_translated_crate (filename : string) (dest_dir : string) if !Config.split_files && !Config.generate_lib_entry_point then ( let filename = Filename.concat dest_dir (crate_name ^ ".lean") in let out = open_out filename in - (* Write *) - Printf.fprintf out "import %s.Funs\n" crate_name; + (* Write (using the Lean module system) *) + Printf.fprintf out "module\n"; + Printf.fprintf out "public import %s.Funs\n" crate_name; + Printf.fprintf out "public section\n"; (* Flush and close the file, log *) close_out out; log#linfo (lazy ("Generated: " ^ filename))); diff --git a/tests/lean/Constants.lean b/tests/lean/Constants.lean index 9c6e58863..4dbc188fe 100644 --- a/tests/lean/Constants.lean +++ b/tests/lean/Constants.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [constants] -import Aeneas +public import Aeneas +public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false From 39c4160b21321916c8fd72544297ef558eb83a49 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Tue, 21 Jul 2026 15:31:52 +0200 Subject: [PATCH 02/40] a bit more --- backends/lean/AeneasMeta/Async/TestTactics.lean | 9 ++++++--- backends/lean/AeneasMeta/Extensions.lean | 4 ++-- backends/lean/AeneasMeta/Saturate/Attribute.lean | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/backends/lean/AeneasMeta/Async/TestTactics.lean b/backends/lean/AeneasMeta/Async/TestTactics.lean index f23077fe5..b9c255939 100644 --- a/backends/lean/AeneasMeta/Async/TestTactics.lean +++ b/backends/lean/AeneasMeta/Async/TestTactics.lean @@ -1,6 +1,9 @@ module public import AeneasMeta.Async.Async public import AeneasMeta.Simp +public meta import AeneasMeta.Utils +public meta import AeneasMeta.Async.Async +public meta import AeneasMeta.Simp.Simp public import Lean public section @@ -17,21 +20,21 @@ open Lean Elab Tactic Utils Note that `scalarTac` does quite a few things, so it tends to be expensive (in the example below, looking at the trace for the synchronous case, it requires ~0.016s for every subgoal). -/ -def trySyncOmega : TacticM Unit := do +meta def trySyncOmega : TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure "repeatTac") (repeatTac splitConjTarget) allGoals (Tactic.Omega.omegaTactic {}) scoped syntax "sync_solve_omega" : tactic scoped elab "sync_solve_omega" : tactic => do trySyncOmega -def tryAsyncOmega : TacticM Unit := do +meta def tryAsyncOmega : TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure "repeatTac") (repeatTac splitConjTarget) allGoalsAsync (Tactic.Omega.omegaTactic {}) scoped syntax "async_solve_omega" : tactic scoped elab "async_solve_omega" : tactic => do tryAsyncOmega -def tryAsyncSimp : TacticM Unit := do +meta def tryAsyncSimp : TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure "repeatTac") (repeatTac splitConjTarget) allGoalsAsync (do let _ ← Simp.simpAt false {} {} (.targets #[] true)) (prio := .max) diff --git a/backends/lean/AeneasMeta/Extensions.lean b/backends/lean/AeneasMeta/Extensions.lean index fa5fd190e..cd20ea4f8 100644 --- a/backends/lean/AeneasMeta/Extensions.lean +++ b/backends/lean/AeneasMeta/Extensions.lean @@ -14,7 +14,7 @@ namespace Extensions open Lean Elab Term Meta open Utils -def ListDeclarationExtension (α : Type) := SimplePersistentEnvExtension α (List α) +@[expose] def ListDeclarationExtension (α : Type) := SimplePersistentEnvExtension α (List α) instance : Inhabited (ListDeclarationExtension α) := inferInstanceAs (Inhabited (SimplePersistentEnvExtension ..)) @@ -28,7 +28,7 @@ def mkListDeclarationExtension [Inhabited α] (name : Name := by exact decl_name toArrayFn := fun l => l.toArray } -def SetDeclarationExtension := SimplePersistentEnvExtension Name NameSet +@[expose] def SetDeclarationExtension := SimplePersistentEnvExtension Name NameSet def mkSetDeclarationExtension (name : Name := by exact decl_name%) : IO SetDeclarationExtension := diff --git a/backends/lean/AeneasMeta/Saturate/Attribute.lean b/backends/lean/AeneasMeta/Saturate/Attribute.lean index dcc61a3e3..4c7f80783 100644 --- a/backends/lean/AeneasMeta/Saturate/Attribute.lean +++ b/backends/lean/AeneasMeta/Saturate/Attribute.lean @@ -1,6 +1,6 @@ module public import Lean -public import AeneasMeta.Utils +public meta import AeneasMeta.Utils public import AeneasMeta.Extensions public section @@ -154,7 +154,7 @@ structure SaturateAttribute where ext : Extension deriving Inhabited -def makeAttribute (mapName attributeName : Name) (elabAttribute : Syntax → MetaM (Option Syntax)) : +meta def makeAttribute (mapName attributeName : Name) (elabAttribute : Syntax → MetaM (Option Syntax)) : IO SaturateAttribute := do let ext ← mkExtension mapName let attrImpl : AttributeImpl := { From cfe02f6dd296754fe0594e5329d1766e8c250c8e Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Tue, 21 Jul 2026 19:42:03 +0200 Subject: [PATCH 03/40] more progress --- backends/lean/Aeneas/Data/Tuples.lean | 8 +-- backends/lean/Aeneas/Tactic/Misc/Let/Let.lean | 4 +- .../lean/AeneasMeta/Saturate/Attribute.lean | 38 ++++++------- backends/lean/AeneasMeta/Saturate/Tactic.lean | 56 +++++++++---------- backends/lean/AeneasMeta/Split.lean | 11 ++-- 5 files changed, 59 insertions(+), 58 deletions(-) diff --git a/backends/lean/Aeneas/Data/Tuples.lean b/backends/lean/Aeneas/Data/Tuples.lean index 7ecbd6ee1..336235ce7 100644 --- a/backends/lean/Aeneas/Data/Tuples.lean +++ b/backends/lean/Aeneas/Data/Tuples.lean @@ -1,6 +1,6 @@ module -public import Lean -public import AeneasMeta.Utils +public meta import Lean +public meta import AeneasMeta.Utils public section namespace Aeneas @@ -19,13 +19,13 @@ syntax:max term noWs ".#" noWs num : term open Lean Meta Elab Term -- Auxliary function for computing the number of elements in a tuple (`Prod`) type. -def getArity (type : Expr) : Nat := +meta def getArity (type : Expr) : Nat := match type with | .app (.app (.const ``Prod _) _) as => getArity as + 1 | _ => 1 -- It is not product -- Given a `tuple` of size `n`, construct a term that for accessing the `i`-th element -def mkGetIdx (tuple : Expr) (n : Nat) (i : Nat) : MetaM Expr := do +meta def mkGetIdx (tuple : Expr) (n : Nat) (i : Nat) : MetaM Expr := do match i with | 0 => mkAppM ``Prod.fst #[tuple] | i+1 => diff --git a/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean b/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean index fa0e40f2f..10d3951ec 100644 --- a/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean +++ b/backends/lean/Aeneas/Tactic/Misc/Let/Let.lean @@ -13,7 +13,7 @@ Tactics to introduce let-bindings while refolding/rewriting the context. open Lean Elab Term Meta Tactic -def opaque_refold (h x : Name) (e : Expr) : TacticM Unit := +meta def opaque_refold (h x : Name) (e : Expr) : TacticM Unit := withMainContext do /- Retrieve the list of propositions in the context -/ let ctx ← getLCtx @@ -64,7 +64,7 @@ example (x y z : Nat) (h0 : x + y = z) (h1 : x + y = 3) (_ : z ≤ 4) : x + y + olet hb: (b : Nat) := a + z omega -def transparent_refold (x : Name) (e : Expr) : TacticM Unit := +meta def transparent_refold (x : Name) (e : Expr) : TacticM Unit := withMainContext do withTransparency .reducible do /- Retrieve the list of propositions in the context -/ let ctx ← getLCtx diff --git a/backends/lean/AeneasMeta/Saturate/Attribute.lean b/backends/lean/AeneasMeta/Saturate/Attribute.lean index 4c7f80783..ca78df3fc 100644 --- a/backends/lean/AeneasMeta/Saturate/Attribute.lean +++ b/backends/lean/AeneasMeta/Saturate/Attribute.lean @@ -1,5 +1,5 @@ module -public import Lean +public meta import Lean public meta import AeneasMeta.Utils public import AeneasMeta.Extensions public section @@ -20,7 +20,7 @@ initialize registerTraceClass `Saturate.diagnostics namespace Attribute -structure Key where +meta structure Key where discrTreeKey : DiscrTreeKey deriving Inhabited @@ -30,7 +30,7 @@ instance : ToFormat Key where instance : ToMessageData Key where toMessageData k := m!"({k.discrTreeKey})" -structure Pattern where +meta structure Pattern where pattern : Expr /- The variables bound in the theorem and that are used in the pattern -/ boundVars : Array Nat @@ -40,7 +40,7 @@ structure Pattern where instVar : Option Nat deriving Inhabited, BEq -structure Rule where +meta structure Rule where -- The source info allows to uniquely identify where the rule was introduced src : SourceInfo numBinders : Nat @@ -49,16 +49,16 @@ structure Rule where thName : Name deriving Inhabited, BEq -instance : ToFormat Pattern where +meta instance : ToFormat Pattern where format x := f!"{x.pattern}" -instance : ToMessageData Pattern where +meta instance : ToMessageData Pattern where toMessageData x := m!"{x.pattern}" -instance : ToFormat Rule where +meta instance : ToFormat Rule where format x := f!"({x.numBinders}, {x.patterns}, {x.thName})" -instance : ToMessageData Rule where +meta instance : ToMessageData Rule where toMessageData x := m!"({x.numBinders}, {x.patterns}, {x.thName})" /-- The saturation attribute is a map from rule set name to set of rules. @@ -99,7 +99,7 @@ instance : ToMessageData Rule where TODO: allow using several patterns. -/ -structure Rules where +meta structure Rules where /- The set of rules. We actually save a *map* rather than a set: it is convenient useful @@ -111,7 +111,7 @@ structure Rules where rules : DiscrTree Rule deriving Inhabited -def Rules.empty : Rules := { +meta def Rules.empty : Rules := { nameToRules := Std.HashMap.emptyWithCapacity, deactivatedRules := Std.HashSet.emptyWithCapacity rules := DiscrTree.empty @@ -120,7 +120,7 @@ def Rules.empty : Rules := { abbrev Extension := SimpleScopedEnvExtension (Key × Rule) Rules -private def Rules.insert (s : Rules) (kv : Key × Rule) : Rules := +private meta def Rules.insert (s : Rules) (kv : Key × Rule) : Rules := let { nameToRules, deactivatedRules, rules } := s let ⟨ k, v ⟩ := kv let nameToRules := nameToRules.insert v.thName v @@ -129,7 +129,7 @@ private def Rules.insert (s : Rules) (kv : Key × Rule) : Rules := -- { nameToRules, deactivatedRules, rules } -private def Rules.erase (s : Rules) (thName : Name) : Rules := +private meta def Rules.erase (s : Rules) (thName : Name) : Rules := let { nameToRules, deactivatedRules, rules } := s /- Note that we can't remove a key from a discrimination tree, so we add the theorem name to the `deactivatedRules` set instead: when instantiating rules @@ -138,7 +138,7 @@ private def Rules.erase (s : Rules) (thName : Name) : Rules := let deactivatedRules := deactivatedRules.insert thName { nameToRules, deactivatedRules, rules } -def mkExtension (name : Name := by exact decl_name%) : +meta def mkExtension (name : Name := by exact decl_name%) : IO Extension := registerSimpleScopedEnvExtension { name := name, @@ -147,7 +147,7 @@ def mkExtension (name : Name := by exact decl_name%) : } /-- The saturation attribute. -/ -structure SaturateAttribute where +meta structure SaturateAttribute where -- The attribute attr : AttributeImpl -- The rule sets @@ -305,16 +305,16 @@ meta def makeAttribute (mapName attributeName : Name) (elabAttribute : Syntax -- If `allow_loose` is specified, we allow not instantiating all the variables. syntax (name := aeneas_saturate) "aeneas_saturate" (term)? : attr -def elabSaturateAttribute (stx : Syntax) : MetaM (Option Syntax) := +meta def elabSaturateAttribute (stx : Syntax) : MetaM (Option Syntax) := withRef stx do match stx with | `(attr| aeneas_saturate $[$pat]?) => do pure pat | _ => throwUnsupportedSyntax -initialize saturateAttr : SaturateAttribute ← do +meta initialize saturateAttr : SaturateAttribute ← do makeAttribute `aeneas_saturate_map `aeneas_saturate elabSaturateAttribute -def SaturateAttribute.find? (s : SaturateAttribute) (e : Expr) : +meta def SaturateAttribute.find? (s : SaturateAttribute) (e : Expr) : MetaM (Array Rule) := do let s := s.ext.getState (← getEnv) let rules ← s.rules.getMatch e @@ -322,10 +322,10 @@ def SaturateAttribute.find? (s : SaturateAttribute) (e : Expr) : and filter the rules which have been deactivated -/ pure (rules.filter fun r => ¬ s.deactivatedRules.contains r.thName) -def SaturateAttribute.getState (s : SaturateAttribute) : MetaM Rules := do +meta def SaturateAttribute.getState (s : SaturateAttribute) : MetaM Rules := do pure (s.ext.getState (← getEnv)) -def SaturateAttribute.showStored (s : SaturateAttribute) : MetaM Unit := do +meta def SaturateAttribute.showStored (s : SaturateAttribute) : MetaM Unit := do let st ← s.getState IO.println f!"rules:\n{st.rules}" IO.println f!"deactivated rules:\n{st.deactivatedRules.toArray}" diff --git a/backends/lean/AeneasMeta/Saturate/Tactic.lean b/backends/lean/AeneasMeta/Saturate/Tactic.lean index a45c2bd44..7d2ce70f8 100644 --- a/backends/lean/AeneasMeta/Saturate/Tactic.lean +++ b/backends/lean/AeneasMeta/Saturate/Tactic.lean @@ -32,7 +32,7 @@ structure VisitConfig extends Config where matchWithRules : Bool matchWithPartialMatches : Bool -structure PartialMatch where +meta structure PartialMatch where numBinders : Nat -- The remaining patterns to match, including the current one patterns : List Pattern @@ -41,10 +41,10 @@ structure PartialMatch where thName : Name deriving Inhabited, BEq -instance : ToFormat PartialMatch where +meta instance : ToFormat PartialMatch where format x := f!"({x.numBinders}, {x.patterns}, {x.thName}, {x.subst})" -instance : ToMessageData PartialMatch where +meta instance : ToMessageData PartialMatch where toMessageData x := m!"({x.numBinders}, {x.patterns}, {x.thName}, {x.subst})" structure DiagnosticsInfo where @@ -54,22 +54,22 @@ structure DiagnosticsInfo where structure Diagnostics where hits : Std.HashMap Name DiagnosticsInfo -def Diagnostics.empty : Diagnostics := ⟨ Std.HashMap.emptyWithCapacity ⟩ +meta def Diagnostics.empty : Diagnostics := ⟨ Std.HashMap.emptyWithCapacity ⟩ -def Diagnostics.insertHit (diagnostics : Diagnostics) (name : Name) : Diagnostics := +meta def Diagnostics.insertHit (diagnostics : Diagnostics) (name : Name) : Diagnostics := match diagnostics.hits[name]? with | none => ⟨ diagnostics.hits.insert name { hits:= 1, used := 0 } ⟩ | some info => ⟨ diagnostics.hits.insert name { info with hits := info.hits + 1 } ⟩ -def Diagnostics.insertUsed (diagnostics : Diagnostics) (name : Name) : Diagnostics := +meta def Diagnostics.insertUsed (diagnostics : Diagnostics) (name : Name) : Diagnostics := match diagnostics.hits[name]? with | none => ⟨ diagnostics.hits.insert name { hits:= 1, used := 0 } ⟩ -- This shouldn't happen | some info => ⟨ diagnostics.hits.insert name { info with used := info.used + 1} ⟩ -def Diagnostics.insertHitRules (info : Diagnostics) (rules : Array Rule) : Diagnostics := +meta def Diagnostics.insertHitRules (info : Diagnostics) (rules : Array Rule) : Diagnostics := rules.foldl (fun info rule => info.insertHit rule.thName) info -def Diagnostics.toArray (info : Diagnostics) : Array String := +meta def Diagnostics.toArray (info : Diagnostics) : Array String := let hits := info.hits.toList let hits := (hits.mergeSort (fun (_, info0) (_, info1) => info0.hits + info0.used ≤ info1.hits + info1.used)).reverse let hits := hits.toArray @@ -82,16 +82,16 @@ inductive AsmPath where | asm (asm : FVarId) | conj (dir : LeftOrRight) (p : AsmPath) -def AsmPath.format (p : AsmPath) : Format := +meta def AsmPath.format (p : AsmPath) : Format := match p with | .asm fvarId => f!"{Expr.fvar fvarId}" | .conj .left p => f!"{p.format}.left" | .conj .right p => f!"{p.format}.right" -instance : ToFormat AsmPath where +meta instance : ToFormat AsmPath where format x := AsmPath.format x -instance : ToMessageData AsmPath where +meta instance : ToMessageData AsmPath where toMessageData x := m!"({AsmPath.format x})" structure State where @@ -111,26 +111,26 @@ structure State where /- Do not introduce a theorem if its conclusion is already in the set -/ ignore : Std.HashSet Expr -def State.insertHitRules (s : State) (rules : Array Rule) : State := +meta def State.insertHitRules (s : State) (rules : Array Rule) : State := { s with diagnostics := s.diagnostics.insertHitRules rules } -def State.insertUsed (s : State) (name : Name) : State := +meta def State.insertUsed (s : State) (name : Name) : State := { s with diagnostics := s.diagnostics.insertUsed name } -def State.insertMatch (s : State) (e : Expr) : State := +meta def State.insertMatch (s : State) (e : Expr) : State := { s with matched := s.matched.insert e } /- Note that we shouldn't insert assumptions which contain bound variables. This should be prevented by the fact that when diving into expressions containing binders, we set the path to `none`. -/ -def State.insertAssumption (s : State) (path : Option AsmPath) (e : Expr) : State := +meta def State.insertAssumption (s : State) (path : Option AsmPath) (e : Expr) : State := match path with | some path => -- We insert assumptions only if they do not contain bound vars { s with assumptions := s.assumptions.insert e path } | none => s -def State.new +meta def State.new (rules : Array Rules) (pmatches : DiscrTree PartialMatch := DiscrTree.empty) (diagnostics : Diagnostics := Diagnostics.empty) @@ -139,7 +139,7 @@ def State.new (ignore : Std.HashSet Expr := Std.HashSet.emptyWithCapacity) : State := { rules, pmatches, diagnostics, matched, assumptions, ignore } -def mkExprFromPath (path : AsmPath) : MetaM Expr := do +meta def mkExprFromPath (path : AsmPath) : MetaM Expr := do match path with | .asm asm => pure (Expr.fvar asm) | .conj dir p => @@ -150,7 +150,7 @@ def mkExprFromPath (path : AsmPath) : MetaM Expr := do | .right => ``And.right mkAppOptM dir #[none, none, some p] -def State.insertPartialMatch (state : State) +meta def State.insertPartialMatch (state : State) (boundVars : Std.HashSet FVarId) (pmatch : PartialMatch) : MetaM State := do withTraceNode `Saturate (fun _ => pure m!"insertPartialMatch") do @@ -205,7 +205,7 @@ def State.insertPartialMatch (state : State) -- Store the partial match pure { state with pmatches := ← state.pmatches.insert key pmatch } -def checkIfPatDefEq (preprocessThm : Option (Array Expr → Expr → MetaM Unit)) +meta def checkIfPatDefEq (preprocessThm : Option (Array Expr → Expr → MetaM Unit)) (pat : Expr) (numBinders : Nat) (e : Expr) : MetaM (Option (Array Expr)) := do withTraceNode `Saturate (fun _ => pure m!"checkIfPatDefEq") do -- Strip the binders, introduce meta-variables at the same time, and match @@ -235,7 +235,7 @@ def checkIfPatDefEq (preprocessThm : Option (Array Expr → Expr → MetaM Unit) return none return (some mvars) -def matchExprWithRules +meta def matchExprWithRules (preprocessThm : Option (Array Expr → Expr → MetaM Unit)) (path : Option AsmPath) (boundVars : Std.HashSet FVarId) @@ -297,7 +297,7 @@ def matchExprWithRules state ← state.insertPartialMatch boundVars pmatch pure state -def matchExprWithPartialMatches +meta def matchExprWithPartialMatches (preprocessThm : Option (Array Expr → Expr → MetaM Unit)) (path : Option AsmPath) (boundVars : Std.HashSet FVarId) @@ -351,7 +351,7 @@ def matchExprWithPartialMatches - `boundVars`: if an instantiation of a theorem contains a bound variable, we ignore it (because we couldn't introduce the instantiated theorem it in the environment) -/ -def matchExpr +meta def matchExpr (preprocessThm : Option (Array Expr → Expr → MetaM Unit)) (path : Option AsmPath) (boundVars : Std.HashSet FVarId) @@ -371,7 +371,7 @@ def matchExpr let state ← matchExprWithPartialMatches preprocessThm path boundVars state e pure state -def filterProofTerms (config : Config) (exprs : Array Expr) : MetaM (Array Expr) := +meta def filterProofTerms (config : Config) (exprs : Array Expr) : MetaM (Array Expr) := if ¬ config.visitProofTerms then exprs.filterM fun arg => do let ty ← inferType arg @@ -380,7 +380,7 @@ def filterProofTerms (config : Config) (exprs : Array Expr) : MetaM (Array Expr) else pure exprs /- Recursively explore a term -/ -private partial def visit +private meta partial def visit (config : VisitConfig) (path : Option AsmPath) (depth : Nat) @@ -472,7 +472,7 @@ private partial def visit This is necessary if we want to saturate the goal in several steps and modify the assumptions in between (with a call to simp for example). -/ -private partial def visitRecomputeAssumptions +private meta partial def visitRecomputeAssumptions (path : Option AsmPath) (depth : Nat) (exploreSubterms : Expr → Array Expr → MetaM (Array Expr)) @@ -551,7 +551,7 @@ def exploreArithSubterms (f : Expr) (args : Array Expr) : MetaM (Array Expr) := pure #[] /- The saturation tactic itself -/ -partial def evalSaturateCore +meta partial def evalSaturateCore (config : Config) (state : State) (exploreSubterms : Option (Expr → Array Expr → MetaM (Array Expr)) := none) @@ -691,7 +691,7 @@ partial def evalSaturateCore pure (state, allFVars) /- Reexplore the context to recompute the set of assumptions -/ -def recomputeAssumptions +meta def recomputeAssumptions (state : State) (exploreSubterms : Option (Expr → Array Expr → MetaM (Array Expr)) := none) (declsToExplore : Array FVarId) @@ -721,7 +721,7 @@ def recomputeAssumptions visit path state decl.type else pure state) state -partial def evalSaturate {α} +meta partial def evalSaturate {α} (config : Config) (satAttr : Array SaturateAttribute) (exploreSubterms : Option (Expr → Array Expr → MetaM (Array Expr)) := none) diff --git a/backends/lean/AeneasMeta/Split.lean b/backends/lean/AeneasMeta/Split.lean index c6969cd23..3b4cd0ac9 100644 --- a/backends/lean/AeneasMeta/Split.lean +++ b/backends/lean/AeneasMeta/Split.lean @@ -1,23 +1,24 @@ module public import AeneasMeta.Utils public import AeneasMeta.Simp +public meta import AeneasMeta.Simp.Simp public section namespace Aeneas.Split open Lean Meta Elab Tactic -def mkExists (var body : Expr) : MetaM Expr := do +meta def mkExists (var body : Expr) : MetaM Expr := do mkAppM ``Exists #[← mkLambdaFVars #[var] body] -def mkExistsSeq (vars : List Expr) (body : Expr) : MetaM Expr := do +meta def mkExistsSeq (vars : List Expr) (body : Expr) : MetaM Expr := do match vars with | [] => pure body | v :: vars => let body ← mkExistsSeq vars body mkExists v body -def mkOrSeq (disjs : List Expr) : MetaM Expr := do +meta def mkOrSeq (disjs : List Expr) : MetaM Expr := do match disjs with | [] => pure (mkConst ``False) | [x] => pure x @@ -53,7 +54,7 @@ List.casesOn : {α : Type u} → We return the fvars introduced for the variables appearing af -/ -def esplitCasesOn (isMatcher : Bool) (e : Expr) (casesOnName : Name) (h : Name) (vars : List (List (Option Name))) : +meta def esplitCasesOn (isMatcher : Bool) (e : Expr) (casesOnName : Name) (h : Name) (vars : List (List (Option Name))) : TacticM (List (Array FVarId × FVarId × MVarId)) := withTraceNode `Utils (fun _ => do pure m!"esplitCasesOn") do Tactic.focus do @@ -236,7 +237,7 @@ We return the fvars introduced for: - the variables introduced when decomposing the inductive - the equality introduced in the context -/ -def esplit (e : Expr) (h : Name) (vars : List (List (Option Name))) : +meta def esplit (e : Expr) (h : Name) (vars : List (List (Option Name))) : TacticM (List (Array FVarId × FVarId × MVarId)) := Tactic.focus do withTraceNode `Utils (fun _ => do pure m!"esplit") do From 95eaea87d65de8b52d185ddb9d4361e1367eb4bf Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 00:26:28 +0200 Subject: [PATCH 04/40] and more... --- backends/lean/Aeneas/Data/Byte.lean | 4 +- .../Aeneas/Data/Range/DivRange/Basic.lean | 8 +-- .../Aeneas/Data/Range/DivRange/Lemmas.lean | 2 +- backends/lean/Aeneas/Data/Range/Lemmas.lean | 2 +- .../Aeneas/Data/Range/MulRange/Basic.lean | 8 +-- .../Aeneas/Data/Range/MulRange/Lemmas.lean | 2 +- backends/lean/Aeneas/Std/Alloc.lean | 2 +- backends/lean/Aeneas/Std/Core/Atomic.lean | 2 +- backends/lean/Aeneas/Std/Core/Default.lean | 1 + backends/lean/Aeneas/Std/Core/Panic.lean | 2 +- backends/lean/Aeneas/Std/Core/Pin.lean | 2 +- backends/lean/Aeneas/Std/Core/Result.lean | 2 +- backends/lean/Aeneas/Std/Primitives.lean | 6 +- backends/lean/Aeneas/Std/Spec.lean | 8 +-- backends/lean/Aeneas/Std/WP.lean | 4 +- .../Simp/SimpBoolProp/SimpBoolProp.lean | 11 +++- .../Tactic/Simproc/ReduceFin/ReduceFin.lean | 1 + .../lean/Aeneas/Tactic/Simproc/ReduceNat.lean | 2 +- .../Tactic/Simproc/ReduceZMod/ReduceZMod.lean | 3 +- .../Tactic/Solver/ScalarTac/CondSimpTac.lean | 22 ++++--- .../Aeneas/Tactic/Solver/ScalarTac/Init.lean | 6 +- .../Tactic/Solver/ScalarTac/ScalarTac.lean | 62 ++++++++++++------- 22 files changed, 95 insertions(+), 67 deletions(-) diff --git a/backends/lean/Aeneas/Data/Byte.lean b/backends/lean/Aeneas/Data/Byte.lean index f151db3e4..2e2c15be2 100644 --- a/backends/lean/Aeneas/Data/Byte.lean +++ b/backends/lean/Aeneas/Data/Byte.lean @@ -1,7 +1,7 @@ module public import Lean -public import Aeneas.Tactic.Simp.SimpLists.Init -public import Aeneas.Tactic.Simp.SimpScalar.Init +public meta import Aeneas.Tactic.Simp.SimpLists.Init +public meta import Aeneas.Tactic.Simp.SimpScalar.Init public section abbrev Byte := BitVec 8 diff --git a/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean b/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean index 8fcc16569..03897bdfa 100644 --- a/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean +++ b/backends/lean/Aeneas/Data/Range/DivRange/Basic.lean @@ -29,7 +29,7 @@ instance : Membership Nat DivRange where namespace DivRange universe u v -@[inline] protected def forIn' [Monad m] (range : DivRange) (init : β) +@[inline, expose] protected def forIn' [Monad m] (range : DivRange) (init : β) (f : (i : Nat) → i ∈ range → β → m (ForInStep β)) : m β := let rec @[specialize] loop (maxSteps : Nat) (b : β) (i : Nat) (hs : ∃ k, i = range.start / range.divisor ^ k) @@ -68,7 +68,7 @@ We now introduce a convenient `DivRange` definition -/ -- TODO: don't use a fuel -def divRange (start stop div : Nat) : List Nat := +@[expose] def divRange (start stop div : Nat) : List Nat := let rec loop (fuel i : Nat) := match fuel with | 0 => [] @@ -81,7 +81,7 @@ def divRange (start stop div : Nat) : List Nat := namespace DivRange /-- A convenient utility for the proofs -/ -def foldWhile' {α : Type u} (r : DivRange) (f : α → (a : Nat) → (a ∈ r) → α) (i : Nat) (init : α) +@[expose] def foldWhile' {α : Type u} (r : DivRange) (f : α → (a : Nat) → (a ∈ r) → α) (i : Nat) (init : α) (hi : i ≤ r.start ∧ ∃ k, i = r.start / r.divisor ^ k) : α := if h: r.stop < i then foldWhile' r f (i / r.divisor) @@ -96,7 +96,7 @@ termination_by i decreasing_by apply Nat.div_lt_self; omega; apply r.divisor_pos /-- A convenient utility for the proofs -/ -def foldWhile {α : Type u} (stop divisor : Nat) (hDiv : 1 < divisor) +@[expose] def foldWhile {α : Type u} (stop divisor : Nat) (hDiv : 1 < divisor) (f : α → (a : Nat) → α) (i : Nat) (init : α) : α := if stop < i then foldWhile stop divisor hDiv f (i / divisor) (f init i) diff --git a/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean b/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean index fa49616ab..fb0f56efc 100644 --- a/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean +++ b/backends/lean/Aeneas/Data/Range/DivRange/Lemmas.lean @@ -63,7 +63,7 @@ private theorem mem_of_mem_divRange_loop_aux exists (k + 1) simp [hkEq, Nat.div_div_eq_div_mul, Nat.pow_add_one'] -private theorem mem_of_mem_divRange (r : DivRange) (a : Nat) +theorem mem_of_mem_divRange (r : DivRange) (a : Nat) (h : a ∈ divRange r.start r.stop r.divisor) : a ∈ r := by have hDiv := r.divisor_pos have h0 := Nat.log_le_self r.divisor r.start diff --git a/backends/lean/Aeneas/Data/Range/Lemmas.lean b/backends/lean/Aeneas/Data/Range/Lemmas.lean index 07b64576e..e0072288d 100644 --- a/backends/lean/Aeneas/Data/Range/Lemmas.lean +++ b/backends/lean/Aeneas/Data/Range/Lemmas.lean @@ -1,6 +1,6 @@ module public import Aeneas.Tactic.Solver.Grind.Init -public import Aeneas.Tactic.Solver.ScalarTac.Init +public meta import Aeneas.Tactic.Solver.ScalarTac.Init public section -- TODO: add a namepsace diff --git a/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean b/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean index d2b7d22b2..2b8f3b0cd 100644 --- a/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean +++ b/backends/lean/Aeneas/Data/Range/MulRange/Basic.lean @@ -30,7 +30,7 @@ instance : Membership Nat MulRange where namespace MulRange universe u v -@[inline] protected def forIn' [Monad m] (range : MulRange) (init : β) +@[inline, expose] protected def forIn' [Monad m] (range : MulRange) (init : β) (f : (i : Nat) → i ∈ range → β → m (ForInStep β)) : m β := let rec @[specialize] loop (maxSteps : Nat) (b : β) (i : Nat) (hs : ∃ k, i = range.start * range.mul ^ k) @@ -68,7 +68,7 @@ end MulRange We now introduce a convenient `mulRange` definition -/ -def mulRange (stop mul : Nat) (hMul : 1 < mul) (i : Nat) (hi : 0 < i) : List Nat := +@[expose] def mulRange (stop mul : Nat) (hMul : 1 < mul) (i : Nat) (hi : 0 < i) : List Nat := if i < stop then i :: mulRange stop mul hMul (i * mul) (by rw [Nat.mul_pos_iff_of_pos_left] <;> omega) else [] @@ -80,7 +80,7 @@ decreasing_by namespace MulRange /-- A convenient utility for the proofs -/ -def foldWhile' {α : Type u} (r : MulRange) (f : α → (a : Nat) → (a ∈ r) → α) (i : Nat) (init : α) +@[expose] def foldWhile' {α : Type u} (r : MulRange) (f : α → (a : Nat) → (a ∈ r) → α) (i : Nat) (init : α) (hi : r.start ≤ i ∧ ∃ k, i = r.start * r.mul ^ k) : α := if h: i < r.stop then foldWhile' r f (i * r.mul) @@ -102,7 +102,7 @@ decreasing_by omega /-- A convenient utility for the proofs -/ -def foldWhile {α : Type u} (stop mul : Nat) (hMul : 1 < mul) +@[expose] def foldWhile {α : Type u} (stop mul : Nat) (hMul : 1 < mul) (f : α → (a : Nat) → α) (i : Nat) (hi : 0 < i) (init : α) : α := if i < stop then foldWhile stop mul hMul f (i * mul) (by simp only [hi, Nat.mul_pos_iff_of_pos_left]; omega) (f init i) diff --git a/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean b/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean index fbce447de..54ea86a18 100644 --- a/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean +++ b/backends/lean/Aeneas/Data/Range/MulRange/Lemmas.lean @@ -65,7 +65,7 @@ decreasing_by have : i < i * mul := by rw [Nat.lt_mul_iff_one_lt_right] <;> omega omega -private theorem mem_of_mem_MulRange (r : MulRange) (a : Nat) +theorem mem_of_mem_MulRange (r : MulRange) (a : Nat) (h : a ∈ mulRange r.stop r.mul r.mul_pos r.start r.start_pos) : a ∈ r := by apply mem_of_mem_MulRange_aux r.stop r.mul r.start r.mul_pos r.start (by diff --git a/backends/lean/Aeneas/Std/Alloc.lean b/backends/lean/Aeneas/Std/Alloc.lean index 956ad4f1f..10b96e8ff 100644 --- a/backends/lean/Aeneas/Std/Alloc.lean +++ b/backends/lean/Aeneas/Std/Alloc.lean @@ -1,6 +1,6 @@ module public import Lean -public import Aeneas.Extract +public meta import Aeneas.Extract.Extract public import Aeneas.Std.Primitives public section diff --git a/backends/lean/Aeneas/Std/Core/Atomic.lean b/backends/lean/Aeneas/Std/Core/Atomic.lean index aa1b3c60f..e2f874341 100644 --- a/backends/lean/Aeneas/Std/Core/Atomic.lean +++ b/backends/lean/Aeneas/Std/Core/Atomic.lean @@ -1,5 +1,5 @@ module -public import Aeneas.Extract +public meta import Aeneas.Extract.Extract public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Default.lean b/backends/lean/Aeneas/Std/Core/Default.lean index d6fcda33b..192a0e934 100644 --- a/backends/lean/Aeneas/Std/Core/Default.lean +++ b/backends/lean/Aeneas/Std/Core/Default.lean @@ -1,5 +1,6 @@ module public import Aeneas.Std.Primitives +public meta import Aeneas.Extract.Extract public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Panic.lean b/backends/lean/Aeneas/Std/Core/Panic.lean index 41dbae43e..5291e23ba 100644 --- a/backends/lean/Aeneas/Std/Core/Panic.lean +++ b/backends/lean/Aeneas/Std/Core/Panic.lean @@ -1,5 +1,5 @@ module -public import Aeneas.Extract +public meta import Aeneas.Extract.Extract public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Pin.lean b/backends/lean/Aeneas/Std/Core/Pin.lean index 0df488ae2..3fcc53330 100644 --- a/backends/lean/Aeneas/Std/Core/Pin.lean +++ b/backends/lean/Aeneas/Std/Core/Pin.lean @@ -1,5 +1,5 @@ module -public import Aeneas.Extract +public meta import Aeneas.Extract.Extract public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Core/Result.lean b/backends/lean/Aeneas/Std/Core/Result.lean index 9ff7e2c16..26eaa357c 100644 --- a/backends/lean/Aeneas/Std/Core/Result.lean +++ b/backends/lean/Aeneas/Std/Core/Result.lean @@ -1,5 +1,5 @@ module -public import Aeneas.Extract +public meta import Aeneas.Extract.Extract public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index dd7ba373d..c91dd888c 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -1,6 +1,6 @@ module public import Lean -public import Aeneas.Std.Global +public meta import Aeneas.Std.Global public import Aeneas.Extract public import AeneasMeta.BvEnumToBitVec public section @@ -18,7 +18,7 @@ open Lean Elab Command Term Meta syntax (name := assert) "#assert" term: command @[command_elab assert] -unsafe +meta unsafe def assertImpl : CommandElab := fun (stx: Syntax) => do runTermElabM (fun _ => do let r ← evalTerm Bool (mkConst ``Bool) stx[1] @@ -37,7 +37,7 @@ info: true syntax (name := elabSyntax) "#elab" term: command @[command_elab elabSyntax] -unsafe +meta unsafe def elabImpl : CommandElab := fun (stx: Syntax) => do runTermElabM (fun _ => do /- Simply elaborate the syntax to check that it is correct -/ diff --git a/backends/lean/Aeneas/Std/Spec.lean b/backends/lean/Aeneas/Std/Spec.lean index 05420f359..84f7f99e3 100644 --- a/backends/lean/Aeneas/Std/Spec.lean +++ b/backends/lean/Aeneas/Std/Spec.lean @@ -35,12 +35,12 @@ structure SpecInfo where liftings : Array LiftingInfo deriving Inhabited -structure SpecInfoExtensionState where +meta structure SpecInfoExtensionState where specInfos : Std.HashMap Name SpecInfo deriving Inhabited /- Initialize the state extension for adding spec theorems -/ -initialize specAttr : SimpleScopedEnvExtension SpecInfo SpecInfoExtensionState ← do +meta initialize specAttr : SimpleScopedEnvExtension SpecInfo SpecInfoExtensionState ← do let ext ← registerSimpleScopedEnvExtension { name := `specStatementRegistrationExtension, initial := { @@ -55,7 +55,7 @@ syntax (name := register_spec_info_cmd) "#register_spec_info " term : command @[command_elab register_spec_info_cmd] -unsafe def register_spec_info : Lean.Elab.Command.CommandElab := fun stx => do +meta unsafe def register_spec_info : Lean.Elab.Command.CommandElab := fun stx => do let info := stx[1] let expr ← Command.liftTermElabM do elabTerm info (some (mkConst ``SpecInfo)) @@ -63,7 +63,7 @@ unsafe def register_spec_info : Lean.Elab.Command.CommandElab := fun stx => do Lean.Meta.evalExpr SpecInfo (mkConst ``SpecInfo) expr specAttr.add value -def specInfoLookup (n : Name) : MetaM (Option SpecInfo) := do +meta def specInfoLookup (n : Name) : MetaM (Option SpecInfo) := do let env ← getEnv let state := specAttr.getState env return state.specInfos.get? n diff --git a/backends/lean/Aeneas/Std/WP.lean b/backends/lean/Aeneas/Std/WP.lean index 5c5d0ea35..a679a47e0 100644 --- a/backends/lean/Aeneas/Std/WP.lean +++ b/backends/lean/Aeneas/Std/WP.lean @@ -11,7 +11,7 @@ namespace Aeneas.Std.WP open Std Result def Post α := (α -> Prop) -def Pre := Prop +abbrev Pre := Prop def Wp α := Post α → Pre @@ -51,7 +51,7 @@ We use this in the Hoare triple notation `⦃ ⦄`. Example: `f 0 ⦃ x y z => ... ⦄` desugars to `spec (f 0) (uncurry' fun x => uncurry' fun y z => ...)`. -/ -def uncurry' {α β} (p : α → β → Prop) : α × β → Prop := +@[expose] def uncurry' {α β} (p : α → β → Prop) : α × β → Prop := fun (x, y) => p x y @[simp] theorem uncurry'_pair x y (p : α → β → Prop) : uncurry' p (x, y) = p x y := by simp [uncurry'] diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean index d344eb154..6aeb49df8 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean @@ -1,6 +1,7 @@ module -public import Mathlib.Tactic.Tauto -public import Aeneas.Tactic.Simp.SimpBoolProp.Init +import Mathlib.Tactic.Tauto +public meta import Lean.Meta.Tactic.Simp.BuiltinSimprocs.Core +public meta import Aeneas.Tactic.Simp.SimpBoolProp.Init public section /-! @@ -11,8 +12,12 @@ namespace Aeneas.SimpBoolProp open Lean Lean.Meta Lean.Parser.Tactic Lean.Elab.Tactic +/-- TODO: `reduceIte` can't be added to a custom simp set via `attribute` under the module system +since builtin simprocs are not `meta`-marked, so `ensureAttrDeclIsMeta` rejects them. So here we +register a local `meta` version of `reduceIte`. Perhaps there is a better way to do this. -/ +simproc ↓ [simp_bool_prop] reduceIte' (ite _ _ _) := reduceIte + attribute [simp_bool_prop] - reduceIte true_implies false_implies implies_true imp_false Bool.true_and Bool.and_true Bool.false_and Bool.and_false diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean index f0aa48f55..a758d8b89 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceFin/ReduceFin.lean @@ -1,5 +1,6 @@ module public import Aeneas.Tactic.Simproc.ReduceFin.Init +public meta import AeneasMeta.Utils public import AeneasMeta.Utils public section diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean index 615fc7ecf..d64cb30a4 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceNat.lean @@ -1,6 +1,6 @@ module public import AeneasMeta.Utils -public import Aeneas.Tactic.Solver.ScalarTac.Init +public meta import Aeneas.Tactic.Solver.ScalarTac.Init public section namespace Aeneas.ReduceNat diff --git a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean index 242d172a9..c8ec82cf8 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/ReduceZMod/ReduceZMod.lean @@ -1,5 +1,6 @@ module -public import Aeneas.Tactic.Simproc.ReduceZMod.Init +public meta import Aeneas.Tactic.Simproc.ReduceZMod.Init +public meta import Mathlib.Data.Int.GCD public import Mathlib.Algebra.Algebra.ZMod public import AeneasMeta.Utils public section diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean index 0ade41c1f..b496f387b 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/CondSimpTac.lean @@ -1,5 +1,9 @@ module -public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +public meta import Aeneas.Tactic.Solver.ScalarTac.ScalarTac +import Lean.Elab.ConfigEval.Instances +import Lean.Elab.ConfigEval.DeriveEvalExpr +import Lean.Elab.ConfigEval.DeriveEvalConfigItem +meta import AeneasMeta.Simp.Simp public section namespace Aeneas.ScalarTac @@ -24,7 +28,7 @@ structure CondSimpPartialArgs where addSimpThms : Array Name := #[] hypsToUse : Array FVarId := #[] -def condSimpParseArgs (tacName : String) (args : TSyntaxArray [`term, `token.«*»]) : +meta def condSimpParseArgs (tacName : String) (args : TSyntaxArray [`term, `token.«*»]) : TacticM CondSimpPartialArgs := do withTraceNode `ScalarTac (fun _ => pure m!"condSimpParseArgs") do withMainContext do @@ -84,13 +88,13 @@ structure CondSimpArgs where addSimpThms : Array Name := #[] hypsToUse : Array FVarId := #[] -instance : HAppend CondSimpArgs CondSimpArgs CondSimpArgs where +meta instance : HAppend CondSimpArgs CondSimpArgs CondSimpArgs where hAppend c0 c1 := let ⟨ a0, b0, c0, d0, e0, f0 ⟩ := c0 let ⟨ a1, b1, c1, d1, e1, f1 ⟩ := c1 ⟨ a0 ++ a1, b0 ++ b1, c0 ++ c1, d0 ++ d1, e0 ++ e1, f0 ++ f1 ⟩ -def CondSimpArgs.toSimpArgs (args : CondSimpArgs) : Simp.SimpArgs := { +meta def CondSimpArgs.toSimpArgs (args : CondSimpArgs) : Simp.SimpArgs := { simpThms := args.simpThms, simprocs := args.simprocs, declsToUnfold := args.declsToUnfold, @@ -98,7 +102,7 @@ def CondSimpArgs.toSimpArgs (args : CondSimpArgs) : Simp.SimpArgs := { addSimpThms := args.addSimpThms, hypsToUse := args.hypsToUse } -def condSimpTacSimp (config : Simp.Config) (args : CondSimpArgs) (loc : Utils.Location) +meta def condSimpTacSimp (config : Simp.Config) (args : CondSimpArgs) (loc : Utils.Location) (toClear : Array FVarId := #[]) (additionalHypsToUse : Array FVarId := #[]) (state : Option (ScalarTac.State × Array FVarId)) : TacticM (Option (Array FVarId)) := do @@ -134,7 +138,7 @@ structure PreprocessResult where /-- Preprocess the goal. Return `none` if the preprocessing actually solves the goal. -/ -def condSimpTacPreprocess (config : CondSimpTacConfig) (hypsArgs args : CondSimpArgs) +meta def condSimpTacPreprocess (config : CondSimpTacConfig) (hypsArgs args : CondSimpArgs) (addSimpThms : TacticM (Array FVarId)) : TacticM (Option PreprocessResult) := do withTraceNode `ScalarTac (fun _ => pure m!"condSimpTacPreprocess") do withMainContext do @@ -190,7 +194,7 @@ def condSimpTacPreprocess (config : CondSimpTacConfig) (hypsArgs args : CondSimp traceGoalWithNode `ScalarTac "Goal after adding the additional simp assumptions" pure (some { args, toClear, hypsToUse, state, oldAsms, newAsms, additionalSimpThms }) -def condSimpTacCore +meta def condSimpTacCore (simpConfig : Simp.Config) (doFirstSimp : Bool) (loc : Utils.Location) @@ -218,7 +222,7 @@ def condSimpTacCore if (← getUnsolvedGoals) == [] then pure none else pure (some (← getMainGoal)) -def condSimpTacClear (res : PreprocessResult) : TacticM Unit := do +meta def condSimpTacClear (res : PreprocessResult) : TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure m!"CondSimpTacClear") do setGoals [← (← getMainGoal).tryClearMany res.hypsToUse] traceGoalWithNode `ScalarTac "Goal after clearing the duplicated hypotheses to use" @@ -228,7 +232,7 @@ def condSimpTacClear (res : PreprocessResult) : TacticM Unit := do traceGoalWithNode `ScalarTac "Goal after clearing the additional theorems" /-- A helper to define tactics which perform conditional simplifications with `scalar_tac` as a discharger. -/ -def condSimpTac +meta def condSimpTac (config : CondSimpTacConfig) (simpConfig : Simp.Config) (hypsArgs args : CondSimpArgs) (addSimpThms : TacticM (Array FVarId)) (doFirstSimp : Bool) diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean index e26d2e484..608a9d732 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/Init.lean @@ -28,17 +28,17 @@ register_simp_attr' scalarTacSimpExt scalarTacSimprocExt scalar_tac_simps syntax (name := scalar_tac) "scalar_tac" (term)? : attr syntax (name := scalar_tac_nonlin) "scalar_tac_nonlin" (term)? : attr -def elabAttribute (stx : Syntax) : MetaM (Option Syntax) := +meta def elabAttribute (stx : Syntax) : MetaM (Option Syntax) := withRef stx do match stx with | `(attr| scalar_tac $[$pat]?) | `(attr| scalar_tac_nonlin $[$pat]?) => pure pat | _ => Lean.Elab.throwUnsupportedSyntax -initialize scalarTacAttribute : Saturate.Attribute.SaturateAttribute ← +meta initialize scalarTacAttribute : Saturate.Attribute.SaturateAttribute ← Saturate.Attribute.makeAttribute `scalar_tac_map `scalar_tac elabAttribute -initialize scalarTacNonLinAttribute : Saturate.Attribute.SaturateAttribute ← +meta initialize scalarTacNonLinAttribute : Saturate.Attribute.SaturateAttribute ← Saturate.Attribute.makeAttribute `scalar_tac_nonlin_map `scalar_tac_nonlin elabAttribute end Aeneas.ScalarTac diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean index e5749892a..d5a3e21d5 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean @@ -5,9 +5,10 @@ public import Init.Data.List.Basic public import Mathlib.Tactic.Ring.RingNF public import AeneasMeta.Utils public import Aeneas.Tactic.Solver.ScalarTac.Core -public import Aeneas.Tactic.Solver.ScalarTac.Init +public meta import Aeneas.Tactic.Solver.ScalarTac.Init public import AeneasMeta.Saturate -public import Aeneas.Tactic.Simp.SimpScalar.Init +public meta import AeneasMeta.Saturate.Tactic +public meta import Aeneas.Tactic.Simp.SimpScalar.Init public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp public import AeneasMeta.Simp public section @@ -96,13 +97,11 @@ def goalIsLinearInt : Tactic.TacticM Bool := do example (x y : Int) (h0 : x ≤ y) (h1 : x ≠ y) : x < y := by omega +-- NOTE: the core *builtin* simprocs (`reduceIte`, `Nat.reduce*`, `Int.reduce*`) that used to be +-- listed here cannot be added to a custom simp set via `attribute` under the module system +-- (builtin simprocs are not `meta`-marked, so `ensureAttrDeclIsMeta` rejects them). They are now +-- injected by name into the `scalar_tac_simps` simproc set in `getSimpArgs` below. attribute [scalar_tac_simps] - reduceIte - Nat.reduceLeDiff Nat.reduceLT Nat.reduceGT Nat.reduceBEq Nat.reduceBNe - Nat.reducePow Nat.reduceAdd Nat.reduceSub Nat.reduceMul Nat.reduceDiv Nat.reduceMod - Int.reduceLT Int.reduceLE Int.reduceGT Int.reduceGE Int.reduceEq Int.reduceNe Int.reduceBEq Int.reduceBNe - Int.reducePow Int.reduceAdd Int.reduceSub Int.reduceMul Int.reduceDiv Int.reduceMod - Int.reduceNegSucc Int.reduceNeg Int.reduceToNat not_lt not_le lt_inf_iff le_inf_iff Fin.is_le' @@ -116,7 +115,7 @@ theorem forall_eq_forall' {α : Type u} (p : α → Prop) : (∀ (x: α), p x) = simp [forall'] @[app_unexpander forall'] -def unexpForall' : Lean.PrettyPrinter.Unexpander | `($_ $_) => `(∀ _, __) | _ => throw () +meta def unexpForall' : Lean.PrettyPrinter.Unexpander | `($_ $_) => `(∀ _, __) | _ => throw () structure SaturateConfig where /- Should we use non-linear arithmetic reasoning? -/ @@ -144,10 +143,12 @@ structure Config extends SaturateConfig where /- Introduce an auxiliary theorem for the proof generated by `scalar_tac` -/ auxTheorem : Bool := true +public meta section declare_config_elab elabConfig Config +end /-- Helper: a version of `omega` which doesn't introduce an auxiliary theorem -/ -def omegaTacticNoAuxThm (cfg : Meta.Omega.OmegaConfig) : TacticM Unit := do +meta def omegaTacticNoAuxThm (cfg : Meta.Omega.OmegaConfig) : TacticM Unit := do liftMetaFinishingTactic fun g => do let some g ← g.falseOrByContra | return () g.withContext do @@ -159,7 +160,7 @@ def omegaTacticNoAuxThm (cfg : Meta.Omega.OmegaConfig) : TacticM Unit := do g.assign (← instantiateMVarsProfiling g') /-- Apply the scalar_tac forward rules -/ -def scalarTacSaturateForward {α} +meta def scalarTacSaturateForward {α} (config : SaturateConfig) (satState : Option Saturate.State) (declsToExplore : Option (Array FVarId)) @@ -202,18 +203,33 @@ elab "scalar_tac_saturate" config:Parser.Tactic.optConfig : tactic => do let config ← elabConfig config let _ ← scalarTacSaturateForward config.toSaturateConfig none none (postprocessThm := none) (fun _ _ => pure ()) -def getSimpArgs : CoreM Simp.SimpArgs := do +/-- Core builtin simprocs we want active in `scalar_tac`'s preprocessing. They can't be added to + the `C` set via `attribute` under the module system (builtin simprocs aren't + `meta`-marked), so we inject them by name here. Pairs are `(name, post)`: `reduceIte` is a pre + (`↓`) simproc, the numeric reducers are post. -/ +private meta def scalarTacBuiltinSimprocs : List (Name × Bool) := + [(``reduceIte, false), + (``Nat.reduceLeDiff, true), (``Nat.reduceLT, true), (``Nat.reduceGT, true), (``Nat.reduceBEq, true), (``Nat.reduceBNe, true), + (``Nat.reducePow, true), (``Nat.reduceAdd, true), (``Nat.reduceSub, true), (``Nat.reduceMul, true), (``Nat.reduceDiv, true), (``Nat.reduceMod, true), + (``Int.reduceLT, true), (``Int.reduceLE, true), (``Int.reduceGT, true), (``Int.reduceGE, true), (``Int.reduceEq, true), (``Int.reduceNe, true), (``Int.reduceBEq, true), (``Int.reduceBNe, true), + (``Int.reducePow, true), (``Int.reduceAdd, true), (``Int.reduceSub, true), (``Int.reduceMul, true), (``Int.reduceDiv, true), (``Int.reduceMod, true), + (``Int.reduceNegSucc, true), (``Int.reduceNeg, true), (``Int.reduceToNat, true)] + +meta def getSimpArgs : CoreM Simp.SimpArgs := do + let mut scalarTacProcs ← scalarTacSimprocExt.getSimprocs + for (n, post) in scalarTacBuiltinSimprocs do + scalarTacProcs ← scalarTacProcs.add n post pure { simprocs := #[ ← SimpBoolProp.simpBoolPropSimprocExt.getSimprocs, - ← scalarTacSimprocExt.getSimprocs + scalarTacProcs ], simpThms := #[ ← SimpBoolProp.simpBoolPropSimpExt.getTheorems, ← scalarTacSimpExt.getTheorems ]} -def getSimpThmNames : CoreM (Array Name) := do +meta def getSimpThmNames : CoreM (Array Name) := do let args ← getSimpArgs let names := args.simpThms.map fun x => (x.lemmaNames.toList.filterMap fun x => @@ -224,14 +240,14 @@ def getSimpThmNames : CoreM (Array Name) := do /- Sometimes `simp at *` doesn't work in the presence of dependent types. However, simplifying the assumptions *does* work, hence this peculiar way of simplifying the context. -/ -def simpAsmsTarget (simpOnly : Bool) (config : Simp.Config) (args : Simp.SimpArgs) : TacticM (Option (Array FVarId)) := +meta def simpAsmsTarget (simpOnly : Bool) (config : Simp.Config) (args : Simp.SimpArgs) : TacticM (Option (Array FVarId)) := withMainContext do let props ← (← getLCtx).getAssumptions let props := (props.map fun d => d.fvarId).toArray Aeneas.Simp.simpAt simpOnly config args (.targets props true) /- Boosting a bit the `omega` tac. -/ -def preprocess (config : Config) : Tactic.TacticM Unit := do +meta def preprocess (config : Config) : Tactic.TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure m!"scalarTacPreprocess") do Tactic.withMainContext do -- Pre-preprocessing @@ -281,7 +297,7 @@ def preprocess (config : Config) : Tactic.TacticM Unit := do structure State where saturateState : Saturate.State -def State.new (config : Config) : MetaM State := do +meta def State.new (config : Config) : MetaM State := do let env ← getEnv let rules := if config.nonLin then #[scalarTacAttribute, scalarTacNonLinAttribute] @@ -290,7 +306,7 @@ def State.new (config : Config) : MetaM State := do let saturateState := Saturate.State.new rules pure { saturateState } -def partialPreprocess (config : Config) (simpArgs : Simp.SimpArgs) (state : State) +meta def partialPreprocess (config : Config) (simpArgs : Simp.SimpArgs) (state : State) (zetaDelta : Bool) (hypsToUseForSimp assumptionsToPreprocess : Array FVarId) (simpTarget : Bool) (postProcessSat : Bool := false ): Tactic.TacticM (Option (State × Array FVarId)) := do @@ -402,7 +418,7 @@ elab "scalar_tac_preprocess" config:Parser.Tactic.optConfig : tactic => do let config ← elabConfig config preprocess config -def scalarTacCore (config : Config) : Tactic.TacticM Unit := do +meta def scalarTacCore (config : Config) : Tactic.TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure m!"scalarTacCore") do Tactic.withMainContext do Tactic.focus do @@ -444,7 +460,7 @@ def scalarTacCore (config : Config) : Tactic.TacticM Unit := do This works also with strict inequalities. -/ -def scalarTacAux (config : Config) : TacticM Unit := do +meta def scalarTacAux (config : Config) : TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure m!"scalarTac") do Tactic.withMainContext do let error : TacticM Unit := do @@ -475,7 +491,7 @@ def scalarTacAux (config : Config) : TacticM Unit := do else error -def scalarTac (config : Config) : TacticM Unit := do +meta def scalarTac (config : Config) : TacticM Unit := do Tactic.focus do if config.auxTheorem then let g ← getMainGoal @@ -543,7 +559,7 @@ elab "scalar_tac" config:Parser.Tactic.optConfig : tactic => do let config ← elabConfig config scalarTac config -def incrScalarTacCore (config : Config) (state : State) (toClear : Array FVarId) (assumptions : Array FVarId) : TacticM Unit := do +meta def incrScalarTacCore (config : Config) (state : State) (toClear : Array FVarId) (assumptions : Array FVarId) : TacticM Unit := do Tactic.focus do Tactic.withMainContext do /- Clear the useless assumptions -/ @@ -562,7 +578,7 @@ def incrScalarTacCore (config : Config) (state : State) (toClear : Array FVarId) saturate the context. TODO: do we really need the config? -/ -def incrScalarTac (config : Config) (state : State) (toClear : Array FVarId) (assumptions : Array FVarId) : TacticM Unit := do +meta def incrScalarTac (config : Config) (state : State) (toClear : Array FVarId) (assumptions : Array FVarId) : TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure m!"incrScalarTac") do if config.auxTheorem then let g ← getMainGoal From b6fd0dcad8f6a176ed5dd533374b6b0357ded647 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 00:31:36 +0200 Subject: [PATCH 05/40] built in simprocs --- .../Tactic/Solver/ScalarTac/ScalarTac.lean | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean index d5a3e21d5..2e8ba2385 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean @@ -97,15 +97,42 @@ def goalIsLinearInt : Tactic.TacticM Bool := do example (x y : Int) (h0 : x ≤ y) (h1 : x ≠ y) : x < y := by omega --- NOTE: the core *builtin* simprocs (`reduceIte`, `Nat.reduce*`, `Int.reduce*`) that used to be --- listed here cannot be added to a custom simp set via `attribute` under the module system --- (builtin simprocs are not `meta`-marked, so `ensureAttrDeclIsMeta` rejects them). They are now --- injected by name into the `scalar_tac_simps` simproc set in `getSimpArgs` below. attribute [scalar_tac_simps] not_lt not_le lt_inf_iff le_inf_iff Fin.is_le' +/- TODO: The core builtin simprocs cannot be added to the `scalar_tac_simps` set directly via `attribute` under the module system. Instead we register, for each, a local `meta` wrapper. -/ +simproc ↓ [scalar_tac_simps] reduceIte' (ite _ _ _) := reduceIte +simproc [scalar_tac_simps] Nat.reduceLeDiff' ((_ : Nat) ≤ _) := Nat.reduceLeDiff +simproc [scalar_tac_simps] Nat.reduceLT' ((_ : Nat) < _) := Nat.reduceLT +simproc [scalar_tac_simps] Nat.reduceGT' ((_ : Nat) > _) := Nat.reduceGT +dsimproc [scalar_tac_simps] Nat.reduceBEq' ((_ : Nat) == _) := Nat.reduceBEq +dsimproc [scalar_tac_simps] Nat.reduceBNe' ((_ : Nat) != _) := Nat.reduceBNe +dsimproc [scalar_tac_simps] Nat.reducePow' ((_ ^ _ : Nat)) := Nat.reducePow +dsimproc [scalar_tac_simps] Nat.reduceAdd' ((_ + _ : Nat)) := Nat.reduceAdd +dsimproc [scalar_tac_simps] Nat.reduceSub' ((_ - _ : Nat)) := Nat.reduceSub +dsimproc [scalar_tac_simps] Nat.reduceMul' ((_ * _ : Nat)) := Nat.reduceMul +dsimproc [scalar_tac_simps] Nat.reduceDiv' ((_ / _ : Nat)) := Nat.reduceDiv +dsimproc [scalar_tac_simps] Nat.reduceMod' ((_ % _ : Nat)) := Nat.reduceMod +simproc [scalar_tac_simps] Int.reduceLT' ((_ : Int) < _) := Int.reduceLT +simproc [scalar_tac_simps] Int.reduceLE' ((_ : Int) ≤ _) := Int.reduceLE +simproc [scalar_tac_simps] Int.reduceGT' ((_ : Int) > _) := Int.reduceGT +simproc [scalar_tac_simps] Int.reduceGE' ((_ : Int) ≥ _) := Int.reduceGE +simproc [scalar_tac_simps] Int.reduceEq' ((_ : Int) = _) := Int.reduceEq +simproc [scalar_tac_simps] Int.reduceNe' ((_ : Int) ≠ _) := Int.reduceNe +dsimproc [scalar_tac_simps] Int.reduceBEq' ((_ : Int) == _) := Int.reduceBEq +dsimproc [scalar_tac_simps] Int.reduceBNe' ((_ : Int) != _) := Int.reduceBNe +dsimproc [scalar_tac_simps] Int.reducePow' ((_ : Int) ^ (_ : Nat)) := Int.reducePow +dsimproc [scalar_tac_simps] Int.reduceAdd' ((_ + _ : Int)) := Int.reduceAdd +dsimproc [scalar_tac_simps] Int.reduceSub' ((_ - _ : Int)) := Int.reduceSub +dsimproc [scalar_tac_simps] Int.reduceMul' ((_ * _ : Int)) := Int.reduceMul +dsimproc [scalar_tac_simps] Int.reduceDiv' ((_ / _ : Int)) := Int.reduceDiv +dsimproc [scalar_tac_simps] Int.reduceMod' ((_ % _ : Int)) := Int.reduceMod +dsimproc [scalar_tac_simps] Int.reduceNegSucc' (Int.negSucc _) := Int.reduceNegSucc +dsimproc [scalar_tac_simps] Int.reduceNeg' ((- _ : Int)) := Int.reduceNeg +dsimproc [scalar_tac_simps] Int.reduceToNat' (Int.toNat _) := Int.reduceToNat + /- Small trick to prevent `simp_all` from simplifying an assumption `h1 : P v` when we have `h0 : ∀ x, P x` in the context: we replace the forall quantifiers with our own definition of `forall`. -/ @@ -203,26 +230,11 @@ elab "scalar_tac_saturate" config:Parser.Tactic.optConfig : tactic => do let config ← elabConfig config let _ ← scalarTacSaturateForward config.toSaturateConfig none none (postprocessThm := none) (fun _ _ => pure ()) -/-- Core builtin simprocs we want active in `scalar_tac`'s preprocessing. They can't be added to - the `C` set via `attribute` under the module system (builtin simprocs aren't - `meta`-marked), so we inject them by name here. Pairs are `(name, post)`: `reduceIte` is a pre - (`↓`) simproc, the numeric reducers are post. -/ -private meta def scalarTacBuiltinSimprocs : List (Name × Bool) := - [(``reduceIte, false), - (``Nat.reduceLeDiff, true), (``Nat.reduceLT, true), (``Nat.reduceGT, true), (``Nat.reduceBEq, true), (``Nat.reduceBNe, true), - (``Nat.reducePow, true), (``Nat.reduceAdd, true), (``Nat.reduceSub, true), (``Nat.reduceMul, true), (``Nat.reduceDiv, true), (``Nat.reduceMod, true), - (``Int.reduceLT, true), (``Int.reduceLE, true), (``Int.reduceGT, true), (``Int.reduceGE, true), (``Int.reduceEq, true), (``Int.reduceNe, true), (``Int.reduceBEq, true), (``Int.reduceBNe, true), - (``Int.reducePow, true), (``Int.reduceAdd, true), (``Int.reduceSub, true), (``Int.reduceMul, true), (``Int.reduceDiv, true), (``Int.reduceMod, true), - (``Int.reduceNegSucc, true), (``Int.reduceNeg, true), (``Int.reduceToNat, true)] - meta def getSimpArgs : CoreM Simp.SimpArgs := do - let mut scalarTacProcs ← scalarTacSimprocExt.getSimprocs - for (n, post) in scalarTacBuiltinSimprocs do - scalarTacProcs ← scalarTacProcs.add n post pure { simprocs := #[ ← SimpBoolProp.simpBoolPropSimprocExt.getSimprocs, - scalarTacProcs + ← scalarTacSimprocExt.getSimprocs ], simpThms := #[ ← SimpBoolProp.simpBoolPropSimpExt.getTheorems, From c5f78f68e37bb528162e1cc94bc4c2fd97f7e3d4 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 00:57:25 +0200 Subject: [PATCH 06/40] std.wp remains! --- backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean | 8 ++++---- backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean | 8 ++++---- backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean | 1 + .../lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean | 8 ++++---- .../lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean b/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean index 1ed876747..73858f8c7 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpIfs/SimpIfs.lean @@ -1,7 +1,7 @@ module -public import Aeneas.Tactic.Simp.SimpIfs.Init +public meta import Aeneas.Tactic.Simp.SimpIfs.Init public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp -public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public meta import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac public section /-! @@ -14,7 +14,7 @@ namespace Aeneas.SimpIfs open Lean Lean.Meta Lean.Parser.Tactic Lean.Elab.Tactic -def simpIfsTac (config : ScalarTac.CondSimpTacConfig) +meta def simpIfsTac (config : ScalarTac.CondSimpTacConfig) (args : ScalarTac.CondSimpPartialArgs) (loc : Utils.Location) : TacticM Unit := do let addSimpThms : TacticM (Array FVarId) := pure #[] let hypsArgs : ScalarTac.CondSimpArgs := { @@ -63,7 +63,7 @@ theorem dite_true {α} (c : Prop) [Decidable c] (h : c) (t : c → α) (e : ¬c theorem dite_fase {α} (c : Prop) [Decidable c] (h : ¬ c) (t : c → α) (e : ¬c → α) : dite c t e = e h := by simp [h] -def parseSimpIfs : +meta def parseSimpIfs : TSyntax ``simp_ifs -> TacticM (ScalarTac.CondSimpTacConfig × ScalarTac.CondSimpPartialArgs × Utils.Location) | `(tactic| simp_ifs $config $[[$args,*]]? $[$loc:location]?) => do let config ← ScalarTac.elabCondSimpTacConfig config diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean b/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean index be0528a76..138e7fee8 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpLists/SimpLists.lean @@ -1,7 +1,7 @@ module public import Mathlib.Data.Nat.Bitwise -public import Aeneas.Tactic.Simp.SimpLists.Init -public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public meta import Aeneas.Tactic.Simp.SimpLists.Init +public meta import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp public section @@ -45,7 +45,7 @@ attribute [simp_lists_safe] List.length_cons List.length_nil -- Automatically go from `getElem!` to `getElem` attribute [simp_lists] getElem!_pos -def simpListsTac (config : ScalarTac.CondSimpTacConfig) +meta def simpListsTac (config : ScalarTac.CondSimpTacConfig) (args : ScalarTac.CondSimpPartialArgs) (loc : Utils.Location) : TacticM Unit := do let addSimpThms : TacticM (Array FVarId) := pure #[] let hypsArgs : ScalarTac.CondSimpArgs := { @@ -85,7 +85,7 @@ The `+safe` option restricts `simp_lists` to only the safe lemmas. -/ syntax (name := simp_lists) "simp_lists" Parser.Tactic.optConfig ("[" (term<|>"*"),* "]")? (location)? : tactic -def parseSimpLists : +meta def parseSimpLists : TSyntax ``simp_lists -> TacticM (ScalarTac.CondSimpTacConfig × ScalarTac.CondSimpPartialArgs × Utils.Location) | `(tactic| simp_lists $config $[[$args,*]]? $[$loc:location]?) => do let config ← ScalarTac.elabCondSimpTacConfig config diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean index 68ac1df1c..fcb6709be 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean @@ -1,6 +1,7 @@ module public import Aeneas.Tactic.Simp.SimpScalar.SimpScalar public import Aeneas.Tactic.Simproc.ReduceNat +import all Init.Data.Nat.Power2.Basic public section section diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean index d7a5b702e..275e00f37 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/SimpScalar.lean @@ -1,8 +1,8 @@ module public import Mathlib.Data.Nat.Bitwise public import Aeneas.Tactic.Simp.SimpScalar.Init -public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac -public import Aeneas.Tactic.Simp.SimpLists.Init -- We need to mark some lemmas as `simp_lists_safe` +public meta import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public meta import Aeneas.Tactic.Simp.SimpLists.Init -- We need to mark some lemmas as `simp_lists_safe` public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp public section @@ -194,7 +194,7 @@ theorem BitVec.toNat_lt_two_pow {w} (x : BitVec w) (i : ℕ) (h : w ≤ i) : x.t attribute [simp_scalar_safe] BitVec.setWidth_eq BitVec.ofNat_eq_ofNat -def simpScalarTac (config : ScalarTac.CondSimpTacConfig) +meta def simpScalarTac (config : ScalarTac.CondSimpTacConfig) (args : ScalarTac.CondSimpPartialArgs) (loc : Utils.Location) : TacticM Unit := do let addSimpThms : TacticM (Array FVarId) := pure #[] let hypsArgs : ScalarTac.CondSimpArgs := { @@ -251,7 +251,7 @@ theorem Nat.lt_pow (a i : ℕ) (h0 : 1 < a) (h1 : 1 < i) : a < a ^ i := ... -/ syntax (name := simp_scalar) "simp_scalar" Parser.Tactic.optConfig ("[" (term<|>"*"),* "]")? (location)? : tactic -def parseSimpScalar : +meta def parseSimpScalar : TSyntax ``simp_scalar -> TacticM (ScalarTac.CondSimpTacConfig × ScalarTac.CondSimpPartialArgs × Utils.Location) | `(tactic| simp_scalar $config $[[$args,*]]? $[$loc:location]?) => do let config ← ScalarTac.elabCondSimpTacConfig config diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean index 2e8ba2385..fdb802a75 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean @@ -136,7 +136,7 @@ dsimproc [scalar_tac_simps] Int.reduceToNat' (Int.toNat _) := Int.reduceToNat /- Small trick to prevent `simp_all` from simplifying an assumption `h1 : P v` when we have `h0 : ∀ x, P x` in the context: we replace the forall quantifiers with our own definition of `forall`. -/ -def forall' {α : Type u} (p : α → Prop) : Prop := ∀ (x: α), p x +@[expose] def forall' {α : Type u} (p : α → Prop) : Prop := ∀ (x: α), p x theorem forall_eq_forall' {α : Type u} (p : α → Prop) : (∀ (x: α), p x) = forall' p := by simp [forall'] From 71affbe05a7f1f72fa45da3d1e1167291f61eef0 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 09:30:39 +0200 Subject: [PATCH 07/40] WP done --- backends/lean/Aeneas/Std/Primitives.lean | 8 +++-- backends/lean/Aeneas/Std/WP.lean | 39 ++++++++++++------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index c91dd888c..8dbe48a55 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -91,7 +91,9 @@ def div? {α: Type u} (r: Result α): Bool := | div => true | ok _ | fail _ => false -def massert (b : Prop) [Decidable b] : Result Unit := +/- TODO (module system): better style would be avoid `@[expose]` here and instead export only the +appropriate charatirization lemmas. The lemmas currently live in `Aeneas.Std.PrimitivesLemmas`. -/ +@[expose] def massert (b : Prop) [Decidable b] : Result Unit := if b then ok () else fail assertionFailure macro "prove_eval_global" : tactic => `(tactic| simp (failIfUnchanged := false) only [global_simps] <;> first | apply Eq.refl | decide) @@ -117,7 +119,7 @@ def Result.ofOption {a : Type u} (x : Option a) (e : Error) : Result a := # Do-DSL Support -/ -def bind {α : Type u} {β : Type v} (x: Result α) (f: α → Result β) : Result β := +@[expose] def bind {α : Type u} {β : Type v} (x: Result α) (f: α → Result β) : Result β := match x with | ok v => f v | fail v => fail v @@ -279,7 +281,7 @@ inductive ControlFlow (α : Type u) (β : Type v) where | done (v : β) -- break deriving Repr, BEq -def loop {α : Type u} {β : Type v} (body : α → Result (ControlFlow α β)) (x : α) : Result β := do +@[expose] def loop {α : Type u} {β : Type v} (body : α → Result (ControlFlow α β)) (x : α) : Result β := do match body x with | ok r => match r with diff --git a/backends/lean/Aeneas/Std/WP.lean b/backends/lean/Aeneas/Std/WP.lean index a679a47e0..2200d078e 100644 --- a/backends/lean/Aeneas/Std/WP.lean +++ b/backends/lean/Aeneas/Std/WP.lean @@ -3,30 +3,31 @@ public import Aeneas.Std.Primitives public import Aeneas.Std.Delab public import Std.Do public import Aeneas.Tactic.Solver.Grind.Init -public import Aeneas.Std.Spec +public meta import Aeneas.Std.Spec +public meta import Aeneas.Std.Delab public section namespace Aeneas.Std.WP open Std Result -def Post α := (α -> Prop) +abbrev Post α := (α -> Prop) abbrev Pre := Prop -def Wp α := Post α → Pre +abbrev Wp α := Post α → Pre -def wp_return (x:α) : Wp α := fun p => p x +@[expose] def wp_return (x:α) : Wp α := fun p => p x -def theta (m:Result α) : Wp α := +@[expose] def theta (m:Result α) : Wp α := match m with | ok x => wp_return x | fail _ => fun _ => False | div => fun _ => False -def spec {α} (x:Result α) (p:Post α) := +@[expose] def spec {α} (x:Result α) (p:Post α) := theta x p -def dspec {α} (x:Result α) (p:Post α) := +@[expose] def dspec {α} (x:Result α) (p:Post α) := match x with | ok x => p x | fail _ => False @@ -274,7 +275,7 @@ open Lean PrettyPrinter Given `x0`, ..., `xn` and `body`, generates the (syntactic) term `fun (x0, ..., xn) => body`. -/ -partial def buildUncurryLam (xs : List (TSyntax `term)) (body : TSyntax `term) : +meta partial def buildUncurryLam (xs : List (TSyntax `term)) (body : TSyntax `term) : MacroM (TSyntax `term) := do let uncurryIdent := mkIdent ``Std.uncurry match xs with @@ -286,7 +287,7 @@ partial def buildUncurryLam (xs : List (TSyntax `term)) (body : TSyntax `term) : `($uncurryIdent (fun $a => $inner)) /-- Helper to elaborate `binder => body` when binder is a tuple - this supports nested tuples. -/ -partial def mkBinderFun (depth : Nat) (binder : Term) (body : Term) : MacroM Term := do +meta partial def mkBinderFun (depth : Nat) (binder : Term) (body : Term) : MacroM Term := do match binder with | `( ($a, $bs,*) ) => let xs : List Term := a :: bs.getElems.toList @@ -305,7 +306,7 @@ partial def mkBinderFun (depth : Nat) (binder : Term) (body : Term) : MacroM Ter buildUncurryLam leafIdents wrappedBody | _ => `(fun $binder => $body) -def mk_function_syntax (p : TSyntax `term) (depth : Nat) (xs : List Term) : MacroM Term := do +meta def mk_function_syntax (p : TSyntax `term) (depth : Nat) (xs : List Term) : MacroM Term := do match xs with | [] => `($p) | [x] => mkBinderFun depth x p @@ -318,7 +319,7 @@ def mk_function_syntax (p : TSyntax `term) (depth : Nat) (xs : List Term) : Macr identifiers — i.e. a binder group like `a b c` — return the identifiers in order. Otherwise return `none`, so anonymous constructors `⟨a, b⟩`, tuple patterns, and other structured terms are left untouched. -/ -private partial def binderGroupIdents? (stx : Syntax) : Option (Array Term) := +private meta partial def binderGroupIdents? (stx : Syntax) : Option (Array Term) := if stx.isIdent then some #[⟨stx⟩] else if stx.getKind == ``Lean.Parser.Term.app || stx.getKind == Lean.nullKind then stx.getArgs.foldlM (init := (#[] : Array Term)) fun acc s => @@ -330,7 +331,7 @@ private partial def binderGroupIdents? (stx : Syntax) : Option (Array Term) := so each name becomes its own product component (exactly as if written separately). Tuple/pattern binders `(a, b)`, `(⟨a, b⟩ : T)`, single binders `(a : T)`, and bare identifiers are returned unchanged. -/ -private def expandGroupedBinder (binder : Term) : MacroM (List Term) := do +private meta def expandGroupedBinder (binder : Term) : MacroM (List Term) := do match binder with | `(($e : $t)) => match binderGroupIdents? e.raw with @@ -341,7 +342,7 @@ private def expandGroupedBinder (binder : Term) : MacroM (List Term) := do | _ => pure [binder] /-- Flatten grouped binders across the whole binder list. -/ -private def expandBinders (xs : List Term) : MacroM (List Term) := do +private meta def expandBinders (xs : List Term) : MacroM (List Term) := do let mut out : Array Term := #[] for x in xs do out := out ++ (← expandGroupedBinder x).toArray @@ -349,7 +350,7 @@ private def expandBinders (xs : List Term) : MacroM (List Term) := do /-- Build the postcondition term for `⦃ xs => p ⦄`, expanding grouped binders into one component per name first. -/ -private def mkPost (p : Term) (xs : List Term) : MacroM Term := do +private meta def mkPost (p : Term) (xs : List Term) : MacroM Term := do mk_function_syntax p 0 (← expandBinders xs) /-- Macro expansion for a single element (may expand to several via a grouped binder) -/ @@ -416,7 +417,7 @@ so the continuation lambdas are left untouched. Example: on `fun a b => fun c => body`, collects `[a, b]` and leaves the reader at `fun c => body`. -/ -private partial def enterUncurryOnce (acc : Array Std.Delab.BinderEntry) +private meta partial def enterUncurryOnce (acc : Array Std.Delab.BinderEntry) (k : Array Std.Delab.BinderEntry → DelabM α) : DelabM α := do match (← getExpr) with | .lam n _ _ _ => @@ -430,7 +431,7 @@ private partial def enterUncurryOnce (acc : Array Std.Delab.BinderEntry) | _ => k acc /-- Is the expression an `uncurry'` or `uncurry` wrapper? -/ -private def isPostBinderWrapper (e : Expr) : Bool := +private meta def isPostBinderWrapper (e : Expr) : Bool := match_expr e.consumeMData with | uncurry' _ _ _ => true | uncurry _ _ _ _ => true @@ -440,7 +441,7 @@ private def isPostBinderWrapper (e : Expr) : Bool := Returns `(binders, bodyTerm)` where each binder is a `Term` (either a plain name like `x` or a (potentially nested) tuple pattern like `(a, b)`). -/ -private partial def delabPostBinders : DelabM (Array Term × Term) := do +private meta partial def delabPostBinders : DelabM (Array Term × Term) := do match_expr (← getExpr).consumeMData with | uncurry' _ _ _ => /- `uncurry' f`: dive into `f` (arg 2) and peel one binder. @@ -493,7 +494,7 @@ where /-- Delaborator for `WP.spec e post` → `e ⦃ binders => body ⦄`. -/ @[scoped delab app.Aeneas.Std.WP.spec] -def delabSpec : Delab := do +meta def delabSpec : Delab := do guard $ (← getExpr).isAppOfArity' ``spec 3 let monadExpr ← withNaryArg 1 delab let (binders, bodyTerm) ← withNaryArg 2 delabPostBinders @@ -504,7 +505,7 @@ def delabSpec : Delab := do /-- Delaborator for `WP.dspec e post` → `e ⦃ binders => body ⦄div`. -/ @[scoped delab app.Aeneas.Std.WP.dspec] -def delabDSpec : Delab := do +meta def delabDSpec : Delab := do guard $ (← getExpr).isAppOfArity' ``dspec 3 let monadExpr ← withNaryArg 1 delab let (binders, bodyTerm) ← withNaryArg 2 delabPostBinders From 1505429036791dce6c286dbae1931c929e93207b Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 13:41:56 +0200 Subject: [PATCH 08/40] decompose --- backends/lean/Aeneas/Command/Decompose.lean | 93 +++++++++++---------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/backends/lean/Aeneas/Command/Decompose.lean b/backends/lean/Aeneas/Command/Decompose.lean index cca83801e..6ab042f36 100644 --- a/backends/lean/Aeneas/Command/Decompose.lean +++ b/backends/lean/Aeneas/Command/Decompose.lean @@ -8,6 +8,7 @@ public import Aeneas.Std.Primitives public import Aeneas.Std.WP public import AeneasMeta.Simp.Simp public import AeneasMeta.Utils +public meta import AeneasMeta.Simp.Simp public section /-! @@ -181,7 +182,7 @@ initialize registerTraceClass `Decompose /-- If true (default), warn when two clauses in the same `#decompose` call produce definitionally equal definitions under different names. -/ -register_option Aeneas.Decompose.checkDuplicate : Bool := { +meta register_option Aeneas.Decompose.checkDuplicate : Bool := { defValue := true descr := "Warn when two decomposition clauses produce identical definitions with different names" } @@ -189,7 +190,7 @@ register_option Aeneas.Decompose.checkDuplicate : Bool := { /-- If true (default), when a clause uses a name that already exists in the environment, check that the existing definition is definitionally equal and reuse it. If false, only look at definitions introduced by the current `#decompose` call. -/ -register_option Aeneas.Decompose.useExisting : Bool := { +meta register_option Aeneas.Decompose.useExisting : Bool := { defValue := true descr := "Allow reusing definitions that already exist in the environment" } @@ -252,7 +253,7 @@ syntax &"appFun" &"full" : decompose_pat syntax &"argArg" num "(" decompose_pat ")" : decompose_pat syntax &"argArg" num &"full" : decompose_pat -partial def elabDecomposePat : Syntax → Except String DecomposePattern +meta partial def elabDecomposePat : Syntax → Except String DecomposePattern | `(decompose_pat| letRange $start $count) => return .letRange start.getNat count.getNat | `(decompose_pat| letAt $idx ($inner)) => do @@ -298,18 +299,18 @@ inductive FVarTree where | leaf : Expr → FVarTree | pair : FVarTree → FVarTree → FVarTree -instance : Inhabited FVarTree where +meta instance : Inhabited FVarTree where default := .leaf default /-- Collect all leaf fvars from a tree into a flat array. -/ -def FVarTree.fvars : FVarTree → Array Expr +meta def FVarTree.fvars : FVarTree → Array Expr | .leaf fv => #[fv] | .pair l r => l.fvars ++ r.fvars /-- Build a right-nested tree from a list of sub-trees. `[t0, t1]` → `pair t0 t1` `[t0, t1, t2]` → `pair t0 (pair t1 t2)` -/ -def buildTreeFromList [Monad m] [MonadError m] : List FVarTree → m FVarTree +meta def buildTreeFromList [Monad m] [MonadError m] : List FVarTree → m FVarTree | [] => throwError "buildTreeFromList: empty list (internal error)" | [t] => return t | t :: ts => return .pair t (← buildTreeFromList ts) @@ -318,7 +319,7 @@ def buildTreeFromList [Monad m] [MonadError m] : List FVarTree → m FVarTree For simple binds, `fvars` has one element. For tuple-destructuring binds (`let (a, b, c) ← comp`), `fvars` has one element per component. -/ -structure BindingEntry where +meta structure BindingEntry where name : Name type : Expr value : Expr -- pure: the value; monadic: the computation @@ -334,21 +335,21 @@ structure BindingEntry where /-- Match `Bind.bind` or `bind` applied to 6 args. Returns `(m, inst, α, β, computation, continuation)`. -/ -def matchBind? (e : Expr) : Option (Expr × Expr × Expr × Expr × Expr × Expr) := do +meta def matchBind? (e : Expr) : Option (Expr × Expr × Expr × Expr × Expr × Expr) := do let fn := e.getAppFn let args := e.getAppArgs guard ((fn.isConstOf ``Bind.bind || fn.isConstOf ``bind) && args.size == 6) return (args[0]!, args[1]!, args[2]!, args[3]!, args[4]!, args[5]!) /-- Match `@ite α cond inst thenBranch elseBranch`. -/ -def matchIte? (e : Expr) : Option (Expr × Expr × Expr × Expr × Expr) := do +meta def matchIte? (e : Expr) : Option (Expr × Expr × Expr × Expr × Expr) := do let fn := e.getAppFn let args := e.getAppArgs guard (fn.isConstOf ``ite && args.size == 5) return (args[0]!, args[1]!, args[2]!, args[3]!, args[4]!) /-- Match `@dite α cond inst thenBranch elseBranch`. -/ -def matchDite? (e : Expr) : Option (Expr × Expr × Expr × Expr × Expr) := do +meta def matchDite? (e : Expr) : Option (Expr × Expr × Expr × Expr × Expr) := do let fn := e.getAppFn let args := e.getAppArgs guard (fn.isConstOf ``dite && args.size == 5) @@ -378,7 +379,7 @@ def matchDite? (e : Expr) : Option (Expr × Expr × Expr × Expr × Expr) := do multiple fvars `#[c, d]` and an `FVarTree` recording the nesting structure. Nested tuples like `let ((a, b), (c, d)) ← ...` are fully opened to their leaf components. -/ -partial def withBindings (e : Expr) (acc : Array BindingEntry) +meta partial def withBindings (e : Expr) (acc : Array BindingEntry) (k : Array BindingEntry → Expr → DecomposeM α) : DecomposeM α := do -- Pure let match e with @@ -584,7 +585,7 @@ where /-- Abstract over `fvars`, always creating lambda binders (even for let-decl fvars). Standard `mkLambdaFVars` creates let-bindings for let-decl fvars, which is wrong when building extracted function definitions that should take parameters. -/ -private def mkLamAbstract (fvars : Array Expr) (body : Expr) : MetaM Expr := do +private meta def mkLamAbstract (fvars : Array Expr) (body : Expr) : MetaM Expr := do let mut result := body for fv in fvars.reverse do let decl ← fv.fvarId!.getDecl @@ -594,7 +595,7 @@ private def mkLamAbstract (fvars : Array Expr) (body : Expr) : MetaM Expr := do /-- Abstract over `fvars`, always creating forall binders (even for let-decl fvars). Standard `mkForallFVars` creates let-types for let-decl fvars, which is wrong when building extracted function type signatures. -/ -private def mkForallAbstract (fvars : Array Expr) (body : Expr) : MetaM Expr := do +private meta def mkForallAbstract (fvars : Array Expr) (body : Expr) : MetaM Expr := do let mut result := body for fv in fvars.reverse do let decl ← fv.fvarId!.getDecl @@ -607,13 +608,13 @@ private def mkForallAbstract (fvars : Array Expr) (body : Expr) : MetaM Expr := /-- Build `Std.uncurry (fun x => body)` for a single pair layer. Always creates a lambda (not a let-binding), even for let-decl fvars. -/ -private def mkUncurry (fvar : Expr) (body : Expr) : MetaM Expr := do +private meta def mkUncurry (fvar : Expr) (body : Expr) : MetaM Expr := do let fn ← mkLamAbstract #[fvar] body mkAppM ``_root_.Aeneas.Std.uncurry #[fn] /-- Compute the product type corresponding to an `FVarTree`. Leaf: the fvar's type. Pair: `leftType × rightType`. -/ -private partial def FVarTree.type : FVarTree → MetaM Expr +private meta partial def FVarTree.type : FVarTree → MetaM Expr | .leaf fvar => inferType fvar | .pair left right => do mkAppM ``Prod #[← left.type, ← right.type] @@ -636,7 +637,7 @@ private partial def FVarTree.type : FVarTree → MetaM Expr `uncurry (fun _x c => uncurry (fun a b => body) _x)` NOT: `uncurry (uncurry (fun a b c => body))` (which `openUncurryFVars` can't parse) NOT: `uncurry (fun _x => uncurry (fun a b c => body) _x)` (right var `c` hidden) -/ -private partial def rebuildUncurryFromTree (tree : FVarTree) (body : Expr) : MetaM Expr := do +private meta partial def rebuildUncurryFromTree (tree : FVarTree) (body : Expr) : MetaM Expr := do match tree with | .leaf fvar => mkLamAbstract #[fvar] body | .pair left right => @@ -679,7 +680,7 @@ where /-- Rebuild an expression from `bindings[startIdx .. endIdx-1]` followed by `terminal`. Abstracts fvars bottom-up using `mkLambdaFVars` / `mkLetFVars`. Handles tuple-destructuring binds by reconstructing `Std.uncurry` chains. -/ -def rebuildBindings (bindings : Array BindingEntry) (terminal : Expr) +meta def rebuildBindings (bindings : Array BindingEntry) (terminal : Expr) (startIdx endIdx : Nat) : MetaM Expr := do let mut result := terminal let mut i := endIdx @@ -703,7 +704,7 @@ def rebuildBindings (bindings : Array BindingEntry) (terminal : Expr) -- ============================================================================ /-- Project element `idx` from a nested tuple of `totalSize` components. -/ -partial def mkProjection (tuple : Expr) (totalSize idx : Nat) : MetaM Expr := do +meta partial def mkProjection (tuple : Expr) (totalSize idx : Nat) : MetaM Expr := do if totalSize ≤ 1 then return tuple if idx == 0 then mkAppM ``Prod.fst #[tuple] else do @@ -715,14 +716,14 @@ partial def mkProjection (tuple : Expr) (totalSize idx : Nat) : MetaM Expr := do -- ============================================================================ /-- Which of `available` appear free in `e`? Preserves order. -/ -def filterRelevantFVars (e : Expr) (available : Array Expr) : MetaM (Array Expr) := +meta def filterRelevantFVars (e : Expr) (available : Array Expr) : MetaM (Array Expr) := available.filterM fun fv => pure (e.containsFVar fv.fvarId!) /-- Collect all non-implementation-detail fvars from the local context that appear free in `e` or in the types of collected fvars (dependency closure). This ensures extracted definitions include all necessary type parameters. Returns fvars in context order. -/ -def collectFreeLocalFVars (e : Expr) : MetaM (Array Expr) := do +meta def collectFreeLocalFVars (e : Expr) : MetaM (Array Expr) := do let lctx ← getLCtx -- Collect fvar IDs that we need (iteratively, until fixpoint) let mut needed : Std.HashSet FVarId := {} @@ -756,7 +757,7 @@ def collectFreeLocalFVars (e : Expr) : MetaM (Array Expr) := do -- ============================================================================ /-- Check if an expression transitively references any noncomputable or opaque constant. -/ -private def hasNoncomputableDep (env : Environment) (e : Expr) : Bool := +private meta def hasNoncomputableDep (env : Environment) (e : Expr) : Bool := e.foldConsts false fun n acc => acc || isNoncomputable env n || match env.find? n with @@ -779,7 +780,7 @@ private def hasNoncomputableDep (env : Environment) (e : Expr) : Bool := noncomputable or opaque constants (which cause deferred IR errors). `clauseDesc` is used in error messages to identify which decomposition clause triggered the conflict. -/ -private def addDefinition (name : Name) (levelParams : List Name) +private meta def addDefinition (name : Name) (levelParams : List Name) (type value : Expr) (srcIsNoncomputable : Bool) (clauseDesc : MessageData := "decomposition clause") : DecomposeM Unit := do let env ← getEnv @@ -860,7 +861,7 @@ private def addDefinition (name : Name) (levelParams : List Name) /-- Extract the whole expression as a new definition. Returns the call expression that replaces it. -/ -def extractFull (body : Expr) (newName : Name) +meta def extractFull (body : Expr) (newName : Name) (levelParams : List Name) (srcIsNoncomputable : Bool) (clauseDesc : MessageData) : DecomposeM Expr := do let relevantFVars ← collectFreeLocalFVars body @@ -875,7 +876,7 @@ def extractFull (body : Expr) (newName : Name) /-- Extract `count` consecutive bindings starting at `start`. Returns the **full** modified body (wrapping bindings before the range too). -/ -def extractLetRange (bindings : Array BindingEntry) (terminal : Expr) +meta def extractLetRange (bindings : Array BindingEntry) (terminal : Expr) (start count : Nat) (newName : Name) (levelParams : List Name) (srcIsNoncomputable : Bool) (clauseDesc : MessageData) : DecomposeM Expr := do @@ -1012,7 +1013,7 @@ def extractLetRange (bindings : Array BindingEntry) (terminal : Expr) -- ============================================================================ /-- Format a pattern for error messages. -/ -def formatPattern : DecomposePattern → String +meta def formatPattern : DecomposePattern → String | .letRange s c => s!"letRange {s} {c}" | .letAt i inner => s!"letAt {i} ({formatPattern inner})" | .afterLets inner => s!"afterLets ({formatPattern inner})" @@ -1023,11 +1024,11 @@ def formatPattern : DecomposePattern → String | .argArg i inner => s!"argArg {i} ({formatPattern inner})" /-- Format a decompose clause for error messages. -/ -private def formatClause (pat : DecomposePattern) (name : Name) : MessageData := +private meta def formatClause (pat : DecomposePattern) (name : Name) : MessageData := m!"{formatPattern pat} => {name}" /-- Format a pattern element (without its inner pattern) for error messages. -/ -private def formatPatternHead : DecomposePattern → String +private meta def formatPatternHead : DecomposePattern → String | .letRange s c => s!"letRange {s} {c}" | .letAt i _ => s!"letAt {i} _" | .afterLets _ => s!"afterLets _" @@ -1038,7 +1039,7 @@ private def formatPatternHead : DecomposePattern → String | .argArg i _ => s!"argArg {i} _" /-- Format a list of applied prefix patterns (outermost first). -/ -private def formatPrefixPath (prefix_ : Array DecomposePattern) : String := +private meta def formatPrefixPath (prefix_ : Array DecomposePattern) : String := if prefix_.isEmpty then "" else -- Build the nested pattern string from the prefix elements @@ -1059,7 +1060,7 @@ private def formatPrefixPath (prefix_ : Array DecomposePattern) : String := Formats the error to show the failing pattern element, the sub-expression it was applied to, and (if non-empty) the prefix pattern that was successfully applied. -/ -def throwNavError (currentExpr : Expr) (rawMsg : MessageData) : DecomposeM α := do +meta def throwNavError (currentExpr : Expr) (rawMsg : MessageData) : DecomposeM α := do let ctx := (← get).navCtx let failingElem := match ctx.currentPattern with | some pat => formatPatternHead pat @@ -1087,7 +1088,7 @@ def throwNavError (currentExpr : Expr) (rawMsg : MessageData) : DecomposeM α := /-- Open `n` nested lambda binders, apply `action` to the innermost body, close them back. If `strict`, throws an error when fewer than `n` lambdas are found. If not strict, applies `action` to whatever expression remains. -/ -private def modifyUnderLambdasCore (strict : Bool) (e : Expr) (n : Nat) +private meta def modifyUnderLambdasCore (strict : Bool) (e : Expr) (n : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do match n with | 0 => action e @@ -1106,20 +1107,20 @@ private def modifyUnderLambdasCore (strict : Bool) (e : Expr) (n : Nat) /-- Open up to `n` lambda binders (permissive: applies action even if fewer lambdas exist). Used for match/dite branches where Lean may compile away some binders. -/ -private def modifyUnderLambdasPermissive (e : Expr) (n : Nat) +private meta def modifyUnderLambdasPermissive (e : Expr) (n : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := modifyUnderLambdasCore (strict := false) e n action /-- Open exactly `n` lambda binders (strict: throws if fewer exist). Used for the `lam` navigation pattern. -/ -def modifyUnderLambdas (e : Expr) (n : Nat) +meta def modifyUnderLambdas (e : Expr) (n : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := modifyUnderLambdasCore (strict := true) e n action /-- Modify branch `idx` of an ite/dite/match expression. Calls `action` on the branch body (under all pattern-variable lambdas); returns the reconstructed expression. -/ -def modifyBranch (e : Expr) (idx : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do +meta def modifyBranch (e : Expr) (idx : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do -- Try ite if let some (α, cond, inst, thenB, elseB) := matchIte? e then if idx == 0 then @@ -1153,7 +1154,7 @@ def modifyBranch (e : Expr) (idx : Nat) (action : Expr → DecomposeM Expr) : De throwNavError e m!"branch {idx}: expression is not an ite, dite, or match" /-- Modify the function part of an application. -/ -def modifyAppFun (e : Expr) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do +meta def modifyAppFun (e : Expr) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do let fn := e.getAppFn let args := e.getAppArgs if args.size == 0 then throwNavError e m!"appFun: expression is not an application" @@ -1161,7 +1162,7 @@ def modifyAppFun (e : Expr) (action : Expr → DecomposeM Expr) : DecomposeM Exp return mkAppN fn' args /-- Modify argument `idx` of an application (0-indexed, explicit args). -/ -def modifyAppArg (e : Expr) (idx : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do +meta def modifyAppArg (e : Expr) (idx : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do let fn := e.getAppFn let args := e.getAppArgs if idx >= args.size then @@ -1177,7 +1178,7 @@ def modifyAppArg (e : Expr) (idx : Nat) (action : Expr → DecomposeM Expr) : De Returns the modified full expression. When `idx == 0`: if the expression is a let or bind, operates on the bound expression; otherwise operates on the full expression (the "terminal"). -/ -partial def modifyBindingValue (e : Expr) (idx : Nat) +meta partial def modifyBindingValue (e : Expr) (idx : Nat) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do if idx == 0 then -- Modify the current binding's value, or the terminal if not a let/bind @@ -1259,7 +1260,7 @@ where /-- Navigate past all let/bind bindings to the terminal expression and apply `action` to it. Returns the modified full expression. -/ -partial def modifyAfterLets (e : Expr) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do +meta partial def modifyAfterLets (e : Expr) (action : Expr → DecomposeM Expr) : DecomposeM Expr := do match e with | .letE name type value body _nonDep => withLetDecl name type value fun fvar => do @@ -1320,7 +1321,7 @@ where /-- Set the navigation context for error messages. Called before each navigation step so that `throwNavError` can format errors with the right context. -/ -private def setNavCtx (rootExpr : Expr) (pat : DecomposePattern) +private meta def setNavCtx (rootExpr : Expr) (pat : DecomposePattern) (appliedPrefix : Array DecomposePattern) : DecomposeM Unit := modify fun s => { s with navCtx := { rootExpr := some rootExpr @@ -1330,7 +1331,7 @@ private def setNavCtx (rootExpr : Expr) (pat : DecomposePattern) /-- Apply one decompose clause: navigate with the pattern, extract, replace. Returns the modified function body. -/ -partial def applyClause (body : Expr) (pat : DecomposePattern) (newName : Name) +meta partial def applyClause (body : Expr) (pat : DecomposePattern) (newName : Name) (levelParams : List Name) (srcIsNoncomputable : Bool) (appliedPrefix : Array DecomposePattern := #[]) : DecomposeM Expr := do @@ -1385,7 +1386,7 @@ partial def applyClause (body : Expr) (pat : DecomposePattern) (newName : Name) /-- Run `simp only` with the given theorems on the goal's target. Returns `none` if the goal was closed, `some mvarId` otherwise. -/ -private def simpOnlyTarget (mvarId : MVarId) (declsToUnfold : Array Name) +private meta def simpOnlyTarget (mvarId : MVarId) (declsToUnfold : Array Name) (addSimpThms : Array Name) : MetaM (Option MVarId) := do let args : SimpArgs := { declsToUnfold, addSimpThms } let (ctx, simprocs) ← mkSimpCtx (simpOnly := true) { maxSteps := 100000 } .simp args @@ -1398,7 +1399,7 @@ private def simpOnlyTarget (mvarId : MVarId) (declsToUnfold : Array Name) /-- Prove the decomposition equality: `∀ params, body_original = body_decomposed`. `defNames` are the names of all auxiliary definitions introduced. -/ -def proveStep (goalType : Expr) (defNames : Array Name) : TermElabM Expr := do +meta def proveStep (goalType : Expr) (defNames : Array Name) : TermElabM Expr := do let simpThms := #[``Aeneas.Std.bind_assoc_eq, ``LawfulMonad.pure_bind] let mvar ← mkFreshExprMVar goalType let (_, mvarId) ← mvar.mvarId!.intros @@ -1417,7 +1418,7 @@ def proveStep (goalType : Expr) (defNames : Array Name) : TermElabM Expr := do /-- Register LSP info for declarations introduced by `#decompose`: - Declaration ranges (for go-to-definition on introduced names) - Term info (for hover on identifiers in the command syntax) -/ -private def registerDecomposeInfo (cmdStx : Syntax) (eqId : Ident) (eqName : Name) +private meta def registerDecomposeInfo (cmdStx : Syntax) (eqId : Ident) (eqName : Name) (parsedClauses : Array (DecomposePattern × Name × Ident)) : TermElabM Unit := do -- Register the equation theorem Elab.addDeclarationRangesFromSyntax eqName cmdStx eqId @@ -1432,13 +1433,13 @@ private def registerDecomposeInfo (cmdStx : Syntax) (eqId : Ident) (eqName : Nam registered := registered.push auxName /-- Resolve the equation theorem name in the current namespace. -/ -private def resolveEqName (eqId : Ident) : TermElabM Name := do +private meta def resolveEqName (eqId : Ident) : TermElabM Name := do let ns ← getCurrNamespace let rawName := eqId.getId pure (if ns.isAnonymous then rawName else ns ++ rawName) /-- Decompose a non-recursive function using its definitional body directly. -/ -private def decomposeViaDef (fnName : Name) (levelParams : List Name) +private meta def decomposeViaDef (fnName : Name) (levelParams : List Name) (srcIsNoncomputable : Bool) (parsedClauses : Array (DecomposePattern × Name × Ident)) (cmdStx : Syntax) (eqId : Ident) : TermElabM Unit := do @@ -1488,7 +1489,7 @@ private def decomposeViaDef (fnName : Name) (levelParams : List Name) the raw definition body contains fixpoint combinator internals. Instead, we use the RHS of the `eq_def` theorem (the clean user-written body) as the expression to decompose, then chain `eq_def` with the decomposition proof. -/ -private def decomposeViaEqDef (fnName eqDefName : Name) (levelParams : List Name) +private meta def decomposeViaEqDef (fnName eqDefName : Name) (levelParams : List Name) (srcIsNoncomputable : Bool) (parsedClauses : Array (DecomposePattern × Name × Ident)) (cmdStx : Syntax) (eqId : Ident) : TermElabM Unit := do @@ -1541,7 +1542,7 @@ private def decomposeViaEqDef (fnName eqDefName : Name) (levelParams : List Name trace[Decompose] "#decompose: created {parsedClauses.size} definition(s) and theorem '{eqName}' (via {eqDefName})" @[command_elab decomposeCmd] -def elabDecompose : CommandElab := fun stx => do +meta def elabDecompose : CommandElab := fun stx => do match stx with | `(command| #decompose $fnId $eqId $[$clauses]*) => do liftTermElabM do From 3209d38c2d88d43de8a78a4cd4ee507d7e04d2d5 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 15:05:18 +0200 Subject: [PATCH 09/40] many more done --- backends/lean/Aeneas/Std/Core/Core.lean | 2 +- backends/lean/Aeneas/Std/Primitives.lean | 4 +- .../lean/Aeneas/Std/PrimitivesLemmas.lean | 4 +- backends/lean/Aeneas/Std/Scalar/Core.lean | 28 +++++----- .../lean/Aeneas/Std/Scalar/LeadingZeros.lean | 2 +- .../Aeneas/Std/Scalar/WrappingOps/Add.lean | 2 +- .../Aeneas/Std/Scalar/WrappingOps/Mul.lean | 2 +- .../Aeneas/Std/Scalar/WrappingOps/Sub.lean | 2 +- .../Aeneas/Tactic/Conv/Natify/Natify.lean | 8 +-- .../lean/Aeneas/Tactic/Step/InferPost.lean | 6 +-- backends/lean/Aeneas/Tactic/Step/Init.lean | 53 ++++++++++--------- 11 files changed, 60 insertions(+), 53 deletions(-) diff --git a/backends/lean/Aeneas/Std/Core/Core.lean b/backends/lean/Aeneas/Std/Core/Core.lean index 893f3b8be..72bfd5166 100644 --- a/backends/lean/Aeneas/Std/Core/Core.lean +++ b/backends/lean/Aeneas/Std/Core/Core.lean @@ -1,7 +1,7 @@ module public import Lean public import Aeneas.Std.Primitives -public import Aeneas.Tactic.Step.Init +public meta import Aeneas.Tactic.Step.Init public import Aeneas.Tactic.Elab.TraitDefault.Init public import Aeneas.Std.Alloc public section diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index 8dbe48a55..a63144885 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -104,7 +104,7 @@ def eval_global {α: Type u} (x: Result α) (_: ok? x := by prove_eval_global) : | fail _ | div => by contradiction | ok x => x -@[simp] +@[simp, expose] def Result.ofOption {a : Type u} (x : Option a) (e : Error) : Result a := match x with | some x => ok x @@ -270,7 +270,7 @@ attribute [simp, grind =] Function.uncurry_apply_pair which appear inside a `lift`. As only a specific set of functions from the standard library are purified (i.e., don't live in `Result`), this should not be a big issue in practice. -/ -def lift {α : Type u} (x : α) : Result α := Result.ok x +@[expose] def lift {α : Type u} (x : α) : Result α := Result.ok x /-! # Loops diff --git a/backends/lean/Aeneas/Std/PrimitivesLemmas.lean b/backends/lean/Aeneas/Std/PrimitivesLemmas.lean index 663e7f8e7..57343b047 100644 --- a/backends/lean/Aeneas/Std/PrimitivesLemmas.lean +++ b/backends/lean/Aeneas/Std/PrimitivesLemmas.lean @@ -1,7 +1,7 @@ module public import Aeneas.Std.Primitives -public import Aeneas.Tactic.Step.Init -public import Aeneas.Tactic.Conv.Bvify.Init +public meta import Aeneas.Tactic.Step.Init +public meta import Aeneas.Tactic.Conv.Bvify.Init public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/Core.lean b/backends/lean/Aeneas/Std/Scalar/Core.lean index 91cefac0e..ece17feb4 100644 --- a/backends/lean/Aeneas/Std/Scalar/Core.lean +++ b/backends/lean/Aeneas/Std/Scalar/Core.lean @@ -4,10 +4,10 @@ public import Lean.Meta.Tactic.Simp public import Aeneas.Std.Core.Core public import Aeneas.Tactic.Step.Init public import Aeneas.Tactic.Solver.ScalarTac.ScalarTac -public import Aeneas.Tactic.Conv.Bvify.Init +public meta import Aeneas.Tactic.Conv.Bvify.Init public import Aeneas.Data.Nat public import Aeneas.Data.Int -public import Aeneas.Tactic.Simp.SimpLists.Init +public meta import Aeneas.Tactic.Simp.SimpLists.Init public import AeneasMeta.BvEnumToBitVec public section @@ -47,7 +47,7 @@ inductive IScalarTy where | I128 deriving BvEnumToBitVec -@[implicit_reducible] +@[implicit_reducible, expose] def UScalarTy.numBits (ty : UScalarTy) : Nat := match ty with | Usize => System.Platform.numBits @@ -57,7 +57,7 @@ def UScalarTy.numBits (ty : UScalarTy) : Nat := | U64 => 64 | U128 => 128 -@[implicit_reducible] +@[implicit_reducible, expose] def IScalarTy.numBits (ty : IScalarTy) : Nat := match ty with | Isize => System.Platform.numBits @@ -73,7 +73,7 @@ structure UScalar (ty : UScalarTy) where bv : BitVec ty.numBits deriving Repr, BEq, DecidableEq -def UScalar.val {ty} (x : UScalar ty) : ℕ := x.bv.toNat +@[expose] def UScalar.val {ty} (x : UScalar ty) : ℕ := x.bv.toNat /-- Signed integer -/ structure IScalar (ty : IScalarTy) where @@ -81,7 +81,7 @@ structure IScalar (ty : IScalarTy) where bv : BitVec ty.numBits deriving Repr, BEq, DecidableEq -def IScalar.val {ty} (x : IScalar ty) : ℤ := x.bv.toInt +@[expose] def IScalar.val {ty} (x : IScalar ty) : ℤ := x.bv.toInt /-! # Bounds, Size @@ -92,6 +92,8 @@ complex expressions (for instance by trying to reduce an expression like `2^128` is extremely expensive). -/ +@[expose] section + irreducible_def UScalar.max (ty : UScalarTy) : Nat := 2^ty.numBits-1 irreducible_def IScalar.min (ty : IScalarTy) : Int := -2^(ty.numBits - 1) irreducible_def IScalar.max (ty : IScalarTy) : Int := 2^(ty.numBits - 1)-1 @@ -185,7 +187,9 @@ def I128.rMax : Int := 170141183460469231731687303715884105727 def Isize.rMin : Int := -2^(System.Platform.numBits - 1) def Isize.rMax : Int := 2^(System.Platform.numBits - 1)-1 -def UScalar.rMax (ty : UScalarTy) : Nat := +end + +@[expose] def UScalar.rMax (ty : UScalarTy) : Nat := match ty with | .Usize => Usize.rMax | .U8 => U8.rMax @@ -194,7 +198,7 @@ def UScalar.rMax (ty : UScalarTy) : Nat := | .U64 => U64.rMax | .U128 => U128.rMax -def IScalar.rMin (ty : IScalarTy) : Int := +@[expose] def IScalar.rMin (ty : IScalarTy) : Int := match ty with | .Isize => Isize.rMin | .I8 => I8.rMin @@ -203,7 +207,7 @@ def IScalar.rMin (ty : IScalarTy) : Int := | .I64 => I64.rMin | .I128 => I128.rMin -def IScalar.rMax (ty : IScalarTy) : Int := +@[expose] def IScalar.rMax (ty : IScalarTy) : Int := match ty with | .Isize => Isize.rMax | .I8 => I8.rMax @@ -365,17 +369,17 @@ theorem UScalarTy.cNumBits_nonzero (ty : UScalarTy) : ty.cNumBits ≠ 0 := by theorem IScalarTy.cNumBits_nonzero (ty : IScalarTy) : ty.cNumBits ≠ 0 := by cases ty <;> simp [cNumBits, I32.numBits] -def UScalar.cMax (ty : UScalarTy) : Nat := +@[expose] def UScalar.cMax (ty : UScalarTy) : Nat := match ty with | .Usize => UScalar.rMax .U32 | _ => UScalar.rMax ty -def IScalar.cMin (ty : IScalarTy) : Int := +@[expose] def IScalar.cMin (ty : IScalarTy) : Int := match ty with | .Isize => IScalar.rMin .I32 | _ => IScalar.rMin ty -def IScalar.cMax (ty : IScalarTy) : Int := +@[expose] def IScalar.cMax (ty : IScalarTy) : Int := match ty with | .Isize => IScalar.rMax .I32 | _ => IScalar.rMax ty diff --git a/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean b/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean index bcd61feca..be2d0fc42 100644 --- a/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean +++ b/backends/lean/Aeneas/Std/Scalar/LeadingZeros.lean @@ -1,7 +1,7 @@ module public import Aeneas.Std.Scalar.Core public import Aeneas.Std.Scalar.Elab -public import Mathlib.Data.Nat.Log +import all Mathlib.Data.Nat.Log public section namespace Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean index e685d1773..ed8113473 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Add.lean @@ -55,7 +55,7 @@ iscalar @[simp, bvify, grind =, agrind =] theorem core.num.«%S».wrapping_add_b @[simp] theorem UScalar.wrapping_add_val_eq {ty} (x y : UScalar ty) : (wrapping_add x y).val = (x.val + y.val) % (UScalar.size ty) := by - simp only [wrapping_add, val, size] + simp only [wrapping_add, val, size_def] have : 0 < 2^ty.numBits := by simp have : 2 ^ ty.numBits - 1 + 1 = 2^ty.numBits := by omega simp only [BitVec.toNat_add, bv_toNat] diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean index b74e8c4e8..fbd131794 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Mul.lean @@ -55,7 +55,7 @@ iscalar @[simp, bvify, grind =, agrind =] theorem core.num.«%S».wrapping_mul_b @[simp] theorem UScalar.wrapping_mul_val_eq {ty} (x y : UScalar ty) : (wrapping_mul x y).val = (x.val * y.val) % (UScalar.size ty) := by - simp only [wrapping_mul, val, size] + simp only [wrapping_mul, val, size_def] have : 0 < 2^ty.numBits := by simp have : 2 ^ ty.numBits - 1 + 1 = 2^ty.numBits := by omega simp only [BitVec.toNat_mul, bv_toNat] diff --git a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean index d946c0287..2e35ead4d 100644 --- a/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean +++ b/backends/lean/Aeneas/Std/Scalar/WrappingOps/Sub.lean @@ -55,7 +55,7 @@ iscalar @[simp, bvify, grind =, agrind =] theorem core.num.«%S».wrapping_sub_b @[simp] theorem UScalar.wrapping_sub_val_eq {ty} (x y : UScalar ty) : (wrapping_sub x y).val = (x.val + (UScalar.size ty - y.val)) % UScalar.size ty := by - simp only [wrapping_sub, val, size] + simp only [wrapping_sub, val, UScalar.size_def] have : 0 < 2^ty.numBits := by simp have : 2 ^ ty.numBits - 1 + 1 = 2^ty.numBits := by omega simp only [BitVec.toNat_sub, bv_toNat] diff --git a/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean b/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean index 03e1cbaf3..35437736c 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Natify/Natify.lean @@ -3,7 +3,7 @@ public import Mathlib.Tactic.Basic public import Mathlib.Tactic.Attr.Register public import Mathlib.Data.Int.Cast.Basic public import Mathlib.Order.Basic -public import Aeneas.Tactic.Conv.Natify.Init +public meta import Aeneas.Tactic.Conv.Natify.Init public import Aeneas.Tactic.Solver.Arith.Lemmas public import Aeneas.Std.Scalar.Core public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp @@ -40,7 +40,7 @@ syntax (name := natify) "natify" ("[" (term<|>"*"),* "]")? (location)? : tactic `simp_bool_prop`, and `push_cast` extensions programmatically. This avoids referencing the `natify` extension attribute by name in syntax quotations, which would collide with the `natify` tactic syntax in this namespace. -/ -private def mkNatifySimpArgs (userArgs : ScalarTac.CondSimpPartialArgs) : TacticM Simp.SimpArgs := do +private meta def mkNatifySimpArgs (userArgs : ScalarTac.CondSimpPartialArgs) : TacticM Simp.SimpArgs := do pure { simpThms := #[← natifySimpExt.getTheorems, ← SimpBoolProp.simpBoolPropSimpExt.getTheorems, @@ -52,7 +52,7 @@ private def mkNatifySimpArgs (userArgs : ScalarTac.CondSimpPartialArgs) : Tactic hypsToUse := userArgs.hypsToUse, } -def natifyTac (userArgs : ScalarTac.CondSimpPartialArgs) (loc : Utils.Location) : TacticM Unit := do +meta def natifyTac (userArgs : ScalarTac.CondSimpPartialArgs) (loc : Utils.Location) : TacticM Unit := do let args ← mkNatifySimpArgs userArgs let _ ← Simp.simpAt true { maxDischargeDepth := 1, decide := false } args loc @@ -64,7 +64,7 @@ elab_rules : tactic natifyTac userArgs loc /-- The `Simp.Context` generated by `natify`. -/ -def mkNatifyContext (userArgs : ScalarTac.CondSimpPartialArgs) : +meta def mkNatifyContext (userArgs : ScalarTac.CondSimpPartialArgs) : TacticM (Simp.Context × Simp.SimprocsArray) := do let args ← mkNatifySimpArgs userArgs Simp.mkSimpCtx true { maxDischargeDepth := 1, decide := false } .simp args diff --git a/backends/lean/Aeneas/Tactic/Step/InferPost.lean b/backends/lean/Aeneas/Tactic/Step/InferPost.lean index c5fe8b21b..3ce7ad736 100644 --- a/backends/lean/Aeneas/Tactic/Step/InferPost.lean +++ b/backends/lean/Aeneas/Tactic/Step/InferPost.lean @@ -1,10 +1,10 @@ module public import Lean public import AeneasMeta.Utils -public import AeneasMeta.Simp.Simp +public meta import AeneasMeta.Simp.Simp public import Mathlib.Tactic.Simproc.ExistsAndEq public import Aeneas.Tactic.Solver.Grind.Init -public import Aeneas.Tactic.Step.Init +public meta import Aeneas.Tactic.Step.Init public section namespace Aeneas @@ -18,7 +18,7 @@ open Lean Elab Meta Tactic TacticM `eliminate` controls which free variables to try clearing from the context before collecting escaping variables -/ -def inferPost (goal : MVarId) (eliminate : LocalDecl → Bool := fun _ => true) : +meta def inferPost (goal : MVarId) (eliminate : LocalDecl → Bool := fun _ => true) : TacticM MVarId := withTraceNode `Step (fun _ => do pure m!"inferPost") <| goal.withContext do traceGoalWithNode "metavariable context" let goalTy ← instantiateMVars (← goal.getType) diff --git a/backends/lean/Aeneas/Tactic/Step/Init.lean b/backends/lean/Aeneas/Tactic/Step/Init.lean index 44967a32b..a6cf3e864 100644 --- a/backends/lean/Aeneas/Tactic/Step/Init.lean +++ b/backends/lean/Aeneas/Tactic/Step/Init.lean @@ -208,7 +208,7 @@ section Methods Given type `α₀ × ... × αₙ`, introduce fresh variables `x₀ : α₀, ..., xₙ : αₙ` and call the continuation with those. -/ - def withFreshTupleFieldFVars [Inhabited a] (basename : Name) (ty : Expr) (k : Array Expr → m a) : m a := do + meta def withFreshTupleFieldFVars [Inhabited a] (basename : Name) (ty : Expr) (k : Array Expr → m a) : m a := do let tys := destProdsType ty let tys := List.map (fun (ty, i) => (Name.num basename i, fun _ => pure ty)) (List.zipIdx tys) withLocalDeclsD ⟨ tys ⟩ k @@ -221,7 +221,7 @@ end Methods ∀ x1 ... xn, H1 → ... Hn → spec (f x1 ... xn) P ``` -/ -def getStepSpecFunArgsExpr (ty : Expr) : +meta def getStepSpecFunArgsExpr (ty : Expr) : MetaM (Expr × SpecInfo) := do let ty := ty.consumeMData unless ← isProp ty do @@ -240,6 +240,8 @@ def getStepSpecFunArgsExpr (ty : Expr) : then pure (args[info.program_index]!, info) -- this is `f x1 ... xn` else throwError "Expected to be a `spec (f x1 ... xn) P`, got {ty₂}" +meta section + deriving instance Ord for Lean.Name structure Rules where /-- @@ -252,13 +254,14 @@ structure Rules where come out of scope) on the side -/ deactivated : Std.HashSet Name deriving Inhabited +end -def Rules.empty : Rules := ⟨ Std.TreeMap.empty, Std.HashSet.emptyWithCapacity ⟩ +meta def Rules.empty : Rules := ⟨ Std.TreeMap.empty, Std.HashSet.emptyWithCapacity ⟩ -def Extension := SimpleScopedEnvExtension ((Name × DiscrTreeKey) × Name) Rules +@[expose] def Extension := SimpleScopedEnvExtension ((Name × DiscrTreeKey) × Name) Rules deriving Inhabited -def Rules.insert (r : Rules) (kv : (Name × Array DiscrTree.Key) × Name) : Rules := +meta def Rules.insert (r : Rules) (kv : (Name × Array DiscrTree.Key) × Name) : Rules := let ((specName, prog), thm) := kv { rules := r.rules.insert specName ((match r.rules.get? specName with @@ -268,10 +271,10 @@ def Rules.insert (r : Rules) (kv : (Name × Array DiscrTree.Key) × Name) : Rule , deactivated := r.deactivated.erase kv.snd } -def Rules.erase (r : Rules) (k : Name) : Rules := +meta def Rules.erase (r : Rules) (k : Name) : Rules := { r with deactivated := r.deactivated.insert k } -def mkExtension (name : Name := by exact decl_name%) : +meta def mkExtension (name : Name := by exact decl_name%) : IO Extension := registerSimpleScopedEnvExtension { name := name, @@ -285,7 +288,7 @@ structure StepSpecAttr where ext : Extension deriving Inhabited -private def generateMvcgenSpec (toMvcgenThm : Name) (stx : Syntax) (attrKind : AttributeKind) +private meta def generateMvcgenSpec (toMvcgenThm : Name) (stx : Syntax) (attrKind : AttributeKind) (thDecl : AsyncConstantInfo) : MetaM Unit := do let sig := thDecl.sig.get let thName := thDecl.name @@ -311,7 +314,7 @@ private def generateMvcgenSpec (toMvcgenThm : Name) (stx : Syntax) (attrKind : A -- Register with @[spec] so mvcgen can find it Lean.Attribute.add mvcgenSpecName `spec .missing attrKind -private def saveStepSpecFromThm (ext : Extension) (attrKind : AttributeKind) (stx : Syntax) +private meta def saveStepSpecFromThm (ext : Extension) (attrKind : AttributeKind) (stx : Syntax) (thName : Name) : AttrM Unit := do -- Lookup the theorem let env ← getEnv @@ -344,7 +347,7 @@ private def saveStepSpecFromThm (ext : Extension) (attrKind : AttributeKind) (st pure () /- Initiliaze the `step` attribute. -/ -initialize stepAttr : StepSpecAttr ← do +meta initialize stepAttr : StepSpecAttr ← do let ext ← mkExtension `stepMap let attrImpl : AttributeImpl := { name := `step @@ -360,7 +363,7 @@ initialize stepAttr : StepSpecAttr ← do registerBuiltinAttribute attrImpl pure { attr := attrImpl, ext := ext } -def StepSpecAttr.find? (s : StepSpecAttr) (name : Name) (e : Expr) : MetaM (Array Name) := do +meta def StepSpecAttr.find? (s : StepSpecAttr) (name : Name) (e : Expr) : MetaM (Array Name) := do let env ← getEnv let state := s.ext.getState env let specState := specAttr.getState env @@ -371,10 +374,10 @@ def StepSpecAttr.find? (s : StepSpecAttr) (name : Name) (e : Expr) : MetaM (Arra let rules ← dtree.getMatch e pure (rules.filter (fun th => th ∉ state.deactivated)) -def StepSpecAttr.getState (s : StepSpecAttr) : MetaM Rules := do +meta def StepSpecAttr.getState (s : StepSpecAttr) : MetaM Rules := do pure (s.ext.getState (← getEnv)) -def showStoredStepThms : MetaM Unit := do +meta def showStoredStepThms : MetaM Unit := do let st ← stepAttr.getState -- TODO: how can we iterate over (at least) the values stored in the tree? --let s := st.toList.foldl (fun s (f, th) => f!"{s}\n{f} → {th}") f!"" @@ -447,7 +450,7 @@ theorem spec_lift {α : Type} (x : α) (P : α → Prop) (h : P x) : simp [Std.lift] apply h -def reduceProdProjs (e : Expr) : MetaM Expr := do +meta def reduceProdProjs (e : Expr) : MetaM Expr := do let pre (e : Expr) : MetaM TransformStep := do trace[Utils] "Attempting to reduce: {e}" match ← reduceProj? e with @@ -513,7 +516,7 @@ end Test Note that the pattern is optional: if the user doesn't provide it, we completely decompose -/ -def liftThmType (thmTy : Expr) (pat : Option Syntax) +meta def liftThmType (thmTy : Expr) (pat : Option Syntax) /- `mkPat` generates the pattern to use to guide the replacement. For instance: `∃ x y, foo a = (x, y)` @@ -582,13 +585,13 @@ def liftThmType (thmTy : Expr) (pat : Option Syntax) pure thmTy -def liftThmReplaceInTy (thm0 pat npat : Expr) (_ : Array Expr) : MetaM Expr := do +meta def liftThmReplaceInTy (thm0 pat npat : Expr) (_ : Array Expr) : MetaM Expr := do let thm ← mapVisit (fun _ e => do if e == pat then pure npat else pure e) thm0 /- Reduce a bit the expression, but in a controlled manner, to make it cleaner -/ let thm ← normalizeLetBindings thm reduceProdProjs thm -def liftThm (stx : Syntax) (name : Name) (pat : Option (TSyntax `term)) +meta def liftThm (stx : Syntax) (name : Name) (pat : Option (TSyntax `term)) (mkPat : Array Expr → Expr → MetaM Expr := fun _ _ => failure) (mkPred := liftThmReplaceInTy) (suffix : String := "step_spec") @@ -694,7 +697,7 @@ syntax (name := step_pure) "step_pure" term : attr section variable {m : Type → Type} [Monad m] [MonadOptions m] [MonadTrace m] [AddMessageContext m] [MonadError m] - partial def parseCommaSeparated (isTuple : Bool) (stx : Syntax) (acc : Array Syntax := #[]) : + meta partial def parseCommaSeparated (isTuple : Bool) (stx : Syntax) (acc : Array Syntax := #[]) : m (Array Syntax) := do trace[StepElab] "parsing comma separated: {stx} with acc: {acc}" -- TODO: check if ident @@ -750,7 +753,7 @@ section return the list of identifiers appearing inside the pattern. Remark: I tried implementing something simpler based on pattern matching but couldn't get it to work. -/ - partial def getStepPurePatternIdents (stx : Syntax) : m (Array Ident) := do + meta partial def getStepPurePatternIdents (stx : Syntax) : m (Array Ident) := do trace[StepElab] "syntax: {stx}" -- Check if this is an identifier match stx with @@ -807,7 +810,7 @@ end open Elab Term Attribute in /-- We desugar patterns of the shape `foo = (x, y, z)` to `∃ x y z, foo = (x, y, z)` in order to bind the variables introduced in the right-hand side, allowing us to elaborate the patterns. -/ -def elabStepPureAttribute (stx : Syntax) : AttrM (TSyntax `term) := +meta def elabStepPureAttribute (stx : Syntax) : AttrM (TSyntax `term) := withRef stx do match stx with | `(attr| step_pure $x = $pat) => do @@ -868,7 +871,7 @@ structure StepPureSpecAttr where If we don't put an equality in the pattern, `step_pure` will introduce one variable per field in the type of the pattern, if it is a tuple. -/ -initialize stepPureAttribute : StepPureSpecAttr ← do +meta initialize stepPureAttribute : StepPureSpecAttr ← do let attrImpl : AttributeImpl := { name := `step_pure descr := "Adds lifted version of pure theorems to the `step_pure` database" @@ -909,7 +912,7 @@ syntax (name := step_pure_def) "step_pure_def" (term)? : attr /-- We desugar patterns of the shape `foo = (x, y, z)` to `∃ x y z, foo = (x, y, z)` in order to bind the variables introduced in the right-hand side, allowing us to elaborate the patterns. -/ -def elabStepPureDefPattern (stx : Syntax) : AttrM (TSyntax `term) := +meta def elabStepPureDefPattern (stx : Syntax) : AttrM (TSyntax `term) := withRef stx do match stx with | `(term| $x = $pat) @@ -932,7 +935,7 @@ structure StepPureDefSpecAttr where theorem specLiftDef {α} (x : α) : Std.WP.spec (Std.lift x) (fun y => y = x) := by simp only [Std.lift, Std.WP.spec_ok] -def mkStepPureDefThm (stx : Syntax) (pat : Option (TSyntax `term)) (n : Name) +meta def mkStepPureDefThm (stx : Syntax) (pat : Option (TSyntax `term)) (n : Name) (suffix : String := "step_spec") : MetaM Name := do -- Regular case let mkPat (fvars : Array Expr) (ty : Expr) : MetaM Expr := do @@ -987,7 +990,7 @@ info: Aeneas.Step.Test.wrapping_add.step_spec (x y : U8) : Std.lift (wrapping_ad #check wrapping_add.step_spec end Test -def elabStepPureDefAttribute (stx : Syntax) : AttrM (Option (TSyntax `term)) := +meta def elabStepPureDefAttribute (stx : Syntax) : AttrM (Option (TSyntax `term)) := withRef stx do match stx with | `(attr| step_pure_def $x = $pat) @@ -1008,7 +1011,7 @@ def elabStepPureDefAttribute (stx : Syntax) : AttrM (Option (TSyntax `term)) := /- The `step_pure_def` attribute, which automatically generates step lemmas for pure definitions. -/ -initialize stepPureDefAttribute : StepPureDefSpecAttr ← do +meta initialize stepPureDefAttribute : StepPureDefSpecAttr ← do let attrImpl : AttributeImpl := { name := `step_pure_def descr := "Automatically generate `step` theorems for pure definitions" From 40d9f182cfb0c784db0017b6060f24003d6adb50 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 15:41:41 +0200 Subject: [PATCH 10/40] and more --- .../lean/Aeneas/Data/Range/SRRange/Basic.lean | 10 +++++----- backends/lean/Aeneas/Std/Array/Core.lean | 2 +- backends/lean/Aeneas/Std/Core/Cmp.lean | 4 ++-- backends/lean/Aeneas/Std/Scalar/Core.lean | 4 ++-- .../lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean | 15 ++++++++------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean b/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean index 1ee48d0a0..c07648769 100644 --- a/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean +++ b/backends/lean/Aeneas/Data/Range/SRRange/Basic.lean @@ -31,12 +31,12 @@ namespace SRRange universe u v /-- The number of elements in the range. -/ -@[simp] def size (r : SRRange) : Nat := (r.stop - r.start + r.step - 1) / r.step +@[simp, expose] def size (r : SRRange) : Nat := (r.stop - r.start + r.step - 1) / r.step /-- A bound of the number of elements in the range -/ -@[simp] def sizeBound (r : SRRange) : Nat := r.stop - r.start +@[simp, expose] def sizeBound (r : SRRange) : Nat := r.stop - r.start -@[inline] protected def forIn' [Monad m] (range : SRRange) (init : β) +@[inline, expose] protected def forIn' [Monad m] (range : SRRange) (init : β) (f : (i : Nat) → i ∈ range → β → m (ForInStep β)) : m β := let rec @[specialize] loop (maxSteps : Nat) (b : β) (i : Nat) (hs : (i - range.start) % range.step = 0) (hl : range.start ≤ i := by omega) : m β := do @@ -61,7 +61,7 @@ instance {m} [Monad m] : ForIn' m SRRange Nat inferInstance where -- No separate `ForIn` instance is required because it can be derived from `ForIn'`. /-- A convenient utility for the proofs, which uses well-founded recursion -/ -def foldWhile' {α : Type u} (r : SRRange) (f : α → (a : Nat) → (a ∈ r) → α) (i : Nat) (init : α) +@[expose] def foldWhile' {α : Type u} (r : SRRange) (f : α → (a : Nat) → (a ∈ r) → α) (i : Nat) (init : α) (hi : r.start ≤ i ∧ (i - r.start) % r.step = 0) : α := if h: i < r.stop then foldWhile' r f (i + r.step) @@ -76,7 +76,7 @@ termination_by r.stop - i decreasing_by have:= r.step_pos; omega /-- A convenient utility for the proofs, which uses well-founded recursion -/ -def foldWhile {α : Type u} (max step : Nat) (hStep : 0 < step) (f : α → Nat → α) (i : Nat) (init : α) : α := +@[expose] def foldWhile {α : Type u} (max step : Nat) (hStep : 0 < step) (f : α → Nat → α) (i : Nat) (init : α) : α := if i < max then foldWhile max step hStep f (i + step) (f init i) else init termination_by max - i diff --git a/backends/lean/Aeneas/Std/Array/Core.lean b/backends/lean/Aeneas/Std/Array/Core.lean index e11490489..09b55a8c1 100644 --- a/backends/lean/Aeneas/Std/Array/Core.lean +++ b/backends/lean/Aeneas/Std/Array/Core.lean @@ -35,7 +35,7 @@ theorem List.mapM_clone_eq {T : Type u} {clone : T → Result T} {l : List T} apply hind apply h -def List.clone (clone : α → Result α) (l : List α) : Result ({ l' : List α // l'.length = l.length}) := +@[expose] def List.clone (clone : α → Result α) (l : List α) : Result ({ l' : List α // l'.length = l.length}) := match h :List.mapM clone l with | ok v => ok ⟨ v, by have := List.mapM_Result_length h; scalar_tac ⟩ | fail e => fail e diff --git a/backends/lean/Aeneas/Std/Core/Cmp.lean b/backends/lean/Aeneas/Std/Core/Cmp.lean index 13ee214b1..591a4b383 100644 --- a/backends/lean/Aeneas/Std/Core/Cmp.lean +++ b/backends/lean/Aeneas/Std/Core/Cmp.lean @@ -130,7 +130,7 @@ def core.cmp.Ord.max_body {Self : Type} (lt : Self → Self → Result Bool) (x y : Self) : Result Self := do if ← lt x y then ok y else ok x -def core.cmp.Ord.min_body {Self : Type} (lt : Self → Self → Result Bool) +@[expose] def core.cmp.Ord.min_body {Self : Type} (lt : Self → Self → Result Bool) (x y : Self) : Result Self := do if ← lt x y then ok x else ok y @@ -159,7 +159,7 @@ def core.cmp.Ord.max.default {Self : Type} (lt : Self → Self → Result Bool) (x y : Self) : Result Self := core.cmp.Ord.max_body lt x y -def core.cmp.Ord.min.default {Self : Type} (lt : Self → Self → Result Bool) +@[expose] def core.cmp.Ord.min.default {Self : Type} (lt : Self → Self → Result Bool) (x y : Self) : Result Self := core.cmp.Ord.min_body lt x y diff --git a/backends/lean/Aeneas/Std/Scalar/Core.lean b/backends/lean/Aeneas/Std/Scalar/Core.lean index ece17feb4..f10691cb4 100644 --- a/backends/lean/Aeneas/Std/Scalar/Core.lean +++ b/backends/lean/Aeneas/Std/Scalar/Core.lean @@ -511,10 +511,10 @@ theorem IScalar.bound_suffices (ty : IScalarTy) (x : Int) : have := cMax_le_rMax ty omega -def UScalar.ofNatCore {ty : UScalarTy} (x : Nat) (h : x < 2^ty.numBits) : UScalar ty := +@[expose] def UScalar.ofNatCore {ty : UScalarTy} (x : Nat) (h : x < 2^ty.numBits) : UScalar ty := { bv := ⟨ x, h ⟩ } -def IScalar.ofIntCore {ty : IScalarTy} (x : Int) (_ : -2^(ty.numBits-1) ≤ x ∧ x < 2^(ty.numBits - 1)) : IScalar ty := +@[expose] def IScalar.ofIntCore {ty : IScalarTy} (x : Int) (_ : -2^(ty.numBits-1) ≤ x ∧ x < 2^(ty.numBits - 1)) : IScalar ty := -- TODO: we should leave `x` unchanged if it is positive, so that expressions like `(1#isize).val` can reduce to `1` let x' := (x % 2^ty.numBits).toNat have h : x' < 2^ty.numBits := by diff --git a/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean b/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean index c0351fda1..9d344d2b7 100644 --- a/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/ZModify/ZModify.lean @@ -3,10 +3,10 @@ public import Mathlib.Tactic.Basic public import Mathlib.Tactic.Attr.Register public import Mathlib.Data.Int.Cast.Basic public import Mathlib.Order.Basic -public import Aeneas.Tactic.Conv.ZModify.Init +public meta import Aeneas.Tactic.Conv.ZModify.Init public import Aeneas.Tactic.Solver.Arith.Lemmas public import Aeneas.Std.Scalar.Core -public import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac +public meta import Aeneas.Tactic.Solver.ScalarTac.CondSimpTac public import Aeneas.Tactic.Simp.SimpBoolProp.SimpBoolProp public section @@ -29,7 +29,9 @@ structure Config where nonLin : Bool := true -- We use the non linear lemmas by default saturationPasses := 3 +meta section declare_config_elab elabConfig Config +end attribute [zmodify] ge_iff_le gt_iff_lt Nat.mod_lt_of_lt @@ -44,7 +46,7 @@ attribute [zmodify] Nat.mod_lt /-- `n` is the parameter of `ZMod`, in case it is not obvious from the context. In particular, if the user provides `n`, it activates the use of conditional rewritings by means of `scalar_tac`. -/ -def zmodifyTac (config : Config) +meta def zmodifyTac (config : Config) (n : Option Expr) (args : ScalarTac.CondSimpPartialArgs) (loc : Utils.Location) : TacticM Unit := do let addSimpThms : TacticM (Array FVarId) := do match n with @@ -87,7 +89,7 @@ or by passing them directly as arguments to the tactic, e.g., `zmodify [my_lemma -/ syntax (name := zmodify) "zmodify" Parser.Tactic.optConfig ("to" term)? ("[" (term<|>"*"),* "]")? (location)? : tactic -def parseZModify : +meta def parseZModify : TSyntax ``zmodify -> TacticM (Config × Option Expr × ScalarTac.CondSimpPartialArgs × Utils.Location) | `(tactic| zmodify $config $[to $n]? $[[$args,*]]? $[$loc:location]?) => do let config ← elabConfig config @@ -104,11 +106,10 @@ elab stx:zmodify : tactic => zmodifyTac config n args loc attribute [zmodify] Nat.eq_mod_iff_eq_ZMod Int.eq_mod_iff_eq_ZMod div_to_ZMod -attribute [zmodify] Nat.reduceGcd - +dsimproc [zmodify] Nat.reduceGcd' (Nat.gcd _ _) := Nat.reduceGcd attribute [zmodify] ZMod.natCast_val ZMod.natCast_mod ZMod.cast_id' ZMod.intCast_mod id_eq attribute [zmodify] Int.cast_add Int.cast_natCast Int.cast_mul -attribute [zmodify] Int.reduceNeg +dsimproc [zmodify] Int.reduceNeg' ((- _ : Int)) := Int.reduceNeg @[zmodify] theorem Nat.eq_mod_zero_iff_eq_ZMod (n : ℕ) (a : Nat) : a % n = 0 ↔ (a : ZMod n) = 0 := by From b96f432c80d0852fce666bc034c44bf0fb46dd8c Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 16:43:00 +0200 Subject: [PATCH 11/40] more --- backends/lean/Aeneas/Std/Array/Array.lean | 2 +- backends/lean/Aeneas/Std/Core/Cmp.lean | 2 +- backends/lean/Aeneas/Std/Scalar/Casts.lean | 2 +- backends/lean/Aeneas/Std/Scalar/Core.lean | 4 ++-- backends/lean/Aeneas/Std/SliceDef.lean | 2 +- .../Aeneas/Tactic/Solver/ScalarDecrTac.lean | 6 ++--- .../lean/Aeneas/Tactic/Step/GrindState.lean | 22 +++++++++---------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/backends/lean/Aeneas/Std/Array/Array.lean b/backends/lean/Aeneas/Std/Array/Array.lean index 9aeeacb9a..360ca2320 100644 --- a/backends/lean/Aeneas/Std/Array/Array.lean +++ b/backends/lean/Aeneas/Std/Array/Array.lean @@ -17,7 +17,7 @@ local macro_rules # Array -/ -def Array (α : Type u) (n : Usize) := { l : List α // l.length = n.val } +@[expose] def Array (α : Type u) (n : Usize) := { l : List α // l.length = n.val } /-- We need this to coerce arrays to lists without marking `Array` as reducible. Also not that we *do not* want to mark `Array` as reducible: it triggers issues. diff --git a/backends/lean/Aeneas/Std/Core/Cmp.lean b/backends/lean/Aeneas/Std/Core/Cmp.lean index 591a4b383..23e2dccee 100644 --- a/backends/lean/Aeneas/Std/Core/Cmp.lean +++ b/backends/lean/Aeneas/Std/Core/Cmp.lean @@ -163,7 +163,7 @@ def core.cmp.Ord.max.default {Self : Type} (lt : Self → Self → Result Bool) (x y : Self) : Result Self := core.cmp.Ord.min_body lt x y -@[trait_default, rust_fun "core::cmp::Ord::min"] +@[expose, trait_default, rust_fun "core::cmp::Ord::min"] def core.cmp.Ord.min.trait_default {Self : Type} (OrdInst : core.cmp.Ord Self) (x y : Self) : Result Self := core.cmp.Ord.min.default OrdInst.partialOrdInst.lt x y diff --git a/backends/lean/Aeneas/Std/Scalar/Casts.lean b/backends/lean/Aeneas/Std/Scalar/Casts.lean index 24465432a..c06aed110 100644 --- a/backends/lean/Aeneas/Std/Scalar/Casts.lean +++ b/backends/lean/Aeneas/Std/Scalar/Casts.lean @@ -1,5 +1,5 @@ module -public import Aeneas.Std.Scalar.Core +public meta import Aeneas.Std.Scalar.Core public import Aeneas.Tactic.Solver.ScalarTac public import Mathlib.Data.BitVec public section diff --git a/backends/lean/Aeneas/Std/Scalar/Core.lean b/backends/lean/Aeneas/Std/Scalar/Core.lean index f10691cb4..3b9d498e8 100644 --- a/backends/lean/Aeneas/Std/Scalar/Core.lean +++ b/backends/lean/Aeneas/Std/Scalar/Core.lean @@ -523,11 +523,11 @@ theorem IScalar.bound_suffices (ty : IScalarTy) (x : Int) : apply Int.emod_lt_of_pos; simp { bv := ⟨ x', h ⟩ } -@[reducible] def UScalar.ofNat {ty : UScalarTy} (x : Nat) +@[reducible, expose] def UScalar.ofNat {ty : UScalarTy} (x : Nat) (hInBounds : x ≤ UScalar.cMax ty := by decide) : UScalar ty := UScalar.ofNatCore x (UScalar.bound_suffices ty x hInBounds) -@[reducible] def IScalar.ofInt {ty : IScalarTy} (x : Int) +@[reducible, expose] def IScalar.ofInt {ty : IScalarTy} (x : Int) (hInBounds : IScalar.cMin ty ≤ x ∧ x ≤ IScalar.cMax ty := by decide) : IScalar ty := IScalar.ofIntCore x (IScalar.bound_suffices ty x hInBounds) diff --git a/backends/lean/Aeneas/Std/SliceDef.lean b/backends/lean/Aeneas/Std/SliceDef.lean index 4b1e80224..5c2f8566d 100644 --- a/backends/lean/Aeneas/Std/SliceDef.lean +++ b/backends/lean/Aeneas/Std/SliceDef.lean @@ -4,6 +4,6 @@ public section namespace Aeneas.Std -def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max } +@[expose] def Slice (α : Type u) := { l : List α // l.length ≤ Usize.max } end Aeneas.Std diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean index fb61669b3..b1bf7c079 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarDecrTac.lean @@ -20,7 +20,7 @@ open Lean Lean.Elab Command Term Lean.Meta Tactic proofs, and if we simplify those assumptions they tend to trigger extremely expensive reductions. -/ -def removeInvImageAssumptions : TacticM Unit := do +meta def removeInvImageAssumptions : TacticM Unit := do withMainContext do -- Get the local declarations let ctx ← Lean.MonadLCtx.getLCtx @@ -50,7 +50,7 @@ elab "decreasing_by_preprocess" : tactic => elab "remove_invImage_assumptions" : tactic => removeInvImageAssumptions -def clearUnusedDeclsOnePass : TacticM Unit := do +meta def clearUnusedDeclsOnePass : TacticM Unit := do withMainContext do let lctx ← getLCtx let decls ← lctx.getDecls @@ -68,7 +68,7 @@ elab "clear_unused_decls_one_pass" : tactic => clearUnusedDeclsOnePass /- We clear from the end to the beginning -/ -def clearRedundantHyps : TacticM Unit := do +meta def clearRedundantHyps : TacticM Unit := do withTraceNode `ScalarTac (fun _ => pure m!"clearRedundantHyps") do withMainContext do let lctx ← getLCtx diff --git a/backends/lean/Aeneas/Tactic/Step/GrindState.lean b/backends/lean/Aeneas/Tactic/Step/GrindState.lean index ecca764da..657d4cdd8 100644 --- a/backends/lean/Aeneas/Tactic/Step/GrindState.lean +++ b/backends/lean/Aeneas/Tactic/Step/GrindState.lean @@ -61,7 +61,7 @@ open Lean.Meta.Grind (GrindM GoalM Goal GoalState) We set `clean := false` and `revert := false` to prevent `mkGoalCore` from mutating the proof goal's MVarId (via `exposeNames` / `revertAll`). Our use of grind is purely for building a knowledge base, not for solving the goal directly. -/ -private def mkGrindParams (config : Config) : MetaM Grind.Params := do +private meta def mkGrindParams (config : Config) : MetaM Grind.Params := do let grindConfig := { config.toGrindConfig with clean := false, revert := false } Aeneas.Grind.mkParams grindConfig (← Aeneas.Grind.getAgrindExtensions config.nla) config.withGroundSimprocs @@ -74,7 +74,7 @@ private def mkGrindParams (config : Config) : MetaM Grind.Params := do so that internalized hypotheses are normalized identically to how `threadedGrindTac` and `evalAGrindWithPreprocess` normalize them before calling grind. Using a different simpset (e.g., the full `@[simp]` set) would cause form mismatches in the e-graph. -/ -private def mkPreprocessSimpCtx : MetaM (Simp.Context × Simp.SimprocsArray) := do +private meta def mkPreprocessSimpCtx : MetaM (Simp.Context × Simp.SimprocsArray) := do let simpArgs ← ScalarTac.getSimpArgs let congrTheorems ← getSimpCongrTheorems let ctx ← Simp.mkContext @@ -85,7 +85,7 @@ private def mkPreprocessSimpCtx : MetaM (Simp.Context × Simp.SimprocsArray) := /-- Run a `GrindM` action with a fresh monad stack (via `GrindM.run`). Used for initialization — reads out all contexts and states for subsequent reuse. -/ -def runGrindFresh {α} (params : Grind.Params) +meta def runGrindFresh {α} (params : Grind.Params) (action : GrindM α) : MetaM (α × Grind.State × Lean.Meta.Sym.State × Lean.Meta.Sym.Context × Grind.Context × Grind.MethodsRef) := Grind.GrindM.run (params := params) do let result ← action @@ -99,7 +99,7 @@ def runGrindFresh {α} (params : Grind.Params) /-- Run a `GrindM` action reusing saved contexts and states from a previous run. Preserves pointer identity of all contexts (`Sym.Context`, `Grind.Context`, `MethodsRef`) to avoid PANICs in the e-graph's proof reconstruction. -/ -def runGrindWithState {α} (state : StepGrindState) (action : GrindM α) +meta def runGrindWithState {α} (state : StepGrindState) (action : GrindM α) : MetaM (α × Grind.State × Lean.Meta.Sym.State) := do let wrappedAction : GrindM (α × Grind.State × Lean.Meta.Sym.State) := do let result ← action @@ -146,7 +146,7 @@ def runGrindWithState {α} (state : StepGrindState) (action : GrindM α) 2. Simplify with Aeneas simpsets and, if the simplified type differs, internalize the simplified fact too. 3. Optionally run the preprocessing loop (`assertAll >> solvers.loop`). -/ -private def internalizeHypotheses (goal : Goal) (config : Config) +private meta def internalizeHypotheses (goal : Goal) (config : Config) (simpCtx : Simp.Context) (simprocs : Simp.SimprocsArray) : GrindM (Goal × Bool) := do -- Build the preprocessing action (solvers + instantiate) once @@ -249,7 +249,7 @@ private def internalizeHypotheses (goal : Goal) (config : Config) The grind state (`Grind.State`, `Sym.State`, `GoalState`) is extracted as return values before `withNewMCtxDepth` restores the old mctx, so it persists across calls. -/ -private def withProtectedGrind {α} (mvarId : MVarId) +private meta def withProtectedGrind {α} (mvarId : MVarId) (action : MVarId → MetaM (α × Bool)) : MetaM (α × Bool × Option Expr) := withNewMCtxDepth (allowLevelAssignments := true) do @@ -265,7 +265,7 @@ private def withProtectedGrind {α} (mvarId : MVarId) pure (result, contradiction, contradictionProof?) /-- Close a goal using a proof of `False`. -/ -def closeGoalWithFalse (mvarId : MVarId) (falseProof : Expr) : MetaM Unit := do +meta def closeGoalWithFalse (mvarId : MVarId) (falseProof : Expr) : MetaM Unit := do let target ← mvarId.getType let level ← getLevel target mvarId.assign (mkApp (mkApp (mkConst ``False.elim [level]) target) falseProof) @@ -273,7 +273,7 @@ def closeGoalWithFalse (mvarId : MVarId) (falseProof : Expr) : MetaM Unit := do /-- Initialize the grind state from the current proof context. Creates a fresh `GoalState` and internalizes all current local hypotheses. Runs inside `withProtectedGrind` (see its docstring for the protection rationale). -/ -def initStepGrindState (config : Config) (mvarId : MVarId) : MetaM StepGrindState := do +meta def initStepGrindState (config : Config) (mvarId : MVarId) : MetaM StepGrindState := do let params ← mkGrindParams config let (simpCtx, simprocs) ← mkPreprocessSimpCtx let ((goalState, grindState, symState, symCtx, grindCtx, methodsRef), contradiction, contradictionProof?) ← @@ -289,7 +289,7 @@ def initStepGrindState (config : Config) (mvarId : MVarId) : MetaM StepGrindStat /-- Update the grind state after new fvars have been introduced (by `introOutputs` or case splits). Only processes fvars with index ≥ `nextDeclIdx` (incremental). Runs inside `withProtectedGrind` (see its docstring for the protection rationale). -/ -def updateStepGrindState (state : StepGrindState) (config : Config) (mvarId : MVarId) +meta def updateStepGrindState (state : StepGrindState) (config : Config) (mvarId : MVarId) : MetaM StepGrindState := do let ((goalState, grindState, symState), contradiction, contradictionProof?) ← withProtectedGrind mvarId fun freshMVarId => do @@ -325,7 +325,7 @@ def updateStepGrindState (state : StepGrindState) (config : Config) (mvarId : MV Returns `true` if the precondition was solved, `false` otherwise. On failure, all MetaM state changes are reverted (via `observing?`). -/ -def dischargeWithGrindState (state : StepGrindState) (config : Config) +meta def dischargeWithGrindState (state : StepGrindState) (config : Config) (precondMVarId : MVarId) : MetaM Bool := do let result ← observing? do /- First, internalize any fvars the e-graph hasn't seen yet. -/ @@ -356,7 +356,7 @@ def dischargeWithGrindState (state : StepGrindState) (config : Config) /-- Update the step state by internalizing new hypotheses from the given goal. No-op if grind state threading is disabled (`grindState? = none`). -/ -def StepState.update (state : StepState) (config : Config) (mvarId : MVarId) : MetaM StepState := +meta def StepState.update (state : StepState) (config : Config) (mvarId : MVarId) : MetaM StepState := match state.grindState? with | some gs => do let gs' ← updateStepGrindState gs config mvarId From 6947f59b4f165aa153b478fc8d60674db645ec28 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 16:55:46 +0200 Subject: [PATCH 12/40] more --- backends/lean/Aeneas/Std/Primitives.lean | 2 +- backends/lean/Aeneas/Std/Scalar/Core.lean | 8 +++---- .../lean/Aeneas/Std/Scalar/Notations.lean | 24 +++++++++---------- backends/lean/Aeneas/Std/Scalar/Ops/Div.lean | 4 ++-- backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index a63144885..566786e23 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -307,7 +307,7 @@ instance SubtypeLawfulBEq [BEq α] (p : α → Prop) [LawfulBEq α] : LawfulBEq /- A helper function that converts failure to none and success to some TODO: move up to Core module? -/ -def Option.ofResult {a : Type u} (x : Result a) : +@[expose] def Option.ofResult {a : Type u} (x : Result a) : Option a := match x with | ok x => some x diff --git a/backends/lean/Aeneas/Std/Scalar/Core.lean b/backends/lean/Aeneas/Std/Scalar/Core.lean index 3b9d498e8..3978a143c 100644 --- a/backends/lean/Aeneas/Std/Scalar/Core.lean +++ b/backends/lean/Aeneas/Std/Scalar/Core.lean @@ -593,20 +593,20 @@ theorem IScalar.check_bounds_eq_inBounds (ty : IScalarTy) (x : Int) : . apply (check_bounds_imp_inBounds h) . simp_all -def UScalar.tryMkOpt (ty : UScalarTy) (x : Nat) : Option (UScalar ty) := +@[expose] def UScalar.tryMkOpt (ty : UScalarTy) (x : Nat) : Option (UScalar ty) := if h:UScalar.check_bounds ty x then some (UScalar.ofNatCore x (UScalar.check_bounds_imp_inBounds h)) else none -def UScalar.tryMk (ty : UScalarTy) (x : Nat) : Result (UScalar ty) := +@[expose] def UScalar.tryMk (ty : UScalarTy) (x : Nat) : Result (UScalar ty) := Result.ofOption (tryMkOpt ty x) integerOverflow -def IScalar.tryMkOpt (ty : IScalarTy) (x : Int) : Option (IScalar ty) := +@[expose] def IScalar.tryMkOpt (ty : IScalarTy) (x : Int) : Option (IScalar ty) := if h:IScalar.check_bounds ty x then some (IScalar.ofIntCore x (IScalar.check_bounds_imp_inBounds h)) else none -def IScalar.tryMk (ty : IScalarTy) (x : Int) : Result (IScalar ty) := +@[expose] def IScalar.tryMk (ty : IScalarTy) (x : Int) : Result (IScalar ty) := Result.ofOption (tryMkOpt ty x) integerOverflow theorem UScalar.tryMkOpt_eq (ty : UScalarTy) (x : Nat) : diff --git a/backends/lean/Aeneas/Std/Scalar/Notations.lean b/backends/lean/Aeneas/Std/Scalar/Notations.lean index 30d0ffb83..f0d0d152d 100644 --- a/backends/lean/Aeneas/Std/Scalar/Notations.lean +++ b/backends/lean/Aeneas/Std/Scalar/Notations.lean @@ -37,40 +37,40 @@ macro:max x:term:max noWs "#isize" : term => `(Isize.ofInt $x (by first | decide -- Some pretty printing (for the goals) @[app_unexpander U8.ofNat] -def unexpU8ofNat : Unexpander | `($_ $n $_) => `($n#u8) | _ => throw () +meta def unexpU8ofNat : Unexpander | `($_ $n $_) => `($n#u8) | _ => throw () @[app_unexpander U16.ofNat] -def unexpU16ofNat : Unexpander | `($_ $n $_) => `($n#u16) | _ => throw () +meta def unexpU16ofNat : Unexpander | `($_ $n $_) => `($n#u16) | _ => throw () @[app_unexpander U32.ofNat] -def unexpU32ofNat : Unexpander | `($_ $n $_) => `($n#u32) | _ => throw () +meta def unexpU32ofNat : Unexpander | `($_ $n $_) => `($n#u32) | _ => throw () @[app_unexpander U64.ofNat] -def unexpU64ofNat : Unexpander | `($_ $n $_) => `($n#u64) | _ => throw () +meta def unexpU64ofNat : Unexpander | `($_ $n $_) => `($n#u64) | _ => throw () @[app_unexpander U128.ofNat] -def unexpU128ofNat : Unexpander | `($_ $n $_) => `($n#u128) | _ => throw () +meta def unexpU128ofNat : Unexpander | `($_ $n $_) => `($n#u128) | _ => throw () @[app_unexpander Usize.ofNat] -def unexpUsizeofNat : Unexpander | `($_ $n $_) => `($n#usize) | _ => throw () +meta def unexpUsizeofNat : Unexpander | `($_ $n $_) => `($n#usize) | _ => throw () @[app_unexpander I8.ofInt] -def unexpI8ofInt : Unexpander | `($_ $n $_) => `($n#i8) | _ => throw () +meta def unexpI8ofInt : Unexpander | `($_ $n $_) => `($n#i8) | _ => throw () @[app_unexpander I16.ofInt] -def unexpI16ofInt : Unexpander | `($_ $n $_) => `($n#i16) | _ => throw () +meta def unexpI16ofInt : Unexpander | `($_ $n $_) => `($n#i16) | _ => throw () @[app_unexpander I32.ofInt] -def unexpI32ofInt : Unexpander | `($_ $n $_) => `($n#i32) | _ => throw () +meta def unexpI32ofInt : Unexpander | `($_ $n $_) => `($n#i32) | _ => throw () @[app_unexpander I64.ofInt] -def unexpI64ofInt : Unexpander | `($_ $n $_) => `($n#i64) | _ => throw () +meta def unexpI64ofInt : Unexpander | `($_ $n $_) => `($n#i64) | _ => throw () @[app_unexpander I128.ofInt] -def unexpI128ofInt : Unexpander | `($_ $n $_) => `($n#i128) | _ => throw () +meta def unexpI128ofInt : Unexpander | `($_ $n $_) => `($n#i128) | _ => throw () @[app_unexpander Isize.ofInt] -def unexpIsizeofInt : Unexpander | `($_ $n $_) => `($n#isize) | _ => throw () +meta def unexpIsizeofInt : Unexpander | `($_ $n $_) => `($n#isize) | _ => throw () -- Notation for pattern matching -- We make the precedence looser than the negation. diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean index 28da617c5..7a99c7e89 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Div.lean @@ -14,10 +14,10 @@ open Result Error Arith ScalarElab WP # Division: Definitions -/ -def UScalar.div {ty : UScalarTy} (x y : UScalar ty) : Result (UScalar ty) := +@[expose] def UScalar.div {ty : UScalarTy} (x y : UScalar ty) : Result (UScalar ty) := if y.bv != 0 then ok ⟨ BitVec.udiv x.bv y.bv ⟩ else fail divisionByZero -def IScalar.div {ty : IScalarTy} (x y : IScalar ty): Result (IScalar ty) := +@[expose] def IScalar.div {ty : IScalarTy} (x y : IScalar ty): Result (IScalar ty) := if y.val != 0 then -- There can be an overflow if `x` is equal to the lower bound and `y` to `-1` if ¬ (x.val = IScalar.min ty && y.val = -1) then ok ⟨ BitVec.sdiv x.bv y.bv ⟩ diff --git a/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean b/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean index 5ccb7ef08..095b46f5d 100644 --- a/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean +++ b/backends/lean/Aeneas/Std/Scalar/Ops/Rem.lean @@ -13,10 +13,10 @@ open Result Error Arith ScalarElab WP /-! # Remainder: Definitions -/ -def UScalar.rem {ty : UScalarTy} (x y : UScalar ty) : Result (UScalar ty) := +@[expose] def UScalar.rem {ty : UScalarTy} (x y : UScalar ty) : Result (UScalar ty) := if y.val != 0 then ok ⟨ BitVec.umod x.bv y.bv ⟩ else fail divisionByZero -def IScalar.rem {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) := +@[expose] def IScalar.rem {ty : IScalarTy} (x y : IScalar ty) : Result (IScalar ty) := if y.val != 0 then ok ⟨ BitVec.srem x.bv y.bv ⟩ else fail divisionByZero From ba87731f3c9b3311b63b9c4be14edad7640a3151 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 17:09:30 +0200 Subject: [PATCH 13/40] grind --- backends/lean/Aeneas/Std/Scalar/Core.lean | 24 +++++++++---------- .../lean/Aeneas/Tactic/Step/GrindState.lean | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/backends/lean/Aeneas/Std/Scalar/Core.lean b/backends/lean/Aeneas/Std/Scalar/Core.lean index 3978a143c..64f4da3d6 100644 --- a/backends/lean/Aeneas/Std/Scalar/Core.lean +++ b/backends/lean/Aeneas/Std/Scalar/Core.lean @@ -672,20 +672,20 @@ abbrev I128 := IScalar .I128 /-! ofNatCore -/ -- TODO: typeclass? -def Usize.ofNatCore := @UScalar.ofNatCore .Usize -def U8.ofNatCore := @UScalar.ofNatCore .U8 -def U16.ofNatCore := @UScalar.ofNatCore .U16 -def U32.ofNatCore := @UScalar.ofNatCore .U32 -def U64.ofNatCore := @UScalar.ofNatCore .U64 -def U128.ofNatCore := @UScalar.ofNatCore .U128 +@[expose] def Usize.ofNatCore := @UScalar.ofNatCore .Usize +@[expose] def U8.ofNatCore := @UScalar.ofNatCore .U8 +@[expose] def U16.ofNatCore := @UScalar.ofNatCore .U16 +@[expose] def U32.ofNatCore := @UScalar.ofNatCore .U32 +@[expose] def U64.ofNatCore := @UScalar.ofNatCore .U64 +@[expose] def U128.ofNatCore := @UScalar.ofNatCore .U128 /-! ofIntCore -/ -def Isize.ofIntCore := @IScalar.ofIntCore .Isize -def I8.ofIntCore := @IScalar.ofIntCore .I8 -def I16.ofIntCore := @IScalar.ofIntCore .I16 -def I32.ofIntCore := @IScalar.ofIntCore .I32 -def I64.ofIntCore := @IScalar.ofIntCore .I64 -def I128.ofIntCore := @IScalar.ofIntCore .I128 +@[expose] def Isize.ofIntCore := @IScalar.ofIntCore .Isize +@[expose] def I8.ofIntCore := @IScalar.ofIntCore .I8 +@[expose] def I16.ofIntCore := @IScalar.ofIntCore .I16 +@[expose] def I32.ofIntCore := @IScalar.ofIntCore .I32 +@[expose] def I64.ofIntCore := @IScalar.ofIntCore .I64 +@[expose] def I128.ofIntCore := @IScalar.ofIntCore .I128 /-! ofNat -/ -- TODO: typeclass? diff --git a/backends/lean/Aeneas/Tactic/Step/GrindState.lean b/backends/lean/Aeneas/Tactic/Step/GrindState.lean index 657d4cdd8..14e35f9e0 100644 --- a/backends/lean/Aeneas/Tactic/Step/GrindState.lean +++ b/backends/lean/Aeneas/Tactic/Step/GrindState.lean @@ -5,6 +5,7 @@ Authors: Son Ho -/ module public import Lean +public import Lean.Meta.Tactic.Grind.Solve public import Aeneas.Tactic.Solver.ScalarTac public import Aeneas.Tactic.Step.Init public import Aeneas.Tactic.Solver.Grind.Init From 2d7bc04128d0aff06fd2c6a8234430caed499ee2 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 17:22:18 +0200 Subject: [PATCH 14/40] more --- backends/lean/Aeneas/Data/Discriminant.lean | 2 +- backends/lean/Aeneas/Tactic/Setup.lean | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/lean/Aeneas/Data/Discriminant.lean b/backends/lean/Aeneas/Data/Discriminant.lean index 3c4a34067..13d4ba296 100644 --- a/backends/lean/Aeneas/Data/Discriminant.lean +++ b/backends/lean/Aeneas/Data/Discriminant.lean @@ -1,6 +1,6 @@ module public import Lean -public import Aeneas.Std.Scalar.Core +public meta import Aeneas.Std.Scalar.Core public import Aeneas.Std.Scalar.Notations public section diff --git a/backends/lean/Aeneas/Tactic/Setup.lean b/backends/lean/Aeneas/Tactic/Setup.lean index 1db6124b4..c1b4cb02e 100644 --- a/backends/lean/Aeneas/Tactic/Setup.lean +++ b/backends/lean/Aeneas/Tactic/Setup.lean @@ -8,12 +8,12 @@ namespace Aeneas open Lean Elab Command Term Meta /-- When `true` (default), using the deprecated `#setup_aeneas_simps` command emits a warning. -/ -register_option Deprecated.setupAeneasSimps : Bool := { +meta register_option Deprecated.setupAeneasSimps : Bool := { defValue := true descr := "Emit warnings when using the deprecated `#setup_aeneas_simps` command" } -private def emitSetupAeneasSimpsWarning : CommandElabM Unit := do +private meta def emitSetupAeneasSimpsWarning : CommandElabM Unit := do if Deprecated.setupAeneasSimps.get (← getOptions) then logWarning m!"`#setup_aeneas_simps` has been deprecated. \ Set `set_option Aeneas.Deprecated.setupAeneasSimps false` to silence this warning." From ea09d544af23e29dab321bcc2e97a35a8615d458 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 17:40:28 +0200 Subject: [PATCH 15/40] iter --- backends/lean/Aeneas/Std/Core/Iter.lean | 8 ++++---- backends/lean/Aeneas/Std/SliceIter.lean | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backends/lean/Aeneas/Std/Core/Iter.lean b/backends/lean/Aeneas/Std/Core/Iter.lean index 32b54ed61..539922ab8 100644 --- a/backends/lean/Aeneas/Std/Core/Iter.lean +++ b/backends/lean/Aeneas/Std/Core/Iter.lean @@ -90,7 +90,7 @@ structure core.iter.traits.iterator.Iterator (Self : Type) (Self_Item : Type) -- rev : Self → Result (core.iter.adapters.rev.Rev Self) -- this leads to a circularity -- TODO: collect -@[trait_default, rust_fun "core::iter::traits::iterator::Iterator::step_by"] +@[expose, trait_default, rust_fun "core::iter::traits::iterator::Iterator::step_by"] def core.iter.traits.iterator.Iterator.step_by.trait_default {Self Item : Type} (_IteratorInst : core.iter.traits.iterator.Iterator Self Item) @@ -98,7 +98,7 @@ def core.iter.traits.iterator.Iterator.step_by.trait_default Result (core.iter.adapters.step_by.StepBy Self) := core.iter.traits.iterator.Iterator.step_by.default self step_by -@[trait_default, rust_fun "core::iter::traits::iterator::Iterator::enumerate"] +@[expose, trait_default, rust_fun "core::iter::traits::iterator::Iterator::enumerate"] def core.iter.traits.iterator.Iterator.enumerate.trait_default {Self Item : Type} (_IteratorInst : core.iter.traits.iterator.Iterator Self Item) @@ -106,7 +106,7 @@ def core.iter.traits.iterator.Iterator.enumerate.trait_default Result (core.iter.adapters.enumerate.Enumerate Self) := core.iter.traits.iterator.Iterator.enumerate.default self -@[trait_default, rust_fun "core::iter::traits::iterator::Iterator::take"] +@[expose, trait_default, rust_fun "core::iter::traits::iterator::Iterator::take"] def core.iter.traits.iterator.Iterator.take.trait_default {Self Item : Type} (_IteratorInst : core.iter.traits.iterator.Iterator Self Item) @@ -143,7 +143,7 @@ def core.iter.adapters.step_by.IteratorStepBy.next @[reducible, rust_trait_impl "core::iter::traits::iterator::Iterator, @Clause0_Item>"] -impl_def core.iter.traits.iterator.IteratorStepBy {I : Type} {Item : Type} +public impl_def core.iter.traits.iterator.IteratorStepBy {I : Type} {Item : Type} (IteratorInst : core.iter.traits.iterator.Iterator I Item) : core.iter.traits.iterator.Iterator (core.iter.adapters.step_by.StepBy I) Item := { next := core.iter.adapters.step_by.IteratorStepBy.next IteratorInst diff --git a/backends/lean/Aeneas/Std/SliceIter.lean b/backends/lean/Aeneas/Std/SliceIter.lean index c78c01ff1..3a98b8295 100644 --- a/backends/lean/Aeneas/Std/SliceIter.lean +++ b/backends/lean/Aeneas/Std/SliceIter.lean @@ -3,6 +3,7 @@ module public import Aeneas.Std.Slice public import Aeneas.Std.Array.Array public import Aeneas.Std.Core.Iter +public meta import Aeneas.Std.Core.Iter public section namespace Aeneas.Std From 27f62b8a8bddde77f2cbc6d3d672c865fd67a4a1 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Wed, 22 Jul 2026 18:40:20 +0200 Subject: [PATCH 16/40] more --- .../lean/Aeneas/Std/Array/ArraySlice.lean | 7 ++-- backends/lean/Aeneas/Std/Core/Fmt.lean | 6 +-- .../Aeneas/Std/Scalar/CoreConvertNum.lean | 2 +- backends/lean/Aeneas/Std/Slice.lean | 38 +++++++++---------- backends/lean/Aeneas/Std/StringDef.lean | 2 +- backends/lean/Aeneas/Std/Vec.lean | 4 +- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/backends/lean/Aeneas/Std/Array/ArraySlice.lean b/backends/lean/Aeneas/Std/Array/ArraySlice.lean index 3a3f5322f..26db54898 100644 --- a/backends/lean/Aeneas/Std/Array/ArraySlice.lean +++ b/backends/lean/Aeneas/Std/Array/ArraySlice.lean @@ -6,6 +6,7 @@ public import Aeneas.Std.Range public import Aeneas.Data.List.List public import Aeneas.Std.Core.Convert public import Aeneas.Std.Core.Cmp +import all Init.Data.List.Control public section /-! Array definitions which mention slices -/ @@ -18,7 +19,7 @@ attribute [-simp] List.getElem!_eq_getElem?_getD /-! Array to slice/subslices -/ -@[step_pure_def] +@[step_pure_def, expose] def Array.to_slice {α : Type u} {n : Usize} (v : Array α n) : Slice α := ⟨ v.val, by scalar_tac ⟩ @@ -93,7 +94,7 @@ theorem Array.update_subslice_spec {α : Type u} {n : Usize} [Inhabited α] (a : simp_lists . scalar_tac -@[rust_fun "core::array::{core::ops::index::Index<[@T; @N], @I, @O>}::index"] +@[expose, rust_fun "core::array::{core::ops::index::Index<[@T; @N], @I, @O>}::index"] def core.array.Array.index {T I Output : Type} {N : Usize} (inst : core.ops.index.Index (Slice T) I Output) (a : Array T N) (i : I) : Result Output := @@ -122,7 +123,7 @@ def core.ops.index.IndexMutArray {T I Output : Type} {N : Usize} index_mut := core.array.Array.index_mut inst } -@[reducible, rust_type "core::array::TryFromSliceError"] +@[reducible, expose, rust_type "core::array::TryFromSliceError"] def core.array.TryFromSliceError := Unit @[simp, simp_lists_safe, grind =, agrind =] diff --git a/backends/lean/Aeneas/Std/Core/Fmt.lean b/backends/lean/Aeneas/Std/Core/Fmt.lean index 159dc501b..7316e6c0c 100644 --- a/backends/lean/Aeneas/Std/Core/Fmt.lean +++ b/backends/lean/Aeneas/Std/Core/Fmt.lean @@ -7,7 +7,7 @@ public section namespace Aeneas.Std -@[reducible, rust_type "core::fmt::Error"] +@[reducible, expose, rust_type "core::fmt::Error"] def core.fmt.Error := Unit /- TODO: -/ @@ -46,10 +46,10 @@ def core.result.Result.unwrap.mut {T E : Type} -- TODO: this is a simplistic model -@[rust_type "core::fmt::Arguments"] +@[expose, rust_type "core::fmt::Arguments"] def core.fmt.Arguments : Type := Unit -@[rust_type "core::fmt::rt::Argument"] +@[expose, rust_type "core::fmt::rt::Argument"] def core.fmt.rt.Argument : Type := Unit @[rust_fun "core::fmt::{core::fmt::Arguments<'a>}::from_str"] diff --git a/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean b/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean index 63f69819d..8ce4218ae 100644 --- a/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean +++ b/backends/lean/Aeneas/Std/Scalar/CoreConvertNum.lean @@ -802,7 +802,7 @@ theorem core.num.«%S».is_multiple_of.spec (a b : «%S») : core.num.«%S».is_multiple_of a b ⦃ (r : Bool) => r = (a.val % b.val = 0) ⦄ := UScalar.is_multiple_of.spec a b -@[reducible, rust_type "core::num::error::TryFromIntError"] +@[reducible, expose, rust_type "core::num::error::TryFromIntError"] def core.num.error.TryFromIntError : Type := Unit /-- General fallible conversion between unsigned scalar types. -/ diff --git a/backends/lean/Aeneas/Std/Slice.lean b/backends/lean/Aeneas/Std/Slice.lean index eaaac1920..6d9d7edca 100644 --- a/backends/lean/Aeneas/Std/Slice.lean +++ b/backends/lean/Aeneas/Std/Slice.lean @@ -93,16 +93,16 @@ theorem Slice.getElem!_Usize_eq {α : Type u} [Inhabited α] (v : Slice α) (i : @[simp, scalar_tac_simps, simp_lists_hyps_simps] abbrev Slice.get? {α : Type u} (v : Slice α) (i : Nat) : Option α := getElem? v i @[simp, scalar_tac_simps, simp_lists_hyps_simps] abbrev Slice.get! {α : Type u} [Inhabited α] (v : Slice α) (i : Nat) : α := getElem! v i -def Slice.setAtNat {α : Type u} (v: Slice α) (i: Nat) (x: α) : Slice α := +@[expose] def Slice.setAtNat {α : Type u} (v: Slice α) (i: Nat) (x: α) : Slice α := ⟨ v.val.set i x, by have := v.property; simp [*] ⟩ -def Slice.set {α : Type u} (v: Slice α) (i: Usize) (x: α) : Slice α := +@[expose] def Slice.set {α : Type u} (v: Slice α) (i: Usize) (x: α) : Slice α := Slice.setAtNat v i.val x def Slice.set_opt {α : Type u} (v: Slice α) (i: Usize) (x: Option α) : Slice α := ⟨ v.val.set_opt i.val x, by have := v.property; simp [*] ⟩ -def Slice.drop {α} (s : Slice α) (i : Usize) : Slice α := +@[expose] def Slice.drop {α} (s : Slice α) (i : Usize) : Slice α := ⟨ s.val.drop i.val, by scalar_tac ⟩ @[simp, simp_lists_safe] @@ -114,7 +114,7 @@ theorem Slice.getElem!_val_drop {T} (s : Slice T) (i : Usize) : abbrev Slice.slice {α : Type u} [Inhabited α] (s : Slice α) (i j : Nat) : List α := s.val.slice i j -def Slice.index_usize {α : Type u} (v: Slice α) (i: Usize) : Result α := +@[expose] def Slice.index_usize {α : Type u} (v: Slice α) (i: Usize) : Result α := match v[i]? with | none => fail .arrayOutOfBounds | some x => ok x @@ -274,7 +274,7 @@ theorem Slice.update_spec {α : Type u} (v: Slice α) (i: Usize) (x : α) simp at * simp [*] -def Slice.index_mut_usize {α : Type u} (v: Slice α) (i: Usize) : +@[expose] def Slice.index_mut_usize {α : Type u} (v: Slice α) (i: Usize) : Result (α × (α → Slice α)) := do let x ← Slice.index_usize v i ok (x, Slice.set v i) @@ -349,7 +349,7 @@ structure core.slice.index.SliceIndex (Self T Output : Type) where index : Self → T → Result Output index_mut : Self → T → Result (Output × (Output → T)) -@[rust_fun "core::slice::index::{core::ops::index::Index<[@T], @I, @O>}::index"] +@[expose, rust_fun "core::slice::index::{core::ops::index::Index<[@T], @I, @O>}::index"] def core.slice.index.Slice.index {T I Output : Type} (inst : core.slice.index.SliceIndex I (Slice T) Output) (slice : Slice T) (i : I) : Result Output := @@ -408,13 +408,13 @@ def core.slice.index.SliceIndexRangeUsizeSlice.get_unchecked_mut {T : Type} : -- Don't know what the model should be - for now we always fail fun _ _ => fail .undef -@[rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index"] +@[expose, rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index"] def core.slice.index.SliceIndexRangeUsizeSlice.index {T : Type} (r : Range Usize) (s : Slice T) : Result (Slice T) := if r.start ≤ r.end ∧ r.end ≤ s.length then ok (⟨ s.val.slice r.start r.end, by scalar_tac⟩) else fail .panic -@[rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index_mut"] +@[expose, rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index_mut"] def core.slice.index.SliceIndexRangeUsizeSlice.index_mut {T : Type} (r : Range Usize) (s : Slice T) : Result (Slice T × (Slice T → Slice T)) := if r.start ≤ r.end ∧ r.end ≤ s.length then @@ -427,7 +427,7 @@ def core.slice.index.SliceIndexRangeUsizeSlice.index_mut {T : Type} (r : Range U else fail .panic /- [core::slice::index::[T]::index_mut] -/ -@[rust_fun "core::slice::index::{core::ops::index::IndexMut<[@T], @I, @O>}::index_mut"] +@[expose, rust_fun "core::slice::index::{core::ops::index::IndexMut<[@T], @I, @O>}::index_mut"] def core.slice.index.Slice.index_mut {T I Output : Type} (inst : core.slice.index.SliceIndex I (Slice T) Output) (s : Slice T) (i : I) : Result (Output × (Output → Slice T)) := @@ -437,7 +437,7 @@ def core.slice.index.Slice.index_mut def core.slice.index.private_slice_index.SealedRangeUsize : core.slice.index.private_slice_index.Sealed (Range Usize) := {} -@[reducible, rust_trait_impl "core::slice::index::SliceIndex, [@T], [@T]>"] +@[reducible, expose, rust_trait_impl "core::slice::index::SliceIndex, [@T], [@T]>"] def core.slice.index.SliceIndexRangeUsizeSlice (T : Type) : core.slice.index.SliceIndex (Range Usize) (Slice T) (Slice T) := { sealedInst := core.slice.index.private_slice_index.SealedRangeUsize @@ -489,14 +489,14 @@ def core.slice.index.SliceIndexRangeToUsizeSlice.get_unchecked_mut -- TODO: update once we make the model of computation more stateful (for now we just fail) fail .undef -@[rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index"] +@[expose, rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index"] def core.slice.index.SliceIndexRangeToUsizeSlice.index {T : Type} (r : core.ops.range.RangeTo Usize) (s : Slice T) : Result (Slice T) := if r.end ≤ s.length then ok (⟨ s.val.slice 0 r.end, by scalar_tac⟩) else fail .panic -@[rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index_mut"] +@[expose, rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index_mut"] def core.slice.index.SliceIndexRangeToUsizeSlice.index_mut {T : Type} (r : core.ops.range.RangeTo Usize) (s : Slice T) : Result ((Slice T) × (Slice T → Slice T)) := @@ -509,7 +509,7 @@ def core.slice.index.SliceIndexRangeToUsizeSlice.index_mut fun s' => ⟨ List.setSlice! s.val 0 s'.val, by scalar_tac ⟩) else fail .panic -@[reducible, rust_trait_impl "core::slice::index::SliceIndex, [@T], [@T]>"] +@[reducible, expose, rust_trait_impl "core::slice::index::SliceIndex, [@T], [@T]>"] def core.slice.index.SliceIndexRangeToUsizeSlice (T : Type) : core.slice.index.SliceIndex (core.ops.range.RangeTo Usize) (Slice T) (Slice T) := { @@ -522,14 +522,14 @@ def core.slice.index.SliceIndexRangeToUsizeSlice (T : Type) : index_mut := core.slice.index.SliceIndexRangeToUsizeSlice.index_mut } -@[rust_trait_impl "core::ops::index::Index<[@T], @I, @O>"] +@[expose, rust_trait_impl "core::ops::index::Index<[@T], @I, @O>"] def core.ops.index.IndexSlice {T I Output : Type} (inst : core.slice.index.SliceIndex I (Slice T) Output) : core.ops.index.Index (Slice T) I Output := { index := core.slice.index.Slice.index inst } -@[rust_trait_impl "core::ops::index::IndexMut<[@T], @I, @O>"] +@[expose, rust_trait_impl "core::ops::index::IndexMut<[@T], @I, @O>"] def core.ops.index.IndexMutSlice {T I Output : Type} (inst : core.slice.index.SliceIndex I (Slice T) Output) : core.ops.index.IndexMut (Slice T) I Output := { @@ -572,7 +572,7 @@ abbrev core.slice.index.Usize.index_mut {T : Type} def core.slice.index.private_slice_index.SealedUsize : core.slice.index.private_slice_index.Sealed Usize := {} -@[reducible, rust_trait_impl "core::slice::index::SliceIndex"] +@[reducible, expose, rust_trait_impl "core::slice::index::SliceIndex"] def core.slice.index.SliceIndexUsizeSlice (T : Type) : core.slice.index.SliceIndex Usize (Slice T) T := { sealedInst := core.slice.index.private_slice_index.SealedUsize @@ -629,14 +629,14 @@ def core.slice.index.SliceIndexRangeFromUsizeSlice.get_unchecked_mut {T : Type} -- We don't have a model for now fun _ _ => fail .undef -@[rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index"] +@[expose, rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index"] def core.slice.index.SliceIndexRangeFromUsizeSlice.index {T : Type} (r : core.ops.range.RangeFrom Usize) (s : Slice T) : Result (Slice T) := if r.start.val ≤ s.length then ok (s.drop r.start) else fail .undef -@[rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index_mut"] +@[expose, rust_fun "core::slice::index::{core::slice::index::SliceIndex, [@T], [@T]>}::index_mut"] def core.slice.index.SliceIndexRangeFromUsizeSlice.index_mut {T : Type} (r : core.ops.range.RangeFrom Usize) (s : Slice T) : Result ((Slice T) × (Slice T → Slice T)) := if r.start ≤ s.length then @@ -662,7 +662,7 @@ def core.slice.index.private_slice_index.SealedRangeFromUsize : core.slice.index.private_slice_index.Sealed (core.ops.range.RangeFrom Usize) := {} -@[reducible, rust_trait_impl "core::slice::index::SliceIndex, [@T], [@T]>"] +@[reducible, expose, rust_trait_impl "core::slice::index::SliceIndex, [@T], [@T]>"] def core.slice.index.SliceIndexRangeFromUsizeSlice (T : Type) : core.slice.index.SliceIndex (core.ops.range.RangeFrom Usize) (Slice T) (Slice T) := { sealedInst := diff --git a/backends/lean/Aeneas/Std/StringDef.lean b/backends/lean/Aeneas/Std/StringDef.lean index 668336dfc..57ecbc039 100644 --- a/backends/lean/Aeneas/Std/StringDef.lean +++ b/backends/lean/Aeneas/Std/StringDef.lean @@ -5,6 +5,6 @@ public section namespace Aeneas.Std -def Str := Slice U8 +@[expose] def Str := Slice U8 end Aeneas.Std diff --git a/backends/lean/Aeneas/Std/Vec.lean b/backends/lean/Aeneas/Std/Vec.lean index 992d2287d..48a022b26 100644 --- a/backends/lean/Aeneas/Std/Vec.lean +++ b/backends/lean/Aeneas/Std/Vec.lean @@ -20,7 +20,7 @@ local macro_rules namespace alloc.vec -@[rust_type "alloc::vec::Vec"] +@[expose, rust_type "alloc::vec::Vec"] def Vec (α : Type u) := { l : List α // l.length ≤ Usize.max } /-- We need this to coerce vectors to lists without marking `Vec` as reducible. @@ -103,7 +103,7 @@ abbrev Vec.get? {α : Type u} (v : Vec α) (i : Nat) : Option α := getElem? v i @[simp, scalar_tac_simps, simp_lists_safe, simp_lists_hyps_simps, grind, agrind] abbrev Vec.get! {α : Type u} [Inhabited α] (v : Vec α) (i : Nat) : α := getElem! v i -def Vec.set {α : Type u} (v: Vec α) (i: Usize) (x: α) : Vec α := +@[expose] def Vec.set {α : Type u} (v: Vec α) (i: Usize) (x: α) : Vec α := ⟨ v.val.set i.val x, by have := v.property; simp [*] ⟩ def Vec.set_opt {α : Type u} (v: Vec α) (i: Usize) (x: Option α) : Vec α := From 2de1d49562240a6a1bef20177a7ec557aac0b209 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Thu, 23 Jul 2026 07:52:42 +0200 Subject: [PATCH 17/40] expose --- backends/lean/Aeneas/Std/Core/Iter.lean | 22 +++++++++---------- .../lean/Aeneas/Std/Scalar/CloneCopy.lean | 8 +++---- backends/lean/Aeneas/Std/Scalar/EqOrd.lean | 10 ++++----- backends/lean/Aeneas/Std/SliceIter.lean | 2 +- backends/lean/Aeneas/Std/VecIter.lean | 2 +- .../Aeneas/Tactic/Elab/TraitDefault/Init.lean | 10 ++++++++- 6 files changed, 31 insertions(+), 23 deletions(-) diff --git a/backends/lean/Aeneas/Std/Core/Iter.lean b/backends/lean/Aeneas/Std/Core/Iter.lean index 539922ab8..13f2554da 100644 --- a/backends/lean/Aeneas/Std/Core/Iter.lean +++ b/backends/lean/Aeneas/Std/Core/Iter.lean @@ -115,7 +115,7 @@ def core.iter.traits.iterator.Iterator.take.trait_default core.iter.traits.iterator.Iterator.take.default self n /-- Skip up to `n` elements from an iterator -/ -def core.iter.adapters.step_by.skipN +@[expose] def core.iter.adapters.step_by.skipN {I : Type} {Item : Type} (iterInst : core.iter.traits.iterator.Iterator I Item) (iter : I) : (n : Nat) → Result I @@ -126,7 +126,7 @@ def core.iter.adapters.step_by.skipN | none => .ok iter | some _ => core.iter.adapters.step_by.skipN iterInst iter n -@[rust_fun +@[expose, rust_fun "core::iter::adapters::step_by::{core::iter::traits::iterator::Iterator, @Clause0_Item>}::next"] def core.iter.adapters.step_by.IteratorStepBy.next {I : Type} {Item : Type} @@ -143,7 +143,7 @@ def core.iter.adapters.step_by.IteratorStepBy.next @[reducible, rust_trait_impl "core::iter::traits::iterator::Iterator, @Clause0_Item>"] -public impl_def core.iter.traits.iterator.IteratorStepBy {I : Type} {Item : Type} +impl_def core.iter.traits.iterator.IteratorStepBy {I : Type} {Item : Type} (IteratorInst : core.iter.traits.iterator.Iterator I Item) : core.iter.traits.iterator.Iterator (core.iter.adapters.step_by.StepBy I) Item := { next := core.iter.adapters.step_by.IteratorStepBy.next IteratorInst @@ -251,7 +251,7 @@ def core.iter.range.IScalarStep.steps_between {ty : IScalarTy} ok ⟨ usizeMax, none ⟩ /-- Generic `forward_checked` for all unsigned scalar types. -/ -def core.iter.range.UScalarStep.forward_checked {ty : UScalarTy} +@[expose] def core.iter.range.UScalarStep.forward_checked {ty : UScalarTy} (start : UScalar ty) (n : Usize) : Result (Option (UScalar ty)) := if h : start.val + n.val ≤ UScalar.max ty then ok (some (UScalar.ofNatCore (start.val + n.val) @@ -288,7 +288,7 @@ def core.iter.range.IScalarStep.backward_checked {ty : IScalarTy} /-- Generic Step instance for all unsigned scalar types. The per-type instances below are abbreviations of this, differing only in Clone/PartialOrd. -/ -def core.iter.range.UScalarStep (ty : UScalarTy) +@[expose] def core.iter.range.UScalarStep (ty : UScalarTy) (cloneInst : core.clone.Clone (UScalar ty)) (partialOrdInst : core.cmp.PartialOrd (UScalar ty) (UScalar ty)) : core.iter.range.Step (UScalar ty) := { @@ -427,7 +427,7 @@ abbrev core.iter.range.StepI128 := IScalarStep .I128 core.clone.CloneI128 core.c -- ============================================================================ -- Model for `Iterator::next` on `Enumerate` -@[rust_fun +@[expose, rust_fun "core::iter::adapters::enumerate::{core::iter::traits::iterator::Iterator, (usize, @Clause0_Item)>}::next"] def core.iter.adapters.enumerate.IteratorEnumerate.next {I : Type} {Item : Type} @@ -460,7 +460,7 @@ impl_def core.iter.traits.iterator.IteratorEnumerate {I : Type} {Item : Type} -- ============================================================================ -- Model for `Iterator::next` on `Take` -@[rust_fun +@[expose, rust_fun "core::iter::adapters::take::{core::iter::traits::iterator::Iterator, @Clause0_Item>}::next"] def core.iter.adapters.take.IteratorTake.next {I : Type} {Item : Type} @@ -488,7 +488,7 @@ impl_def core.iter.traits.iterator.IteratorTake {I : Type} {Item : Type} (core.iter.traits.iterator.IteratorTake IteratorInst) } -@[rust_fun +@[expose, rust_fun "core::iter::range::{core::iter::traits::iterator::Iterator, @A>}::next"] def core.iter.range.IteratorRange.next {A : Type} (StepInst : core.iter.range.Step A) : @@ -541,12 +541,12 @@ def core.iter.adapters.zip.Zip.Insts.CoreIterTraitsIteratorIteratorPair.next | none => ok (none, ⟨a', b'⟩) | some b => ok (some (a, b), ⟨a', b'⟩) -@[rust_fun "core::ops::range::{core::ops::range::RangeInclusive<@Idx>}::new"] +@[expose, rust_fun "core::ops::range::{core::ops::range::RangeInclusive<@Idx>}::new"] def core.ops.range.RangeInclusive.new {Idx : Type} (start «end» : Idx) : Result (core.ops.range.RangeInclusive Idx) := ok ⟨start, «end», false⟩ -@[rust_fun "core::ops::range::{core::ops::range::RangeInclusive<@Idx>}::is_empty"] +@[expose, rust_fun "core::ops::range::{core::ops::range::RangeInclusive<@Idx>}::is_empty"] def core.ops.range.RangeInclusive.is_empty {Idx : Type} (inst : core.cmp.PartialOrd Idx Idx) (self : core.ops.range.RangeInclusive Idx) : Result Bool := do if self.exhausted then ok true @@ -571,7 +571,7 @@ def core.ops.range.RangeInclusive.is_empty {Idx : Type} (inst : core.cmp.Partial }) } ``` -/ -@[rust_fun +@[expose, rust_fun "core::iter::range::{core::iter::traits::iterator::Iterator, @A>}::next"] def core.ops.range.RangeInclusive.Insts.CoreIterTraitsIteratorIterator.next {A : Type} (StepInst : core.iter.range.Step A) diff --git a/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean b/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean index bfdc9c26b..d0aae1fe0 100644 --- a/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean +++ b/backends/lean/Aeneas/Std/Scalar/CloneCopy.lean @@ -12,16 +12,16 @@ open Result Error ScalarElab -/ -- Remark: the command `uscalar` turns the name `Clone'S` into `CloneU8`, `CloneU16`, etc. -uscalar @[reducible, simp] def core.clone.impls.Clone'S.clone (x : «%S») : «%S» := x +uscalar @[reducible, simp, expose] def core.clone.impls.Clone'S.clone (x : «%S») : «%S» := x uscalar @[reducible, simp] def core.clone.impls.Clone'S.clone_from (_ x : «%S») : «%S» := x -iscalar @[reducible, simp] def core.clone.impls.Clone'S.clone (x : «%S») : «%S» := x +iscalar @[reducible, simp, expose] def core.clone.impls.Clone'S.clone (x : «%S») : «%S» := x iscalar @[reducible, simp] def core.clone.impls.Clone'S.clone_from (_ x : «%S») : «%S» := x -uscalar @[reducible] def core.clone.Clone'S : core.clone.Clone «%S» := { +uscalar @[reducible, expose] def core.clone.Clone'S : core.clone.Clone «%S» := { clone := liftFun1 core.clone.impls.Clone'S.clone clone_from := liftFun2 core.clone.impls.Clone'S.clone_from } -iscalar @[reducible] def core.clone.Clone'S : core.clone.Clone «%S» := { +iscalar @[reducible, expose] def core.clone.Clone'S : core.clone.Clone «%S» := { clone := liftFun1 core.clone.impls.Clone'S.clone clone_from := liftFun2 core.clone.impls.Clone'S.clone_from } diff --git a/backends/lean/Aeneas/Std/Scalar/EqOrd.lean b/backends/lean/Aeneas/Std/Scalar/EqOrd.lean index 346300349..d397c71a5 100644 --- a/backends/lean/Aeneas/Std/Scalar/EqOrd.lean +++ b/backends/lean/Aeneas/Std/Scalar/EqOrd.lean @@ -39,23 +39,23 @@ scalar @[simp] abbrev core.cmp.impls.Ord'S.cmp (x y : «%S») : Ordering := comp /- [core::cmp::impls::{core::cmp::PartialOrd for u8}::lt]: Name pattern: core::cmp::impls::{core::cmp::PartialOrd}::lt -/ -scalar def core.cmp.impls.PartialOrd'S.lt (x y : «%S») : Bool := x.val < y.val +scalar @[expose] def core.cmp.impls.PartialOrd'S.lt (x y : «%S») : Bool := x.val < y.val /- [core::cmp::impls::{core::cmp::PartialOrd for u8}::le]: Name pattern: core::cmp::impls::{core::cmp::PartialOrd}::le -/ -scalar def core.cmp.impls.PartialOrd'S.le (x y : «%S») : Bool := x.val ≤ y.val +scalar @[expose] def core.cmp.impls.PartialOrd'S.le (x y : «%S») : Bool := x.val ≤ y.val /- [core::cmp::impls::{core::cmp::PartialOrd for u8}::gt]: Name pattern: core::cmp::impls::{core::cmp::PartialOrd}::gt -/ -scalar def core.cmp.impls.PartialOrd'S.gt (x y : «%S») : Bool := x.val > y.val +scalar @[expose] def core.cmp.impls.PartialOrd'S.gt (x y : «%S») : Bool := x.val > y.val /- [core::cmp::impls::{core::cmp::PartialOrd for u8}::ge]: Name pattern: core::cmp::impls::{core::cmp::PartialOrd}::ge -/ -scalar def core.cmp.impls.PartialOrd'S.ge (x y : «%S») : Bool := x.val ≥ y.val +scalar @[expose] def core.cmp.impls.PartialOrd'S.ge (x y : «%S») : Bool := x.val ≥ y.val /- Trait implementation: [core::cmp::impls::{core::cmp::PartialOrd for u8}] Name pattern: core::cmp::PartialOrd -/ -scalar @[reducible] def core.cmp.PartialOrd'S : core.cmp.PartialOrd «%S» «%S» := { +scalar @[reducible, expose] def core.cmp.PartialOrd'S : core.cmp.PartialOrd «%S» «%S» := { partialEqInst := core.cmp.PartialEq'S partial_cmp := liftFun2 core.cmp.impls.PartialOrd'S.partial_cmp lt := liftFun2 core.cmp.impls.PartialOrd'S.lt diff --git a/backends/lean/Aeneas/Std/SliceIter.lean b/backends/lean/Aeneas/Std/SliceIter.lean index 3a98b8295..8689720a7 100644 --- a/backends/lean/Aeneas/Std/SliceIter.lean +++ b/backends/lean/Aeneas/Std/SliceIter.lean @@ -136,7 +136,7 @@ def core.slice.iter.ChunksExact.getRemainder {T : Type} (self : core.slice.iter.ChunksExact T) : Result (Slice T) := ok self.remainder -@[rust_fun +@[expose, rust_fun "core::slice::iter::{core::iter::traits::iterator::Iterator, &'a [@T]>}::next"] def core.slice.iter.IteratorChunksExact.next {T : Type} (self : core.slice.iter.ChunksExact T) : diff --git a/backends/lean/Aeneas/Std/VecIter.lean b/backends/lean/Aeneas/Std/VecIter.lean index ac8b57d05..2ed88c49f 100644 --- a/backends/lean/Aeneas/Std/VecIter.lean +++ b/backends/lean/Aeneas/Std/VecIter.lean @@ -7,7 +7,7 @@ namespace Aeneas.Std open Result -@[rust_type "alloc::vec::into_iter::IntoIter" (keepParams := [true, false])] +@[rust_type "alloc::vec::into_iter::IntoIter" (keepParams := [true, false]), expose] def alloc.vec.into_iter.IntoIter (T : Type) : Type := alloc.vec.Vec T @[rust_fun diff --git a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean index d296c3ed9..cebff98e4 100644 --- a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean +++ b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean @@ -322,6 +322,11 @@ meta def resolveStructFields (value : Expr) (selfFvarId : FVarId) (type : Expr) compiles, and applies any declaration attributes (e.g., `@[simp]`). -/ elab mods:declModifiers "impl_def " id:declId sig:optDeclSig val:declVal : command => do let modifiers ← elabModifiers mods + /- TODO: when migrating to the module system, recover the old visibility. Better style would + be to expose less and provide relevant theorems. -/ + let modifiers := + if modifiers.visibility matches .regular then { modifiers with visibility := .public } + else modifiers let (binders, type?) := expandOptDeclSig sig let typeStx ← match type? with | some t => pure t @@ -391,6 +396,9 @@ elab mods:declModifiers "impl_def " id:declId sig:optDeclSig val:declVal : comma } let docCtx := (← getLCtx, ← getLocalInstances) - addAndCompileNonRec docCtx preDef + /- TODO: when migrating to the module system, recover the old visibility. Better style would + be to expose less and provide relevant theorems. -/ + withExporting (isExporting := true) do + addAndCompileNonRec docCtx preDef end Aeneas.TraitDefault From 86a31cd3b966561b750fc9a19fd65dced11d129d Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Thu, 23 Jul 2026 17:46:12 +0200 Subject: [PATCH 18/40] wave wave --- backends/lean/Aeneas/Do/Elab.lean | 88 +++++++++---------- .../lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean | 55 +++++++++--- .../Aeneas/Tactic/Simp/SimpListsScalar.lean | 4 +- 3 files changed, 89 insertions(+), 58 deletions(-) diff --git a/backends/lean/Aeneas/Do/Elab.lean b/backends/lean/Aeneas/Do/Elab.lean index 22dc8f3ee..f0672f441 100644 --- a/backends/lean/Aeneas/Do/Elab.lean +++ b/backends/lean/Aeneas/Do/Elab.lean @@ -1,6 +1,6 @@ module public import Lean -public import Mathlib.Control.Monad.Cont +public meta import Mathlib.Control.Monad.Cont public import Aeneas.Std public section @@ -22,18 +22,18 @@ open Lean Elab Parser Term Meta /- Some necessary instances for `ContT` -/ -instance [MonadExceptOf ε m] [Monad m] : MonadExceptOf ε (ContT r m) where +meta instance [MonadExceptOf ε m] [Monad m] : MonadExceptOf ε (ContT r m) where throw e := fun _ => throw e tryCatch x h := fun k => tryCatch (x k) (fun e => h e k) -- -instance [MonadRef m] [Monad m] : MonadRef (ContT r m) where +meta instance [MonadRef m] [Monad m] : MonadRef (ContT r m) where getRef := fun k => do let ref ← MonadRef.getRef; k ref withRef ref x := fun k => MonadRef.withRef ref (x k) -- -instance [AddErrorMessageContext m] [Monad m] : AddErrorMessageContext (ContT r m) where +meta instance [AddErrorMessageContext m] [Monad m] : AddErrorMessageContext (ContT r m) where add stx msg := fun k => do let r ← AddErrorMessageContext.add stx msg; k r -- -instance [Monad m] [MonadQuotation m] : MonadQuotation (ContT r m) where +meta instance [Monad m] [MonadQuotation m] : MonadQuotation (ContT r m) where getCurrMacroScope := fun k => do let s ← getCurrMacroScope; k s getContext := fun k => do let ctx ← MonadQuotation.getContext; k ctx withFreshMacroScope x := fun k => withFreshMacroScope (x k) @@ -54,7 +54,7 @@ structure Context where abbrev ElabM := ReaderT Context $ ContT Expr TermElabM /-- Split `m α` and synthesize the `Bind m` and `Pure m` instances. -/ -def mkContext (expectedType : Expr) : TermElabM Context := do +meta def mkContext (expectedType : Expr) : TermElabM Context := do let expectedType ← whnf expectedType let (m, α) ← match expectedType with | Expr.app m α => pure (m, α) @@ -63,42 +63,42 @@ def mkContext (expectedType : Expr) : TermElabM Context := do let pureInst ← synthInstance (← mkAppM ``Pure #[m]) return { m, expectedAlpha := α, bindInst, pureInst } -def ElabM.mkBind (e k : Expr) : ElabM Expr := do +meta def ElabM.mkBind (e k : Expr) : ElabM Expr := do let ctx ← read mkAppOptM ``Bind.bind #[some ctx.m, some ctx.bindInst, none, none, some e, some k] /-- Build `m α`. -/ -def ElabM.mkMonadicType (α : Expr) : ElabM Expr := read >>= fun ctx => pure (mkApp ctx.m α) +meta def ElabM.mkMonadicType (α : Expr) : ElabM Expr := read >>= fun ctx => pure (mkApp ctx.m α) /-- Run an `ElabM` against the given `do` block expected type. -/ -def ElabM.execute (x : ElabM Expr) (expectedType : Expr) : TermElabM Expr := do +meta def ElabM.execute (x : ElabM Expr) (expectedType : Expr) : TermElabM Expr := do let ctx ← mkContext expectedType (x.run ctx).run pure /-- `Meta.withLocalDeclD` lifted to `ElabM`. -/ -def ElabM.withLocalDeclD (name : Name) (type : Expr) (body : Expr → ElabM Expr) : ElabM Expr := +meta def ElabM.withLocalDeclD (name : Name) (type : Expr) (body : Expr → ElabM Expr) : ElabM Expr := fun ctx k => Meta.withLocalDeclD name type fun fvar => (body fvar).run ctx |>.run k /-- `Meta.withLetDecl` lifted to `ElabM`. -/ -def ElabM.withLetDecl (name : Name) (type : Expr) (value : Expr) +meta def ElabM.withLetDecl (name : Name) (type : Expr) (value : Expr) (body : Expr → ElabM Expr) : ElabM Expr := fun ctx k => Meta.withLetDecl name type value fun fvar => (body fvar).run ctx |>.run k /-- Our own `foldInfo` since InfoTree.foldInfo` requires a `ContextInfo` to be set which isn't available while we're in `termElab`. -/ -partial def foldInfoNoCtx {α : Type u} (f : Info → α → α) (init : α) : InfoTree → α +meta partial def foldInfoNoCtx {α : Type u} (f : Info → α → α) (init : α) : InfoTree → α | .context _ t => foldInfoNoCtx f init t | .node i ts => ts.foldl (init := f i init) (foldInfoNoCtx f) | .hole _ => init -def inRange (r : Syntax.Range) (s : Syntax) : Bool := +meta def inRange (r : Syntax.Range) (s : Syntax) : Bool := s.getRange?.any fun inner => r.start ≤ inner.start && inner.stop ≤ r.stop /-- Extract the `(userName, syntax)` binder entry from `info` when it's a binder `TermInfo` -/ -def binderEntry? (patRange : Syntax.Range) (info : Info) : Option (Name × Syntax) := do +meta def binderEntry? (patRange : Syntax.Range) (info : Info) : Option (Name × Syntax) := do let .ofTermInfo ti := info | none let .fvar fid := ti.expr | none if ti.isBinder && inRange patRange ti.stx then @@ -109,7 +109,7 @@ def binderEntry? (patRange : Syntax.Range) (info : Info) : Option (Name × Synta /-- `foldInfoNoCtx` callback: prepend a pattern-binder entry from `info` onto `acc` when `info` describes one. -/ -def collectBinder (patRange : Syntax.Range) (info : Info) +meta def collectBinder (patRange : Syntax.Range) (info : Info) (acc : List (Name × Syntax)) : List (Name × Syntax) := match binderEntry? patRange info with | some entry => entry :: acc @@ -118,7 +118,7 @@ def collectBinder (patRange : Syntax.Range) (info : Info) /-- Walk the current InfoTrees and collect a `userName → Syntax` map for every binder `TermInfo` entry whose syntax falls inside `patRange`. Throws on duplicate `userName`s, which will be a Lean error anyway. -/ -def buildArmBinderMap (patRange : Syntax.Range) : ElabM (NameMap Syntax) := do +meta def buildArmBinderMap (patRange : Syntax.Range) : ElabM (NameMap Syntax) := do let trees ← getInfoTrees let entries := trees.foldl (init := []) (foldInfoNoCtx (collectBinder patRange)) let mut m : NameMap Syntax := ∅ @@ -130,7 +130,7 @@ def buildArmBinderMap (patRange : Syntax.Range) : ElabM (NameMap Syntax) := do /-- Fill a match arm's `?m` by elaborating `body` under the arm's pattern binders and assigning the abstracted result to the mvar. -/ -def ElabM.assignArmMVar (arm : Expr) (binderMap : NameMap Syntax) (body : ElabM Expr) : +meta def ElabM.assignArmMVar (arm : Expr) (binderMap : NameMap Syntax) (body : ElabM Expr) : ElabM Unit := fun ctx k => Meta.lambdaTelescope arm fun fvars ebody => do let .mvar mvarId := ebody.getAppFn @@ -152,7 +152,7 @@ def ElabM.assignArmMVar (arm : Expr) (binderMap : NameMap Syntax) (body : ElabM /-- For a single-constructor inductive (other than `Prod`), return the constructor name and field types instantiated at the type's parameters. `none` otherwise. -/ -def getCtorFieldTypes (ty : Expr) : MetaM (Option (Name × List Expr)) := do +meta def getCtorFieldTypes (ty : Expr) : MetaM (Option (Name × List Expr)) := do let ty ← whnf ty -- Prod has its own decompose/uncurry path if ty.isAppOf ``Prod then return none @@ -167,7 +167,7 @@ def getCtorFieldTypes (ty : Expr) : MetaM (Option (Name × List Expr)) := do return some (ctorName, fieldTypes) /-- Build `T.casesOn discr minor` with a non-dependent motive `fun _ : ty => resultType`. -/ -def mkCasesOn (ty : Expr) (indName : Name) (discr : Expr) +meta def mkCasesOn (ty : Expr) (indName : Name) (discr : Expr) (minor : Expr) (resultType : Expr) : MetaM Expr := do let indVal ← getConstInfoInduct indName -- `casesOn`'s first universe is the motive's; the rest are the inductive's. @@ -177,14 +177,14 @@ def mkCasesOn (ty : Expr) (indName : Name) (discr : Expr) let motive ← withLocalDeclD `_ ty fun x => mkLambdaFVars #[x] resultType return mkAppN casesOn (params ++ #[motive, discr, minor]) -partial def decomposeProductType (ty : Expr) (n : Nat) : MetaM (List Expr) := do +meta partial def decomposeProductType (ty : Expr) (n : Nat) : MetaM (List Expr) := do if n ≤ 1 then return [ty] let ty ← whnf ty match_expr ty with | Prod α β => return α :: (← decomposeProductType β (n - 1)) | _ => throwError "expected a product type, got{indentExpr ty}" -partial def mkUncurries (innerLam : Expr) (types : List Expr) : MetaM Expr := do +meta partial def mkUncurries (innerLam : Expr) (types : List Expr) : MetaM Expr := do match types with | [] | [_] => return innerLam | [_, _] => mkAppM ``_root_.Aeneas.Std.uncurry #[innerLam] @@ -203,7 +203,7 @@ inductive PatShape where deriving Inhabited /-- Walk `pat` alongside its expected `ty`, producing a `PatShape`. -/ -partial def analyzePat (pat : Term) (ty : Expr) : ElabM PatShape := do +meta partial def analyzePat (pat : Term) (ty : Expr) : ElabM PatShape := do let analyzeSubs (subPats : Array Term) (subTypes : List Expr) : ElabM (Array PatShape) := subPats.toList.zip subTypes |>.toArray.mapM fun (p, t) => analyzePat p t match pat with @@ -234,12 +234,12 @@ partial def analyzePat (pat : Term) (ty : Expr) : ElabM PatShape := do throwError "analyzePat: unsupported pattern kind `{pat.raw.getKind}`{indentD pat}" /-- Result type of a `casesOn` whose minor is `curried : f₁ → … → fₙ → ρ`. -/ -def computeCasesOnResultType (curried : Expr) (fieldTypes : List Expr) : MetaM Expr := do +meta def computeCasesOnResultType (curried : Expr) (fieldTypes : List Expr) : MetaM Expr := do forallBoundedTelescope (← inferType curried) fieldTypes.length fun _ body => return body /-- Introduce a fresh fvar for `sub` and register a binder InfoTree node when the sub-pattern is a named leaf. Non-leaf sub-patterns get a synthetic `_xN` name. -/ -def withSubPatFVar (sub : PatShape) (ty : Expr) (idx : Nat) (k : Expr → ElabM Expr) : ElabM Expr := +meta def withSubPatFVar (sub : PatShape) (ty : Expr) (idx : Nat) (k : Expr → ElabM Expr) : ElabM Expr := let (n, id?) := match sub with | .leaf (some id) => (id.getId, some id) | .leaf none => (`_, none) @@ -251,7 +251,7 @@ def withSubPatFVar (sub : PatShape) (ty : Expr) (idx : Nat) (k : Expr → ElabM mutual /-- Build a curried lambda `fun x₁ … xₙ => body [x₁, …, xₙ]`, one fvar per sub-pattern. -/ -partial def mkCurriedLambda (subs : List PatShape) (types : List Expr) +meta partial def mkCurriedLambda (subs : List PatShape) (types : List Expr) (body : Array Expr → ElabM Expr) (idx : Nat := 0) : ElabM Expr := do match subs, types with | [], _ | _, [] => body #[] @@ -262,7 +262,7 @@ partial def mkCurriedLambda (subs : List PatShape) (types : List Expr) mkLambdaFVars #[fv] innerBody /-- Recursively unpack each `fv` per its `sub`, calling `body` with the collected leaves. -/ -partial def unpackAll (subs : List PatShape) (fvs : List Expr) (types : List Expr) +meta partial def unpackAll (subs : List PatShape) (fvs : List Expr) (types : List Expr) (body : Array Expr → ElabM Expr) : ElabM Expr := do match subs, fvs, types with | [], _, _ | _, [], _ | _, _, [] => body #[] @@ -272,7 +272,7 @@ partial def unpackAll (subs : List PatShape) (fvs : List Expr) (types : List Exp /-- Unpack `fv : ty` per `sub`, calling `body` with the leaves. Emits `Std.uncurry` for `.prod` and `T.casesOn` for `.ctor`. -/ -partial def unpackFvar (sub : PatShape) (fv : Expr) (ty : Expr) +meta partial def unpackFvar (sub : PatShape) (fv : Expr) (ty : Expr) (body : Array Expr → ElabM Expr) : ElabM Expr := do match sub with | .leaf _ => body #[fv] @@ -294,7 +294,7 @@ end /-- Build a continuation `k : ty → ρ` that destructures its argument per `shape` and calls `body` with the leaf fvars. -/ -partial def mkPatContinuation (shape : PatShape) (ty : Expr) +meta partial def mkPatContinuation (shape : PatShape) (ty : Expr) (body : Array Expr → ElabM Expr) : ElabM Expr := do match shape with | .leaf _ => withSubPatFVar shape ty 0 fun fv => do @@ -316,7 +316,7 @@ partial def mkPatContinuation (shape : PatShape) (ty : Expr) /-- Elaborate `cond`, returning a `Prop`. `Bool` is coerced to `cond = true`. Synthetic mvars are forced so `Decidable` can be inferred downstream. -/ -def elabIfCondition (cond : Term) : ElabM Expr := do +meta def elabIfCondition (cond : Term) : ElabM Expr := do let condExpr ← Lean.Elab.Term.elabTerm cond none synthesizeSyntheticMVarsNoPostponing let condExpr ← instantiateMVars condExpr @@ -327,14 +327,14 @@ def elabIfCondition (cond : Term) : ElabM Expr := do pure condExpr /-- Build `ite propExpr thn els`, synthesizing the `Decidable` instance. -/ -def mkIteExpr (propExpr thn els : Expr) : MetaM Expr := do +meta def mkIteExpr (propExpr thn els : Expr) : MetaM Expr := do mkAppOptM ``ite #[none, some propExpr, none, some thn, some els] /-! ## Individual `doElem` handlers-/ abbrev DoElem := TSyntax `doElem -def getDoElems (doSeq : TSyntax ``doSeq) : ElabM (List DoElem) := do +meta def getDoElems (doSeq : TSyntax ``doSeq) : ElabM (List DoElem) := do match doSeq with | `(doSeq| $[$elems $[;]?]*) => return elems.toList | _ => throwError "unexpected `doSeq` syntax {indentD doSeq}" @@ -342,7 +342,7 @@ def getDoElems (doSeq : TSyntax ``doSeq) : ElabM (List DoElem) := do mutual /-- Dispatch a `doElem` to its handler. -/ -partial def elabDoElem (elem : DoElem) (rest : List DoElem) : ElabM Expr := do +meta partial def elabDoElem (elem : DoElem) (rest : List DoElem) : ElabM Expr := do match elem with | `(doElem| let $x:ident $[: $ty?]? ← $rhs) => elabDoLetArrowId x ty? rhs rest | `(doElem| let $pat:term ← $rhs) => elabDoLetArrowPat pat rhs rest @@ -365,7 +365,7 @@ partial def elabDoElem (elem : DoElem) (rest : List DoElem) : ElabM Expr := do /-- Elaborate a monadic sub-term. If `rest` is empty, use the block's expected type `m α`; otherwise elaborate at `m Unit` and bind `rest` onto it. -/ -partial def elabMonadicAsDoElem +meta partial def elabMonadicAsDoElem (elabAtType : Expr → ElabM Expr) (rest : List DoElem) : ElabM Expr := do match rest with | [] => @@ -386,11 +386,11 @@ partial def elabMonadicAsDoElem ElabM.mkBind e body /-- Elaborate a term in a `doSeq` position. -/ -partial def elabDoExpr (term : Term) (rest : List DoElem) : ElabM Expr := +meta partial def elabDoExpr (term : Term) (rest : List DoElem) : ElabM Expr := elabMonadicAsDoElem (fun ty => elabTermEnsuringType term ty) rest /-- Elaborate `let x ← e`. -/ -partial def elabDoLetArrowId (x : Ident) (ty? : Option Term) (rhs : DoElem) +meta partial def elabDoLetArrowId (x : Ident) (ty? : Option Term) (rhs : DoElem) (rest : List DoElem) : ElabM Expr := do let name := x.getId let ty ← match ty? with @@ -419,7 +419,7 @@ partial def elabDoLetArrowId (x : Ident) (ty? : Option Term) (rhs : DoElem) ElabM.mkBind e body /-- Elaborate `let pat ← e`. -/ -partial def elabDoLetArrowPat (pat : Term) (rhs : DoElem) (rest : List DoElem) : ElabM Expr := do +meta partial def elabDoLetArrowPat (pat : Term) (rhs : DoElem) (rest : List DoElem) : ElabM Expr := do let α ← mkFreshTypeMVar let expectedType ← ElabM.mkMonadicType α let e ← withReader (fun ctx => { ctx with expectedAlpha := α }) do @@ -442,7 +442,7 @@ partial def elabDoLetArrowPat (pat : Term) (rhs : DoElem) (rest : List DoElem) : ElabM.mkBind e k /-- Elaborate `let x := e`. -/ -partial def elabDoLetId (x : Ident) (ty? : Option Term) (rhs : Term) +meta partial def elabDoLetId (x : Ident) (ty? : Option Term) (rhs : Term) (rest : List DoElem) : ElabM Expr := do let name := x.getId let α ← match ty? with @@ -456,7 +456,7 @@ partial def elabDoLetId (x : Ident) (ty? : Option Term) (rhs : Term) mkLetFVars #[fvar] restExpr /-- Elaborate `let pat := e`. -/ -partial def elabDoLetPat (pat : Term) (rhs : Term) +meta partial def elabDoLetPat (pat : Term) (rhs : Term) (rest : List DoElem) : ElabM Expr := do let α ← mkFreshTypeMVar let val ← elabTermEnsuringType rhs α @@ -470,7 +470,7 @@ partial def elabDoLetPat (pat : Term) (rhs : Term) /-- Elaborate an `if/else-if/…/else` chain as nested `ite`s. `rest` is bound once outside the chain. -/ -partial def elabDoIfChain (branches : Array (Term × TSyntax ``doSeq)) +meta partial def elabDoIfChain (branches : Array (Term × TSyntax ``doSeq)) (elseSeq : TSyntax ``doSeq) (rest : List DoElem) : ElabM Expr := do let elabAtType (ty : Expr) : ElabM Expr := do let some α := ty.getAppArgs[0]? @@ -487,7 +487,7 @@ partial def elabDoIfChain (branches : Array (Term × TSyntax ``doSeq)) /-- Elaborate a `match`. Drives Lean's match elaborator with `_` in each arm body, then fills the resulting per-arm mvars by elaborating the original `doSeq`s directly in the mvar's local context -/ -partial def elabDoMatch +meta partial def elabDoMatch (gen? : Option (TSyntax [`Lean.Parser.Term.trueVal, `Lean.Parser.Term.falseVal])) (motive? : Option (TSyntax ``Term.motive)) (discrs : Array (TSyntax ``Term.matchDiscr)) @@ -536,17 +536,17 @@ partial def elabDoMatch instantiateMVars matchExpr elabMonadicAsDoElem elabAtType rest -partial def elabDoSeqCore : List DoElem → ElabM Expr +meta partial def elabDoSeqCore : List DoElem → ElabM Expr | [] => throwError "unexpected empty `do` block" | elem :: rest => elabDoElem elem rest end -def elabDoSeq (doSeq : TSyntax ``doSeq) : ElabM Expr := +meta def elabDoSeq (doSeq : TSyntax ``doSeq) : ElabM Expr := getDoElems doSeq >>= fun elems => elabDoSeqCore elems /-- Option to toggle the new Aeneas `do` elaborator -/ -register_option Aeneas.customDoElab : Bool := { +meta register_option Aeneas.customDoElab : Bool := { defValue := true descr := "Use the custom Aeneas `do` elaborator" } @@ -555,7 +555,7 @@ register_option Aeneas.customDoElab : Bool := { `Aeneas.Std.Result _` blocks when `Aeneas.newDoElab` is set; otherwise falls back to Lean's default. -/ @[term_elab «do»] -def elabDo : TermElab := fun stx expectedType? => do +meta def elabDo : TermElab := fun stx expectedType? => do let useNewElab ← do let some expectedType := expectedType? | pure false let expectedType ← instantiateMVars =<< whnf expectedType diff --git a/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean b/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean index 3e91bd17f..d0092086f 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Bvify/Bvify.lean @@ -25,17 +25,48 @@ structure Config where nonLin : Bool := true -- We use the non linear lemmas by default saturationPasses := 3 +meta section declare_config_elab elabConfig Config +end /- Simp procedures -/ + +/- Builtin simprocs cannot be added to the `bvify` set directly via `attribute`. -/ +simproc ↓ [bvify] reduceIte' (ite _ _ _) := reduceIte +simproc [bvify] Nat.reduceLeDiff' ((_ : Nat) ≤ _) := Nat.reduceLeDiff +simproc [bvify] Nat.reduceLT' ((_ : Nat) < _) := Nat.reduceLT +simproc [bvify] Nat.reduceGT' ((_ : Nat) > _) := Nat.reduceGT +dsimproc [bvify] Nat.reduceBEq' ((_ : Nat) == _) := Nat.reduceBEq +dsimproc [bvify] Nat.reduceBNe' ((_ : Nat) != _) := Nat.reduceBNe +dsimproc [bvify] Nat.reducePow' ((_ ^ _ : Nat)) := Nat.reducePow +dsimproc [bvify] Nat.reduceAdd' ((_ + _ : Nat)) := Nat.reduceAdd +dsimproc [bvify] Nat.reduceSub' ((_ - _ : Nat)) := Nat.reduceSub +dsimproc [bvify] Nat.reduceMul' ((_ * _ : Nat)) := Nat.reduceMul +dsimproc [bvify] Nat.reduceDiv' ((_ / _ : Nat)) := Nat.reduceDiv +dsimproc [bvify] Nat.reduceMod' ((_ % _ : Nat)) := Nat.reduceMod +simproc [bvify] Int.reduceLT' ((_ : Int) < _) := Int.reduceLT +simproc [bvify] Int.reduceLE' ((_ : Int) ≤ _) := Int.reduceLE +simproc [bvify] Int.reduceGT' ((_ : Int) > _) := Int.reduceGT +simproc [bvify] Int.reduceGE' ((_ : Int) ≥ _) := Int.reduceGE +simproc [bvify] Int.reduceEq' ((_ : Int) = _) := Int.reduceEq +simproc [bvify] Int.reduceNe' ((_ : Int) ≠ _) := Int.reduceNe +dsimproc [bvify] Int.reduceBEq' ((_ : Int) == _) := Int.reduceBEq +dsimproc [bvify] Int.reduceBNe' ((_ : Int) != _) := Int.reduceBNe +dsimproc [bvify] Int.reducePow' ((_ : Int) ^ (_ : Nat)) := Int.reducePow +dsimproc [bvify] Int.reduceAdd' ((_ + _ : Int)) := Int.reduceAdd +dsimproc [bvify] Int.reduceSub' ((_ - _ : Int)) := Int.reduceSub +dsimproc [bvify] Int.reduceMul' ((_ * _ : Int)) := Int.reduceMul +dsimproc [bvify] Int.reduceDiv' ((_ / _ : Int)) := Int.reduceDiv +dsimproc [bvify] Int.reduceMod' ((_ % _ : Int)) := Int.reduceMod +dsimproc [bvify] Int.reduceNegSucc' (Int.negSucc _) := Int.reduceNegSucc +dsimproc [bvify] Int.reduceNeg' ((- _ : Int)) := Int.reduceNeg +dsimproc [bvify] Int.reduceToNat' (Int.toNat _) := Int.reduceToNat +dsimproc [bvify] BitVec.reduceMul' ((_ * _ : BitVec _)) := BitVec.reduceMul +dsimproc [bvify] BitVec.reduceAdd' ((_ + _ : BitVec _)) := BitVec.reduceAdd +dsimproc [bvify] BitVec.reduceSub' ((_ - _ : BitVec _)) := BitVec.reduceSub +dsimproc [bvify] BitVec.reduceMod' ((_ % _ : BitVec _)) := BitVec.reduceMod +dsimproc [bvify] BitVec.reduceDiv' ((_ / _ : BitVec _)) := BitVec.reduceDiv attribute [bvify] - reduceIte - Nat.reduceLeDiff Nat.reduceLT Nat.reduceGT Nat.reduceBEq Nat.reduceBNe - Nat.reducePow Nat.reduceAdd Nat.reduceSub Nat.reduceMul Nat.reduceDiv Nat.reduceMod - Int.reduceLT Int.reduceLE Int.reduceGT Int.reduceGE Int.reduceEq Int.reduceNe Int.reduceBEq Int.reduceBNe - Int.reducePow Int.reduceAdd Int.reduceSub Int.reduceMul Int.reduceDiv Int.reduceMod - Int.reduceNegSucc Int.reduceNeg Int.reduceToNat - BitVec.reduceMul BitVec.reduceAdd BitVec.reduceSub BitVec.reduceMod BitVec.reduceDiv Nat.dvd_iff_mod_eq_zero BitVec.ofNat_or BitVec.ofNat_and @@ -288,7 +319,7 @@ theorem UScalar.le_equiv_bv_le {ty : UScalarTy} (x y : UScalar ty) : x ≤ y ↔ @[bvify] theorem U128.le_bv (x y : U128) : x ≤ y ↔ x.bv ≤ y.bv := by rfl @[bvify] theorem Usize.le_bv (x y : Usize) : x ≤ y ↔ x.bv ≤ y.bv := by rfl -def bvifyAddSimpThms (n : Expr) : TacticM (Array FVarId) := do +meta def bvifyAddSimpThms (n : Expr) : TacticM (Array FVarId) := do let addThm (thName : Name) : TacticM FVarId := do let thm ← mkAppM thName #[n] Utils.addDeclTac (← Utils.mkFreshAnonPropUserName) thm (← inferType thm) (asLet := false) fun thm => pure thm.fvarId! @@ -298,16 +329,16 @@ def bvifyAddSimpThms (n : Expr) : TacticM (Array FVarId) := do let eq_iff ← addThm ``BitVec.iff_ofNat_eq' pure #[le_iff, lt_iff, lt_max_iff, eq_iff] -def bvifySimpConfig : Simp.Config := {maxDischargeDepth := 2, failIfUnchanged := false} +meta def bvifySimpConfig : Simp.Config := {maxDischargeDepth := 2, failIfUnchanged := false} -def bvifyTacSimp (loc : Utils.Location) : TacticM (Option (Array FVarId)) := do +meta def bvifyTacSimp (loc : Utils.Location) : TacticM (Option (Array FVarId)) := do let args : ScalarTac.CondSimpArgs := { simpThms := #[← bvifySimpExt.getTheorems, ← SimpBoolProp.simpBoolPropSimpExt.getTheorems] simprocs := #[← bvifySimprocExt.getSimprocs, ← SimpBoolProp.simpBoolPropSimprocExt.getSimprocs] } ScalarTac.condSimpTacSimp bvifySimpConfig args loc #[] #[] none -def bvifyTac (config : Config) (n : Expr) (loc : Utils.Location) : TacticM Unit := do +meta def bvifyTac (config : Config) (n : Expr) (loc : Utils.Location) : TacticM Unit := do let hypsArgs : ScalarTac.CondSimpArgs := { simpThms := #[← bvifyHypsSimpExt.getTheorems, ← SimpBoolProp.simpBoolPropHypsSimpExt.getTheorems] simprocs := #[← bvifyHypsSimprocExt.getSimprocs, ← SimpBoolProp.simpBoolPropHypsSimprocExt.getSimprocs] @@ -348,7 +379,7 @@ with an `have` (e.g., `have h' : BitVec.ofNat n a < BitVec.ofNat n b := ...`), a -/ syntax (name := bvify) "bvify " colGt Parser.Tactic.optConfig term (location)? : tactic -def parseBvify : TSyntax ``bvify -> TacticM (Config × Expr × Utils.Location) +meta def parseBvify : TSyntax ``bvify -> TacticM (Config × Expr × Utils.Location) | `(tactic| bvify $config $n:term $[$loc:location]?) => do let config ← elabConfig config -- TODO: if we forget the number of bits the error messages are spurious diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean b/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean index 6a50811b4..e23f3ebc6 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpListsScalar.lean @@ -13,7 +13,7 @@ The `simp_lists_scalar` tactic is a combination of `simp_lists` and `simp_scalar open Lean Lean.Meta Lean.Parser.Tactic Lean.Elab.Tactic -def simpListsScalarTac (config : ScalarTac.CondSimpTacConfig) +meta def simpListsScalarTac (config : ScalarTac.CondSimpTacConfig) (args : ScalarTac.CondSimpPartialArgs) (loc : Utils.Location) : TacticM Unit := do let addSimpThms : TacticM (Array FVarId) := pure #[] let hypsArgs : ScalarTac.CondSimpArgs := { @@ -70,7 +70,7 @@ and `@[simp_scalar_safe]`). -/ syntax (name := simp_lists) "simp_lists_scalar" Parser.Tactic.optConfig ("[" (term<|>"*"),* "]")? (location)? : tactic -def parseSimpListsScalar : +meta def parseSimpListsScalar : TSyntax ``simp_lists -> TacticM (ScalarTac.CondSimpTacConfig × ScalarTac.CondSimpPartialArgs × Utils.Location) | `(tactic| simp_lists_scalar $config $[[$args,*]]? $[$loc:location]?) => do let config ← ScalarTac.elabCondSimpTacConfig config From 45e86fdc8e4e61fc91d99474f539961a12ddf3a3 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Thu, 23 Jul 2026 18:36:32 +0200 Subject: [PATCH 19/40] delab --- backends/lean/Aeneas/Do/Delab.lean | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backends/lean/Aeneas/Do/Delab.lean b/backends/lean/Aeneas/Do/Delab.lean index b5e85fd6a..343631b95 100644 --- a/backends/lean/Aeneas/Do/Delab.lean +++ b/backends/lean/Aeneas/Do/Delab.lean @@ -15,7 +15,7 @@ namespace Delab /-- `Std.uncurry (fun x₁ … xₙ => body) val` → `let (x₁, …, xₙ) := val; body`. -/ @[delab app.Aeneas.Std.uncurry] -def delabUncurryLet : Delab := do +meta def delabUncurryLet : Delab := do unless Aeneas.customDoElab.get (← getOptions) do failure -- only fire when fully applied unless (← getExpr).isAppOfArity ``_root_.Aeneas.Std.uncurry 5 do failure @@ -29,7 +29,7 @@ def delabUncurryLet : Delab := do /-- `T.casesOn val (fun f₁ … fₙ => body)` → `let ⟨f₁, …, fₙ⟩ := val; body` -/ @[delab app] -def delabSingleCtorCasesOn : Delab := do +meta def delabSingleCtorCasesOn : Delab := do unless Aeneas.customDoElab.get (← getOptions) do failure let e ← getExpr let .const (.str typeName "casesOn") _ := e.getAppFn | failure @@ -45,7 +45,7 @@ private structure CtorBindShape where numParams : Nat /-- Recognise `fun _x => T.casesOn _x …` for single-ctor `T ≠ Prod`. -/ -private def parseCtorBind? (arg : Expr) : DelabM CtorBindShape := do +private meta def parseCtorBind? (arg : Expr) : DelabM CtorBindShape := do let .lam xName _ body _ := arg | failure let .const (.str typeName "casesOn") _ := body.getAppFn | failure let some (.inductInfo { ctors := [_], numParams, .. }) := (← getEnv).find? typeName @@ -54,7 +54,7 @@ private def parseCtorBind? (arg : Expr) : DelabM CtorBindShape := do /-- Walk a `Bind.bind` chain into `doElem`s, recognising tuple and ctor destructuring continuations in addition to plain binds and lets. -/ -partial def aeneasDelabDoElems : DelabM (List DoElem) := do +meta partial def aeneasDelabDoElems : DelabM (List DoElem) := do let e ← getExpr if e.isAppOfArity ``Bind.bind 6 then let α := e.getAppArgs[2]! @@ -114,7 +114,7 @@ open Parser Term /-- Top-level `do`-block delab, restricted to the `Std.Result` monad. -/ @[delab app.Bind.bind] -def aeneasDelabDo : Delab := whenNotPPOption getPPExplicit <| whenPPOption getPPNotation do +meta def aeneasDelabDo : Delab := whenNotPPOption getPPExplicit <| whenPPOption getPPNotation do unless Aeneas.customDoElab.get (← getOptions) do failure let e ← getExpr -- only use the new `do` delaborator for `Result _` do blocks From c7e067c31184c7aec8f2b990d1838def135178a4 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Thu, 23 Jul 2026 19:31:14 +0200 Subject: [PATCH 20/40] expose --- backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean | 1 + backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean b/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean index 528028f80..c1db76d6c 100644 --- a/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Conv/Bvify/Lemmas.lean @@ -1,6 +1,7 @@ module public import Aeneas.Tactic.Conv.Bvify.Bvify public import Aeneas.Tactic.Simp.SimpScalar +import all Init.Data.Nat.Power2.Basic public section @[bvify] diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean index fcb6709be..ee52ba703 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpScalar/Lemmas.lean @@ -133,7 +133,7 @@ be discharged by `simp`. -/ /-- Computable variant of `isPowerOfTwo`. -/ -@[scalar_tac_simps, simp_scalar_safe] +@[scalar_tac_simps, simp_scalar_safe, expose] def Nat.isPowerOfTwo' (n : Nat) : Bool := 2 ^ n.log2 = n example : Nat.isPowerOfTwo' 65536 := by simp [scalar_tac_simps] From 626295b362df4cba38e411c6e5be065ad4f5d925 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Thu, 23 Jul 2026 22:41:59 +0200 Subject: [PATCH 21/40] bvtac --- backends/lean/Aeneas/Std/WP.lean | 2 +- .../Aeneas/Tactic/Solver/BvTac/BvTac.lean | 11 ++- backends/lean/Aeneas/Tactic/Step/Step.lean | 89 ++++++++++--------- 3 files changed, 53 insertions(+), 49 deletions(-) diff --git a/backends/lean/Aeneas/Std/WP.lean b/backends/lean/Aeneas/Std/WP.lean index 2200d078e..bfb5a905e 100644 --- a/backends/lean/Aeneas/Std/WP.lean +++ b/backends/lean/Aeneas/Std/WP.lean @@ -109,7 +109,7 @@ theorem spec_bind {α β} {k : α -> Result β} {Pₖ : Post β} {m : Result α} def curry {α β γ} (f : α × β → γ) (x : α) : β → γ := fun y => f (x, y) /-- Implication -/ -def imp (P Q : Prop) : Prop := P → Q +@[expose] def imp (P Q : Prop) : Prop := P → Q @[simp] theorem imp_and_iff (P0 P1 Q : Prop) : imp (P0 ∧ P1) Q ↔ P0 → imp P1 Q := by simp [imp] diff --git a/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean b/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean index dc9f5f552..4f24de479 100644 --- a/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/BvTac/BvTac.lean @@ -1,5 +1,6 @@ module public import Aeneas.Tactic.Conv.Bvify +public meta import Aeneas.Tactic.Conv.Bvify.Bvify public import Aeneas.Std public import Aeneas.Tactic.Solver.BvTac.Init public section @@ -11,17 +12,19 @@ open Bvify Utils structure Config extends Lean.Elab.Tactic.BVDecide.Frontend.BVDecideConfig, Bvify.Config where +meta section declare_config_elab elabConfig Config +end -def disjConj : Std.HashSet Name := Std.HashSet.ofList [ +meta def disjConj : Std.HashSet Name := Std.HashSet.ofList [ ``And, ``Or ] -def arithConsts : Std.HashSet Name := Std.HashSet.ofList [ +meta def arithConsts : Std.HashSet Name := Std.HashSet.ofList [ ``BEq.beq, ``LT.lt, ``LE.le, ``GT.gt, ``GE.ge ] -partial def getn : TacticM Expr := do +meta partial def getn : TacticM Expr := do let mgoal ← getMainGoal let goalTy ← instantiateMVars (← mgoal.getType) let raiseError : TacticM Expr := @@ -51,7 +54,7 @@ partial def getn : TacticM Expr := do raiseError aux goalTy -partial def bvTacPreprocess (config : Config) (n : Option Expr): TacticM Unit := do +meta partial def bvTacPreprocess (config : Config) (n : Option Expr): TacticM Unit := do Elab.Tactic.focus do trace[BvTac] "Original goal: {← getMainGoal}" /- First try simplifying the goal - if it is an (in-)equality between scalars, it may get diff --git a/backends/lean/Aeneas/Tactic/Step/Step.lean b/backends/lean/Aeneas/Tactic/Step/Step.lean index 531649fc0..57455e6d9 100644 --- a/backends/lean/Aeneas/Tactic/Step/Step.lean +++ b/backends/lean/Aeneas/Tactic/Step/Step.lean @@ -26,12 +26,12 @@ a bug and doesn't give the proper arguments: this way we make sure tactics like will not crash if there is a bug in the code which adds the pretty equality (this is only useful information for the user). -/ -@[irreducible] def prettyMonadEq {α : Type u} {β : Type v} (_ : Std.Result α) (_ : β) : Type := Unit +@[irreducible, expose] def prettyMonadEq {α : Type u} {β : Type v} (_ : Std.Result α) (_ : β) : Type := Unit macro:max "[> " "let" y:term " ← " x:term " <]" : term => `(prettyMonadEq $x $y) @[app_unexpander prettyMonadEq] -def unexpPrettyMonadEqofNat : Lean.PrettyPrinter.Unexpander | `($_ $x $y) => `([> let $y ← $x <]) | _ => throw () +meta def unexpPrettyMonadEqofNat : Lean.PrettyPrinter.Unexpander | `($_ $x $y) => `([> let $y ← $x <]) | _ => throw () example (x y z : Std.U32) (_ : [> let z ← x + y <]) : True := by simp @@ -57,7 +57,7 @@ def eq_imp_prettyMonadEq {α : Type u} {β : Type v} (x : Std.Result α) (y : β @[defeq] theorem iscalar_i64_eq : Std.IScalar .I64 = Std.I64 := by rfl @[defeq] theorem iscalar_i128_eq : Std.IScalar .I128 = Std.I128 := by rfl @[defeq] theorem iscalar_isize_eq : Std.IScalar .Isize = Std.Isize := by rfl -def scalar_eqs := #[ +meta def scalar_eqs := #[ ``uscalar_usize_eq, ``uscalar_u8_eq, ``uscalar_u16_eq, ``uscalar_u32_eq, ``uscalar_u64_eq, ``uscalar_u128_eq, ``iscalar_isize_eq, ``iscalar_i8_eq, ``iscalar_i16_eq, ``iscalar_i32_eq, ``iscalar_i64_eq, ``iscalar_i128_eq ] @@ -79,9 +79,8 @@ attribute [step_simps] Aeneas.Std.bind_assoc_eq attribute [step_simps] Aeneas.Std.uncurry_apply_pair attribute [step_simps] ite_self -- this is sometimes necessary -attribute [step_post_simps] - -- We often see expressions like `Int.ofNat 3` - Int.reduceToNat +-- We often see expressions like `Int.ofNat 3` +dsimproc [step_post_simps] Int.reduceToNat' (Int.toNat _) := Int.reduceToNat inductive TheoremOrLocal where | Theorem (thName : Name) @@ -106,7 +105,7 @@ instance: ToString UsedTheorem where | .localHyp decl => s!"local hypothesis {decl.userName.toString}" | .stepThm name => s!"step theorem {name}" -def toSyntax: UsedTheorem → MetaM Syntax.Term +meta def toSyntax: UsedTheorem → MetaM Syntax.Term | givenExpr e => -- Remark: exprToSyntax doesn't give the expected result Lean.Meta.Tactic.TryThis.delabToRefinableSyntax e @@ -150,17 +149,17 @@ inductive OptTask α where | task (t : Task α) | none -def OptTask.get (x : OptTask α) : Option α := +meta def OptTask.get (x : OptTask α) : Option α := match x with | .task t => some t.get | .none => .none -def OptTask.map (f : α → β) (x : OptTask α) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) : OptTask β := +meta def OptTask.map (f : α → β) (x : OptTask α) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) : OptTask β := match x with | .task t => .task (t.map f prio sync) | .none => .none -def OptTask.bind (x : OptTask α) (f : α → Task β) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) : OptTask β := +meta def OptTask.bind (x : OptTask α) (f : α → Task β) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) : OptTask β := match x with | .task t => .task (t.bind f prio sync) | .none => .none @@ -232,7 +231,7 @@ structure Args where Also looks up which type of spec is being used in the statement, and returns the corresponding SpecInfo -/ -def getFirstBind (goalTy : Expr) : MetaM (Bool × Expr × SpecInfo) := do +meta def getFirstBind (goalTy : Expr) : MetaM (Bool × Expr × SpecInfo) := do forallTelescope goalTy fun nvars goalTy => do let (spec?, args) := goalTy.consumeMData.withApp (fun f args => (f, args)) @@ -256,33 +255,35 @@ def getFirstBind (goalTy : Expr) : MetaM (Bool × Expr × SpecInfo) := do /-- Names introduced by the `do` elaborator's `mkPatContinuation` as a fallback (`_xN`) when no leaf name is available — e.g. all leaves are `_`. These get filtered out so we fall back to spec post-condition names. -/ -def Name.isElabSynthesized : Name → Bool +meta def Name.isElabSynthesized : Name → Bool | .str .anonymous s => s.startsWith "_x" && s.length > 2 && (s.drop 2).all Char.isDigit | _ => false /-- Convert an fvar's user name into the `Option Name` slot used by `step*`. Returns `none` for macro-scoped names and `_xN` placeholders. -/ -def fvarNameSlot (fv : Expr) : MetaM (Option Name) := do +meta def fvarNameSlot (fv : Expr) : MetaM (Option Name) := do let n ← fv.fvarId!.getUserName pure (if n.hasMacroScopes ∨ Name.isElabSynthesized n then none else some n) /-- Used to name post-condition hypotheses introduced by `step`. -/ -def postName (base : Name) (suffix : String) : Name := +meta def postName (base : Name) (suffix : String) : Name := base.getPrefix ++ .mkSimple (base.getString! ++ "_post" ++ suffix) +meta section /-- A generic binary tree with data at the leaves. Underlies `FVarTree` and `NameTree`. -/ inductive BTree (α : Type) where | leaf (val : α) | pair (left right : BTree α) deriving Inhabited, Repr +end /-- Flatten a `BTree` into a left-to-right array of leaf values. -/ -def BTree.flatten {α} : BTree α → Array α +meta def BTree.flatten {α} : BTree α → Array α | .leaf v => #[v] | .pair l r => l.flatten ++ r.flatten /-- Monadic map over the leaf values of a `BTree`. -/ -def BTree.mapM {m} [Monad m] {α β} (f : α → m β) : BTree α → m (BTree β) +meta def BTree.mapM {m} [Monad m] {α β} (f : α → m β) : BTree α → m (BTree β) | .leaf v => return .leaf (← f v) | .pair l r => return .pair (← l.mapM f) (← r.mapM f) @@ -305,7 +306,7 @@ See the examples and state descriptions below for the full specification. - **A** (`uncurryTelescope`): entry — dispatch on `uncurry`/`uncurry'`/lambda/other - **B** (`intoUncurry`): inside uncurry — peel up to 2 lambdas from `f` - **C** (`decomposeFVar`): check if an fvar is destructured by applied `uncurry` in body -/ -partial def uncurryTelescope (e : Expr) (k : Option FVarTree → Expr → MetaM α) : MetaM α := do +meta partial def uncurryTelescope (e : Expr) (k : Option FVarTree → Expr → MetaM α) : MetaM α := do /- ## State A: Entry - `e = uncurry f` or `e = uncurry' f`: go to B(f, ...). - `e = fun x => body`: plain lambda, introduce fvar, call k. @@ -395,19 +396,19 @@ where /-- Analyze a continuation expression to compute a `NameTree`. Wrapper around `uncurryTelescope` that extracts names from the `FVarTree`. -/ -def getContInput (e : Expr) : MetaM NameTree := do +meta def getContInput (e : Expr) : MetaM NameTree := do uncurryTelescope e fun optTree _body => do match optTree with | some tree => tree.mapM fvarNameSlot | none => return .leaf none /-- Extract names from a post-condition or bind-continuation expression. -/ -def getPostNames (e : Expr) : MetaM (Array (Option Name)) := do +meta def getPostNames (e : Expr) : MetaM (Array (Option Name)) := do return (← getContInput e).flatten /-- Extract the variable names from the bind continuation in the current goal. Returns an empty array if the goal is not a bind. -/ -def getBindVarNames : TacticM (Array (Option Name)) := do +meta def getBindVarNames : TacticM (Array (Option Name)) := do try withMainContext do let goalTy ← (← getMainGoal).getType @@ -420,7 +421,7 @@ def getBindVarNames : TacticM (Array (Option Name)) := do /-- Extract the names used in the post-condition of the current goal. The goal should be a valid spec statement, such as `spec program post`. -/ -def getPostNamesFromGoal : TacticM (Array (Option Name)) := do +meta def getPostNamesFromGoal : TacticM (Array (Option Name)) := do try let goalTy ← (← getMainGoal).getType let goalTy ← instantiateMVars goalTy @@ -438,7 +439,7 @@ def getPostNamesFromGoal : TacticM (Array (Option Name)) := do /-- Extract variable names from the current goal for naming `step` outputs. If the goal is a bind (`let x ← ...` or `let (a, b, …) ← …`), extracts the binding names; otherwise falls back to the spec's post-condition. -/ -def getVarNamesFromGoal : TacticM (Array (Option Name) × Option Name) := do +meta def getVarNamesFromGoal : TacticM (Array (Option Name) × Option Name) := do let bindNames ← getBindVarNames if bindNames.any Option.isSome then pure (bindNames, bindNames.findSome? id) @@ -447,7 +448,7 @@ def getVarNamesFromGoal : TacticM (Array (Option Name) × Option Name) := do pure (names, names[0]?.join) /-- Attempt to resolve typeclasses. -/ -def trySolveTypeclasses (mvarsIds : List MVarId) : TacticM (List MVarId) := do +meta def trySolveTypeclasses (mvarsIds : List MVarId) : TacticM (List MVarId) := do withTraceNode `Step (fun _ => pure m!"trySolveTypeclasses") do mvarsIds.filterMapM fun (mvar : MVarId) => do trace[Step] "goal: {mvar}" @@ -479,7 +480,7 @@ def trySolveTypeclasses (mvarsIds : List MVarId) : TacticM (List MVarId) := do The resulting target should be of the shape: `qimp_spec P k Q` (or `qimp P Q`) -/ -def tryMatch (info : SpecInfo) (lifting : Option LiftingInfo) (isLet : Bool) (th : Expr) : +meta def tryMatch (info : SpecInfo) (lifting : Option LiftingInfo) (isLet : Bool) (th : Expr) : TacticM (Array MVarId) := do withTraceNode `Step (fun _ => pure m!"tryMatch") do /- Apply the theorem @@ -578,7 +579,7 @@ def tryMatch (info : SpecInfo) (lifting : Option LiftingInfo) (isLet : Bool) (th pure mvarsIds /-- Small helper: introduce the pretty equality (e.g., `[> let z ← x + y <]`) -/ -def introPrettyEquality (args : Args) (fExpr : Expr) (outputFVars : Array Expr) : +meta def introPrettyEquality (args : Args) (fExpr : Expr) (outputFVars : Array Expr) : TacticM Unit := do withTraceNode `Step (fun _ => pure m!"introPrettyEquality") do withMainContext do @@ -602,7 +603,7 @@ are named later in `introOutputs`. NOTE: We are using `cases` to break up the FVar which could be slow for nested goals or when the goal context gets large. Something to keep an eye on. -/ -partial def destructureFVar {α} (goal : MVarId) (fv : FVarId) (tree : BTree α) : +meta partial def destructureFVar {α} (goal : MVarId) (fv : FVarId) (tree : BTree α) : TacticM (Array FVarId × MVarId) := do match tree with | .leaf _ => return (#[fv], goal) @@ -624,7 +625,7 @@ partial def destructureFVar {α} (goal : MVarId) (fv : FVarId) (tree : BTree α) /-- Introduce one universally-quantified output and destructure it according to the tree's shape. The destructured FVars are named later in `introOutputs`. -/ -def introOneSurfaceBinder {α} (goal : MVarId) (tree : BTree α) : +meta def introOneSurfaceBinder {α} (goal : MVarId) (tree : BTree α) : TacticM (Array FVarId × MVarId) := do let tmp ← mkFreshUserName `_x let (fv, goal') ← goal.intro tmp @@ -635,7 +636,7 @@ have shape `qimp_spec P k Q` or `qimp P Q`. Returns the bind continuation `k`'s tree (for `qimp_spec`) or the outer post `Q`'s tree (for `qimp`) -/ -def extractCallSiteTree (goalTy : Expr) : MetaM (Option NameTree) := do +meta def extractCallSiteTree (goalTy : Expr) : MetaM (Option NameTree) := do match_expr goalTy.consumeMData with | Std.WP.qimp_spec _ _ _ k _ => return some (← getContInput k) | Std.WP.qimp _ _ Q => return some (← getContInput Q) @@ -659,7 +660,7 @@ def extractCallSiteTree (goalTy : Expr) : MetaM (Option NameTree) := do If a grind state is provided, it is updated with the newly introduced hypotheses so that subsequent steps can reuse it. -/ -def introOutputs (info : SpecInfo) (args : Args) (fExpr : Expr) (stepState : StepState) : +meta def introOutputs (info : SpecInfo) (args : Args) (fExpr : Expr) (stepState : StepState) : TacticM (Option MainGoal) := do withTraceNode `Step (fun _ => pure m!"introOutputs") do traceGoalWithNode "Initial goal" @@ -845,7 +846,7 @@ def introOutputs (info : SpecInfo) (args : Args) (fExpr : Expr) (stepState : Ste (this is a way of avoiding spurious instantiations). This helps with the second phase. - we then use the other tactic on the preconditions -/ -def trySolvePreconditions (args : Args) (config : Config) +meta def trySolvePreconditions (args : Args) (config : Config) (originalGoal : MVarId) (stepState : StepState) (solvePreconditionTac : Option StepGrindState → TacticM Unit) (newPropGoals : List MVarId) @@ -891,7 +892,7 @@ The main thing we do is simplify the post-conditions. TODO: simplify or remove this function. -/ -def postprocessMainGoal (mainGoal : Option MainGoal) : TacticM (Option MainGoal) := do +meta def postprocessMainGoal (mainGoal : Option MainGoal) : TacticM (Option MainGoal) := do withTraceNode `Step (fun _ => pure m!"postprocessMainGoal") do match mainGoal with | none => pure none @@ -933,7 +934,7 @@ def postprocessMainGoal (mainGoal : Option MainGoal) : TacticM (Option MainGoal) else pure none /-- If the option is set, infer an unresolved postcondition metavariable in the main goal. -/ -def inferPostMainGoal (args : Args) (mainGoal : Option MainGoal) : TacticM (Option MainGoal) := do +meta def inferPostMainGoal (args : Args) (mainGoal : Option MainGoal) : TacticM (Option MainGoal) := do withTraceNode `Step (fun _ => pure m!"inferPostMainGoal") do unless args.inferPost do return mainGoal @@ -946,7 +947,7 @@ def inferPostMainGoal (args : Args) (mainGoal : Option MainGoal) : TacticM (Opti let goal ← inferPost mg.goal (eliminate := fun decl => decl.type.isAppOf ``prettyMonadEq) pure (some { mg with goal := goal }) -def stepWith (info : SpecInfo) (lifting : Option LiftingInfo) (args : Args) (isLet:Bool) (fExpr : Expr) (th : Expr) : +meta def stepWith (info : SpecInfo) (lifting : Option LiftingInfo) (args : Args) (isLet:Bool) (fExpr : Expr) (th : Expr) : TacticM Goals := do withTraceNode `Step (fun _ => pure m!"stepWith") do -- Save the main goal before tryMatch (needed for lazy grind state initialization) @@ -997,21 +998,21 @@ def stepWith (info : SpecInfo) (lifting : Option LiftingInfo) (args : Args) (isL /-- Small utility: if `args` is not empty, return the name of the app in the first arg, if it is a const. -/ -def getFirstArgAppName (args : Array Expr) : MetaM (Option Name) := do +meta def getFirstArgAppName (args : Array Expr) : MetaM (Option Name) := do if args.size = 0 then pure none else args[0]!.withApp fun f _ => do if f.isConst then pure (some f.constName) else pure none -def getFirstArg (args : Array Expr) : Option Expr := do +meta def getFirstArg (args : Array Expr) : Option Expr := do if args.size = 0 then none else some args[0]! /-- Helper: try to apply a theorem. Return the list of post-conditions we introduced if it succeeded. -/ -def tryApply (info : SpecInfo) (lifting : Option LiftingInfo) (args : Args) (isLet:Bool) (fExpr : Expr) (kind : String) (th : Option Expr) : +meta def tryApply (info : SpecInfo) (lifting : Option LiftingInfo) (args : Args) (isLet:Bool) (fExpr : Expr) (kind : String) (th : Option Expr) : TacticM (Option Goals) := do let res ← do match th with @@ -1034,7 +1035,7 @@ def tryApply (info : SpecInfo) (lifting : Option LiftingInfo) (args : Args) (isL spec statment represented by `info` or `none` if it already is the correct spec statement -/ -def getLiftingForThm (info : SpecInfo) (thm : Expr) : MetaM (Option LiftingInfo) := do +meta def getLiftingForThm (info : SpecInfo) (thm : Expr) : MetaM (Option LiftingInfo) := do let thTy ← inferType thm let thTy ← normalizeLetBindings thTy let thOutput ← forallTelescope thTy (fun _ out => return out) @@ -1057,7 +1058,7 @@ def getLiftingForThm (info : SpecInfo) (thm : Expr) : MetaM (Option LiftingInfo) -- TODO: check that they are "compatible" with the goal to avoid a potentially expensive unification -/ -def tryAssumptions (info : SpecInfo) (args : Args) (isLet:Bool) (fExpr : Expr) : +meta def tryAssumptions (info : SpecInfo) (args : Args) (isLet:Bool) (fExpr : Expr) : TacticM (Option (Goals × UsedTheorem)) := do withTraceNode `Step (fun _ => pure m!"tryAssumptions") do run where @@ -1074,7 +1075,7 @@ where catch _ => continue pure none -def stepAsmsOrLookupTheorem (args : Args) (withTh : Option Expr) : +meta def stepAsmsOrLookupTheorem (args : Args) (withTh : Option Expr) : TacticM (Goals × UsedTheorem) := do withMainContext do -- Retrieve the goal @@ -1158,7 +1159,7 @@ def stepAsmsOrLookupTheorem (args : Args) (withTh : Option Expr) : syntax stepArgs := Parser.Tactic.optConfig ("with" term)? ("as" " ⟨ " binderIdent,* " ⟩")? ("by" tacticSeq)? -def parseStepArgs +meta def parseStepArgs : TSyntax ``Aeneas.Step.stepArgs → TacticM (Config × Option Expr × Array (Option Name) × Bool × Option Name × Option Syntax.Tactic) | args@`(stepArgs| $config $[with $pspec:term]? $[as ⟨ $ids,* ⟩]? $[by $byTac]? ) => @@ -1204,7 +1205,7 @@ def parseStepArgs | _ => throwUnsupportedSyntax /-- Use `agrind` after preprocessing goal the goal, in particular to simplify arithmetic expressions. -/ -def evalAGrindWithPreprocess (withGroundSimprocs : Bool) (config : Grind.Config) (nla : Bool) : TacticM Unit := do +meta def evalAGrindWithPreprocess (withGroundSimprocs : Bool) (config : Grind.Config) (nla : Bool) : TacticM Unit := do withTraceNode `Step (fun _ => do pure m!"evalAGrindWithPreprocess") do traceGoalWithNode "before preprocessing" let simpArgs : Simp.SimpArgs ← ScalarTac.getSimpArgs @@ -1227,7 +1228,7 @@ def evalAGrindWithPreprocess (withGroundSimprocs : Bool) (config : Grind.Config) Aeneas.Grind.agrindEval config params mvarId catch e => trace[Step] "Grind failed:\n{e.toMessageData}" -def evalStepCore (config : Config) (keepPretty : Option Name) (withArg : Option Expr) +meta def evalStepCore (config : Config) (keepPretty : Option Name) (withArg : Option Expr) (ids : Array (Option Name)) (idsUserProvided : Bool) (postsBasename : Option Name := none) (byTacStx : Option Syntax.Tactic) (stepState : StepState := {}) @@ -1358,7 +1359,7 @@ def evalStepCore (config : Config) (keepPretty : Option Name) (withArg : Option trace[Step] "Step done" return ⟨ goals, usedTheorem ⟩ -def evalStep +meta def evalStep (config : Config) (keepPretty : Option Name) (withArg: Option Expr) (ids: Array (Option Name)) (idsUserProvided : Bool) (postsBasename : Option Name := none) (byTac : Option Syntax.Tactic) @@ -1498,7 +1499,7 @@ syntax optConfig := Parser.Tactic.optConfig syntax (name := letStep) "let" noWs "*" " ⟨ " binderIdent,* " ⟩" colGe " ← " colGe ("[" Parser.Tactic.optConfig " ] ")? ("*?" <|> "*" <|> term) ("by" tacticSeq)? : tactic -def parseLetStep +meta def parseLetStep : TSyntax ``Aeneas.Step.letStep -> TacticM (Config × Option Expr × Bool × Array (Option Name) × Option Name × Option Syntax.Tactic) | args@`(tactic| let* ⟨ $ids,* ⟩ ← $[[$config]]? $pspec $[by $byTac]?) => withMainContext do From 8fa23a054edcc5d3d67411204537102eb29057f2 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 10:26:00 +0200 Subject: [PATCH 22/40] expose more! --- backends/lean/Aeneas/Std/Primitives.lean | 8 ++-- backends/lean/Aeneas/Std/Scalar/Bitwise.lean | 12 +++--- .../Aeneas/Tactic/Simproc/BvSimprocs.lean | 4 +- .../Aeneas/Tactic/Solver/BvTac/Lemmas.lean | 1 + .../lean/Aeneas/Tactic/Step/Deprecated.lean | 28 +++++++------- .../Aeneas/Tactic/Step/DspecInduction.lean | 5 ++- backends/lean/Aeneas/Tactic/Step/Init.lean | 2 +- .../Aeneas/Tactic/Step/StepArraySpec.lean | 4 +- .../lean/Aeneas/Tactic/Step/StepStar.lean | 38 ++++++++++--------- 9 files changed, 53 insertions(+), 49 deletions(-) diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index 566786e23..6a96821d7 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -126,11 +126,11 @@ def Result.ofOption {a : Type u} (x : Option a) (e : Error) : Result a := | div => div -- Allows using Result in do-blocks -instance : Bind Result where +@[expose] instance : Bind Result where bind := bind -- Allows using pure x in do-blocks -instance : Pure Result where +@[expose] instance : Pure Result where pure := fun x => ok x @[simp] theorem bind_ok (x : α) (f : α → Result β) : bind (.ok x) f = f x := by simp [bind] @@ -159,7 +159,7 @@ def bind_eq_iff (x : Result α) (y y' : α → Result β) : ∀ v, x = ok v → y v = y' v := by cases x <;> simp_all -instance : Monad Result where +@[expose] instance : Monad Result where /-! # Partial Fixpoint @@ -192,7 +192,7 @@ directly. `uncurry` is purely internal to Aeneas' elaboration pipeline and should never be directly manipulated by the user. -/ -@[inline] def uncurry {α β γ} (f : α → β → γ) : α × β → γ := +@[inline, expose] def uncurry {α β γ} (f : α → β → γ) : α × β → γ := fun (a, b) => f a b @[simp, grind =] theorem uncurry_apply_pair {α β γ} (f : α → β → γ) (a : α) (b : β) : diff --git a/backends/lean/Aeneas/Std/Scalar/Bitwise.lean b/backends/lean/Aeneas/Std/Scalar/Bitwise.lean index 33e9bebe4..bdda539ee 100644 --- a/backends/lean/Aeneas/Std/Scalar/Bitwise.lean +++ b/backends/lean/Aeneas/Std/Scalar/Bitwise.lean @@ -107,9 +107,9 @@ instance {ty0 ty1} : HShiftRight (IScalar ty0) (IScalar ty1) (Result (IScalar ty /-! Bitwise and -/ -def UScalar.and {ty} (x y : UScalar ty) : UScalar ty := ⟨ x.bv &&& y.bv ⟩ +@[expose] def UScalar.and {ty} (x y : UScalar ty) : UScalar ty := ⟨ x.bv &&& y.bv ⟩ -def IScalar.and {ty} (x y : IScalar ty) : IScalar ty := ⟨ x.bv &&& y.bv ⟩ +@[expose] def IScalar.and {ty} (x y : IScalar ty) : IScalar ty := ⟨ x.bv &&& y.bv ⟩ instance {ty} : HAnd (UScalar ty) (UScalar ty) (UScalar ty) where hAnd x y := UScalar.and x y @@ -120,9 +120,9 @@ instance {ty} : HAnd (IScalar ty) (IScalar ty) (IScalar ty) where /-! Bitwise or -/ -def UScalar.or {ty} (x y : UScalar ty) : UScalar ty := ⟨ x.bv ||| y.bv ⟩ +@[expose] def UScalar.or {ty} (x y : UScalar ty) : UScalar ty := ⟨ x.bv ||| y.bv ⟩ -def IScalar.or {ty} (x y : IScalar ty) : IScalar ty := ⟨ x.bv ||| y.bv ⟩ +@[expose] def IScalar.or {ty} (x y : IScalar ty) : IScalar ty := ⟨ x.bv ||| y.bv ⟩ instance {ty} : HOr (UScalar ty) (UScalar ty) (UScalar ty) where hOr x y := UScalar.or x y @@ -133,9 +133,9 @@ instance {ty} : HOr (IScalar ty) (IScalar ty) (IScalar ty) where /-! Xor -/ -def UScalar.xor {ty} (x y : UScalar ty) : UScalar ty := ⟨ x.bv ^^^ y.bv ⟩ +@[expose] def UScalar.xor {ty} (x y : UScalar ty) : UScalar ty := ⟨ x.bv ^^^ y.bv ⟩ -def IScalar.xor {ty} (x y : IScalar ty) : IScalar ty := ⟨ x.bv ^^^ y.bv ⟩ +@[expose] def IScalar.xor {ty} (x y : IScalar ty) : IScalar ty := ⟨ x.bv ^^^ y.bv ⟩ instance {ty} : HXor (UScalar ty) (UScalar ty) (UScalar ty) where hXor x y := UScalar.xor x y diff --git a/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean b/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean index 2cf23d519..a0ed16814 100644 --- a/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean +++ b/backends/lean/Aeneas/Tactic/Simproc/BvSimprocs.lean @@ -13,7 +13,7 @@ section open Lean Meta in /-- Check if an expression is a numeric literal (Nat or Int, possibly negated). -/ -private def isNumLit : Lean.Expr → Bool +private meta def isNumLit : Lean.Expr → Bool | Lean.Expr.lit (.natVal _) => true | Lean.Expr.app f a => isNumLit f || isNumLit a | Lean.Expr.const ``Nat.zero _ => true @@ -22,7 +22,7 @@ private def isNumLit : Lean.Expr → Bool /-- Check if an expression is a scalar literal (without whnf). Matches the elaborated form of `n#u8`, `n#i32`, etc. which is `U8.ofNat n proof` or `I32.ofInt n proof`. -/ -private def isScalarLit (x : Lean.Expr) : Bool := +private meta def isScalarLit (x : Lean.Expr) : Bool := match x with | Lean.Expr.app (Lean.Expr.app _ value) _ => isNumLit value | _ => false diff --git a/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean b/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean index 7be728fa6..119f7add7 100644 --- a/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean +++ b/backends/lean/Aeneas/Tactic/Solver/BvTac/Lemmas.lean @@ -1,5 +1,6 @@ module public import Aeneas.Tactic.Solver.BvTac.BvTac +import all Init.Data.Nat.Bitwise.Basic public section /-! diff --git a/backends/lean/Aeneas/Tactic/Step/Deprecated.lean b/backends/lean/Aeneas/Tactic/Step/Deprecated.lean index b869b99ae..12557027f 100644 --- a/backends/lean/Aeneas/Tactic/Step/Deprecated.lean +++ b/backends/lean/Aeneas/Tactic/Step/Deprecated.lean @@ -24,12 +24,12 @@ namespace Aeneas.Deprecated open Lean Elab Meta Tactic /-- When `true` (default), using the deprecated `progress` syntax emits a warning. -/ -register_option Aeneas.Deprecated.progressWarning : Bool := { +meta register_option Aeneas.Deprecated.progressWarning : Bool := { defValue := true descr := "Emit warnings when using the deprecated `progress` syntax (renamed to `step`)" } -private def emitProgressWarning (what : String) : CoreM Unit := do +private meta def emitProgressWarning (what : String) : CoreM Unit := do if Aeneas.Deprecated.progressWarning.get (← getOptions) then logWarning m!"`{what}` has been renamed to `{what.replace "progress" "step"}`. \ The `{what}` syntax is deprecated and will be removed in a future version. \ @@ -62,7 +62,7 @@ elab tk:"progress?" args:Step.stepArgs : tactic => do syntax (name := deprecatedProgressStar) "progress" noWs ("*" <|> "*?") StepStar.«step*_args» : tactic @[tactic deprecatedProgressStar] -def evalDeprecatedProgressStarTac : Tactic := fun stx => do +meta def evalDeprecatedProgressStarTac : Tactic := fun stx => do match stx with | `(tactic| progress* $args:«step*_args») => emitProgressWarning "progress*" @@ -88,7 +88,7 @@ syntax (name := deprecatedProgressArraySpec) open Lean.Elab.Command in @[command_elab deprecatedProgressArraySpec] -def evalDeprecatedProgressArraySpec : CommandElab := fun stx => do +meta def evalDeprecatedProgressArraySpec : CommandElab := fun stx => do liftCoreM <| emitProgressWarning "progress_array_spec" match stx with | `($[$vis]? progress_array_spec (name := $thm_name:ident) $array:ident [ $i:ident ]! { $x:ident => $pred:term } by $tac:tacticSeq) => do @@ -111,7 +111,7 @@ These register theorems in the same `step` database as their non-deprecated coun -/ /-- **Deprecated:** Use `@[step]` instead. -/ -private def progressDeprecatedAttrImpl : AttributeImpl where +private meta def progressDeprecatedAttrImpl : AttributeImpl where «name» := `progress descr := "Deprecated: use `step` instead. Adds theorems to the `step` database." add := fun thName stx attrKind => do @@ -121,51 +121,51 @@ private def progressDeprecatedAttrImpl : AttributeImpl where erase := fun thName => do Step.stepAttr.attr.erase thName -initialize _progressDeprecatedAttr : Unit ← +meta initialize _progressDeprecatedAttr : Unit ← registerBuiltinAttribute progressDeprecatedAttrImpl /-- **Deprecated:** Use `@[step_pure]` instead. -/ -private def progressPureDeprecatedAttrImpl : AttributeImpl where +private meta def progressPureDeprecatedAttrImpl : AttributeImpl where «name» := `progress_pure descr := "Deprecated: use `step_pure` instead." add := fun thName stx attrKind => do emitProgressWarning "progress_pure" Step.stepPureAttribute.attr.add thName stx attrKind -initialize _progressPureDeprecatedAttr : Unit ← +meta initialize _progressPureDeprecatedAttr : Unit ← registerBuiltinAttribute progressPureDeprecatedAttrImpl /-- **Deprecated:** Use `@[step_pure_def]` instead. -/ -private def progressPureDefDeprecatedAttrImpl : AttributeImpl where +private meta def progressPureDefDeprecatedAttrImpl : AttributeImpl where «name» := `progress_pure_def descr := "Deprecated: use `step_pure_def` instead." add := fun thName stx attrKind => do emitProgressWarning "progress_pure_def" Step.stepPureDefAttribute.attr.add thName stx attrKind -initialize _progressPureDefDeprecatedAttr : Unit ← +meta initialize _progressPureDefDeprecatedAttr : Unit ← registerBuiltinAttribute progressPureDefDeprecatedAttrImpl /-- **Deprecated:** Use `@[step_simps]` instead. Forwards to `step_simps`. -/ -initialize do +meta initialize do mkSimpAttr `progress_simps "Deprecated: use `step_simps` instead. Forwards to `step_simps`." Step.stepSimpExt /-- **Deprecated:** Use `@[step_pre_simps]` instead. Forwards to `step_pre_simps`. -/ -initialize do +meta initialize do mkSimpAttr `progress_pre_simps "Deprecated: use `step_pre_simps` instead. Forwards to `step_pre_simps`." Step.stepPreSimpExt /-- **Deprecated:** Use `@[step_post_simps]` instead. Forwards to `step_post_simps`. -/ -initialize do +meta initialize do mkSimpAttr `progress_post_simps "Deprecated: use `step_post_simps` instead. Forwards to `step_post_simps`." Step.stepPostSimpExt /-- **Deprecated:** Use `@[step_post_simps_proc]` instead. Forwards to `step_post_simps_proc`. -/ -initialize do +meta initialize do Simp.mkSimprocAttr `progress_post_simps_proc "Deprecated: use `step_post_simps_proc` instead. Forwards to `step_post_simps_proc`." Step.stepPostSimprocExt `Aeneas.Deprecated.progressPostSimpsProcDeprecated diff --git a/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean b/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean index c1d8e9176..159b6899d 100644 --- a/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean +++ b/backends/lean/Aeneas/Tactic/Step/DspecInduction.lean @@ -9,6 +9,7 @@ public import AeneasMeta.Async public import Aeneas.Tactic.Solver.Grind.Init public import Aeneas.Tactic.Step.InferPost public import Aeneas.Tactic.Step.Step +import all Init.Internal.Order.Basic public section /- Tactic for unfolding partial_fixpoint definitions with fixpoint_induct. @@ -98,14 +99,14 @@ theorem WP_func_admissible (α β : Type) (arg) (post) apply Lean.Order.admissible_flatOrder simp only [WP.dspec] -def getParamNames (ty : Expr) : MetaM (Array Name) := do +meta def getParamNames (ty : Expr) : MetaM (Array Name) := do forallTelescope ty fun xs _ => do xs.mapM fun x => do let localDecl ← x.fvarId!.getDecl return localDecl.userName -- given a function type, return list of input types -def getInputTypes (ty : Expr) : List Expr := +meta def getInputTypes (ty : Expr) : List Expr := match ty with | .forallE _ ty body _ => .cons ty (getInputTypes body) | _ => [] diff --git a/backends/lean/Aeneas/Tactic/Step/Init.lean b/backends/lean/Aeneas/Tactic/Step/Init.lean index a6cf3e864..6d1f6bfa0 100644 --- a/backends/lean/Aeneas/Tactic/Step/Init.lean +++ b/backends/lean/Aeneas/Tactic/Step/Init.lean @@ -1034,7 +1034,7 @@ meta initialize stepPureDefAttribute : StepPureDefSpecAttr ← do open Tactic /-! # Logging Utils -/ -def traceGoalWithNode (msg : String) : TacticM Unit := Utils.traceGoalWithNode `Step msg +meta def traceGoalWithNode (msg : String) : TacticM Unit := Utils.traceGoalWithNode `Step msg end Step diff --git a/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean b/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean index 849e1a34c..3fa97a03f 100644 --- a/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean +++ b/backends/lean/Aeneas/Tactic/Step/StepArraySpec.lean @@ -38,7 +38,7 @@ namespace Std open Result WP -def Array.allIdx (f : Usize → α → Bool) (ls : List α) (i : Nat := 0) : Bool := +meta def Array.allIdx (f : Usize → α → Bool) (ls : List α) (i : Nat := 0) : Bool := match ls with | [] => True | hd :: tl => @@ -104,7 +104,7 @@ syntax (name := stepArraySpec) " { " ident " => " term " } " " by " tacticSeq : command open Lean Lean.Elab Lean.Parser.Command Lean.Elab.Command in -def parseStepArraySpec +meta def parseStepArraySpec : TSyntax ``stepArraySpec -> CommandElabM Unit := fun stx => do match stx with | `($[$vis]? step_array_spec (name := $thm_name:ident) $array:ident [ $i:ident ]! { $x:ident => $pred:term } by $tac:tacticSeq) => do diff --git a/backends/lean/Aeneas/Tactic/Step/StepStar.lean b/backends/lean/Aeneas/Tactic/Step/StepStar.lean index ccca5ff21..8316dd7bd 100644 --- a/backends/lean/Aeneas/Tactic/Step/StepStar.lean +++ b/backends/lean/Aeneas/Tactic/Step/StepStar.lean @@ -8,7 +8,7 @@ namespace Aeneas /-- Given a goal of the shape `spec (match ... with ...) post`, perform a case split and introduce an equality. -/ -def esplitMatchAtSpec (h : Name) (names : Option (List (List (Option Name)))) : +meta def esplitMatchAtSpec (h : Name) (names : Option (List (List (Option Name)))) : TacticM (List (Array FVarId × FVarId × MVarId)) := do withTraceNode `Utils (fun _ => do pure m!"esplitMatchAtSpec") do focus do withMainContext do @@ -45,7 +45,7 @@ def esplitMatchAtSpec (h : Name) (names : Option (List (List (Option Name)))) : -- pure goals -def esplitMatchAtSpecTac (h : Name) (names : Option (List (List (Option Name)))) : +meta def esplitMatchAtSpecTac (h : Name) (names : Option (List (List (Option Name)))) : TacticM (List (MVarId)) := do (← esplitMatchAtSpec h names).mapM fun (_, _, g) => pure g @@ -62,7 +62,7 @@ theorem dite_false : (dite False t e) = e (by simp) := by simp /-- Split an `if then else` in a spec predicate: `⊢ spec (if ... then ... else ...) post` -/ -def esplitIteAtSpec (h : Name) : TacticM (List (FVarId × MVarId)) := do +meta def esplitIteAtSpec (h : Name) : TacticM (List (FVarId × MVarId)) := do focus do withMainContext do let tgt ← getMainTarget tgt.consumeMData.withApp fun spec? args => do @@ -98,7 +98,7 @@ def esplitIteAtSpec (h : Name) : TacticM (List (FVarId × MVarId)) := do setGoals (goals.map Prod.snd) pure goals -def esplitIteAtSpecTac (h : Name) : TacticM (List MVarId) := do +meta def esplitIteAtSpecTac (h : Name) : TacticM (List MVarId) := do pure ((← esplitIteAtSpec h).map Prod.snd) elab "spec_split_if": tactic => do setGoals (← esplitIteAtSpecTac (← mkFreshUserName `h)) @@ -138,7 +138,7 @@ example (b : Bool) : Std.WP.spec (if h: b then .ok 0 else .ok 1) (fun _ => True) /-- Given a goal of the shape `spec (match ... with ...) post` or `spec (if ... then ... else ...)`, perform a case split. -/ -def esplitAtSpec (h : Name) (names : Option (List (List (Option Name)))) : TacticM (List (Array FVarId × FVarId × MVarId)) := do +meta def esplitAtSpec (h : Name) (names : Option (List (List (Option Name)))) : TacticM (List (Array FVarId × FVarId × MVarId)) := do withTraceNode `Utils (fun _ => do pure m!"esplitAtSpec") do focus do withMainContext do let tgt ← getMainTarget @@ -155,13 +155,14 @@ def esplitAtSpec (h : Name) (names : Option (List (List (Option Name)))) : Tacti trace[Utils] "splitting an if then else" pure ((← esplitIteAtSpec h).map fun (h, g) => (#[], h, g)) -def esplitAtSpecTac (h : Name) : TacticM (List MVarId) := do +meta def esplitAtSpecTac (h : Name) : TacticM (List MVarId) := do pure ((← esplitAtSpec h (some [])).map fun (_, _, g) => g) elab "spec_split": tactic => do setGoals (← esplitAtSpecTac (← mkFreshUserName `h)) elab "spec_split" "as" h:ident : tactic => do setGoals (← esplitAtSpecTac h.getId) namespace Bifurcation +meta section /-- Expression on which a branch depends -/ structure Discr where @@ -239,8 +240,9 @@ instance: ToMessageData Info where let discr := MessageData.ofArray <| discrs.map (ToMessageData.toMessageData) let branches := MessageData.ofArray <| branches.map (ToMessageData.toMessageData) m!"(info {kind} {discr} {branches})" +end -def Info.ofExpr(e: Expr): MetaM (Option Info) := do +meta def Info.ofExpr(e: Expr): MetaM (Option Info) := do let e := e.consumeMData if e.isIte || e.isDIte then let kind := if e.isIte then .ite else .dite @@ -282,7 +284,7 @@ def Info.ofExpr(e: Expr): MetaM (Option Info) := do else return none else return none -def Info.toExpr(info: Info): Expr := +meta def Info.toExpr(info: Info): Expr := let fn := Expr.const info.matcher info.uLevels let args := info.params ++ #[info.motive] ++ @@ -294,7 +296,7 @@ end Bifurcation namespace StepStar -abbrev traceGoalWithNode := Step.traceGoalWithNode +meta abbrev traceGoalWithNode := Step.traceGoalWithNode structure Config where stepConfig : Step.Config @@ -310,12 +312,12 @@ inductive TaskOrDone α where | task (x : Task α) | done (x : α) -def TaskOrDone.get (x : TaskOrDone α) : α := +meta def TaskOrDone.get (x : TaskOrDone α) : α := match x with | .task x => x.get | .done x => x -def TaskOrDone.mk (x : α) : TaskOrDone α := .done x +meta def TaskOrDone.mk (x : α) : TaskOrDone α := .done x inductive BranchArg where | case (stx : TSyntax `Lean.Parser.Tactic.caseArg) @@ -339,14 +341,14 @@ structure Result where unassignedVars : Array MVarId subgoals: Array MVarId -instance: Append Info where +meta instance: Append Info where append inf1 inf2 := { script := .seq inf1.script inf2.script, subgoals := inf1.subgoals ++ inf2.subgoals, unassignedVars := inf1.unassignedVars ++ inf2.unassignedVars, } -def nameToBinderIdent (n : Name) : TSyntax `Lean.binderIdent := +meta def nameToBinderIdent (n : Name) : TSyntax `Lean.binderIdent := if n.isInternalDetail then mkNode ``Lean.binderIdent #[mkHole mkNullNode] else mkNode ``Lean.binderIdent #[mkIdent n] @@ -354,7 +356,7 @@ def nameToBinderIdent (n : Name) : TSyntax `Lean.binderIdent := /-- Convert the script into syntax. This is a blocking operation: it waits for all the sub-components of the script to be generated. -/ -partial def Script.toSyntax (script : Script) : MetaM (Array Syntax.Tactic) := do +meta partial def Script.toSyntax (script : Script) : MetaM (Array Syntax.Tactic) := do match script with | .split splitStx branches => let branches ← branches.mapM fun (caseArgs, branch) => do @@ -384,7 +386,7 @@ inductive TargetKind where | unknown /- Smaller helper which we use to check in which situation we are -/ -def analyzeTarget : TacticM TargetKind := do +meta def analyzeTarget : TacticM TargetKind := do withTraceNode `Step (fun _ => do pure m!"analyzeTarget") do try let goalTy ← (← getMainGoal).getType @@ -411,7 +413,7 @@ def analyzeTarget : TacticM TargetKind := do trace[Step] "exception caught" pure .unknown -partial def evalStepStar (cfg: Config) (fuel : Option Nat) : TacticM Result := +meta partial def evalStepStar (cfg: Config) (fuel : Option Nat) : TacticM Result := withMainContext do focus do withTraceNode `Step (fun _ => do pure m!"evalStepStar") do -- Initialize the step state (grind threading) @@ -864,7 +866,7 @@ where Lean.mkNode ``Lean.Parser.Tactic.caseArg #[tag, mkNullNode (args := binderIdents)] syntax «step*_args» := (num)? Lean.Parser.Tactic.optConfig ("by" tacticSeq)? -def parseArgs: TSyntax `Aeneas.StepStar.«step*_args» → TermElabM (Config × Option Nat) +meta def parseArgs: TSyntax `Aeneas.StepStar.«step*_args» → TermElabM (Config × Option Nat) | `(«step*_args»| $(fuel)? $config $[by $preconditionTac:tacticSeq]?) => do withTraceNode `Step (fun _ => pure m!"parseArgs") do let fuel ← do match fuel with @@ -893,7 +895,7 @@ Its variant `step*?` allows automatically generating the equivalent proof script syntax (name := stepStar) "step" noWs ("*" <|> "*?") «step*_args»: tactic @[tactic stepStar, inherit_doc Step.step] -def evalStepStarTac : Tactic := fun stx => do +meta def evalStepStarTac : Tactic := fun stx => do match stx with | `(tactic| step* $args:«step*_args») => let (cfg, fuel) ← parseArgs args From 2c653431981c1f7645d9cb3e88892451f5bb336a Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 10:45:46 +0200 Subject: [PATCH 23/40] expose public --- src/Translate.ml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Translate.ml b/src/Translate.ml index 778840305..08733b5bc 100644 --- a/src/Translate.ml +++ b/src/Translate.ml @@ -1377,9 +1377,7 @@ let extract_file (config : gen_config) (ctx : gen_ctx) (fi : extract_file_info) List.iter (fun m -> Printf.fprintf out "public import %s\n" m) fi.custom_includes; - (* Everything below is part of the module's public interface (module - system). *) - Printf.fprintf out "public section\n"; + Printf.fprintf out "@[expose] public section\n"; (* Always open the Primitives namespace *) Printf.fprintf out "open Aeneas Aeneas.Std Result ControlFlow Error\n"; (* It happens that we generate duplicated namespaces, like `betree.betree`. From 543ff847c9a859d10b571dbc64535622b13de878 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 10:50:41 +0200 Subject: [PATCH 24/40] less todo --- backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean | 4 ---- 1 file changed, 4 deletions(-) diff --git a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean index cebff98e4..1a78d8046 100644 --- a/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean +++ b/backends/lean/Aeneas/Tactic/Elab/TraitDefault/Init.lean @@ -322,8 +322,6 @@ meta def resolveStructFields (value : Expr) (selfFvarId : FVarId) (type : Expr) compiles, and applies any declaration attributes (e.g., `@[simp]`). -/ elab mods:declModifiers "impl_def " id:declId sig:optDeclSig val:declVal : command => do let modifiers ← elabModifiers mods - /- TODO: when migrating to the module system, recover the old visibility. Better style would - be to expose less and provide relevant theorems. -/ let modifiers := if modifiers.visibility matches .regular then { modifiers with visibility := .public } else modifiers @@ -396,8 +394,6 @@ elab mods:declModifiers "impl_def " id:declId sig:optDeclSig val:declVal : comma } let docCtx := (← getLCtx, ← getLocalInstances) - /- TODO: when migrating to the module system, recover the old visibility. Better style would - be to expose less and provide relevant theorems. -/ withExporting (isExporting := true) do addAndCompileNonRec docCtx preDef From 0f1aaefac430c8e981e007b85b648b273bf3d632 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 10:52:46 +0200 Subject: [PATCH 25/40] directly --- .../lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean index 6aeb49df8..78c6c3a49 100644 --- a/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean +++ b/backends/lean/Aeneas/Tactic/Simp/SimpBoolProp/SimpBoolProp.lean @@ -12,9 +12,7 @@ namespace Aeneas.SimpBoolProp open Lean Lean.Meta Lean.Parser.Tactic Lean.Elab.Tactic -/-- TODO: `reduceIte` can't be added to a custom simp set via `attribute` under the module system -since builtin simprocs are not `meta`-marked, so `ensureAttrDeclIsMeta` rejects them. So here we -register a local `meta` version of `reduceIte`. Perhaps there is a better way to do this. -/ +/-- TODO: builtin simprocs can't be directly added under the module system. -/ simproc ↓ [simp_bool_prop] reduceIte' (ite _ _ _) := reduceIte attribute [simp_bool_prop] From 7fdc059f6bded47db2feb3e194e29a6626d78213 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 10:54:15 +0200 Subject: [PATCH 26/40] concise --- backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean index fdb802a75..ffbd63983 100644 --- a/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean +++ b/backends/lean/Aeneas/Tactic/Solver/ScalarTac/ScalarTac.lean @@ -102,7 +102,7 @@ attribute [scalar_tac_simps] lt_inf_iff le_inf_iff Fin.is_le' -/- TODO: The core builtin simprocs cannot be added to the `scalar_tac_simps` set directly via `attribute` under the module system. Instead we register, for each, a local `meta` wrapper. -/ +/-- TODO: builtin simprocs can't be directly added under the module system. -/ simproc ↓ [scalar_tac_simps] reduceIte' (ite _ _ _) := reduceIte simproc [scalar_tac_simps] Nat.reduceLeDiff' ((_ : Nat) ≤ _) := Nat.reduceLeDiff simproc [scalar_tac_simps] Nat.reduceLT' ((_ : Nat) < _) := Nat.reduceLT From ad173a37ba96286727fec41ed2adf30ee477cb6f Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 10:57:34 +0200 Subject: [PATCH 27/40] opt --- src/Translate.ml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Translate.ml b/src/Translate.ml index 08733b5bc..329ae4f5d 100644 --- a/src/Translate.ml +++ b/src/Translate.ml @@ -1312,8 +1312,6 @@ let extract_file (config : gen_config) (ctx : gen_ctx) (fi : extract_file_info) (* Create the header *) (match Config.backend () with | Lean -> - (* Opt into the Lean module system (the [module] keyword must be the first - command of the file). *) Printf.fprintf out "module\n"; Printf.fprintf out "-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS\n"; Printf.fprintf out "-- [%s]%s\n" fi.rust_module_name fi.custom_msg From 71ce065fcb62dd2cfb3abbe665e40fb0f3f9051d Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 10:59:22 +0200 Subject: [PATCH 28/40] write --- src/Translate.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Translate.ml b/src/Translate.ml index 329ae4f5d..42229fc32 100644 --- a/src/Translate.ml +++ b/src/Translate.ml @@ -2152,7 +2152,7 @@ let extract_translated_crate (filename : string) (dest_dir : string) if !Config.split_files && !Config.generate_lib_entry_point then ( let filename = Filename.concat dest_dir (crate_name ^ ".lean") in let out = open_out filename in - (* Write (using the Lean module system) *) + (* Write *) Printf.fprintf out "module\n"; Printf.fprintf out "public import %s.Funs\n" crate_name; Printf.fprintf out "public section\n"; From 0aca2e3092c8f052347d4a0fbef21f03047b26f1 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 11:41:13 +0200 Subject: [PATCH 29/40] qimp --- backends/lean/Aeneas/Std/WP.lean | 2 +- backends/lean/Aeneas/Tactic/Solver/Grind/Tests.lean | 4 +++- backends/lean/Aeneas/Tactic/Step/Tests/SpecParameters.lean | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backends/lean/Aeneas/Std/WP.lean b/backends/lean/Aeneas/Std/WP.lean index bfb5a905e..786c9bf94 100644 --- a/backends/lean/Aeneas/Std/WP.lean +++ b/backends/lean/Aeneas/Std/WP.lean @@ -135,7 +135,7 @@ theorem spec_mono' {α} {P₁ : Post α} {m : Result α} {P₀ : Post α} (h : s cases m <;> grind [qimp] /-- Implication of a `spec` predicate with quantifier -/ -def qimp_spec {α β} (P : α → Prop) (k : α → Result β) (Q : β → Prop) : Prop := +@[expose] def qimp_spec {α β} (P : α → Prop) (k : α → Result β) (Q : β → Prop) : Prop := ∀ x, P x → spec (k x) Q /-- This alternative to `spec_bind` controls the introduction of universal quantifiers with `imp_spec`. -/ diff --git a/backends/lean/Aeneas/Tactic/Solver/Grind/Tests.lean b/backends/lean/Aeneas/Tactic/Solver/Grind/Tests.lean index ad904dc1e..f19905ae3 100644 --- a/backends/lean/Aeneas/Tactic/Solver/Grind/Tests.lean +++ b/backends/lean/Aeneas/Tactic/Solver/Grind/Tests.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Solver.ScalarTac.Lemmas +module +public import Aeneas.Tactic.Solver.ScalarTac.Lemmas +public section /-! # `grind` pattern-selection tests for the Aeneas `.val` projections diff --git a/backends/lean/Aeneas/Tactic/Step/Tests/SpecParameters.lean b/backends/lean/Aeneas/Tactic/Step/Tests/SpecParameters.lean index 5f06a0d78..19d0e2cd4 100644 --- a/backends/lean/Aeneas/Tactic/Step/Tests/SpecParameters.lean +++ b/backends/lean/Aeneas/Tactic/Step/Tests/SpecParameters.lean @@ -1,4 +1,6 @@ -import Aeneas.Tactic.Step +module +public import Aeneas.Tactic.Step +public section open Aeneas Aeneas.Std Result From ea1e22a6e66f8d92ad572519771b7c6def4170c4 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 12:06:56 +0200 Subject: [PATCH 30/40] no effect --- backends/lean/Aeneas/Std/Primitives.lean | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index 6a96821d7..fa0b4dac1 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -126,11 +126,11 @@ def Result.ofOption {a : Type u} (x : Option a) (e : Error) : Result a := | div => div -- Allows using Result in do-blocks -@[expose] instance : Bind Result where +instance : Bind Result where bind := bind -- Allows using pure x in do-blocks -@[expose] instance : Pure Result where +instance : Pure Result where pure := fun x => ok x @[simp] theorem bind_ok (x : α) (f : α → Result β) : bind (.ok x) f = f x := by simp [bind] @@ -159,7 +159,7 @@ def bind_eq_iff (x : Result α) (y y' : α → Result β) : ∀ v, x = ok v → y v = y' v := by cases x <;> simp_all -@[expose] instance : Monad Result where +instance : Monad Result where /-! # Partial Fixpoint From eda10571b0654e0b51817f1296e450ff1d1be2b9 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 12:18:35 +0200 Subject: [PATCH 31/40] regenerate tests --- tests/lean/Adt.lean | 4 +++- tests/lean/AdtBorrows.lean | 4 +++- tests/lean/ArraySliceIndex.lean | 4 +++- tests/lean/Arrays.lean | 4 +++- tests/lean/ArraysDefs.lean | 4 +++- tests/lean/AsMut.lean | 4 +++- tests/lean/AssertCfg.lean | 4 +++- tests/lean/Avl/Funs.lean | 6 ++++-- tests/lean/Avl/Types.lean | 4 +++- tests/lean/Bitwise.lean | 4 +++- tests/lean/BlanketImpl.lean | 4 +++- tests/lean/BoolCmp.lean | 4 +++- tests/lean/Bst/Funs.lean | 6 ++++-- tests/lean/Bst/Types.lean | 4 +++- tests/lean/Builtin.lean | 4 +++- tests/lean/BuiltinAuto.lean | 4 +++- tests/lean/CastSigned.lean | 4 +++- tests/lean/ChunksExact.lean | 4 +++- tests/lean/Closures.lean | 4 +++- tests/lean/ConstShadow.lean | 4 +++- tests/lean/Constants.lean | 2 +- tests/lean/ConstantsLean.lean | 4 +++- tests/lean/Curve25519/Curve25519.lean | 4 +++- tests/lean/Default.lean | 4 +++- tests/lean/DefaultedMethod.lean | 4 +++- tests/lean/Demo/Demo.lean | 4 +++- tests/lean/Deref.lean | 4 +++- tests/lean/Derive.lean | 4 +++- tests/lean/Discriminant.lean | 4 +++- tests/lean/Drop.lean | 4 +++- tests/lean/DropBug.lean | 4 +++- tests/lean/Dyn.lean | 4 +++- tests/lean/DynamicSize.lean | 4 +++- tests/lean/FromTo.lean | 4 +++- tests/lean/GenericUnitOutput.lean | 4 +++- tests/lean/Hashmap/Funs.lean | 6 ++++-- tests/lean/Hashmap/Types.lean | 4 +++- tests/lean/HigherRankedTraitBounds.lean | 4 +++- tests/lean/Into.lean | 4 +++- tests/lean/Issue1044OpaqueTuple.lean | 4 +++- tests/lean/Issue1140GlobalLoop.lean | 4 +++- tests/lean/Issue1141ImplFnRef.lean | 4 +++- tests/lean/Issue134LoopSharedBorrows.lean | 4 +++- tests/lean/Issue194RecursiveStructProjector.lean | 4 +++- tests/lean/Issue270LoopList.lean | 4 +++- tests/lean/Issue440TypeError.lean | 4 +++- tests/lean/Issue789LoopCtxMatch.lean | 4 +++- tests/lean/Issue801Hrtb.lean | 4 +++- tests/lean/Issue803SelfInArray.lean | 4 +++- tests/lean/Issue804ClosureReturnRef.lean | 4 +++- tests/lean/Issue807MissingSymbolicValue.lean | 4 +++- tests/lean/Issue815GlobalReferencingFallibleGlobal.lean | 4 +++- tests/lean/IssueCharon1172.lean | 4 +++- tests/lean/IterAdapters.lean | 4 +++- tests/lean/Iterators.lean | 4 +++- tests/lean/IteratorsArray.lean | 4 +++- tests/lean/IteratorsScalar.lean | 4 +++- tests/lean/JoinDuplicate.lean | 4 +++- tests/lean/Joins.lean | 4 +++- tests/lean/ListBorrows.lean | 4 +++- tests/lean/LoopSharedBorrowProj.lean | 4 +++- tests/lean/LoopSharedLoanInJoin.lean | 4 +++- tests/lean/Loops.lean | 4 +++- tests/lean/LoopsAdts.lean | 4 +++- tests/lean/LoopsIssues.lean | 4 +++- tests/lean/LoopsNested.lean | 4 +++- tests/lean/LoopsNestedRec.lean | 4 +++- tests/lean/LoopsRec.lean | 4 +++- tests/lean/LoopsSequences.lean | 4 +++- tests/lean/MiniTree.lean | 4 +++- tests/lean/MultiTarget.lean | 4 +++- tests/lean/MutBorrowInSharedBorrow.lean | 4 +++- tests/lean/Names.lean | 4 +++- tests/lean/NestedBorrows.lean | 4 +++- tests/lean/NestedSharedBorrows.lean | 4 +++- tests/lean/NoNestedBorrows.lean | 4 +++- tests/lean/OpaqueMutRegion.lean | 4 +++- tests/lean/Options.lean | 4 +++- tests/lean/Order.lean | 4 +++- tests/lean/OverflowingOps.lean | 4 +++- tests/lean/Paper.lean | 4 +++- tests/lean/PoloniusList.lean | 4 +++- tests/lean/Print.lean | 4 +++- tests/lean/Range.lean | 4 +++- tests/lean/RenameAttribute.lean | 4 +++- tests/lean/RustBorrowCheckIssues.lean | 4 +++- tests/lean/Scalars.lean | 4 +++- tests/lean/Slices.lean | 4 +++- tests/lean/Static.lean | 4 +++- tests/lean/StepBy.lean | 4 +++- tests/lean/StringChars.lean | 4 +++- tests/lean/SwitchTest.lean | 4 +++- tests/lean/Traits.lean | 4 +++- tests/lean/Tutorial/Tutorial.lean | 4 +++- tests/lean/Vec.lean | 4 +++- tests/lean/VecIter.lean | 4 +++- 96 files changed, 289 insertions(+), 99 deletions(-) diff --git a/tests/lean/Adt.lean b/tests/lean/Adt.lean index f99cbd9c1..72d1d7010 100644 --- a/tests/lean/Adt.lean +++ b/tests/lean/Adt.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [adt] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/AdtBorrows.lean b/tests/lean/AdtBorrows.lean index 455ecdc5b..e03666430 100644 --- a/tests/lean/AdtBorrows.lean +++ b/tests/lean/AdtBorrows.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [adt_borrows] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/ArraySliceIndex.lean b/tests/lean/ArraySliceIndex.lean index 51415b432..e72a7e8de 100644 --- a/tests/lean/ArraySliceIndex.lean +++ b/tests/lean/ArraySliceIndex.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [array_slice_index] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Arrays.lean b/tests/lean/Arrays.lean index 00b7716b6..f1e2969b9 100644 --- a/tests/lean/Arrays.lean +++ b/tests/lean/Arrays.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [arrays] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/ArraysDefs.lean b/tests/lean/ArraysDefs.lean index 66725b3bf..bad6d4acc 100644 --- a/tests/lean/ArraysDefs.lean +++ b/tests/lean/ArraysDefs.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [arrays_defs] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/AsMut.lean b/tests/lean/AsMut.lean index cc5610961..63e621472 100644 --- a/tests/lean/AsMut.lean +++ b/tests/lean/AsMut.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [as_mut] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/AssertCfg.lean b/tests/lean/AssertCfg.lean index 06bfb83fd..9799aa9ff 100644 --- a/tests/lean/AssertCfg.lean +++ b/tests/lean/AssertCfg.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [assert_cfg] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Avl/Funs.lean b/tests/lean/Avl/Funs.lean index 34be2c16a..f3874881a 100644 --- a/tests/lean/Avl/Funs.lean +++ b/tests/lean/Avl/Funs.lean @@ -1,7 +1,9 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [avl]: function definitions -import Aeneas -import Avl.Types +public import Aeneas +public import Avl.Types +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Avl/Types.lean b/tests/lean/Avl/Types.lean index 3e5ad7260..9bc74d61e 100644 --- a/tests/lean/Avl/Types.lean +++ b/tests/lean/Avl/Types.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [avl]: type definitions -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Bitwise.lean b/tests/lean/Bitwise.lean index 5e6d4f8d5..0d83b4008 100644 --- a/tests/lean/Bitwise.lean +++ b/tests/lean/Bitwise.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bitwise] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/BlanketImpl.lean b/tests/lean/BlanketImpl.lean index f3a4c66c6..a640c3593 100644 --- a/tests/lean/BlanketImpl.lean +++ b/tests/lean/BlanketImpl.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [blanket_impl] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/BoolCmp.lean b/tests/lean/BoolCmp.lean index ad07046ea..5b5471379 100644 --- a/tests/lean/BoolCmp.lean +++ b/tests/lean/BoolCmp.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bool_cmp] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Bst/Funs.lean b/tests/lean/Bst/Funs.lean index 546e7d74c..7f83ebf5a 100644 --- a/tests/lean/Bst/Funs.lean +++ b/tests/lean/Bst/Funs.lean @@ -1,7 +1,9 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bst]: function definitions -import Aeneas -import Bst.Types +public import Aeneas +public import Bst.Types +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Bst/Types.lean b/tests/lean/Bst/Types.lean index 396756db9..074d4f08b 100644 --- a/tests/lean/Bst/Types.lean +++ b/tests/lean/Bst/Types.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [bst]: type definitions -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Builtin.lean b/tests/lean/Builtin.lean index 281cf36c0..26ebf6642 100644 --- a/tests/lean/Builtin.lean +++ b/tests/lean/Builtin.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [builtin] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/BuiltinAuto.lean b/tests/lean/BuiltinAuto.lean index 674dd52f2..f558b5005 100644 --- a/tests/lean/BuiltinAuto.lean +++ b/tests/lean/BuiltinAuto.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [builtin_auto] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/CastSigned.lean b/tests/lean/CastSigned.lean index b1139e148..822364535 100644 --- a/tests/lean/CastSigned.lean +++ b/tests/lean/CastSigned.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cast_signed] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/ChunksExact.lean b/tests/lean/ChunksExact.lean index 4e6dab516..bc3216664 100644 --- a/tests/lean/ChunksExact.lean +++ b/tests/lean/ChunksExact.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [chunks_exact] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Closures.lean b/tests/lean/Closures.lean index 75ee34250..d082bdb30 100644 --- a/tests/lean/Closures.lean +++ b/tests/lean/Closures.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [closures] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/ConstShadow.lean b/tests/lean/ConstShadow.lean index 4e9052034..f68ae5e1b 100644 --- a/tests/lean/ConstShadow.lean +++ b/tests/lean/ConstShadow.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [const_shadow] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Constants.lean b/tests/lean/Constants.lean index 4dbc188fe..ebe8cf93e 100644 --- a/tests/lean/Constants.lean +++ b/tests/lean/Constants.lean @@ -2,7 +2,7 @@ module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [constants] public import Aeneas -public section +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/ConstantsLean.lean b/tests/lean/ConstantsLean.lean index ac9fc5fef..ac2dfb221 100644 --- a/tests/lean/ConstantsLean.lean +++ b/tests/lean/ConstantsLean.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [constants_lean] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Curve25519/Curve25519.lean b/tests/lean/Curve25519/Curve25519.lean index c8e93ba8e..f94be5d01 100644 --- a/tests/lean/Curve25519/Curve25519.lean +++ b/tests/lean/Curve25519/Curve25519.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [curve25519] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Default.lean b/tests/lean/Default.lean index 5f2d36dd1..58c6d0c72 100644 --- a/tests/lean/Default.lean +++ b/tests/lean/Default.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [default] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/DefaultedMethod.lean b/tests/lean/DefaultedMethod.lean index 83629e00e..299cf7b62 100644 --- a/tests/lean/DefaultedMethod.lean +++ b/tests/lean/DefaultedMethod.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [defaulted_method] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Demo/Demo.lean b/tests/lean/Demo/Demo.lean index f4d1c0d29..43e023c79 100644 --- a/tests/lean/Demo/Demo.lean +++ b/tests/lean/Demo/Demo.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [demo] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Deref.lean b/tests/lean/Deref.lean index af02ef13e..93cc9feca 100644 --- a/tests/lean/Deref.lean +++ b/tests/lean/Deref.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [deref] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Derive.lean b/tests/lean/Derive.lean index 6e44a4a24..e5f0ebca3 100644 --- a/tests/lean/Derive.lean +++ b/tests/lean/Derive.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [derive] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Discriminant.lean b/tests/lean/Discriminant.lean index 262f00653..c028d6185 100644 --- a/tests/lean/Discriminant.lean +++ b/tests/lean/Discriminant.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [discriminant] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Drop.lean b/tests/lean/Drop.lean index a0119232e..b526c5141 100644 --- a/tests/lean/Drop.lean +++ b/tests/lean/Drop.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [drop] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/DropBug.lean b/tests/lean/DropBug.lean index 76ca0695c..c0c4f51b2 100644 --- a/tests/lean/DropBug.lean +++ b/tests/lean/DropBug.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [drop_bug] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Dyn.lean b/tests/lean/Dyn.lean index 1ca9dd626..bad5255ef 100644 --- a/tests/lean/Dyn.lean +++ b/tests/lean/Dyn.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [dyn] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/DynamicSize.lean b/tests/lean/DynamicSize.lean index 152bd575a..6bdce8135 100644 --- a/tests/lean/DynamicSize.lean +++ b/tests/lean/DynamicSize.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [dynamic_size] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/FromTo.lean b/tests/lean/FromTo.lean index 9ea0f6c7d..8c362e84e 100644 --- a/tests/lean/FromTo.lean +++ b/tests/lean/FromTo.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [from_to] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/GenericUnitOutput.lean b/tests/lean/GenericUnitOutput.lean index f6ae337b7..2343df741 100644 --- a/tests/lean/GenericUnitOutput.lean +++ b/tests/lean/GenericUnitOutput.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generic_unit_output] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean index 256c7fafd..633c8420e 100644 --- a/tests/lean/Hashmap/Funs.lean +++ b/tests/lean/Hashmap/Funs.lean @@ -1,7 +1,9 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [hashmap]: function definitions -import Aeneas -import Hashmap.Types +public import Aeneas +public import Hashmap.Types +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Hashmap/Types.lean b/tests/lean/Hashmap/Types.lean index 6f2c23bbe..de9c7da0c 100644 --- a/tests/lean/Hashmap/Types.lean +++ b/tests/lean/Hashmap/Types.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [hashmap]: type definitions -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/HigherRankedTraitBounds.lean b/tests/lean/HigherRankedTraitBounds.lean index add8008e0..0a887ce94 100644 --- a/tests/lean/HigherRankedTraitBounds.lean +++ b/tests/lean/HigherRankedTraitBounds.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [higher_ranked_trait_bounds] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Into.lean b/tests/lean/Into.lean index 67c45af90..5632ef85a 100644 --- a/tests/lean/Into.lean +++ b/tests/lean/Into.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [into] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue1044OpaqueTuple.lean b/tests/lean/Issue1044OpaqueTuple.lean index b1964742b..828250eea 100644 --- a/tests/lean/Issue1044OpaqueTuple.lean +++ b/tests/lean/Issue1044OpaqueTuple.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_1044_opaque_tuple] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue1140GlobalLoop.lean b/tests/lean/Issue1140GlobalLoop.lean index f76ca385e..621d9804d 100644 --- a/tests/lean/Issue1140GlobalLoop.lean +++ b/tests/lean/Issue1140GlobalLoop.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_1140_global_loop] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue1141ImplFnRef.lean b/tests/lean/Issue1141ImplFnRef.lean index fa8c284c2..798016078 100644 --- a/tests/lean/Issue1141ImplFnRef.lean +++ b/tests/lean/Issue1141ImplFnRef.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_1141_impl_fn_ref] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue134LoopSharedBorrows.lean b/tests/lean/Issue134LoopSharedBorrows.lean index 9a9f81078..def4a4ac5 100644 --- a/tests/lean/Issue134LoopSharedBorrows.lean +++ b/tests/lean/Issue134LoopSharedBorrows.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_134_loop_shared_borrows] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue194RecursiveStructProjector.lean b/tests/lean/Issue194RecursiveStructProjector.lean index f91052e01..67f5774ab 100644 --- a/tests/lean/Issue194RecursiveStructProjector.lean +++ b/tests/lean/Issue194RecursiveStructProjector.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_194_recursive_struct_projector] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue270LoopList.lean b/tests/lean/Issue270LoopList.lean index 727f5732a..72b3e3082 100644 --- a/tests/lean/Issue270LoopList.lean +++ b/tests/lean/Issue270LoopList.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_270_loop_list] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue440TypeError.lean b/tests/lean/Issue440TypeError.lean index f1779dba8..d0ee0623f 100644 --- a/tests/lean/Issue440TypeError.lean +++ b/tests/lean/Issue440TypeError.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_440_type_error] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue789LoopCtxMatch.lean b/tests/lean/Issue789LoopCtxMatch.lean index afeb5baf5..44fc27e91 100644 --- a/tests/lean/Issue789LoopCtxMatch.lean +++ b/tests/lean/Issue789LoopCtxMatch.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_789_loop_ctx_match] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue801Hrtb.lean b/tests/lean/Issue801Hrtb.lean index 9565d0b79..8aa8a5c0c 100644 --- a/tests/lean/Issue801Hrtb.lean +++ b/tests/lean/Issue801Hrtb.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_801_hrtb] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue803SelfInArray.lean b/tests/lean/Issue803SelfInArray.lean index 642bc2376..3deb6f3b4 100644 --- a/tests/lean/Issue803SelfInArray.lean +++ b/tests/lean/Issue803SelfInArray.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_803_self_in_array] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue804ClosureReturnRef.lean b/tests/lean/Issue804ClosureReturnRef.lean index 023c657f9..8adca83d5 100644 --- a/tests/lean/Issue804ClosureReturnRef.lean +++ b/tests/lean/Issue804ClosureReturnRef.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_804_closure_return_ref] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue807MissingSymbolicValue.lean b/tests/lean/Issue807MissingSymbolicValue.lean index 4e0f074a3..544f54330 100644 --- a/tests/lean/Issue807MissingSymbolicValue.lean +++ b/tests/lean/Issue807MissingSymbolicValue.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_807_missing_symbolic_value] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Issue815GlobalReferencingFallibleGlobal.lean b/tests/lean/Issue815GlobalReferencingFallibleGlobal.lean index af6ed3064..9f9accdec 100644 --- a/tests/lean/Issue815GlobalReferencingFallibleGlobal.lean +++ b/tests/lean/Issue815GlobalReferencingFallibleGlobal.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_815_global_referencing_fallible_global] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/IssueCharon1172.lean b/tests/lean/IssueCharon1172.lean index 3ee1e31cd..b6d1bbf5b 100644 --- a/tests/lean/IssueCharon1172.lean +++ b/tests/lean/IssueCharon1172.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [issue_charon_1172] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/IterAdapters.lean b/tests/lean/IterAdapters.lean index f1aee0526..6af20605b 100644 --- a/tests/lean/IterAdapters.lean +++ b/tests/lean/IterAdapters.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [iter_adapters] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Iterators.lean b/tests/lean/Iterators.lean index cbf8daac3..3a3f1f4f4 100644 --- a/tests/lean/Iterators.lean +++ b/tests/lean/Iterators.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [iterators] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/IteratorsArray.lean b/tests/lean/IteratorsArray.lean index e259e9d21..2e5de6e0c 100644 --- a/tests/lean/IteratorsArray.lean +++ b/tests/lean/IteratorsArray.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [iterators_array] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/IteratorsScalar.lean b/tests/lean/IteratorsScalar.lean index f1cd2ce7a..0cd1fd245 100644 --- a/tests/lean/IteratorsScalar.lean +++ b/tests/lean/IteratorsScalar.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [iterators_scalar] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/JoinDuplicate.lean b/tests/lean/JoinDuplicate.lean index cc254b69a..48a3ba984 100644 --- a/tests/lean/JoinDuplicate.lean +++ b/tests/lean/JoinDuplicate.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [join_duplicate] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Joins.lean b/tests/lean/Joins.lean index 4fad829e1..702d323a7 100644 --- a/tests/lean/Joins.lean +++ b/tests/lean/Joins.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [joins] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/ListBorrows.lean b/tests/lean/ListBorrows.lean index d0b9358cb..8706ef2a7 100644 --- a/tests/lean/ListBorrows.lean +++ b/tests/lean/ListBorrows.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [list_borrows] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopSharedBorrowProj.lean b/tests/lean/LoopSharedBorrowProj.lean index d8a9334e1..5dafeeed6 100644 --- a/tests/lean/LoopSharedBorrowProj.lean +++ b/tests/lean/LoopSharedBorrowProj.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loop_shared_borrow_proj] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopSharedLoanInJoin.lean b/tests/lean/LoopSharedLoanInJoin.lean index aab74d806..d004f67ce 100644 --- a/tests/lean/LoopSharedLoanInJoin.lean +++ b/tests/lean/LoopSharedLoanInJoin.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loop_shared_loan_in_join] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Loops.lean b/tests/lean/Loops.lean index a84c0f1b6..23cf40558 100644 --- a/tests/lean/Loops.lean +++ b/tests/lean/Loops.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loops] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopsAdts.lean b/tests/lean/LoopsAdts.lean index 5e3d80e40..8d8b1cda5 100644 --- a/tests/lean/LoopsAdts.lean +++ b/tests/lean/LoopsAdts.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loops_adts] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopsIssues.lean b/tests/lean/LoopsIssues.lean index 93dd4b548..f84184f02 100644 --- a/tests/lean/LoopsIssues.lean +++ b/tests/lean/LoopsIssues.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loops_issues] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopsNested.lean b/tests/lean/LoopsNested.lean index dfc2dd8f0..346d5b922 100644 --- a/tests/lean/LoopsNested.lean +++ b/tests/lean/LoopsNested.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loops_nested] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopsNestedRec.lean b/tests/lean/LoopsNestedRec.lean index 128ff9342..335242919 100644 --- a/tests/lean/LoopsNestedRec.lean +++ b/tests/lean/LoopsNestedRec.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loops_nested_rec] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopsRec.lean b/tests/lean/LoopsRec.lean index 83d649316..363a8f4c9 100644 --- a/tests/lean/LoopsRec.lean +++ b/tests/lean/LoopsRec.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loops_rec] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/LoopsSequences.lean b/tests/lean/LoopsSequences.lean index beda7f8d0..2c62f6bc9 100644 --- a/tests/lean/LoopsSequences.lean +++ b/tests/lean/LoopsSequences.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [loops_sequences] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/MiniTree.lean b/tests/lean/MiniTree.lean index ae54d4543..874b46843 100644 --- a/tests/lean/MiniTree.lean +++ b/tests/lean/MiniTree.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mini_tree] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/MultiTarget.lean b/tests/lean/MultiTarget.lean index 7a6c9b273..297be0797 100644 --- a/tests/lean/MultiTarget.lean +++ b/tests/lean/MultiTarget.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [multi_target] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/MutBorrowInSharedBorrow.lean b/tests/lean/MutBorrowInSharedBorrow.lean index 7b017f905..6fb788c8c 100644 --- a/tests/lean/MutBorrowInSharedBorrow.lean +++ b/tests/lean/MutBorrowInSharedBorrow.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [mut_borrow_in_shared_borrow] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Names.lean b/tests/lean/Names.lean index ff03c177c..c21580e94 100644 --- a/tests/lean/Names.lean +++ b/tests/lean/Names.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [names] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/NestedBorrows.lean b/tests/lean/NestedBorrows.lean index 61b3b2b31..c968721ba 100644 --- a/tests/lean/NestedBorrows.lean +++ b/tests/lean/NestedBorrows.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nested_borrows] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/NestedSharedBorrows.lean b/tests/lean/NestedSharedBorrows.lean index 00aa471c6..f6a48494c 100644 --- a/tests/lean/NestedSharedBorrows.lean +++ b/tests/lean/NestedSharedBorrows.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [nested_shared_borrows] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index e2a706b74..e95a5a77b 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [no_nested_borrows] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/OpaqueMutRegion.lean b/tests/lean/OpaqueMutRegion.lean index bfa1e8ffd..10fd1a9a9 100644 --- a/tests/lean/OpaqueMutRegion.lean +++ b/tests/lean/OpaqueMutRegion.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [opaque_mut_region] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Options.lean b/tests/lean/Options.lean index 4de39313d..7a0f58f3d 100644 --- a/tests/lean/Options.lean +++ b/tests/lean/Options.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [options] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Order.lean b/tests/lean/Order.lean index ad3a94ea2..addfddaff 100644 --- a/tests/lean/Order.lean +++ b/tests/lean/Order.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [order] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/OverflowingOps.lean b/tests/lean/OverflowingOps.lean index 341c93ba4..6eee7667e 100644 --- a/tests/lean/OverflowingOps.lean +++ b/tests/lean/OverflowingOps.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [overflowing_ops] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Paper.lean b/tests/lean/Paper.lean index 0f0142377..9a5cad5df 100644 --- a/tests/lean/Paper.lean +++ b/tests/lean/Paper.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [paper] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/PoloniusList.lean b/tests/lean/PoloniusList.lean index 716f3e159..14a9571f4 100644 --- a/tests/lean/PoloniusList.lean +++ b/tests/lean/PoloniusList.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [polonius_list] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Print.lean b/tests/lean/Print.lean index a65dfb9c1..6341dd846 100644 --- a/tests/lean/Print.lean +++ b/tests/lean/Print.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [print] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Range.lean b/tests/lean/Range.lean index f27d35a7e..bbe19cf56 100644 --- a/tests/lean/Range.lean +++ b/tests/lean/Range.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [range] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/RenameAttribute.lean b/tests/lean/RenameAttribute.lean index 5faad73ae..221821ea5 100644 --- a/tests/lean/RenameAttribute.lean +++ b/tests/lean/RenameAttribute.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rename_attribute] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/RustBorrowCheckIssues.lean b/tests/lean/RustBorrowCheckIssues.lean index c2d0c0cc1..8b9ab49c6 100644 --- a/tests/lean/RustBorrowCheckIssues.lean +++ b/tests/lean/RustBorrowCheckIssues.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rust_borrow_check_issues] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Scalars.lean b/tests/lean/Scalars.lean index b08de12b1..3501dc802 100644 --- a/tests/lean/Scalars.lean +++ b/tests/lean/Scalars.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [scalars] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Slices.lean b/tests/lean/Slices.lean index 46ba2bc46..db6e749ae 100644 --- a/tests/lean/Slices.lean +++ b/tests/lean/Slices.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [slices] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Static.lean b/tests/lean/Static.lean index 9d3179866..344771f96 100644 --- a/tests/lean/Static.lean +++ b/tests/lean/Static.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [static] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/StepBy.lean b/tests/lean/StepBy.lean index f7f47292a..f6e90b09e 100644 --- a/tests/lean/StepBy.lean +++ b/tests/lean/StepBy.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [step_by] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/StringChars.lean b/tests/lean/StringChars.lean index a4fea188c..c54a8f339 100644 --- a/tests/lean/StringChars.lean +++ b/tests/lean/StringChars.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [string_chars] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/SwitchTest.lean b/tests/lean/SwitchTest.lean index 2bde1187c..2b62dfd11 100644 --- a/tests/lean/SwitchTest.lean +++ b/tests/lean/SwitchTest.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [switch_test] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index 225916084..eaf1af634 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [traits] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Tutorial/Tutorial.lean b/tests/lean/Tutorial/Tutorial.lean index 7fc8cc012..884a3c165 100644 --- a/tests/lean/Tutorial/Tutorial.lean +++ b/tests/lean/Tutorial/Tutorial.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [tutorial] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Vec.lean b/tests/lean/Vec.lean index dd72bcf13..d00d5eed8 100644 --- a/tests/lean/Vec.lean +++ b/tests/lean/Vec.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [vec] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/VecIter.lean b/tests/lean/VecIter.lean index b2468dc8c..55fd2867a 100644 --- a/tests/lean/VecIter.lean +++ b/tests/lean/VecIter.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [vec_iter] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false From af13097f4e727c4d5c68ba401c4c8e4822f993cd Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 14:14:34 +0200 Subject: [PATCH 32/40] updates based on tests --- backends/lean/Aeneas/Data/Discriminant.lean | 19 ++++++++++--------- backends/lean/Aeneas/Std/Core/Cmp.lean | 2 +- backends/lean/Aeneas/Std/Core/Core.lean | 2 +- backends/lean/Aeneas/Std/Core/Iter.lean | 4 ++-- .../lean/AeneasMeta/Simp/RegisterCommand.lean | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/backends/lean/Aeneas/Data/Discriminant.lean b/backends/lean/Aeneas/Data/Discriminant.lean index 13d4ba296..d066595d8 100644 --- a/backends/lean/Aeneas/Data/Discriminant.lean +++ b/backends/lean/Aeneas/Data/Discriminant.lean @@ -2,6 +2,7 @@ module public import Lean public meta import Aeneas.Std.Scalar.Core public import Aeneas.Std.Scalar.Notations +public meta import Mathlib.Data.List.Monad public section namespace Aeneas @@ -27,7 +28,7 @@ inductive ScalarTy where | U8 | U16 | U32 | U64 | U128 | Usize | I8 | I16 | I32 | I64 | I128 | Isize -def mkScalarValue (ty : ScalarTy) (val : Nat) : TermElabM Term := do +meta def mkScalarValue (ty : ScalarTy) (val : Nat) : TermElabM Term := do let value := Syntax.mkNumLit (toString val) match ty with | .U8 => `($(value)#u8) @@ -43,7 +44,7 @@ def mkScalarValue (ty : ScalarTy) (val : Nat) : TermElabM Term := do | .I128 => `($(value)#i128) | .Isize => `($(value)#isize) -def mkScalarTy (ty : ScalarTy) : TermElabM Term := do +meta def mkScalarTy (ty : ScalarTy) : TermElabM Term := do match ty with | .U8 => `(_root_.Aeneas.Std.U8) | .U16 => `(_root_.Aeneas.Std.U16) @@ -62,7 +63,7 @@ def mkScalarTy (ty : ScalarTy) : TermElabM Term := do This function is adapted from `Lean.Elab.Deriving.BEq`. -/ -def generateReadDiscriminantCmds (declName : Name) (ty : ScalarTy) (discrValues : Option (List Nat)) : +meta def generateReadDiscriminantCmds (declName : Name) (ty : ScalarTy) (discrValues : Option (List Nat)) : TermElabM (List Syntax) := do -- Lookup the declaration, which should be an inductive let env ← getEnv @@ -123,12 +124,12 @@ def generateReadDiscriminantCmds (declName : Name) (ty : ScalarTy) (discrValues let ty ← mkScalarTy ty let auxFunName := Name.mkStr declName "read_discriminant" let binders := header.binders - let defStx ← `(def $(mkIdent auxFunName):ident $binders:bracketedBinder* : $ty := $body:term) + let defStx ← `(public def $(mkIdent auxFunName):ident $binders:bracketedBinder* : $ty := $body:term) -- Generate the syntax for the instance let binders := binders.extract 0 indVal.numParams let args := header.argNames.map mkIdent - let instStx ← `(instance $binders:bracketedBinder* : Aeneas.Std.Discriminant ($header.targetType) ($ty) where + let instStx ← `(public instance $binders:bracketedBinder* : Aeneas.Std.Discriminant ($header.targetType) ($ty) where read_discriminant := @$(mkIdent auxFunName):ident $args*) -- @@ -136,14 +137,14 @@ def generateReadDiscriminantCmds (declName : Name) (ty : ScalarTy) (discrValues /-- Given an inductive declaration name and an optional list of values, generate an instance of `Std.Discriminant`. If the list of values is not provided, we use values `0`, `1`, etc. -/ -def generateReadDiscriminant (declName : Name) (ty : ScalarTy) (discrValues : Option (List Nat)) : +meta def generateReadDiscriminant (declName : Name) (ty : ScalarTy) (discrValues : Option (List Nat)) : CommandElabM Unit := do let cmds ← liftTermElabM (generateReadDiscriminantCmds declName ty discrValues) cmds.forM elabCommand syntax (name := readDiscriminant) "discriminant" ident ("["num,*"]")? : attr -def elabTypeToken (stx : Syntax) : AttrM ScalarTy := +meta def elabTypeToken (stx : Syntax) : AttrM ScalarTy := match stx.getId with | `u8 => pure ScalarTy.U8 | `u16 => pure ScalarTy.U16 @@ -159,7 +160,7 @@ def elabTypeToken (stx : Syntax) : AttrM ScalarTy := | `isize => pure ScalarTy.Isize | _ => throwUnsupportedSyntax -def elabReadDiscriminantAttribute (stx : Syntax) : AttrM (ScalarTy × Option (List Nat)) := +meta def elabReadDiscriminantAttribute (stx : Syntax) : AttrM (ScalarTy × Option (List Nat)) := withRef stx do match stx with | `(attr| discriminant $ty) => do @@ -170,7 +171,7 @@ def elabReadDiscriminantAttribute (stx : Syntax) : AttrM (ScalarTy × Option (Li pure (← elabTypeToken ty, some ((x.getElems.toList.map Syntax.isNatLit?).map Option.get!)) | _ => throwUnsupportedSyntax -initialize discriminantAttribute : AttributeImpl ← do +public meta initialize discriminantAttribute : AttributeImpl ← do let attrImpl : AttributeImpl := { name := `readDiscriminant descr := "Generates an instance of `Std.Discriminant` for the given inductive" diff --git a/backends/lean/Aeneas/Std/Core/Cmp.lean b/backends/lean/Aeneas/Std/Core/Cmp.lean index 23e2dccee..18120dbe8 100644 --- a/backends/lean/Aeneas/Std/Core/Cmp.lean +++ b/backends/lean/Aeneas/Std/Core/Cmp.lean @@ -30,7 +30,7 @@ def core.cmp.PartialEq.ne.default {Self Rhs : Type} (eq : Self → Rhs → Resul (self : Self) (other : Rhs) : Result Bool := do ok (¬ (← eq self other)) -@[trait_default, rust_fun "core::cmp::PartialEq::ne"] +@[expose, trait_default, rust_fun "core::cmp::PartialEq::ne"] def core.cmp.PartialEq.ne.trait_default {Self Rhs : Type} (PartialEqInst : core.cmp.PartialEq Self Rhs) (self : Self) (other : Rhs) : Result Bool := diff --git a/backends/lean/Aeneas/Std/Core/Core.lean b/backends/lean/Aeneas/Std/Core/Core.lean index 72bfd5166..939e0034b 100644 --- a/backends/lean/Aeneas/Std/Core/Core.lean +++ b/backends/lean/Aeneas/Std/Core/Core.lean @@ -29,7 +29,7 @@ structure clone.Clone (Self : Type) where clone : Self → Result Self clone_from : Self → Self → Result Self := fun _ => clone -@[trait_default] +@[expose, trait_default] def clone.Clone.clone_from.default {Self : Type} (CloneInst : core.clone.Clone Self) (_self source : Self) : Result Self := CloneInst.clone source diff --git a/backends/lean/Aeneas/Std/Core/Iter.lean b/backends/lean/Aeneas/Std/Core/Iter.lean index 13f2554da..b9905b356 100644 --- a/backends/lean/Aeneas/Std/Core/Iter.lean +++ b/backends/lean/Aeneas/Std/Core/Iter.lean @@ -602,7 +602,7 @@ def core.iter.traits.iterator.Iterator.zip.default let b ← into_iter other ok ⟨self, b⟩ -@[trait_default, rust_fun "core::iter::traits::iterator::Iterator::zip"] +@[expose, trait_default, rust_fun "core::iter::traits::iterator::Iterator::zip"] def core.iter.traits.iterator.Iterator.zip.trait_default {Self U Item0 Item1 IntoIter : Type} (_IteratorInst : core.iter.traits.iterator.Iterator Self Item0) @@ -616,7 +616,7 @@ def core.iter.traits.iterator.Iterator.rev.default Self → Result (core.iter.adapters.rev.Rev Self) := fun self => ok ⟨self⟩ -@[trait_default, rust_fun "core::iter::traits::iterator::Iterator::rev"] +@[expose, trait_default, rust_fun "core::iter::traits::iterator::Iterator::rev"] def core.iter.traits.iterator.Iterator.rev.trait_default {Self Item0 Item1 : Type} (_IteratorInst : core.iter.traits.iterator.Iterator Self Item0) diff --git a/backends/lean/AeneasMeta/Simp/RegisterCommand.lean b/backends/lean/AeneasMeta/Simp/RegisterCommand.lean index 12cbb2c0f..71a133dd0 100644 --- a/backends/lean/AeneasMeta/Simp/RegisterCommand.lean +++ b/backends/lean/AeneasMeta/Simp/RegisterCommand.lean @@ -18,10 +18,10 @@ macro (name := Parser.Command.registerSimpAttr) doc:(docComment)? let procIdParser := mkIdentFrom procId (`Parser.Attr ++ procId.getId) let procDescr := quote s!"simproc set for {procId.getId.toString}" -- TODO: better docDomment for simprocs - `($[$doc:docComment]? initialize $ext : SimpExtension ← registerSimpAttr $(quote id.getId) $descr $(quote id.getId) + `($[$doc:docComment]? public meta initialize $ext : SimpExtension ← registerSimpAttr $(quote id.getId) $descr $(quote id.getId) $[$doc:docComment]? syntax (name := $idParser:ident) $(quote str):str (Parser.Tactic.simpPre <|> Parser.Tactic.simpPost)? patternIgnore("← " <|> "<- ")? (prio)? : attr /-- Simplification procedure -/ - initialize $extProc : SimprocExtension ← registerSimprocAttr $(quote procId.getId) $procDescr none $(quote procId.getId) + public meta initialize $extProc : SimprocExtension ← registerSimprocAttr $(quote procId.getId) $procDescr none $(quote procId.getId) /-- Simplification procedure -/ syntax (name := $procIdParser:ident) $(quote procStr):str (Parser.Tactic.simpPre <|> Parser.Tactic.simpPost)? : attr) From 7af9e4865f7d569be4a9042cffaa5f446df1c862 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Fri, 24 Jul 2026 16:49:03 +0200 Subject: [PATCH 33/40] remove comment --- backends/lean/Aeneas/Std/Primitives.lean | 2 -- 1 file changed, 2 deletions(-) diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index fa0b4dac1..e0b4f096b 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -91,8 +91,6 @@ def div? {α: Type u} (r: Result α): Bool := | div => true | ok _ | fail _ => false -/- TODO (module system): better style would be avoid `@[expose]` here and instead export only the -appropriate charatirization lemmas. The lemmas currently live in `Aeneas.Std.PrimitivesLemmas`. -/ @[expose] def massert (b : Prop) [Decidable b] : Result Unit := if b then ok () else fail assertionFailure From cd92a9aacc7f729cbecca5a9fe614096025580ac Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Sat, 25 Jul 2026 12:38:11 +0200 Subject: [PATCH 34/40] #assert --- tests/lean/ChunksExact.lean | 4 +--- tests/lean/IterAdapters.lean | 4 +--- tests/lean/Scalars.lean | 4 +--- tests/lean/StepBy.lean | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/lean/ChunksExact.lean b/tests/lean/ChunksExact.lean index bc3216664..4e6dab516 100644 --- a/tests/lean/ChunksExact.lean +++ b/tests/lean/ChunksExact.lean @@ -1,8 +1,6 @@ -module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [chunks_exact] -public import Aeneas -@[expose] public section +import Aeneas open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/IterAdapters.lean b/tests/lean/IterAdapters.lean index 6af20605b..f1aee0526 100644 --- a/tests/lean/IterAdapters.lean +++ b/tests/lean/IterAdapters.lean @@ -1,8 +1,6 @@ -module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [iter_adapters] -public import Aeneas -@[expose] public section +import Aeneas open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/Scalars.lean b/tests/lean/Scalars.lean index 3501dc802..b08de12b1 100644 --- a/tests/lean/Scalars.lean +++ b/tests/lean/Scalars.lean @@ -1,8 +1,6 @@ -module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [scalars] -public import Aeneas -@[expose] public section +import Aeneas open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false diff --git a/tests/lean/StepBy.lean b/tests/lean/StepBy.lean index f6e90b09e..f7f47292a 100644 --- a/tests/lean/StepBy.lean +++ b/tests/lean/StepBy.lean @@ -1,8 +1,6 @@ -module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [step_by] -public import Aeneas -@[expose] public section +import Aeneas open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false From ae6c5bfc4a802ddfd168cdef9bb34d1ca342fd7b Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Sat, 25 Jul 2026 13:49:21 +0200 Subject: [PATCH 35/40] good without precompiled modules --- backends/lean/AeneasMeta/Saturate/Attribute.lean | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backends/lean/AeneasMeta/Saturate/Attribute.lean b/backends/lean/AeneasMeta/Saturate/Attribute.lean index ca78df3fc..5fc3a4782 100644 --- a/backends/lean/AeneasMeta/Saturate/Attribute.lean +++ b/backends/lean/AeneasMeta/Saturate/Attribute.lean @@ -12,11 +12,11 @@ open Utils Extensions namespace Saturate -initialize registerTraceClass `Saturate -initialize registerTraceClass `Saturate.insertPartialMatch -initialize registerTraceClass `Saturate.explore -initialize registerTraceClass `Saturate.attribute -initialize registerTraceClass `Saturate.diagnostics +meta initialize registerTraceClass `Saturate +meta initialize registerTraceClass `Saturate.insertPartialMatch +meta initialize registerTraceClass `Saturate.explore +meta initialize registerTraceClass `Saturate.attribute +meta initialize registerTraceClass `Saturate.diagnostics namespace Attribute From 94caf9b25981af46a1d2a4863bb2dcd290eab945 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Sat, 25 Jul 2026 15:20:38 +0200 Subject: [PATCH 36/40] assert tests --- backends/lean/Aeneas/Std/Primitives.lean | 10 ++ src/Config.ml | 4 + src/Main.ml | 4 + src/Translate.ml | 23 ++-- tests/coq/misc/NoNestedBorrows.v | 150 +++++++++++----------- tests/coq/misc/Paper.v | 18 +-- tests/fstar/misc/Paper.fst | 18 +-- tests/lean/CastSigned.lean | 34 +++-- tests/lean/ChunksExact.lean | 18 +-- tests/lean/IterAdapters.lean | 90 ++++++------- tests/lean/NoNestedBorrows.lean | 154 +++++++++++------------ tests/lean/Paper.lean | 22 ++-- tests/lean/Scalars.lean | 74 +++++------ tests/lean/StepBy.lean | 22 ++-- tests/src/chunks_exact.rs | 1 + tests/src/iter_adapters.rs | 1 + tests/src/scalars.rs | 1 + tests/src/step_by.rs | 1 + 18 files changed, 333 insertions(+), 312 deletions(-) diff --git a/backends/lean/Aeneas/Std/Primitives.lean b/backends/lean/Aeneas/Std/Primitives.lean index e0b4f096b..4dbf42e78 100644 --- a/backends/lean/Aeneas/Std/Primitives.lean +++ b/backends/lean/Aeneas/Std/Primitives.lean @@ -15,6 +15,16 @@ namespace Std open Lean Elab Command Term Meta +/-- `#assert e` checks that the boolean expression `e` evaluates to `true`, raising an error +otherwise (like a Rust `assert!`). It is emitted by the extraction engine for functions marked +`#[verify::test]`. + +**Note:** `#assert` *compiles and runs* `e` (via `evalTerm`), so it needs the compiled/native code +of every function `e` transitively calls. Consequently: + +* In the IDE (Lean server): always works, both with the module system or without. +* In files which don't use the module system: works. +* In a file which uses the module system, built using `lake build`: **does not work**. -/ syntax (name := assert) "#assert" term: command @[command_elab assert] diff --git a/src/Config.ml b/src/Config.ml index cb919aeb1..5ee14a4c5 100644 --- a/src/Config.ml +++ b/src/Config.ml @@ -255,6 +255,10 @@ let extract_decreases_clauses = ref false given by the user. *) let extract_template_decreases_clauses = ref true +(** Whether to emit Lean output using the module system. Defaults to [true]. + Pass `-use-lean-modules false` to emit non-module Lean files. *) +let use_lean_modules = ref true + (** {1 Micro passes} *) (** Some provers like F* and Coq don't support the decomposition of return diff --git a/src/Main.ml b/src/Main.ml index 8073dba6b..5071dc93b 100644 --- a/src/Main.ml +++ b/src/Main.ml @@ -105,6 +105,10 @@ let () = Arg.String set_subdir, " Extract the files in a sub-folder; this option has an impact on the \ import paths of the generated files" ); + ( "-use-lean-modules", + Arg.Bool (fun b -> use_lean_modules := b), + " Emit Lean files using the module system (default: true). Pass \ + `-use-lean-modules false` to emit non-module files." ); ( "-test-units", Arg.Set test_unit_functions, " Test the unit functions with the concrete (i.e., not symbolic) \ diff --git a/src/Translate.ml b/src/Translate.ml index 42229fc32..c915e8d41 100644 --- a/src/Translate.ml +++ b/src/Translate.ml @@ -1312,7 +1312,7 @@ let extract_file (config : gen_config) (ctx : gen_ctx) (fi : extract_file_info) (* Create the header *) (match Config.backend () with | Lean -> - Printf.fprintf out "module\n"; + if !Config.use_lean_modules then Printf.fprintf out "module\n"; Printf.fprintf out "-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS\n"; Printf.fprintf out "-- [%s]%s\n" fi.rust_module_name fi.custom_msg | Coq | FStar | HOL4 -> @@ -1366,16 +1366,20 @@ let extract_file (config : gen_config) (ctx : gen_ctx) (fi : extract_file_info) fi.custom_includes; Printf.fprintf out "Module %s.\n" fi.module_name | Lean -> - Printf.fprintf out "public import Aeneas\n"; + let import_kw = + if !Config.use_lean_modules then "public import" else "import" + in + Printf.fprintf out "%s Aeneas\n" import_kw; (* Add the custom imports *) List.iter - (fun m -> Printf.fprintf out "public import %s\n" m) + (fun m -> Printf.fprintf out "%s %s\n" import_kw m) fi.custom_imports; (* Add the custom includes *) List.iter - (fun m -> Printf.fprintf out "public import %s\n" m) + (fun m -> Printf.fprintf out "%s %s\n" import_kw m) fi.custom_includes; - Printf.fprintf out "@[expose] public section\n"; + if !Config.use_lean_modules then + Printf.fprintf out "@[expose] public section\n"; (* Always open the Primitives namespace *) Printf.fprintf out "open Aeneas Aeneas.Std Result ControlFlow Error\n"; (* It happens that we generate duplicated namespaces, like `betree.betree`. @@ -2152,10 +2156,11 @@ let extract_translated_crate (filename : string) (dest_dir : string) if !Config.split_files && !Config.generate_lib_entry_point then ( let filename = Filename.concat dest_dir (crate_name ^ ".lean") in let out = open_out filename in - (* Write *) - Printf.fprintf out "module\n"; - Printf.fprintf out "public import %s.Funs\n" crate_name; - Printf.fprintf out "public section\n"; + if !Config.use_lean_modules then ( + Printf.fprintf out "module\n"; + Printf.fprintf out "public import %s.Funs\n" crate_name; + Printf.fprintf out "public section\n") + else Printf.fprintf out "import %s.Funs\n" crate_name; (* Flush and close the file, log *) close_out out; log#linfo (lazy ("Generated: " ^ filename))); diff --git a/tests/coq/misc/NoNestedBorrows.v b/tests/coq/misc/NoNestedBorrows.v index 7fe5a6cfe..9ce2bc469 100644 --- a/tests/coq/misc/NoNestedBorrows.v +++ b/tests/coq/misc/NoNestedBorrows.v @@ -15,7 +15,7 @@ Module NoNestedBorrows. Axiom core_fmt_Arguments_t : Type. (** [no_nested_borrows::Pair] - Source: 'tests/src/no_nested_borrows.rs', lines 7:0-10:1 + Source: 'tests/src/no_nested_borrows.rs', lines 8:0-11:1 Visibility: public *) Record Pair_t (T1 : Type) (T2 : Type) := mkPair_t { @@ -28,7 +28,7 @@ Arguments pair_x { _ } { _ }. Arguments pair_y { _ } { _ }. (** [no_nested_borrows::List] - Source: 'tests/src/no_nested_borrows.rs', lines 12:0-15:1 + Source: 'tests/src/no_nested_borrows.rs', lines 13:0-16:1 Visibility: public *) Inductive List_t (T : Type) := | List_Cons : T -> List_t T -> List_t T @@ -39,29 +39,29 @@ Arguments List_Cons { _ }. Arguments List_Nil { _ }. (** [no_nested_borrows::One] - Source: 'tests/src/no_nested_borrows.rs', lines 23:0-25:1 + Source: 'tests/src/no_nested_borrows.rs', lines 24:0-26:1 Visibility: public *) Inductive One_t (T1 : Type) := | One_One : T1 -> One_t T1. Arguments One_One { _ }. (** [no_nested_borrows::EmptyEnum] - Source: 'tests/src/no_nested_borrows.rs', lines 29:0-31:1 + Source: 'tests/src/no_nested_borrows.rs', lines 30:0-32:1 Visibility: public *) Inductive EmptyEnum_t := | EmptyEnum_Empty : EmptyEnum_t. (** [no_nested_borrows::Enum] - Source: 'tests/src/no_nested_borrows.rs', lines 35:0-38:1 + Source: 'tests/src/no_nested_borrows.rs', lines 36:0-39:1 Visibility: public *) Inductive Enum_t := | Enum_Variant1 : Enum_t | Enum_Variant2 : Enum_t. (** [no_nested_borrows::EmptyStruct] - Source: 'tests/src/no_nested_borrows.rs', lines 42:0-42:25 + Source: 'tests/src/no_nested_borrows.rs', lines 43:0-43:25 Visibility: public *) Definition EmptyStruct_t : Type := unit. (** [no_nested_borrows::Sum] - Source: 'tests/src/no_nested_borrows.rs', lines 44:0-47:1 + Source: 'tests/src/no_nested_borrows.rs', lines 45:0-48:1 Visibility: public *) Inductive Sum_t (T1 : Type) (T2 : Type) := | Sum_Left : T1 -> Sum_t T1 T2 @@ -72,25 +72,25 @@ Arguments Sum_Left { _ } { _ }. Arguments Sum_Right { _ } { _ }. (** [no_nested_borrows::cast_u32_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 49:0-51:1 + Source: 'tests/src/no_nested_borrows.rs', lines 50:0-52:1 Visibility: public *) Definition cast_u32_to_i32 (x : u32) : result i32 := scalar_cast U32 I32 x. (** [no_nested_borrows::cast_bool_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 53:0-55:1 + Source: 'tests/src/no_nested_borrows.rs', lines 54:0-56:1 Visibility: public *) Definition cast_bool_to_i32 (x : bool) : result i32 := scalar_cast_bool I32 x. (** [no_nested_borrows::cast_bool_to_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 58:0-60:1 + Source: 'tests/src/no_nested_borrows.rs', lines 59:0-61:1 Visibility: public *) Definition cast_bool_to_bool (x : bool) : result bool := Ok x. (** [no_nested_borrows::test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 64:0-74:1 + Source: 'tests/src/no_nested_borrows.rs', lines 65:0-75:1 Visibility: public *) Definition test2 : result unit := _ <- u32_add 23%u32 44%u32; Ok tt. @@ -99,14 +99,14 @@ Definition test2 : result unit := Check (test2)%return. (** [no_nested_borrows::get_max]: - Source: 'tests/src/no_nested_borrows.rs', lines 76:0-82:1 + Source: 'tests/src/no_nested_borrows.rs', lines 77:0-83:1 Visibility: public *) Definition get_max (x : u32) (y : u32) : result u32 := if x s>= y then Ok x else Ok y . (** [no_nested_borrows::test3]: - Source: 'tests/src/no_nested_borrows.rs', lines 85:0-90:1 + Source: 'tests/src/no_nested_borrows.rs', lines 86:0-91:1 Visibility: public *) Definition test3 : result unit := x <- get_max 4%u32 3%u32; @@ -119,7 +119,7 @@ Definition test3 : result unit := Check (test3)%return. (** [no_nested_borrows::test_neg1]: - Source: 'tests/src/no_nested_borrows.rs', lines 93:0-97:1 + Source: 'tests/src/no_nested_borrows.rs', lines 94:0-98:1 Visibility: public *) Definition test_neg1 : result unit := y <- i32_neg 3%i32; massert (y s= (-3)%i32) @@ -129,7 +129,7 @@ Definition test_neg1 : result unit := Check (test_neg1)%return. (** [no_nested_borrows::refs_test1]: - Source: 'tests/src/no_nested_borrows.rs', lines 101:0-110:1 + Source: 'tests/src/no_nested_borrows.rs', lines 102:0-111:1 Visibility: public *) Definition refs_test1 : result unit := massert (1%i32 s= 1%i32). @@ -138,7 +138,7 @@ Definition refs_test1 : result unit := Check (refs_test1)%return. (** [no_nested_borrows::refs_test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 113:0-125:1 + Source: 'tests/src/no_nested_borrows.rs', lines 114:0-126:1 Visibility: public *) Definition refs_test2 : result unit := _ <- massert (2%i32 s= 2%i32); @@ -151,7 +151,7 @@ Definition refs_test2 : result unit := Check (refs_test2)%return. (** [no_nested_borrows::test_list1]: - Source: 'tests/src/no_nested_borrows.rs', lines 130:0-132:1 + Source: 'tests/src/no_nested_borrows.rs', lines 131:0-133:1 Visibility: public *) Definition test_list1 : result unit := Ok tt. @@ -160,31 +160,31 @@ Definition test_list1 : result unit := Check (test_list1)%return. (** [no_nested_borrows::copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 134:0-136:1 + Source: 'tests/src/no_nested_borrows.rs', lines 135:0-137:1 Visibility: public *) Definition copy_int (x : i32) : result i32 := Ok x. (** [no_nested_borrows::test_unreachable]: - Source: 'tests/src/no_nested_borrows.rs', lines 140:0-144:1 + Source: 'tests/src/no_nested_borrows.rs', lines 141:0-145:1 Visibility: public *) Definition test_unreachable (b : bool) : result unit := massert (negb b). (** [no_nested_borrows::test_panic]: - Source: 'tests/src/no_nested_borrows.rs', lines 147:0-151:1 + Source: 'tests/src/no_nested_borrows.rs', lines 148:0-152:1 Visibility: public *) Definition test_panic (b : bool) : result unit := massert (negb b). (** [no_nested_borrows::test_panic_msg]: - Source: 'tests/src/no_nested_borrows.rs', lines 155:0-159:1 + Source: 'tests/src/no_nested_borrows.rs', lines 156:0-160:1 Visibility: public *) Definition test_panic_msg (b : bool) : result unit := massert (negb b). (** [no_nested_borrows::test_copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 163:0-168:1 + Source: 'tests/src/no_nested_borrows.rs', lines 164:0-169:1 Visibility: public *) Definition test_copy_int : result unit := y <- copy_int 0%i32; massert (0%i32 s= y) @@ -194,14 +194,14 @@ Definition test_copy_int : result unit := Check (test_copy_int)%return. (** [no_nested_borrows::is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 170:0-175:1 + Source: 'tests/src/no_nested_borrows.rs', lines 171:0-176:1 Visibility: public *) Definition is_cons {T : Type} (l : List_t T) : result bool := match l with | List_Cons _ _ => Ok true | List_Nil => Ok false end . (** [no_nested_borrows::test_is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 178:0-182:1 + Source: 'tests/src/no_nested_borrows.rs', lines 179:0-183:1 Visibility: public *) Definition test_is_cons : result unit := b <- is_cons (List_Cons 0%i32 List_Nil); massert b @@ -211,14 +211,14 @@ Definition test_is_cons : result unit := Check (test_is_cons)%return. (** [no_nested_borrows::split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 184:0-189:1 + Source: 'tests/src/no_nested_borrows.rs', lines 185:0-190:1 Visibility: public *) Definition split_list {T : Type} (l : List_t T) : result (T * (List_t T)) := match l with | List_Cons hd tl => Ok (hd, tl) | List_Nil => Fail_ Failure end . (** [no_nested_borrows::test_split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 193:0-198:1 + Source: 'tests/src/no_nested_borrows.rs', lines 194:0-199:1 Visibility: public *) Definition test_split_list : result unit := p <- split_list (List_Cons 0%i32 List_Nil); @@ -230,7 +230,7 @@ Definition test_split_list : result unit := Check (test_split_list)%return. (** [no_nested_borrows::choose]: - Source: 'tests/src/no_nested_borrows.rs', lines 200:0-206:1 + Source: 'tests/src/no_nested_borrows.rs', lines 201:0-207:1 Visibility: public *) Definition choose {T : Type} (b : bool) (x : T) (y : T) : result (T * (T -> (T * T))) := @@ -240,7 +240,7 @@ Definition choose . (** [no_nested_borrows::choose_test]: - Source: 'tests/src/no_nested_borrows.rs', lines 209:0-218:1 + Source: 'tests/src/no_nested_borrows.rs', lines 210:0-219:1 Visibility: public *) Definition choose_test : result unit := p <- choose true 0%i32 0%i32; @@ -256,26 +256,26 @@ Definition choose_test : result unit := Check (choose_test)%return. (** [no_nested_borrows::test_char]: - Source: 'tests/src/no_nested_borrows.rs', lines 221:0-223:1 + Source: 'tests/src/no_nested_borrows.rs', lines 222:0-224:1 Visibility: public *) Definition test_char : result char := Ok (char_of_byte Coq.Init.Byte.x61). (** [no_nested_borrows::panic_mut_borrow]: - Source: 'tests/src/no_nested_borrows.rs', lines 226:0-228:1 + Source: 'tests/src/no_nested_borrows.rs', lines 227:0-229:1 Visibility: public *) Definition panic_mut_borrow (i : u32) : result u32 := Fail_ Failure. (** [no_nested_borrows::Tree] - Source: 'tests/src/no_nested_borrows.rs', lines 231:0-234:1 + Source: 'tests/src/no_nested_borrows.rs', lines 232:0-235:1 Visibility: public *) Inductive Tree_t (T : Type) := | Tree_Leaf : T -> Tree_t T | Tree_Node : T -> NodeElem_t T -> Tree_t T -> Tree_t T (** [no_nested_borrows::NodeElem] - Source: 'tests/src/no_nested_borrows.rs', lines 236:0-239:1 + Source: 'tests/src/no_nested_borrows.rs', lines 237:0-240:1 Visibility: public *) with NodeElem_t (T : Type) := | NodeElem_Cons : Tree_t T -> NodeElem_t T -> NodeElem_t T @@ -289,7 +289,7 @@ Arguments NodeElem_Cons { _ }. Arguments NodeElem_Nil { _ }. (** [no_nested_borrows::list_length]: - Source: 'tests/src/no_nested_borrows.rs', lines 272:0-277:1 + Source: 'tests/src/no_nested_borrows.rs', lines 273:0-278:1 Visibility: public *) Fixpoint list_length {T : Type} (l : List_t T) : result u32 := match l with @@ -299,7 +299,7 @@ Fixpoint list_length {T : Type} (l : List_t T) : result u32 := . (** [no_nested_borrows::list_nth_shared]: - Source: 'tests/src/no_nested_borrows.rs', lines 280:0-293:1 + Source: 'tests/src/no_nested_borrows.rs', lines 281:0-294:1 Visibility: public *) Fixpoint list_nth_shared {T : Type} (l : List_t T) (i : u32) : result T := match l with @@ -310,7 +310,7 @@ Fixpoint list_nth_shared {T : Type} (l : List_t T) (i : u32) : result T := . (** [no_nested_borrows::list_nth_mut]: - Source: 'tests/src/no_nested_borrows.rs', lines 296:0-309:1 + Source: 'tests/src/no_nested_borrows.rs', lines 297:0-310:1 Visibility: public *) Fixpoint list_nth_mut {T : Type} (l : List_t T) (i : u32) : result (T * (T -> List_t T)) := @@ -331,7 +331,7 @@ Fixpoint list_nth_mut . (** [no_nested_borrows::list_rev_aux]: - Source: 'tests/src/no_nested_borrows.rs', lines 312:0-322:1 + Source: 'tests/src/no_nested_borrows.rs', lines 313:0-323:1 Visibility: public *) Fixpoint list_rev_aux {T : Type} (li : List_t T) (lo : List_t T) : result (List_t T) := @@ -342,14 +342,14 @@ Fixpoint list_rev_aux . (** [no_nested_borrows::list_rev]: - Source: 'tests/src/no_nested_borrows.rs', lines 326:0-329:1 + Source: 'tests/src/no_nested_borrows.rs', lines 327:0-330:1 Visibility: public *) Definition list_rev {T : Type} (l : List_t T) : result (List_t T) := let (li, _) := core_mem_replace l List_Nil in list_rev_aux li List_Nil . (** [no_nested_borrows::test_list_functions]: - Source: 'tests/src/no_nested_borrows.rs', lines 332:0-346:1 + Source: 'tests/src/no_nested_borrows.rs', lines 333:0-347:1 Visibility: public *) Definition test_list_functions : result unit := i <- @@ -384,7 +384,7 @@ Definition test_list_functions : result unit := Check (test_list_functions)%return. (** [no_nested_borrows::id_mut_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 348:0-350:1 + Source: 'tests/src/no_nested_borrows.rs', lines 349:0-351:1 Visibility: public *) Definition id_mut_pair1 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -394,7 +394,7 @@ Definition id_mut_pair1 . (** [no_nested_borrows::id_mut_pair2]: - Source: 'tests/src/no_nested_borrows.rs', lines 352:0-354:1 + Source: 'tests/src/no_nested_borrows.rs', lines 353:0-355:1 Visibility: public *) Definition id_mut_pair2 {T1 : Type} {T2 : Type} (p : (T1 * T2)) : @@ -404,7 +404,7 @@ Definition id_mut_pair2 . (** [no_nested_borrows::id_mut_pair3]: - Source: 'tests/src/no_nested_borrows.rs', lines 356:0-358:1 + Source: 'tests/src/no_nested_borrows.rs', lines 357:0-359:1 Visibility: public *) Definition id_mut_pair3 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -414,7 +414,7 @@ Definition id_mut_pair3 . (** [no_nested_borrows::id_mut_pair4]: - Source: 'tests/src/no_nested_borrows.rs', lines 360:0-362:1 + Source: 'tests/src/no_nested_borrows.rs', lines 361:0-363:1 Visibility: public *) Definition id_mut_pair4 {T1 : Type} {T2 : Type} (p : (T1 * T2)) : @@ -424,7 +424,7 @@ Definition id_mut_pair4 . (** [no_nested_borrows::StructWithTuple] - Source: 'tests/src/no_nested_borrows.rs', lines 367:0-369:1 + Source: 'tests/src/no_nested_borrows.rs', lines 368:0-370:1 Visibility: public *) Record StructWithTuple_t (T1 : Type) (T2 : Type) := mkStructWithTuple_t { @@ -436,28 +436,28 @@ Arguments mkStructWithTuple_t { _ } { _ }. Arguments structWithTuple_p { _ } { _ }. (** [no_nested_borrows::new_tuple1]: - Source: 'tests/src/no_nested_borrows.rs', lines 371:0-373:1 + Source: 'tests/src/no_nested_borrows.rs', lines 372:0-374:1 Visibility: public *) Definition new_tuple1 : result (StructWithTuple_t u32 u32) := Ok {| structWithTuple_p := (1%u32, 2%u32) |} . (** [no_nested_borrows::new_tuple2]: - Source: 'tests/src/no_nested_borrows.rs', lines 375:0-377:1 + Source: 'tests/src/no_nested_borrows.rs', lines 376:0-378:1 Visibility: public *) Definition new_tuple2 : result (StructWithTuple_t i16 i16) := Ok {| structWithTuple_p := (1%i16, 2%i16) |} . (** [no_nested_borrows::new_tuple3]: - Source: 'tests/src/no_nested_borrows.rs', lines 379:0-381:1 + Source: 'tests/src/no_nested_borrows.rs', lines 380:0-382:1 Visibility: public *) Definition new_tuple3 : result (StructWithTuple_t u64 i64) := Ok {| structWithTuple_p := (1%u64, 2%i64) |} . (** [no_nested_borrows::StructWithPair] - Source: 'tests/src/no_nested_borrows.rs', lines 384:0-386:1 + Source: 'tests/src/no_nested_borrows.rs', lines 385:0-387:1 Visibility: public *) Record StructWithPair_t (T1 : Type) (T2 : Type) := mkStructWithPair_t { @@ -469,14 +469,14 @@ Arguments mkStructWithPair_t { _ } { _ }. Arguments structWithPair_p { _ } { _ }. (** [no_nested_borrows::new_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 388:0-394:1 + Source: 'tests/src/no_nested_borrows.rs', lines 389:0-395:1 Visibility: public *) Definition new_pair1 : result (StructWithPair_t u32 u32) := Ok {| structWithPair_p := {| pair_x := 1%u32; pair_y := 2%u32 |} |} . (** [no_nested_borrows::test_constants]: - Source: 'tests/src/no_nested_borrows.rs', lines 397:0-402:1 + Source: 'tests/src/no_nested_borrows.rs', lines 398:0-403:1 Visibility: public *) Definition test_constants : result unit := swt <- new_tuple1; @@ -496,7 +496,7 @@ Definition test_constants : result unit := Check (test_constants)%return. (** [no_nested_borrows::test_weird_borrows1]: - Source: 'tests/src/no_nested_borrows.rs', lines 407:0-415:1 + Source: 'tests/src/no_nested_borrows.rs', lines 408:0-416:1 Visibility: public *) Definition test_weird_borrows1 : result unit := Ok tt. @@ -505,7 +505,7 @@ Definition test_weird_borrows1 : result unit := Check (test_weird_borrows1)%return. (** [no_nested_borrows::test_mem_replace]: - Source: 'tests/src/no_nested_borrows.rs', lines 417:0-421:1 + Source: 'tests/src/no_nested_borrows.rs', lines 418:0-422:1 Visibility: public *) Definition test_mem_replace (px : u32) : result u32 := let (y, _) := core_mem_replace px 1%u32 in @@ -514,78 +514,78 @@ Definition test_mem_replace (px : u32) : result u32 := . (** [no_nested_borrows::test_shared_borrow_bool1]: - Source: 'tests/src/no_nested_borrows.rs', lines 424:0-433:1 + Source: 'tests/src/no_nested_borrows.rs', lines 425:0-434:1 Visibility: public *) Definition test_shared_borrow_bool1 (b : bool) : result u32 := if b then Ok 0%u32 else Ok 1%u32 . (** [no_nested_borrows::test_shared_borrow_bool2]: - Source: 'tests/src/no_nested_borrows.rs', lines 437:0-447:1 + Source: 'tests/src/no_nested_borrows.rs', lines 438:0-448:1 Visibility: public *) Definition test_shared_borrow_bool2 : result u32 := Ok 0%u32. (** [no_nested_borrows::test_shared_borrow_enum1]: - Source: 'tests/src/no_nested_borrows.rs', lines 452:0-460:1 + Source: 'tests/src/no_nested_borrows.rs', lines 453:0-461:1 Visibility: public *) Definition test_shared_borrow_enum1 (l : List_t u32) : result u32 := match l with | List_Cons _ _ => Ok 1%u32 | List_Nil => Ok 0%u32 end . (** [no_nested_borrows::test_shared_borrow_enum2]: - Source: 'tests/src/no_nested_borrows.rs', lines 464:0-473:1 + Source: 'tests/src/no_nested_borrows.rs', lines 465:0-474:1 Visibility: public *) Definition test_shared_borrow_enum2 : result u32 := Ok 0%u32. (** [no_nested_borrows::incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 475:0-477:1 + Source: 'tests/src/no_nested_borrows.rs', lines 476:0-478:1 Visibility: public *) Definition incr (x : u32) : result u32 := u32_add x 1%u32. (** [no_nested_borrows::call_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 479:0-482:1 + Source: 'tests/src/no_nested_borrows.rs', lines 480:0-483:1 Visibility: public *) Definition call_incr (x : u32) : result u32 := incr x. (** [no_nested_borrows::read_then_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 484:0-488:1 + Source: 'tests/src/no_nested_borrows.rs', lines 485:0-489:1 Visibility: public *) Definition read_then_incr (x : u32) : result (u32 * u32) := x1 <- u32_add x 1%u32; Ok (x, x1) . (** [no_nested_borrows::Tuple] - Source: 'tests/src/no_nested_borrows.rs', lines 490:0-490:33 + Source: 'tests/src/no_nested_borrows.rs', lines 491:0-491:33 Visibility: public *) Definition Tuple_t (T1 : Type) (T2 : Type) : Type := T1 * T2. (** [no_nested_borrows::read_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 492:0-494:1 + Source: 'tests/src/no_nested_borrows.rs', lines 493:0-495:1 Visibility: public *) Definition read_tuple (x : (u32 * u32)) : result u32 := let (i, _) := x in Ok i . (** [no_nested_borrows::update_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 496:0-498:1 + Source: 'tests/src/no_nested_borrows.rs', lines 497:0-499:1 Visibility: public *) Definition update_tuple (x : (u32 * u32)) : result (u32 * u32) := let (_, i) := x in Ok (1%u32, i) . (** [no_nested_borrows::read_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 500:0-502:1 + Source: 'tests/src/no_nested_borrows.rs', lines 501:0-503:1 Visibility: public *) Definition read_tuple_struct (x : Tuple_t u32 u32) : result u32 := let (i, _) := x in Ok i . (** [no_nested_borrows::update_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 504:0-506:1 + Source: 'tests/src/no_nested_borrows.rs', lines 505:0-507:1 Visibility: public *) Definition update_tuple_struct (x : Tuple_t u32 u32) : result (Tuple_t u32 u32) := @@ -593,7 +593,7 @@ Definition update_tuple_struct . (** [no_nested_borrows::create_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 508:0-510:1 + Source: 'tests/src/no_nested_borrows.rs', lines 509:0-511:1 Visibility: public *) Definition create_tuple_struct (x : u32) (y : u64) : result (Tuple_t u32 u64) := @@ -601,42 +601,42 @@ Definition create_tuple_struct . (** [no_nested_borrows::IdType] - Source: 'tests/src/no_nested_borrows.rs', lines 513:0-513:24 + Source: 'tests/src/no_nested_borrows.rs', lines 514:0-514:24 Visibility: public *) Definition IdType_t (T : Type) : Type := T. (** [no_nested_borrows::use_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 515:0-517:1 + Source: 'tests/src/no_nested_borrows.rs', lines 516:0-518:1 Visibility: public *) Definition use_id_type {T : Type} (x : IdType_t T) : result T := Ok x. (** [no_nested_borrows::create_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 519:0-521:1 + Source: 'tests/src/no_nested_borrows.rs', lines 520:0-522:1 Visibility: public *) Definition create_id_type {T : Type} (x : T) : result (IdType_t T) := Ok x. (** [no_nested_borrows::not_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 523:0-525:1 + Source: 'tests/src/no_nested_borrows.rs', lines 524:0-526:1 Visibility: public *) Definition not_bool (x : bool) : result bool := Ok (negb x). (** [no_nested_borrows::not_u32]: - Source: 'tests/src/no_nested_borrows.rs', lines 527:0-529:1 + Source: 'tests/src/no_nested_borrows.rs', lines 528:0-530:1 Visibility: public *) Definition not_u32 (x : u32) : result u32 := Ok (scalar_not x). (** [no_nested_borrows::not_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 531:0-533:1 + Source: 'tests/src/no_nested_borrows.rs', lines 532:0-534:1 Visibility: public *) Definition not_i32 (x : i32) : result i32 := Ok (scalar_not x). (** [no_nested_borrows::borrow_mut_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 535:0-537:1 *) + Source: 'tests/src/no_nested_borrows.rs', lines 536:0-538:1 *) Definition borrow_mut_tuple {T : Type} {U : Type} (x : (T * U)) : result ((T * U) * ((T * U) -> (T * U))) @@ -645,12 +645,12 @@ Definition borrow_mut_tuple . (** [no_nested_borrows::ExpandSimpliy::Wrapper] - Source: 'tests/src/no_nested_borrows.rs', lines 541:4-541:32 + Source: 'tests/src/no_nested_borrows.rs', lines 542:4-542:32 Visibility: public *) Definition ExpandSimpliy_Wrapper_t (T : Type) : Type := T * T. (** [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb1]: - Source: 'tests/src/no_nested_borrows.rs', lines 543:4-549:5 + Source: 'tests/src/no_nested_borrows.rs', lines 544:4-550:5 Visibility: public *) Definition expandSimpliy_check_expand_simplify_symb1 (x : ExpandSimpliy_Wrapper_t bool) : result (ExpandSimpliy_Wrapper_t bool) := @@ -658,7 +658,7 @@ Definition expandSimpliy_check_expand_simplify_symb1 . (** [no_nested_borrows::ExpandSimpliy::Wrapper2] - Source: 'tests/src/no_nested_borrows.rs', lines 551:4-554:5 + Source: 'tests/src/no_nested_borrows.rs', lines 552:4-555:5 Visibility: public *) Record ExpandSimpliy_Wrapper2_t := mkExpandSimpliy_Wrapper2_t { @@ -667,7 +667,7 @@ mkExpandSimpliy_Wrapper2_t { . (** [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb2]: - Source: 'tests/src/no_nested_borrows.rs', lines 556:4-562:5 + Source: 'tests/src/no_nested_borrows.rs', lines 557:4-563:5 Visibility: public *) Definition expandSimpliy_check_expand_simplify_symb2 (x : ExpandSimpliy_Wrapper2_t) : result ExpandSimpliy_Wrapper2_t := diff --git a/tests/coq/misc/Paper.v b/tests/coq/misc/Paper.v index 009dcf180..6de9eac57 100644 --- a/tests/coq/misc/Paper.v +++ b/tests/coq/misc/Paper.v @@ -9,13 +9,13 @@ Local Open Scope Primitives_scope. Module Paper. (** [paper::ref_incr]: - Source: 'tests/src/paper.rs', lines 7:0-9:1 + Source: 'tests/src/paper.rs', lines 8:0-10:1 Visibility: public *) Definition ref_incr (x : i32) : result i32 := i32_add x 1%i32. (** [paper::test_incr]: - Source: 'tests/src/paper.rs', lines 12:0-16:1 + Source: 'tests/src/paper.rs', lines 13:0-17:1 Visibility: public *) Definition test_incr : result unit := x <- ref_incr 0%i32; massert (x s= 1%i32) @@ -25,7 +25,7 @@ Definition test_incr : result unit := Check (test_incr)%return. (** [paper::choose]: - Source: 'tests/src/paper.rs', lines 19:0-25:1 + Source: 'tests/src/paper.rs', lines 20:0-26:1 Visibility: public *) Definition choose {T : Type} (b : bool) (x : T) (y : T) : result (T * (T -> (T * T))) := @@ -35,7 +35,7 @@ Definition choose . (** [paper::test_choose]: - Source: 'tests/src/paper.rs', lines 28:0-36:1 + Source: 'tests/src/paper.rs', lines 29:0-37:1 Visibility: public *) Definition test_choose : result unit := p <- choose true 0%i32 0%i32; @@ -51,7 +51,7 @@ Definition test_choose : result unit := Check (test_choose)%return. (** [paper::List] - Source: 'tests/src/paper.rs', lines 40:0-43:1 + Source: 'tests/src/paper.rs', lines 41:0-44:1 Visibility: public *) Inductive List_t (T : Type) := | List_Cons : T -> List_t T -> List_t T @@ -62,7 +62,7 @@ Arguments List_Cons { _ }. Arguments List_Nil { _ }. (** [paper::list_nth_mut]: - Source: 'tests/src/paper.rs', lines 47:0-60:1 + Source: 'tests/src/paper.rs', lines 48:0-61:1 Visibility: public *) Fixpoint list_nth_mut {T : Type} (l : List_t T) (i : u32) : result (T * (T -> List_t T)) := @@ -83,7 +83,7 @@ Fixpoint list_nth_mut . (** [paper::sum]: - Source: 'tests/src/paper.rs', lines 62:0-71:1 + Source: 'tests/src/paper.rs', lines 63:0-72:1 Visibility: public *) Fixpoint sum (l : List_t i32) : result i32 := match l with @@ -93,7 +93,7 @@ Fixpoint sum (l : List_t i32) : result i32 := . (** [paper::test_nth]: - Source: 'tests/src/paper.rs', lines 74:0-79:1 + Source: 'tests/src/paper.rs', lines 75:0-80:1 Visibility: public *) Definition test_nth : result unit := p <- @@ -110,7 +110,7 @@ Definition test_nth : result unit := Check (test_nth)%return. (** [paper::call_choose]: - Source: 'tests/src/paper.rs', lines 82:0-88:1 + Source: 'tests/src/paper.rs', lines 83:0-89:1 Visibility: public *) Definition call_choose (p : (u32 * u32)) : result u32 := let (px, py) := p in diff --git a/tests/fstar/misc/Paper.fst b/tests/fstar/misc/Paper.fst index cddb1275b..435e98666 100644 --- a/tests/fstar/misc/Paper.fst +++ b/tests/fstar/misc/Paper.fst @@ -6,13 +6,13 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [paper::ref_incr]: - Source: 'tests/src/paper.rs', lines 7:0-9:1 + Source: 'tests/src/paper.rs', lines 8:0-10:1 Visibility: public *) let ref_incr (x : i32) : result i32 = i32_add x 1 (** [paper::test_incr]: - Source: 'tests/src/paper.rs', lines 12:0-16:1 + Source: 'tests/src/paper.rs', lines 13:0-17:1 Visibility: public *) let test_incr : result unit = let* x = ref_incr 0 in massert (x = 1) @@ -21,7 +21,7 @@ let test_incr : result unit = let _ = assert_norm (test_incr = Ok ()) (** [paper::choose]: - Source: 'tests/src/paper.rs', lines 19:0-25:1 + Source: 'tests/src/paper.rs', lines 20:0-26:1 Visibility: public *) let choose (#t : Type0) (b : bool) (x : t) (y : t) : result (t & (t -> (t & t))) = @@ -30,7 +30,7 @@ let choose else let back = fun y1 -> (x, y1) in Ok (y, back) (** [paper::test_choose]: - Source: 'tests/src/paper.rs', lines 28:0-36:1 + Source: 'tests/src/paper.rs', lines 29:0-37:1 Visibility: public *) let test_choose : result unit = let* (z, choose_back) = choose true 0 0 in @@ -44,14 +44,14 @@ let test_choose : result unit = let _ = assert_norm (test_choose = Ok ()) (** [paper::List] - Source: 'tests/src/paper.rs', lines 40:0-43:1 + Source: 'tests/src/paper.rs', lines 41:0-44:1 Visibility: public *) type list_t (t : Type0) = | List_Cons : t -> list_t t -> list_t t | List_Nil : list_t t (** [paper::list_nth_mut]: - Source: 'tests/src/paper.rs', lines 47:0-60:1 + Source: 'tests/src/paper.rs', lines 48:0-61:1 Visibility: public *) let rec list_nth_mut (#t : Type0) (l : list_t t) (i : u32) : result (t & (t -> list_t t)) = @@ -68,7 +68,7 @@ let rec list_nth_mut end (** [paper::sum]: - Source: 'tests/src/paper.rs', lines 62:0-71:1 + Source: 'tests/src/paper.rs', lines 63:0-72:1 Visibility: public *) let rec sum (l : list_t i32) : result i32 = begin match l with @@ -77,7 +77,7 @@ let rec sum (l : list_t i32) : result i32 = end (** [paper::test_nth]: - Source: 'tests/src/paper.rs', lines 74:0-79:1 + Source: 'tests/src/paper.rs', lines 75:0-80:1 Visibility: public *) let test_nth : result unit = let* (x, list_nth_mut_back) = @@ -92,7 +92,7 @@ let test_nth : result unit = let _ = assert_norm (test_nth = Ok ()) (** [paper::call_choose]: - Source: 'tests/src/paper.rs', lines 82:0-88:1 + Source: 'tests/src/paper.rs', lines 83:0-89:1 Visibility: public *) let call_choose (p : (u32 & u32)) : result u32 = let (px, py) = p in diff --git a/tests/lean/CastSigned.lean b/tests/lean/CastSigned.lean index 822364535..1a63c7ddc 100644 --- a/tests/lean/CastSigned.lean +++ b/tests/lean/CastSigned.lean @@ -1,8 +1,6 @@ -module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cast_signed] -public import Aeneas -@[expose] public section +import Aeneas open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false @@ -17,7 +15,7 @@ set_option maxRecDepth 2048 namespace cast_signed /-- [cast_signed::test_u8_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 9:0-13:1 + Source: 'tests/src/cast_signed.rs', lines 10:0-14:1 Visibility: public -/ def test_u8_cast_signed_all_ones : Result Unit := do let y ← core.num.U8.cast_signed 255#u8 @@ -27,7 +25,7 @@ def test_u8_cast_signed_all_ones : Result Unit := do #assert (test_u8_cast_signed_all_ones == ok ()) /-- [cast_signed::test_i8_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 17:0-21:1 + Source: 'tests/src/cast_signed.rs', lines 18:0-22:1 Visibility: public -/ def test_i8_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I8.cast_unsigned (-1)#i8 @@ -37,7 +35,7 @@ def test_i8_cast_unsigned_neg_one : Result Unit := do #assert (test_i8_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_u16_cast_signed_high_bit]: - Source: 'tests/src/cast_signed.rs', lines 25:0-29:1 + Source: 'tests/src/cast_signed.rs', lines 26:0-30:1 Visibility: public -/ def test_u16_cast_signed_high_bit : Result Unit := do let y ← core.num.U16.cast_signed 32768#u16 @@ -47,7 +45,7 @@ def test_u16_cast_signed_high_bit : Result Unit := do #assert (test_u16_cast_signed_high_bit == ok ()) /-- [cast_signed::test_i16_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 33:0-37:1 + Source: 'tests/src/cast_signed.rs', lines 34:0-38:1 Visibility: public -/ def test_i16_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I16.cast_unsigned (-1)#i16 @@ -57,7 +55,7 @@ def test_i16_cast_unsigned_neg_one : Result Unit := do #assert (test_i16_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_u32_cast_signed_small]: - Source: 'tests/src/cast_signed.rs', lines 41:0-45:1 + Source: 'tests/src/cast_signed.rs', lines 42:0-46:1 Visibility: public -/ def test_u32_cast_signed_small : Result Unit := do let y ← core.num.U32.cast_signed 255#u32 @@ -67,7 +65,7 @@ def test_u32_cast_signed_small : Result Unit := do #assert (test_u32_cast_signed_small == ok ()) /-- [cast_signed::test_u32_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 49:0-53:1 + Source: 'tests/src/cast_signed.rs', lines 50:0-54:1 Visibility: public -/ def test_u32_cast_signed_all_ones : Result Unit := do let y ← core.num.U32.cast_signed 4294967295#u32 @@ -77,7 +75,7 @@ def test_u32_cast_signed_all_ones : Result Unit := do #assert (test_u32_cast_signed_all_ones == ok ()) /-- [cast_signed::test_u32_cast_signed_high_bit]: - Source: 'tests/src/cast_signed.rs', lines 57:0-61:1 + Source: 'tests/src/cast_signed.rs', lines 58:0-62:1 Visibility: public -/ def test_u32_cast_signed_high_bit : Result Unit := do let y ← core.num.U32.cast_signed 2147483648#u32 @@ -87,7 +85,7 @@ def test_u32_cast_signed_high_bit : Result Unit := do #assert (test_u32_cast_signed_high_bit == ok ()) /-- [cast_signed::test_i32_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 65:0-69:1 + Source: 'tests/src/cast_signed.rs', lines 66:0-70:1 Visibility: public -/ def test_i32_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I32.cast_unsigned (-1)#i32 @@ -97,7 +95,7 @@ def test_i32_cast_unsigned_neg_one : Result Unit := do #assert (test_i32_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_i32_cast_roundtrip]: - Source: 'tests/src/cast_signed.rs', lines 73:0-77:1 + Source: 'tests/src/cast_signed.rs', lines 74:0-78:1 Visibility: public -/ def test_i32_cast_roundtrip : Result Unit := do let i ← core.num.U32.cast_signed 3735928559#u32 @@ -108,7 +106,7 @@ def test_i32_cast_roundtrip : Result Unit := do #assert (test_i32_cast_roundtrip == ok ()) /-- [cast_signed::test_u64_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 81:0-85:1 + Source: 'tests/src/cast_signed.rs', lines 82:0-86:1 Visibility: public -/ def test_u64_cast_signed_all_ones : Result Unit := do let y ← core.num.U64.cast_signed core.num.U64.MAX @@ -118,7 +116,7 @@ def test_u64_cast_signed_all_ones : Result Unit := do #assert (test_u64_cast_signed_all_ones == ok ()) /-- [cast_signed::test_i64_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 89:0-93:1 + Source: 'tests/src/cast_signed.rs', lines 90:0-94:1 Visibility: public -/ def test_i64_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I64.cast_unsigned (-1)#i64 @@ -128,7 +126,7 @@ def test_i64_cast_unsigned_neg_one : Result Unit := do #assert (test_i64_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_u128_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 97:0-101:1 + Source: 'tests/src/cast_signed.rs', lines 98:0-102:1 Visibility: public -/ def test_u128_cast_signed_all_ones : Result Unit := do let y ← core.num.U128.cast_signed core.num.U128.MAX @@ -138,7 +136,7 @@ def test_u128_cast_signed_all_ones : Result Unit := do #assert (test_u128_cast_signed_all_ones == ok ()) /-- [cast_signed::test_i128_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 105:0-109:1 + Source: 'tests/src/cast_signed.rs', lines 106:0-110:1 Visibility: public -/ def test_i128_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I128.cast_unsigned (-1)#i128 @@ -148,7 +146,7 @@ def test_i128_cast_unsigned_neg_one : Result Unit := do #assert (test_i128_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_usize_cast_roundtrip]: - Source: 'tests/src/cast_signed.rs', lines 113:0-117:1 + Source: 'tests/src/cast_signed.rs', lines 114:0-118:1 Visibility: public -/ def test_usize_cast_roundtrip : Result Unit := do let i ← core.num.Usize.cast_signed 12345#usize @@ -159,7 +157,7 @@ def test_usize_cast_roundtrip : Result Unit := do #assert (test_usize_cast_roundtrip == ok ()) /-- [cast_signed::test_isize_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 121:0-125:1 + Source: 'tests/src/cast_signed.rs', lines 122:0-126:1 Visibility: public -/ def test_isize_cast_unsigned_neg_one : Result Unit := do let y ← core.num.Isize.cast_unsigned (-1)#isize diff --git a/tests/lean/ChunksExact.lean b/tests/lean/ChunksExact.lean index 4e6dab516..3c5d34087 100644 --- a/tests/lean/ChunksExact.lean +++ b/tests/lean/ChunksExact.lean @@ -15,7 +15,7 @@ set_option maxRecDepth 2048 namespace chunks_exact /-- [chunks_exact::test_chunks_exact_exact_fit]: - Source: 'tests/src/chunks_exact.rs', lines 8:0-22:1 + Source: 'tests/src/chunks_exact.rs', lines 9:0-23:1 Visibility: public -/ def test_chunks_exact_exact_fit : Result Unit := do let s ← @@ -49,7 +49,7 @@ def test_chunks_exact_exact_fit : Result Unit := do #assert (test_chunks_exact_exact_fit == ok ()) /-- [chunks_exact::test_chunks_exact_with_remainder]: - Source: 'tests/src/chunks_exact.rs', lines 26:0-41:1 + Source: 'tests/src/chunks_exact.rs', lines 27:0-42:1 Visibility: public -/ def test_chunks_exact_with_remainder : Result Unit := do let s ← @@ -85,7 +85,7 @@ def test_chunks_exact_with_remainder : Result Unit := do #assert (test_chunks_exact_with_remainder == ok ()) /-- [chunks_exact::test_chunks_exact_remainder_2]: - Source: 'tests/src/chunks_exact.rs', lines 45:0-57:1 + Source: 'tests/src/chunks_exact.rs', lines 46:0-58:1 Visibility: public -/ def test_chunks_exact_remainder_2 : Result Unit := do let s ← @@ -115,7 +115,7 @@ def test_chunks_exact_remainder_2 : Result Unit := do #assert (test_chunks_exact_remainder_2 == ok ()) /-- [chunks_exact::test_chunks_exact_size_1]: - Source: 'tests/src/chunks_exact.rs', lines 61:0-73:1 + Source: 'tests/src/chunks_exact.rs', lines 62:0-74:1 Visibility: public -/ def test_chunks_exact_size_1 : Result Unit := do let s ← @@ -144,7 +144,7 @@ def test_chunks_exact_size_1 : Result Unit := do #assert (test_chunks_exact_size_1 == ok ()) /-- [chunks_exact::test_chunks_exact_empty]: - Source: 'tests/src/chunks_exact.rs', lines 77:0-83:1 + Source: 'tests/src/chunks_exact.rs', lines 78:0-84:1 Visibility: public -/ def test_chunks_exact_empty : Result Unit := do let s ← lift (Array.to_slice (Std.Array.empty Std.U32)) @@ -160,7 +160,7 @@ def test_chunks_exact_empty : Result Unit := do #assert (test_chunks_exact_empty == ok ()) /-- [chunks_exact::test_chunks_exact_chunk_larger_than_slice]: - Source: 'tests/src/chunks_exact.rs', lines 87:0-95:1 + Source: 'tests/src/chunks_exact.rs', lines 88:0-96:1 Visibility: public -/ def test_chunks_exact_chunk_larger_than_slice : Result Unit := do let s ← lift (Array.to_slice (Array.make 2#usize [ 1#u32, 2#u32 ])) @@ -180,7 +180,7 @@ def test_chunks_exact_chunk_larger_than_slice : Result Unit := do #assert (test_chunks_exact_chunk_larger_than_slice == ok ()) /-- [chunks_exact::test_chunks_exact_chunk_equals_slice]: - Source: 'tests/src/chunks_exact.rs', lines 99:0-109:1 + Source: 'tests/src/chunks_exact.rs', lines 100:0-110:1 Visibility: public -/ def test_chunks_exact_chunk_equals_slice : Result Unit := do let s ← lift (Array.to_slice (Array.make 3#usize [ 1#u32, 2#u32, 3#u32 ])) @@ -204,7 +204,7 @@ def test_chunks_exact_chunk_equals_slice : Result Unit := do #assert (test_chunks_exact_chunk_equals_slice == ok ()) /-- [chunks_exact::test_chunks_exact_2_odd]: - Source: 'tests/src/chunks_exact.rs', lines 113:0-126:1 + Source: 'tests/src/chunks_exact.rs', lines 114:0-127:1 Visibility: public -/ def test_chunks_exact_2_odd : Result Unit := do let s ← @@ -236,7 +236,7 @@ def test_chunks_exact_2_odd : Result Unit := do #assert (test_chunks_exact_2_odd == ok ()) /-- [chunks_exact::test_chunks_exact_2_single_element]: - Source: 'tests/src/chunks_exact.rs', lines 130:0-137:1 + Source: 'tests/src/chunks_exact.rs', lines 131:0-138:1 Visibility: public -/ def test_chunks_exact_2_single_element : Result Unit := do let s ← lift (Array.to_slice (Array.make 1#usize [ 42#u32 ])) diff --git a/tests/lean/IterAdapters.lean b/tests/lean/IterAdapters.lean index f1aee0526..357d1d873 100644 --- a/tests/lean/IterAdapters.lean +++ b/tests/lean/IterAdapters.lean @@ -15,7 +15,7 @@ set_option maxRecDepth 2048 namespace iter_adapters /-- [iter_adapters::test_enumerate_slice]: - Source: 'tests/src/iter_adapters.rs', lines 14:0-24:1 + Source: 'tests/src/iter_adapters.rs', lines 15:0-25:1 Visibility: public -/ def test_enumerate_slice : Result Unit := do let s ← @@ -52,7 +52,7 @@ def test_enumerate_slice : Result Unit := do #assert (test_enumerate_slice == ok ()) /-- [iter_adapters::test_enumerate_empty]: - Source: 'tests/src/iter_adapters.rs', lines 28:0-32:1 + Source: 'tests/src/iter_adapters.rs', lines 29:0-33:1 Visibility: public -/ def test_enumerate_empty : Result Unit := do let s ← lift (Array.to_slice (Std.Array.empty Std.U32)) @@ -70,7 +70,7 @@ def test_enumerate_empty : Result Unit := do #assert (test_enumerate_empty == ok ()) /-- [iter_adapters::test_take_2]: - Source: 'tests/src/iter_adapters.rs', lines 40:0-46:1 + Source: 'tests/src/iter_adapters.rs', lines 41:0-47:1 Visibility: public -/ def test_take_2 : Result Unit := do let s ← @@ -100,7 +100,7 @@ def test_take_2 : Result Unit := do #assert (test_take_2 == ok ()) /-- [iter_adapters::test_take_0]: - Source: 'tests/src/iter_adapters.rs', lines 50:0-54:1 + Source: 'tests/src/iter_adapters.rs', lines 51:0-55:1 Visibility: public -/ def test_take_0 : Result Unit := do let s ← @@ -119,7 +119,7 @@ def test_take_0 : Result Unit := do #assert (test_take_0 == ok ()) /-- [iter_adapters::test_take_more_than_available]: - Source: 'tests/src/iter_adapters.rs', lines 58:0-65:1 + Source: 'tests/src/iter_adapters.rs', lines 59:0-66:1 Visibility: public -/ def test_take_more_than_available : Result Unit := do let s ← lift (Array.to_slice (Array.make 3#usize [ 1#u32, 2#u32, 3#u32 ])) @@ -152,7 +152,7 @@ def test_take_more_than_available : Result Unit := do #assert (test_take_more_than_available == ok ()) /-- [iter_adapters::test_range_u8]: loop body 0: - Source: 'tests/src/iter_adapters.rs', lines 75:4-77:5 + Source: 'tests/src/iter_adapters.rs', lines 76:4-78:5 Visibility: public -/ @[rust_loop_body] def test_range_u8_loop.body @@ -167,7 +167,7 @@ def test_range_u8_loop.body ok (cont (iter1, count1)) /-- [iter_adapters::test_range_u8]: loop 0: - Source: 'tests/src/iter_adapters.rs', lines 75:4-77:5 + Source: 'tests/src/iter_adapters.rs', lines 76:4-78:5 Visibility: public -/ @[rust_loop] def test_range_u8_loop @@ -177,7 +177,7 @@ def test_range_u8_loop (iter, count) /-- [iter_adapters::test_range_u8]: - Source: 'tests/src/iter_adapters.rs', lines 73:0-79:1 + Source: 'tests/src/iter_adapters.rs', lines 74:0-80:1 Visibility: public -/ def test_range_u8 : Result Unit := do let count ← test_range_u8_loop { start := 0#u8, «end» := 5#u8 } 0#u32 @@ -187,7 +187,7 @@ def test_range_u8 : Result Unit := do #assert (test_range_u8 == ok ()) /-- [iter_adapters::test_range_u16]: loop body 0: - Source: 'tests/src/iter_adapters.rs', lines 85:4-87:5 + Source: 'tests/src/iter_adapters.rs', lines 86:4-88:5 Visibility: public -/ @[rust_loop_body] def test_range_u16_loop.body @@ -202,7 +202,7 @@ def test_range_u16_loop.body ok (cont (iter1, count1)) /-- [iter_adapters::test_range_u16]: loop 0: - Source: 'tests/src/iter_adapters.rs', lines 85:4-87:5 + Source: 'tests/src/iter_adapters.rs', lines 86:4-88:5 Visibility: public -/ @[rust_loop] def test_range_u16_loop @@ -214,7 +214,7 @@ def test_range_u16_loop (iter, count) /-- [iter_adapters::test_range_u16]: - Source: 'tests/src/iter_adapters.rs', lines 83:0-89:1 + Source: 'tests/src/iter_adapters.rs', lines 84:0-90:1 Visibility: public -/ def test_range_u16 : Result Unit := do let count ← test_range_u16_loop { start := 0#u16, «end» := 4#u16 } 0#u32 @@ -224,7 +224,7 @@ def test_range_u16 : Result Unit := do #assert (test_range_u16 == ok ()) /-- [iter_adapters::test_range_u32]: loop body 0: - Source: 'tests/src/iter_adapters.rs', lines 95:4-97:5 + Source: 'tests/src/iter_adapters.rs', lines 96:4-98:5 Visibility: public -/ @[rust_loop_body] def test_range_u32_loop.body @@ -239,7 +239,7 @@ def test_range_u32_loop.body ok (cont (iter1, count1)) /-- [iter_adapters::test_range_u32]: loop 0: - Source: 'tests/src/iter_adapters.rs', lines 95:4-97:5 + Source: 'tests/src/iter_adapters.rs', lines 96:4-98:5 Visibility: public -/ @[rust_loop] def test_range_u32_loop @@ -251,7 +251,7 @@ def test_range_u32_loop (iter, count) /-- [iter_adapters::test_range_u32]: - Source: 'tests/src/iter_adapters.rs', lines 93:0-99:1 + Source: 'tests/src/iter_adapters.rs', lines 94:0-100:1 Visibility: public -/ def test_range_u32 : Result Unit := do let count ← test_range_u32_loop { start := 0#u32, «end» := 3#u32 } 0#u32 @@ -261,7 +261,7 @@ def test_range_u32 : Result Unit := do #assert (test_range_u32 == ok ()) /-- [iter_adapters::test_range_u64]: loop body 0: - Source: 'tests/src/iter_adapters.rs', lines 105:4-107:5 + Source: 'tests/src/iter_adapters.rs', lines 106:4-108:5 Visibility: public -/ @[rust_loop_body] def test_range_u64_loop.body @@ -276,7 +276,7 @@ def test_range_u64_loop.body ok (cont (iter1, count1)) /-- [iter_adapters::test_range_u64]: loop 0: - Source: 'tests/src/iter_adapters.rs', lines 105:4-107:5 + Source: 'tests/src/iter_adapters.rs', lines 106:4-108:5 Visibility: public -/ @[rust_loop] def test_range_u64_loop @@ -288,7 +288,7 @@ def test_range_u64_loop (iter, count) /-- [iter_adapters::test_range_u64]: - Source: 'tests/src/iter_adapters.rs', lines 103:0-109:1 + Source: 'tests/src/iter_adapters.rs', lines 104:0-110:1 Visibility: public -/ def test_range_u64 : Result Unit := do let count ← test_range_u64_loop { start := 0#u64, «end» := 4#u64 } 0#u64 @@ -298,7 +298,7 @@ def test_range_u64 : Result Unit := do #assert (test_range_u64 == ok ()) /-- [iter_adapters::test_range_usize]: loop body 0: - Source: 'tests/src/iter_adapters.rs', lines 115:4-117:5 + Source: 'tests/src/iter_adapters.rs', lines 116:4-118:5 Visibility: public -/ @[rust_loop_body] def test_range_usize_loop.body @@ -314,7 +314,7 @@ def test_range_usize_loop.body ok (cont (iter1, count1)) /-- [iter_adapters::test_range_usize]: loop 0: - Source: 'tests/src/iter_adapters.rs', lines 115:4-117:5 + Source: 'tests/src/iter_adapters.rs', lines 116:4-118:5 Visibility: public -/ @[rust_loop] def test_range_usize_loop @@ -326,7 +326,7 @@ def test_range_usize_loop (iter, count) /-- [iter_adapters::test_range_usize]: - Source: 'tests/src/iter_adapters.rs', lines 113:0-119:1 + Source: 'tests/src/iter_adapters.rs', lines 114:0-120:1 Visibility: public -/ def test_range_usize : Result Unit := do let count ← @@ -337,7 +337,7 @@ def test_range_usize : Result Unit := do #assert (test_range_usize == ok ()) /-- [iter_adapters::test_range_empty]: loop body 0: - Source: 'tests/src/iter_adapters.rs', lines 125:4-127:5 + Source: 'tests/src/iter_adapters.rs', lines 126:4-128:5 Visibility: public -/ @[rust_loop_body] def test_range_empty_loop.body @@ -352,7 +352,7 @@ def test_range_empty_loop.body ok (cont (iter1, count1)) /-- [iter_adapters::test_range_empty]: loop 0: - Source: 'tests/src/iter_adapters.rs', lines 125:4-127:5 + Source: 'tests/src/iter_adapters.rs', lines 126:4-128:5 Visibility: public -/ @[rust_loop] def test_range_empty_loop @@ -362,7 +362,7 @@ def test_range_empty_loop (iter, count) /-- [iter_adapters::test_range_empty]: - Source: 'tests/src/iter_adapters.rs', lines 123:0-129:1 + Source: 'tests/src/iter_adapters.rs', lines 124:0-130:1 Visibility: public -/ def test_range_empty : Result Unit := do let count ← test_range_empty_loop { start := 5#u8, «end» := 5#u8 } 0#u32 @@ -372,7 +372,7 @@ def test_range_empty : Result Unit := do #assert (test_range_empty == ok ()) /-- [iter_adapters::test_array_into_iter]: - Source: 'tests/src/iter_adapters.rs', lines 137:0-144:1 + Source: 'tests/src/iter_adapters.rs', lines 138:0-145:1 Visibility: public -/ def test_array_into_iter : Result Unit := do let s ← @@ -395,7 +395,7 @@ def test_array_into_iter : Result Unit := do #assert (test_array_into_iter == ok ()) /-- [iter_adapters::test_slice_into_iter]: - Source: 'tests/src/iter_adapters.rs', lines 148:0-157:1 + Source: 'tests/src/iter_adapters.rs', lines 149:0-158:1 Visibility: public -/ def test_slice_into_iter : Result Unit := do let s ← @@ -421,7 +421,7 @@ def test_slice_into_iter : Result Unit := do #assert (test_slice_into_iter == ok ()) /-- [iter_adapters::test_enumerate_step_by]: - Source: 'tests/src/iter_adapters.rs', lines 165:0-172:1 + Source: 'tests/src/iter_adapters.rs', lines 166:0-173:1 Visibility: public -/ def test_enumerate_step_by : Result Unit := do let s ← @@ -454,7 +454,7 @@ def test_enumerate_step_by : Result Unit := do #assert (test_enumerate_step_by == ok ()) /-- [iter_adapters::test_enumerate_take]: - Source: 'tests/src/iter_adapters.rs', lines 176:0-184:1 + Source: 'tests/src/iter_adapters.rs', lines 177:0-185:1 Visibility: public -/ def test_enumerate_take : Result Unit := do let s ← @@ -493,7 +493,7 @@ def test_enumerate_take : Result Unit := do #assert (test_enumerate_take == ok ()) /-- [iter_adapters::test_take_exhausted_then_next]: - Source: 'tests/src/iter_adapters.rs', lines 188:0-197:1 + Source: 'tests/src/iter_adapters.rs', lines 189:0-198:1 Visibility: public -/ def test_take_exhausted_then_next : Result Unit := do let s ← lift (Array.to_slice (Array.make 1#usize [ 42#u32 ])) @@ -521,7 +521,7 @@ def test_take_exhausted_then_next : Result Unit := do #assert (test_take_exhausted_then_next == ok ()) /-- [iter_adapters::test_range_single_element]: - Source: 'tests/src/iter_adapters.rs', lines 206:0-210:1 + Source: 'tests/src/iter_adapters.rs', lines 207:0-211:1 Visibility: public -/ def test_range_single_element : Result Unit := do let (o, it) ← @@ -537,7 +537,7 @@ def test_range_single_element : Result Unit := do #assert (test_range_single_element == ok ()) /-- [iter_adapters::test_range_u8_near_max]: - Source: 'tests/src/iter_adapters.rs', lines 214:0-218:1 + Source: 'tests/src/iter_adapters.rs', lines 215:0-219:1 Visibility: public -/ def test_range_u8_near_max : Result Unit := do let (o, it) ← @@ -553,7 +553,7 @@ def test_range_u8_near_max : Result Unit := do #assert (test_range_u8_near_max == ok ()) /-- [iter_adapters::test_range_u8_start_gt_end]: - Source: 'tests/src/iter_adapters.rs', lines 222:0-225:1 + Source: 'tests/src/iter_adapters.rs', lines 223:0-226:1 Visibility: public -/ def test_range_u8_start_gt_end : Result Unit := do let (o, _) ← @@ -566,7 +566,7 @@ def test_range_u8_start_gt_end : Result Unit := do #assert (test_range_u8_start_gt_end == ok ()) /-- [iter_adapters::test_range_u8_start_eq_end]: - Source: 'tests/src/iter_adapters.rs', lines 229:0-232:1 + Source: 'tests/src/iter_adapters.rs', lines 230:0-233:1 Visibility: public -/ def test_range_u8_start_eq_end : Result Unit := do let (o, _) ← @@ -579,7 +579,7 @@ def test_range_u8_start_eq_end : Result Unit := do #assert (test_range_u8_start_eq_end == ok ()) /-- [iter_adapters::test_range_u16_boundary]: - Source: 'tests/src/iter_adapters.rs', lines 236:0-242:1 + Source: 'tests/src/iter_adapters.rs', lines 237:0-243:1 Visibility: public -/ def test_range_u16_boundary : Result Unit := do let (o, it) ← @@ -604,7 +604,7 @@ def test_range_u16_boundary : Result Unit := do #assert (test_range_u16_boundary == ok ()) /-- [iter_adapters::test_range_u32_boundary]: - Source: 'tests/src/iter_adapters.rs', lines 246:0-251:1 + Source: 'tests/src/iter_adapters.rs', lines 247:0-252:1 Visibility: public -/ def test_range_u32_boundary : Result Unit := do let (o, it) ← @@ -625,7 +625,7 @@ def test_range_u32_boundary : Result Unit := do #assert (test_range_u32_boundary == ok ()) /-- [iter_adapters::test_range_u64_boundary]: - Source: 'tests/src/iter_adapters.rs', lines 255:0-261:1 + Source: 'tests/src/iter_adapters.rs', lines 256:0-262:1 Visibility: public -/ def test_range_u64_boundary : Result Unit := do let (o, it) ← @@ -650,7 +650,7 @@ def test_range_u64_boundary : Result Unit := do #assert (test_range_u64_boundary == ok ()) /-- [iter_adapters::test_range_usize_start_gt_end]: - Source: 'tests/src/iter_adapters.rs', lines 265:0-268:1 + Source: 'tests/src/iter_adapters.rs', lines 266:0-269:1 Visibility: public -/ def test_range_usize_start_gt_end : Result Unit := do let (o, _) ← @@ -663,7 +663,7 @@ def test_range_usize_start_gt_end : Result Unit := do #assert (test_range_usize_start_gt_end == ok ()) /-- [iter_adapters::test_step_by_larger_than_range]: - Source: 'tests/src/iter_adapters.rs', lines 272:0-276:1 + Source: 'tests/src/iter_adapters.rs', lines 273:0-277:1 Visibility: public -/ def test_step_by_larger_than_range : Result Unit := do let it ← @@ -685,7 +685,7 @@ def test_step_by_larger_than_range : Result Unit := do #assert (test_step_by_larger_than_range == ok ()) /-- [iter_adapters::test_step_by_exact_range]: - Source: 'tests/src/iter_adapters.rs', lines 280:0-284:1 + Source: 'tests/src/iter_adapters.rs', lines 281:0-285:1 Visibility: public -/ def test_step_by_exact_range : Result Unit := do let it ← @@ -707,7 +707,7 @@ def test_step_by_exact_range : Result Unit := do #assert (test_step_by_exact_range == ok ()) /-- [iter_adapters::test_step_by_one]: - Source: 'tests/src/iter_adapters.rs', lines 288:0-295:1 + Source: 'tests/src/iter_adapters.rs', lines 289:0-296:1 Visibility: public -/ def test_step_by_one : Result Unit := do let it ← @@ -744,7 +744,7 @@ def test_step_by_one : Result Unit := do #assert (test_step_by_one == ok ()) /-- [iter_adapters::test_step_by_empty]: - Source: 'tests/src/iter_adapters.rs', lines 299:0-302:1 + Source: 'tests/src/iter_adapters.rs', lines 300:0-303:1 Visibility: public -/ def test_step_by_empty : Result Unit := do let it ← @@ -761,7 +761,7 @@ def test_step_by_empty : Result Unit := do #assert (test_step_by_empty == ok ()) /-- [iter_adapters::test_step_by_odd_range]: - Source: 'tests/src/iter_adapters.rs', lines 306:0-312:1 + Source: 'tests/src/iter_adapters.rs', lines 307:0-313:1 Visibility: public -/ def test_step_by_odd_range : Result Unit := do let it ← @@ -793,7 +793,7 @@ def test_step_by_odd_range : Result Unit := do #assert (test_step_by_odd_range == ok ()) /-- [iter_adapters::test_step_by_u8_near_max]: - Source: 'tests/src/iter_adapters.rs', lines 316:0-322:1 + Source: 'tests/src/iter_adapters.rs', lines 317:0-323:1 Visibility: public -/ def test_step_by_u8_near_max : Result Unit := do let it ← @@ -825,7 +825,7 @@ def test_step_by_u8_near_max : Result Unit := do #assert (test_step_by_u8_near_max == ok ()) /-- [iter_adapters::test_range_inclusive_basic]: - Source: 'tests/src/iter_adapters.rs', lines 330:0-336:1 + Source: 'tests/src/iter_adapters.rs', lines 331:0-337:1 Visibility: public -/ def test_range_inclusive_basic : Result Unit := do let it ← core.ops.range.RangeInclusive.new 1#usize 3#usize @@ -854,7 +854,7 @@ def test_range_inclusive_basic : Result Unit := do #assert (test_range_inclusive_basic == ok ()) /-- [iter_adapters::test_range_inclusive_singleton]: - Source: 'tests/src/iter_adapters.rs', lines 340:0-344:1 + Source: 'tests/src/iter_adapters.rs', lines 341:0-345:1 Visibility: public -/ def test_range_inclusive_singleton : Result Unit := do let it ← core.ops.range.RangeInclusive.new 7#usize 7#usize @@ -873,7 +873,7 @@ def test_range_inclusive_singleton : Result Unit := do #assert (test_range_inclusive_singleton == ok ()) /-- [iter_adapters::test_range_inclusive_empty]: - Source: 'tests/src/iter_adapters.rs', lines 348:0-351:1 + Source: 'tests/src/iter_adapters.rs', lines 349:0-352:1 Visibility: public -/ def test_range_inclusive_empty : Result Unit := do let it ← core.ops.range.RangeInclusive.new 5#usize 3#usize diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index e95a5a77b..53db69775 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -1,8 +1,6 @@ -module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [no_nested_borrows] -public import Aeneas -@[expose] public section +import Aeneas open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false @@ -17,14 +15,14 @@ set_option maxRecDepth 2048 namespace no_nested_borrows /-- [no_nested_borrows::Pair] - Source: 'tests/src/no_nested_borrows.rs', lines 7:0-10:1 + Source: 'tests/src/no_nested_borrows.rs', lines 8:0-11:1 Visibility: public -/ structure Pair (T1 : Type) (T2 : Type) where x : T1 y : T2 /-- [no_nested_borrows::List] - Source: 'tests/src/no_nested_borrows.rs', lines 12:0-15:1 + Source: 'tests/src/no_nested_borrows.rs', lines 13:0-16:1 Visibility: public -/ @[discriminant isize] inductive List (T : Type) where @@ -32,21 +30,21 @@ inductive List (T : Type) where | Nil : List T /-- [no_nested_borrows::One] - Source: 'tests/src/no_nested_borrows.rs', lines 23:0-25:1 + Source: 'tests/src/no_nested_borrows.rs', lines 24:0-26:1 Visibility: public -/ @[discriminant isize] inductive One (T1 : Type) where | One : T1 → One T1 /-- [no_nested_borrows::EmptyEnum] - Source: 'tests/src/no_nested_borrows.rs', lines 29:0-31:1 + Source: 'tests/src/no_nested_borrows.rs', lines 30:0-32:1 Visibility: public -/ @[discriminant isize] inductive EmptyEnum where | Empty : EmptyEnum /-- [no_nested_borrows::Enum] - Source: 'tests/src/no_nested_borrows.rs', lines 35:0-38:1 + Source: 'tests/src/no_nested_borrows.rs', lines 36:0-39:1 Visibility: public -/ @[discriminant isize] inductive Enum where @@ -54,13 +52,13 @@ inductive Enum where | Variant2 : Enum /-- [no_nested_borrows::EmptyStruct] - Source: 'tests/src/no_nested_borrows.rs', lines 42:0-42:25 + Source: 'tests/src/no_nested_borrows.rs', lines 43:0-43:25 Visibility: public -/ @[reducible] def EmptyStruct := Unit /-- [no_nested_borrows::Sum] - Source: 'tests/src/no_nested_borrows.rs', lines 44:0-47:1 + Source: 'tests/src/no_nested_borrows.rs', lines 45:0-48:1 Visibility: public -/ @[discriminant isize] inductive Sum (T1 : Type) (T2 : Type) where @@ -68,25 +66,25 @@ inductive Sum (T1 : Type) (T2 : Type) where | Right : T2 → Sum T1 T2 /-- [no_nested_borrows::cast_u32_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 49:0-51:1 + Source: 'tests/src/no_nested_borrows.rs', lines 50:0-52:1 Visibility: public -/ def cast_u32_to_i32 (x : Std.U32) : Result Std.I32 := do ok (UScalar.hcast .I32 x) /-- [no_nested_borrows::cast_bool_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 53:0-55:1 + Source: 'tests/src/no_nested_borrows.rs', lines 54:0-56:1 Visibility: public -/ def cast_bool_to_i32 (x : Bool) : Result Std.I32 := do ok (IScalar.cast_fromBool .I32 x) /-- [no_nested_borrows::cast_bool_to_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 58:0-60:1 + Source: 'tests/src/no_nested_borrows.rs', lines 59:0-61:1 Visibility: public -/ def cast_bool_to_bool (x : Bool) : Result Bool := do ok x /-- [no_nested_borrows::test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 64:0-74:1 + Source: 'tests/src/no_nested_borrows.rs', lines 65:0-75:1 Visibility: public -/ def test2 : Result Unit := do let _ ← 23#u32 + 44#u32 @@ -96,7 +94,7 @@ def test2 : Result Unit := do #assert (test2 == ok ()) /-- [no_nested_borrows::get_max]: - Source: 'tests/src/no_nested_borrows.rs', lines 76:0-82:1 + Source: 'tests/src/no_nested_borrows.rs', lines 77:0-83:1 Visibility: public -/ def get_max (x : Std.U32) (y : Std.U32) : Result Std.U32 := do if x >= y @@ -104,7 +102,7 @@ def get_max (x : Std.U32) (y : Std.U32) : Result Std.U32 := do else ok y /-- [no_nested_borrows::test3]: - Source: 'tests/src/no_nested_borrows.rs', lines 85:0-90:1 + Source: 'tests/src/no_nested_borrows.rs', lines 86:0-91:1 Visibility: public -/ def test3 : Result Unit := do let x ← get_max 4#u32 3#u32 @@ -116,7 +114,7 @@ def test3 : Result Unit := do #assert (test3 == ok ()) /-- [no_nested_borrows::test_neg1]: - Source: 'tests/src/no_nested_borrows.rs', lines 93:0-97:1 + Source: 'tests/src/no_nested_borrows.rs', lines 94:0-98:1 Visibility: public -/ def test_neg1 : Result Unit := do let y ← -. 3#i32 @@ -126,7 +124,7 @@ def test_neg1 : Result Unit := do #assert (test_neg1 == ok ()) /-- [no_nested_borrows::refs_test1]: - Source: 'tests/src/no_nested_borrows.rs', lines 101:0-110:1 + Source: 'tests/src/no_nested_borrows.rs', lines 102:0-111:1 Visibility: public -/ def refs_test1 : Result Unit := do massert (1#i32 = 1#i32) @@ -135,7 +133,7 @@ def refs_test1 : Result Unit := do #assert (refs_test1 == ok ()) /-- [no_nested_borrows::refs_test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 113:0-125:1 + Source: 'tests/src/no_nested_borrows.rs', lines 114:0-126:1 Visibility: public -/ def refs_test2 : Result Unit := do massert (2#i32 = 2#i32) @@ -147,7 +145,7 @@ def refs_test2 : Result Unit := do #assert (refs_test2 == ok ()) /-- [no_nested_borrows::test_list1]: - Source: 'tests/src/no_nested_borrows.rs', lines 130:0-132:1 + Source: 'tests/src/no_nested_borrows.rs', lines 131:0-133:1 Visibility: public -/ def test_list1 : Result Unit := do ok () @@ -156,31 +154,31 @@ def test_list1 : Result Unit := do #assert (test_list1 == ok ()) /-- [no_nested_borrows::copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 134:0-136:1 + Source: 'tests/src/no_nested_borrows.rs', lines 135:0-137:1 Visibility: public -/ def copy_int (x : Std.I32) : Result Std.I32 := do ok x /-- [no_nested_borrows::test_unreachable]: - Source: 'tests/src/no_nested_borrows.rs', lines 140:0-144:1 + Source: 'tests/src/no_nested_borrows.rs', lines 141:0-145:1 Visibility: public -/ def test_unreachable (b : Bool) : Result Unit := do massert (¬ b) /-- [no_nested_borrows::test_panic]: - Source: 'tests/src/no_nested_borrows.rs', lines 147:0-151:1 + Source: 'tests/src/no_nested_borrows.rs', lines 148:0-152:1 Visibility: public -/ def test_panic (b : Bool) : Result Unit := do massert (¬ b) /-- [no_nested_borrows::test_panic_msg]: - Source: 'tests/src/no_nested_borrows.rs', lines 155:0-159:1 + Source: 'tests/src/no_nested_borrows.rs', lines 156:0-160:1 Visibility: public -/ def test_panic_msg (b : Bool) : Result Unit := do massert (¬ b) /-- [no_nested_borrows::test_copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 163:0-168:1 + Source: 'tests/src/no_nested_borrows.rs', lines 164:0-169:1 Visibility: public -/ def test_copy_int : Result Unit := do let y ← copy_int 0#i32 @@ -190,7 +188,7 @@ def test_copy_int : Result Unit := do #assert (test_copy_int == ok ()) /-- [no_nested_borrows::is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 170:0-175:1 + Source: 'tests/src/no_nested_borrows.rs', lines 171:0-176:1 Visibility: public -/ def is_cons {T : Type} (l : List T) : Result Bool := do match l with @@ -198,7 +196,7 @@ def is_cons {T : Type} (l : List T) : Result Bool := do | List.Nil => ok false /-- [no_nested_borrows::test_is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 178:0-182:1 + Source: 'tests/src/no_nested_borrows.rs', lines 179:0-183:1 Visibility: public -/ def test_is_cons : Result Unit := do let b ← is_cons (List.Cons 0#i32 List.Nil) @@ -208,7 +206,7 @@ def test_is_cons : Result Unit := do #assert (test_is_cons == ok ()) /-- [no_nested_borrows::split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 184:0-189:1 + Source: 'tests/src/no_nested_borrows.rs', lines 185:0-190:1 Visibility: public -/ def split_list {T : Type} (l : List T) : Result (T × (List T)) := do match l with @@ -216,7 +214,7 @@ def split_list {T : Type} (l : List T) : Result (T × (List T)) := do | List.Nil => fail panic /-- [no_nested_borrows::test_split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 193:0-198:1 + Source: 'tests/src/no_nested_borrows.rs', lines 194:0-199:1 Visibility: public -/ def test_split_list : Result Unit := do let (hd, _) ← split_list (List.Cons 0#i32 List.Nil) @@ -226,7 +224,7 @@ def test_split_list : Result Unit := do #assert (test_split_list == ok ()) /-- [no_nested_borrows::choose]: - Source: 'tests/src/no_nested_borrows.rs', lines 200:0-206:1 + Source: 'tests/src/no_nested_borrows.rs', lines 201:0-207:1 Visibility: public -/ def choose {T : Type} (b : Bool) (x : T) (y : T) : Result (T × (T → (T × T))) := do @@ -237,7 +235,7 @@ def choose ok (y, back) /-- [no_nested_borrows::choose_test]: - Source: 'tests/src/no_nested_borrows.rs', lines 209:0-218:1 + Source: 'tests/src/no_nested_borrows.rs', lines 210:0-219:1 Visibility: public -/ def choose_test : Result Unit := do let (z, choose_back) ← choose true 0#i32 0#i32 @@ -251,13 +249,13 @@ def choose_test : Result Unit := do #assert (choose_test == ok ()) /-- [no_nested_borrows::test_char]: - Source: 'tests/src/no_nested_borrows.rs', lines 221:0-223:1 + Source: 'tests/src/no_nested_borrows.rs', lines 222:0-224:1 Visibility: public -/ def test_char : Result Char := do ok 'a' /-- [no_nested_borrows::panic_mut_borrow]: - Source: 'tests/src/no_nested_borrows.rs', lines 226:0-228:1 + Source: 'tests/src/no_nested_borrows.rs', lines 227:0-229:1 Visibility: public -/ def panic_mut_borrow (i : Std.U32) : Result Std.U32 := do fail panic @@ -265,7 +263,7 @@ def panic_mut_borrow (i : Std.U32) : Result Std.U32 := do mutual /-- [no_nested_borrows::Tree] - Source: 'tests/src/no_nested_borrows.rs', lines 231:0-234:1 + Source: 'tests/src/no_nested_borrows.rs', lines 232:0-235:1 Visibility: public -/ @[discriminant isize] inductive Tree (T : Type) where @@ -273,7 +271,7 @@ inductive Tree (T : Type) where | Node : T → NodeElem T → Tree T → Tree T /-- [no_nested_borrows::NodeElem] - Source: 'tests/src/no_nested_borrows.rs', lines 236:0-239:1 + Source: 'tests/src/no_nested_borrows.rs', lines 237:0-240:1 Visibility: public -/ @[discriminant isize] inductive NodeElem (T : Type) where @@ -283,7 +281,7 @@ inductive NodeElem (T : Type) where end /-- [no_nested_borrows::list_length]: - Source: 'tests/src/no_nested_borrows.rs', lines 272:0-277:1 + Source: 'tests/src/no_nested_borrows.rs', lines 273:0-278:1 Visibility: public -/ def list_length {T : Type} (l : List T) : Result Std.U32 := do match l with @@ -293,7 +291,7 @@ def list_length {T : Type} (l : List T) : Result Std.U32 := do partial_fixpoint /-- [no_nested_borrows::list_nth_shared]: - Source: 'tests/src/no_nested_borrows.rs', lines 280:0-293:1 + Source: 'tests/src/no_nested_borrows.rs', lines 281:0-294:1 Visibility: public -/ def list_nth_shared {T : Type} (l : List T) (i : Std.U32) : Result T := do match l with @@ -306,7 +304,7 @@ def list_nth_shared {T : Type} (l : List T) (i : Std.U32) : Result T := do partial_fixpoint /-- [no_nested_borrows::list_nth_mut]: - Source: 'tests/src/no_nested_borrows.rs', lines 296:0-309:1 + Source: 'tests/src/no_nested_borrows.rs', lines 297:0-310:1 Visibility: public -/ def list_nth_mut {T : Type} (l : List T) (i : Std.U32) : Result (T × (T → List T)) := do @@ -325,7 +323,7 @@ def list_nth_mut partial_fixpoint /-- [no_nested_borrows::list_rev_aux]: - Source: 'tests/src/no_nested_borrows.rs', lines 312:0-322:1 + Source: 'tests/src/no_nested_borrows.rs', lines 313:0-323:1 Visibility: public -/ def list_rev_aux {T : Type} (li : List T) (lo : List T) : Result (List T) := do match li with @@ -334,14 +332,14 @@ def list_rev_aux {T : Type} (li : List T) (lo : List T) : Result (List T) := do partial_fixpoint /-- [no_nested_borrows::list_rev]: - Source: 'tests/src/no_nested_borrows.rs', lines 326:0-329:1 + Source: 'tests/src/no_nested_borrows.rs', lines 327:0-330:1 Visibility: public -/ def list_rev {T : Type} (l : List T) : Result (List T) := do let (li, _) := core.mem.replace l List.Nil list_rev_aux li List.Nil /-- [no_nested_borrows::test_list_functions]: - Source: 'tests/src/no_nested_borrows.rs', lines 332:0-346:1 + Source: 'tests/src/no_nested_borrows.rs', lines 333:0-347:1 Visibility: public -/ def test_list_functions : Result Unit := do let i ← @@ -374,7 +372,7 @@ def test_list_functions : Result Unit := do #assert (test_list_functions == ok ()) /-- [no_nested_borrows::id_mut_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 348:0-350:1 + Source: 'tests/src/no_nested_borrows.rs', lines 349:0-351:1 Visibility: public -/ def id_mut_pair1 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -383,7 +381,7 @@ def id_mut_pair1 ok ((x, y), fun p => p) /-- [no_nested_borrows::id_mut_pair2]: - Source: 'tests/src/no_nested_borrows.rs', lines 352:0-354:1 + Source: 'tests/src/no_nested_borrows.rs', lines 353:0-355:1 Visibility: public -/ def id_mut_pair2 {T1 : Type} {T2 : Type} (p : (T1 × T2)) : @@ -392,7 +390,7 @@ def id_mut_pair2 ok (p, fun p1 => p1) /-- [no_nested_borrows::id_mut_pair3]: - Source: 'tests/src/no_nested_borrows.rs', lines 356:0-358:1 + Source: 'tests/src/no_nested_borrows.rs', lines 357:0-359:1 Visibility: public -/ def id_mut_pair3 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -401,7 +399,7 @@ def id_mut_pair3 ok ((x, y), fun x1 => x1, fun y1 => y1) /-- [no_nested_borrows::id_mut_pair4]: - Source: 'tests/src/no_nested_borrows.rs', lines 360:0-362:1 + Source: 'tests/src/no_nested_borrows.rs', lines 361:0-363:1 Visibility: public -/ def id_mut_pair4 {T1 : Type} {T2 : Type} (p : (T1 × T2)) : @@ -410,43 +408,43 @@ def id_mut_pair4 ok (p, fun p1 => p1, fun p1 => p1) /-- [no_nested_borrows::StructWithTuple] - Source: 'tests/src/no_nested_borrows.rs', lines 367:0-369:1 + Source: 'tests/src/no_nested_borrows.rs', lines 368:0-370:1 Visibility: public -/ structure StructWithTuple (T1 : Type) (T2 : Type) where p : (T1 × T2) /-- [no_nested_borrows::new_tuple1]: - Source: 'tests/src/no_nested_borrows.rs', lines 371:0-373:1 + Source: 'tests/src/no_nested_borrows.rs', lines 372:0-374:1 Visibility: public -/ def new_tuple1 : Result (StructWithTuple Std.U32 Std.U32) := do ok { p := (1#u32, 2#u32) } /-- [no_nested_borrows::new_tuple2]: - Source: 'tests/src/no_nested_borrows.rs', lines 375:0-377:1 + Source: 'tests/src/no_nested_borrows.rs', lines 376:0-378:1 Visibility: public -/ def new_tuple2 : Result (StructWithTuple Std.I16 Std.I16) := do ok { p := (1#i16, 2#i16) } /-- [no_nested_borrows::new_tuple3]: - Source: 'tests/src/no_nested_borrows.rs', lines 379:0-381:1 + Source: 'tests/src/no_nested_borrows.rs', lines 380:0-382:1 Visibility: public -/ def new_tuple3 : Result (StructWithTuple Std.U64 Std.I64) := do ok { p := (1#u64, 2#i64) } /-- [no_nested_borrows::StructWithPair] - Source: 'tests/src/no_nested_borrows.rs', lines 384:0-386:1 + Source: 'tests/src/no_nested_borrows.rs', lines 385:0-387:1 Visibility: public -/ structure StructWithPair (T1 : Type) (T2 : Type) where p : Pair T1 T2 /-- [no_nested_borrows::new_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 388:0-394:1 + Source: 'tests/src/no_nested_borrows.rs', lines 389:0-395:1 Visibility: public -/ def new_pair1 : Result (StructWithPair Std.U32 Std.U32) := do ok { p := { x := 1#u32, y := 2#u32 } } /-- [no_nested_borrows::test_constants]: - Source: 'tests/src/no_nested_borrows.rs', lines 397:0-402:1 + Source: 'tests/src/no_nested_borrows.rs', lines 398:0-403:1 Visibility: public -/ def test_constants : Result Unit := do let swt ← new_tuple1 @@ -465,7 +463,7 @@ def test_constants : Result Unit := do #assert (test_constants == ok ()) /-- [no_nested_borrows::test_weird_borrows1]: - Source: 'tests/src/no_nested_borrows.rs', lines 407:0-415:1 + Source: 'tests/src/no_nested_borrows.rs', lines 408:0-416:1 Visibility: public -/ def test_weird_borrows1 : Result Unit := do ok () @@ -474,7 +472,7 @@ def test_weird_borrows1 : Result Unit := do #assert (test_weird_borrows1 == ok ()) /-- [no_nested_borrows::test_mem_replace]: - Source: 'tests/src/no_nested_borrows.rs', lines 417:0-421:1 + Source: 'tests/src/no_nested_borrows.rs', lines 418:0-422:1 Visibility: public -/ def test_mem_replace (px : Std.U32) : Result Std.U32 := do let (y, _) := core.mem.replace px 1#u32 @@ -482,7 +480,7 @@ def test_mem_replace (px : Std.U32) : Result Std.U32 := do ok 2#u32 /-- [no_nested_borrows::test_shared_borrow_bool1]: - Source: 'tests/src/no_nested_borrows.rs', lines 424:0-433:1 + Source: 'tests/src/no_nested_borrows.rs', lines 425:0-434:1 Visibility: public -/ def test_shared_borrow_bool1 (b : Bool) : Result Std.U32 := do if b @@ -490,13 +488,13 @@ def test_shared_borrow_bool1 (b : Bool) : Result Std.U32 := do else ok 1#u32 /-- [no_nested_borrows::test_shared_borrow_bool2]: - Source: 'tests/src/no_nested_borrows.rs', lines 437:0-447:1 + Source: 'tests/src/no_nested_borrows.rs', lines 438:0-448:1 Visibility: public -/ def test_shared_borrow_bool2 : Result Std.U32 := do ok 0#u32 /-- [no_nested_borrows::test_shared_borrow_enum1]: - Source: 'tests/src/no_nested_borrows.rs', lines 452:0-460:1 + Source: 'tests/src/no_nested_borrows.rs', lines 453:0-461:1 Visibility: public -/ def test_shared_borrow_enum1 (l : List Std.U32) : Result Std.U32 := do match l with @@ -504,58 +502,58 @@ def test_shared_borrow_enum1 (l : List Std.U32) : Result Std.U32 := do | List.Nil => ok 0#u32 /-- [no_nested_borrows::test_shared_borrow_enum2]: - Source: 'tests/src/no_nested_borrows.rs', lines 464:0-473:1 + Source: 'tests/src/no_nested_borrows.rs', lines 465:0-474:1 Visibility: public -/ def test_shared_borrow_enum2 : Result Std.U32 := do ok 0#u32 /-- [no_nested_borrows::incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 475:0-477:1 + Source: 'tests/src/no_nested_borrows.rs', lines 476:0-478:1 Visibility: public -/ def incr (x : Std.U32) : Result Std.U32 := do x + 1#u32 /-- [no_nested_borrows::call_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 479:0-482:1 + Source: 'tests/src/no_nested_borrows.rs', lines 480:0-483:1 Visibility: public -/ def call_incr (x : Std.U32) : Result Std.U32 := do incr x /-- [no_nested_borrows::read_then_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 484:0-488:1 + Source: 'tests/src/no_nested_borrows.rs', lines 485:0-489:1 Visibility: public -/ def read_then_incr (x : Std.U32) : Result (Std.U32 × Std.U32) := do let x1 ← x + 1#u32 ok (x, x1) /-- [no_nested_borrows::Tuple] - Source: 'tests/src/no_nested_borrows.rs', lines 490:0-490:33 + Source: 'tests/src/no_nested_borrows.rs', lines 491:0-491:33 Visibility: public -/ def Tuple (T1 : Type) (T2 : Type) := T1 × T2 /-- [no_nested_borrows::read_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 492:0-494:1 + Source: 'tests/src/no_nested_borrows.rs', lines 493:0-495:1 Visibility: public -/ def read_tuple (x : (Std.U32 × Std.U32)) : Result Std.U32 := do let (i, _) := x ok i /-- [no_nested_borrows::update_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 496:0-498:1 + Source: 'tests/src/no_nested_borrows.rs', lines 497:0-499:1 Visibility: public -/ def update_tuple (x : (Std.U32 × Std.U32)) : Result (Std.U32 × Std.U32) := do let (_, i) := x ok (1#u32, i) /-- [no_nested_borrows::read_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 500:0-502:1 + Source: 'tests/src/no_nested_borrows.rs', lines 501:0-503:1 Visibility: public -/ def read_tuple_struct (x : Tuple Std.U32 Std.U32) : Result Std.U32 := do let (i, _) := x ok i /-- [no_nested_borrows::update_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 504:0-506:1 + Source: 'tests/src/no_nested_borrows.rs', lines 505:0-507:1 Visibility: public -/ def update_tuple_struct (x : Tuple Std.U32 Std.U32) : Result (Tuple Std.U32 Std.U32) := do @@ -563,50 +561,50 @@ def update_tuple_struct ok (1#u32, i) /-- [no_nested_borrows::create_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 508:0-510:1 + Source: 'tests/src/no_nested_borrows.rs', lines 509:0-511:1 Visibility: public -/ def create_tuple_struct (x : Std.U32) (y : Std.U64) : Result (Tuple Std.U32 Std.U64) := do ok (x, y) /-- [no_nested_borrows::IdType] - Source: 'tests/src/no_nested_borrows.rs', lines 513:0-513:24 + Source: 'tests/src/no_nested_borrows.rs', lines 514:0-514:24 Visibility: public -/ @[reducible] def IdType (T : Type) := T /-- [no_nested_borrows::use_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 515:0-517:1 + Source: 'tests/src/no_nested_borrows.rs', lines 516:0-518:1 Visibility: public -/ def use_id_type {T : Type} (x : IdType T) : Result T := do ok x /-- [no_nested_borrows::create_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 519:0-521:1 + Source: 'tests/src/no_nested_borrows.rs', lines 520:0-522:1 Visibility: public -/ def create_id_type {T : Type} (x : T) : Result (IdType T) := do ok x /-- [no_nested_borrows::not_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 523:0-525:1 + Source: 'tests/src/no_nested_borrows.rs', lines 524:0-526:1 Visibility: public -/ def not_bool (x : Bool) : Result Bool := do ok (¬ x) /-- [no_nested_borrows::not_u32]: - Source: 'tests/src/no_nested_borrows.rs', lines 527:0-529:1 + Source: 'tests/src/no_nested_borrows.rs', lines 528:0-530:1 Visibility: public -/ def not_u32 (x : Std.U32) : Result Std.U32 := do ok (~~~ x) /-- [no_nested_borrows::not_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 531:0-533:1 + Source: 'tests/src/no_nested_borrows.rs', lines 532:0-534:1 Visibility: public -/ def not_i32 (x : Std.I32) : Result Std.I32 := do ok (~~~ x) /-- [no_nested_borrows::borrow_mut_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 535:0-537:1 -/ + Source: 'tests/src/no_nested_borrows.rs', lines 536:0-538:1 -/ def borrow_mut_tuple {T : Type} {U : Type} (x : (T × U)) : Result ((T × U) × ((T × U) → (T × U))) @@ -614,12 +612,12 @@ def borrow_mut_tuple ok (x, fun x1 => x1) /-- [no_nested_borrows::ExpandSimpliy::Wrapper] - Source: 'tests/src/no_nested_borrows.rs', lines 541:4-541:32 + Source: 'tests/src/no_nested_borrows.rs', lines 542:4-542:32 Visibility: public -/ def ExpandSimpliy.Wrapper (T : Type) := T × T /-- [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb1]: - Source: 'tests/src/no_nested_borrows.rs', lines 543:4-549:5 + Source: 'tests/src/no_nested_borrows.rs', lines 544:4-550:5 Visibility: public -/ def ExpandSimpliy.check_expand_simplify_symb1 (x : ExpandSimpliy.Wrapper Bool) : Result (ExpandSimpliy.Wrapper Bool) := do @@ -629,14 +627,14 @@ def ExpandSimpliy.check_expand_simplify_symb1 else ok x /-- [no_nested_borrows::ExpandSimpliy::Wrapper2] - Source: 'tests/src/no_nested_borrows.rs', lines 551:4-554:5 + Source: 'tests/src/no_nested_borrows.rs', lines 552:4-555:5 Visibility: public -/ structure ExpandSimpliy.Wrapper2 where b : Bool x : Std.U32 /-- [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb2]: - Source: 'tests/src/no_nested_borrows.rs', lines 556:4-562:5 + Source: 'tests/src/no_nested_borrows.rs', lines 557:4-563:5 Visibility: public -/ def ExpandSimpliy.check_expand_simplify_symb2 (x : ExpandSimpliy.Wrapper2) : Result ExpandSimpliy.Wrapper2 := do diff --git a/tests/lean/Paper.lean b/tests/lean/Paper.lean index 9a5cad5df..2744fd9d2 100644 --- a/tests/lean/Paper.lean +++ b/tests/lean/Paper.lean @@ -1,8 +1,6 @@ -module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [paper] -public import Aeneas -@[expose] public section +import Aeneas open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false @@ -17,13 +15,13 @@ set_option maxRecDepth 2048 namespace paper /-- [paper::ref_incr]: - Source: 'tests/src/paper.rs', lines 7:0-9:1 + Source: 'tests/src/paper.rs', lines 8:0-10:1 Visibility: public -/ def ref_incr (x : Std.I32) : Result Std.I32 := do x + 1#i32 /-- [paper::test_incr]: - Source: 'tests/src/paper.rs', lines 12:0-16:1 + Source: 'tests/src/paper.rs', lines 13:0-17:1 Visibility: public -/ def test_incr : Result Unit := do let x ← ref_incr 0#i32 @@ -33,7 +31,7 @@ def test_incr : Result Unit := do #assert (test_incr == ok ()) /-- [paper::choose]: - Source: 'tests/src/paper.rs', lines 19:0-25:1 + Source: 'tests/src/paper.rs', lines 20:0-26:1 Visibility: public -/ def choose {T : Type} (b : Bool) (x : T) (y : T) : Result (T × (T → (T × T))) := do @@ -44,7 +42,7 @@ def choose ok (y, back) /-- [paper::test_choose]: - Source: 'tests/src/paper.rs', lines 28:0-36:1 + Source: 'tests/src/paper.rs', lines 29:0-37:1 Visibility: public -/ def test_choose : Result Unit := do let (z, choose_back) ← choose true 0#i32 0#i32 @@ -58,7 +56,7 @@ def test_choose : Result Unit := do #assert (test_choose == ok ()) /-- [paper::List] - Source: 'tests/src/paper.rs', lines 40:0-43:1 + Source: 'tests/src/paper.rs', lines 41:0-44:1 Visibility: public -/ @[discriminant isize] inductive List (T : Type) where @@ -66,7 +64,7 @@ inductive List (T : Type) where | Nil : List T /-- [paper::list_nth_mut]: - Source: 'tests/src/paper.rs', lines 47:0-60:1 + Source: 'tests/src/paper.rs', lines 48:0-61:1 Visibility: public -/ def list_nth_mut {T : Type} (l : List T) (i : Std.U32) : Result (T × (T → List T)) := do @@ -85,7 +83,7 @@ def list_nth_mut partial_fixpoint /-- [paper::sum]: - Source: 'tests/src/paper.rs', lines 62:0-71:1 + Source: 'tests/src/paper.rs', lines 63:0-72:1 Visibility: public -/ def sum (l : List Std.I32) : Result Std.I32 := do match l with @@ -95,7 +93,7 @@ def sum (l : List Std.I32) : Result Std.I32 := do partial_fixpoint /-- [paper::test_nth]: - Source: 'tests/src/paper.rs', lines 74:0-79:1 + Source: 'tests/src/paper.rs', lines 75:0-80:1 Visibility: public -/ def test_nth : Result Unit := do let (x, list_nth_mut_back) ← @@ -110,7 +108,7 @@ def test_nth : Result Unit := do #assert (test_nth == ok ()) /-- [paper::call_choose]: - Source: 'tests/src/paper.rs', lines 82:0-88:1 + Source: 'tests/src/paper.rs', lines 83:0-89:1 Visibility: public -/ def call_choose (p : (Std.U32 × Std.U32)) : Result Std.U32 := do let (px, py) := p diff --git a/tests/lean/Scalars.lean b/tests/lean/Scalars.lean index b08de12b1..23c6e1757 100644 --- a/tests/lean/Scalars.lean +++ b/tests/lean/Scalars.lean @@ -15,67 +15,67 @@ set_option maxRecDepth 2048 namespace scalars /-- [scalars::u32_use_wrapping_add]: - Source: 'tests/src/scalars.rs', lines 5:0-7:1 -/ + Source: 'tests/src/scalars.rs', lines 6:0-8:1 -/ def u32_use_wrapping_add (x : Std.U32) (y : Std.U32) : Result Std.U32 := do ok (core.num.U32.wrapping_add x y) /-- [scalars::i32_use_wrapping_add]: - Source: 'tests/src/scalars.rs', lines 9:0-11:1 -/ + Source: 'tests/src/scalars.rs', lines 10:0-12:1 -/ def i32_use_wrapping_add (x : Std.I32) (y : Std.I32) : Result Std.I32 := do ok (core.num.I32.wrapping_add x y) /-- [scalars::u32_use_wrapping_sub]: - Source: 'tests/src/scalars.rs', lines 13:0-15:1 -/ + Source: 'tests/src/scalars.rs', lines 14:0-16:1 -/ def u32_use_wrapping_sub (x : Std.U32) (y : Std.U32) : Result Std.U32 := do ok (core.num.U32.wrapping_sub x y) /-- [scalars::i32_use_wrapping_sub]: - Source: 'tests/src/scalars.rs', lines 17:0-19:1 -/ + Source: 'tests/src/scalars.rs', lines 18:0-20:1 -/ def i32_use_wrapping_sub (x : Std.I32) (y : Std.I32) : Result Std.I32 := do ok (core.num.I32.wrapping_sub x y) /-- [scalars::u32_use_shift_right]: - Source: 'tests/src/scalars.rs', lines 21:0-23:1 -/ + Source: 'tests/src/scalars.rs', lines 22:0-24:1 -/ def u32_use_shift_right (x : Std.U32) : Result Std.U32 := do x >>> 2#i32 /-- [scalars::i32_use_shift_right]: - Source: 'tests/src/scalars.rs', lines 25:0-27:1 -/ + Source: 'tests/src/scalars.rs', lines 26:0-28:1 -/ def i32_use_shift_right (x : Std.I32) : Result Std.I32 := do x >>> 2#i32 /-- [scalars::u32_use_shift_left]: - Source: 'tests/src/scalars.rs', lines 29:0-31:1 -/ + Source: 'tests/src/scalars.rs', lines 30:0-32:1 -/ def u32_use_shift_left (x : Std.U32) : Result Std.U32 := do x <<< 2#i32 /-- [scalars::i32_use_shift_left]: - Source: 'tests/src/scalars.rs', lines 33:0-35:1 -/ + Source: 'tests/src/scalars.rs', lines 34:0-36:1 -/ def i32_use_shift_left (x : Std.I32) : Result Std.I32 := do x <<< 2#i32 /-- [scalars::u32_use_wrapping_shl]: - Source: 'tests/src/scalars.rs', lines 37:0-39:1 -/ + Source: 'tests/src/scalars.rs', lines 38:0-40:1 -/ def u32_use_wrapping_shl (x : Std.U32) (s : Std.U32) : Result Std.U32 := do ok (core.num.U32.wrapping_shl x s) /-- [scalars::i32_use_wrapping_shl]: - Source: 'tests/src/scalars.rs', lines 41:0-43:1 -/ + Source: 'tests/src/scalars.rs', lines 42:0-44:1 -/ def i32_use_wrapping_shl (x : Std.I32) (s : Std.U32) : Result Std.I32 := do ok (core.num.I32.wrapping_shl x s) /-- [scalars::u32_use_wrapping_shr]: - Source: 'tests/src/scalars.rs', lines 45:0-47:1 -/ + Source: 'tests/src/scalars.rs', lines 46:0-48:1 -/ def u32_use_wrapping_shr (x : Std.U32) (s : Std.U32) : Result Std.U32 := do ok (core.num.U32.wrapping_shr x s) /-- [scalars::i32_use_wrapping_shr]: - Source: 'tests/src/scalars.rs', lines 49:0-51:1 -/ + Source: 'tests/src/scalars.rs', lines 50:0-52:1 -/ def i32_use_wrapping_shr (x : Std.I32) (s : Std.U32) : Result Std.I32 := do ok (core.num.I32.wrapping_shr x s) /-- [scalars::shr_into_index_mut]: - Source: 'tests/src/scalars.rs', lines 57:0-59:1 -/ + Source: 'tests/src/scalars.rs', lines 58:0-60:1 -/ def shr_into_index_mut (x : Std.U64) (out : Array Std.U64 2#usize) : Result (Array Std.U64 2#usize) @@ -84,7 +84,7 @@ def shr_into_index_mut Array.update out 0#usize i /-- [scalars::shl_into_index_mut]: - Source: 'tests/src/scalars.rs', lines 62:0-64:1 -/ + Source: 'tests/src/scalars.rs', lines 63:0-65:1 -/ def shl_into_index_mut (x : Std.U64) (out : Array Std.U64 2#usize) : Result (Array Std.U64 2#usize) @@ -93,44 +93,44 @@ def shl_into_index_mut Array.update out 0#usize i /-- [scalars::add_and]: - Source: 'tests/src/scalars.rs', lines 66:0-68:1 -/ + Source: 'tests/src/scalars.rs', lines 67:0-69:1 -/ def add_and (a : Std.U32) (b : Std.U32) : Result Std.U32 := do let i ← lift (b &&& a) let i1 ← lift (b &&& a) i + i1 /-- [scalars::u32_use_rotate_right]: - Source: 'tests/src/scalars.rs', lines 70:0-72:1 -/ + Source: 'tests/src/scalars.rs', lines 71:0-73:1 -/ def u32_use_rotate_right (x : Std.U32) : Result Std.U32 := do ok (core.num.U32.rotate_right x 2#u32) /-- [scalars::i32_use_rotate_right]: - Source: 'tests/src/scalars.rs', lines 74:0-76:1 -/ + Source: 'tests/src/scalars.rs', lines 75:0-77:1 -/ def i32_use_rotate_right (x : Std.I32) : Result Std.I32 := do ok (core.num.I32.rotate_right x 2#u32) /-- [scalars::u32_use_rotate_left]: - Source: 'tests/src/scalars.rs', lines 78:0-80:1 -/ + Source: 'tests/src/scalars.rs', lines 79:0-81:1 -/ def u32_use_rotate_left (x : Std.U32) : Result Std.U32 := do ok (core.num.U32.rotate_left x 2#u32) /-- [scalars::i32_use_rotate_left]: - Source: 'tests/src/scalars.rs', lines 82:0-84:1 -/ + Source: 'tests/src/scalars.rs', lines 83:0-85:1 -/ def i32_use_rotate_left (x : Std.I32) : Result Std.I32 := do ok (core.num.I32.rotate_left x 2#u32) /-- [scalars::u32_default]: - Source: 'tests/src/scalars.rs', lines 86:0-88:1 -/ + Source: 'tests/src/scalars.rs', lines 87:0-89:1 -/ def u32_default : Result Std.U32 := do ok (core.default.DefaultU32.default) /-- [scalars::i32_default]: - Source: 'tests/src/scalars.rs', lines 90:0-92:1 -/ + Source: 'tests/src/scalars.rs', lines 91:0-93:1 -/ def i32_default : Result Std.I32 := do ok (core.default.DefaultI32.default) /-- [scalars::match_usize]: - Source: 'tests/src/scalars.rs', lines 94:0-99:1 -/ + Source: 'tests/src/scalars.rs', lines 95:0-100:1 -/ def match_usize (x : Std.Usize) : Result Bool := do match x.val with | 0 => ok true @@ -139,7 +139,7 @@ def match_usize (x : Std.Usize) : Result Bool := do | _ => ok false /-- [scalars::match_isize]: - Source: 'tests/src/scalars.rs', lines 101:0-106:1 -/ + Source: 'tests/src/scalars.rs', lines 102:0-107:1 -/ def match_isize (x : Std.Isize) : Result Std.Isize := do match x.val with | 0 => ok 0#isize @@ -148,39 +148,39 @@ def match_isize (x : Std.Isize) : Result Std.Isize := do | _ => x + 1#isize /-- [scalars::u32_as_u16]: - Source: 'tests/src/scalars.rs', lines 108:0-110:1 -/ + Source: 'tests/src/scalars.rs', lines 109:0-111:1 -/ def u32_as_u16 (x : Std.U32) : Result Std.U16 := do ok (UScalar.cast .U16 x) /-- [scalars::u16_as_u32]: - Source: 'tests/src/scalars.rs', lines 112:0-114:1 -/ + Source: 'tests/src/scalars.rs', lines 113:0-115:1 -/ def u16_as_u32 (x : Std.U16) : Result Std.U32 := do ok (UScalar.cast .U32 x) /-- [scalars::u32_as_i16]: - Source: 'tests/src/scalars.rs', lines 116:0-118:1 -/ + Source: 'tests/src/scalars.rs', lines 117:0-119:1 -/ def u32_as_i16 (x : Std.U32) : Result Std.I16 := do ok (UScalar.hcast .I16 x) /-- [scalars::i16_as_u32]: - Source: 'tests/src/scalars.rs', lines 120:0-122:1 -/ + Source: 'tests/src/scalars.rs', lines 121:0-123:1 -/ def i16_as_u32 (x : Std.I16) : Result Std.U32 := do ok (IScalar.hcast .U32 x) /-- [scalars::u32_use_bits]: - Source: 'tests/src/scalars.rs', lines 124:0-126:1 + Source: 'tests/src/scalars.rs', lines 125:0-127:1 Visibility: public -/ def u32_use_bits : Result Std.U32 := do ok core.num.U32.BITS /-- [scalars::i32_use_bits]: - Source: 'tests/src/scalars.rs', lines 128:0-130:1 + Source: 'tests/src/scalars.rs', lines 129:0-131:1 Visibility: public -/ def i32_use_bits : Result Std.U32 := do ok core.num.I32.BITS /-- [scalars::test_is_multiple_of_true]: - Source: 'tests/src/scalars.rs', lines 137:0-139:1 + Source: 'tests/src/scalars.rs', lines 138:0-140:1 Visibility: public -/ def test_is_multiple_of_true : Result Unit := do let b ← core.num.Usize.is_multiple_of 12#usize 4#usize @@ -190,7 +190,7 @@ def test_is_multiple_of_true : Result Unit := do #assert (test_is_multiple_of_true == ok ()) /-- [scalars::test_is_multiple_of_false]: - Source: 'tests/src/scalars.rs', lines 142:0-144:1 + Source: 'tests/src/scalars.rs', lines 143:0-145:1 Visibility: public -/ def test_is_multiple_of_false : Result Unit := do let b ← core.num.Usize.is_multiple_of 7#usize 3#usize @@ -200,7 +200,7 @@ def test_is_multiple_of_false : Result Unit := do #assert (test_is_multiple_of_false == ok ()) /-- [scalars::test_is_multiple_of_zero_divisor]: - Source: 'tests/src/scalars.rs', lines 147:0-151:1 + Source: 'tests/src/scalars.rs', lines 148:0-152:1 Visibility: public -/ def test_is_multiple_of_zero_divisor : Result Unit := do let b ← core.num.Usize.is_multiple_of 0#usize 0#usize @@ -212,7 +212,7 @@ def test_is_multiple_of_zero_divisor : Result Unit := do #assert (test_is_multiple_of_zero_divisor == ok ()) /-- [scalars::test_try_from_usize_u32_ok]: - Source: 'tests/src/scalars.rs', lines 158:0-160:1 + Source: 'tests/src/scalars.rs', lines 159:0-161:1 Visibility: public -/ def test_try_from_usize_u32_ok : Result Unit := do let r ← @@ -224,7 +224,7 @@ def test_try_from_usize_u32_ok : Result Unit := do #assert (test_try_from_usize_u32_ok == ok ()) /-- [scalars::checked_div]: - Source: 'tests/src/scalars.rs', lines 166:0-171:1 -/ + Source: 'tests/src/scalars.rs', lines 167:0-172:1 -/ def checked_div (a : Std.U32) (b : Std.U32) : Result (core.result.Result Std.U32 Unit) := do if b = 0#u32 @@ -233,7 +233,7 @@ def checked_div ok (core.result.Result.Ok i) /-- [scalars::use_question_mark]: - Source: 'tests/src/scalars.rs', lines 173:0-176:1 -/ + Source: 'tests/src/scalars.rs', lines 174:0-177:1 -/ def use_question_mark (a : Std.U32) (b : Std.U32) : Result (core.result.Result Std.U32 Unit) := do let r ← checked_div a b @@ -247,7 +247,7 @@ def use_question_mark Std.U32 (core.convert.FromSame Unit) residual /-- [scalars::test_question_mark_ok]: - Source: 'tests/src/scalars.rs', lines 179:0-183:1 + Source: 'tests/src/scalars.rs', lines 180:0-184:1 Visibility: public -/ def test_question_mark_ok : Result Unit := do let r ← use_question_mark 10#u32 2#u32 @@ -260,7 +260,7 @@ def test_question_mark_ok : Result Unit := do #assert (test_question_mark_ok == ok ()) /-- [scalars::test_question_mark_err]: - Source: 'tests/src/scalars.rs', lines 186:0-189:1 + Source: 'tests/src/scalars.rs', lines 187:0-190:1 Visibility: public -/ def test_question_mark_err : Result Unit := do let r ← use_question_mark 10#u32 0#u32 diff --git a/tests/lean/StepBy.lean b/tests/lean/StepBy.lean index f7f47292a..97f095b4b 100644 --- a/tests/lean/StepBy.lean +++ b/tests/lean/StepBy.lean @@ -15,7 +15,7 @@ set_option maxRecDepth 2048 namespace step_by /-- [step_by::test_step_by_1]: - Source: 'tests/src/step_by.rs', lines 8:0-17:1 + Source: 'tests/src/step_by.rs', lines 9:0-18:1 Visibility: public -/ def test_step_by_1 : Result Unit := do let s ← @@ -60,7 +60,7 @@ def test_step_by_1 : Result Unit := do #assert (test_step_by_1 == ok ()) /-- [step_by::test_step_by_2]: - Source: 'tests/src/step_by.rs', lines 21:0-28:1 + Source: 'tests/src/step_by.rs', lines 22:0-29:1 Visibility: public -/ def test_step_by_2 : Result Unit := do let s ← @@ -95,7 +95,7 @@ def test_step_by_2 : Result Unit := do #assert (test_step_by_2 == ok ()) /-- [step_by::test_step_by_3]: - Source: 'tests/src/step_by.rs', lines 32:0-39:1 + Source: 'tests/src/step_by.rs', lines 33:0-40:1 Visibility: public -/ def test_step_by_3 : Result Unit := do let s ← @@ -130,7 +130,7 @@ def test_step_by_3 : Result Unit := do #assert (test_step_by_3 == ok ()) /-- [step_by::test_step_by_larger_than_len]: - Source: 'tests/src/step_by.rs', lines 43:0-48:1 + Source: 'tests/src/step_by.rs', lines 44:0-49:1 Visibility: public -/ def test_step_by_larger_than_len : Result Unit := do let s ← lift (Array.to_slice (Array.make 3#usize [ 0#u32, 1#u32, 2#u32 ])) @@ -153,7 +153,7 @@ def test_step_by_larger_than_len : Result Unit := do #assert (test_step_by_larger_than_len == ok ()) /-- [step_by::test_step_by_empty]: - Source: 'tests/src/step_by.rs', lines 52:0-56:1 + Source: 'tests/src/step_by.rs', lines 53:0-57:1 Visibility: public -/ def test_step_by_empty : Result Unit := do let s ← lift (Array.to_slice (Std.Array.empty Std.U32)) @@ -171,7 +171,7 @@ def test_step_by_empty : Result Unit := do #assert (test_step_by_empty == ok ()) /-- [step_by::test_step_by_single]: - Source: 'tests/src/step_by.rs', lines 60:0-65:1 + Source: 'tests/src/step_by.rs', lines 61:0-66:1 Visibility: public -/ def test_step_by_single : Result Unit := do let s ← lift (Array.to_slice (Array.make 1#usize [ 42#u32 ])) @@ -194,7 +194,7 @@ def test_step_by_single : Result Unit := do #assert (test_step_by_single == ok ()) /-- [step_by::test_step_by_single_step_2]: - Source: 'tests/src/step_by.rs', lines 69:0-74:1 + Source: 'tests/src/step_by.rs', lines 70:0-75:1 Visibility: public -/ def test_step_by_single_step_2 : Result Unit := do let s ← lift (Array.to_slice (Array.make 1#usize [ 42#u32 ])) @@ -217,7 +217,7 @@ def test_step_by_single_step_2 : Result Unit := do #assert (test_step_by_single_step_2 == ok ()) /-- [step_by::test_step_by_eq_len]: - Source: 'tests/src/step_by.rs', lines 78:0-83:1 + Source: 'tests/src/step_by.rs', lines 79:0-84:1 Visibility: public -/ def test_step_by_eq_len : Result Unit := do let s ← lift (Array.to_slice (Array.make 3#usize [ 0#u32, 1#u32, 2#u32 ])) @@ -240,7 +240,7 @@ def test_step_by_eq_len : Result Unit := do #assert (test_step_by_eq_len == ok ()) /-- [step_by::test_step_by_len_minus_1]: - Source: 'tests/src/step_by.rs', lines 87:0-93:1 + Source: 'tests/src/step_by.rs', lines 88:0-94:1 Visibility: public -/ def test_step_by_len_minus_1 : Result Unit := do let s ← lift (Array.to_slice (Array.make 3#usize [ 0#u32, 1#u32, 2#u32 ])) @@ -268,7 +268,7 @@ def test_step_by_len_minus_1 : Result Unit := do #assert (test_step_by_len_minus_1 == ok ()) /-- [step_by::test_step_by_two_elements]: - Source: 'tests/src/step_by.rs', lines 97:0-102:1 + Source: 'tests/src/step_by.rs', lines 98:0-103:1 Visibility: public -/ def test_step_by_two_elements : Result Unit := do let s ← lift (Array.to_slice (Array.make 2#usize [ 0#u32, 1#u32 ])) @@ -291,7 +291,7 @@ def test_step_by_two_elements : Result Unit := do #assert (test_step_by_two_elements == ok ()) /-- [step_by::test_step_by_4_on_longer]: - Source: 'tests/src/step_by.rs', lines 106:0-113:1 + Source: 'tests/src/step_by.rs', lines 107:0-114:1 Visibility: public -/ def test_step_by_4_on_longer : Result Unit := do let s ← diff --git a/tests/src/chunks_exact.rs b/tests/src/chunks_exact.rs index 6bacb1d31..36fdc61c6 100644 --- a/tests/src/chunks_exact.rs +++ b/tests/src/chunks_exact.rs @@ -1,3 +1,4 @@ +//@ [lean] aeneas-args=-use-lean-modules false //@ [!lean] skip #![feature(register_tool)] #![register_tool(verify)] diff --git a/tests/src/iter_adapters.rs b/tests/src/iter_adapters.rs index c82ab3a32..ad8f36a65 100644 --- a/tests/src/iter_adapters.rs +++ b/tests/src/iter_adapters.rs @@ -1,3 +1,4 @@ +//@ [lean] aeneas-args=-use-lean-modules false //@ [!lean] skip #![feature(register_tool)] #![register_tool(verify)] diff --git a/tests/src/scalars.rs b/tests/src/scalars.rs index 20d52bd6b..ddb0e5fde 100644 --- a/tests/src/scalars.rs +++ b/tests/src/scalars.rs @@ -1,3 +1,4 @@ +//@ [lean] aeneas-args=-use-lean-modules false //@ [!lean] skip #![feature(register_tool)] #![register_tool(verify)] diff --git a/tests/src/step_by.rs b/tests/src/step_by.rs index f2ad52368..81d98fa18 100644 --- a/tests/src/step_by.rs +++ b/tests/src/step_by.rs @@ -1,3 +1,4 @@ +//@ [lean] aeneas-args=-use-lean-modules false //@ [!lean] skip #![feature(register_tool)] #![register_tool(verify)] From 660fd43ad405085c7ab376c137037446274b705a Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Sat, 25 Jul 2026 15:36:40 +0200 Subject: [PATCH 37/40] correct the test output --- tests/coq/misc/NoNestedBorrows.v | 150 +++++++++++++++--------------- tests/coq/misc/Paper.v | 18 ++-- tests/fstar/misc/Paper.fst | 18 ++-- tests/lean/CastSigned.lean | 34 +++---- tests/lean/NoNestedBorrows.lean | 154 ++++++++++++++++--------------- tests/lean/Paper.lean | 22 +++-- 6 files changed, 201 insertions(+), 195 deletions(-) diff --git a/tests/coq/misc/NoNestedBorrows.v b/tests/coq/misc/NoNestedBorrows.v index 9ce2bc469..7fe5a6cfe 100644 --- a/tests/coq/misc/NoNestedBorrows.v +++ b/tests/coq/misc/NoNestedBorrows.v @@ -15,7 +15,7 @@ Module NoNestedBorrows. Axiom core_fmt_Arguments_t : Type. (** [no_nested_borrows::Pair] - Source: 'tests/src/no_nested_borrows.rs', lines 8:0-11:1 + Source: 'tests/src/no_nested_borrows.rs', lines 7:0-10:1 Visibility: public *) Record Pair_t (T1 : Type) (T2 : Type) := mkPair_t { @@ -28,7 +28,7 @@ Arguments pair_x { _ } { _ }. Arguments pair_y { _ } { _ }. (** [no_nested_borrows::List] - Source: 'tests/src/no_nested_borrows.rs', lines 13:0-16:1 + Source: 'tests/src/no_nested_borrows.rs', lines 12:0-15:1 Visibility: public *) Inductive List_t (T : Type) := | List_Cons : T -> List_t T -> List_t T @@ -39,29 +39,29 @@ Arguments List_Cons { _ }. Arguments List_Nil { _ }. (** [no_nested_borrows::One] - Source: 'tests/src/no_nested_borrows.rs', lines 24:0-26:1 + Source: 'tests/src/no_nested_borrows.rs', lines 23:0-25:1 Visibility: public *) Inductive One_t (T1 : Type) := | One_One : T1 -> One_t T1. Arguments One_One { _ }. (** [no_nested_borrows::EmptyEnum] - Source: 'tests/src/no_nested_borrows.rs', lines 30:0-32:1 + Source: 'tests/src/no_nested_borrows.rs', lines 29:0-31:1 Visibility: public *) Inductive EmptyEnum_t := | EmptyEnum_Empty : EmptyEnum_t. (** [no_nested_borrows::Enum] - Source: 'tests/src/no_nested_borrows.rs', lines 36:0-39:1 + Source: 'tests/src/no_nested_borrows.rs', lines 35:0-38:1 Visibility: public *) Inductive Enum_t := | Enum_Variant1 : Enum_t | Enum_Variant2 : Enum_t. (** [no_nested_borrows::EmptyStruct] - Source: 'tests/src/no_nested_borrows.rs', lines 43:0-43:25 + Source: 'tests/src/no_nested_borrows.rs', lines 42:0-42:25 Visibility: public *) Definition EmptyStruct_t : Type := unit. (** [no_nested_borrows::Sum] - Source: 'tests/src/no_nested_borrows.rs', lines 45:0-48:1 + Source: 'tests/src/no_nested_borrows.rs', lines 44:0-47:1 Visibility: public *) Inductive Sum_t (T1 : Type) (T2 : Type) := | Sum_Left : T1 -> Sum_t T1 T2 @@ -72,25 +72,25 @@ Arguments Sum_Left { _ } { _ }. Arguments Sum_Right { _ } { _ }. (** [no_nested_borrows::cast_u32_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 50:0-52:1 + Source: 'tests/src/no_nested_borrows.rs', lines 49:0-51:1 Visibility: public *) Definition cast_u32_to_i32 (x : u32) : result i32 := scalar_cast U32 I32 x. (** [no_nested_borrows::cast_bool_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 54:0-56:1 + Source: 'tests/src/no_nested_borrows.rs', lines 53:0-55:1 Visibility: public *) Definition cast_bool_to_i32 (x : bool) : result i32 := scalar_cast_bool I32 x. (** [no_nested_borrows::cast_bool_to_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 59:0-61:1 + Source: 'tests/src/no_nested_borrows.rs', lines 58:0-60:1 Visibility: public *) Definition cast_bool_to_bool (x : bool) : result bool := Ok x. (** [no_nested_borrows::test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 65:0-75:1 + Source: 'tests/src/no_nested_borrows.rs', lines 64:0-74:1 Visibility: public *) Definition test2 : result unit := _ <- u32_add 23%u32 44%u32; Ok tt. @@ -99,14 +99,14 @@ Definition test2 : result unit := Check (test2)%return. (** [no_nested_borrows::get_max]: - Source: 'tests/src/no_nested_borrows.rs', lines 77:0-83:1 + Source: 'tests/src/no_nested_borrows.rs', lines 76:0-82:1 Visibility: public *) Definition get_max (x : u32) (y : u32) : result u32 := if x s>= y then Ok x else Ok y . (** [no_nested_borrows::test3]: - Source: 'tests/src/no_nested_borrows.rs', lines 86:0-91:1 + Source: 'tests/src/no_nested_borrows.rs', lines 85:0-90:1 Visibility: public *) Definition test3 : result unit := x <- get_max 4%u32 3%u32; @@ -119,7 +119,7 @@ Definition test3 : result unit := Check (test3)%return. (** [no_nested_borrows::test_neg1]: - Source: 'tests/src/no_nested_borrows.rs', lines 94:0-98:1 + Source: 'tests/src/no_nested_borrows.rs', lines 93:0-97:1 Visibility: public *) Definition test_neg1 : result unit := y <- i32_neg 3%i32; massert (y s= (-3)%i32) @@ -129,7 +129,7 @@ Definition test_neg1 : result unit := Check (test_neg1)%return. (** [no_nested_borrows::refs_test1]: - Source: 'tests/src/no_nested_borrows.rs', lines 102:0-111:1 + Source: 'tests/src/no_nested_borrows.rs', lines 101:0-110:1 Visibility: public *) Definition refs_test1 : result unit := massert (1%i32 s= 1%i32). @@ -138,7 +138,7 @@ Definition refs_test1 : result unit := Check (refs_test1)%return. (** [no_nested_borrows::refs_test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 114:0-126:1 + Source: 'tests/src/no_nested_borrows.rs', lines 113:0-125:1 Visibility: public *) Definition refs_test2 : result unit := _ <- massert (2%i32 s= 2%i32); @@ -151,7 +151,7 @@ Definition refs_test2 : result unit := Check (refs_test2)%return. (** [no_nested_borrows::test_list1]: - Source: 'tests/src/no_nested_borrows.rs', lines 131:0-133:1 + Source: 'tests/src/no_nested_borrows.rs', lines 130:0-132:1 Visibility: public *) Definition test_list1 : result unit := Ok tt. @@ -160,31 +160,31 @@ Definition test_list1 : result unit := Check (test_list1)%return. (** [no_nested_borrows::copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 135:0-137:1 + Source: 'tests/src/no_nested_borrows.rs', lines 134:0-136:1 Visibility: public *) Definition copy_int (x : i32) : result i32 := Ok x. (** [no_nested_borrows::test_unreachable]: - Source: 'tests/src/no_nested_borrows.rs', lines 141:0-145:1 + Source: 'tests/src/no_nested_borrows.rs', lines 140:0-144:1 Visibility: public *) Definition test_unreachable (b : bool) : result unit := massert (negb b). (** [no_nested_borrows::test_panic]: - Source: 'tests/src/no_nested_borrows.rs', lines 148:0-152:1 + Source: 'tests/src/no_nested_borrows.rs', lines 147:0-151:1 Visibility: public *) Definition test_panic (b : bool) : result unit := massert (negb b). (** [no_nested_borrows::test_panic_msg]: - Source: 'tests/src/no_nested_borrows.rs', lines 156:0-160:1 + Source: 'tests/src/no_nested_borrows.rs', lines 155:0-159:1 Visibility: public *) Definition test_panic_msg (b : bool) : result unit := massert (negb b). (** [no_nested_borrows::test_copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 164:0-169:1 + Source: 'tests/src/no_nested_borrows.rs', lines 163:0-168:1 Visibility: public *) Definition test_copy_int : result unit := y <- copy_int 0%i32; massert (0%i32 s= y) @@ -194,14 +194,14 @@ Definition test_copy_int : result unit := Check (test_copy_int)%return. (** [no_nested_borrows::is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 171:0-176:1 + Source: 'tests/src/no_nested_borrows.rs', lines 170:0-175:1 Visibility: public *) Definition is_cons {T : Type} (l : List_t T) : result bool := match l with | List_Cons _ _ => Ok true | List_Nil => Ok false end . (** [no_nested_borrows::test_is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 179:0-183:1 + Source: 'tests/src/no_nested_borrows.rs', lines 178:0-182:1 Visibility: public *) Definition test_is_cons : result unit := b <- is_cons (List_Cons 0%i32 List_Nil); massert b @@ -211,14 +211,14 @@ Definition test_is_cons : result unit := Check (test_is_cons)%return. (** [no_nested_borrows::split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 185:0-190:1 + Source: 'tests/src/no_nested_borrows.rs', lines 184:0-189:1 Visibility: public *) Definition split_list {T : Type} (l : List_t T) : result (T * (List_t T)) := match l with | List_Cons hd tl => Ok (hd, tl) | List_Nil => Fail_ Failure end . (** [no_nested_borrows::test_split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 194:0-199:1 + Source: 'tests/src/no_nested_borrows.rs', lines 193:0-198:1 Visibility: public *) Definition test_split_list : result unit := p <- split_list (List_Cons 0%i32 List_Nil); @@ -230,7 +230,7 @@ Definition test_split_list : result unit := Check (test_split_list)%return. (** [no_nested_borrows::choose]: - Source: 'tests/src/no_nested_borrows.rs', lines 201:0-207:1 + Source: 'tests/src/no_nested_borrows.rs', lines 200:0-206:1 Visibility: public *) Definition choose {T : Type} (b : bool) (x : T) (y : T) : result (T * (T -> (T * T))) := @@ -240,7 +240,7 @@ Definition choose . (** [no_nested_borrows::choose_test]: - Source: 'tests/src/no_nested_borrows.rs', lines 210:0-219:1 + Source: 'tests/src/no_nested_borrows.rs', lines 209:0-218:1 Visibility: public *) Definition choose_test : result unit := p <- choose true 0%i32 0%i32; @@ -256,26 +256,26 @@ Definition choose_test : result unit := Check (choose_test)%return. (** [no_nested_borrows::test_char]: - Source: 'tests/src/no_nested_borrows.rs', lines 222:0-224:1 + Source: 'tests/src/no_nested_borrows.rs', lines 221:0-223:1 Visibility: public *) Definition test_char : result char := Ok (char_of_byte Coq.Init.Byte.x61). (** [no_nested_borrows::panic_mut_borrow]: - Source: 'tests/src/no_nested_borrows.rs', lines 227:0-229:1 + Source: 'tests/src/no_nested_borrows.rs', lines 226:0-228:1 Visibility: public *) Definition panic_mut_borrow (i : u32) : result u32 := Fail_ Failure. (** [no_nested_borrows::Tree] - Source: 'tests/src/no_nested_borrows.rs', lines 232:0-235:1 + Source: 'tests/src/no_nested_borrows.rs', lines 231:0-234:1 Visibility: public *) Inductive Tree_t (T : Type) := | Tree_Leaf : T -> Tree_t T | Tree_Node : T -> NodeElem_t T -> Tree_t T -> Tree_t T (** [no_nested_borrows::NodeElem] - Source: 'tests/src/no_nested_borrows.rs', lines 237:0-240:1 + Source: 'tests/src/no_nested_borrows.rs', lines 236:0-239:1 Visibility: public *) with NodeElem_t (T : Type) := | NodeElem_Cons : Tree_t T -> NodeElem_t T -> NodeElem_t T @@ -289,7 +289,7 @@ Arguments NodeElem_Cons { _ }. Arguments NodeElem_Nil { _ }. (** [no_nested_borrows::list_length]: - Source: 'tests/src/no_nested_borrows.rs', lines 273:0-278:1 + Source: 'tests/src/no_nested_borrows.rs', lines 272:0-277:1 Visibility: public *) Fixpoint list_length {T : Type} (l : List_t T) : result u32 := match l with @@ -299,7 +299,7 @@ Fixpoint list_length {T : Type} (l : List_t T) : result u32 := . (** [no_nested_borrows::list_nth_shared]: - Source: 'tests/src/no_nested_borrows.rs', lines 281:0-294:1 + Source: 'tests/src/no_nested_borrows.rs', lines 280:0-293:1 Visibility: public *) Fixpoint list_nth_shared {T : Type} (l : List_t T) (i : u32) : result T := match l with @@ -310,7 +310,7 @@ Fixpoint list_nth_shared {T : Type} (l : List_t T) (i : u32) : result T := . (** [no_nested_borrows::list_nth_mut]: - Source: 'tests/src/no_nested_borrows.rs', lines 297:0-310:1 + Source: 'tests/src/no_nested_borrows.rs', lines 296:0-309:1 Visibility: public *) Fixpoint list_nth_mut {T : Type} (l : List_t T) (i : u32) : result (T * (T -> List_t T)) := @@ -331,7 +331,7 @@ Fixpoint list_nth_mut . (** [no_nested_borrows::list_rev_aux]: - Source: 'tests/src/no_nested_borrows.rs', lines 313:0-323:1 + Source: 'tests/src/no_nested_borrows.rs', lines 312:0-322:1 Visibility: public *) Fixpoint list_rev_aux {T : Type} (li : List_t T) (lo : List_t T) : result (List_t T) := @@ -342,14 +342,14 @@ Fixpoint list_rev_aux . (** [no_nested_borrows::list_rev]: - Source: 'tests/src/no_nested_borrows.rs', lines 327:0-330:1 + Source: 'tests/src/no_nested_borrows.rs', lines 326:0-329:1 Visibility: public *) Definition list_rev {T : Type} (l : List_t T) : result (List_t T) := let (li, _) := core_mem_replace l List_Nil in list_rev_aux li List_Nil . (** [no_nested_borrows::test_list_functions]: - Source: 'tests/src/no_nested_borrows.rs', lines 333:0-347:1 + Source: 'tests/src/no_nested_borrows.rs', lines 332:0-346:1 Visibility: public *) Definition test_list_functions : result unit := i <- @@ -384,7 +384,7 @@ Definition test_list_functions : result unit := Check (test_list_functions)%return. (** [no_nested_borrows::id_mut_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 349:0-351:1 + Source: 'tests/src/no_nested_borrows.rs', lines 348:0-350:1 Visibility: public *) Definition id_mut_pair1 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -394,7 +394,7 @@ Definition id_mut_pair1 . (** [no_nested_borrows::id_mut_pair2]: - Source: 'tests/src/no_nested_borrows.rs', lines 353:0-355:1 + Source: 'tests/src/no_nested_borrows.rs', lines 352:0-354:1 Visibility: public *) Definition id_mut_pair2 {T1 : Type} {T2 : Type} (p : (T1 * T2)) : @@ -404,7 +404,7 @@ Definition id_mut_pair2 . (** [no_nested_borrows::id_mut_pair3]: - Source: 'tests/src/no_nested_borrows.rs', lines 357:0-359:1 + Source: 'tests/src/no_nested_borrows.rs', lines 356:0-358:1 Visibility: public *) Definition id_mut_pair3 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -414,7 +414,7 @@ Definition id_mut_pair3 . (** [no_nested_borrows::id_mut_pair4]: - Source: 'tests/src/no_nested_borrows.rs', lines 361:0-363:1 + Source: 'tests/src/no_nested_borrows.rs', lines 360:0-362:1 Visibility: public *) Definition id_mut_pair4 {T1 : Type} {T2 : Type} (p : (T1 * T2)) : @@ -424,7 +424,7 @@ Definition id_mut_pair4 . (** [no_nested_borrows::StructWithTuple] - Source: 'tests/src/no_nested_borrows.rs', lines 368:0-370:1 + Source: 'tests/src/no_nested_borrows.rs', lines 367:0-369:1 Visibility: public *) Record StructWithTuple_t (T1 : Type) (T2 : Type) := mkStructWithTuple_t { @@ -436,28 +436,28 @@ Arguments mkStructWithTuple_t { _ } { _ }. Arguments structWithTuple_p { _ } { _ }. (** [no_nested_borrows::new_tuple1]: - Source: 'tests/src/no_nested_borrows.rs', lines 372:0-374:1 + Source: 'tests/src/no_nested_borrows.rs', lines 371:0-373:1 Visibility: public *) Definition new_tuple1 : result (StructWithTuple_t u32 u32) := Ok {| structWithTuple_p := (1%u32, 2%u32) |} . (** [no_nested_borrows::new_tuple2]: - Source: 'tests/src/no_nested_borrows.rs', lines 376:0-378:1 + Source: 'tests/src/no_nested_borrows.rs', lines 375:0-377:1 Visibility: public *) Definition new_tuple2 : result (StructWithTuple_t i16 i16) := Ok {| structWithTuple_p := (1%i16, 2%i16) |} . (** [no_nested_borrows::new_tuple3]: - Source: 'tests/src/no_nested_borrows.rs', lines 380:0-382:1 + Source: 'tests/src/no_nested_borrows.rs', lines 379:0-381:1 Visibility: public *) Definition new_tuple3 : result (StructWithTuple_t u64 i64) := Ok {| structWithTuple_p := (1%u64, 2%i64) |} . (** [no_nested_borrows::StructWithPair] - Source: 'tests/src/no_nested_borrows.rs', lines 385:0-387:1 + Source: 'tests/src/no_nested_borrows.rs', lines 384:0-386:1 Visibility: public *) Record StructWithPair_t (T1 : Type) (T2 : Type) := mkStructWithPair_t { @@ -469,14 +469,14 @@ Arguments mkStructWithPair_t { _ } { _ }. Arguments structWithPair_p { _ } { _ }. (** [no_nested_borrows::new_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 389:0-395:1 + Source: 'tests/src/no_nested_borrows.rs', lines 388:0-394:1 Visibility: public *) Definition new_pair1 : result (StructWithPair_t u32 u32) := Ok {| structWithPair_p := {| pair_x := 1%u32; pair_y := 2%u32 |} |} . (** [no_nested_borrows::test_constants]: - Source: 'tests/src/no_nested_borrows.rs', lines 398:0-403:1 + Source: 'tests/src/no_nested_borrows.rs', lines 397:0-402:1 Visibility: public *) Definition test_constants : result unit := swt <- new_tuple1; @@ -496,7 +496,7 @@ Definition test_constants : result unit := Check (test_constants)%return. (** [no_nested_borrows::test_weird_borrows1]: - Source: 'tests/src/no_nested_borrows.rs', lines 408:0-416:1 + Source: 'tests/src/no_nested_borrows.rs', lines 407:0-415:1 Visibility: public *) Definition test_weird_borrows1 : result unit := Ok tt. @@ -505,7 +505,7 @@ Definition test_weird_borrows1 : result unit := Check (test_weird_borrows1)%return. (** [no_nested_borrows::test_mem_replace]: - Source: 'tests/src/no_nested_borrows.rs', lines 418:0-422:1 + Source: 'tests/src/no_nested_borrows.rs', lines 417:0-421:1 Visibility: public *) Definition test_mem_replace (px : u32) : result u32 := let (y, _) := core_mem_replace px 1%u32 in @@ -514,78 +514,78 @@ Definition test_mem_replace (px : u32) : result u32 := . (** [no_nested_borrows::test_shared_borrow_bool1]: - Source: 'tests/src/no_nested_borrows.rs', lines 425:0-434:1 + Source: 'tests/src/no_nested_borrows.rs', lines 424:0-433:1 Visibility: public *) Definition test_shared_borrow_bool1 (b : bool) : result u32 := if b then Ok 0%u32 else Ok 1%u32 . (** [no_nested_borrows::test_shared_borrow_bool2]: - Source: 'tests/src/no_nested_borrows.rs', lines 438:0-448:1 + Source: 'tests/src/no_nested_borrows.rs', lines 437:0-447:1 Visibility: public *) Definition test_shared_borrow_bool2 : result u32 := Ok 0%u32. (** [no_nested_borrows::test_shared_borrow_enum1]: - Source: 'tests/src/no_nested_borrows.rs', lines 453:0-461:1 + Source: 'tests/src/no_nested_borrows.rs', lines 452:0-460:1 Visibility: public *) Definition test_shared_borrow_enum1 (l : List_t u32) : result u32 := match l with | List_Cons _ _ => Ok 1%u32 | List_Nil => Ok 0%u32 end . (** [no_nested_borrows::test_shared_borrow_enum2]: - Source: 'tests/src/no_nested_borrows.rs', lines 465:0-474:1 + Source: 'tests/src/no_nested_borrows.rs', lines 464:0-473:1 Visibility: public *) Definition test_shared_borrow_enum2 : result u32 := Ok 0%u32. (** [no_nested_borrows::incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 476:0-478:1 + Source: 'tests/src/no_nested_borrows.rs', lines 475:0-477:1 Visibility: public *) Definition incr (x : u32) : result u32 := u32_add x 1%u32. (** [no_nested_borrows::call_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 480:0-483:1 + Source: 'tests/src/no_nested_borrows.rs', lines 479:0-482:1 Visibility: public *) Definition call_incr (x : u32) : result u32 := incr x. (** [no_nested_borrows::read_then_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 485:0-489:1 + Source: 'tests/src/no_nested_borrows.rs', lines 484:0-488:1 Visibility: public *) Definition read_then_incr (x : u32) : result (u32 * u32) := x1 <- u32_add x 1%u32; Ok (x, x1) . (** [no_nested_borrows::Tuple] - Source: 'tests/src/no_nested_borrows.rs', lines 491:0-491:33 + Source: 'tests/src/no_nested_borrows.rs', lines 490:0-490:33 Visibility: public *) Definition Tuple_t (T1 : Type) (T2 : Type) : Type := T1 * T2. (** [no_nested_borrows::read_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 493:0-495:1 + Source: 'tests/src/no_nested_borrows.rs', lines 492:0-494:1 Visibility: public *) Definition read_tuple (x : (u32 * u32)) : result u32 := let (i, _) := x in Ok i . (** [no_nested_borrows::update_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 497:0-499:1 + Source: 'tests/src/no_nested_borrows.rs', lines 496:0-498:1 Visibility: public *) Definition update_tuple (x : (u32 * u32)) : result (u32 * u32) := let (_, i) := x in Ok (1%u32, i) . (** [no_nested_borrows::read_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 501:0-503:1 + Source: 'tests/src/no_nested_borrows.rs', lines 500:0-502:1 Visibility: public *) Definition read_tuple_struct (x : Tuple_t u32 u32) : result u32 := let (i, _) := x in Ok i . (** [no_nested_borrows::update_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 505:0-507:1 + Source: 'tests/src/no_nested_borrows.rs', lines 504:0-506:1 Visibility: public *) Definition update_tuple_struct (x : Tuple_t u32 u32) : result (Tuple_t u32 u32) := @@ -593,7 +593,7 @@ Definition update_tuple_struct . (** [no_nested_borrows::create_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 509:0-511:1 + Source: 'tests/src/no_nested_borrows.rs', lines 508:0-510:1 Visibility: public *) Definition create_tuple_struct (x : u32) (y : u64) : result (Tuple_t u32 u64) := @@ -601,42 +601,42 @@ Definition create_tuple_struct . (** [no_nested_borrows::IdType] - Source: 'tests/src/no_nested_borrows.rs', lines 514:0-514:24 + Source: 'tests/src/no_nested_borrows.rs', lines 513:0-513:24 Visibility: public *) Definition IdType_t (T : Type) : Type := T. (** [no_nested_borrows::use_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 516:0-518:1 + Source: 'tests/src/no_nested_borrows.rs', lines 515:0-517:1 Visibility: public *) Definition use_id_type {T : Type} (x : IdType_t T) : result T := Ok x. (** [no_nested_borrows::create_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 520:0-522:1 + Source: 'tests/src/no_nested_borrows.rs', lines 519:0-521:1 Visibility: public *) Definition create_id_type {T : Type} (x : T) : result (IdType_t T) := Ok x. (** [no_nested_borrows::not_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 524:0-526:1 + Source: 'tests/src/no_nested_borrows.rs', lines 523:0-525:1 Visibility: public *) Definition not_bool (x : bool) : result bool := Ok (negb x). (** [no_nested_borrows::not_u32]: - Source: 'tests/src/no_nested_borrows.rs', lines 528:0-530:1 + Source: 'tests/src/no_nested_borrows.rs', lines 527:0-529:1 Visibility: public *) Definition not_u32 (x : u32) : result u32 := Ok (scalar_not x). (** [no_nested_borrows::not_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 532:0-534:1 + Source: 'tests/src/no_nested_borrows.rs', lines 531:0-533:1 Visibility: public *) Definition not_i32 (x : i32) : result i32 := Ok (scalar_not x). (** [no_nested_borrows::borrow_mut_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 536:0-538:1 *) + Source: 'tests/src/no_nested_borrows.rs', lines 535:0-537:1 *) Definition borrow_mut_tuple {T : Type} {U : Type} (x : (T * U)) : result ((T * U) * ((T * U) -> (T * U))) @@ -645,12 +645,12 @@ Definition borrow_mut_tuple . (** [no_nested_borrows::ExpandSimpliy::Wrapper] - Source: 'tests/src/no_nested_borrows.rs', lines 542:4-542:32 + Source: 'tests/src/no_nested_borrows.rs', lines 541:4-541:32 Visibility: public *) Definition ExpandSimpliy_Wrapper_t (T : Type) : Type := T * T. (** [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb1]: - Source: 'tests/src/no_nested_borrows.rs', lines 544:4-550:5 + Source: 'tests/src/no_nested_borrows.rs', lines 543:4-549:5 Visibility: public *) Definition expandSimpliy_check_expand_simplify_symb1 (x : ExpandSimpliy_Wrapper_t bool) : result (ExpandSimpliy_Wrapper_t bool) := @@ -658,7 +658,7 @@ Definition expandSimpliy_check_expand_simplify_symb1 . (** [no_nested_borrows::ExpandSimpliy::Wrapper2] - Source: 'tests/src/no_nested_borrows.rs', lines 552:4-555:5 + Source: 'tests/src/no_nested_borrows.rs', lines 551:4-554:5 Visibility: public *) Record ExpandSimpliy_Wrapper2_t := mkExpandSimpliy_Wrapper2_t { @@ -667,7 +667,7 @@ mkExpandSimpliy_Wrapper2_t { . (** [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb2]: - Source: 'tests/src/no_nested_borrows.rs', lines 557:4-563:5 + Source: 'tests/src/no_nested_borrows.rs', lines 556:4-562:5 Visibility: public *) Definition expandSimpliy_check_expand_simplify_symb2 (x : ExpandSimpliy_Wrapper2_t) : result ExpandSimpliy_Wrapper2_t := diff --git a/tests/coq/misc/Paper.v b/tests/coq/misc/Paper.v index 6de9eac57..009dcf180 100644 --- a/tests/coq/misc/Paper.v +++ b/tests/coq/misc/Paper.v @@ -9,13 +9,13 @@ Local Open Scope Primitives_scope. Module Paper. (** [paper::ref_incr]: - Source: 'tests/src/paper.rs', lines 8:0-10:1 + Source: 'tests/src/paper.rs', lines 7:0-9:1 Visibility: public *) Definition ref_incr (x : i32) : result i32 := i32_add x 1%i32. (** [paper::test_incr]: - Source: 'tests/src/paper.rs', lines 13:0-17:1 + Source: 'tests/src/paper.rs', lines 12:0-16:1 Visibility: public *) Definition test_incr : result unit := x <- ref_incr 0%i32; massert (x s= 1%i32) @@ -25,7 +25,7 @@ Definition test_incr : result unit := Check (test_incr)%return. (** [paper::choose]: - Source: 'tests/src/paper.rs', lines 20:0-26:1 + Source: 'tests/src/paper.rs', lines 19:0-25:1 Visibility: public *) Definition choose {T : Type} (b : bool) (x : T) (y : T) : result (T * (T -> (T * T))) := @@ -35,7 +35,7 @@ Definition choose . (** [paper::test_choose]: - Source: 'tests/src/paper.rs', lines 29:0-37:1 + Source: 'tests/src/paper.rs', lines 28:0-36:1 Visibility: public *) Definition test_choose : result unit := p <- choose true 0%i32 0%i32; @@ -51,7 +51,7 @@ Definition test_choose : result unit := Check (test_choose)%return. (** [paper::List] - Source: 'tests/src/paper.rs', lines 41:0-44:1 + Source: 'tests/src/paper.rs', lines 40:0-43:1 Visibility: public *) Inductive List_t (T : Type) := | List_Cons : T -> List_t T -> List_t T @@ -62,7 +62,7 @@ Arguments List_Cons { _ }. Arguments List_Nil { _ }. (** [paper::list_nth_mut]: - Source: 'tests/src/paper.rs', lines 48:0-61:1 + Source: 'tests/src/paper.rs', lines 47:0-60:1 Visibility: public *) Fixpoint list_nth_mut {T : Type} (l : List_t T) (i : u32) : result (T * (T -> List_t T)) := @@ -83,7 +83,7 @@ Fixpoint list_nth_mut . (** [paper::sum]: - Source: 'tests/src/paper.rs', lines 63:0-72:1 + Source: 'tests/src/paper.rs', lines 62:0-71:1 Visibility: public *) Fixpoint sum (l : List_t i32) : result i32 := match l with @@ -93,7 +93,7 @@ Fixpoint sum (l : List_t i32) : result i32 := . (** [paper::test_nth]: - Source: 'tests/src/paper.rs', lines 75:0-80:1 + Source: 'tests/src/paper.rs', lines 74:0-79:1 Visibility: public *) Definition test_nth : result unit := p <- @@ -110,7 +110,7 @@ Definition test_nth : result unit := Check (test_nth)%return. (** [paper::call_choose]: - Source: 'tests/src/paper.rs', lines 83:0-89:1 + Source: 'tests/src/paper.rs', lines 82:0-88:1 Visibility: public *) Definition call_choose (p : (u32 * u32)) : result u32 := let (px, py) := p in diff --git a/tests/fstar/misc/Paper.fst b/tests/fstar/misc/Paper.fst index 435e98666..cddb1275b 100644 --- a/tests/fstar/misc/Paper.fst +++ b/tests/fstar/misc/Paper.fst @@ -6,13 +6,13 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [paper::ref_incr]: - Source: 'tests/src/paper.rs', lines 8:0-10:1 + Source: 'tests/src/paper.rs', lines 7:0-9:1 Visibility: public *) let ref_incr (x : i32) : result i32 = i32_add x 1 (** [paper::test_incr]: - Source: 'tests/src/paper.rs', lines 13:0-17:1 + Source: 'tests/src/paper.rs', lines 12:0-16:1 Visibility: public *) let test_incr : result unit = let* x = ref_incr 0 in massert (x = 1) @@ -21,7 +21,7 @@ let test_incr : result unit = let _ = assert_norm (test_incr = Ok ()) (** [paper::choose]: - Source: 'tests/src/paper.rs', lines 20:0-26:1 + Source: 'tests/src/paper.rs', lines 19:0-25:1 Visibility: public *) let choose (#t : Type0) (b : bool) (x : t) (y : t) : result (t & (t -> (t & t))) = @@ -30,7 +30,7 @@ let choose else let back = fun y1 -> (x, y1) in Ok (y, back) (** [paper::test_choose]: - Source: 'tests/src/paper.rs', lines 29:0-37:1 + Source: 'tests/src/paper.rs', lines 28:0-36:1 Visibility: public *) let test_choose : result unit = let* (z, choose_back) = choose true 0 0 in @@ -44,14 +44,14 @@ let test_choose : result unit = let _ = assert_norm (test_choose = Ok ()) (** [paper::List] - Source: 'tests/src/paper.rs', lines 41:0-44:1 + Source: 'tests/src/paper.rs', lines 40:0-43:1 Visibility: public *) type list_t (t : Type0) = | List_Cons : t -> list_t t -> list_t t | List_Nil : list_t t (** [paper::list_nth_mut]: - Source: 'tests/src/paper.rs', lines 48:0-61:1 + Source: 'tests/src/paper.rs', lines 47:0-60:1 Visibility: public *) let rec list_nth_mut (#t : Type0) (l : list_t t) (i : u32) : result (t & (t -> list_t t)) = @@ -68,7 +68,7 @@ let rec list_nth_mut end (** [paper::sum]: - Source: 'tests/src/paper.rs', lines 63:0-72:1 + Source: 'tests/src/paper.rs', lines 62:0-71:1 Visibility: public *) let rec sum (l : list_t i32) : result i32 = begin match l with @@ -77,7 +77,7 @@ let rec sum (l : list_t i32) : result i32 = end (** [paper::test_nth]: - Source: 'tests/src/paper.rs', lines 75:0-80:1 + Source: 'tests/src/paper.rs', lines 74:0-79:1 Visibility: public *) let test_nth : result unit = let* (x, list_nth_mut_back) = @@ -92,7 +92,7 @@ let test_nth : result unit = let _ = assert_norm (test_nth = Ok ()) (** [paper::call_choose]: - Source: 'tests/src/paper.rs', lines 83:0-89:1 + Source: 'tests/src/paper.rs', lines 82:0-88:1 Visibility: public *) let call_choose (p : (u32 & u32)) : result u32 = let (px, py) = p in diff --git a/tests/lean/CastSigned.lean b/tests/lean/CastSigned.lean index 1a63c7ddc..822364535 100644 --- a/tests/lean/CastSigned.lean +++ b/tests/lean/CastSigned.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [cast_signed] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false @@ -15,7 +17,7 @@ set_option maxRecDepth 2048 namespace cast_signed /-- [cast_signed::test_u8_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 10:0-14:1 + Source: 'tests/src/cast_signed.rs', lines 9:0-13:1 Visibility: public -/ def test_u8_cast_signed_all_ones : Result Unit := do let y ← core.num.U8.cast_signed 255#u8 @@ -25,7 +27,7 @@ def test_u8_cast_signed_all_ones : Result Unit := do #assert (test_u8_cast_signed_all_ones == ok ()) /-- [cast_signed::test_i8_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 18:0-22:1 + Source: 'tests/src/cast_signed.rs', lines 17:0-21:1 Visibility: public -/ def test_i8_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I8.cast_unsigned (-1)#i8 @@ -35,7 +37,7 @@ def test_i8_cast_unsigned_neg_one : Result Unit := do #assert (test_i8_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_u16_cast_signed_high_bit]: - Source: 'tests/src/cast_signed.rs', lines 26:0-30:1 + Source: 'tests/src/cast_signed.rs', lines 25:0-29:1 Visibility: public -/ def test_u16_cast_signed_high_bit : Result Unit := do let y ← core.num.U16.cast_signed 32768#u16 @@ -45,7 +47,7 @@ def test_u16_cast_signed_high_bit : Result Unit := do #assert (test_u16_cast_signed_high_bit == ok ()) /-- [cast_signed::test_i16_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 34:0-38:1 + Source: 'tests/src/cast_signed.rs', lines 33:0-37:1 Visibility: public -/ def test_i16_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I16.cast_unsigned (-1)#i16 @@ -55,7 +57,7 @@ def test_i16_cast_unsigned_neg_one : Result Unit := do #assert (test_i16_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_u32_cast_signed_small]: - Source: 'tests/src/cast_signed.rs', lines 42:0-46:1 + Source: 'tests/src/cast_signed.rs', lines 41:0-45:1 Visibility: public -/ def test_u32_cast_signed_small : Result Unit := do let y ← core.num.U32.cast_signed 255#u32 @@ -65,7 +67,7 @@ def test_u32_cast_signed_small : Result Unit := do #assert (test_u32_cast_signed_small == ok ()) /-- [cast_signed::test_u32_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 50:0-54:1 + Source: 'tests/src/cast_signed.rs', lines 49:0-53:1 Visibility: public -/ def test_u32_cast_signed_all_ones : Result Unit := do let y ← core.num.U32.cast_signed 4294967295#u32 @@ -75,7 +77,7 @@ def test_u32_cast_signed_all_ones : Result Unit := do #assert (test_u32_cast_signed_all_ones == ok ()) /-- [cast_signed::test_u32_cast_signed_high_bit]: - Source: 'tests/src/cast_signed.rs', lines 58:0-62:1 + Source: 'tests/src/cast_signed.rs', lines 57:0-61:1 Visibility: public -/ def test_u32_cast_signed_high_bit : Result Unit := do let y ← core.num.U32.cast_signed 2147483648#u32 @@ -85,7 +87,7 @@ def test_u32_cast_signed_high_bit : Result Unit := do #assert (test_u32_cast_signed_high_bit == ok ()) /-- [cast_signed::test_i32_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 66:0-70:1 + Source: 'tests/src/cast_signed.rs', lines 65:0-69:1 Visibility: public -/ def test_i32_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I32.cast_unsigned (-1)#i32 @@ -95,7 +97,7 @@ def test_i32_cast_unsigned_neg_one : Result Unit := do #assert (test_i32_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_i32_cast_roundtrip]: - Source: 'tests/src/cast_signed.rs', lines 74:0-78:1 + Source: 'tests/src/cast_signed.rs', lines 73:0-77:1 Visibility: public -/ def test_i32_cast_roundtrip : Result Unit := do let i ← core.num.U32.cast_signed 3735928559#u32 @@ -106,7 +108,7 @@ def test_i32_cast_roundtrip : Result Unit := do #assert (test_i32_cast_roundtrip == ok ()) /-- [cast_signed::test_u64_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 82:0-86:1 + Source: 'tests/src/cast_signed.rs', lines 81:0-85:1 Visibility: public -/ def test_u64_cast_signed_all_ones : Result Unit := do let y ← core.num.U64.cast_signed core.num.U64.MAX @@ -116,7 +118,7 @@ def test_u64_cast_signed_all_ones : Result Unit := do #assert (test_u64_cast_signed_all_ones == ok ()) /-- [cast_signed::test_i64_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 90:0-94:1 + Source: 'tests/src/cast_signed.rs', lines 89:0-93:1 Visibility: public -/ def test_i64_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I64.cast_unsigned (-1)#i64 @@ -126,7 +128,7 @@ def test_i64_cast_unsigned_neg_one : Result Unit := do #assert (test_i64_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_u128_cast_signed_all_ones]: - Source: 'tests/src/cast_signed.rs', lines 98:0-102:1 + Source: 'tests/src/cast_signed.rs', lines 97:0-101:1 Visibility: public -/ def test_u128_cast_signed_all_ones : Result Unit := do let y ← core.num.U128.cast_signed core.num.U128.MAX @@ -136,7 +138,7 @@ def test_u128_cast_signed_all_ones : Result Unit := do #assert (test_u128_cast_signed_all_ones == ok ()) /-- [cast_signed::test_i128_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 106:0-110:1 + Source: 'tests/src/cast_signed.rs', lines 105:0-109:1 Visibility: public -/ def test_i128_cast_unsigned_neg_one : Result Unit := do let y ← core.num.I128.cast_unsigned (-1)#i128 @@ -146,7 +148,7 @@ def test_i128_cast_unsigned_neg_one : Result Unit := do #assert (test_i128_cast_unsigned_neg_one == ok ()) /-- [cast_signed::test_usize_cast_roundtrip]: - Source: 'tests/src/cast_signed.rs', lines 114:0-118:1 + Source: 'tests/src/cast_signed.rs', lines 113:0-117:1 Visibility: public -/ def test_usize_cast_roundtrip : Result Unit := do let i ← core.num.Usize.cast_signed 12345#usize @@ -157,7 +159,7 @@ def test_usize_cast_roundtrip : Result Unit := do #assert (test_usize_cast_roundtrip == ok ()) /-- [cast_signed::test_isize_cast_unsigned_neg_one]: - Source: 'tests/src/cast_signed.rs', lines 122:0-126:1 + Source: 'tests/src/cast_signed.rs', lines 121:0-125:1 Visibility: public -/ def test_isize_cast_unsigned_neg_one : Result Unit := do let y ← core.num.Isize.cast_unsigned (-1)#isize diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index 53db69775..e95a5a77b 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [no_nested_borrows] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false @@ -15,14 +17,14 @@ set_option maxRecDepth 2048 namespace no_nested_borrows /-- [no_nested_borrows::Pair] - Source: 'tests/src/no_nested_borrows.rs', lines 8:0-11:1 + Source: 'tests/src/no_nested_borrows.rs', lines 7:0-10:1 Visibility: public -/ structure Pair (T1 : Type) (T2 : Type) where x : T1 y : T2 /-- [no_nested_borrows::List] - Source: 'tests/src/no_nested_borrows.rs', lines 13:0-16:1 + Source: 'tests/src/no_nested_borrows.rs', lines 12:0-15:1 Visibility: public -/ @[discriminant isize] inductive List (T : Type) where @@ -30,21 +32,21 @@ inductive List (T : Type) where | Nil : List T /-- [no_nested_borrows::One] - Source: 'tests/src/no_nested_borrows.rs', lines 24:0-26:1 + Source: 'tests/src/no_nested_borrows.rs', lines 23:0-25:1 Visibility: public -/ @[discriminant isize] inductive One (T1 : Type) where | One : T1 → One T1 /-- [no_nested_borrows::EmptyEnum] - Source: 'tests/src/no_nested_borrows.rs', lines 30:0-32:1 + Source: 'tests/src/no_nested_borrows.rs', lines 29:0-31:1 Visibility: public -/ @[discriminant isize] inductive EmptyEnum where | Empty : EmptyEnum /-- [no_nested_borrows::Enum] - Source: 'tests/src/no_nested_borrows.rs', lines 36:0-39:1 + Source: 'tests/src/no_nested_borrows.rs', lines 35:0-38:1 Visibility: public -/ @[discriminant isize] inductive Enum where @@ -52,13 +54,13 @@ inductive Enum where | Variant2 : Enum /-- [no_nested_borrows::EmptyStruct] - Source: 'tests/src/no_nested_borrows.rs', lines 43:0-43:25 + Source: 'tests/src/no_nested_borrows.rs', lines 42:0-42:25 Visibility: public -/ @[reducible] def EmptyStruct := Unit /-- [no_nested_borrows::Sum] - Source: 'tests/src/no_nested_borrows.rs', lines 45:0-48:1 + Source: 'tests/src/no_nested_borrows.rs', lines 44:0-47:1 Visibility: public -/ @[discriminant isize] inductive Sum (T1 : Type) (T2 : Type) where @@ -66,25 +68,25 @@ inductive Sum (T1 : Type) (T2 : Type) where | Right : T2 → Sum T1 T2 /-- [no_nested_borrows::cast_u32_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 50:0-52:1 + Source: 'tests/src/no_nested_borrows.rs', lines 49:0-51:1 Visibility: public -/ def cast_u32_to_i32 (x : Std.U32) : Result Std.I32 := do ok (UScalar.hcast .I32 x) /-- [no_nested_borrows::cast_bool_to_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 54:0-56:1 + Source: 'tests/src/no_nested_borrows.rs', lines 53:0-55:1 Visibility: public -/ def cast_bool_to_i32 (x : Bool) : Result Std.I32 := do ok (IScalar.cast_fromBool .I32 x) /-- [no_nested_borrows::cast_bool_to_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 59:0-61:1 + Source: 'tests/src/no_nested_borrows.rs', lines 58:0-60:1 Visibility: public -/ def cast_bool_to_bool (x : Bool) : Result Bool := do ok x /-- [no_nested_borrows::test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 65:0-75:1 + Source: 'tests/src/no_nested_borrows.rs', lines 64:0-74:1 Visibility: public -/ def test2 : Result Unit := do let _ ← 23#u32 + 44#u32 @@ -94,7 +96,7 @@ def test2 : Result Unit := do #assert (test2 == ok ()) /-- [no_nested_borrows::get_max]: - Source: 'tests/src/no_nested_borrows.rs', lines 77:0-83:1 + Source: 'tests/src/no_nested_borrows.rs', lines 76:0-82:1 Visibility: public -/ def get_max (x : Std.U32) (y : Std.U32) : Result Std.U32 := do if x >= y @@ -102,7 +104,7 @@ def get_max (x : Std.U32) (y : Std.U32) : Result Std.U32 := do else ok y /-- [no_nested_borrows::test3]: - Source: 'tests/src/no_nested_borrows.rs', lines 86:0-91:1 + Source: 'tests/src/no_nested_borrows.rs', lines 85:0-90:1 Visibility: public -/ def test3 : Result Unit := do let x ← get_max 4#u32 3#u32 @@ -114,7 +116,7 @@ def test3 : Result Unit := do #assert (test3 == ok ()) /-- [no_nested_borrows::test_neg1]: - Source: 'tests/src/no_nested_borrows.rs', lines 94:0-98:1 + Source: 'tests/src/no_nested_borrows.rs', lines 93:0-97:1 Visibility: public -/ def test_neg1 : Result Unit := do let y ← -. 3#i32 @@ -124,7 +126,7 @@ def test_neg1 : Result Unit := do #assert (test_neg1 == ok ()) /-- [no_nested_borrows::refs_test1]: - Source: 'tests/src/no_nested_borrows.rs', lines 102:0-111:1 + Source: 'tests/src/no_nested_borrows.rs', lines 101:0-110:1 Visibility: public -/ def refs_test1 : Result Unit := do massert (1#i32 = 1#i32) @@ -133,7 +135,7 @@ def refs_test1 : Result Unit := do #assert (refs_test1 == ok ()) /-- [no_nested_borrows::refs_test2]: - Source: 'tests/src/no_nested_borrows.rs', lines 114:0-126:1 + Source: 'tests/src/no_nested_borrows.rs', lines 113:0-125:1 Visibility: public -/ def refs_test2 : Result Unit := do massert (2#i32 = 2#i32) @@ -145,7 +147,7 @@ def refs_test2 : Result Unit := do #assert (refs_test2 == ok ()) /-- [no_nested_borrows::test_list1]: - Source: 'tests/src/no_nested_borrows.rs', lines 131:0-133:1 + Source: 'tests/src/no_nested_borrows.rs', lines 130:0-132:1 Visibility: public -/ def test_list1 : Result Unit := do ok () @@ -154,31 +156,31 @@ def test_list1 : Result Unit := do #assert (test_list1 == ok ()) /-- [no_nested_borrows::copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 135:0-137:1 + Source: 'tests/src/no_nested_borrows.rs', lines 134:0-136:1 Visibility: public -/ def copy_int (x : Std.I32) : Result Std.I32 := do ok x /-- [no_nested_borrows::test_unreachable]: - Source: 'tests/src/no_nested_borrows.rs', lines 141:0-145:1 + Source: 'tests/src/no_nested_borrows.rs', lines 140:0-144:1 Visibility: public -/ def test_unreachable (b : Bool) : Result Unit := do massert (¬ b) /-- [no_nested_borrows::test_panic]: - Source: 'tests/src/no_nested_borrows.rs', lines 148:0-152:1 + Source: 'tests/src/no_nested_borrows.rs', lines 147:0-151:1 Visibility: public -/ def test_panic (b : Bool) : Result Unit := do massert (¬ b) /-- [no_nested_borrows::test_panic_msg]: - Source: 'tests/src/no_nested_borrows.rs', lines 156:0-160:1 + Source: 'tests/src/no_nested_borrows.rs', lines 155:0-159:1 Visibility: public -/ def test_panic_msg (b : Bool) : Result Unit := do massert (¬ b) /-- [no_nested_borrows::test_copy_int]: - Source: 'tests/src/no_nested_borrows.rs', lines 164:0-169:1 + Source: 'tests/src/no_nested_borrows.rs', lines 163:0-168:1 Visibility: public -/ def test_copy_int : Result Unit := do let y ← copy_int 0#i32 @@ -188,7 +190,7 @@ def test_copy_int : Result Unit := do #assert (test_copy_int == ok ()) /-- [no_nested_borrows::is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 171:0-176:1 + Source: 'tests/src/no_nested_borrows.rs', lines 170:0-175:1 Visibility: public -/ def is_cons {T : Type} (l : List T) : Result Bool := do match l with @@ -196,7 +198,7 @@ def is_cons {T : Type} (l : List T) : Result Bool := do | List.Nil => ok false /-- [no_nested_borrows::test_is_cons]: - Source: 'tests/src/no_nested_borrows.rs', lines 179:0-183:1 + Source: 'tests/src/no_nested_borrows.rs', lines 178:0-182:1 Visibility: public -/ def test_is_cons : Result Unit := do let b ← is_cons (List.Cons 0#i32 List.Nil) @@ -206,7 +208,7 @@ def test_is_cons : Result Unit := do #assert (test_is_cons == ok ()) /-- [no_nested_borrows::split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 185:0-190:1 + Source: 'tests/src/no_nested_borrows.rs', lines 184:0-189:1 Visibility: public -/ def split_list {T : Type} (l : List T) : Result (T × (List T)) := do match l with @@ -214,7 +216,7 @@ def split_list {T : Type} (l : List T) : Result (T × (List T)) := do | List.Nil => fail panic /-- [no_nested_borrows::test_split_list]: - Source: 'tests/src/no_nested_borrows.rs', lines 194:0-199:1 + Source: 'tests/src/no_nested_borrows.rs', lines 193:0-198:1 Visibility: public -/ def test_split_list : Result Unit := do let (hd, _) ← split_list (List.Cons 0#i32 List.Nil) @@ -224,7 +226,7 @@ def test_split_list : Result Unit := do #assert (test_split_list == ok ()) /-- [no_nested_borrows::choose]: - Source: 'tests/src/no_nested_borrows.rs', lines 201:0-207:1 + Source: 'tests/src/no_nested_borrows.rs', lines 200:0-206:1 Visibility: public -/ def choose {T : Type} (b : Bool) (x : T) (y : T) : Result (T × (T → (T × T))) := do @@ -235,7 +237,7 @@ def choose ok (y, back) /-- [no_nested_borrows::choose_test]: - Source: 'tests/src/no_nested_borrows.rs', lines 210:0-219:1 + Source: 'tests/src/no_nested_borrows.rs', lines 209:0-218:1 Visibility: public -/ def choose_test : Result Unit := do let (z, choose_back) ← choose true 0#i32 0#i32 @@ -249,13 +251,13 @@ def choose_test : Result Unit := do #assert (choose_test == ok ()) /-- [no_nested_borrows::test_char]: - Source: 'tests/src/no_nested_borrows.rs', lines 222:0-224:1 + Source: 'tests/src/no_nested_borrows.rs', lines 221:0-223:1 Visibility: public -/ def test_char : Result Char := do ok 'a' /-- [no_nested_borrows::panic_mut_borrow]: - Source: 'tests/src/no_nested_borrows.rs', lines 227:0-229:1 + Source: 'tests/src/no_nested_borrows.rs', lines 226:0-228:1 Visibility: public -/ def panic_mut_borrow (i : Std.U32) : Result Std.U32 := do fail panic @@ -263,7 +265,7 @@ def panic_mut_borrow (i : Std.U32) : Result Std.U32 := do mutual /-- [no_nested_borrows::Tree] - Source: 'tests/src/no_nested_borrows.rs', lines 232:0-235:1 + Source: 'tests/src/no_nested_borrows.rs', lines 231:0-234:1 Visibility: public -/ @[discriminant isize] inductive Tree (T : Type) where @@ -271,7 +273,7 @@ inductive Tree (T : Type) where | Node : T → NodeElem T → Tree T → Tree T /-- [no_nested_borrows::NodeElem] - Source: 'tests/src/no_nested_borrows.rs', lines 237:0-240:1 + Source: 'tests/src/no_nested_borrows.rs', lines 236:0-239:1 Visibility: public -/ @[discriminant isize] inductive NodeElem (T : Type) where @@ -281,7 +283,7 @@ inductive NodeElem (T : Type) where end /-- [no_nested_borrows::list_length]: - Source: 'tests/src/no_nested_borrows.rs', lines 273:0-278:1 + Source: 'tests/src/no_nested_borrows.rs', lines 272:0-277:1 Visibility: public -/ def list_length {T : Type} (l : List T) : Result Std.U32 := do match l with @@ -291,7 +293,7 @@ def list_length {T : Type} (l : List T) : Result Std.U32 := do partial_fixpoint /-- [no_nested_borrows::list_nth_shared]: - Source: 'tests/src/no_nested_borrows.rs', lines 281:0-294:1 + Source: 'tests/src/no_nested_borrows.rs', lines 280:0-293:1 Visibility: public -/ def list_nth_shared {T : Type} (l : List T) (i : Std.U32) : Result T := do match l with @@ -304,7 +306,7 @@ def list_nth_shared {T : Type} (l : List T) (i : Std.U32) : Result T := do partial_fixpoint /-- [no_nested_borrows::list_nth_mut]: - Source: 'tests/src/no_nested_borrows.rs', lines 297:0-310:1 + Source: 'tests/src/no_nested_borrows.rs', lines 296:0-309:1 Visibility: public -/ def list_nth_mut {T : Type} (l : List T) (i : Std.U32) : Result (T × (T → List T)) := do @@ -323,7 +325,7 @@ def list_nth_mut partial_fixpoint /-- [no_nested_borrows::list_rev_aux]: - Source: 'tests/src/no_nested_borrows.rs', lines 313:0-323:1 + Source: 'tests/src/no_nested_borrows.rs', lines 312:0-322:1 Visibility: public -/ def list_rev_aux {T : Type} (li : List T) (lo : List T) : Result (List T) := do match li with @@ -332,14 +334,14 @@ def list_rev_aux {T : Type} (li : List T) (lo : List T) : Result (List T) := do partial_fixpoint /-- [no_nested_borrows::list_rev]: - Source: 'tests/src/no_nested_borrows.rs', lines 327:0-330:1 + Source: 'tests/src/no_nested_borrows.rs', lines 326:0-329:1 Visibility: public -/ def list_rev {T : Type} (l : List T) : Result (List T) := do let (li, _) := core.mem.replace l List.Nil list_rev_aux li List.Nil /-- [no_nested_borrows::test_list_functions]: - Source: 'tests/src/no_nested_borrows.rs', lines 333:0-347:1 + Source: 'tests/src/no_nested_borrows.rs', lines 332:0-346:1 Visibility: public -/ def test_list_functions : Result Unit := do let i ← @@ -372,7 +374,7 @@ def test_list_functions : Result Unit := do #assert (test_list_functions == ok ()) /-- [no_nested_borrows::id_mut_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 349:0-351:1 + Source: 'tests/src/no_nested_borrows.rs', lines 348:0-350:1 Visibility: public -/ def id_mut_pair1 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -381,7 +383,7 @@ def id_mut_pair1 ok ((x, y), fun p => p) /-- [no_nested_borrows::id_mut_pair2]: - Source: 'tests/src/no_nested_borrows.rs', lines 353:0-355:1 + Source: 'tests/src/no_nested_borrows.rs', lines 352:0-354:1 Visibility: public -/ def id_mut_pair2 {T1 : Type} {T2 : Type} (p : (T1 × T2)) : @@ -390,7 +392,7 @@ def id_mut_pair2 ok (p, fun p1 => p1) /-- [no_nested_borrows::id_mut_pair3]: - Source: 'tests/src/no_nested_borrows.rs', lines 357:0-359:1 + Source: 'tests/src/no_nested_borrows.rs', lines 356:0-358:1 Visibility: public -/ def id_mut_pair3 {T1 : Type} {T2 : Type} (x : T1) (y : T2) : @@ -399,7 +401,7 @@ def id_mut_pair3 ok ((x, y), fun x1 => x1, fun y1 => y1) /-- [no_nested_borrows::id_mut_pair4]: - Source: 'tests/src/no_nested_borrows.rs', lines 361:0-363:1 + Source: 'tests/src/no_nested_borrows.rs', lines 360:0-362:1 Visibility: public -/ def id_mut_pair4 {T1 : Type} {T2 : Type} (p : (T1 × T2)) : @@ -408,43 +410,43 @@ def id_mut_pair4 ok (p, fun p1 => p1, fun p1 => p1) /-- [no_nested_borrows::StructWithTuple] - Source: 'tests/src/no_nested_borrows.rs', lines 368:0-370:1 + Source: 'tests/src/no_nested_borrows.rs', lines 367:0-369:1 Visibility: public -/ structure StructWithTuple (T1 : Type) (T2 : Type) where p : (T1 × T2) /-- [no_nested_borrows::new_tuple1]: - Source: 'tests/src/no_nested_borrows.rs', lines 372:0-374:1 + Source: 'tests/src/no_nested_borrows.rs', lines 371:0-373:1 Visibility: public -/ def new_tuple1 : Result (StructWithTuple Std.U32 Std.U32) := do ok { p := (1#u32, 2#u32) } /-- [no_nested_borrows::new_tuple2]: - Source: 'tests/src/no_nested_borrows.rs', lines 376:0-378:1 + Source: 'tests/src/no_nested_borrows.rs', lines 375:0-377:1 Visibility: public -/ def new_tuple2 : Result (StructWithTuple Std.I16 Std.I16) := do ok { p := (1#i16, 2#i16) } /-- [no_nested_borrows::new_tuple3]: - Source: 'tests/src/no_nested_borrows.rs', lines 380:0-382:1 + Source: 'tests/src/no_nested_borrows.rs', lines 379:0-381:1 Visibility: public -/ def new_tuple3 : Result (StructWithTuple Std.U64 Std.I64) := do ok { p := (1#u64, 2#i64) } /-- [no_nested_borrows::StructWithPair] - Source: 'tests/src/no_nested_borrows.rs', lines 385:0-387:1 + Source: 'tests/src/no_nested_borrows.rs', lines 384:0-386:1 Visibility: public -/ structure StructWithPair (T1 : Type) (T2 : Type) where p : Pair T1 T2 /-- [no_nested_borrows::new_pair1]: - Source: 'tests/src/no_nested_borrows.rs', lines 389:0-395:1 + Source: 'tests/src/no_nested_borrows.rs', lines 388:0-394:1 Visibility: public -/ def new_pair1 : Result (StructWithPair Std.U32 Std.U32) := do ok { p := { x := 1#u32, y := 2#u32 } } /-- [no_nested_borrows::test_constants]: - Source: 'tests/src/no_nested_borrows.rs', lines 398:0-403:1 + Source: 'tests/src/no_nested_borrows.rs', lines 397:0-402:1 Visibility: public -/ def test_constants : Result Unit := do let swt ← new_tuple1 @@ -463,7 +465,7 @@ def test_constants : Result Unit := do #assert (test_constants == ok ()) /-- [no_nested_borrows::test_weird_borrows1]: - Source: 'tests/src/no_nested_borrows.rs', lines 408:0-416:1 + Source: 'tests/src/no_nested_borrows.rs', lines 407:0-415:1 Visibility: public -/ def test_weird_borrows1 : Result Unit := do ok () @@ -472,7 +474,7 @@ def test_weird_borrows1 : Result Unit := do #assert (test_weird_borrows1 == ok ()) /-- [no_nested_borrows::test_mem_replace]: - Source: 'tests/src/no_nested_borrows.rs', lines 418:0-422:1 + Source: 'tests/src/no_nested_borrows.rs', lines 417:0-421:1 Visibility: public -/ def test_mem_replace (px : Std.U32) : Result Std.U32 := do let (y, _) := core.mem.replace px 1#u32 @@ -480,7 +482,7 @@ def test_mem_replace (px : Std.U32) : Result Std.U32 := do ok 2#u32 /-- [no_nested_borrows::test_shared_borrow_bool1]: - Source: 'tests/src/no_nested_borrows.rs', lines 425:0-434:1 + Source: 'tests/src/no_nested_borrows.rs', lines 424:0-433:1 Visibility: public -/ def test_shared_borrow_bool1 (b : Bool) : Result Std.U32 := do if b @@ -488,13 +490,13 @@ def test_shared_borrow_bool1 (b : Bool) : Result Std.U32 := do else ok 1#u32 /-- [no_nested_borrows::test_shared_borrow_bool2]: - Source: 'tests/src/no_nested_borrows.rs', lines 438:0-448:1 + Source: 'tests/src/no_nested_borrows.rs', lines 437:0-447:1 Visibility: public -/ def test_shared_borrow_bool2 : Result Std.U32 := do ok 0#u32 /-- [no_nested_borrows::test_shared_borrow_enum1]: - Source: 'tests/src/no_nested_borrows.rs', lines 453:0-461:1 + Source: 'tests/src/no_nested_borrows.rs', lines 452:0-460:1 Visibility: public -/ def test_shared_borrow_enum1 (l : List Std.U32) : Result Std.U32 := do match l with @@ -502,58 +504,58 @@ def test_shared_borrow_enum1 (l : List Std.U32) : Result Std.U32 := do | List.Nil => ok 0#u32 /-- [no_nested_borrows::test_shared_borrow_enum2]: - Source: 'tests/src/no_nested_borrows.rs', lines 465:0-474:1 + Source: 'tests/src/no_nested_borrows.rs', lines 464:0-473:1 Visibility: public -/ def test_shared_borrow_enum2 : Result Std.U32 := do ok 0#u32 /-- [no_nested_borrows::incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 476:0-478:1 + Source: 'tests/src/no_nested_borrows.rs', lines 475:0-477:1 Visibility: public -/ def incr (x : Std.U32) : Result Std.U32 := do x + 1#u32 /-- [no_nested_borrows::call_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 480:0-483:1 + Source: 'tests/src/no_nested_borrows.rs', lines 479:0-482:1 Visibility: public -/ def call_incr (x : Std.U32) : Result Std.U32 := do incr x /-- [no_nested_borrows::read_then_incr]: - Source: 'tests/src/no_nested_borrows.rs', lines 485:0-489:1 + Source: 'tests/src/no_nested_borrows.rs', lines 484:0-488:1 Visibility: public -/ def read_then_incr (x : Std.U32) : Result (Std.U32 × Std.U32) := do let x1 ← x + 1#u32 ok (x, x1) /-- [no_nested_borrows::Tuple] - Source: 'tests/src/no_nested_borrows.rs', lines 491:0-491:33 + Source: 'tests/src/no_nested_borrows.rs', lines 490:0-490:33 Visibility: public -/ def Tuple (T1 : Type) (T2 : Type) := T1 × T2 /-- [no_nested_borrows::read_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 493:0-495:1 + Source: 'tests/src/no_nested_borrows.rs', lines 492:0-494:1 Visibility: public -/ def read_tuple (x : (Std.U32 × Std.U32)) : Result Std.U32 := do let (i, _) := x ok i /-- [no_nested_borrows::update_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 497:0-499:1 + Source: 'tests/src/no_nested_borrows.rs', lines 496:0-498:1 Visibility: public -/ def update_tuple (x : (Std.U32 × Std.U32)) : Result (Std.U32 × Std.U32) := do let (_, i) := x ok (1#u32, i) /-- [no_nested_borrows::read_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 501:0-503:1 + Source: 'tests/src/no_nested_borrows.rs', lines 500:0-502:1 Visibility: public -/ def read_tuple_struct (x : Tuple Std.U32 Std.U32) : Result Std.U32 := do let (i, _) := x ok i /-- [no_nested_borrows::update_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 505:0-507:1 + Source: 'tests/src/no_nested_borrows.rs', lines 504:0-506:1 Visibility: public -/ def update_tuple_struct (x : Tuple Std.U32 Std.U32) : Result (Tuple Std.U32 Std.U32) := do @@ -561,50 +563,50 @@ def update_tuple_struct ok (1#u32, i) /-- [no_nested_borrows::create_tuple_struct]: - Source: 'tests/src/no_nested_borrows.rs', lines 509:0-511:1 + Source: 'tests/src/no_nested_borrows.rs', lines 508:0-510:1 Visibility: public -/ def create_tuple_struct (x : Std.U32) (y : Std.U64) : Result (Tuple Std.U32 Std.U64) := do ok (x, y) /-- [no_nested_borrows::IdType] - Source: 'tests/src/no_nested_borrows.rs', lines 514:0-514:24 + Source: 'tests/src/no_nested_borrows.rs', lines 513:0-513:24 Visibility: public -/ @[reducible] def IdType (T : Type) := T /-- [no_nested_borrows::use_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 516:0-518:1 + Source: 'tests/src/no_nested_borrows.rs', lines 515:0-517:1 Visibility: public -/ def use_id_type {T : Type} (x : IdType T) : Result T := do ok x /-- [no_nested_borrows::create_id_type]: - Source: 'tests/src/no_nested_borrows.rs', lines 520:0-522:1 + Source: 'tests/src/no_nested_borrows.rs', lines 519:0-521:1 Visibility: public -/ def create_id_type {T : Type} (x : T) : Result (IdType T) := do ok x /-- [no_nested_borrows::not_bool]: - Source: 'tests/src/no_nested_borrows.rs', lines 524:0-526:1 + Source: 'tests/src/no_nested_borrows.rs', lines 523:0-525:1 Visibility: public -/ def not_bool (x : Bool) : Result Bool := do ok (¬ x) /-- [no_nested_borrows::not_u32]: - Source: 'tests/src/no_nested_borrows.rs', lines 528:0-530:1 + Source: 'tests/src/no_nested_borrows.rs', lines 527:0-529:1 Visibility: public -/ def not_u32 (x : Std.U32) : Result Std.U32 := do ok (~~~ x) /-- [no_nested_borrows::not_i32]: - Source: 'tests/src/no_nested_borrows.rs', lines 532:0-534:1 + Source: 'tests/src/no_nested_borrows.rs', lines 531:0-533:1 Visibility: public -/ def not_i32 (x : Std.I32) : Result Std.I32 := do ok (~~~ x) /-- [no_nested_borrows::borrow_mut_tuple]: - Source: 'tests/src/no_nested_borrows.rs', lines 536:0-538:1 -/ + Source: 'tests/src/no_nested_borrows.rs', lines 535:0-537:1 -/ def borrow_mut_tuple {T : Type} {U : Type} (x : (T × U)) : Result ((T × U) × ((T × U) → (T × U))) @@ -612,12 +614,12 @@ def borrow_mut_tuple ok (x, fun x1 => x1) /-- [no_nested_borrows::ExpandSimpliy::Wrapper] - Source: 'tests/src/no_nested_borrows.rs', lines 542:4-542:32 + Source: 'tests/src/no_nested_borrows.rs', lines 541:4-541:32 Visibility: public -/ def ExpandSimpliy.Wrapper (T : Type) := T × T /-- [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb1]: - Source: 'tests/src/no_nested_borrows.rs', lines 544:4-550:5 + Source: 'tests/src/no_nested_borrows.rs', lines 543:4-549:5 Visibility: public -/ def ExpandSimpliy.check_expand_simplify_symb1 (x : ExpandSimpliy.Wrapper Bool) : Result (ExpandSimpliy.Wrapper Bool) := do @@ -627,14 +629,14 @@ def ExpandSimpliy.check_expand_simplify_symb1 else ok x /-- [no_nested_borrows::ExpandSimpliy::Wrapper2] - Source: 'tests/src/no_nested_borrows.rs', lines 552:4-555:5 + Source: 'tests/src/no_nested_borrows.rs', lines 551:4-554:5 Visibility: public -/ structure ExpandSimpliy.Wrapper2 where b : Bool x : Std.U32 /-- [no_nested_borrows::ExpandSimpliy::check_expand_simplify_symb2]: - Source: 'tests/src/no_nested_borrows.rs', lines 557:4-563:5 + Source: 'tests/src/no_nested_borrows.rs', lines 556:4-562:5 Visibility: public -/ def ExpandSimpliy.check_expand_simplify_symb2 (x : ExpandSimpliy.Wrapper2) : Result ExpandSimpliy.Wrapper2 := do diff --git a/tests/lean/Paper.lean b/tests/lean/Paper.lean index 2744fd9d2..9a5cad5df 100644 --- a/tests/lean/Paper.lean +++ b/tests/lean/Paper.lean @@ -1,6 +1,8 @@ +module -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [paper] -import Aeneas +public import Aeneas +@[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false @@ -15,13 +17,13 @@ set_option maxRecDepth 2048 namespace paper /-- [paper::ref_incr]: - Source: 'tests/src/paper.rs', lines 8:0-10:1 + Source: 'tests/src/paper.rs', lines 7:0-9:1 Visibility: public -/ def ref_incr (x : Std.I32) : Result Std.I32 := do x + 1#i32 /-- [paper::test_incr]: - Source: 'tests/src/paper.rs', lines 13:0-17:1 + Source: 'tests/src/paper.rs', lines 12:0-16:1 Visibility: public -/ def test_incr : Result Unit := do let x ← ref_incr 0#i32 @@ -31,7 +33,7 @@ def test_incr : Result Unit := do #assert (test_incr == ok ()) /-- [paper::choose]: - Source: 'tests/src/paper.rs', lines 20:0-26:1 + Source: 'tests/src/paper.rs', lines 19:0-25:1 Visibility: public -/ def choose {T : Type} (b : Bool) (x : T) (y : T) : Result (T × (T → (T × T))) := do @@ -42,7 +44,7 @@ def choose ok (y, back) /-- [paper::test_choose]: - Source: 'tests/src/paper.rs', lines 29:0-37:1 + Source: 'tests/src/paper.rs', lines 28:0-36:1 Visibility: public -/ def test_choose : Result Unit := do let (z, choose_back) ← choose true 0#i32 0#i32 @@ -56,7 +58,7 @@ def test_choose : Result Unit := do #assert (test_choose == ok ()) /-- [paper::List] - Source: 'tests/src/paper.rs', lines 41:0-44:1 + Source: 'tests/src/paper.rs', lines 40:0-43:1 Visibility: public -/ @[discriminant isize] inductive List (T : Type) where @@ -64,7 +66,7 @@ inductive List (T : Type) where | Nil : List T /-- [paper::list_nth_mut]: - Source: 'tests/src/paper.rs', lines 48:0-61:1 + Source: 'tests/src/paper.rs', lines 47:0-60:1 Visibility: public -/ def list_nth_mut {T : Type} (l : List T) (i : Std.U32) : Result (T × (T → List T)) := do @@ -83,7 +85,7 @@ def list_nth_mut partial_fixpoint /-- [paper::sum]: - Source: 'tests/src/paper.rs', lines 63:0-72:1 + Source: 'tests/src/paper.rs', lines 62:0-71:1 Visibility: public -/ def sum (l : List Std.I32) : Result Std.I32 := do match l with @@ -93,7 +95,7 @@ def sum (l : List Std.I32) : Result Std.I32 := do partial_fixpoint /-- [paper::test_nth]: - Source: 'tests/src/paper.rs', lines 75:0-80:1 + Source: 'tests/src/paper.rs', lines 74:0-79:1 Visibility: public -/ def test_nth : Result Unit := do let (x, list_nth_mut_back) ← @@ -108,7 +110,7 @@ def test_nth : Result Unit := do #assert (test_nth == ok ()) /-- [paper::call_choose]: - Source: 'tests/src/paper.rs', lines 83:0-89:1 + Source: 'tests/src/paper.rs', lines 82:0-88:1 Visibility: public -/ def call_choose (p : (Std.U32 × Std.U32)) : Result Std.U32 := do let (px, py) := p From d66540f86cdcaa8551caec49c22b9db81c6a17ab Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Sat, 25 Jul 2026 15:46:55 +0200 Subject: [PATCH 38/40] min imports --- backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean b/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean index e17e0d80e..7331fffe9 100644 --- a/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean +++ b/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean @@ -6,7 +6,8 @@ Analogous to `fcongr` (which is `congr` with reducible transparency). -/ module -public import ImportGraph.Tools.MinImports +public meta import Lean.Elab.Tactic.Basic +public meta import Lean.Elab.Term.TermElabM public section open Lean Meta Parser Elab Tactic From 01b86b25e1d4a2769d559c97b8206ef05ecb3f38 Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Sat, 25 Jul 2026 15:47:53 +0200 Subject: [PATCH 39/40] revert --- backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean b/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean index 7331fffe9..d676c6e22 100644 --- a/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean +++ b/backends/lean/Aeneas/Tactic/Misc/FApplyExact.lean @@ -6,8 +6,7 @@ Analogous to `fcongr` (which is `congr` with reducible transparency). -/ module -public meta import Lean.Elab.Tactic.Basic -public meta import Lean.Elab.Term.TermElabM +public import Lean public section open Lean Meta Parser Elab Tactic From 397bac9ad6e24311262d9c35464dfab5f74f7f5b Mon Sep 17 00:00:00 2001 From: Oliver Butterley Date: Tue, 28 Jul 2026 12:23:44 +0200 Subject: [PATCH 40/40] avoid trailing public section --- src/Translate.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Translate.ml b/src/Translate.ml index c915e8d41..d054f592d 100644 --- a/src/Translate.ml +++ b/src/Translate.ml @@ -2158,8 +2158,7 @@ let extract_translated_crate (filename : string) (dest_dir : string) let out = open_out filename in if !Config.use_lean_modules then ( Printf.fprintf out "module\n"; - Printf.fprintf out "public import %s.Funs\n" crate_name; - Printf.fprintf out "public section\n") + Printf.fprintf out "public import %s.Funs\n" crate_name) else Printf.fprintf out "import %s.Funs\n" crate_name; (* Flush and close the file, log *) close_out out;