Skip to content

Pentagon as value product#2465

Draft
schuler-henry wants to merge 4 commits into2451-interval-pentagon-ai-pentagon-inference-visitorfrom
pentagon-as-value-product
Draft

Pentagon as value product#2465
schuler-henry wants to merge 4 commits into2451-interval-pentagon-ai-pentagon-inference-visitorfrom
pentagon-as-value-product

Conversation

@schuler-henry
Copy link
Copy Markdown
Collaborator

No description provided.

Implemented closed pentagon domain as state domain of a closed-pentagon value domain that combines the interval value domain with a set domain representing the upper bounds.

public static top<Domain extends AnyAbstractDomain>(domain: Domain): StateAbstractDomain<Domain, StateDomainTop> {
return new StateAbstractDomain(new Map<NodeId, never>(), domain);
public static top<Domain extends AnyAbstractDomain, T extends StateAbstractDomain<Domain, StateDomainLift<Domain>>>(this: new (value: StateDomainTop, domain: Domain) => T, domain: Domain): T {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a more readable name for T, e.g. StateDomain?

Suggested change
public static top<Domain extends AnyAbstractDomain, T extends StateAbstractDomain<Domain, StateDomainLift<Domain>>>(this: new (value: StateDomainTop, domain: Domain) => T, domain: Domain): T {
public static top<Domain extends AnyAbstractDomain, StateDomain extends StateAbstractDomain<Domain>>(this: new (value: StateDomainTop, domain: Domain) => StateDomain, domain: Domain): StateDomain {

return new ClosedPentagonDomain({ interval: StateAbstractDomain.top(IntervalDomain.top()), upperBounds: UpperBoundsDomain.top() });
public override create(value: StateDomainLift<ClosedPentagonValueDomain>): this;
public override create(value: StateDomainLift<ClosedPentagonValueDomain>): ClosedPentagonDomain {
return new ClosedPentagonDomain(value, ClosedPentagonValueDomain.top());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return new ClosedPentagonDomain(value, ClosedPentagonValueDomain.top());
return new ClosedPentagonDomain(value, this.domain);

if(this._value !== Bottom) {
const valueWithoutNodeItself = value.create(value.value);
valueWithoutNodeItself.value.upperBounds.remove(node);
(this._value as Map<NodeId, ClosedPentagonValueDomain>).set(node, valueWithoutNodeItself);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe super.set(node, valueWithoutNodeItself)?

public static bottom(): ClosedPentagonDomain {
return new ClosedPentagonDomain({ interval: StateAbstractDomain.bottom(IntervalDomain.bottom()), upperBounds: UpperBoundsDomain.bottom() });
public override set(node: NodeId, value: ClosedPentagonValueDomain) {
if(this._value !== Bottom) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, prefer to use the getter this._value if you don't need to modify it

Suggested change
if(this._value !== Bottom) {
if(this.value !== Bottom) {

Comment on lines +39 to +40
const valueWithoutNodeItself = value.create(value.value);
valueWithoutNodeItself.value.upperBounds.remove(node);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just put this directly into the reduction ClosedPentagonDomain.reduce so that you do not have to do this separately. If not, I would at least outsource this into a helper function

Comment on lines +68 to +70
public override narrow(_other: this): this {
throw new Error('Not Implemented');
}
Copy link
Copy Markdown
Collaborator

@OliverGerstl OliverGerstl Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would at least call super.narrow so that we do not have to adapt this code when narrowing is supported later

Comment on lines +56 to +66
public override join(other: this): this {
return this.create(super.join(other).value);
}

public override meet(other: this): this {
return this.create(super.meet(other).value);
}

public override widen(other: this): this {
return this.create(super.widen(other).value);
}
Copy link
Copy Markdown
Collaborator

@OliverGerstl OliverGerstl Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently a bit inefficient, as we call create two times every time we are joining two states which copies the whole mapping

Comment on lines +72 to +77
public override concretize(_limit: number): ReadonlySet<ConcreteState<ClosedPentagonValueDomain>> | typeof Top {
if(this.value === Bottom) {
return new Set();
}
return Top;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to override this?


(value.upperBounds.value as Map<NodeId, ReadonlySet<NodeId>>).set(key, newUpperBounds);
public override isTop(): this is this & StateAbstractDomain<ClosedPentagonValueDomain, StateDomainTop> {
return this.value !== Bottom && this.value.values().every(pentagon => pentagon.value.interval.isTop() && pentagon.value.upperBounds.isTop());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the correct Top representation here.
Because, if you have a node for which you inferred Top in the inferval/upper bounds domain, you at least inferred that it is a number.
This contains more information than an empty map where you have no information about any node.
I think you don't need to override the isTop check here (your implementation of this.top is also the same as for the state domain)

return this.value !== Bottom && this.value.values().every(pentagon => pentagon.value.interval.isTop() && pentagon.value.upperBounds.isTop());
}

public static reduce(value: StateDomainLift<ClosedPentagonValueDomain>): StateDomainLift<ClosedPentagonValueDomain> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be public?

}

public static top(): ClosedPentagonValueDomain {
return new ClosedPentagonValueDomain({ interval: IntervalDomain.top(), upperBounds: UpperBoundsValueDomain.top() as UpperBoundsValueDomain });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

significant why?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bottom carries them but top does not yet carry the sign-figures

Replaced the visitor call with a callback that resolves the interval for a node id to make the function mapper visitor independent to be reused in the pentagon semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants