The swap preserves the meaning (module FrontSem) #
In a model where the swappable operations commute, value and log-weight alike (Swap.Lawful;
for add, whose log-weight is 0), a program and any program with some swappable lines swapped
(SwapLine) have the same trace values, semantics and log-weight. The theorems about a typed
swap therefore hold for the program as written: density, concordance with the swap's inverse
program, and bijectivity. swapArgs emits a swap (swapArgs_swap).
l' is l, or l = o(a, b) and l' = o(b, a) for a swappable o.
- refl {S : Type} {Sg : Sig S} [Swap Sg] (l : Line Sg) : SwapLine l l
- swap {S : Type} {Sg : Sig S} [Swap Sg] {as bs : List S} (o : Sg.Op as bs) (hs : Swap.swappable o = true) (a b : ℕ) : SwapLine { as := as, bs := bs, op := o, args := [a, b] } { as := as, bs := bs, op := o, args := [b, a] }
Instances For
theorem
RoleFlow.trace_swap
{S : Type}
{Sg : Sig S}
[Swap Sg]
[Sorts S]
{M : Model Sg}
(hM : Swap.Lawful M)
{Γ : List S}
{ls ls' : List (Line Sg)}
(hs : List.Forall₂ SwapLine ls ls')
(h : LinesWF Γ ls)
(h' : LinesWF Γ ls')
(v : Val Γ)
{i : ℕ}
{s : S}
(hi : (ctxAfter Γ ls)[i]? = some s)
(hi' : (ctxAfter Γ ls')[i]? = some s)
:
Programs #
theorem
RoleFlow.Prog.density_swap
{S : Type}
{Sg : Sig S}
[Swap Sg]
{P : Prog Sg}
{ls : List (Line Sg)}
{ρ : List Role}
[Sorts S]
{M : Model Sg}
(hM : Swap.Lawful M)
(hs : List.Forall₂ SwapLine P.lines ls)
(hT : (P.swap ls).Typed ρ)
(θ : Val P.wts)
:
Density of the written program, from a typed swap.
theorem
RoleFlow.Prog.inverse_sem_swap
{S : Type}
{Sg : Sig S}
[Swap Sg]
{P : Prog Sg}
{ls : List (Line Sg)}
{ρ : List Role}
[Sorts S]
{M : Model Sg}
(hM : Swap.Lawful M)
(hs : List.Forall₂ SwapLine P.lines ls)
(hT : (P.swap ls).Typed ρ)
(θ : Val P.wts)
(x : Val P.ins)
:
Concordance: the swap's inverse program undoes the written program.
theorem
RoleFlow.Prog.bijective_swap
{S : Type}
{Sg : Sig S}
[Swap Sg]
{P : Prog Sg}
{ls : List (Line Sg)}
{ρ : List Role}
[Sorts S]
{M : Model Sg}
(hM : Swap.Lawful M)
(hs : List.Forall₂ SwapLine P.lines ls)
(hT : (P.swap ls).Typed ρ)
(hR : M.RightLaw)
(θ : Val P.wts)
:
Function.Bijective (sem M P ⋯ θ)
Bijectivity of the written program, from a typed swap, under the right law.