Two programs with same logic

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi,
Two set of codes can be compared by using
beyond compare or other equivalent software
to determine the areas of differences and the
areas of similarities. But, there are scenarios
in which the same logic would be used by 2 set of
programs/softwares but that the variable names
might be different. So, how to determine this
without executing the program ? Is there any tool
that will help in identifying the existence of similar
logics in two different programs ? Any ideas ?

Thx in advans,
Karthik Balaguru
0
Reply karthikbalaguru79 (791) 12/20/2009 3:42:18 PM

See related articles to this posting


karthikbalaguru <karthikbalaguru79@gmail.com> writes:
>in which the same logic would be used by 2 set of

  Determining whether two programs behave the same for
  every input should in general be equivalent to the

http://en.wikipedia.org/wiki/Halting_problem

  .

  For special conditions, it should still be possible: 
  For example, when variables are only renamed, one 
  can replace both name sequences by generated names.

  (I have removed other groups from the �Newsgroups:�
  header.)

0
Reply ram 12/20/2009 3:50:16 PM

ram@zedat.fu-berlin.de (Stefan Ram) writes:
> karthikbalaguru <karthikbalaguru79@gmail.com> writes:
>>in which the same logic would be used by 2 set of
>
>   Determining whether two programs behave the same for
>   every input should in general be equivalent to the
>
> http://en.wikipedia.org/wiki/Halting_problem
>
>   .
>
>   For special conditions, it should still be possible: 
>   For example, when variables are only renamed, one 
>   can replace both name sequences by generated names.
>
>   (I have removed other groups from the »Newsgroups:«
>   header.)

The original article was cross-posted to
comp.os.linux.development.apps, comp.programming,
comp.unix.programmer, and comp.lang.c.  Why did you remove everything
but comp.lang.c?  The question isn't specific to C or to any other
language; surely comp.programming would be more appropriate.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
Reply Keith 12/20/2009 6:19:41 PM

Keith Thompson <kst-u@mib.org> writes:
>The question isn't specific to C or to any other language;
>surely comp.programming would be more appropriate.

  Since it was posted to comp.lang.c, I assumed that the
  OP was referring to a C program. This assumption might
  have been wrong, but I had it at the time I was reading
  his OP.

>Why did you remove everything but comp.lang.c?

  Since I had this assumption, I deemed the other groups
  to be not appropriate. (I might have been wrong with
  this assessment.)

  It is my own posting style not to crosspost to multiple
  groups without sufficient reason. This was another reason
  for me to trim the Newgroup header.

0
Reply ram 12/20/2009 6:40:19 PM

"karthikbalaguru" <karthikbalaguru79@gmail.com> wrote in message news:
> Two set of codes can be compared by using
> beyond compare or other equivalent software
> to determine the areas of differences and the
> areas of similarities. But, there are scenarios
> in which the same logic would be used by 2 set of
> programs/softwares but that the variable names
> might be different. So, how to determine this
> without executing the program ? Is there any tool
> that will help in identifying the existence of similar
> logics in two different programs ? Any ideas ?
>
I think such exist. Whilst in the general case "do two programs have the 
same output for the same input?" is the same as the halting problem, you are 
probably not interested in the general case, but intwo programs which have 
been copied from the same source, with identifiers changed and maybe a few 
minor control paths added. 


0
Reply Malcolm 12/20/2009 7:20:09 PM

On 20 Dec 2009 at 15:50, Stefan Ram wrote:
> karthikbalaguru <karthikbalaguru79@gmail.com> writes:
>>in which the same logic would be used by 2 set of
>
> Determining whether two programs behave the same for every input
> should in general be equivalent to the
> http://en.wikipedia.org/wiki/Halting_problem

A gold medal there for exceeding even the customary level of uselessness
in a clc response.

It's obvious that the OP doesn't care about whether two programs behave
the same for every input. He's interested in the question:
heuristically, given two programs, are they "very similar"?

Notice that there are plenty of practical reasons for wanting to answer
this question:
* if the programs are given as source code, an instructor wants to check
for copying-with-superficial-changes; or a lawyer wants to check for a
GPL infringement
* if the programs are binary, anti-virus vendors might be interested in
this

