This PR changes the handling of over-applied cases expressions in
`ToLCNF` to avoid generating function declarations that are called
immediately. For example, `ToLCNF` previously produced this:
```lean-4
set_option trace.Compiler.init true
/--
trace: [Compiler.init] size: 4
def test x y : Bool :=
fun _y.1 _y.2 : Bool :=
cases x : Bool
| PUnit.unit =>
fun _f.3 a : Bool :=
return a;
let _x.4 := _f.3 _y.2;
return _x.4;
let _x.5 := _y.1 y;
return _x.5
-/
#guard_msgs in
def test (x : Unit) (y : Bool) : Bool :=
x.casesOn (fun a => a) y
```
which is now simplified to
```lean-4
set_option trace.Compiler.init true
/--
trace: [Compiler.init] size: 3
def test x y : Bool :=
cases x : Bool
| PUnit.unit =>
let a := y;
return a
-/
#guard_msgs in
def test (x : Unit) (y : Bool) : Bool :=
x.casesOn (fun a => a) y
```
This is especially relevant for #8309 because there `dite` is defined as
an over-applied `Bool.casesOn`.
12 lines
264 B
Text
12 lines
264 B
Text
set_option trace.Compiler.init true
|
|
/--
|
|
trace: [Compiler.init] size: 3
|
|
def test x y : Bool :=
|
|
cases x : Bool
|
|
| PUnit.unit =>
|
|
let a := y;
|
|
return a
|
|
-/
|
|
#guard_msgs in
|
|
def test (x : Unit) (y : Bool) : Bool :=
|
|
x.casesOn (fun a => a) y
|