structure
GaudisCrypt.Lens
(a : Type u)
(b : Type v)
extends GaudisCrypt.Getter a b, GaudisCrypt.Setter a b :
Type (max u v)
Instances For
@[implicit_reducible]
Equations
noncomputable def
GaudisCrypt.Lens.get_from_set
{a : Type u_1}
{m : Type u_2}
[ne : Nonempty a]
(set : a → m → m)
:
m → a
Equations
- GaudisCrypt.Lens.get_from_set set mem = if h : ∃ (x : a), set x mem = mem then Classical.choose h else Classical.choice ne
Instances For
A setter that discards its writes.
Equations
- GaudisCrypt.Setter.throwaway = { set := fun (x : a) (s : m) => s, set_set := ⋯ }
Instances For
Equations
- GaudisCrypt.Lens.id = { get := fun (m : m) => m, set := fun (a x : m) => a, set_set := ⋯, set_get := ⋯, get_set := ⋯ }
Instances For
The trivial lens onto a subsingleton-with-default content type: reads nothing, writes
nothing. Its footprint is ⊥.
Equations
- GaudisCrypt.Lens.punit = { get := fun (x : s) => default, set := fun (x : t) (σ : s) => σ, set_set := ⋯, set_get := ⋯, get_set := ⋯ }
Instances For
Equations
- GaudisCrypt.LensIn.mk' lens = { content := a, lens := lens }
Instances For
Equations
- GaudisCrypt.IsoLens lens = Function.Bijective lens.get
Instances For
@[implicit_reducible]
Equations
- One or more equations did not get rendered due to their size.
@[reducible, inline]
Equations
Instances For
def
GaudisCrypt.Lens.liftFunction
{a : Type u_1}
{m : Type u_2}
(lens : Lens a m)
(f : Function.End a)
:
Equations
- lens.liftFunction f x = lens.set (f (lens.get x)) x
Instances For
The relation equal_outside is an equivalence.
- refl:
set (get s) s = s(byget_set) - symm:
set x s = s'→set (get s) s' = set (get s) (set x s) = set (get s) s = s(first step byset_set, second byget_set) - trans:
set x s = s',set y s' = s''→set y s = set y (set x s) = s''(byset_set)
Equations
- lens.equal_outside_setoid = { r := lens.equal_outside, iseqv := ⋯ }
Instances For
Equations
- lens.ComplContent = Quotient lens.equal_outside_setoid
Instances For
def
GaudisCrypt.Lens.compl
{a : Type u_1}
{m : Type u_2}
(lens : Lens a m)
:
Lens lens.ComplContent m
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
GaudisCrypt.lens_leq_content_leq
{m : Type u_1}
[Nonempty m]
(lens1 lens2 : LensIn m)
(h : lens1 ≤ lens2)
:
theorem
GaudisCrypt.get_surjective
{m : Type u_1}
{a : Type u_2}
[Nonempty m]
(lens : Lens a m)
:
Function.Surjective lens.get
theorem
GaudisCrypt.get_injective_iso_lens
{m : Type u_1}
{a : Type u_2}
[Nonempty m]
(lens : Lens a m)
:
Function.Injective lens.get → IsoLens lens
theorem
GaudisCrypt.iso_lens_ge
{a : Type u_1}
{m : Type u_2}
{b : Type u_1}
{z : Lens a b}
(lens1 : Lens a m)
(lens2 : Lens b m)
:
IsoLens z → lens2.chain z = lens1 → LensIn.mk' lens1 ≥ LensIn.mk' lens2
Navigating nested tuples #
A TuplePath names a slot in an arbitrarily nested tuple of binary products
(here/left/right); the ProjAt typeclass decomposes the (concrete) tuple type
structurally, so Lens.insideTuple path deduces both the tuple type M and the
component type A from the expected output type. Encoding the path as an inductive
(rather than Nat arithmetic in instance indices) keeps typeclass resolution
robust.
@[implicit_reducible]
Equations
- GaudisCrypt.instProjAtHere = { proj := GaudisCrypt.Lens.id }
@[implicit_reducible]
Equations
- GaudisCrypt.instProjAtLeftProd = { proj := (GaudisCrypt.ProjAt.proj p).ofst }
@[implicit_reducible]
Equations
- GaudisCrypt.instProjAtRightProd = { proj := (GaudisCrypt.ProjAt.proj p).osnd }
The lens projecting the slot named by p out of a (possibly nested) tuple. The
tuple type M and component type A are deduced from the expected output type.