Compare that with the halting problem, which has no practical
application and is of purely theoretical interest.

0
Reply Antoninus 12/20/2009 7:30:20 PM

On Dec 20, 11:42=A0pm, karthikbalaguru <karthikbalagur...@gmail.com>
wrote:
> Hi,
> Two set of codes can be compared by using
> beyond compare or other equivalent software
> to determine the areas of differences and the
> areas of similarities. But, there are scenarios
> in which the same logic would be used by 2 set of
> programs/softwares but that the variable names
> might be different. So, how to determine this
> without executing the program ? Is there any tool
> that will help in identifying the existence of similar
> logics in two different programs ? Any ideas ?
>
> Thx in advans,
> Karthik Balaguru

As others have pointed out, the general problem is equivalent to the
Halting problem and is not solvable by an automated tool.

However, there are useful levels of similarity, where "similarity" is
a generalized identity:

(1) Similarity after compiler lexical analysis: "printf( \"Hello world\
\n\" );" as a fragment is similar in this way to "printf(\"Hello world\
\n\");"

(2) Similarity after parsing: "int a; a =3D 1+1;" is similar in this
sense to "int b; b =3D 1+1;"

(3) Similarity after code motion, elimination and optimization that
preserves intent: "int a; int b; a =3D 0; b =3D 0;" is similar to "int b;
int a; b =3D 0; a =3D 0;". "if (b || -1) c();" is similar in this sense to
"c();"

Factoring compilers better and providing an open architecture would
allow us to use compilers for far more than merely compiling. Instead
of shipping compilers, we should ship components. But, it's much more
amusing here to engage in the politics of personal destruction.
0
Reply spinoza1111 12/22/2009 12:10:34 PM

karthikbalaguru wrote:
> Hi,
> Two set of codes can be compared by using
> beyond compare or other equivalent software
> to determine the areas of differences and the
> areas of similarities. But, there are scenarios
> in which the same logic would be used by 2 set of
> programs/softwares but that the variable names
> might be different. So, how to determine this
> without executing the program ? Is there any tool
> that will help in identifying the existence of similar
> logics in two different programs ? Any ideas ?

As others say, it would be difficult at best to find dups. But a
couple approaches that could help. One might be to run both codes
through an obfuscator which would replace the programmer's meaningful
variable names with generated names. Then compare. But there's still
a lot of room for programming style to mess you up.

A second approach would be to compile both to assembler and compare
the assembler code. That should remove a fair amount of programmer
style problems but not all.
0
Reply Joe 12/22/2009 7:05:34 PM

On 2009-12-20, karthikbalaguru <karthikbalaguru79@gmail.com> wrote:
> Hi,
> Two set of codes can be compared by using
> beyond compare or other equivalent software
> to determine the areas of differences and the
> areas of similarities. But, there are scenarios
> in which the same logic would be used by 2 set of
> programs/softwares but that the variable names
> might be different. So, how to determine this
> without executing the program ? Is there any tool
> that will help in identifying the existence of similar
> logics in two different programs ? Any ideas ?

The structural similarity you are hinting at can be easily found if you parse
the code into a nice abstract syntax tree representation. Then it's just a
matter of writing an equality function which compares two pieces of code.

This is easiest to understand and illustrate through the Lisp language.

The comparison is similar to a routine that compares two trees, except that it
has to understand all ``special forms'' in the language, and their semantics.
That is to say, the comparison has to behave as a ``code walker'', with respect
to two trees at the same time. It has to recognize all special syntactic
constructs, so that it can apply the right kind of comparison.

It also must be capable of performing variable renaming.

So for instance we might want these two to be found equivalent:

  (let ((x 1)) (+ x x))

  (let ((y 1)) (+ y y))

