90 likes | 216 Views
Incrementalization across object abstraction Lecture 12. Ras Bodik CS294-2 Software Synthesis Spring 2006. Administrativia . Project proposals were due two days ago Summaries continue posting them also to pl.newsdog.info. Example: spec. class Protocol signals: set(Signal)
E N D
Incrementalization across object abstractionLecture 12 Ras BodikCS294-2 Software Synthesis Spring 2006
Administrativia • Project proposals • were due two days ago • Summaries • continue posting them also to pl.newsdog.info
Example: spec class Protocol signals: set(Signal) threshold: float addSignal(signal): signals.add(signal) findStrongSignals(): return { s in signals | s.getStrength() > threshold } class Signal strength: float setStrength(v): strength = v getStrength(): return strength
class Protocol signals: set(Signal) strongsignals: set(Signal) threshold: float setting threshold … stringsignals = { s | signal.getStrength() > threshold} addSignal(signal): signals.add(signal) if signal.getStrength() > threshold strongsignals.add(signal) findStrongSignals(): return strongsignals class Signal strength: float protocols: set(Protocols) setStrength(v): strength = v foreach p in protocols if p.threashold < strength then p.strongsignals.add(this) else p.strongsignals.remove(this) getStrength(): return strength
class Protocol signals: set(Signal) strongsignals: set(Signal) threshold: float addSignal(signal): signals.add(signal) signal.registerProtocol(this) if signal.getStrength() > threshold strongsignals.add(signal) findStrongSignals(): return strongsignals class Signal strength: float protocols: set(Protocols) registerProtocol(p): protocols.registerProtocol(p) setStrength(v): strength = v foreach p in protocols if p.signals.contains(this) if p.strongsignals.contains(this) if not p.threashold < strength p.strongsignals.remove(this) else if p.threashold < strength p.strongsignals.add(this) getStrength(): return strength
class Protocol signals: set(Signal) strongsignals: set(Signal) threshold: float addSignal(signal): signals.add(signal) signal.registerProtocol(this) if signal.getStrength() > threshold strongsignals.add(signal) findStrongSignals(): return strongsignals updateSignal(signal): if signals.contains(signal) if strongsignals.contains(signal) if not threashold < signal.getStrength() strongsignals.remove(signal) else if threashold < signal.getStrength() strongsignals.add(signal) class Signal strength: float protocols: set(Protocols) registerProtocol(p): protocols.registerProtocol(p) setStrength(v): strength = v foreach p in protocols p.update(this) getStrength(): return strength
Rules for set comprehension inv r = { v in s | e } O(|s| x cost(e)) if vars(e) {v, this} at s = new set() O(1) do r = new set() O(1) at s.remove(x) O(1) do if e[vx] r.remove(x) O(cost(e)) at s.add(x) O(1) do if e[vx] r.add(x) O(cost(e)) at s.add(x) if type(s) = set(C), C != Cq, and there is an update to a field in C do x.takeCq(this) O(1)
Rules for set comprehension (2) inv r = { v in s | e } O(|s| x cost(e)) if vars(e) {v, this} at update if s is a field of Cq, type(s) = set(Cu), != Cq {v,f: v in s} readq and writeq = {this.f} de in Cu cqs: set(Cq) takeCq(cq): cqs.add(cq) in Cq updateCu(x): if s.contains(x) if r.contains(x) if not e[vx] r.remove(x) else if e[vx] r.add(x)
Where do rules come from? • For complex computations • manual rule development is difficult • at least as much as manual incrementalization • Issues • described system does not verify correctness of rules • Solution (outside scope of paper) • automatic rules creation • computation rules (applicable to similar comp’s) • works for a class of programs • done for set comprehensions