Skip to content

Commit 246a2e2

Browse files
committed
feat(JtvEcho): mechanise Echo×Epistemic function-effect lattice (ADR-0009)
Adds SECTION 5 to the Lean development: the formal counterpart of the Rust `epistemic.rs` + `effect.rs` slices that completed ADR-0009 D1-D3. * `Epistemic` inductive (hidden/bounded/full = Opaque/Partial/Transparent; the lowercase keywords are reserved in Lean, hence the rename) with `Epistemic.join` (full absorbing, hidden unit) and the lattice laws epi_join_comm / epi_join_assoc / epi_join_idem. * `FunctionEffect` structure — a point in the product lattice `Echo × Epistemic` — with componentwise `FunctionEffect.join` and the laws feffect_join_comm / feffect_join_assoc / feffect_join_idem proved from the Echo (SECTION 1) and Epistemic component laws. The three product laws are exactly what makes call-graph composition (`resolved_effects` in effect.rs) well-defined: the join fold is order- and repetition-independent, so `g ∘ f` carries `effect f ⊔ effect g` however the calls are arranged. `lake build` green; zero sorry/admit/axiom. Completes the (b) workstream (Echo + Epistemic first-class) on the proof side. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BJmfoz1ZS1Pejy9LLMY742
1 parent f6e63b7 commit 246a2e2

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

jtv_proofs/JtvEcho.lean

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,75 @@ theorem neg_injective : Injective (fun n : Int => -n) := by
312312
have h' : -a = -b := h
313313
omega
314314

315+
-- ============================================================================
316+
-- SECTION 5: FUNCTION EFFECTS — Echo × Epistemic (ADR-0009 D1+D3)
317+
-- ============================================================================
318+
319+
/-
320+
ADR-0009 lifts Echo to a first-class *function effect* and adds a parallel
321+
*Epistemic* effect (what a function reveals about its inputs). The effect a
322+
function carries is a point in the product lattice `Echo × Epistemic`, and
323+
composition across calls is the (idempotent, commutative) join. This section
324+
mechanises the Epistemic lattice and the product, mirroring the Echo lattice
325+
of SECTION 1, and pins the lattice laws that make composition well-defined.
326+
327+
Constructor names map to the Rust `epistemic.rs` / ADR-0009 D2 grades:
328+
`hidden = Opaque`, `bounded = Partial`, `full = Transparent`
329+
(lowercase `opaque` / `partial` are Lean keywords, hence the rename).
330+
-/
331+
332+
/-- The epistemic grade (ADR-0009 D2): how much a function reveals about inputs.
333+
`hidden ⊑ bounded ⊑ full` (= Opaque ⊑ Partial ⊑ Transparent). -/
334+
inductive Epistemic where
335+
| hidden
336+
| bounded
337+
| full
338+
deriving Repr, DecidableEq
339+
340+
/-- Join (worst-case revelation): `full` absorbing, `hidden` the unit. -/
341+
def Epistemic.join : Epistemic → Epistemic → Epistemic
342+
| .full, _ => .full
343+
| _, .full => .full
344+
| .bounded, _ => .bounded
345+
| _, .bounded => .bounded
346+
| .hidden, .hidden => .hidden
347+
348+
theorem epi_join_comm (a b : Epistemic) : a.join b = b.join a := by
349+
cases a <;> cases b <;> rfl
350+
351+
theorem epi_join_assoc (a b c : Epistemic) :
352+
(a.join b).join c = a.join (b.join c) := by
353+
cases a <;> cases b <;> cases c <;> rfl
354+
355+
theorem epi_join_idem (a : Epistemic) : a.join a = a := by
356+
cases a <;> rfl
357+
358+
/-- The function effect row (ADR-0009 D3): a point in `Echo × Epistemic`,
359+
composed componentwise. -/
360+
structure FunctionEffect where
361+
echo : Echo
362+
epi : Epistemic
363+
deriving Repr, DecidableEq
364+
365+
/-- Componentwise join of two function effects. -/
366+
def FunctionEffect.join (x y : FunctionEffect) : FunctionEffect :=
367+
{ echo := x.echo ⊔ y.echo, epi := x.epi.join y.epi }
368+
369+
/-- **Composition is a commutative, idempotent join** (ADR-0009): the effect of
370+
a composite is the join of its parts', and these three laws make that fold
371+
independent of the order and repetition of calls — so `g ∘ f` carries
372+
`effect f ⊔ effect g` however the calls are arranged. -/
373+
theorem feffect_join_comm (a b : FunctionEffect) : a.join b = b.join a := by
374+
cases a; cases b
375+
simp [FunctionEffect.join, join_comm, epi_join_comm]
376+
377+
theorem feffect_join_assoc (a b c : FunctionEffect) :
378+
(a.join b).join c = a.join (b.join c) := by
379+
cases a; cases b; cases c
380+
simp [FunctionEffect.join, join_assoc, epi_join_assoc]
381+
382+
theorem feffect_join_idem (a : FunctionEffect) : a.join a = a := by
383+
cases a
384+
simp [FunctionEffect.join, join_idem, epi_join_idem]
385+
315386
end Jtv.Echo

0 commit comments

Comments
 (0)