Instances For
Lens onto the global part of a ProcedureState.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Lens onto the local part of a ProcedureState.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- GaudisCrypt.paramListToTuple [] = Unit
- GaudisCrypt.paramListToTuple [x_1] = x_1
- GaudisCrypt.paramListToTuple (x_1 :: xs) = (x_1 × GaudisCrypt.paramListToTuple xs)
Instances For
The local state of a procedure: parameter values (params) and local-variable
values (vars). Indexed by the parameter types and the local declarations only
(not the return type), so it can be formed before the return type is known — this is
what lets a proc with an omitted return type elaborate.
- params : paramListToTuple paramTypes
- vars : paramListToTuple (List.map (fun (x : (t : Type) × Inhabited t) => x.fst) locals)
Instances For
The local state for a full signature (delegates to LocalVariableState; reducible
so sig.LocalVariableState locals is defeq to LocalVariableState sig.params locals).
Equations
- sig.LocalVariableState locals = GaudisCrypt.LocalVariableState sig.params locals
Instances For
Lens onto the parameter tuple of a LocalVariableState.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Lens onto the local-variable tuple of a LocalVariableState.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Lift a lens into the parameter tuple to a lens into the full procedure state
(localL ∘ paramsL). Analogous to Lens.ofst. (Defined in the Lens namespace via
_root_ so dot notation lens.intoParams resolves.)
Equations
Instances For
Lift a lens into the local-variable tuple to a lens into the full procedure state
(localL ∘ varsL). Analogous to Lens.ofst.
Equations
Instances For
Local program variables are Lens.intoVars of their slot projections; distinct slots
are disjoint, and intoVars (two chain layers) preserves that.
Equations
- sig.ParamType = GaudisCrypt.paramListToTuple sig.params
Instances For
Equations
- sig.localVariableInit locals params = { params := params, vars := GaudisCrypt.localDefaults✝ locals }
Instances For
A sequences of procedure signatures, intended to be used to describe the type of holes in a program
- empty : HoleSigs
- append : HoleSigs → ProcedureSignature → HoleSigs
Instances For
- zero {a : ProcedureSignature} {Γ : HoleSigs} : HoleIndex (Γ.append a) a
- succ {Γ : HoleSigs} {a b : ProcedureSignature} : HoleIndex Γ a → HoleIndex (Γ.append b) a
Instances For
Equations
- GaudisCrypt.instDecidableEqHoleIndex.decEq GaudisCrypt.HoleIndex.zero GaudisCrypt.HoleIndex.zero = isTrue ⋯
- GaudisCrypt.instDecidableEqHoleIndex.decEq GaudisCrypt.HoleIndex.zero a_3.succ = isFalse ⋯
- GaudisCrypt.instDecidableEqHoleIndex.decEq a_3.succ GaudisCrypt.HoleIndex.zero = isFalse ⋯
- GaudisCrypt.instDecidableEqHoleIndex.decEq a_5.succ b.succ = if h : a_5 = b then h ▸ have inst := GaudisCrypt.instDecidableEqHoleIndex.decEq a_5 a_5; isTrue ⋯ else isFalse ⋯
Instances For
Equations
Instances For
Equations
Instances For
Syntactic program (with arbitrary Lean terms as expressions)
- skip [ProgramSpec] {h : HoleSigs} {l : Type} : StmtWithHoles h l
- sample [ProgramSpec] {l : Type} {h : HoleSigs} {a : Type} : Setter a (ProcedureState l) → Getter (SubProbability a) (ProcedureState l) → StmtWithHoles h l
- call' [ProgramSpec] {l : Type} {h : HoleSigs} {sig : ProcedureSignature} : Setter sig.ret (ProcedureState l) → (locals : List ((t : Type) × Inhabited t)) → StmtWithHoles HoleSigs.empty (sig.LocalVariableState locals) → Getter sig.ret (ProcedureState (sig.LocalVariableState locals)) → Getter sig.ParamType (ProcedureState l) → StmtWithHoles h l
- hole [ProgramSpec] {h : HoleSigs} {l : Type} {sig : ProcedureSignature} (n : HoleIndex h sig) : Setter sig.ret (ProcedureState l) → Getter sig.ParamType (ProcedureState l) → StmtWithHoles h l
- seq [ProgramSpec] {h : HoleSigs} {l : Type} : StmtWithHoles h l → StmtWithHoles h l → StmtWithHoles h l
- ifThenElse [ProgramSpec] {l : Type} {h : HoleSigs} : Getter Bool (ProcedureState l) → StmtWithHoles h l → StmtWithHoles h l → StmtWithHoles h l
- while [ProgramSpec] {l : Type} {h : HoleSigs} : Getter Bool (ProcedureState l) → StmtWithHoles h l → StmtWithHoles h l
Instances For
Instances For
- body : StmtWithHoles holeSigs (sig.LocalVariableState self.locals)
- return_val : Getter sig.ret (ProcedureState (sig.LocalVariableState self.locals))
Instances For
Equations
Instances For
The signature of a procedure-with-holes as a term — sig is otherwise only reachable as
an implicit argument of the type, which makes it awkward to name in generated code.
Instances For
Equations
- GaudisCrypt.StmtWithHoles.call x proc params = GaudisCrypt.StmtWithHoles.call' x proc.locals proc.body proc.return_val params
Instances For
Equations
- GaudisCrypt.StmtWithHoles.assign x e = GaudisCrypt.StmtWithHoles.sample x { get := fun (st : GaudisCrypt.ProcedureState l) => pure (e.get st) }
Instances For
Equations
- GaudisCrypt.Stmt.call x proc params = GaudisCrypt.StmtWithHoles.call x proc params
Instances For
Equations
- holes.Instantiation = ({sig : GaudisCrypt.ProcedureSignature} → GaudisCrypt.HoleIndex holes sig → GaudisCrypt.Procedure sig)
Instances For
The only instantiation of no holes at all.
Instances For
Extend an instantiation by one more procedure, for one more (last-appended) hole. Written in
the order the holes were appended, nil.push p₀ |>.push p₁ …, this is how an instantiation is
built up from concrete procedures — note HoleIndex.zero is the last one pushed.
Instances For
Looking up the hole a push was made for.
Looking up any other hole of a push falls through to the instantiation it extends.
Convert an instantiation into a plain list of procedures (tagged by their signature),
in the same right-nested order as HoleSigs.Instantiation.toModuleTuple.
The head of the list corresponds to the most-recently appended hole signature.
Instances For
Instantiate all holes in a statement using resolve, turning each .hole into a
.call' of the resolved procedure. Hole-free constructors are simply re-typed.
Equations
- One or more equations did not get rendered due to their size.
- GaudisCrypt.StmtWithHoles.skip.instantiate instantiation = GaudisCrypt.StmtWithHoles.skip
- (GaudisCrypt.StmtWithHoles.sample x e).instantiate instantiation = GaudisCrypt.StmtWithHoles.sample x e
- (GaudisCrypt.StmtWithHoles.call' x ls b r p).instantiate instantiation = GaudisCrypt.StmtWithHoles.call' x ls b r p
- (GaudisCrypt.StmtWithHoles.hole n x p).instantiate instantiation = GaudisCrypt.StmtWithHoles.call x (instantiation n) p
- (GaudisCrypt.StmtWithHoles.while c t).instantiate instantiation = GaudisCrypt.StmtWithHoles.while c (t.instantiate fun {sig : GaudisCrypt.ProcedureSignature} => instantiation)
Instances For
Equations
- proc.instantiate instantiation = { locals := proc.locals, body := proc.body.instantiate fun {sig : GaudisCrypt.ProcedureSignature} => instantiation, return_val := proc.return_val }
Instances For
A structural size measure used to justify termination of programDenotation.
The auto-generated sizeOf for StmtWithHoles is trivially 0 (the inductive
lives in a higher universe because its constructors quantify over a : Type), so
we define our own.
Equations
- GaudisCrypt.StmtWithHoles.skip.depth = 0
- (GaudisCrypt.StmtWithHoles.sample a_1 a_2).depth = 0
- (GaudisCrypt.StmtWithHoles.hole n a a_1).depth = 0
- (GaudisCrypt.StmtWithHoles.call' a locals body a_1 a_2).depth = body.depth + 1
- (p.seq q).depth = max p.depth q.depth + 1
- (GaudisCrypt.StmtWithHoles.ifThenElse a p q).depth = max p.depth q.depth + 1
- (GaudisCrypt.StmtWithHoles.while a p).depth = p.depth + 1
Instances For
A hole-free statement has nothing to instantiate: every constructor is re-typed as itself, and
the .hole case cannot occur (HoleIndex .empty _ is empty). Recursion is on depth — the
statement's own index HoleSigs.empty is not a variable, so the equation compiler cannot recurse
on it structurally.
Instantiating a procedure that has no holes leaves it alone.
Equations
- One or more equations did not get rendered due to their size.
- GaudisCrypt.programDenotation GaudisCrypt.StmtWithHoles.skip = GaudisCrypt.ProgramDenotation.skip
- GaudisCrypt.programDenotation (GaudisCrypt.StmtWithHoles.sample x_1 e) = do let μ ← GaudisCrypt.ProgramDenotation.get e let v ← μ.toProgramDenotation GaudisCrypt.ProgramDenotation.set x_1 v
- GaudisCrypt.programDenotation (p.seq q) = do let __discr ← GaudisCrypt.programDenotation p have x : Unit := __discr GaudisCrypt.programDenotation q
- GaudisCrypt.programDenotation (GaudisCrypt.StmtWithHoles.while c p) = GaudisCrypt.while_loop (GaudisCrypt.ProgramDenotation.get c) (GaudisCrypt.programDenotation p)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The procedure denotation as an explicit wrapper: initialise locals, run the
body, extract (return_val, global).
Equations
Instances For
procedureDenotation of an instantiated procedure is procWrap of its body
(generic over the holes and their instantiation).