-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KD: Add reverse (length xs) = length xs proof.
- Loading branch information
1 parent
aac926f
commit a8e6844
Showing
3 changed files
with
45 additions
and
0 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,42 @@ | ||
----------------------------------------------------------------------------- | ||
Check failure on line 1 in Documentation/SBV/Examples/KnuckleDragger/RevLen.hs GitHub Actions / hlint
|
||
-- | | ||
-- Module : Documentation.SBV.Examples.KnuckleDragger.RevLen | ||
-- Copyright : (c) Levent Erkok | ||
-- License : BSD3 | ||
-- Maintainer: [email protected] | ||
-- Stability : experimental | ||
-- | ||
-- Proof that reversing a list does not change its length. | ||
----------------------------------------------------------------------------- | ||
|
||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeAbstractions #-} | ||
|
||
{-# OPTIONS_GHC -Wall -Werror #-} | ||
|
||
module Documentation.SBV.Examples.KnuckleDragger.RevLen where | ||
|
||
import Prelude hiding (length, reverse) | ||
|
||
import Data.SBV | ||
import Data.SBV.Tools.KnuckleDragger | ||
|
||
import Data.SBV.List (reverse, length) | ||
|
||
-- | @length xs == length (reverse xs)@ | ||
-- | ||
-- We have: | ||
-- | ||
-- >>> revLen | ||
-- Lemma: revLen Q.E.D. | ||
revLen :: IO Proven | ||
revLen = do | ||
let p :: SList Integer -> SBool | ||
p xs = length (reverse xs) .== length xs | ||
|
||
induct <- inductionPrinciple p | ||
|
||
lemma "revLen" | ||
(\(Forall @"xs" xs) -> p xs) | ||
[induct] |
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