@@ -39,7 +39,12 @@ function contradiction_worker(
3939 }
4040 }
4141
42- let contradiction : string [ ] = [ ]
42+ let contradictory_property : string | null = null
43+
44+ const used_implications : {
45+ implication : NormalizedCategoryImplication
46+ relevant : boolean
47+ } [ ] = [ ]
4348
4449 const deduced_satisfied_properties = new Set ( satisfied_properties )
4550
@@ -57,19 +62,47 @@ function contradiction_worker(
5762 const implication = get_next_implication ( )
5863 if ( ! implication ) break
5964
60- let segment = `${ [ ...implication . assumptions ] . join ( ' ∧ ' ) } ⟹ ${ implication . conclusion } `
65+ used_implications . push ( { implication, relevant : false } )
66+ deduced_satisfied_properties . add ( implication . conclusion )
6167
6268 if ( unsatisfied_properties . has ( implication . conclusion ) ) {
63- segment += ` ↯`
64- contradiction . push ( segment )
65- return contradiction
69+ contradictory_property = implication . conclusion
70+ break
71+ }
72+ }
73+
74+ if ( ! contradictory_property ) return null
75+
76+ // remove irrelevant implications
77+
78+ const relevant_properties = new Set ( [ contradictory_property ] )
79+
80+ for ( let i = used_implications . length - 1 ; i >= 0 ; i -- ) {
81+ const { implication } = used_implications [ i ]
82+ const is_relevant = relevant_properties . has ( implication . conclusion )
83+
84+ if ( is_relevant ) {
85+ used_implications [ i ] . relevant = is_relevant
86+ for ( const p of implication . assumptions ) {
87+ if ( ! satisfied_properties . has ( p ) ) relevant_properties . add ( p )
88+ }
6689 }
90+ }
6791
92+ const relevant_implications = used_implications
93+ . filter ( ( item ) => item . relevant )
94+ . map ( ( item ) => item . implication )
95+
96+ const contradiction : string [ ] = [ ]
97+
98+ for ( let i = 0 ; i < relevant_implications . length ; i ++ ) {
99+ const implication = relevant_implications [ i ]
100+ let segment = `${ [ ...implication . assumptions ] . join ( ' ∧ ' ) } ⟹ ${ implication . conclusion } `
101+ if ( i === relevant_implications . length - 1 ) segment += ` ↯`
68102 contradiction . push ( segment )
69- deduced_satisfied_properties . add ( implication . conclusion )
70103 }
71104
72- return null
105+ return contradiction
73106}
74107
75108function get_normalized_category_implications ( ) {
0 commit comments