Skip to content

Commit c571c93

Browse files
authored
flag redundant asserted traits (#211)
1 parent c0f7179 commit c571c93

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
disproveFormula,
1515
proveTheorem,
1616
} from './Logic/index.js'
17+
export { type Result } from './Logic/Prover.js'
1718
export { type Space, SpacePage } from './Space.js'
1819
export { type Theorem, SerializedTheorem } from './Theorem.js'
1920
export { type Trait } from './Trait.js'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script lang="ts">
2+
import { checkIfRedundant } from '@/stores/deduction'
3+
import context from '@/context'
4+
import type { Space, Property } from '@/types'
5+
import Table from '../Theorems/Table.svelte'
6+
export let space: Space
7+
export let property: Property
8+
const { theorems, traits } = context()
9+
$: result = checkIfRedundant(space, property, $theorems, $traits)
10+
</script>
11+
12+
{#if result.redundant}
13+
<div class="alert alert-warning">
14+
<strong>Notice:</strong>
15+
This asserted property can be deduced from the other asserted traits for this
16+
space, due to the following theorems.
17+
</div>
18+
<Table theorems={result.theorems} />
19+
{/if}

packages/viewer/src/components/Traits/Show.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import type { Space, Property, Trait, Proof as ProofT } from '@/models'
33
import { Icons, Link, References, Source, Typeset } from '@/components/Shared'
44
import Proof from './Proof.svelte'
5+
import Redundancy from './Redundancy.svelte'
6+
import { contributingUrl } from '@/constants'
57
export let space: Space
68
export let property: Property
79
export let trait: Trait | undefined
@@ -36,7 +38,6 @@
3638
))[]
3739
}
3840
| undefined
39-
import { contributingUrl } from '@/constants'
4041
</script>
4142
4243
<h3>Space S{space.id} | Property P{property.id}</h3>
@@ -73,6 +74,7 @@
7374
</section>
7475
<h3>References</h3>
7576
<References references={meta.refs} />
77+
<Redundancy {space} {property} />
7678
{:else}
7779
Please consider <a href={contributingUrl}>contributing</a> a proof or disproof
7880
of this property.

packages/viewer/src/stores/deduction.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,31 @@ function loadProof(
188188

189189
return result
190190
}
191+
192+
export function checkIfRedundant(
193+
space: Space,
194+
property: Property,
195+
thms: Theorems,
196+
traits: Traits,
197+
): { redundant: boolean; theorems: Theorem[] } {
198+
const assertedTraits = traits.forSpace(space).filter(([_, t]) => t.asserted)
199+
const map = new Map(
200+
assertedTraits.map(([p, t]) => {
201+
if (p === property) {
202+
return [p.id, !t.value]
203+
} else {
204+
return [p.id, t.value]
205+
}
206+
}),
207+
)
208+
const result = deduceTraits(indexTheorems(thms), map)
209+
const redundant = result.kind === 'contradiction'
210+
if (!redundant) {
211+
const theorems: Theorem[] = []
212+
return { redundant, theorems }
213+
}
214+
const theorems = result.contradiction.theorems
215+
.map(t => thms.find(t))
216+
.filter(t => t !== null)
217+
return { redundant, theorems }
218+
}

0 commit comments

Comments
 (0)