Documentation

CslibFrontier.MachineLearning.UniformLearning.AdaptiveCircuit

Adaptive learners computed by small circuits #

An adaptive membership-query learner chooses each query from the answers to the queries before it. Given queries Q, where Q i maps the answers to the first i queries to the i-th queried point, and a hypothesis H of all q answers, UniformLearning.QueryLearner.ofAdaptive Q H is the learner asking these queries in turn, a decision tree of depth q (UniformLearning.QueryLearner.queriesAtMost_ofAdaptive). Run on a target f, it outputs H of the answers of f (UniformLearning.QueryLearner.eval_ofAdaptive, UniformLearning.QueryLearner.answersUpTo).

A learner has an adaptive circuit of size S with q queries (UniformLearning.QueryLearner.HasAdaptiveCircuit) when, on every seed, each query is computed from the earlier answers by a De Morgan circuit, and the hypothesis at x from all answers followed by x, with at most S gates in all. The queries do not depend on x: as in UniformLearning.QueryLearner, the learner outputs a hypothesis. This is learning by circuits with adaptive membership queries, the adaptive counterpart of UniformLearning.QueryLearner.HasCircuit, which is the special case of constant queries (UniformLearning.QueryLearner.HasCircuit.hasAdaptiveCircuit). Such a learner agrees with one making at most q queries (UniformLearning.QueryLearner.HasAdaptiveCircuit.exists_queriesAtMost). The other model of adaptive queries in the library is the oracle circuit of CslibFrontier.Computability.Circuit.Boolean.Oracle, one circuit whose oracle gates take arguments computed from the answers of other oracle gates; UniformLearning.QueryLearner.HasCircuit.exists_oracleCircuit turns a non-adaptive learner with a circuit into one. Here the queries and the hypothesis are separate circuits, so that the answers can be read from a truth table, and no adaptive counterpart of that bridge is proved.

Reading the answers from a truth table T of 2 ^ n entries costs at most the gates of the queries plus 2 ^ n (2 n + 3) + 1 gates per query, for selecting the entry at the computed address (UniformLearning.QueryLearner.complexity_append_answers_le). This bounds the circuits that test a learner on truth tables in CslibFrontier.MachineLearning.UniformLearning.CryptoHardness.Circuit.

The size counts the circuits of the queries and of the hypothesis separately, so gates shared between them are counted once for each; neither depth nor running time is certified.

Main definitions #

Main results #

def Cslib.MachineLearning.UniformLearning.QueryLearner.answersUpTo {ι : Type u_1} {q : ℕ} (Q : (i : Fin q) → (Fin ↑i → Bool) → ι → Bool) (f : (ι → Bool) → Bool) (k : ℕ) :
k ≤ q → Fin k → Bool

The answers of the target f to the first k adaptive queries Q: the query Q i maps the answers to the queries before it to the point queried next.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.answersUpTo_const {ι : Type u_1} {q : ℕ} (pts : Fin q → ι → Bool) (f : (ι → Bool) → Bool) (k : ℕ) (hk : k ≤ q) :
answersUpTo (fun (i : Fin q) (x : Fin ↑i → Bool) => pts i) f k hk = fun (j : Fin k) => f (pts (Fin.castLE hk j))

The answers to constant queries are the values at the queried points.

def Cslib.MachineLearning.UniformLearning.QueryLearner.adaptiveTree {ι : Type u_1} {q : ℕ} {β : Type u_3} (Q : (i : Fin q) → (Fin ↑i → Bool) → ι → Bool) (H : (Fin q → Bool) → β) (r k : ℕ) :
k + r = q → (Fin k → Bool) → DecisionTree (ι → Bool) β

The decision tree asking the remaining r adaptive queries after the answers a to the first k, then outputting H of all q answers.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.eval_adaptiveTree {ι : Type u_1} {q : ℕ} {β : Type u_3} (Q : (i : Fin q) → (Fin ↑i → Bool) → ι → Bool) (H : (Fin q → Bool) → β) (f : (ι → Bool) → Bool) (r k : ℕ) (h : k + r = q) :
(adaptiveTree Q H r k h (answersUpTo Q f k ⋯)).eval f = H (answersUpTo Q f q ⋯)

Run on f after the answers of f to the first k queries, the tree outputs H of all the answers of f.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.depth_adaptiveTree_le {ι : Type u_1} {q : ℕ} {β : Type u_3} (Q : (i : Fin q) → (Fin ↑i → Bool) → ι → Bool) (H : (Fin q → Bool) → β) (r k : ℕ) (h : k + r = q) (a : Fin k → Bool) :
(adaptiveTree Q H r k h a).depth ≤ r

The tree asking r more queries has depth at most r.

def Cslib.MachineLearning.UniformLearning.QueryLearner.ofAdaptive {ι : Type u_1} {Ω : Type u_2} {q : ℕ} (Q : Ω → (i : Fin q) → (Fin ↑i → Bool) → ι → Bool) (H : Ω → (Fin q → Bool) → (ι → Bool) → Bool) :

The adaptive learner: on the seed ω, it asks the queries Q ω, each computed from the answers to the earlier ones, and outputs the hypothesis H ω of all q answers.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.eval_ofAdaptive {ι : Type u_1} {Ω : Type u_2} {q : ℕ} (Q : Ω → (i : Fin q) → (Fin ↑i → Bool) → ι → Bool) (H : Ω → (Fin q → Bool) → (ι → Bool) → Bool) (f : (ι → Bool) → Bool) (ω : Ω) :
(ofAdaptive Q H ω).eval f = H ω (answersUpTo (Q ω) f q ⋯)

Run on f, the adaptive learner outputs the hypothesis of the answers of f.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.queriesAtMost_ofAdaptive {ι : Type u_1} {Ω : Type u_2} {q : ℕ} (Q : Ω → (i : Fin q) → (Fin ↑i → Bool) → ι → Bool) (H : Ω → (Fin q → Bool) → (ι → Bool) → Bool) :

The adaptive learner makes at most q queries.

An adaptive learner computed by small circuits: on every seed ω, the i-th query is computed from the answers to the earlier queries by a De Morgan circuit, and the hypothesis at x from all q answers followed by x, with at most S gates in all. Exposed: clients build and take apart the witnesses.

theorem Cslib.MachineLearning.UniformLearning.QueryLearner.HasAdaptiveCircuit.exists_queriesAtMost {n q S : ℕ} {Ω : Type u_1} {A : QueryLearner (Fin n) Ω} (hA : A.HasAdaptiveCircuit q S) :
∃ (B : QueryLearner (Fin n) Ω), B.QueriesAtMost q ∧ ∀ (ω : Ω), (B ω).eval = (A ω).eval

A learner with an adaptive circuit agrees with a learner making at most q queries.

Non-adaptive learners are adaptive. A learner with q non-adaptive queries and a circuit of S gates has an adaptive circuit of S + 2 q gates: each fixed query is a constant, of two gates.

Reading the answers from a truth table. Computing, from the truth table T of a target on n bits, the table followed by the answers of the target to the adaptive queries Q costs at most the gates of the queries plus 2 ^ n (2 n + 3) + 1 gates per query, for selecting the entry at the computed address.