Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: symmetry in nested predicates #1069

Merged
merged 2 commits into from Jul 22, 2022
Merged

Conversation

liangyiliang
Copy link
Contributor

@liangyiliang liangyiliang commented Jul 22, 2022

Description

Related issue/PR: #1068

This PR fixes the bug listed in #1068: that symmetric predicates does not match if it appears within a nested predicate.

Implementation strategy and design decisions

Previously, we only check the symmetry of the outer-most predicate. In the case of matching Not(Bond(A, B)) against Not(Bond(B, A)), we only check the symmetry of Not, and then it compares Bond(A, B) and Bond(B, A) without ever considering symmetry. The fix essentially applies this symmetric consideration on all levels of the predicate recursively.

A test case has also been added to consider this case.

Examples with steps to reproduce them

-- dsl
type Atom
type Hydrogen <: Atom
type Oxygen <: Atom
symmetric predicate SBond( Atom a1, Atom a2 )
predicate Not(Prop)

-- sty
canvas {
    width = 50
    height = 40
}

forall Hydrogen h; Oxygen o
where Not(SBond(o, h)) {
    myText = Text {
        string: "Hello"
    }
}

-- sub
Hydrogen H
Oxygen O
Not(SBond(H, O))

This now prints "Hello" on the screen because it successfully matched Not(SBond(O, H)) against Not(SBond(H, O)). Previously, nothing is printed.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new ESLint warnings
  • I have reviewed any generated changes to the diagrams/ folder

@cloudflare-pages
Copy link

cloudflare-pages bot commented Jul 22, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 97f60dc
Status: ✅  Deploy successful!
Preview URL: https://9af5a2a5.penrose-72l.pages.dev
Branch Preview URL: https://symmetry-nested-predicates.penrose-72l.pages.dev

View logs

@codecov
Copy link

codecov bot commented Jul 22, 2022

Codecov Report

Merging #1069 (b23375b) into main (de83edf) will increase coverage by 0.03%.
The diff coverage is 90.47%.

❗ Current head b23375b differs from pull request most recent head 97f60dc. Consider uploading reports for the commit 97f60dc to get more accurate results

@@            Coverage Diff             @@
##             main    #1069      +/-   ##
==========================================
+ Coverage   64.23%   64.27%   +0.03%     
==========================================
  Files          59       59              
  Lines        7362     7361       -1     
  Branches     1655     1654       -1     
==========================================
+ Hits         4729     4731       +2     
+ Misses       2624     2621       -3     
  Partials        9        9              
Impacted Files Coverage Δ
packages/core/src/compiler/Style.ts 68.32% <90.47%> (+0.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de83edf...97f60dc. Read the comment docs.

@liangyiliang liangyiliang changed the title fix: symmetry in nested predicates [WIP] fix: symmetry in nested predicates Jul 22, 2022
@liangyiliang liangyiliang marked this pull request as ready for review July 22, 2022 15:02
@joshsunshine joshsunshine self-requested a review July 22, 2022 15:07
@liangyiliang liangyiliang merged commit 7d0d4bf into main Jul 22, 2022
@liangyiliang liangyiliang deleted the symmetry-nested-predicates branch July 22, 2022 15:10
@liangyiliang liangyiliang linked an issue Jul 22, 2022 that may be closed by this pull request
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.

Symmetry in nested predicates
2 participants