Add product list example proving the append homomorphism#992
Merged
Conversation
`examples/product.pf` defines the classic intro-FP `product` over `List<UInt>` and proves `product(xs ++ ys) = product(xs) * product(ys)` by structural induction — the multiplicative twin of `length_append`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
examples/product.pf, a new worked example: the classic intro-to-functional-programmingproductfunction overList<UInt>,and a proof that it is a homomorphism from
(List<UInt>, ++)to(UInt, *):This is the multiplicative twin of the library's
length_append, proved by structural induction onxs. The example is not already covered inexamples/(the existingconcat.pf,sum_*, andlength-related examples are distinct functions).Validation
Both parsers accept it with no warnings:
The file also includes three
assertsanity checks (product([2,3,4]) = 24,product(@[]<UInt>) = 1,product([5]) = 5).Note
While writing this with the recommended
mcp__deduce__*workflow I hit a friction point filed as #991: the MCPcheck_filetool reported the proof clean, butdeduce.pyflagged two redundantreplacearguments that an auto rule already handles. The committed proof has those redundant arguments removed.🤖 Generated with Claude Code