Algo.prim.prim.Facts definitions
DefinitionAlgo_prim_prim_FactsDefinitions and required structural lemmas from Algo.prim.prim.Facts. Source declarations are retained by compiler-reported ranges; imports are redirected to the corresponding definition bundles. This bundle contains no theorem stubs.
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.
import Definitions.Def_Algo_prim_prim_Generated
set_option autoImplicit true
set_option backward.isDefEq.respectTransparency false
set_option backward.defeqAttrib.useBackward true
-- Generated by Algo2Lean 0.1.4 https://github.com/lunjiah/algo2lean
-- Optional proof certificate; execution remains the generated Step relation.
namespace «Algo».«prim».«prim»
open Algo2LeanCore _root_.Algo2LeanGenerated
/-- Optional determinism evidence for the separately supplied interface code. -/
structure DependencyFacts (dependencies : Dependencies) where
«PriorityQueue» : InterfaceFacts dependencies.«PriorityQueue».toInterfaceCode
namespace Algo2LeanGenerated
variable (dependencies : Dependencies)
local notation "Frame" => Frame dependencies
local notation "Stack" => Stack dependencies
local notation "Configuration" => Configuration dependencies
local notation "Transcript" => Transcript dependencies
local notation "Step" => Step dependencies
local notation "is__a2l_import_1_PriorityQueue" => is__a2l_import_1_PriorityQueue dependencies
private def next_scan_edges (h : Heap) (s : State_scan_edges) (stack : Stack) : Nat → Configuration
| 1 => (Algo2LeanCore.resumeConfig h (Result.fn_scan_edges (s.t8)) stack)
| 2 => (.active h (Frame.fn_scan_edges 1 { s with t8 := () }) stack)
| 3 => if s.t9 then (.active h (Frame.fn_scan_edges 21 s) stack) else (.active h (Frame.fn_scan_edges 2 s) stack)
| 4 => (.active h (Frame.fn_scan_edges 3 { s with t9 := (decide ((s.v5 ≠ none))) }) stack)
| 5 => (.active h (Frame.fn_scan_edges 4 { s with v5 := ((field__a2l_import_0_Edge_next h ((s.v5).getD 0)).getD none) }) stack)
| 6 => (.active (h.tick "improvements" 1) (Frame.fn_scan_edges 5 s) stack)
| 7 => (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_push_or_decrease ((s.t13), s.t14, s.t15)) [] (fun value => match value with | .fn_PriorityQueue_push_or_decrease result => (Frame.fn_scan_edges 6 { s with t12 := result }) | _ => .invalid)) stack)
| 8 => (.active h (Frame.fn_scan_edges 7 { s with t15 := s.v7 }) stack)
| 9 => (.active h (Frame.fn_scan_edges 8 { s with t14 := s.v6 }) stack)
| 10 => (.active h (Frame.fn_scan_edges 9 { s with t13 := s.t13 }) stack)
| 11 => (.active h (Frame.fn_scan_edges 10 { s with t13 := s.v0 }) stack)
| 12 => (.active (h.tick "queue_updates" 1) (Frame.fn_scan_edges 11 s) stack)
| 13 => (.active (h.write s.v2 s.v6 s.v4) (Frame.fn_scan_edges 12 s) stack)
| 14 => (.active (h.write s.v1 s.v6 s.v7) (Frame.fn_scan_edges 13 s) stack)
| 15 => if s.t11 then (.active h (Frame.fn_scan_edges 14 s) stack) else (.active h (Frame.fn_scan_edges 5 s) stack)
| 16 => (.active h (Frame.fn_scan_edges 15 { s with t11 := ((decide (((h.read s.v2 s.v6) < (0 : Int)))) || (decide ((s.v7 < (h.read s.v1 s.v6))))) }) stack)
| 17 => (.active h (Frame.fn_scan_edges 16 { s with v7 := ((field__a2l_import_0_Edge_weight h ((s.v5).getD 0)).getD 0) }) stack)
| 18 => if s.t10 then (.active h (Frame.fn_scan_edges 17 s) stack) else (.active h (Frame.fn_scan_edges 5 s) stack)
| 19 => (.active h (Frame.fn_scan_edges 18 { s with t10 := (decide (((h.read s.v3 s.v6) = (0 : Int)))) }) stack)
| 20 => (.active h (Frame.fn_scan_edges 19 { s with v6 := ((field__a2l_import_0_Edge_target h ((s.v5).getD 0)).getD 0) }) stack)
| 21 => (.active (h.tick "edges" 1) (Frame.fn_scan_edges 20 s) stack)
| pc => .active h (.fn_scan_edges pc s) stack
private def next_prim (h : Heap) (s : State_prim) (stack : Stack) : Nat → Configuration
| 1 => (Algo2LeanCore.resumeConfig h (Result.fn_prim (s.t7)) stack)
| 2 => (.active h (Frame.fn_prim 1 { s with t7 := s.v4 }) stack)
| 3 => if s.t8 then (.active h (Frame.fn_prim 22 s) stack) else (.active h (Frame.fn_prim 2 s) stack)
| 4 => (.active h (Frame.fn_prim 3 { s with t8 := (!s.t9) }) stack)
| 5 => (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_is_empty (s.t10)) [] (fun value => match value with | .fn_PriorityQueue_is_empty result => (Frame.fn_prim 4 { s with t9 := result }) | _ => .invalid)) stack)
| 6 => (.active h (Frame.fn_prim 5 { s with t10 := s.t10 }) stack)
| 7 => (.active h (Frame.fn_prim 6 { s with t10 := s.v2 }) stack)
| 8 => (.active (h.tick "queue_empty_checks" 1) (Frame.fn_prim 7 s) stack)
| 9 => (.active h (Frame.fn_scan_edges 4 ({ v0 := s.t12, v1 := s.t13, v2 := s.t14, v3 := s.t15, v4 := s.t16, v5 := s.t17 } : State_scan_edges)) ((fun value => match value with | .fn_scan_edges result => (Frame.fn_prim 8 { s with t11 := result }) | _ => .invalid) :: stack))
| 10 => (.active h (Frame.fn_prim 9 { s with t17 := ((seq__a2l_import_0_Edge_optional.get h ((field__a2l_import_0_Graph_heads h (s.v0)).getD 0) s.v6).getD none) }) stack)
| 11 => (.active h (Frame.fn_prim 10 { s with t16 := s.v6 }) stack)
| 12 => (.active h (Frame.fn_prim 11 { s with t15 := s.v5 }) stack)
| 13 => (.active h (Frame.fn_prim 12 { s with t14 := s.v4 }) stack)
| 14 => (.active h (Frame.fn_prim 13 { s with t13 := s.v3 }) stack)
| 15 => (.active h (Frame.fn_prim 14 { s with t12 := s.v2 }) stack)
| 16 => (.active (h.tick "settlements" 1) (Frame.fn_prim 15 s) stack)
| 17 => (.active (h.write s.v5 s.v6 (1 : Int)) (Frame.fn_prim 16 s) stack)
| 18 => (.active h (Frame.fn_prim 17 { s with v6 := s.t18 }) stack)
| 19 => (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_pop_min (s.t19)) [] (fun value => match value with | .fn_PriorityQueue_pop_min result => (Frame.fn_prim 18 { s with t18 := result }) | _ => .invalid)) stack)
| 20 => (.active h (Frame.fn_prim 19 { s with t19 := s.t19 }) stack)
| 21 => (.active h (Frame.fn_prim 20 { s with t19 := s.v2 }) stack)
| 22 => (.active (h.tick "queue_pops" 1) (Frame.fn_prim 21 s) stack)
| 23 => (.active (h.tick "queue_empty_checks" 1) (Frame.fn_prim 7 s) stack)
| 24 => (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_push_or_decrease ((s.t21), s.t22, s.t23)) [] (fun value => match value with | .fn_PriorityQueue_push_or_decrease result => (Frame.fn_prim 23 { s with t20 := result }) | _ => .invalid)) stack)
| 25 => (.active h (Frame.fn_prim 24 { s with t23 := (0 : Int) }) stack)
| 26 => (.active h (Frame.fn_prim 25 { s with t22 := s.v1 }) stack)
| 27 => (.active h (Frame.fn_prim 26 { s with t21 := s.t21 }) stack)
| 28 => (.active h (Frame.fn_prim 27 { s with t21 := s.v2 }) stack)
| 29 => (.active (h.tick "queue_updates" 1) (Frame.fn_prim 28 s) stack)
| 30 => (.active (h.write s.v3 s.v1 (0 : Int)) (Frame.fn_prim 29 s) stack)
| pc => .active h (.fn_prim pc s) stack
/-- A total projection used only to certify uniqueness of actual transitions. -/
def next (facts : DependencyFacts dependencies) : Configuration → Configuration
| .done h result => .done h result
| .active h frame stack => match frame with
| .invalid => .active h .invalid stack
| .fn_scan_edges pc s => next_scan_edges dependencies h s stack pc
| .fn_prim pc s => next_prim dependencies h s stack pc
| .interface_PriorityQueue frame inner resume =>
ModuleCall.config Frame.interface_PriorityQueue resume stack (facts.«PriorityQueue».next (.active h frame inner))
/-- Each generated rule agrees with the projection; guards remain in Step. -/
theorem step_next (facts : DependencyFacts dependencies) {before after : Configuration} (transition : Step before after) :
next dependencies facts before = after := by
cases transition with
| scan_edges_pc1 h s stack => rfl
| scan_edges_pc2 h s stack => rfl
| scan_edges_pc3_true h s stack condition => simp [next, next_scan_edges, condition]
| scan_edges_pc3_false h s stack condition => simp [next, next_scan_edges, condition]
| scan_edges_pc4 h s stack => rfl
| scan_edges_pc5 h s stack defined => rfl
| scan_edges_pc6 h s stack => rfl
| scan_edges_pc7 h s stack => rfl
| scan_edges_pc8 h s stack => rfl
| scan_edges_pc9 h s stack => rfl
| scan_edges_pc10 h s stack defined => rfl
| scan_edges_pc11 h s stack => rfl
| scan_edges_pc12 h s stack => rfl
| scan_edges_pc13 h s stack defined => rfl
| scan_edges_pc14 h s stack defined => rfl
| scan_edges_pc15_true h s stack condition => simp [next, next_scan_edges, condition]
| scan_edges_pc15_false h s stack condition => simp [next, next_scan_edges, condition]
| scan_edges_pc16 h s stack defined => rfl
| scan_edges_pc17 h s stack defined => rfl
| scan_edges_pc18_true h s stack condition => simp [next, next_scan_edges, condition]
| scan_edges_pc18_false h s stack condition => simp [next, next_scan_edges, condition]
| scan_edges_pc19 h s stack defined => rfl
| scan_edges_pc20 h s stack defined => rfl
| scan_edges_pc21 h s stack => rfl
| prim_pc1 h s stack defined => rfl
| prim_pc2 h s stack => rfl
| prim_pc3_true h s stack condition => simp [next, next_prim, condition]
| prim_pc3_false h s stack condition => simp [next, next_prim, condition]
| prim_pc4 h s stack => rfl
| prim_pc5 h s stack => rfl
| prim_pc6 h s stack defined => rfl
| prim_pc7 h s stack => rfl
| prim_pc8 h s stack => rfl
| prim_pc9 h s stack => rfl
| prim_pc10 h s stack defined => rfl
| prim_pc11 h s stack => rfl
| prim_pc12 h s stack => rfl
| prim_pc13 h s stack => rfl
| prim_pc14 h s stack => rfl
| prim_pc15 h s stack => rfl
| prim_pc16 h s stack => rfl
| prim_pc17 h s stack defined => rfl
| prim_pc18 h s stack => rfl
| prim_pc19 h s stack => rfl
| prim_pc20 h s stack defined => rfl
| prim_pc21 h s stack => rfl
| prim_pc22 h s stack => rfl
| prim_pc23 h s stack => rfl
| prim_pc24 h s stack => rfl
| prim_pc25 h s stack => rfl
| prim_pc26 h s stack => rfl
| prim_pc27 h s stack defined => rfl
| prim_pc28 h s stack => rfl
| prim_pc29 h s stack => rfl
| prim_pc30 h s stack defined => rfl
| interface_PriorityQueue h frame inner resume caller after transition =>
exact congrArg (ModuleCall.config Frame.interface_PriorityQueue resume caller) (facts.«PriorityQueue».step_next transition)
/-- Imported determinism composes without reopening imported transition rules. -/
theorem deterministic (facts : DependencyFacts dependencies) : Deterministic Step := by
intro before left right first second
exact (step_next dependencies facts first).symm.trans (step_next dependencies facts second)
end Algo2LeanGenerated
end «Algo».«prim».«prim»
namespace Algo.«prim».«prim»
open Algo2LeanCore _root_.Algo2LeanGenerated Algo2LeanGenerated
variable (dependencies : Dependencies)
local notation "Frame" => Frame dependencies
local notation "Stack" => Stack dependencies
local notation "Configuration" => Configuration dependencies
local notation "Transcript" => Transcript dependencies
local notation "Step" => Step dependencies
local notation "is__a2l_import_1_PriorityQueue" => is__a2l_import_1_PriorityQueue dependencies
variable {dependencies}
theorem scan_edges.Run.eq_of_call (facts : DependencyFacts dependencies) {before after expectedHeap input output expected}
(run : _root_.Algo.«prim».«prim».scan_edges.Run dependencies before input after output)
(call : _root_.Algo.«prim».«prim».scan_edges.Call dependencies before input expectedHeap expected) :
after = expectedHeap ∧ output = expected := by
have same := Reaches.eq_of_terminal (step := Step) (deterministic dependencies facts)
run.2 call.2.root (terminal dependencies _ _) (terminal dependencies _ _)
cases same
exact ⟨rfl, rfl⟩
theorem prim.Run.eq_of_call (facts : DependencyFacts dependencies) {before after expectedHeap input output expected}
(run : _root_.Algo.«prim».«prim».prim.Run dependencies before input after output)
(call : _root_.Algo.«prim».«prim».prim.Call dependencies before input expectedHeap expected) :
after = expectedHeap ∧ output = expected := by
have same := Reaches.eq_of_terminal (step := Step) (deterministic dependencies facts)
run.2 call.2.root (terminal dependencies _ _) (terminal dependencies _ _)
cases same
exact ⟨rfl, rfl⟩
end Algo.«prim».«prim»