Skip to content
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

refactor: is_trivial check to be more succinct #24

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Qpf/Macro/Comp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,7 @@ partial def handleApp (vars : Vector FVarId arity) (target : Q(Type u)) : TermEl
In such cases, we can directly return `G`, rather than generate a composition of projections.
-/

-- O(n²), equivalent to a zipping and would be O(n) and much more readable
let is_trivial :=
args.length == arity
&& args.toList.enum.all fun ⟨i, arg⟩ =>
arg.isFVar && isLiveVar vars arg.fvarId! && vars'.indexOf arg.fvarId! == i
-- Equivalent (?), O(n), and more readable
-- TODO: is this really equivalent
/- let is_trivial := (args.toList.mapM Expr.fvarId?).any (· == vars') -/
let is_trivial := args.toList.mapM Expr.fvarId? == some vars'

if is_trivial then
trace[QPF] "The application is trivial"
Expand Down
Loading