Code Monkey home page Code Monkey logo

pyeda's People

Contributors

alexwebr avatar asishm avatar balsaad avatar cjdrake avatar danjujan avatar functionpointer avatar fzanollo avatar harnesser avatar jaepil avatar jeffbiggers avatar kitaniboy avatar nadiahpk avatar shader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyeda's Issues

Cannot use weakref for expression restrict cache

Recently looked at using weakref.WeakValueDictionary for the Expression.restrict cache, but it didn't work b/c it cannot be used to store integers. Unfortunately, when doing expression simplification, I am using the actual integer 0 and 1 values, which are not of the same type as of expression arguments.

I think maybe it's time to revert back to having an expression Constant implementation. The ZERO and ONE objects should be singletons. I think the reason I got rid of this in the past was that I wanted the actual return value to be an integer, not some weird expression object that the user wouldn't know what to do with. In other words, "x * -x" should just return 0, not ExpressionConstantZero or whatever.

To solve the problem, similar to BDD, expression functions should "exprify" their inputs, and "constify" their outputs. This leads to a very interesting possibility of actually parsing much more elaborate expressions written using strings, rather than just 0 and 1.

This would have the added benefit of making the type of all expression objects consistent, and uniform. I doubt PyPy or some other JIT would approve of using integers the way I'm using them.

DIMACS parsing should also return AST

Similar to pyeda.parsing.boolexpr, the DIMACS formats shouldn't directly return Expression instances. CNF should return a tuple of tuple of ints, and SAT should return an AST.

Add a simplify=True/False parameter to Expression constructors

Profiling shows that expression construction does lots of redundant computation simplifying expressions. Need to enable a method to construct the entire tree, then run a simplify operation once in a top-down manner.

First thought is that if you have And(..., simplify=True) as the default, then that will be good for interactive use, but you can use And(..., simplify=False) to just save simplification for later by calling F.simplify() or simplify(F).

pos/neg unate methods busted

In Expression, checking the inputs looks for boolfunc.Function. Should be Expression. The unate methods are not implemented by Table representations.

The table implementation of this method seems straight-forward. Not sure if the expression algorithm of using min/max terms makes any sense. Need to look this one up.

Reorganize code

I'm definitely mixing several unrelated things in the current repository structure.

Possible future organization:

pyeda/
    __init__.py
    util.py
    boolalg/
        __init__.py
        alphas.py
        bdd.py
        boolfunc.py
        expr.py
        nfexpr.py
        table.py
        vexpr.py
    logic/
        __init__.py
        addition.py
        floatingpoint.py
        graycode.py
        multiplication.py
        sudoku.py
        ...
    parsing/
        dimacs.py
        verilog.py
        ...

Some notes:

  • Not sure where to put satisfiability. Might make sense in boolalg, but that's a lot of nesting, and I think SAT can stand on its own--it's so important. Would be nice to integrate several SAT algorithms.
  • After integrating some fast SAT solvers written in C/C++, I think the nfexpr type can go away. It's a neat function representation, but cannot possibly implement the full boofunc interface.

TruthTable.inputs (and support) uses Expression type

There's no reason for other Function implementations to use an Expression as the Variable implementation.

A table implementation of a variable is just a one-bit table with a label. A BDD implementation of a variable is just a Node with low=0 and high=1. And so on...

The binop.apply2 method behaves unexpectedly as a result of this (among other things).

Probably expr.py, table.py, bdd.py, etc will each require their own "Variable" class. Considering we already duplicate that name between boolfunc.py and expr.py, probably a good idea to change the class name to ExprVariable, TableVariable, BDDVariable, etc.

Drop imports from pyeda package

Recently saw a problem with this in pyeda/__init__.py:

from pyeda.expr import (..., expr, ...)

Unfortunately, that actually replaces the pyeda.expr module with the pyeda.expr.expr function.

So probably the best solution is to just drop almost all imports, and require users to just import stuff explicitly.

Use "yield from" syntax

There are a few iterators that could make use of the cool yield from syntax introduced in Python 3.3. Need to deprecate Python 3.2.

Change Function.top back to first element of inputs

In "Synthesis and Optimization of Digital Circuits" by DeMicheli, page 80 he defines the top variable as "the first variable in the support set".

In "Logic Synthesis and Verification Algorithms" by Hatchel/Somenzi, on page 234 they define the top variable as "the variable with the lowest index".

In the last release I used the last variable in the ordered support, so that appears to have been a mistake. Maybe if there's a top variable, there can also be a bottom as well.

Normalize TypeError/ValueError messages

Should standardize the format of runtime input argument errors. Should be something like:

expected {type or value description} [, got {type or value description} ]

The 'got' part of the statement can be a bit annoying to produce sometimes, so optional.

Get rid of PCTable data type

After thinking about this, there isn't really any value to maintaining a truth table that uses only 0/1, and one that uses positional cube notation. The space savings is only 2x, and since truth tables are already exponential in size it seems a bit silly to maintain this for its compression purposes alone.

Better to expend more time thinking about and implementing an ImplicantTable implementation.

So get rid of TruthTable, and replace the PCTable with TruthTable.

Implement logic expression parser

Related to issue #24, it would be extremely useful to implement a general-purpose logic expression parser that can handle variable names in the form x.y.z[1][2][3], unary '-', and all the usual infix operators: '+', '-', '*', 'xor' , '=', '->'.

Consolidate expr2cnf and expr2dnf functions to expr2nfexpr

Only need a single function which determines whether the expression input is in DNF/CNF form, and then do the proper conversion automatically. The actual conversion is from "Expression" to "NormalFormExpression". Too easy to mistake cnf/dnf for an actual type, rather than just a format.

Default table format should be generic

Currently, the Table.str method assumes you want your table to be printed in Espresso format. A better implementation will make the str(F) method return a generic table, maybe something like RestructuredText. Then need another method that takes a 'fmt' parameter. Using fmt=None should return the generic string.

Add ITE operator

An if-then-else expression would be pretty awesome. Might have some practical use in the implementation of BDDs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.