Tool to refactor boolean expressions [closed] - refactoring

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm looking for a tool to refactor boolean expression. I've got expressions like
a1 => (b1 <=> c or d) AND
a2 => (b2 <=> c or d) AND
a2 => (b2 <=> c or d)
The tool should be able to simplify expressions, e.g. extract the sub expression "c or d" in the example above. Is there a free computer algebra system which can do this?
Currently I think of refactoring the expressions manually an prove the equivalence with a little haskell quickcheck script.

I'm not sure about a tool but take a look at Boolean Algebra
you can draw a grid of all the inputs and output to try and find a minimal boolean expression

The DMS Software Reengineering Tookit could do this.
It is generalized compiler technology for parsing languages (including Java) to ASTs and symbol tables. DMS also provides source-to-source transformations, and associative and commutative law rewriting.
Your boolean expressions would show up as Java AST expression trees.
By providing a set of rules about boolean algebra, you can manipulate
those expression trees.
We have done this in the past to carry out boolean expression simplification and transformation for C, RLL and a system of diagnostic equations, both on large scale expressions, and on lots of medium scale expressions (scale much like your example).
EDIT 5/19/2010: See an example of conventional algebra transformations using DMS. Its trivial to construct a variant that does Boolean algebra instead.

Boolean Refactor and Simplification
This tool worked great for optimising complex boolean expressions.

Related

