Algo.dijkstra.dijkstra.Generated definitions
DefinitionAlgo_dijkstra_dijkstra_GeneratedDefinitions and required structural lemmas from Algo.dijkstra.dijkstra.Generated. 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_Algo2LeanLib_Modules
import Definitions.Def_Algo2LeanLib_Interface
import Definitions.Def_Algo_graph_Generated
import Definitions.Def_Algo_dijkstra_priority_queue_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
namespace Algo.«dijkstra».«dijkstra»
open _root_.Algo2LeanGenerated
-- Independently compiled module; imported algorithms keep their own transitions.
structure Dependencies where
«PriorityQueue» : Algo.«dijkstra».«priority_queue».«PriorityQueue».Code
namespace Algo2LeanGenerated
abbrev Ref__a2l_import_0_Edge := Algo.«graph».Algo2LeanGenerated.Ref_Edge
abbrev Ref__a2l_import_0_Graph := Algo.«graph».Algo2LeanGenerated.Ref_Graph
abbrev Ref__a2l_import_1_PriorityQueue := ObjectRef
abbrev is__a2l_import_0_Edge := Algo.«graph».Algo2LeanGenerated.is_Edge
abbrev create__a2l_import_0_Edge := Algo.«graph».Algo2LeanGenerated.create_Edge
abbrev field__a2l_import_0_Edge_target := Algo.«graph».Algo2LeanGenerated.field_Edge_target
abbrev set__a2l_import_0_Edge_target := Algo.«graph».Algo2LeanGenerated.set_Edge_target
abbrev field__a2l_import_0_Edge_weight := Algo.«graph».Algo2LeanGenerated.field_Edge_weight
abbrev set__a2l_import_0_Edge_weight := Algo.«graph».Algo2LeanGenerated.set_Edge_weight
abbrev field__a2l_import_0_Edge_next := Algo.«graph».Algo2LeanGenerated.field_Edge_next
abbrev set__a2l_import_0_Edge_next := Algo.«graph».Algo2LeanGenerated.set_Edge_next
abbrev is__a2l_import_0_Graph := Algo.«graph».Algo2LeanGenerated.is_Graph
abbrev create__a2l_import_0_Graph := Algo.«graph».Algo2LeanGenerated.create_Graph
abbrev field__a2l_import_0_Graph_size := Algo.«graph».Algo2LeanGenerated.field_Graph_size
abbrev set__a2l_import_0_Graph_size := Algo.«graph».Algo2LeanGenerated.set_Graph_size
abbrev field__a2l_import_0_Graph_heads := Algo.«graph».Algo2LeanGenerated.field_Graph_heads
abbrev set__a2l_import_0_Graph_heads := Algo.«graph».Algo2LeanGenerated.set_Graph_heads
def is__a2l_import_1_PriorityQueue (dependencies : Dependencies) (h : Heap) (ref : ObjectRef) : Prop :=
dependencies.«PriorityQueue».valid h ref = true
def seq__a2l_import_0_Edge_optional : SequenceType (Option Ref__a2l_import_0_Edge) where
name := "graph.Edge?"
encode := fun value => (match value with | some ref => ObjectValue.objectValue ref | none => ObjectValue.noneValue)
decode := ObjectValue.asNullableObject
decode_encode := by intro value; cases value <;> rfl
structure State_scan_edges where
v0 : Ref__a2l_import_1_PriorityQueue := 0 -- queue
v1 : SeqRef := 0 -- distance
v2 : SeqRef := 0 -- settled
v3 : Int := 0 -- vertex
v4 : (Option Ref__a2l_import_0_Edge) := none -- edge
v5 : Int := 0 -- target
v6 : Int := 0 -- candidate
t7 : Unit := () -- temporary
t8 : Bool := false -- temporary
t9 : Bool := false -- temporary
t10 : Bool := false -- temporary
t11 : Unit := () -- temporary
t12 : Ref__a2l_import_1_PriorityQueue := 0 -- temporary
t13 : Int := 0 -- temporary
t14 : Int := 0 -- temporary
structure State_dijkstra where
v0 : Ref__a2l_import_0_Graph := 0 -- graph
v1 : Int := 0 -- source
v2 : Ref__a2l_import_1_PriorityQueue := 0 -- queue
v3 : SeqRef := 0 -- distance
v4 : SeqRef := 0 -- settled
v5 : Int := 0 -- vertex
t6 : SeqRef := 0 -- temporary
t7 : Bool := false -- temporary
t8 : Bool := false -- temporary
t9 : Ref__a2l_import_1_PriorityQueue := 0 -- temporary
t10 : Unit := () -- temporary
t11 : Ref__a2l_import_1_PriorityQueue := 0 -- temporary
t12 : SeqRef := 0 -- temporary
t13 : SeqRef := 0 -- temporary
t14 : Int := 0 -- temporary
t15 : (Option Ref__a2l_import_0_Edge) := none -- temporary
t16 : Int := 0 -- temporary
t17 : Ref__a2l_import_1_PriorityQueue := 0 -- temporary
t18 : Unit := () -- temporary
t19 : Ref__a2l_import_1_PriorityQueue := 0 -- temporary
t20 : Int := 0 -- temporary
t21 : Int := 0 -- temporary
inductive Frame (dependencies : Dependencies) where
| invalid
| fn_scan_edges (pc : Nat) (state : State_scan_edges)
| fn_dijkstra (pc : Nat) (state : State_dijkstra)
| interface_PriorityQueue (frame : dependencies.«PriorityQueue».Frame) (inner : (Algo2LeanCore.Stack dependencies.«PriorityQueue».Frame Algo.«dijkstra».«priority_queue».«PriorityQueue».Result)) (resume : Algo.«dijkstra».«priority_queue».«PriorityQueue».Result → Frame dependencies)
inductive Result where
| fn_scan_edges (value : Unit)
| fn_dijkstra (value : SeqRef)
abbrev Configuration (dependencies : Dependencies) := Algo2LeanCore.Config Heap (Frame dependencies) Result
abbrev Stack (dependencies : Dependencies) := Algo2LeanCore.Stack (Frame dependencies) Result
abbrev Transcript (dependencies : Dependencies) := List (Configuration dependencies)
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 "is__a2l_import_1_PriorityQueue" => is__a2l_import_1_PriorityQueue dependencies
inductive Step : Configuration → Configuration → Prop where
| scan_edges_pc1 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 1 s) stack) (Algo2LeanCore.resumeConfig h (Result.fn_scan_edges (s.t7)) stack)
| scan_edges_pc2 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 2 s) stack) (.active h (Frame.fn_scan_edges 1 { s with t7 := () }) stack)
| scan_edges_pc3_true (h : Heap) (s : State_scan_edges) (stack : Stack) (condition : s.t8 = true) :
Step (.active h (Frame.fn_scan_edges 3 s) stack) (.active h (Frame.fn_scan_edges 20 s) stack)
| scan_edges_pc3_false (h : Heap) (s : State_scan_edges) (stack : Stack) (condition : s.t8 = false) :
Step (.active h (Frame.fn_scan_edges 3 s) stack) (.active h (Frame.fn_scan_edges 2 s) stack)
| scan_edges_pc4 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 4 s) stack) (.active h (Frame.fn_scan_edges 3 { s with t8 := (decide ((s.v4 ≠ none))) }) stack)
| scan_edges_pc5 (h : Heap) (s : State_scan_edges) (stack : Stack) (defined : (((s.v4).isSome = true) ∧ ((field__a2l_import_0_Edge_next h ((s.v4).getD 0)).isSome = true))) :
Step (.active h (Frame.fn_scan_edges 5 s) stack) (.active h (Frame.fn_scan_edges 4 { s with v4 := ((field__a2l_import_0_Edge_next h ((s.v4).getD 0)).getD none) }) stack)
| scan_edges_pc6 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 6 s) stack) (.active (h.tick "improvements" 1) (Frame.fn_scan_edges 5 s) stack)
| scan_edges_pc7 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 7 s) stack) (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_push_or_decrease ((s.t12), s.t13, s.t14)) [] (fun value => match value with | .fn_PriorityQueue_push_or_decrease result => (Frame.fn_scan_edges 6 { s with t11 := result }) | _ => .invalid)) stack)
| scan_edges_pc8 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 8 s) stack) (.active h (Frame.fn_scan_edges 7 { s with t14 := s.v6 }) stack)
| scan_edges_pc9 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 9 s) stack) (.active h (Frame.fn_scan_edges 8 { s with t13 := s.v5 }) stack)
| scan_edges_pc10 (h : Heap) (s : State_scan_edges) (stack : Stack) (defined : (is__a2l_import_1_PriorityQueue h (s.t12))) :
Step (.active h (Frame.fn_scan_edges 10 s) stack) (.active h (Frame.fn_scan_edges 9 { s with t12 := s.t12 }) stack)
| scan_edges_pc11 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 11 s) stack) (.active h (Frame.fn_scan_edges 10 { s with t12 := s.v0 }) stack)
| scan_edges_pc12 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 12 s) stack) (.active (h.tick "queue_updates" 1) (Frame.fn_scan_edges 11 s) stack)
| scan_edges_pc13 (h : Heap) (s : State_scan_edges) (stack : Stack) (defined : s.v1 < h.nextRef) :
Step (.active h (Frame.fn_scan_edges 13 s) stack) (.active (h.write s.v1 s.v5 s.v6) (Frame.fn_scan_edges 12 s) stack)
| scan_edges_pc14_true (h : Heap) (s : State_scan_edges) (stack : Stack) (condition : s.t10 = true) :
Step (.active h (Frame.fn_scan_edges 14 s) stack) (.active h (Frame.fn_scan_edges 13 s) stack)
| scan_edges_pc14_false (h : Heap) (s : State_scan_edges) (stack : Stack) (condition : s.t10 = false) :
Step (.active h (Frame.fn_scan_edges 14 s) stack) (.active h (Frame.fn_scan_edges 5 s) stack)
| scan_edges_pc15 (h : Heap) (s : State_scan_edges) (stack : Stack) (defined : (((s.v1 < h.nextRef))) ∧ (((decide (((h.read s.v1 s.v5) < (0 : Int)))) = false → ((s.v1 < h.nextRef))))) :
Step (.active h (Frame.fn_scan_edges 15 s) stack) (.active h (Frame.fn_scan_edges 14 { s with t10 := ((decide (((h.read s.v1 s.v5) < (0 : Int)))) || (decide ((s.v6 < (h.read s.v1 s.v5))))) }) stack)
| scan_edges_pc16 (h : Heap) (s : State_scan_edges) (stack : Stack) (defined : ((s.v1 < h.nextRef)) ∧ ((((s.v4).isSome = true) ∧ ((field__a2l_import_0_Edge_weight h ((s.v4).getD 0)).isSome = true)))) :
Step (.active h (Frame.fn_scan_edges 16 s) stack) (.active h (Frame.fn_scan_edges 15 { s with v6 := ((h.read s.v1 s.v3) + ((field__a2l_import_0_Edge_weight h ((s.v4).getD 0)).getD 0)) }) stack)
| scan_edges_pc17_true (h : Heap) (s : State_scan_edges) (stack : Stack) (condition : s.t9 = true) :
Step (.active h (Frame.fn_scan_edges 17 s) stack) (.active h (Frame.fn_scan_edges 16 s) stack)
| scan_edges_pc17_false (h : Heap) (s : State_scan_edges) (stack : Stack) (condition : s.t9 = false) :
Step (.active h (Frame.fn_scan_edges 17 s) stack) (.active h (Frame.fn_scan_edges 5 s) stack)
| scan_edges_pc18 (h : Heap) (s : State_scan_edges) (stack : Stack) (defined : ((s.v2 < h.nextRef))) :
Step (.active h (Frame.fn_scan_edges 18 s) stack) (.active h (Frame.fn_scan_edges 17 { s with t9 := (decide (((h.read s.v2 s.v5) = (0 : Int)))) }) stack)
| scan_edges_pc19 (h : Heap) (s : State_scan_edges) (stack : Stack) (defined : (((s.v4).isSome = true) ∧ ((field__a2l_import_0_Edge_target h ((s.v4).getD 0)).isSome = true))) :
Step (.active h (Frame.fn_scan_edges 19 s) stack) (.active h (Frame.fn_scan_edges 18 { s with v5 := ((field__a2l_import_0_Edge_target h ((s.v4).getD 0)).getD 0) }) stack)
| scan_edges_pc20 (h : Heap) (s : State_scan_edges) (stack : Stack) :
Step (.active h (Frame.fn_scan_edges 20 s) stack) (.active (h.tick "edges" 1) (Frame.fn_scan_edges 19 s) stack)
| dijkstra_pc1 (h : Heap) (s : State_dijkstra) (stack : Stack) (defined : s.t6 < h.nextRef) :
Step (.active h (Frame.fn_dijkstra 1 s) stack) (Algo2LeanCore.resumeConfig h (Result.fn_dijkstra (s.t6)) stack)
| dijkstra_pc2 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 2 s) stack) (.active h (Frame.fn_dijkstra 1 { s with t6 := s.v3 }) stack)
| dijkstra_pc3_true (h : Heap) (s : State_dijkstra) (stack : Stack) (condition : s.t7 = true) :
Step (.active h (Frame.fn_dijkstra 3 s) stack) (.active h (Frame.fn_dijkstra 21 s) stack)
| dijkstra_pc3_false (h : Heap) (s : State_dijkstra) (stack : Stack) (condition : s.t7 = false) :
Step (.active h (Frame.fn_dijkstra 3 s) stack) (.active h (Frame.fn_dijkstra 2 s) stack)
| dijkstra_pc4 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 4 s) stack) (.active h (Frame.fn_dijkstra 3 { s with t7 := (!s.t8) }) stack)
| dijkstra_pc5 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 5 s) stack) (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_is_empty (s.t9)) [] (fun value => match value with | .fn_PriorityQueue_is_empty result => (Frame.fn_dijkstra 4 { s with t8 := result }) | _ => .invalid)) stack)
| dijkstra_pc6 (h : Heap) (s : State_dijkstra) (stack : Stack) (defined : (is__a2l_import_1_PriorityQueue h (s.t9))) :
Step (.active h (Frame.fn_dijkstra 6 s) stack) (.active h (Frame.fn_dijkstra 5 { s with t9 := s.t9 }) stack)
| dijkstra_pc7 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 7 s) stack) (.active h (Frame.fn_dijkstra 6 { s with t9 := s.v2 }) stack)
| dijkstra_pc8 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 8 s) stack) (.active (h.tick "queue_empty_checks" 1) (Frame.fn_dijkstra 7 s) stack)
| dijkstra_pc9 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 9 s) stack) (.active h (Frame.fn_scan_edges 4 ({ v0 := s.t11, v1 := s.t12, v2 := s.t13, v3 := s.t14, v4 := s.t15 } : State_scan_edges)) ((fun value => match value with | .fn_scan_edges result => (Frame.fn_dijkstra 8 { s with t10 := result }) | _ => .invalid) :: stack))
| dijkstra_pc10 (h : Heap) (s : State_dijkstra) (stack : Stack) (defined : ((((field__a2l_import_0_Graph_heads h (s.v0)).isSome = true))) ∧ ((seq__a2l_import_0_Edge_optional.get h ((field__a2l_import_0_Graph_heads h (s.v0)).getD 0) s.v5).isSome = true)) :
Step (.active h (Frame.fn_dijkstra 10 s) stack) (.active h (Frame.fn_dijkstra 9 { s with t15 := ((seq__a2l_import_0_Edge_optional.get h ((field__a2l_import_0_Graph_heads h (s.v0)).getD 0) s.v5).getD none) }) stack)
| dijkstra_pc11 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 11 s) stack) (.active h (Frame.fn_dijkstra 10 { s with t14 := s.v5 }) stack)
| dijkstra_pc12 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 12 s) stack) (.active h (Frame.fn_dijkstra 11 { s with t13 := s.v4 }) stack)
| dijkstra_pc13 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 13 s) stack) (.active h (Frame.fn_dijkstra 12 { s with t12 := s.v3 }) stack)
| dijkstra_pc14 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 14 s) stack) (.active h (Frame.fn_dijkstra 13 { s with t11 := s.v2 }) stack)
| dijkstra_pc15 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 15 s) stack) (.active (h.tick "settlements" 1) (Frame.fn_dijkstra 14 s) stack)
| dijkstra_pc16 (h : Heap) (s : State_dijkstra) (stack : Stack) (defined : s.v4 < h.nextRef) :
Step (.active h (Frame.fn_dijkstra 16 s) stack) (.active (h.write s.v4 s.v5 (1 : Int)) (Frame.fn_dijkstra 15 s) stack)
| dijkstra_pc17 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 17 s) stack) (.active h (Frame.fn_dijkstra 16 { s with v5 := s.t16 }) stack)
| dijkstra_pc18 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 18 s) stack) (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_pop_min (s.t17)) [] (fun value => match value with | .fn_PriorityQueue_pop_min result => (Frame.fn_dijkstra 17 { s with t16 := result }) | _ => .invalid)) stack)
| dijkstra_pc19 (h : Heap) (s : State_dijkstra) (stack : Stack) (defined : (is__a2l_import_1_PriorityQueue h (s.t17))) :
Step (.active h (Frame.fn_dijkstra 19 s) stack) (.active h (Frame.fn_dijkstra 18 { s with t17 := s.t17 }) stack)
| dijkstra_pc20 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 20 s) stack) (.active h (Frame.fn_dijkstra 19 { s with t17 := s.v2 }) stack)
| dijkstra_pc21 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 21 s) stack) (.active (h.tick "queue_pops" 1) (Frame.fn_dijkstra 20 s) stack)
| dijkstra_pc22 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 22 s) stack) (.active (h.tick "queue_empty_checks" 1) (Frame.fn_dijkstra 7 s) stack)
| dijkstra_pc23 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 23 s) stack) (.active h (Frame.interface_PriorityQueue (dependencies.«PriorityQueue».entry_PriorityQueue_push_or_decrease ((s.t19), s.t20, s.t21)) [] (fun value => match value with | .fn_PriorityQueue_push_or_decrease result => (Frame.fn_dijkstra 22 { s with t18 := result }) | _ => .invalid)) stack)
| dijkstra_pc24 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 24 s) stack) (.active h (Frame.fn_dijkstra 23 { s with t21 := (0 : Int) }) stack)
| dijkstra_pc25 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 25 s) stack) (.active h (Frame.fn_dijkstra 24 { s with t20 := s.v1 }) stack)
| dijkstra_pc26 (h : Heap) (s : State_dijkstra) (stack : Stack) (defined : (is__a2l_import_1_PriorityQueue h (s.t19))) :
Step (.active h (Frame.fn_dijkstra 26 s) stack) (.active h (Frame.fn_dijkstra 25 { s with t19 := s.t19 }) stack)
| dijkstra_pc27 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 27 s) stack) (.active h (Frame.fn_dijkstra 26 { s with t19 := s.v2 }) stack)
| dijkstra_pc28 (h : Heap) (s : State_dijkstra) (stack : Stack) :
Step (.active h (Frame.fn_dijkstra 28 s) stack) (.active (h.tick "queue_updates" 1) (Frame.fn_dijkstra 27 s) stack)
| dijkstra_pc29 (h : Heap) (s : State_dijkstra) (stack : Stack) (defined : s.v3 < h.nextRef) :
Step (.active h (Frame.fn_dijkstra 29 s) stack) (.active (h.write s.v3 s.v1 (0 : Int)) (Frame.fn_dijkstra 28 s) stack)
| interface_PriorityQueue (h : Heap) (frame : dependencies.«PriorityQueue».Frame) (inner : (Algo2LeanCore.Stack dependencies.«PriorityQueue».Frame Algo.«dijkstra».«priority_queue».«PriorityQueue».Result))
(resume : Algo.«dijkstra».«priority_queue».«PriorityQueue».Result → Frame) (caller : Stack) (after : (Algo2LeanCore.Config Heap dependencies.«PriorityQueue».Frame Algo.«dijkstra».«priority_queue».«PriorityQueue».Result))
(transition : dependencies.«PriorityQueue».Step (.active h frame inner) after) :
Step (.active h (Frame.interface_PriorityQueue frame inner resume) caller)
(Algo2LeanCore.ModuleCall.config Frame.interface_PriorityQueue resume caller after)
local notation "Step" => Step dependencies
theorem terminal (h : Heap) (result : Result) :
Algo2LeanCore.Terminal Step (.done h result) := by
intro next transition
cases transition
theorem interface_PriorityQueue_simulates :
Algo2LeanCore.ModuleCall.Simulates Frame.interface_PriorityQueue dependencies.«PriorityQueue».Step Step := by
apply Algo2LeanCore.ModuleCall.Delegates.simulates
· exact Step.interface_PriorityQueue
· exact dependencies.«PriorityQueue».terminal
end Algo2LeanGenerated
open 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
def entry_scan_edges (input : Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge)) : Frame :=
(Frame.fn_scan_edges 4 ({ v0 := input.1, v1 := input.2.1, v2 := input.2.2.1, v3 := input.2.2.2.1, v4 := input.2.2.2.2 } : State_scan_edges))
local notation "entry_scan_edges" => entry_scan_edges dependencies
def scan_edges.ValidInput (h : Heap) (input : Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge)) : Prop := is__a2l_import_1_PriorityQueue h input.1 ∧ input.2.1 < h.nextRef ∧ input.2.2.1 < h.nextRef ∧ (∀ ref ∈ input.2.2.2.2, is__a2l_import_0_Edge h ref)
def scan_edges.initial (h : Heap) (input : Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge)) : Configuration :=
Algo2LeanCore.start h (Frame.fn_scan_edges 4 ({ v0 := input.1, v1 := input.2.1, v2 := input.2.2.1, v3 := input.2.2.2.1, v4 := input.2.2.2.2 } : State_scan_edges))
def scan_edges.Run (h : Heap) (input : Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge)) (h' : Heap) (output : Unit) : Prop :=
_root_.Algo.«dijkstra».«dijkstra».scan_edges.ValidInput dependencies h input ∧ Algo2LeanCore.Reaches Step (_root_.Algo.«dijkstra».«dijkstra».scan_edges.initial dependencies h input) (.done h' (Result.fn_scan_edges output))
def scan_edges.ValidHeapTranscript (h : Heap) (input : Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge)) (trace : Transcript) : Prop :=
_root_.Algo.«dijkstra».«dijkstra».scan_edges.ValidInput dependencies h input ∧ ∃ final, Algo2LeanCore.Valid Step (_root_.Algo.«dijkstra».«dijkstra».scan_edges.initial dependencies h input) trace final
def scan_edges.Call (h : Heap) (input : Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge)) (h' : Heap) (output : Unit) : Prop :=
_root_.Algo.«dijkstra».«dijkstra».scan_edges.ValidInput dependencies h input ∧ Algo2LeanCore.Summary Step h (Frame.fn_scan_edges 4 ({ v0 := input.1, v1 := input.2.1, v2 := input.2.2.1, v3 := input.2.2.2.1, v4 := input.2.2.2.2 } : State_scan_edges)) h' (Result.fn_scan_edges output)
-- Complete this function from the supplied local state, under any caller stack.
def scan_edges.CallFrom (state : Configuration) (finalHeap : Heap) (output : Unit) : Prop :=
match state with
| .active heap (Frame.fn_scan_edges pc locals) _ =>
Algo2LeanCore.Summary Step heap (Frame.fn_scan_edges pc locals) finalHeap (Result.fn_scan_edges output)
| _ => False
-- Object inputs carry their heap, preserving shared references and cycles.
def scan_edges.load (input : Heap × (Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge))) : Heap × (Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge)) := input
def scan_edges.ValidTranscript (my_input : Heap × (Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge))) (trace : Transcript) : Prop :=
let loaded := _root_.Algo.«dijkstra».«dijkstra».scan_edges.load my_input
_root_.Algo.«dijkstra».«dijkstra».scan_edges.ValidHeapTranscript dependencies loaded.1 loaded.2 trace
def scan_edges.Returns (my_input : Heap × (Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge))) (my_output : Unit) : Prop :=
let loaded := _root_.Algo.«dijkstra».«dijkstra».scan_edges.load my_input
∃ finalHeap, _root_.Algo.«dijkstra».«dijkstra».scan_edges.Run dependencies loaded.1 loaded.2 finalHeap my_output
-- Output and clock increments from one completed execution.
def scan_edges.ReturnsWithCost (my_input : Heap × (Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef × Int × (Option Ref__a2l_import_0_Edge))) (my_output : Unit) (costs : Clocks) : Prop :=
let loaded := _root_.Algo.«dijkstra».«dijkstra».scan_edges.load my_input
∃ finalHeap, _root_.Algo.«dijkstra».«dijkstra».scan_edges.Run dependencies loaded.1 loaded.2 finalHeap my_output ∧ Heap.cost loaded.1 finalHeap = costs
theorem scan_edges.ReturnsWithCost.returns {dependencies : Dependencies} {input output costs}
(run : _root_.Algo.«dijkstra».«dijkstra».scan_edges.ReturnsWithCost dependencies input output costs) : _root_.Algo.«dijkstra».«dijkstra».scan_edges.Returns dependencies input output := by
obtain ⟨heap, execution, _⟩ := run
exact ⟨heap, execution⟩
theorem scan_edges.Returns.withCost {dependencies : Dependencies} {input output}
(run : _root_.Algo.«dijkstra».«dijkstra».scan_edges.Returns dependencies input output) : ∃ costs, _root_.Algo.«dijkstra».«dijkstra».scan_edges.ReturnsWithCost dependencies input output costs := by
obtain ⟨heap, execution⟩ := run
exact ⟨Heap.cost (_root_.Algo.«dijkstra».«dijkstra».scan_edges.load input).1 heap, heap, execution, rfl⟩
theorem scan_edges.Call.run {dependencies : Dependencies} {before input after output}
(call : _root_.Algo.«dijkstra».«dijkstra».scan_edges.Call dependencies before input after output) :
_root_.Algo.«dijkstra».«dijkstra».scan_edges.Run dependencies before input after output :=
⟨call.1, call.2.root⟩
def entry_dijkstra (input : Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef) : Frame :=
(Frame.fn_dijkstra 29 ({ v0 := input.1, v1 := input.2.1, v2 := input.2.2.1, v3 := input.2.2.2.1, v4 := input.2.2.2.2 } : State_dijkstra))
local notation "entry_dijkstra" => entry_dijkstra dependencies
def dijkstra.ValidInput (h : Heap) (input : Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef) : Prop := is__a2l_import_0_Graph h input.1 ∧ is__a2l_import_1_PriorityQueue h input.2.2.1 ∧ input.2.2.2.1 < h.nextRef ∧ input.2.2.2.2 < h.nextRef
def dijkstra.initial (h : Heap) (input : Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef) : Configuration :=
Algo2LeanCore.start h (Frame.fn_dijkstra 29 ({ v0 := input.1, v1 := input.2.1, v2 := input.2.2.1, v3 := input.2.2.2.1, v4 := input.2.2.2.2 } : State_dijkstra))
def dijkstra.Run (h : Heap) (input : Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef) (h' : Heap) (output : SeqRef) : Prop :=
_root_.Algo.«dijkstra».«dijkstra».dijkstra.ValidInput dependencies h input ∧ Algo2LeanCore.Reaches Step (_root_.Algo.«dijkstra».«dijkstra».dijkstra.initial dependencies h input) (.done h' (Result.fn_dijkstra output))
def dijkstra.ValidHeapTranscript (h : Heap) (input : Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef) (trace : Transcript) : Prop :=
_root_.Algo.«dijkstra».«dijkstra».dijkstra.ValidInput dependencies h input ∧ ∃ final, Algo2LeanCore.Valid Step (_root_.Algo.«dijkstra».«dijkstra».dijkstra.initial dependencies h input) trace final
def dijkstra.Call (h : Heap) (input : Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef) (h' : Heap) (output : SeqRef) : Prop :=
_root_.Algo.«dijkstra».«dijkstra».dijkstra.ValidInput dependencies h input ∧ Algo2LeanCore.Summary Step h (Frame.fn_dijkstra 29 ({ v0 := input.1, v1 := input.2.1, v2 := input.2.2.1, v3 := input.2.2.2.1, v4 := input.2.2.2.2 } : State_dijkstra)) h' (Result.fn_dijkstra output)
-- Complete this function from the supplied local state, under any caller stack.
def dijkstra.CallFrom (state : Configuration) (finalHeap : Heap) (output : SeqRef) : Prop :=
match state with
| .active heap (Frame.fn_dijkstra pc locals) _ =>
Algo2LeanCore.Summary Step heap (Frame.fn_dijkstra pc locals) finalHeap (Result.fn_dijkstra output)
| _ => False
-- Object inputs carry their heap, preserving shared references and cycles.
def dijkstra.load (input : Heap × (Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef)) : Heap × (Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef) := input
def dijkstra.ValidTranscript (my_input : Heap × (Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef)) (trace : Transcript) : Prop :=
let loaded := _root_.Algo.«dijkstra».«dijkstra».dijkstra.load my_input
_root_.Algo.«dijkstra».«dijkstra».dijkstra.ValidHeapTranscript dependencies loaded.1 loaded.2 trace
def dijkstra.Returns (my_input : Heap × (Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef)) (my_output : Seq) : Prop :=
let loaded := _root_.Algo.«dijkstra».«dijkstra».dijkstra.load my_input
∃ finalHeap result, _root_.Algo.«dijkstra».«dijkstra».dijkstra.Run dependencies loaded.1 loaded.2 finalHeap result ∧ finalHeap.store result = my_output
-- Output and clock increments from one completed execution.
def dijkstra.ReturnsWithCost (my_input : Heap × (Ref__a2l_import_0_Graph × Int × Ref__a2l_import_1_PriorityQueue × SeqRef × SeqRef)) (my_output : Seq) (costs : Clocks) : Prop :=
let loaded := _root_.Algo.«dijkstra».«dijkstra».dijkstra.load my_input
∃ finalHeap result, _root_.Algo.«dijkstra».«dijkstra».dijkstra.Run dependencies loaded.1 loaded.2 finalHeap result ∧ finalHeap.store result = my_output ∧ Heap.cost loaded.1 finalHeap = costs
theorem dijkstra.ReturnsWithCost.returns {dependencies : Dependencies} {input output costs}
(run : _root_.Algo.«dijkstra».«dijkstra».dijkstra.ReturnsWithCost dependencies input output costs) : _root_.Algo.«dijkstra».«dijkstra».dijkstra.Returns dependencies input output := by
obtain ⟨heap, result, execution, value, _⟩ := run
exact ⟨heap, result, execution, value⟩
theorem dijkstra.Returns.withCost {dependencies : Dependencies} {input output}
(run : _root_.Algo.«dijkstra».«dijkstra».dijkstra.Returns dependencies input output) : ∃ costs, _root_.Algo.«dijkstra».«dijkstra».dijkstra.ReturnsWithCost dependencies input output costs := by
obtain ⟨heap, result, execution, value⟩ := run
exact ⟨Heap.cost (_root_.Algo.«dijkstra».«dijkstra».dijkstra.load input).1 heap, heap, result, execution, value, rfl⟩
theorem dijkstra.Call.run {dependencies : Dependencies} {before input after output}
(call : _root_.Algo.«dijkstra».«dijkstra».dijkstra.Call dependencies before input after output) :
_root_.Algo.«dijkstra».«dijkstra».dijkstra.Run dependencies before input after output :=
⟨call.1, call.2.root⟩
end Algo.«dijkstra».«dijkstra»