Skip to content

abc claims the aig is empty starting with version 6.1.7 #121

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

Closed
jbroot opened this issue Feb 2, 2021 · 14 comments
Closed

abc claims the aig is empty starting with version 6.1.7 #121

jbroot opened this issue Feb 2, 2021 · 14 comments
Assignees

Comments

@jbroot
Copy link

jbroot commented Feb 2, 2021

Step 1: write aig to file with aig.write(file) (pyaiger function)
Step 2: convert ascii aig to binary aig with aigtoaig
Step 3: read binary aig with abc
abc claims the aig is an empty network. These same steps worked in pyaiger version 6.1.6
using Python 3.8

@mvcisback mvcisback self-assigned this Feb 6, 2021
@mvcisback
Copy link
Owner

Hi @jbroot ,

Sorry about that. I recently rewrote the parser/writer to not use a PEG grammar due to performance issues.

Looking at the commits, I think this was what changed in 6.1.7.

Do you have a small executable example I could use to reproduce the regression?

In particular, I'm curious what aag is output for 6.1.6 vs latest py-aiger version.

@jbroot
Copy link
Author

jbroot commented Feb 6, 2021

Sure, here is my smallest file that produces the error.
Note: abc and aigtoaig must be installed and symlinked inside /bin/ or /usr/bin/ or the equivalent of your OS. Ubuntu 20.04 with Python 3.8 was used for this error.

xorAigs.txt

@jbroot
Copy link
Author

jbroot commented Feb 6, 2021

Exact abc error:

ABC command line: "read /tmp/a06d4685-a7f3-478c-be1e-6032cbabac03bin.aig; show".
The number of objects does not match.
Reading AIG from file has failed.
Error: Empty network.

Here are the contents of the /tmp/...aig file:

aig 10 2 0 1 7
19

i0 a
i1 b
o0 out

@mvcisback
Copy link
Owner

Thanks!

I will look into reproducing and extracting a regression test later today.

@mvcisback
Copy link
Owner

mvcisback commented Feb 8, 2021

So I've confirmed that this occurs. No need to get abc involved. The problem seems to be with the following aag:

aag 9 2 0 1 6
2
4
17
6 4 2
8 7 4
10 5 2
12 10 9
14 7 4
16 15 13
i0 a
i1 b
o0 out

aigtoaig succeeds into going from aag to aig, but when converting back it declares

*** [aigtoaig] line 2: invalid maximal variable index

I don't readily see the problem, but I'll look into it more later today.

@mvcisback
Copy link
Owner

I wrote out the corresponding circuit by hand it seems fine to me.

One thing I noticed is that aigtoaig outputs a weird file.

Namely, it has a header:

aig 20 2 0 1 6

compared to the input header

aag 9 2 0 1 6

AFAIK aigtoaig checks the AIG is well formed when taking it in so I think this is a bug with aigtoaig.

@mvcisback
Copy link
Owner

I will report this to Armin Biere.

@jbroot if you can confirm that this is a correct AAG file, please let me know.

@jbroot
Copy link
Author

jbroot commented Feb 8, 2021 via email

@jbroot
Copy link
Author

jbroot commented Feb 8, 2021

So I've confirmed that this occurs. No need to get abc involved. The problem seems to be with the following aag:

> aag 9 2 0 1 6
> 2
> 4
> 17
> 6 4 2
> 8 7 4
> 10 5 2
> 12 10 9
> 14 7 4
> 16 15 13
> i0 a
> i1 b
> o0 out

I changed the maximum variable index from 9 to 8 since all ANDs and inputs are used and 8 = I+L+A. aigtoaig and ABC accepted this change and would not allow the prior. The xorComplex produced in 6.1.6 had header 9 2 0 1 7. All AND gates and inputs were used and 9 = 2 + 0 + 7.

@mvcisback
Copy link
Owner

@jbroot I think you may have flipped >= and <=.

I believe the spec is supposed to be M >= I + L + A with equality only being a restriction on the binary format. M <= I + L + A wouldn't make sense since then you couldn't handle unused inputs.

This constraint is supposed to be checked at runtime in py-aiger.

The thing that I'm worried about is that aigtoaig is generating:

aig 20 2 0 1 6

Thus it is violating this equality constraint. In implementing the new parser/writer, I added infrastructure to soon support the binary format. What I'm thinking might be happening is that there is a weird code path being triggered since the aag input almost matches what needs to happen in the aig output.

@mvcisback
Copy link
Owner

So the 20 was my fault when messing with aigtoaig, but I think this is indeed a bug.

This aag doesn't work

aag 9 2 0 1 6
2
4
17
6 4 2
8 7 4
10 5 2
12 10 9
14 7 4
16 15 13
i0 a
i1 b
o0 out

But this one does

aag 9 2 0 1 6
2
4
17
6 2 4 <--------------------- This line changed. Flipped 4 and 2.
8 7 4
10 5 2
12 10 9
14 7 4
16 15 13
i0 a
i1 b
o0 out

I think there's an optimization to avoid recomputing the header if the body corresponds with the body for an aig.

@mvcisback
Copy link
Owner

regarding py-aiger, I think the simplest fix is to force the equality constraint. Will apply patch soon.

@mvcisback
Copy link
Owner

@jbroot

The latest version of py-aiger should have a tight literal count.

If this works for you please close the issue.

Also, if you're using py-aiger in any academic work, please use the citation at the bottom of the README :)

@mvcisback
Copy link
Owner

Armin Biere responded and added it on the TODO for AIGER :)

Closing.

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

No branches or pull requests

2 participants