570 likes | 737 Views
Playing with Time and Space in Circuits and Programs. Gérard Berry Collège de France Chaire Algorithmes, machines et langages. PPS, 24/04/2013. Agenda. 2-adic numbers and space / time exchange in synchronous circuits Never determinize non-deterministic automata !
E N D
Playing with Time and Spacein Circuits and Programs Gérard Berry Collège de France Chaire Algorithmes, machines et langages PPS, 24/04/2013
Agenda • 2-adic numbers and space / time exchange in synchronous circuits • Never determinize non-deterministic automata ! • Use hierarchical automata for another exponential gain in space and timing optimization G. Berry, PPS,
Agenda • 2-adic numbers and space / time exchange in synchronous circuits • Never determinize non-deterministic automata ! • Use hierarchical automata for another exponential gain in space and timing optimization G. Berry, PPS,
Source of the 2-adic Part J. Vuillemin. On circuits and numbers, IEEE Trans. on Computers, 43:8:868-79, 1994 G. Berry, PPS,
2-adic Numbers (Hensel, ~1900) • R is a completion de Q. Is it the only one ? • No : p-adic numbers for p prime • infinite numbers written low-order bits first • Beautiful, but physical ? cf. Matière à Pensée, p. 32 • Alain Connes / JP Changeux • Jean Vuillemin : 2-adiques integers are the right model • Jean Vuillemin : of arithmetic digital circuits • Jean Vuillemin : Let us create their physics! 2-adic numbers unify computable arithmetic with Boolean logic G. Berry, PPS,
2Z : the Ring of 2-adic Numbers x 2x0x1x2… low-order bits first operations and from left to right 0200000... 2(0) 1210000... 21(0) 2201000... 201(0) 1211111... 2(1) 2201111... 20(1) x 2101010...2(10) y 2010101... 2(01) x2100000... 2001010... y 2x or x y 1 x14x x 1/3 y 2/3 G. Berry, PPS,
2Z : the Ring of 2-adic Numbers p/q exists for all integer p, q iff q est odd (cf. Euclide) 1/2 does not exist because x0x0cannot have value 1 No order compatible with the operations 1 0 1 G. Berry, PPS,
2Z as a Boolean Algebra • 2-adic x seen as the set {i|xi1 } • example:1/3 2101010... { i|ieven } • pointwise Boolean operations • x yx y x • (x y)n xnynetc. • Fundamental arithmetico-logical equality : 2100011... x x 1 2011100... 2111111... G. Berry, PPS,
Cantor Metric Space d(x,x) 0 d(x,y) 2nn minimal s.t. xnyn Example: d(201111..., 201101... 1/8) • Lemma :2Z isultrametric : • d(x,z) max(d(x,y),d(y,z)) x y z d(x,z) min(d(x,y),d(y,z)) G. Berry, PPS,
Cantor Metric Space • Open set basis : finite prefixes • x0x1...xn {2x0x1...xny0y1...yn...| y2Z} ex.: open set for 210010 1 1 0 0 0 • Compact – very different from reals ! G. Berry, PPS,
Continuous functions Lemma :f: 2Z 2Z continuous iff f(x)ndepends on a finite number of xm 2x0x1......xm... 2y0y1...yn... Continuity preservation of information finiteness G. Berry, PPS,
Synchronous Functions f(x) x 0x0x1...xn... x0x1...xn... G. Berry, PPS,
Synchronous and Contracting Functions f(x) x • Definition :f: 2Z 2Z synchronous iff computable by a synchronous circuit (with finite or infinite memory) • Theorem :f: 2Z 2Z is synchronous iff f(x)n only depends on x0x1...xn, i.e., iff f is contracting x,y. d(f(x),f(y)) d(x,y) Preuve : « only if » trivial, Preuve : for « if » see SDD construction later on G. Berry, PPS,
Moore Circuits and Strict Contraction • A Moore synchronous circuit is such that any wire between an input and an output traverses a register Moore Circuit • A function f: 2Z 2Z is strictly contracting • iff f(x)n only depends on x0x1...xn1 x,y. d(f(x),f(y)) d(x,y) Theorem : a function is computable by a Moore circuit if and only if it is contracting G. Berry, PPS,
Feedbacks in Moore Circuits are Legal Moore Circuit f(x) x G. Berry, PPS,
Feedbacks in Moore Circuits are Legal Moore Circuit f(x) x f(x) x,y. d(f(x),f(y)) d(x,y) x,y. d(f(x),f(y)) 0,6 d(x,y) Lipschitz Banach theorem:any Lipschitzian function over a compact set has a unique fixpoint G. Berry, PPS,
+ + Full Adder s a xor a s b b r c c and r bits and or and s axorbxorc r (a and b) or (b and c) or (c and a) G. Berry, PPS,
r r = 0 s + + 1 0 0 + + a b s r 2 1 1 1 a b r s 3 2 2 2 Addition in Space + a 0 + b s ab but within infinite time! 0 continuity: cut at n bits for n output bits x2n x mod 2n s2n1 a2nb2n G. Berry, PPS,
+ + Full Adder s a xor a s b b r c c and r bits and or abc s2r and s axorbxorc r (a and b) or (b and c) or (c and a) G. Berry, PPS,
+ + Basic 2-adic Operators a s abc s2r b r c 20x0x1...xn... 2x0x1...xn... 2x0x1...xn... x 12x x 2x 21x0x1...xn... G. Berry, PPS,
s s Addition and Subtraction Over Time a a + + b b + + 2r r r 12r ab2r s2r ab12r s2r bb 1 s ab b1 b same equation as over space! ab s tick ! s ab G. Berry, PPS,
Mixed Space / Time Addition a aeao x y 2x0y0x1y1... ao ae se so + + be bo re + + b be bo s se so tick ! s ab 2ro ro still the same equation ! Same source code for any space / time tradeoff G. Berry, PPS,
s Stereo Addition a + b + se so (aebe)(ao bo) r stereo adder Alternates 2 additions over time (even / odd bits) stereo left / right channels G. Berry, PPS,
s s Addition and Subtraction Over Time a a + + b b + + a a s s b b tick ! G. Berry, PPS,
x 3x x _ y x/3 Multiplication and division by a constant proof : x2x 3x proof : yx2y division only by odd integers! G. Berry, PPS,
Quasi-inverse y1/(12x) y2xy 1 y12xy ? x y12xy1/(12x) contracting synchronous but infinite memory (cf. SDD construction) G. Berry, PPS,
x z y Quasi Square Root y 18x ... but tells us nothing about bit transformations! y 14z y2 18z16z2 zx2z2 y2 18x16z216z2 G. Berry, PPS,
Spatio-Temporal Decomposition of f Synchronous f0 first bit output by f for inputs 0... f1 ... 1... fw last bit output by f for the finite word w f00-predictor : f0w=f(w0) for any word w f11-predictor : f1w=f(w1) fuu-predictor : fuw=f(wu) for any words w,u G. Berry, PPS,
x 3x + Automaton of x 3x 0/0 1/1 00 10 0/1 0/1 1/0 0/0 01 11 1/0 1/1 G. Berry, PPS,
x 3x + Predictor0 of x 3x 0/0 0/0 0/ 1/1 1/ 1/1 00 00 10 10 0/1 0/ 0/0 0/1 0/0 0/ 1/0 1/ 1/0 0/0 0/1 0/ 01 11 01 11 1/0 1/0 1/ 1/1 1/ 1/0 G. Berry, PPS,
x f1 1 f(x) 0 f0 SDD Decomposition Step f(x) = mux(x, f12f1(x), f02f0(x)) f1 f0 G. Berry, PPS,
x f11 f11 1 x f10 f10 0 f1 1 f1 f(x) x f0 0 f0 f01 f01 1 f00 0 f00 SDD Space/Time Normal Form of f ... ... ... ... Truth-table in space and time ultra-fast : critical path one mux Half of the bits disappear at each cycle G. Berry, PPS,
x f11 f11 1 x f10 f10 0 1 f1 f1 f(x) x f0 0 f0 f01 f01 1 f00 0 f00 Shared SDD of f with Finite Memory ... ... ... ... f finite memory finitely many distinct predictors fu n f with n registers SDD(f) may have22registers G. Berry, PPS,
From continuous functions to circuits • f continuous but not synchronous: • over space : trivial if infinite space • over time : expand the time • 2-adic number : < value, validity > • 0 0 1 0 1 1 0 1 1 1 0 0 ... • 0 1 1 0 0 1 1 0 0 1 1 0 ... • 0 1 1 0 1 Theorem : every continuous function can be realized by a synchronous circuit with validity G. Berry, PPS,
Trace of a Synchronous Function Tr(f) 2f0f1f00f01 f10f11f000f001... f02f14(Tr(f0) ʘ Tr(f1 )) Application of a trace Tr(f) to an argument x is continuous calculus ? Power series over Z/2Z : S(f) = nTr(f)nzn Theorem :f:2Z 2Zsynchronous has finite memory iff S(f) is algebraic over Z/2Z G. Berry, PPS,
From Synchronous Traces to Transcendental Numbers Theorem (Van der Porten) : if f has finite memory, them the real number 0, f0f1f00f01 f10f11f000f001... is either rational or transcendantal Almost any finite automaton generates a transcendental number! Automatic Sequences: Theory, Applications, Generalizations Jean-Paul Allouche et Jeffrey Shallit Cambridge University Press (21 juillet 2003) G. Berry, PPS,
Conclusion Thanks to Jean Vuillemin • 2-adic numbers are the good model of arithmetic synchronous circuits (only?) • the 2-adic metric, continuity, and synchronism are fundamental notions to explore further • The structure of the predictor space is largely unknown • The relation between continuous functions and validity-circuits remains to be studied (calculus?) G. Berry, PPS,
Agenda • 2-adic numbers and space / time exchange in synchronous circuits • Never determinize non-deterministic automata ! • Use hierarchical automata for another exponential gain in space and timing optimization G. Berry, PPS,
From Deterministic Automata to Circuits b b e0 e2 a a 1-hot encoding (only one ri to 1) size explosion! b b (ab+b)*ba e1 e3 r0 r2 b b b b r1 ok a a r3 G. Berry, PPS,
The Non-Deterministic Case b s0 s1 s2 s3 • no size explosion • much better! b (ab+b)*ba a a b b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s3 s2 s1 b (ab+b)*ba a a b a b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s1 s2 s3 tick! b (ab+b)*ba a a b a b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s1 s2 s3 b (ab+b)*ba a a b ab b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s1 s2 s3 tick! b (ab+b)*ba a a b ab b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s1 s2 s3 b (ab+b)*ba a a b abb b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s1 s2 s3 tick! b a a b abb b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s1 s2 s3 b (ab+b)*ba a a b abba b b b ok a a G. Berry, PPS,
Electrical Subset Construction b s0 s1 s2 s3 tick! b (ab+b)*ba a a b abba b b b ok a a G. Berry, PPS,
Esterel v7 implementation b module Autom : input a, b; output ok; local{r0, r1, r2, r3} : reg; refine r0 : init true; sustain { next r0 <= (r0 or r1) and b, next r1 <= r0 and a, next r2 <= r0 and b, next r3 <= r2 and a, ok<= next r3 } end module s0 s1 s2 s3 b a a b Compiled into C, C++, VHDL, Verilog, etc. G. Berry, PPS,
Agenda • 2-adic numbers and space / time exchange in synchronous circuits • Never determinize non-deterministic automata ! • Use hierarchical automata for another exponential gain in space and timing optimization G. Berry, PPS,