def
definition
empty
show as:
view math explainer →
open explainer
Generate a durable explainer page for this declaration.
open lean source
IndisputableMonolith.RRF.Foundation.Ledger on GitHub at line 80.
browse module
All declarations in this module, on Recognition.
explainer page
depends on
used by
-
IsBalanced -
P_vs_NP_resolved -
high_depth_empty -
high_depth_not_large -
IsNatural -
AllReachable -
determined_values_correct -
geometric_isolation_enables_propagation_thm -
buildPeelingResult -
Bool -
iteration_bound_from_clauses -
HasCover -
verify_ns_holds -
shifts_match_cube_faces -
abilene_dichotomy -
abileneParadoxCert -
group_sigma -
truthful_no_violation -
truthful_strictly_improves -
logUtilityPartial -
prob -
aggCoeff_rowMoves -
aggCoeff_rowMoves_aux_theorem -
fifteenth_generator_required_iff_not_rich -
additive_strict_of_both_inconsistent -
ConfigSpace -
CostFunction -
recognition_work_constraint_cert -
distinguishability_from_specification -
nontrivial_specification_of_proper_subtype -
self_ref_query_impossible -
conservation_from_balance -
empty_ledger -
empty_ledger_balanced -
empty_ledger_cost -
net_flow -
ledgerPhase -
SimplicialLedger -
regge_sum_append -
cancelling_pair_closed
formal source
77namespace Ledger
78
79/-- The empty ledger. -/
80def empty : Ledger := {
81 transactions := [],
82 total_debit := 0,
83 total_credit := 0,
84 global_balance := by omega
85}
86
87/-- A singleton ledger. -/
88def singleton (t : Transaction) : Ledger := {
89 transactions := [t],
90 total_debit := t.debit,
91 total_credit := t.credit,
92 global_balance := t.balanced
93}
94
95/-- Append a transaction to a ledger. -/
96def append (L : Ledger) (t : Transaction) : Ledger := {
97 transactions := L.transactions ++ [t],
98 total_debit := L.total_debit + t.debit,
99 total_credit := L.total_credit + t.credit,
100 global_balance := by
101 have hL := L.global_balance
102 have ht := t.balanced
103 omega
104}
105
106/-- The net balance of a ledger (should always be 0). -/
107def net (L : Ledger) : ℤ := L.total_debit + L.total_credit
108
109/-- Ledger net is always zero. -/
110theorem net_zero (L : Ledger) : L.net = 0 := L.global_balance