on master help sign in
Merge pull request #4094 from joom/master

Add splitPair tactic to Pruviloj

commitf70b942ca9b624ab1a2ee7c989ab1ee708ea7698 authorAhmad Salim Al-Sibahi <asal@itu.dk> dateTue 3 Oct 2017, 09:38 (9 years ago) parente32d0c318b99b5
2 files changed+16−1
CHANGELOG.md+1−1 libs/pruviloj/Pruviloj/Core.idr+15
CHANGELOG.md+1−1
@@ -11,7 +11,7 @@
1111
1212+ Added `Text.Literate`, a module for working with literate source files.
1313+ Added `Data.IORef`, for working with mutable references in `IO`.
14−+ Added `discriminate` tactic to Pruviloj.
14++ Added `discriminate` and `splitPair` tactics to Pruviloj.
1515
1616## Tool Updates
1717+ Private functions are no longer visible in the REPL except for modules
libs/pruviloj/Pruviloj/Core.idr+15
@@ -256,6 +256,21 @@ unproduct tm =
256256 try (unproduct (Var n1))
257257 try (unproduct (Var n2))
258258
259+||| If the goal is a tuple or a dependent pair, then split it into
260+||| two goals and return the new goal names.
261+||| It fails if the goal is neither a `Pair` nor a `DPair`.
262+splitPair : Elab (TTName, TTName)
263+splitPair =
264+ let bug = [TextPart "Splitting created wrong number of holes"] in
265+ case !goalType of
266+ `(Pair ~A ~B) => do [x, y] <- apply `(MkPair {A=~A} {B=~B}) [False, False]
267+ | _ => fail bug
268+ solve ; pure (x, y)
269+ `(DPair ~A ~Pr) => do [x, y] <- apply `(MkDPair {a=~A} {P=~Pr}) [False, False]
270+ | _ => fail bug
271+ solve ; pure (x, y)
272+ _ => fail [TextPart "Goal is not a pair"]
273+
259274||| A special-purpose tactic that attempts to solve a goal using
260275||| `Refl`. This is useful for ensuring that goals in fact are trivial
261276||| when developing or testing other tactics; otherwise, consider