Git Product home page Git Product logo

Comments (5)

davidedc avatar davidedc commented on August 24, 2024

I'll look into this as soon as I can (likely a couple of weeks). Any help welcome.

from algebrite.

pabloahb avatar pabloahb commented on August 24, 2024

Hi, I think that the problem is in the function Eval_testeq

To compare [1,2] and [3,4], this function calculates the difference between [1,2] and [3,4] and then it does this:


			if (iszero(p1))
				# if we got to zero then fine
				push_integer(1)
			else if isnum(p1)
				# if we got to any other number then
				# we know they are different
				push_integer(0)
			else
				# if we didn't get to a number then we
				# don't know whether the quantities are
				# different so do nothing
				push orig


The problem is that the difference between [1,2] and [3,4] is a TENSOR!!!!!
Is not zero, is not a number, it is a tensor and you can fix the function this way:


			if (iszero(p1))
				# if we got to zero then fine
				push_integer(1)
			else if isnum(p1)
				# if we got to any other number then
				# we know they are different
				push_integer(0)
			else if istensor(p1)
				# if we got to any other tensor then
				# we know they are different
				push_integer(0)
			else
				# if we didn't get to a number then we
				# don't know whether the quantities are
				# different so do nothing
				push orig


Please check this commit:
pabloahb@ad3bf87

from algebrite.

pabloahb avatar pabloahb commented on August 24, 2024

Additionally,

I found an error in the "Eval_and" function:
This function searches for zeros and if it does not find them, it returns 1

# and definition
Eval_and = ->
	p1 = cdr(p1)
	while (iscons(p1))
		push(car(p1))
		Eval_predicate()
		p2 = pop()
		if (iszero(p2))
			push_integer(0)
			return
		p1 = cdr(p1)
	push_integer(1)

The problem is that when this function receives undefined arguments or arguments different than zero, the function will assume that the argument is true because it is different from 0 and this produces a false positive error.


Algebrite.run("and(undef_a,undef_b,undef_c)")
"1"
Algebrite.run("and(undef_var,10,-20)")
"1"

from algebrite.

davidedc avatar davidedc commented on August 24, 2024

@pabloahb thanks, yes, those are the sections that I'm reworking. There are a couple of cases that we also need to look at... for example we can't quite assume this piece:

# if we got to any other tensor then
# we know they are different

because e.g. in the case [0,0]==[0,a] the result there would be false, while the result should really be push orig because we don't know about a, so the equality test should remain unevaluated rather than false.

I just re-worked "and", and I'm going to re-work the others tomorrow morning, so we can all review hopefully tomorrow and see where we are at.

from algebrite.

davidedc avatar davidedc commented on August 24, 2024

I think this should fix booleans.

Outline of the changes:

  • there is a new routine "isZeroLikeOrNonZeroLikeOrUndetermined" which is important
  • then the "check" function has been reworked.
  • then "test*" have been changed.
  • finally, "and", "or", "not" have been changed.

All other changes are just due to renaming of a couple of functions.

See the three changed test files to see if they convince you.

from algebrite.

Related Issues (20)

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.