Skip to content

Commit

Permalink
flag redundant asserted traits
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenClontz committed Dec 13, 2024
1 parent c0f7179 commit 2cb0345
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
disproveFormula,
proveTheorem,
} from './Logic/index.js'
export { type Result } from './Logic/Prover.js'
export { type Space, SpacePage } from './Space.js'
export { type Theorem, SerializedTheorem } from './Theorem.js'
export { type Trait } from './Trait.js'
Expand Down
16 changes: 16 additions & 0 deletions packages/viewer/src/components/Traits/Redundancy.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script lang="ts">
import { checkNegation } from '@/stores/deduction'
import context from '@/context'
import type { Space, Property } from '@/types'
export let space: Space
export let property: Property
const { theorems, traits } = context()
$: redundant = checkNegation($theorems, space, $traits, property).kind === "contradiction"
</script>

{#if redundant}
<div class="alert alert-warning">
This asserted property can be deduced from the other asserted traits for
this space.
</div>
{/if}
4 changes: 3 additions & 1 deletion packages/viewer/src/components/Traits/Show.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import type { Space, Property, Trait, Proof as ProofT } from '@/models'
import { Icons, Link, References, Source, Typeset } from '@/components/Shared'
import Proof from './Proof.svelte'
import Redundancy from './Redundancy.svelte'
import { contributingUrl } from '@/constants'
export let space: Space
export let property: Property
export let trait: Trait | undefined
Expand Down Expand Up @@ -36,7 +38,6 @@
))[]
}
| undefined
import { contributingUrl } from '@/constants'
</script>
<h3>Space S{space.id} | Property P{property.id}</h3>
Expand Down Expand Up @@ -71,6 +72,7 @@
<section class="description-markdown">
<Source source={meta.description} internal external />
</section>
<Redundancy {space} {property} />
<h3>References</h3>
<References references={meta.refs} />
{:else}
Expand Down
20 changes: 20 additions & 0 deletions packages/viewer/src/stores/deduction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
Traits,
} from '@/models'
import { eachTick, read, subscribeUntil } from '@/util'
import type { Result } from '@pi-base/core'

export type State = {
checked: Set<number>
Expand Down Expand Up @@ -188,3 +189,22 @@ function loadProof(

return result
}

export function checkNegation(
theorems: Theorems,
space: Space,
traits: Traits,
property: Property,
): Result<number, number> {
const assertedTraits = traits.forSpace(space).filter(([_, t]) => t.asserted)
const map = new Map(
assertedTraits.map(([p, t]) => {
if (p === property) {
return [p.id, !t.value]
} else {
return [p.id, t.value]
}
}),
)
return deduceTraits(indexTheorems(theorems), map)
}

0 comments on commit 2cb0345

Please sign in to comment.