How to implement fully-declarative Horn logic? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I would like to formalize some knowledge and execute queries in what may referred to as fully-declarative Horn logic (or, fully-declarative Prolog). Could anyone provide some guidelines on how to implement it? I briefly recap the fine description from the link above:
The formal language is that of (the core of) Prolog: a "program" is a set of rules and facts as in Prolog (including functions and variables and basically, containing only user defined predicates).
In contrast to Prolog, however, I am looking for an implementation that is sound and complete with respect to the standard declarative semantics of logic programs --- the least Herbrand model (i.e., the inductively defined set of ground terms). In theoretical work on logic programming this is usually the object of study, and it is well known that a sound and complete answer to queries can be attained (in the "recursively-enumerable" sense), for example, using SLD-resolution subject to the following conditions:
fair search for matching rules (e.g., Prolog's depth-first search is not fair);
unification with "occurs-check" (checking that a variable doesn't occur in a term with which it is unified).
I am looking for a concise implementation that would build on existing capabilities, rather than inventing the wheel. Two of the more promising directions that I see are implementing it as a meta-interpreter of Prolog, or as part of some theorem prover. Could anyone with practical knowledge in these domains provide some guideline on how to implement it? Can it be easily implemented in miniKanren?
My intentions are to formalize some knowledge in a fully-declarative manner. The crucial characteristics of such a formalization is that it precisely corresponds to the mathematical notion of (monotone) induction, so that the knowledge and it's properties can be easily reasoned about with inductive arguments.
It is an easy exercise to implement a prover for Horn logic in a few lines of Prolog. Start with the Vanilla Meta-interpreter, then modify it to use the standard unify_with_occurs_check/2 predicate for all unifications, and to use a complete search procedure - iterative deepening depth first search is the simplest to implement.
See #mat's page A Couple of Meta-interpreters in Prolog for some inspiration.
More pointers:
Datalog has declarative semantics, but as a "Prolog without function symbols" it is not Prolog. See the excellent intro "What You Always Wanted to Know About Datalog (And Never Dared to Ask)" by Ceri, Gottlob and Tanca, 1989. Available via CiteSeerX
Implementations of Prolog that use tabling instead of depth-first search for added declarativeness (plus other nice features as I understand), like XSB.

How do define a metric in order to evaluate programmers? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Lets suppose we have programmer A,B,c . The quality is defined as the number of bugs/month and productivity as LOC/month. So we have programmer A with quality 2 and prod. 2500; programmer B with quality 5 and prod. 500 and programmer C with quality 25 and prod 200. How do I define a metric to evaluate which programmers is the best? I search over the internet for a method, but with no results in finding an example of how do i evaluate programmers. Can someone help me with this ? I would really appreacite
There is probably no standard way to deal with this. Because 1. there is no standard definition of which programer is the best, and if there were something close, 2. it would probably not rely on those metrics. So you are left with subjective choices here.
As mentioned in the question's comments, you have to be careful with the selected metrics because they don't respect the representation condition [ 1 ] (e.g. counter-examples can be found -- and there would be a lot in this very case). So don't believe you can judge developers on these metrics, that would be a big mistake and a flagrant counter-productive use of metrics, see [ 2 ] for more details.
However, I believe these metrics and implied subjective choices are still worth something, as long as you know to what extent they are valid. They still represent a value, and it is interesting to have them, and monitor them: as numbers, they might help understand some aspects of the development, too.
So maybe the answer proposed would be a visualisation-based one: plot them nicely (a bubble chart may be interesting, or good old bar charts) as metrics, not as high-level characteristics. You could also map them to a scale (difficult to define, though.) to get a normalised indicator (e.g. from 1 to 5) and build a tree like in PolarSys Dashboard.
[ 1 ] Fenton, N. (1994). Software Measurement: a Necessary Scientific Basis. IEEE Transactions on Software Engineering, 20(3), 199–206. doi:10.1109/32.268921
[ 2 ] Kaner, C., & Bond, W. P. (2004). Software engineering metrics: What do they measure and how do we know? Methodology, 8(6), 1–12.

Comparision of abstract machines for execution of Prolog [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I'm looking for research paper or any other publication that compare different abstract machines (more than one) for execution of Prolog with prolog interpreters not based on abstact machines. What I've seen so far is that majority of implementations seems to base their prolog interpreters on Warren Abstract Machine although other abstract machines were proposed (eg. Vienna Abstract Machine, Tree-Oriented Abstract Machine) and there is no any general comparision. I'm interested in comparision of efficiency (not features), although all compared interpreters should allow for constraint-logic programming.
You can build constraint logic programming on top of ordinary prolog
if you introduce some primitives for a trailed constraint store and
some primitives for unification hooks. E.g.:
SICStus Prolog: Attributed Variables
http://sicstus.sics.se/sicstus/docs/3.7.1/html/sicstus_17.html
Jekejeke Minlog: Little Solver
http://www.jekejeke.ch/idatab/doclet/prod/en/docs/15_min/10_docu/02_reference/04_examples/05_solver.html
http://www.jekejeke.ch/idatab/doclet/prod/en/docs/15_min/15_stdy/06_bench/10_examples/02_addensure/01_referensure.p.html
Of course you can view the additional primitives as new instructions
in the abstract machine. But in both cases above the primitives are
added on the predicate level, so that it begs the question whether there
is really a need for an abstract machine for constraint logic programming.
Of course you will find a couple of suggestions of constraint logic programming
abstract machines as well through google.
Bye

Any (free) tools to compute Taylor series expansion of a function? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
After painful trial and error, I arrived at a grotesque function that behaves the way I want it to:
(exp(- abs(6 * (x - 0.7)) ^ 2.5 ) + exp(- (x-1.7) ^ 8 ) * 1.2)/1.5785
I only care about the values for the range 0 <= x <= 1 and the slope at x = 1.
In this interval, 0 <= y <= 1 as well.
Are there any free tools (web-based or MAC OS X) that will generate the Taylor series expansion for this? (I found one, but it choked on such a complex formula and does not support abs.)
My purpose in generating the series expansion is that it may be more efficient to compute. (This function will be called hundreds of thousands of times in Javascript, so performance is an issue.)
Alternately, I could sample the points and do a curve fitting if I had a curve fitting tool. (I do not own MS Excel, alas.) Know of any free non-linear curve-fitting tools (web-based or MAC OS X)?
GNU Octave is a free package that, among other things, has a function polyfit to do
least-squares polynomial curve fitting. I think this (or some other package with an equivalent function) is probably a better match for your problem than Taylor series expansion. That absolute value term might make it hard to find a Taylor series that extrapolates well through the point at x=0.7, where the first derivative has a discontinuity.
Maxima does this. See the taylor function.
https://ctaylor.codeplex.com
This is a C++ library which allows you to write expressions and variables and calculate not only the value but also any order derivative.
The compiler is the one generating the code for the derivatives.
Wolfram Alpha will do this for you symbolically for free on the web. H/T #ExcessPhase for the idea of using abs(x)=sqrt(x*x).

Simple random english sentence generator [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I need a simple random English sentence generator. I need to populate it with my own words, but it needs to be capable of making longer sentences that at least follow the rules of English, even if they don't make sense.
I expect there are millions of them out there, so rather than re-inventing the wheel, I'm hoping you know of a source for one, or a resource that will give me enough information that I don't have to hunt down my rusty English skills.
You're looking for an implementation of markov chains for English sentences.
A quick Google search for "markov chain sentence generator" returned:
http://www.jwz.org/dadadodo/
http://code.google.com/p/lorem-ipsum-generator/
http://kartoffelsalad.googlecode.com/svn-history/r9/trunk/lib/markov.py
I know this is an old question, but as I found it via Google I think it's worth mentioning something like Context Free Grammars in addition to Markov Chains.
My understanding of Markov Chains is that they create the "next" item probabilistically only according to what the "current" item is. Perhaps I'm mistaken, but I don't see how this would ensure that the result would follow grammatical rules.
For instance, I usually see Markov Chains suggested as a way of creating "English sounding" words. If you create a Markov chain using letters from a dataset of English words, the output would be a word that sounds English, but it wouldn't necessarily be a real word. I believe the same would be true of sentences- you can generate something which may sound ok, but it may not be a grammatically correct sentence.
Context Free Grammars (or possibly also Regular Grammars?) might be a better candidate, since they generate sentences according to a defined ruleset. And it would be easy to populate it with your own words, as the original question requests. The downside is that you need to define these rules yourself, rather than relying on a dataset. It's been a long time since I've used a grammar to generate an English sentence, so I don't remember how hard it was to get good / varied responses.
You might be able to use/modify part of the CS Paper Generator.

Resources