For thaat we have to recognize that we have two matching constructs
(both are ``let''). They both bind the same number of variables,
using the same initialization values. Next, we have to normalize
the bodies. We can do that by renaming the variables on each
side: e.g. both x and y get renamed to t0 (temporary variable #0).
Each time we rename a variable we generate a new temporary.
When we rename x to t0 and substitute, we end up with:

  (let ((t0 1)) (+ t0 t0))

And when we do the same substitution on the variable y on the second form we
of course also end up with:

  (let ((t0 1)) (+ t0 t0))

So now having done this substituion over the let, we can recursively process
the body of each let and continue comparing: we now end up comparing (+ t0 t0)
to (+ t0 t0). We have a positive match on the same symbol +, and we know that
it's a function call.  The two functions calls have the same number of
arguments, which we can compare one by one, finding an exact match in
ech position: the expression t0 trivially matches the expression t0.
Thus having reached bottom, we conclude that the two constructs are equivalent
(modulo variable naming).

This applies to the comparison of C programs too because for the C language,
you can pick this kind of tree representation with symbols and atoms.
Parse the code to that, and write a comparison which applies the right
kind of rules.

The question is the semantic depth that you want in the comparison.

Should the expression  !(!P || !Q) match P && Q, by the application of
De Morgan's law?

Does your equivalence function fold constant expressions, so that
2 + 2 matches 1 + 3?

There is a huge range of things you can do in between the most naive
static comparison (in which even differences in variable names do matter)
to running the program and trying to identify that it does the same things
to all inputs (running into the halting problem).


Now about implementing this. Turns out, the annoying part of parsing C to
structure is already done. For instance, there is this Japanese gentleman's
project called SC:

http://super.para.media.kyoto-u.ac.jp/~tasuku/sc/index-e.html

With this software, you would be able to just concentrate on writing the
equivalence function.
0
Reply Kaz 12/22/2009 7:53:43 PM

On Dec 23, 12:05=A0am, Joe Beanfish <j...@nospam.duh> wrote:
> karthikbalaguru wrote:
> > Hi,
> > Two set of codes can be compared by using
> > beyond compare or other equivalent software
> > to determine the areas of differences and the
> > areas of similarities. But, there are scenarios
> > in which the same logic would be used by 2 set of
> > programs/softwares but that the variable names
> > might be different. So, how to determine this
> > without executing the program ? Is there any tool
> > that will help in identifying the existence of similar
> > logics in two different programs ? Any ideas ?
>
> As others say, it would be difficult at best to find dups. But a
> couple approaches that could help. One might be to run both codes
> through an obfuscator which would replace the programmer's meaningful
> variable names with generated names. Then compare. But there's still
> a lot of room for programming style to mess you up.
>

Agreed !

> A second approach would be to compile both to assembler and compare
> the assembler code. That should remove a fair amount of programmer
> style problems but not all.

Interesting approach ! I think, this is better than the earlier
approach. But, Need to know the kind of programmer style
problems that will not get covered by this second approach.
Any ideas ?

Thx in advans,
Karthik Balaguru
0
Reply karthikbalaguru 12/27/2009 6:17:06 AM

On Dec 23, 12:53=A0am, Kaz Kylheku <kkylh...@gmail.com> wrote:
> On 2009-12-20, karthikbalaguru <karthikbalagur...@gmail.com> wrote:
>
> > Hi,
> > Two set of codes can be compared by using
> > beyond compare or other equivalent software
> > to determine the areas of differences and the
> > areas of similarities. But, there are scenarios
> > in which the same logic would be used by 2 set of
> > programs/softwares but that the variable names
> > might be different. So, how to determine this
> > without executing the program ? Is there any tool
> > that will help in identifying the existence of similar
> > logics in two different programs ? Any ideas ?
>
> The structural similarity you are hinting at can be easily found if you p=
arse
> the code into a nice abstract syntax tree representation. Then it's just =
a
> matter of writing an equality function which compares two pieces of code.
>
> This is easiest to understand and illustrate through the Lisp language.
>
> The comparison is similar to a routine that compares two trees, except th=
at it
> has to understand all ``special forms'' in the language, and their semant=
ics.
> That is to say, the comparison has to behave as a ``code walker'', with r=
espect
> to two trees at the same time. It has to recognize all special syntactic
> constructs, so that it can apply the right kind of comparison.
>
> It also must be capable of performing variable renaming.
>
> So for instance we might want these two to be found equivalent:
>
> =A0 (let ((x 1)) (+ x x))
>
> =A0 (let ((y 1)) (+ y y))
>
> For thaat we have to recognize that we have two matching constructs
> (both are ``let''). They both bind the same number of variables,
> using the same initialization values. Next, we have to normalize
> the bodies. We can do that by renaming the variables on each
> side: e.g. both x and y get renamed to t0 (temporary variable #0).
> Each time we rename a variable we generate a new temporary.
> When we rename x to t0 and substitute, we end up with:
>
> =A0 (let ((t0 1)) (+ t0 t0))
>
> And when we do the same substitution on the variable y on the second form=
 we
> of course also end up with:
>
> =A0 (let ((t0 1)) (+ t0 t0))
>
> So now having done this substituion over the let, we can recursively proc=
ess
> the body of each let and continue comparing: we now end up comparing (+ t=
0 t0)
> to (+ t0 t0). We have a positive match on the same symbol +, and we know =
that
> it's a function call. =A0The two functions calls have the same number of
> arguments, which we can compare one by one, finding an exact match in
> ech position: the expression t0 trivially matches the expression t0.
> Thus having reached bottom, we conclude that the two constructs are equiv=
alent
> (modulo variable naming).
>
> This applies to the comparison of C programs too because for the C langua=
ge,
> you can pick this kind of tree representation with symbols and atoms.
> Parse the code to that, and write a comparison which applies the right
> kind of rules.
>

Interesting. Agreed !

> The question is the semantic depth that you want in the comparison.
>

True !

> Should the expression =A0!(!P || !Q) match P && Q, by the application of
> De Morgan's law?
>
> Does your equivalence function fold constant expressions, so that
> 2 + 2 matches 1 + 3?
>
> There is a huge range of things you can do in between the most naive
> static comparison (in which even differences in variable names do matter)
> to running the program and trying to identify that it does the same thing=
s
> to all inputs (running into the halting problem).

Yeah. True !

> Now about implementing this. Turns out, the annoying part of parsing C to
> structure is already done. For instance, there is this Japanese gentleman=
's
> project called SC:
>
> http://super.para.media.kyoto-u.ac.jp/~tasuku/sc/index-e.html
>
> With this software, you would be able to just concentrate on writing the
> equivalence function.

Okay, I will look into this !

Thx,
Karthik Balaguru
0
Reply karthikbalaguru 12/27/2009 7:10:16 AM

karthikbalaguru <karthikbalaguru79@gmail.com> writes:

> On Dec 23, 12:05�am, Joe Beanfish <j...@nospam.duh> wrote:
>> karthikbalaguru wrote:
>> > Hi,
>> > Two set of codes can be compared by using
>> > beyond compare or other equivalent software
>> > to determine the areas of differences and the
>> > areas of similarities. But, there are scenarios
>> > in which the same logic would be used by 2 set of
>> > programs/softwares but that the variable names
>> > might be different. So, how to determine this
>> > without executing the program ? Is there any tool
>> > that will help in identifying the existence of similar
>> > logics in two different programs ? Any ideas ?
>>
>> As others say, it would be difficult at best to find dups. But a
>> couple approaches that could help. One might be to run both codes
>> through an obfuscator which would replace the programmer's meaningful
>> variable names with generated names. Then compare. But there's still
>> a lot of room for programming style to mess you up.
>>
>
> Agreed !
>
>> A second approach would be to compile both to assembler and compare
>> the assembler code. That should remove a fair amount of programmer
>> style problems but not all.
>
> Interesting approach ! I think, this is better than the earlier
> approach. But, Need to know the kind of programmer style
> problems that will not get covered by this second approach.
> Any ideas ?

It's not just a question or programming style. You're at the semantics
of the programs.  The question is to compare the semantics of two
programs.  So you first have to represent the semantics of a program.
One way to do that would be to have a formal semantic definition of
the programming language, and to translate the programs into that
formalism,  and then compare thetheir formal semantics.
Unfortunately, not a lot of languages have a formal semantic
definition, and for most of the programming languages which have been
developed without such in mind, when one is developed for them, if it
is complete, then it is rather complex, giving formal semantic forms
that are not really more obvious than the original program (for
example, in the case of C).  In conclusion, for these kind of
programming language, the best way to express their semantics in a
formal way is to consider their compilation to some simplier
processor code, and then compare these codes.

Now of course when you compile these two programs:

(defun s1 (v) 
 (loop for e across v sum e))

(defun s2 (v)
  (do ((s 0)
       (i (1- (length v)) (1- i)))
      ((< i 0) s)
   (incf s (aref v i))))
     

you get two different listings, but you have to find a way to conclude
that they do exactly the same thing:

C/LISP[215]> (disassemble 's1)

Disassembly of function S1
(CONST 0) = 0
1 required argument
0 optional arguments
No rest parameter
No keyword parameters
19 byte-code instructions:
0     (CONST&PUSH 0)                      ; 0
1     (NIL&PUSH)
2     (CONST&PUSH 0)                      ; 0
3     (JMP L19)
5     L5
5     (LOAD&PUSH 4)
6     (LOAD&PUSH 3)
7     (CALLSR&STORE 1 1 1)                ; AREF
11    (LOAD&PUSH 0)
12    (LOAD&PUSH 2)
13    (CALLSR&STORE 2 53 0)               ; +
17    (LOAD&INC&STORE 2)
19    L19
19    (LOAD&PUSH 2)
20    (LOAD&PUSH 5)
21    (CALLS2&PUSH 72)                    ; LENGTH
23    (CALLSR&JMPIFNOT 1 50 L5)           ; >=
27    (POP)
28    (SKIP&RET 4)
NIL
C/LISP[216]> (disassemble 's2)

Disassembly of function S2
(CONST 0) = 0
1 required argument
0 optional arguments
No rest parameter
No keyword parameters
17 byte-code instructions:
0     (CONST&PUSH 0)                      ; 0
1     (LOAD&PUSH 2)
2     (CALLS2&PUSH 72)                    ; LENGTH
4     (CALLS2&PUSH 152)                   ; 1-
6     (JMP L20)
8     L8
8     (LOAD&PUSH 1)
9     (LOAD&PUSH 4)
10    (LOAD&PUSH 2)
11    (CALLSR&PUSH 1 1)                   ; AREF
14    (CALLSR&STORE 2 53 1)               ; +
18    (LOAD&DEC&STORE 0)
20    L20
20    (LOAD&PUSH 0)
21    (CALLS2&JMPIFNOT 148 L8)            ; MINUSP
24    (LOAD 1)
25    (SKIP&RET 4)
NIL


The semantics of assembly is not more obvious than the semantics of
high level programming languages.  The reason why you will work with
assembly is not that (otherwise we would keep programming in
assembly!).  The point of assembly, is that the instructions are
simplier: their semantics is simplier.  Therefore it is easier for
programs to work with it.  You want to compare semantics, then it's
simplier to compare the semantics of simplier instructions.  However,
you still have a lot of work to do, even if each step of this work
will be simplier.  But it is possible to infer mechanically from both
these assembly codes that each element of the vector is read, and
summed, and that the sum is returned by the function.  Therefore that
these two functions are equivalent semantically.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
0
Reply pjb 12/27/2009 12:39:25 PM

In article <87fx6wmvym.fsf@hubble.informatimago.com>,
Pascal J. Bourguignon <pjb@informatimago.com> was apparently confused
about which newsgroup he was in when he wrote:
....
>Now of course when you compile these two programs:
>
>(defun s1 (v) 
> (loop for e across v sum e))
>
>(defun s2 (v)
>  (do ((s 0)
>       (i (1- (length v)) (1- i)))
>      ((< i 0) s)
>   (incf s (aref v i))))

(Channelling our good friend Kiki, who is so good at pointing out the
obvious)

Lisp and C are two different languages.

0
Reply gazelle 12/27/2009 1:17:14 PM
comp.lang.c 29425 articles. 31 followers. Post

12 Replies
428 Views

Similar Articles

[PageSpeed] 25


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Finding the difference in consequences between two logic programs
Hello, Given two logic programs LP1 and LP2, I would like to generate consequences of LP1 that are not consequences of LP2. Is there an efficient way of finding these consequences? A basic solution is quite simple to express: lp1_and_not_lp2(X) :- lp1(X), \+ lp2(X). but as the programs become more complex, the inefficiency of this approach becomes a problem. It seems to be quite a general problem - is there any theory I should know about, and is another setting (e.g. CLP / answer set programming) more suited than Prolog? In my case, LP1 and LP2 are closely related (to get LP2 just add/ ...

second order logic programming and thematic role based logic programming
Im not a great programmer so im looking for fairly simple introductions into second order logic programming. I really just want to be able to quantify over a set of finite predicates {the set of finite predicates availible in the knowledge base}. Also if anyone knows anything about thematic roles and could help me find a logic programinng lanquage based on that. I'd be ecstatic. On 7 =C1=D7=C7, 09:26, Sean Clarke <sea...@gmail.com> wrote: > Im not a great programmer so im looking for fairly simple > introductions into second order logic programming. I really just want > ...

A question about program logic... program provided
This program is an example from Deitel and Deitel, "C How to Program" My question is about the logic in the shuffle function. j = rand() % 52; What keeps j from having the same value more than once? ------------------------------------------------------ /* The program comes from "C How to Program" * by Deitel and Deitel */ /* Fig. 10.3: fig10_03.c The card shuffling and dealing program using structures */ #include <stdio.h> #include <stdlib.h> #include <time.h> /* card structure definition */ struct card { const char *...

How do i connect two matlab programs on two different computers
hello, My objective is to connect two matlab programs on different computers and pass a string between the two. I have been looking into tcpip command in the instrument control toolbox, but after i create the object, I am unable to open the connection between the two. The error that occurs is : ??? Error using ==> fopen Operation timed out: connect. Please let me know about the correct procedure to achieve the above objective. thanks for the help Regards, shashikiran prabhakar "shashikiran prabhakar" <shashikiranp@yahoo.com> wrote in message news:eef4710.-1@webx.raydaf...

How to trigger two programs on two different machines at the same time?
Hi all, I hope this is a proper ng to pose my question, could you please point me to a better one if otherwise? I need to run two different recording systems each residing in a separate machine: one acquires audio while the other records video. Obviously, I want the two resulting streams to be as synchronized as possible, i.e., they should start recording at the same time. How good do you think it would be to do this over the ethernet network? Also, could you suggest a way to program a script that would launch the recording on the second machine at the same time as the one on the first...

Two programs get two different run time
Prog1: function f = fibnum(n) % FIBNUM Fibonacci number. % FIBNUM(n) generates the nth Fibonacci number. if n <= 1 f = 1; else f = fibnum(n-1) + fibnum(n-2); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Prog 2: function f = fibonacci(n) % FIBONACCI Fibonacci sequence % f = FIBONACCI(n) generates the first n Fibonacci numbers. f = zeros(n,1); f(1) = 1; f(2) = 2; for k = 3:n f(k) = f(k-1) + f(k-2); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I try tic and toc to compare two programs' run time, quite different. Why, both of them use recrusive way. TimeX Gu...

programming logic
Hi Please help me to solve this. A table contains the following data (related to TV channel) 1. Program_Id (just an ID) 2. Start Date (e.g. 12-Apr-2006) 3. End Date (NULL if there is no end date, e.g. News) 4. Program Start Time (e.g. 7:30 PM) 5. Program End Time (e.g. 8:00 PM) 6. Type 1= Daily 2= Weekdays 3= Weekends 4=Weekly 5= Fortnightly 6 = Monthly (E.g. if 12-Apr-2006 is that start date the next occurance will be May 10th, that is second wednesday of every month) Now I need to add new data into the table. Before that I need to check whether th...

program logic
the following short program is suppose to take a line c02345edbundie 5californiaSt,WestVirginia balancetransfer0.00000creditlimit 100 I12345sarahbundie 5californiaSt,WestVirginia balancetransfer0.00000creditlimit 100 it is suppose to compare the first digit in each line, in this case 0 and 1 and output them in accending order to the sort_data file. The problem I have is that the sort data file for some reason can not be created, could you please tell look over the program tell me if it does what it is suppose to, and how I can force the program to create the file. On 15 Feb 200...

Programming Logic
Hi everyone, I'm trying to solve a problem whereby there are contractors who bill us for services, and we know how much service is billed and the total amount, but not the individual rate for each each service. Yes, it doesn't make sense, but its what I have to deal with. So the data is in a form as follows: data example; input x1 x2 z1; cards; 2 1 85 1 3 95 ; run; Where for example we have two products x1 and x2 and two invoices, totalling 85 and 95 dollars respectively and I need to solve for the individual prices. I think I need to use IML here, any suggestions or help is mu...

Logic Programming
Yes! The question rears its head once again! ;o) I have done some search and trial and horrors.. (PyLog has vanished?) But I fail to find anything useful when it comes to do Logic Programming (e.g. Prolog'ish) in the context of Python. And yes, I tend to beleive that I need to! No, I do not really like the idea of piping def's and queries to SWI-prolog =E1la PyProlog. So, I would be *so* happy if someone could point at some module that gives me the possibility to define a knowledgebase and queries from within Python and still access the structures from Python code. *pleeze!* I be...

Two SATA disk burners, only one shows up in two programs
My homebuilt PC has tow Sata internal burners: a Lite-On iHAS524 DVD/RW drive and a Plextor PX-LB950 BD drive. I'm running Windows 7 64-bit and using a Asus Sabertooth X-79 motherboard. In two programs I've been using for long time in the 32-bit days, 'Exact Audio Copy' and a 2003 audio burning program 'Fuerio' in which the best burner does not appear in drive listings. The 'Fuerio" shows the Plextor in settings but only lists the Lite-On for drive choice for burning, and EAC onyl sees the Lite-On. Both drives are on the same pair of SATA ports and...

How to call values@datas from image processing program into fuzzy logic program
Hi...i'm new in this forum...I need someone idea@help to settle my problem.My problem is how to call output data from image processing program into fuzzy logic program. For example the output data of image processing are length, width and area...So, this data will become as the input to fuzzy logic program...The image processing data must automatically become the input to fuzzy logic program....For time being, i insert manually the fuzzy input data....Anybody can help me... ...

How can we include two physical files of the same name residing in two different libraries in a single RPG/RPGLE program?
Hi all, Suppose there are two physical files each having the same name, say STUDMAST residing in two different libraries. I have to copy the records from one file to the other.How do you do this in an RPGLE program? How can we include both the files in the F-SPEC. Arup K George "Arup K George" <arupkgeorge@coolgoose.com> wrote in message news:1cc2ad41.0404050058.22c6bfd2@posting.google.com... > Hi all, > > Suppose there are two physical files each having the same > name, say STUDMAST residin...

Logic Programming In Perl
Hi all, Pardon me pimping out my own stuff, but I recently wrote a module to allow basic logic programming (via Prolog) in Perl. I'm giving a presentation tomorrow night and if anyone is interested, you can read the slides at http://users.easystreet.com/ovid/presentations/logic/ Naturally, without the talk, there's a lot of context missing, but if anyone notes any egregious errors, I'd love to hear 'em (there's a lot of handwaving, too, as I only have 45 minutes for the official talk, scheduled for August) Anyone curious about the actual code can browse it at http://sea...

Two programs simultaneously
Hi Is it possible to make two programs to run at the same time. What I'm intending to do is to play a chord (musical three notes simlutaneously) using BEEP command so that I can make two frequencies to be played at the same time. Thank you. Gurveer Hi, please take a look at www.hpcalc.org , where you'll find a variety of programs dealing with sound creation. There may also be an explanation why you can't run more than one program (at the same time) on a single-task machine, and about the limited capabilities of the built-in piezo beeper;-) HTH Raymond "Gurveer" ...

Logic behind the program
Hello, the code below calculate the number of bits set in an unsigned integer. Can you explain me the logic behind the code? unsigned int x = Some number; x=(0xaaaaaaaa&x)>>1+(0x55555555&x); x=(0xcccccccc&x)>>2+(0x33333333&x); x=(0xf0f0f0f0&x)>>4+(0x0f0f0f0f&x); x=(0xff00ff00&x)>>8+(0x00ff00ff&x); x=x>>16+(0x0000ffff&x)); In article <1188382529.409612.7500@e9g2000prf.googlegroups.com>, ravi <dceravigupta@gmail.com> wrote: >the code below calculate the number of bits set in an unsigned >integer. >Can you...

programming on fuzzy logic
i got a big problem here, i am newbie on using MATLAB software and i hope anyone here can help me..... Now i'm developing a fuzzy logic system on machining operation...it something about theanalysis on machinability data. The input is hardness and depth of cut and output is the recommended cutting speed for turning operation.... i have set all the rules and the membership functions for the 'trimf' shape. But the problem is the next step...i need to related some machining formula to the membership function..maybe i need to do some programming but im really new guy in programming.. ...

How to compare two logicals?
Hi! Sorry for the following silly question, but I did not manage to find the answer in a fine manual: Suppose I have LOGICAL :: StaggeredA, StaggeredB How can I check if StaggeredA and StaggeredB have the same value (either both .TRUE. or both .FALSE.)? g95 complains about the comparison (StaggeredA .EQ. StaggeredB)... Arjan On Feb 1, 11:32=A0am, Arjan <arjan.van.d...@rivm.nl> wrote: > Hi! > > Sorry for the following silly question, but I did not manage to find > the answer in a fine manual: > Suppose I have > LOGICAL :: StaggeredA, StaggeredB > ...

Interaction between two programs
I'm sure this might be a simple questions, but here it goes anyway. I am trying to do a 'front end' to a program. For example I have a program that doesn't take command line arguments, but prompts the user for input every time it is run, ie. Enter your name: I want to run a program that will automatically type the name into that field. I just don't really know where to start. Is this suppossed to be a spawn or an exec? I saw something about pipes, but didn't quite get it. Please explain for me. This is NOT for a class, just trying to learn how to do things Se...

[OT] Logic Programming
Hello everyone. Following a Ruby Quiz posting a while a go, and various prior mentions of Prolog, I ventured off and had an explore on Wikipedia: http://en.wikipedia.org/wiki/Logic_programming Opinion piece: My interest here is that I'm unimpressed with the current state of programming. My feeling is that we've gone off down the wrong route with imperative programming and with OO. Mostly I have this feeling because there are many things that I want to express, which I don't think are particularly complex, but which seem hard to express with programs. I find I need to say a lo...

lisp logic programming
Hi. How can I do logic programming in lisp ? Is there some free library to download ? Thanks Maybe one of http://www.cliki.net/Prolog I tried PAIP for some days, but it didn't fit my needs. Haris Bogdanovich wrote: > How can I do logic programming in lisp ? > Is there some free library to download ? � On Tuesday, September 13, 2011 2:15:05 PM UTC+2, Haris Bogdanovich wrote: > Hi. > > How can I do logic programming in lisp ? > Is there some free library to download ? > > Thanks Check Norvig's PAIP for an implementation of a Prolog "almost-compile...

getting logic of program
Hello I want logic or algorithm for following c function. void hmethod( float **array, float **zeta, float **attrib, int *linext, char *alphabet, int obj, int att ) { //H start computations --------------------------------------------- int b = 0, i = 0, j = 0, k = 0, q = 0, r = 0; float ** hvalue, count = 0.0, total = 0.0, rank = 0.0, meanvalue = 0.0; hvalue = ( float ** )malloc( sizeof( float * ) ); for( i = 0; i < obj; i++ ) { hvalue[ i ] = ( float * )malloc( sizeof( float ) * obj ); } //Here we compare the adjacent elements //First store the...

Two utility programs
If anyone is interested, here are a couple of little convenience C programs. One prints the system's serial number. The other prints its machine type and model. I don't claim to be any kind of ODM internals guy; these were written to fill a desire to learn more about ODM programming. So if you have any suggestions for improvement, share them with me if you would. Have fun. -Ross ----- serial.c ----- #if 0 /* # Save this text to a file named "serial.c." To compile this program # using read-only ODM system calls, you'll need to have AIX 5.2 plus # IY57150. To dete...

Capture program logic?
Hello. W2K, v7, FP10a. I want to develop my own capture program instead of original because I bored to fight with it's behavior - it suddenly stops doing any job during heavy workload in our system and I can't make it work without losing any data changings since stopping to moment when I found this error. I want do it with data change triggers. Is somewhere description - what such program have to do to communicate with apply program? Thanks in advance, Mark. ...