Skip to content

Commit

Permalink
refactor: transform optimisation step
Browse files Browse the repository at this point in the history
  • Loading branch information
William Sørensen committed Jun 26, 2024
1 parent bfc07e0 commit e932a49
Showing 1 changed file with 1 addition and 8 deletions.
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)) : TermE
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

0 comments on commit e932a49

Please sign in to comment.