Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Algo.prim.scan.Analysis definitions

Definition
Algo_prim_scan_Analysis

by lunjia · Oct 11, 2026 · Mathlib 0df444a (Lean v4.33.1)

algo2leanalgorithmsclrsdata-structuresrunning-timetextbook

Definitions and required structural lemmas from Algo.prim.scan.Analysis. Source declarations are retained by compiler-reported ranges; imports are redirected to the corresponding definition bundles. This bundle contains no theorem stubs.

<!-- algo2lean-provenance-v0.1.4 -->

Algo2Lean provenance and reproduction. These definitions target Algo2Lean v0.1.4, using the compiler source at public commit 0f79d5e4242e6477531c9ee4410409f5b1c92f76, and Lean 4.33.1. The versioned compiler location is Algo2Lean v0.1.4. Compile all supplied .algo files and imports to reproduce the raw generated definitions. Release publication and exact website parity require their separately recorded checks; this metadata alone does not assert them. Prove2Me imports and declaration packaging are mechanically adapted, with original hashes, compiler-reported source ranges, and adaptations recorded in transplant provenance. Exact reproduction does not prove the compiler correct.

Definition code
import Definitions.Def_Algo_prim_support_Analysis
import Definitions.Def_Algo_prim_math_Analysis

set_option autoImplicit true
set_option backward.isDefEq.respectTransparency false
set_option backward.defeqAttrib.useBackward true



set_option backward.isDefEq.respectTransparency false
set_option backward.defeqAttrib.useBackward true

/-! Prim's adjacency scan preserves queue contents, parent pointers, and keys.
Every queue update uses only the imported operation contract. -/
namespace PrimAnalysis
open Algo2LeanCore Algo2LeanGenerated Algo2Lean.Dijkstra
open Algo2Lean.Prim
open Algo.prim.graph.Algo2LeanGenerated
open Algo.prim.prim Algo.dijkstra.priority_queue
open PriorityQueueAnalysis PrimGraph PrimControl

variable {dependencies : Dependencies} {client : Client}
variable (model : Model dependencies.PriorityQueue client.queue client.protection)
variable (contracts : Contracts model reservedClocks)
include contracts

structure EdgeAdvanced (before after : QueueState model)
    (vertex target weight : Int) (edge : Ref_Edge) (next : Option Ref_Edge) : Prop where
  storage : Storage model after
  matching : QueueMatches model after
  selected : after.heap.read client.selected = before.heap.read client.selected
  scan : KeyScan (fun v => before.heap.read client.selected v ≠ 0) vertex
    [(target,weight)] (before.heap.read client.key) (before.heap.read client.parent)
    (after.heap.read client.key) (after.heap.read client.parent)
  costs : CostBounds model before after 0 1
  frame : GraphFrame before.heap after.heap client.graph client.heads
  execution : ∀ finalHeap,
    ScanLoop dependencies after.heap client.queue client.key client.parent client.selected vertex next finalHeap →
    ScanLoop dependencies before.heap client.queue client.key client.parent client.selected vertex (some edge) finalHeap

structure AdjacencyScanned (before after : QueueState model)
    (vertex : Int) (head : Option Ref_Edge) (edges : List (Int × Int)) : Prop where
  storage : Storage model after
  matching : QueueMatches model after
  selected : after.heap.read client.selected = before.heap.read client.selected
  scan : KeyScan (fun v => before.heap.read client.selected v ≠ 0) vertex edges
    (before.heap.read client.key) (before.heap.read client.parent)
    (after.heap.read client.key) (after.heap.read client.parent)
  costs : CostBounds model before after 0 edges.length
  frame : GraphFrame before.heap after.heap client.graph client.heads
  execution : ScanLoop dependencies before.heap client.queue client.key client.parent client.selected vertex head after.heap





end PrimAnalysis
Source
https://github.com/lunjiah/algo2lean/blob/d832a5655d7cac6d032e728a4798128147b27922/examples/analysis/prim/scan.lean

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me