-
Notifications
You must be signed in to change notification settings - Fork 9
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
Issue with Demorgan Definition of AND #125
Comments
Tried doing this myself, defining
This one copied from your issue above,
Seems to give me a proper
Trying this out with |
Ah my bad on not giving the other defs |
Reproducing fails with |
Reproducing in the spec: #127 |
Let's analyse it, under the preface that I didn't actually run any of this and it's purely manual code analysis. To be on the same page, the issue is that spec occurs with this piece of AST: {
type: "function",
argument: "b",
body: { type: "variable", name: "b" },
} This function does not contain In the capture avoidance step it then has to generate a new name. As far as the system is concerned, the free variables are: const freeInReplacer = ["b"]; // The outer variable that the lambda is applied to.
const freeInExpressionBody = ["b"]; // This is actually not true, but irrelevant to this specific issue.
const argNames = []; Using these variables, it thinks the first safe free name is {
type: "function",
argument: "ε₁",
body: { type: "variable", name: "ε₁" },
} However, the resursive application of the reduction on the body of the lambda-explorer/src/lib/lambda/operations.ts Line 138 in 0fd8e7c
So in addition to the three cases already mentioned, there is a fourth requirement that arguments should not change to the name you are trying to replace. As mentioned, if that name does occur in the body of the function it already works; it will appear in the lambda-explorer/src/lib/lambda/operations.ts Lines 112 to 115 in 0fd8e7c
// 4: isn't the argument name that is being replaced. I.e. solved by adding lambda-explorer/src/lib/lambda/operations.ts Lines 120 to 122 in 0fd8e7c
let newName = generateNewName(
freeInReplacer.concat(freeInExpressionBody, argNames, [nameToReplace])
); It may also be solved by not doing any replacement at all if So why did I say that
|
const freeInExpressionBody = getFreeVars(expression.body).map( |
Although in that case, the variable should be part of argNames
, so that line should also use expression
instead of expression.body
. And unsurprisingly that should lead to the same result, only shifting the array in which the function argument itself occurs.
lambda-explorer/src/lib/lambda/operations.ts
Line 119 in 0fd8e7c
const argNames = getAllArgumentNames(expression.body); |
Probably fixes evinism#125 and evinism#126
Thank you for the project! Was super fun!
I tried defining AND in terms of NOT and OR and my definition does not seem to work. I believe this to be a bug? https://en.wikipedia.org/wiki/De_Morgan's_laws
The text was updated successfully, but these errors were encountered: