Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion. • 103 items • Updated • 3
statement stringlengths 1 615 | proof stringlengths 0 8.26k | type stringclasses 11
values | symbolic_name stringlengths 1 64 | library stringclasses 29
values | filename stringclasses 121
values | imports listlengths 0 15 | deps listlengths 0 20 | docstring stringlengths 0 1.5k | source_url stringclasses 1
value | commit stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|
compileCargo (name : String) (manifestFile : FilePath) (cargo : FilePath := "cargo")
(env : Array (String × Option String)) : LogIO Unit | do
logInfo s!"Creating {name}"
proc {
env := env
cmd := cargo.toString
args := #["build", "--release", "--manifest-path", manifestFile.toString]
} | def | compileCargo | Root | lakefile.lean | [
"Lake"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
buildCargo (targetFile : FilePath) (manifestFile : FilePath) (targetDest : FilePath)
(oFileJobs : Array (BuildJob FilePath)) (stopOnSuccess : Bool) :
SpawnM (BuildJob FilePath) | let name := targetFile.fileName.getD targetFile.toString
buildFileAfterDepArray targetFile oFileJobs fun _ => do
let env := if stopOnSuccess then #[("RUSTFLAGS", some "--cfg stop_on_success")] else #[]
compileCargo name manifestFile (env := env)
createParentDirs targetDest
proc {
cmd := "cp"
... | def | buildCargo | Root | lakefile.lean | [
"Lake"
] | [
"compileCargo"
] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
runEquivalenceTactic (mvarId : MVarId) (stx : Syntax) : TermElabM Unit | do
runTransformationTactic TransformationGoal.Equivalence mvarId stx | def | CvxLean.runEquivalenceTactic | Command | CvxLean/Command/Equivalence.lean | [
"CvxLean.Lib.Equivalence",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Equivalence",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Run a transformation tactic indicating that an equivalence is expected. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
elabEquivalenceProof (lhs : Expr) (rhsName : Name) (stx : Syntax) : TermElabM (Expr × Expr) | elabTransformationProof TransformationGoal.Equivalence lhs rhsName stx | def | CvxLean.elabEquivalenceProof | Command | CvxLean/Command/Equivalence.lean | [
"CvxLean.Lib.Equivalence",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Equivalence",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Run equivalence tactic and return both the right-hand term (`q`) and the equivalence proof, of
type `Equivalence p q`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalEquivalenceAux (probIdStx eqvIdStx : TSyntax `ident) (xs : Array (Syntax × Expr))
(lhsStx : Syntax) (proofStx : TSyntax `Lean.Parser.Term.byTactic) (bwdMap : Bool) :
TermElabM Unit | do
let D ← Meta.mkFreshTypeMVar
let R ← Meta.mkFreshTypeMVar
let lhsTy := mkApp2 (Lean.mkConst ``Minimization) D R
let lhs ← elabTermAndSynthesizeEnsuringType lhsStx (some lhsTy)
-- NOTE: `instantiateMVars` does not infer the preorder instance.
for mvarId in ← getMVars lhs do
try {
let mvarVal ← ... | def | CvxLean.evalEquivalenceAux | Command | CvxLean/Command/Equivalence.lean | [
"CvxLean.Lib.Equivalence",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Equivalence",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [
"Lean.simpleAddAndCompileDefn",
"Minimization",
"aggressiveSimpConfig"
] | Open an equivalence environment with a given left-hand-side problem (`lhsStx`) and perhaps some
parameters (`xs`). From this, an equivalence goal is set to a target problem which is represented by
a metavariable. The proof (`proofStx`) is evaluated to produce the desired equivalence. The
metavariable is then instantiat... | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalEquivalence : CommandElab | fun stx => match stx with
| `(equivalence $eqvId / $probId $declSig := $proofStx) => do
liftTermElabM do
let (binders, lhsStx) := expandDeclSig declSig.raw
elabBindersEx binders.getArgs fun xs =>
evalEquivalenceAux probId eqvId xs lhsStx proofStx false
| _ => throwUnsupportedSyntax | def | CvxLean.evalEquivalence | Command | CvxLean/Command/Equivalence.lean | [
"CvxLean.Lib.Equivalence",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Equivalence",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Create `equivalence` command. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalEquivalenceAndBwdMap : CommandElab | fun stx => match stx with
| `(equivalence* $eqvId / $probId $declSig := $proofStx) => do
liftTermElabM do
let (binders, lhsStx) := expandDeclSig declSig.raw
elabBindersEx binders.getArgs fun xs =>
evalEquivalenceAux probId eqvId xs lhsStx proofStx true
| _ => throwUnsupportedSyntax | def | CvxLean.evalEquivalenceAndBwdMap | Command | CvxLean/Command/Equivalence.lean | [
"CvxLean.Lib.Equivalence",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Equivalence",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Same as `equivalence` but also adds the backward map to the environment. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
runReductionTactic (mvarId : MVarId) (stx : Syntax) : TermElabM Unit | runTransformationTactic TransformationGoal.Reduction mvarId stx | def | CvxLean.runReductionTactic | Command | CvxLean/Command/Reduction.lean | [
"Lean",
"CvxLean.Lib.Reduction",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Reduction",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Run a transformation tactic indicating that a reduction is expected. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
elabReductionProof (lhs : Expr) (rhsName : Name) (stx : Syntax) : TermElabM (Expr × Expr) | elabTransformationProof TransformationGoal.Reduction lhs rhsName stx | def | CvxLean.elabReductionProof | Command | CvxLean/Command/Reduction.lean | [
"Lean",
"CvxLean.Lib.Reduction",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Reduction",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Run reduction tactic and return both the right-hand term (`q`) and the reduction proof, of
type `Reduction p q`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalReductionAux (probIdStx redIdStx : TSyntax `ident) (xs : Array (Syntax × Expr))
(lhsStx : Syntax) (proofStx : TSyntax `Lean.Parser.Term.byTactic) (bwdMap : Bool) :
TermElabM Unit | do
let D ← Meta.mkFreshTypeMVar
let R ← Meta.mkFreshTypeMVar
let lhsTy := mkApp2 (Lean.mkConst ``Minimization) D R
let lhs ← elabTermAndSynthesizeEnsuringType lhsStx (some lhsTy)
-- NOTE: `instantiateMVars` does not infer the preorder instance.
for mvarId in ← getMVars lhs do
try {
let mvarVal ← ... | def | CvxLean.evalReductionAux | Command | CvxLean/Command/Reduction.lean | [
"Lean",
"CvxLean.Lib.Reduction",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Reduction",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [
"Lean.simpleAddAndCompileDefn",
"Minimization",
"aggressiveSimpConfig"
] | Open a reduction environment with a given left-hand-side problem (`lhsStx`) and perhaps some
parameters (`xs`). From this, a reduction goal is set to a target problem which is represented by a
metavariable. The proof (`proofStx`) is evaluated to produce the desired reduction. The metavariable
is then instantiated and t... | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalReduction : CommandElab | fun stx => match stx with
| `(reduction $eqvId / $probId $declSig := $proofStx) => do
liftTermElabM do
let (binders, lhsStx) := expandDeclSig declSig.raw
elabBindersEx binders.getArgs fun xs =>
evalReductionAux probId eqvId xs lhsStx proofStx false
| _ => throwUnsupportedSyntax | def | CvxLean.evalReduction | Command | CvxLean/Command/Reduction.lean | [
"Lean",
"CvxLean.Lib.Reduction",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Reduction",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Create `reduction` command. It is similar to the `equivalence` command, but requires a
`Reduction` instead of an `Equivalence`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalReductionAndBwdMap : CommandElab | fun stx => match stx with
| `(reduction* $eqvId / $probId $declSig := $proofStx) => do
liftTermElabM do
let (binders, lhsStx) := expandDeclSig declSig.raw
elabBindersEx binders.getArgs fun xs =>
evalReductionAux probId eqvId xs lhsStx proofStx true
| _ => throwUnsupportedSyntax | def | CvxLean.evalReductionAndBwdMap | Command | CvxLean/Command/Reduction.lean | [
"Lean",
"CvxLean.Lib.Reduction",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Simp",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Reduction",
"CvxLean.Meta.TacticBuilder",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Same as `reduction` but also adds the backward map to the environment. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
runRelaxationTactic (mvarId : MVarId) (stx : Syntax) : TermElabM Unit | runTransformationTactic TransformationGoal.Relaxation mvarId stx | def | CvxLean.runRelaxationTactic | Command | CvxLean/Command/Relaxation.lean | [
"Lean",
"CvxLean.Lib.Relaxation",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Relaxation",
"CvxLean.Meta.TacticBuilder"
] | [] | Run a transformation tactic indicating that a relaxation is expected. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
elabRelaxationProof (lhs : Expr) (rhsName : Name) (stx : Syntax) : TermElabM (Expr × Expr) | elabTransformationProof TransformationGoal.Relaxation lhs rhsName stx | def | CvxLean.elabRelaxationProof | Command | CvxLean/Command/Relaxation.lean | [
"Lean",
"CvxLean.Lib.Relaxation",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Relaxation",
"CvxLean.Meta.TacticBuilder"
] | [] | Run relaxation tactic and return both the right-hand term (`q`) and the relaxation proof, of
type `Relaxation p q`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalRelaxation : CommandElab | fun stx => match stx with
| `(relaxation $relIdStx / $probIdStx $declSig := $proofStx) => do
liftTermElabM do
let (binders, lhsStx) := expandDeclSig declSig.raw
elabBindersEx binders.getArgs fun xs => do
let D ← Meta.mkFreshTypeMVar
let R ← Meta.mkFreshTypeMVar
let lhsTy := mkApp2 (Lean.mkCo... | def | CvxLean.evalRelaxation | Command | CvxLean/Command/Relaxation.lean | [
"Lean",
"CvxLean.Lib.Relaxation",
"CvxLean.Syntax.Minimization",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Relaxation",
"CvxLean.Meta.TacticBuilder"
] | [
"Minimization"
] | Definition of the `relaxation` command. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
getProblemName (stx : Syntax) : MetaM Name | do
-- TODO: Full name with parameters?
let idStx :=
match stx with
| Syntax.ident _ _ _ _ => stx
| Syntax.node _ _ args => args.getD 0 Syntax.missing
| _ => Syntax.missing
if ¬ idStx.getId.isStr then
throwError "Invalid name for minimization problem: {idStx}."
let currNamespace ← getCurrNam... | def | CvxLean.getProblemName | Command | CvxLean/Command/Solve.lean | [
"CvxLean.Tactic.DCP.AtomLibrary.All",
"CvxLean.Command.Solve.Conic"
] | [] | Get problem name. Used to add information about the solution to the environment. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
getCanonizedProblemAndBwdMap (prob : Expr) : MetaM (MinimizationExpr × Expr) | do
let ogProb ← MinimizationExpr.fromExpr prob
let (canonProb, eqvProof) ← DCP.canonize ogProb
let backwardMap ← mkAppM ``Minimization.Equivalence.psi #[eqvProof]
return (canonProb, backwardMap) | def | CvxLean.getCanonizedProblemAndBwdMap | Command | CvxLean/Command/Solve.lean | [
"CvxLean.Tactic.DCP.AtomLibrary.All",
"CvxLean.Command.Solve.Conic"
] | [] | Call DCP and get the problem in conic form as well as `ψ`, the backward map from the
equivalence. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalSolve : CommandElab | fun stx =>
match stx with
| `(solve $probInstance) =>
liftTermElabM <| do
let probTerm ← elabTerm probInstance.raw none
let probTerm ← whnf probTerm
let probTerm ← instantiateMVars probTerm
-- NOTE: Needed to solve the "OfNat" mvar bug.
for mvarId in ← getMVars probTerm do
... | def | CvxLean.evalSolve | Command | CvxLean/Command/Solve.lean | [
"CvxLean.Tactic.DCP.AtomLibrary.All",
"CvxLean.Command.Solve.Conic"
] | [
"CvxLean.maximizeNeg"
] | The `solve` command. It works as follows:
1. Canonize optimization problem to conic form.
2. Extract problem data using `determineCoeffsFromExpr`.
3. Obtain a solution using `solutionDataFromProblemData`, which calls an external solver.
4. Store the result in the enviroment. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
solutionDataFromProblemData (minExpr : MinimizationExpr) (data : ProblemData)
(sections : ScalarAffineSections) : MetaM SolutionData | do
-- Create CBF problem.
let cbf ← CBF.ofProblemData minExpr data sections
-- Create files and run solver. The names are randomized to avoid race conditions when running the
-- tests.
let r ← IO.rand 0 (2 ^ 32 - 1)
let outputPath := s!"solver/problem{r}.sol"
let inputPath := s!"solver/problem{r}.cbf"
... | def | CvxLean.Meta.solutionDataFromProblemData | Command.Solve | CvxLean/Command/Solve/Conic.lean | [
"CvxLean.Lib.Minimization",
"CvxLean.Lib.Math.Data.Real",
"CvxLean.Lib.Math.Data.Array",
"CvxLean.Lib.Math.Data.Matrix",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.ToExpr",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Minimization",
"CvxLean.Syntax.Minimization",
"CvxLea... | [
"Sol.Parser.parse",
"mosekBinPath"
] | From a minimization expression with given problem data, proceed as follows:
1. Convert `ProblemData` to CBF format.
2. Call MOSEK by writing to a `.cbf` file.
3. Read the solution from the resulting `.sol` file.
4. Return the solution as `SolutionData`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
exprFromSolutionData (minExpr : MinimizationExpr) (solData : SolutionData) :
MetaM Expr | do
let vars ← decomposeDomainInstantiating minExpr
-- Generate solution of the correct shape.
let solPointExprArrayRaw : Array Expr :=
Array.mk <| solData.varsSols.map (fun v => floatToReal v.value)
-- Vectors and matrices as functions.
let mut solPointExprArray : Array Expr := #[]
-- TODO: This won'... | def | CvxLean.Meta.exprFromSolutionData | Command.Solve | CvxLean/Command/Solve/Conic.lean | [
"CvxLean.Lib.Minimization",
"CvxLean.Lib.Math.Data.Real",
"CvxLean.Lib.Math.Data.Array",
"CvxLean.Lib.Math.Data.Matrix",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.ToExpr",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Meta.Minimization",
"CvxLean.Syntax.Minimization",
"CvxLea... | [
"Lean.Expr.mkProd"
] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
mkFloat (n : Nat) : Expr | mkApp3 (mkConst ``OfNat.ofNat [levelZero])
(mkConst ``Float) (mkNatLit n) (mkApp (mkConst ``instOfNatFloat) (mkNatLit n)) | def | CvxLean.mkFloat | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
mkFinIdxExpr (i : Nat) (n : Nat) : MetaM Expr | do
return mkApp2 (mkConst ``Fin.ofNat) (mkNatLit n.pred) (mkNatLit i) | def | CvxLean.mkFinIdxExpr | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
mkOfNatExpr (i : Nat) (ty : Expr) : MetaM Expr | do
let ie := mkNatLit i
let inst ← synthInstance (mkApp2 (mkConst ``OfNat [levelZero]) ty ie)
return mkApp3 (mkConst ``OfNat.ofNat [levelZero]) ty ie inst | def | CvxLean.mkOfNatExpr | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
evalFloat (e : Expr) : MetaM Float | do
evalExpr Float (mkConst ``Float) e | def | CvxLean.evalFloat | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
elemsOfFintype (ty : Expr) : MetaM (Array Expr) | do
match ty with
| .app (.const ``Fin _) nExpr => do
let n : Nat ← evalExpr Nat (mkConst ``Nat) nExpr
let mut res := #[]
for i in [:n] do
res := res.push (← mkFinIdxExpr i n)
return res
| .app (.app (.const ``Sum lvl) tyl) tyr => do
let elemsl := (← elemsOfFintype tyl).map fun e =>
... | def | CvxLean.elemsOfFintype | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | Generate an array of elements of a finite type | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
evalFloatMatrix (e : Expr) : MetaM (Array (Array Float)) | do
let (tyn, tym) ←
match (← inferType e) with
| .forallE _ tyn (.forallE _ tym (.const ``Float _) _) _ =>
pure (tyn, tym)
| .app (.app (.app (.const ``Matrix _) tyn) tym) (.const ``Float _) =>
pure (tyn, tym)
| _ => throwCoeffsError "not a float matrix ({e})."
let elemsn ← elemsOfFi... | def | CvxLean.evalFloatMatrix | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
generateZerosOfShape (ty : Expr) : MetaM Expr | match ty.consumeMData with
-- 1-dimensional variables.
| .const ``Float _ =>
return (mkFloat 0)
-- Vectors.
| .forallE _ ty (.const ``Float _) _ =>
return (mkLambda `_ BinderInfo.default ty (mkFloat 0))
-- Matrices.
| .app (.app (.app (.const ``Matrix _) tyn) tym)
(.const ``Float _) => do
... | def | CvxLean.generateZerosOfShape | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
generateBasisOfShape (ty : Expr) : MetaM (Array Expr × Array Expr) | match ty.consumeMData with
-- 1-dimensional variables.
| .const ``Float _ =>
return (#[], #[mkFloat 1])
-- Vectors.
| .forallE _ tyn (.const ``Float _) _ => do
let mut res := #[]
for i in ← elemsOfFintype tyn do
let b ← withLocalDeclD `i' tyn fun i' => do
let ite ← mkAppM ``i... | def | CvxLean.generateBasisOfShape | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
unrollVectors (constraints : Expr) : MetaM (Array Expr) | do
let mut res := #[]
let cs ← decomposeConstraints constraints
for (_, c) in cs do
let c' := Expr.consumeMData c
match c' with
-- Vector zero cone.
| .app (.app (.app (.const ``Real.Vec.zeroCone _) (.app (.const ``Fin _) n)) _) e =>
let n : Nat ← evalExpr Nat (mkConst ``Nat) n
for... | def | CvxLean.unrollVectors | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [
"Real.Vec.expCone",
"Real.Vec.nonnegOrthCone",
"Real.Vec.rotatedSoCone",
"Real.Vec.soCone",
"Real.Vec.zeroCone",
"Real.expCone",
"Real.nonnegOrthCone",
"Real.rotatedSoCone",
"Real.soCone",
"Real.zeroCone"
] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
determineScalarCoeffsAux (e : Expr) (p : Expr) (fty : Expr) :
MetaM (Array Float × Float) | do
-- Constant part.
let mut constExpr := e
let zs ← generateZerosOfShape fty
constExpr := constExpr.replaceFVar p zs
let const ← evalFloat constExpr
-- Coefficients.
let (_, scalarBasis) ← generateBasisOfShape fty
let mut coeffs := #[]
for one in scalarBasis do
let mut coeff := e.replaceFVar p on... | def | CvxLean.determineScalarCoeffsAux | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
determineMatrixCoeffsAux (e : Expr) (p : Expr) (fty : Expr) :
MetaM (Array (Array (Array Float)) × Array (Array Float)) | do
-- Constant part.
let mut constExpr := e
let zs ← generateZerosOfShape fty
constExpr := constExpr.replaceFVar p zs
let const ← evalFloatMatrix constExpr
-- Coefficients.
let (_, scalarBasis) ← generateBasisOfShape fty
let mut coeffs := #[]
for one in scalarBasis do
let coeff := e.replaceFVar p ... | def | CvxLean.determineMatrixCoeffsAux | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
determineCoeffsFromExpr (minExpr : MinimizationExpr) :
MetaM (ProblemData × ScalarAffineSections) | do
let floatDomain ← realToFloat minExpr.domain
-- Coefficients for objective function.
let objectiveData ← withLambdaBody minExpr.objFun fun p objFun => do
let objFun ← realToFloat objFun
return ← determineScalarCoeffsAux objFun p floatDomain
let (constraintsData, sections) ←
withLambdaBody minEx... | def | CvxLean.determineCoeffsFromExpr | Command.Solve.Float | CvxLean/Command/Solve/Float/Coeffs.lean | [
"CvxLean.Lib.Math.Data.Fin",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Util.Debug",
"CvxLean.Syntax.Minimization",
"CvxLean.Command.Solve.Float.ProblemData",
"CvxLean.Command.Solve.Float.RealToFloatLibrary"
] | [
"Real.Matrix.PSDCone",
"Real.Matrix.nonnegOrthCone",
"Real.expCone",
"Real.nonnegOrthCone",
"Real.rotatedSoCone",
"Real.soCone",
"Real.zeroCone"
] | Given a `MinimizationExpr`, representing a problem, assuming that it is in conic form, generate
a `ProblemData`. The expression is first translated to floats, then we find the coefficients of all
the affine terms involved in the cone membership constraints by plugging in the appropriate basis
vectors and matrices and c... | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
floatToReal (f : Float) : Expr | let nnRatCastToOfScientific :=
mkApp2 (mkConst ``NNRatCast.toOfScientific ([levelZero] : List Level))
(mkConst ``Real) (mkConst ``Real.instNNRatCast)
let realOfScientific :=
mkApp2 (mkConst ``OfScientific.ofScientific ([levelZero] : List Level))
(mkConst ``Real) nnRatCastToOfScientific
match Jso... | def | CvxLean.floatToReal | Command.Solve.Float | CvxLean/Command/Solve/Float/FloatToReal.lean | [
"Mathlib.Data.Real.Basic",
"CvxLean.Lib.Math.Data.Real"
] | [] | Convert a `Float` to an `Expr` of type `Real`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
ScalarConeType
| Zero | PosOrth | Exp | Q | QR | inductive | CvxLean.ScalarConeType | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Cones admitting scalar affine constraints. The `PosOrth` type actually corresponds to the
nonnegative orthant, but at the solver level, it is usually called the positive orthant, so we use
that terminology here. Note that the only cone that admits matrix affine constraints is the PSD
cone. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
ScalarAffine | (n m : Nat)
(A : Array (Array Float))
(a : Array Float)
(b : Float) | structure | CvxLean.ScalarAffine | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Encodes the expression `⟨X, A⟩ + ∑ i, aᵢ xᵢ + b`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
MatrixAffine | (n : Nat)
(H : Array (Array (Array Float)))
(D : Array (Array Float)) | structure | CvxLean.MatrixAffine | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Encodies the expression `∑ i, xᵢ • Hᵢ + D`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
ProblemData | (objective : Option ScalarAffine)
(scalarAffineConstraints : Array (ScalarAffine × ScalarConeType))
(matrixAffineConstraints : Array MatrixAffine) | structure | CvxLean.ProblemData | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Data structure storing the floating-point coefficient of the objective function and constraints
of a problem in conic form. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
empty : ProblemData | ProblemData.mk none #[] #[] | def | CvxLean.ProblemData.empty | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
setObjective (data : ProblemData) (A : Array (Array Float)) (a : Array Float) (b : Float) :
ProblemData | { data with objective := ScalarAffine.mk A.size a.size A a b } | def | CvxLean.ProblemData.setObjective | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Set full objective function of the form `⟨X, A⟩ + ∑ i, aᵢ xᵢ + b`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
setObjectiveOnlyVector (data : ProblemData) (a : Array Float) (b : Float) : ProblemData | data.setObjective #[] a b | def | CvxLean.ProblemData.setObjectiveOnlyVector | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Same as `setObjective` if the objective is of the form `∑ i, aᵢxᵢ + b`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
setObjectiveOnlyMatrix (data : ProblemData) (A : Array (Array Float)) (b : Float) :
ProblemData | data.setObjective A #[] b | def | CvxLean.ProblemData.setObjectiveOnlyMatrix | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Same as `setObjective` if the objective is of the form `⟨A, X⟩ + b`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addScalarAffineConstraint (data : ProblemData) (A : Array (Array Float)) (a : Array Float)
(b : Float) (sct : ScalarConeType) : ProblemData | let constraint := ScalarAffine.mk A.size a.size A a b
{ data with scalarAffineConstraints :=
data.scalarAffineConstraints.push ⟨constraint, sct⟩ } | def | CvxLean.ProblemData.addScalarAffineConstraint | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Add a scalar affine constraint of the form ``⟨X, A⟩ + ∑ i, aᵢ xᵢ + b ∈ 𝒦`, where `𝒦` is a cone
of type `sct`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addScalarAffineConstraintOnlyVector (data : ProblemData) (a : Array Float) (b : Float)
(sct : ScalarConeType) : ProblemData | data.addScalarAffineConstraint #[] a b sct | def | CvxLean.ProblemData.addScalarAffineConstraintOnlyVector | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Same as `addScalarAffineConstraint` if the constraint is of the form `∑ i, aᵢ xᵢ + b ∈ 𝒦`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addZeroConstraint (data : ProblemData) (a : Array Float) (b : Float) : ProblemData | data.addScalarAffineConstraintOnlyVector a b ScalarConeType.Zero | def | CvxLean.ProblemData.addZeroConstraint | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Add zero cone constraint `∑ i, aᵢxᵢ + b ∈ 0` to problem data. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addExpConstraint (data : ProblemData) (a : Array Float) (b : Float) : ProblemData | data.addScalarAffineConstraintOnlyVector a b ScalarConeType.Exp | def | CvxLean.ProblemData.addExpConstraint | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Add exponential cone constraint `∑ i, aᵢxᵢ + b ∈ 𝒦ₑ` to problem data. Note that the
second-order cone is `3`-dimensional, so to capture `(x, y, z) ∈ 𝒦ₑ` we do `x ∈ 𝒦ₑ`, `y ∈ 𝒦ₑ`, and
`z ∈ 𝒦ₑ` consecutively. We keep track of how to group consecutive constraints in
`CvxLean/Command/Solve/Float/Coeffs.lean`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addPosOrthConstraint (data : ProblemData) (a : Array Float) (b : Float) : ProblemData | data.addScalarAffineConstraintOnlyVector a b ScalarConeType.PosOrth | def | CvxLean.ProblemData.addPosOrthConstraint | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Add positive orthant cone constraint `∑ i, aᵢxᵢ + b ∈ ℝ₊` to problem data. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addSOConstraint (data : ProblemData) (a : Array Float) (b : Float) : ProblemData | data.addScalarAffineConstraintOnlyVector a b ScalarConeType.Q | def | CvxLean.ProblemData.addSOConstraint | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Add second-order cone constraint `∑ i, aᵢxᵢ + b ∈ 𝒬` to problem data. Note that the second-order
cone is `n+1`-dimensional. The same remark on grouping constraints in `addExpConstraint` applies. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addRotatedSOConstraint (data : ProblemData) (a : Array Float) (b : Float) : ProblemData | data.addScalarAffineConstraintOnlyVector a b ScalarConeType.QR | def | CvxLean.ProblemData.addRotatedSOConstraint | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
addMatrixAffineConstraint (data : ProblemData) (H : Array (Array (Array Float)))
(D : Array (Array Float)) : ProblemData | let constraint := MatrixAffine.mk D.size H D
{ data with matrixAffineConstraints := data.matrixAffineConstraints.push constraint } | def | CvxLean.ProblemData.addMatrixAffineConstraint | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Add a matrix affine constraint `∑ i, xᵢ • Hᵢ + D ∈ 𝒮₊ⁿ` to problem data. The only matrix cone
we consider is the PSD cone. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
ScalarAffineSections : Type | Array Nat | def | CvxLean.ScalarAffineSections | Command.Solve.Float | CvxLean/Command/Solve/Float/ProblemData.lean | [] | [] | Indices to group constraints together and tag cones with the correct dimension when translating
problem data to solver formats. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
realToFloat (e : Expr) : MetaM Expr | do
let e ← e.removeMData
let discrTree ← getRealToFloatDiscrTree
let translations ← discrTree.getMatch e
for translation in translations do
let (mvars, _, pattern) ← lambdaMetaTelescope translation.real
if ← isDefEq pattern e then
-- TODO: Search for conditions.
let args ← mvars.mapM instant... | def | CvxLean.realToFloat | Command.Solve.Float | CvxLean/Command/Solve/Float/RealToFloatCmd.lean | [
"CvxLean.Lib.Math.Data.Real",
"CvxLean.Lib.Math.Data.Vec",
"CvxLean.Lib.Math.Data.Matrix",
"CvxLean.Lib.Math.CovarianceEstimation",
"CvxLean.Lib.Math.LogDet",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Minimization",
"CvxLean.Syntax.OptimizationPara... | [
"getOptimizationParamExpr",
"isOptimizationParam"
] | Traverse expression recursively and if a match is found in the real-to-float library return the
float version. The "correctness" of this function depends on the translations defined in the
library. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
elabAddRealToFloatCommand : CommandElab | | `(add_real_to_float : $real := $float) =>
liftTermElabM do
let real ← elabTermAndSynthesize real.raw none
let float ← elabTermAndSynthesize float.raw none
addRealToFloatData { real := real, float := float }
| _ => throwUnsupportedSyntax | def | CvxLean.elabAddRealToFloatCommand | Command.Solve.Float | CvxLean/Command/Solve/Float/RealToFloatCmd.lean | [
"CvxLean.Lib.Math.Data.Real",
"CvxLean.Lib.Math.Data.Vec",
"CvxLean.Lib.Math.Data.Matrix",
"CvxLean.Lib.Math.CovarianceEstimation",
"CvxLean.Lib.Math.LogDet",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Minimization",
"CvxLean.Syntax.OptimizationPara... | [] | The `add_real_to_float` command, which simply adds the user-defined expressions to the
environment extension. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
elabRealToFloatCommand : CommandElab | | `(#real_to_float $stx) =>
liftTermElabM do
let e ← elabTermAndSynthesize stx.raw none
let res ← realToFloat e
check res
logInfo m!"{res}"
if Expr.isConstOf (← inferType res) ``Float then
let res ← Meta.evalExpr Float (mkConst ``Float) res
logInfo m!"{res}"
| _ => throwUnsupportedSynt... | def | CvxLean.elabRealToFloatCommand | Command.Solve.Float | CvxLean/Command/Solve/Float/RealToFloatCmd.lean | [
"CvxLean.Lib.Math.Data.Real",
"CvxLean.Lib.Math.Data.Vec",
"CvxLean.Lib.Math.Data.Matrix",
"CvxLean.Lib.Math.CovarianceEstimation",
"CvxLean.Lib.Math.LogDet",
"CvxLean.Lib.Cones.All",
"CvxLean.Meta.Util.Expr",
"CvxLean.Meta.Util.Error",
"CvxLean.Meta.Minimization",
"CvxLean.Syntax.OptimizationPara... | [] | Transform the given expression to its float version and log the result. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
RealToFloatData where
real : Expr
float : Expr
deriving BEq, Inhabited | structure | CvxLean.RealToFloatData | Command.Solve.Float | CvxLean/Command/Solve/Float/RealToFloatExt.lean | [
"CvxLean.Tactic.DCP.DiscrTree"
] | [] | Data structure to store the real-to-float translation. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
RealToFloatExtension | PersistentEnvExtension
(Array Key × RealToFloatData) (Array Key × RealToFloatData) (DiscrTree RealToFloatData)
deriving Inhabited | def | CvxLean.RealToFloatExtension | Command.Solve.Float | CvxLean/Command/Solve/Float/RealToFloatExt.lean | [
"CvxLean.Tactic.DCP.DiscrTree"
] | [] | Type of persistent environment extension for real-to-float. We use a discrimination tree. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
addRealToFloatData (data : RealToFloatData) : MetaM Unit | do
let (_, _, expr) ← lambdaMetaTelescope data.real
let keys ← DiscrTree.mkPath expr
setEnv <| realToFloatExtension.addEntry (← getEnv) (keys, data) | def | CvxLean.addRealToFloatData | Command.Solve.Float | CvxLean/Command/Solve/Float/RealToFloatExt.lean | [
"CvxLean.Tactic.DCP.DiscrTree"
] | [] | Add a new real-to-float translation to the environment. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
getRealToFloatDiscrTree : MetaM (DiscrTree RealToFloatData) | do
return realToFloatExtension.getState (← getEnv) | def | CvxLean.getRealToFloatDiscrTree | Command.Solve.Float | CvxLean/Command/Solve/Float/RealToFloatExt.lean | [
"CvxLean.Tactic.DCP.DiscrTree"
] | [] | Get the discrimination tree of all real-to-float translations. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
SimpleVarSol where
name : String
value : Float | structure | CvxLean.SimpleVarSol | Command.Solve.Float | CvxLean/Command/Solve/Float/SolutionData.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | ||
SimpleMatrixVarSol where
name : String
I : Nat
J : Nat
value : Option Float | structure | CvxLean.SimpleMatrixVarSol | Command.Solve.Float | CvxLean/Command/Solve/Float/SolutionData.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | ||
SolutionData where
status : String
varsSols : List SimpleVarSol
matrixVarsSols : List SimpleMatrixVarSol | structure | CvxLean.SolutionData | Command.Solve.Float | CvxLean/Command/Solve/Float/SolutionData.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | ||
ObjSense
| MAX | MIN | inductive | CBF.ObjSense | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Objective sense. Either a maximization or minimization problem. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
ConeType
| F | LPos | LNeg | LEq | Q | QR | EXP
deriving DecidableEq | inductive | CBF.ConeType | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Cone type: free, positive orthant, negative orthant, fixpoint zero (for equality), quadratic,
quadratic rotated or exponential. The quadratic cone is called second-order in other parts of the
project. Note that this definition is independent from the cone types in
`CvxLean/Command/Solve/Float/ProblemData.lean`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
Cone where
type : ConeType
dim : Nat | structure | CBF.Cone | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Cone type and dimension. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
ConeProduct where
n : Nat
k : Nat
cones : List Cone | structure | CBF.ConeProduct | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Holds the total dimension (`n`), number of cones (`k`), and a list of cones
(`[t₁, d₁], ..., [tₖ, dₖ]`). We must have that `∑dᵢ = n`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
empty : ConeProduct | ConeProduct.mk 0 0 [] | def | CBF.ConeProduct.empty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
isEmpty (cp : ConeProduct) : Prop | cp.k = 0 | def | CBF.ConeProduct.isEmpty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
addCone (cp : ConeProduct) (c : Cone) : ConeProduct | ConeProduct.mk (cp.n + c.dim) (cp.k + 1) (cp.cones.concat c) | def | CBF.ConeProduct.addCone | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
DimensionList where
n : Nat
dimensions : List Nat | structure | CBF.DimensionList | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Number of dimensions and list of dimensions. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
empty : DimensionList | DimensionList.mk 0 [] | def | CBF.DimensionList.empty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
isEmpty (dl : DimensionList) : Prop | dl.n = 0 | def | CBF.DimensionList.isEmpty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
addDimension (dl : DimensionList) (d : Nat) : DimensionList | DimensionList.mk (dl.n + 1) (dl.dimensions.concat d) | def | CBF.DimensionList.addDimension | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
EncodedValue where
value : Option Float | structure | CBF.EncodedValue | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Simply a float. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
empty : EncodedValue | EncodedValue.mk none | def | CBF.EncodedValue.empty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
isEmpty (ev : EncodedValue) : Prop | ev.value.isNone | def | CBF.EncodedValue.isEmpty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
EncodedVectorEntry where
i : Nat
value : Float | structure | CBF.EncodedVectorEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Represents the value `aᵢ`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromIndexAndValue (i : Nat) (v : Float) : EncodedVectorEntry | EncodedVectorEntry.mk i v | def | CBF.EncodedVectorEntry.fromIndexAndValue | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
EncodedVector where
n : Nat
values : List EncodedVectorEntry | structure | CBF.EncodedVector | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Represents the vector `a = (aᵢ)` where `n` entries are non-zero. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
empty : EncodedVector | EncodedVector.mk 0 [] | def | CBF.EncodedVector.empty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
isEmpty (ev : EncodedVector) : Prop | ev.n = 0 | def | CBF.EncodedVector.isEmpty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
addEntry (ev : EncodedVector) (eve : EncodedVectorEntry) : EncodedVector | if eve.value < 0 || eve.value > 0 then
EncodedVector.mk (ev.n + 1) (ev.values.concat eve)
else
ev | def | CBF.EncodedVector.addEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
stack (ev1 ev2 : EncodedVector) : EncodedVector | EncodedVector.mk (ev1.n + ev2.n) (ev1.values ++ ev2.values) | def | CBF.EncodedVector.stack | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromIndexAndValue (i : Nat) (v : Float) : EncodedVector | if v > 0 || v < 0 then
EncodedVector.mk 1 [EncodedVectorEntry.fromIndexAndValue i v]
else
EncodedVector.mk 0 [] | def | CBF.EncodedVector.fromIndexAndValue | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromArray (a : Array Float) : EncodedVector | Id.run <| do
let mut ev := empty
for (i, ai) in a.data.enum do
if ai > 0 || ai < 0 then
ev := ev.addEntry (EncodedVectorEntry.mk i ai)
return ev | def | CBF.EncodedVector.fromArray | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
EncodedMatrixEntry where
i : Nat
j : Nat
value : Float | structure | CBF.EncodedMatrixEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Represents the vlaue `aᵢⱼ`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromIndexAndEncodedVectorEntry (i : Nat) (eve : EncodedVectorEntry) : EncodedMatrixEntry | EncodedMatrixEntry.mk i eve.i eve.value | def | CBF.EncodedMatrixEntry.fromIndexAndEncodedVectorEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
EncodedMatrix where
n : Nat
values : List EncodedMatrixEntry | structure | CBF.EncodedMatrix | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Represents the matrix `A = (aᵢⱼ)` where `n` entries are non-zero. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
empty : EncodedMatrix | EncodedMatrix.mk 0 [] | def | CBF.EncodedMatrix.empty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
isEmpty (em : EncodedMatrix) : Prop | em.n = 0 | def | CBF.EncodedMatrix.isEmpty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
addEntry (em : EncodedMatrix) (eme : EncodedMatrixEntry) : EncodedMatrix | if eme.value < 0 || eme.value > 0 then
EncodedMatrix.mk (em.n + 1) (em.values.concat eme)
else
em | def | CBF.EncodedMatrix.addEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
stack (em1 em2 : EncodedMatrix) : EncodedMatrix | EncodedMatrix.mk (em1.n + em2.n) (em1.values ++ em2.values) | def | CBF.EncodedMatrix.stack | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromIndexAndEncodedVector (i : Nat) (ev : EncodedVector) : EncodedMatrix | Id.run <| do
let mut em := empty
for eve in ev.values do
let eme := EncodedMatrixEntry.fromIndexAndEncodedVectorEntry i eve
em := em.addEntry eme
em | def | CBF.EncodedMatrix.fromIndexAndEncodedVector | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromArray (A : Array (Array Float)) : EncodedMatrix | Id.run <| do
let mut em := empty
for (i, ai) in A.data.enum do
for (j, aij) in ai.data.enum do
if i >= j && (aij > 0 || aij < 0) then
em := em.addEntry (EncodedMatrixEntry.mk i j aij)
return em | def | CBF.EncodedMatrix.fromArray | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
EncodedMatrixListEntry where
i : Nat
j : Nat
k : Nat
value : Float | structure | CBF.EncodedMatrixListEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Represents the entry `Aⱼₖ` in the ith matrix in the list. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromIndexAndEncodedMatrixEntry (i : Nat) (eme : EncodedMatrixEntry) : EncodedMatrixListEntry | EncodedMatrixListEntry.mk i eme.i eme.j eme.value | def | CBF.EncodedMatrixListEntry.fromIndexAndEncodedMatrixEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
EncodedMatrixList where
n : Nat
values : List EncodedMatrixListEntry | structure | CBF.EncodedMatrixList | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | Represents `L = [A₁, ...]` where the total number of non-zero entries of all the matrices `Aᵢ`
is `n`. | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
empty : EncodedMatrixList | EncodedMatrixList.mk 0 [] | def | CBF.EncodedMatrixList.empty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
isEmpty (eml : EncodedMatrixList) : Prop | eml.n = 0 | def | CBF.EncodedMatrixList.isEmpty | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
addEntry (eml : EncodedMatrixList) (emle : EncodedMatrixListEntry) : EncodedMatrixList | if emle.value > 0 || emle.value < 0 then
EncodedMatrixList.mk (eml.n + 1) (eml.values.concat emle)
else
eml | def | CBF.EncodedMatrixList.addEntry | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
stack (eml1 eml2 : EncodedMatrixList) : EncodedMatrixList | EncodedMatrixList.mk (eml1.n + eml2.n) (eml1.values ++ eml2.values) | def | CBF.EncodedMatrixList.stack | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 | |
fromIndexAndEncodedMatrix (i : Nat) (em : EncodedMatrix) : EncodedMatrixList | Id.run <| do
let mut eml := empty
for eme in em.values do
let emle := EncodedMatrixListEntry.fromIndexAndEncodedMatrixEntry i eme
eml := eml.addEntry emle
eml | def | CBF.EncodedMatrixList.fromIndexAndEncodedMatrix | Command.Solve.Mosek | CvxLean/Command/Solve/Mosek/CBF.lean | [] | [] | https://github.com/verified-optimization/CvxLean | c62c2f292c6420f31a12e738ebebdfed50f6f840 |
Structured dataset from CvxLean — Convex optimization.
c62c2f292c6420f31a12e738ebebdfed50f6f840| Column | Type | Description |
|---|---|---|
| statement | string | Declaration signature/claim with the leading keyword removed (verbatim slice); the full declaration minus its proof |
| proof | string | Verbatim proof/body, empty if the declaration has none |
| type | string | Declaration keyword |
| symbolic_name | string | Declaration identifier |
| library | string | Sub-library |
| filename | string | Repository-relative source path |
| imports | list[string] | File-level Require/Import modules |
| deps | list[string] | Intra-corpus identifiers referenced |
| docstring | string | Preceding documentation comment, empty if absent |
| source_url | string | Upstream repository |
| commit | string | Upstream commit extracted |
| Type | Count |
|---|---|
| def | 947 |
| lemma | 141 |
| structure | 48 |
| abbrev | 42 |
| inductive | 18 |
| macro | 10 |
| instance | 10 |
| opaque | 10 |
| theorem | 9 |
| elab | 6 |
| class | 1 |
compileCargo (name : String) (manifestFile : FilePath) (cargo : FilePath := "cargo")
(env : Array (String × Option String)) : LogIO Unit
do
logInfo s!"Creating {name}"
proc {
env := env
cmd := cargo.toString
args := #["build", "--release", "--manifest-path", manifestFile.toString]
}
compileCargo | lakefile.leanEach declaration is split into a statement (signature/claim) and a proof (body) that are disjoint
and together form the complete declaration, for proof modeling, autoformalization, retrieval, and
dependency analysis via deps.
@misc{lean4_cvxlean_dataset,
title = {Lean4-CvxLean},
author = {Norton, Charles},
year = {2026},
note = {Extracted from https://github.com/verified-optimization/CvxLean, commit c62c2f292c64},
url = {https://huggingface.co/datasets/phanerozoic/Lean4-CvxLean}
}