summaryrefslogtreecommitdiff
path: root/source/Test/Unit/Kernel.hs
diff options
context:
space:
mode:
authoradelon <22380201+adelon@users.noreply.github.com>2026-07-28 14:47:19 +0200
committeradelon <22380201+adelon@users.noreply.github.com>2026-07-28 14:51:24 +0200
commit331d86e4a00bae144b6539edeb1deb9af78c5c7e (patch)
tree203567e38b79d2eecabe12fee0642eadd18e1a59 /source/Test/Unit/Kernel.hs
parent63503003ca8022ad9890396866f52bf56bcb252d (diff)
Prepare direct inductive kernel proofs
Diffstat (limited to 'source/Test/Unit/Kernel.hs')
-rw-r--r--source/Test/Unit/Kernel.hs73
1 files changed, 73 insertions, 0 deletions
diff --git a/source/Test/Unit/Kernel.hs b/source/Test/Unit/Kernel.hs
index 1cc481a..c8ed786 100644
--- a/source/Test/Unit/Kernel.hs
+++ b/source/Test/Unit/Kernel.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE PatternSynonyms #-}
module Test.Unit.Kernel (unitTests) where
@@ -8,6 +9,10 @@ import Checking.Foundation qualified as Foundation
import Checking.Kernel.Derivation
import Checking.Kernel.Semantics qualified as Semantics
import Checking.Kernel.SetLfp qualified as SetLfp
+import Checking.Transition (checkedGlobalType)
+import Checking.Typed.Inductive qualified as Inductive
+import Report.Location (pattern Nowhere)
+import Syntax.Internal qualified as Internal
import Data.Set qualified as Set
import Data.Vector qualified as Vector
@@ -37,6 +42,9 @@ unitTests =
"checks and replays the exact set fixed-point rules"
checksSetLfpRules
, testCase
+ "replays direct inductive facts"
+ replaysDirectInductiveFacts
+ , testCase
"rejects altered set fixed-point applications"
rejectsAlteredSetLfpApplications
, testCase
@@ -413,6 +421,71 @@ checksSetLfpRules = do
(Set.singleton Foundation.SetLfpBound)
(replayedKernelRuleUses replayed)
+replaysDirectInductiveFacts :: Assertion
+replaysDirectInductiveFacts = do
+ foundation <-
+ expectRight Foundation.checkedFoundation
+ traverse_
+ (replayInductive foundation)
+ [ Inductive.DirectInductive
+ []
+ (Internal.EmptySet Nowhere)
+ (Inductive.DirectInductiveClause
+ []
+ []
+ (Internal.EmptySet Nowhere)
+ :| [])
+ , let x = Internal.NamedVar "x"
+ in Inductive.DirectInductive
+ []
+ (Internal.EmptySet Nowhere)
+ ( Inductive.DirectInductiveClause
+ []
+ []
+ (Internal.EmptySet Nowhere)
+ :| [ Inductive.DirectInductiveClause
+ [x]
+ [Inductive.DirectRecursiveCondition
+ (Internal.TermVar x)]
+ (Internal.TermVar x)
+ ]
+ )
+ ]
+ where
+ replayInductive foundation inductive = do
+ prepared <-
+ expectRight
+ (Inductive.prepareTypedInductive
+ foundation
+ (const Nothing)
+ (Internal.Marker "direct_inductive")
+ inductive)
+ imports <-
+ traverse
+ (expectRight . derivationImportJudgment)
+ (Inductive.typedInductiveGuardTargets
+ prepared)
+ traverse_
+ (\fact -> do
+ replayed <-
+ expectRight
+ (replayKernelDerivation
+ foundation
+ defaultKernelReplayLimits
+ (Just . checkedGlobalType)
+ imports
+ (Inductive.typedInductiveFactTarget
+ fact)
+ (Inductive.typedInductiveFactDerivation
+ fact))
+ assertEqual
+ "replay target"
+ (Inductive.typedInductiveFactTarget
+ fact)
+ (replayedKernelTarget replayed))
+ (Inductive.typedInductiveFacts
+ prepared)
+
rejectsAlteredSetLfpApplications :: Assertion
rejectsAlteredSetLfpApplications = do
foundation <-