Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flag redundant asserted traits #211

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 19 additions & 0 deletions packages/viewer/src/components/Traits/Redundancy.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script lang="ts">
import { checkIfRedundant } from '@/stores/deduction'
import context from '@/context'
import type { Space, Property } from '@/types'
import Table from '../Theorems/Table.svelte'
export let space: Space
export let property: Property
const { theorems, traits } = context()
$: result = checkIfRedundant(space, property, $theorems, $traits)
</script>

{#if result.redundant}
<div class="alert alert-warning">
<strong>Notice:</strong>
This asserted property can be deduced from the other asserted traits for this
space, due to the following theorems.
</div>
<Table theorems={result.theorems} />
{/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 @@ -73,6 +74,7 @@
</section>
<h3>References</h3>
<References references={meta.refs} />
<Redundancy {space} {property} />
{:else}
Please consider <a href={contributingUrl}>contributing</a> a proof or disproof
of this property.
Expand Down
28 changes: 28 additions & 0 deletions packages/viewer/src/stores/deduction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,31 @@ function loadProof(

return result
}

export function checkIfRedundant(
space: Space,
property: Property,
thms: Theorems,
traits: Traits,
): { redundant: boolean; theorems: Theorem[] } {
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]
}
}),
)
const result = deduceTraits(indexTheorems(thms), map)
const redundant = result.kind === 'contradiction'
if (!redundant) {
const theorems: Theorem[] = []
return { redundant, theorems }
}
const theorems = result.contradiction.theorems
.map(t => thms.find(t))
.filter(t => t !== null)
return { redundant, theorems }
}
Loading