-
Notifications
You must be signed in to change notification settings - Fork 24
Add support for function declaration statements #352
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
Conversation
6016b5a to
b8ec252
Compare
…or Func - Added ToFormat for generic Func with proper constraints - Added [ToFormat T.IDMeta] to Factory.lean section variables - Removed unnecessary ToFormat instances from test files and Program.lean - Removed custom Env.format function (now uses default ToFormat) - Function bodies now display properly instead of showing <body>
- Resolved conflict in Factory.lean (Factory_wf moved to FactoryWF.lean in main) - Applied rotate_left fix to FactoryWF.lean
…rotate_left fix to FactoryWF
- Modified testFuncDeclSymbolic to show functions capture variables by reference - Function declared with n=10, then n mutated to 20, function uses n=20 at call time - Proof obligation correctly shows result should be 25 (5+20), not 15 (5+10) - Reverted Env.lean to main (custom scope formatting not needed)
…claration time - Functions now capture variable values at declaration time, not by reference - Free variables in function body are substituted with their current values from environment - Test demonstrates: n=10 at declaration, n=20 after mutation, function uses n=10 - Proof obligation correctly shows result is 15 (5+10), not 25 (5+20)
joscoh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, had a few questions about polymorphism. Also, do the small step semantics for Statements (StmtSemanticsSmallStep.lean) need to be updated?
|
I updated |
- Add WFfuncDeclProp structure in WF.lean checking input parameter uniqueness - Add LFunc.type_inputs_nodup theorem in Factory.lean - Add Function.typeCheck_inputs_nodup theorem in FunctionType.lean - Add listMap_keys_map_snd helper lemma in StatementWF.lean - Replace sorry in funcDecl case with complete proof
…Check - Simplify FuncWF.body_freevars to use subset notation (porting PR #386) - Simplify FuncWF.body_freevars_decidable to a 1-line proof - Extract PureFunc.typeCheck helper in FunctionType.lean to reduce code duplication - Update StatementType.lean to use the shared PureFunc.typeCheck helper
- Changed extendEval from existential parameter inside step_funcDecl to explicit parameter of StepStmt inductive type - Updated StepStmtStar, EvalStmtSmall, EvalStmtsSmall, IsTerminal to accept extendEval parameter - Updated evalStmtsSmallNil and terminalIsTerminal theorems accordingly - Also includes PureFunc.typeCheck returning Function to avoid duplicate conversion in StatementType.lean
Address PR review comment: LFuncWF is now a type alias (abbreviation) of FuncWF, instantiated with Lambda-specific getName and getVarNames functions. This maintains the same semantics while reducing code duplication.
…ta-org/Strata into add-func-decl-to-statements
Add support for function declarations within statement blocks
This PR adds the ability to declare functions as a statement
Stmt.funcDeclin Strata Core, enabling local function definitions within procedures.Changes
Stmt.funcDeclfor declaring functions within statement blocksSemantics
δ(SemanticEval) as state throughEvalStmtandEvalBlockEvalCmdParamsignature to includeδ'output parameter for evaluator changesTesting
Added tests demonstrating funcDecl functionality including polymorphic functions with type parameters. Existing tests pass.