lean4-htt/tmp/even_odd.lean
Leonardo de Moura 789d4e148f feat(library/equations_compiler): add pack_mutual
This step packs a collection of mutually recursive functions into a
single one. We use `psum` to combine the different domains, and
`psum.cases_on` to combine the codomains.
2017-05-18 15:29:51 -07:00

27 lines
712 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import data.vector
open nat
universes u v
set_option pp.all true
set_option trace.eqn_compiler.wf_rec true
set_option trace.debug.eqn_compiler.wf_rec true
set_option trace.debug.eqn_compiler.mutual true
set_option trace.eqn_compiler.elim_match true
mutual def even, odd
with even : nat → bool
| 0 := tt
| (a+1) := odd a
with odd : nat → bool
| 0 := ff
| (a+1) := even a
mutual def f, g {α : Type u} {β : Type v} (f : α → β) (p : α × β)
with f : Π n : nat, vector (α × β) n
| 0 := vector.nil
| (succ n) := vector.cons p $ (g n p.1).map (λ b, (p.1, b))
with g : Π n : nat, α → vector β n
| 0 a := vector.nil
| (succ n) a := vector.cons p.2 $ (f n).map (λ p, p.2)