-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] added a
co_cases
tactic for manipulating the inner
representation of coinductive types. Not meant for manipulating individual coinductive types
- Loading branch information
1 parent
ce8da6a
commit 90db5b4
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
import .basic | ||
import .tactic |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import .basic | ||
#check @cofix.cases | ||
namespace tactic | ||
open lean.parser interactive interactive.types | ||
open tactic.interactive (generalize cases_arg_p) | ||
local postfix `?`:9000 := optional | ||
|
||
meta def lambdas : list expr → expr → tactic expr | ||
| (v@(expr.local_const uniq pp info _) :: es) f := do | ||
t ← infer_type v, | ||
f' ← lambdas es f, | ||
return $ expr.lam pp info t $ expr.abstract_local f' uniq | ||
| _ f := return f | ||
|
||
meta def co_cases (pat : parse cases_arg_p) (ns : parse with_ident_list) : tactic unit := | ||
do ls ← local_context, | ||
e ← to_expr pat.2, | ||
ls ← ls.mfilter (λ h, do | ||
t ← infer_type h, | ||
return $ e.occurs t), | ||
n ← revert_lst ls, | ||
generalize e `p, | ||
p ← intro1, | ||
t ← target, | ||
lam ← lambdas [p] t, | ||
refine ``(@cofix.cases _ _ %%lam _ %%p), | ||
clear p, | ||
when (e.is_local_constant ∧ pat.1.is_none) (clear e), | ||
intro_lst $ ns.take 2, | ||
intron (2 - ns.length), | ||
target >>= head_beta >>= change, | ||
intron n | ||
|
||
run_cmd add_interactive [`co_cases] | ||
|
||
end tactic |