-
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.
- Loading branch information
1 parent
ca6ad32
commit cc2e013
Showing
2 changed files
with
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
----------------------------------------------------------------------------- | ||
Check failure on line 1 in Documentation/SBV/Examples/KnuckleDragger/Tao.hs GitHub Actions / hlint
|
||
-- | | ||
-- Module : Documentation.SBV.Examples.KnuckleDragger.Tao | ||
-- Copyright : (c) Levent Erkok | ||
-- License : BSD3 | ||
-- Maintainer: [email protected] | ||
-- Stability : experimental | ||
-- | ||
-- Proves a problem originating in algebra: | ||
-- https://mathoverflow.net/questions/450890/is-there-an-identity-between-the-commutative-identity-and-the-constant-identity/ | ||
-- | ||
-- Apparently this was posed by Terrence Tao: https://mathstodon.xyz/@tao/110736805384878353 | ||
-- | ||
-- Essentially, for an arbitrary binary operation op, we prove that | ||
-- | ||
-- @ | ||
-- (x op x) op y == y op x | ||
-- @ | ||
-- | ||
-- Implies that @op@ must be commutative. | ||
----------------------------------------------------------------------------- | ||
|
||
|
||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE TypeAbstractions #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
{-# OPTIONS_GHC -Wall -Werror #-} | ||
|
||
module Documentation.SBV.Examples.KnuckleDragger.Tao where | ||
|
||
import Data.SBV | ||
import Data.SBV.Tools.KnuckleDragger | ||
|
||
-- | Create an uninterpreted type to do the proofs over. | ||
data T | ||
mkUninterpretedSort ''T | ||
|
||
-- | Prove that: | ||
-- | ||
-- @ | ||
-- (x op x) op y == y op x | ||
-- @ | ||
-- | ||
-- means that @op@ is commutative. | ||
-- | ||
-- We have: | ||
-- | ||
-- >>> tao | ||
-- Lemma: tao Q.E.D. | ||
-- [Proven] tao | ||
tao :: IO Proof | ||
tao = runKD $ do | ||
let op :: ST -> ST -> ST | ||
op = uninterpret "op" | ||
|
||
lemma "tao" ( quantifiedBool (\(Forall @"x" x) (Forall @"y" y) -> ((x `op` x) `op` y) .== y `op` x) | ||
.=> quantifiedBool (\(Forall @"x" x) (Forall @"y" y) -> (x `op` y) .== (y `op` x))) | ||
[] |
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