11import { STRUCTURE_MAPS , STRUCTURES_WITH_DUALS , type StructureType } from './config'
2- import { are_equal_sets , get_client , parse_json_set } from './utils/helpers'
2+ import { are_equal_sets , parse_json_set } from './utils/helpers'
3+ import { get_client } from './utils/db'
34
45const db = get_client ( )
56
@@ -24,9 +25,9 @@ export function create_dualized_implications(type: StructureType) {
2425 assumptions : string
2526 conclusions : string
2627 dual_assumptions : string
28+ dual_conclusions : string
2729 dual_source_assumptions : string
2830 dual_target_assumptions : string
29- dual_conclusions : string
3031 }
3132 > (
3233 `SELECT
@@ -42,22 +43,22 @@ export function create_dualized_implications(type: StructureType) {
4243 ) AS dual_assumptions,
4344 (
4445 SELECT json_group_array(p.dual_property_id)
45- FROM source_assumptions a
46+ FROM conclusions a
4647 LEFT JOIN properties p ON p.id = a.property_id
4748 WHERE a.implication_id = i.id
48- ) AS dual_source_assumptions ,
49+ ) AS dual_conclusions ,
4950 (
5051 SELECT json_group_array(p.dual_property_id)
51- FROM target_assumptions a
52+ FROM source_assumptions a
5253 LEFT JOIN properties p ON p.id = a.property_id
5354 WHERE a.implication_id = i.id
54- ) AS dual_target_assumptions ,
55+ ) AS dual_source_assumptions ,
5556 (
5657 SELECT json_group_array(p.dual_property_id)
57- FROM conclusions a
58+ FROM target_assumptions a
5859 LEFT JOIN properties p ON p.id = a.property_id
5960 WHERE a.implication_id = i.id
60- ) AS dual_conclusions
61+ ) AS dual_target_assumptions
6162 FROM implications_view i
6263 WHERE i.type = ? AND i.is_deduced = FALSE` ,
6364 )
@@ -92,7 +93,7 @@ export function create_dualized_implications(type: StructureType) {
9293 VALUES (?, ?, ?, ?)
9394 ` )
9495
95- const mapped_assumption_inserts = {
96+ const associated_assumption_inserts = {
9697 source : source_assumption_insert ,
9798 target : target_assumption_insert ,
9899 }
@@ -124,7 +125,7 @@ export function create_dualized_implications(type: StructureType) {
124125
125126 count ++
126127
127- const mapped_dual_assumptions = {
128+ const associated_dual_assumptions = {
128129 source : dual_source_assumptions ,
129130 target : dual_target_assumptions ,
130131 }
@@ -149,8 +150,8 @@ export function create_dualized_implications(type: StructureType) {
149150 const [ name , from , to ] = map
150151 if ( from !== type ) continue
151152
152- for ( const assumption of mapped_dual_assumptions [ name ] ?? [ ] ) {
153- mapped_assumption_inserts [ name ] . run ( dual_id , assumption , type , to )
153+ for ( const assumption of associated_dual_assumptions [ name ] ?? [ ] ) {
154+ associated_assumption_inserts [ name ] . run ( dual_id , assumption , type , to )
154155 }
155156 }
156157 }
@@ -169,7 +170,9 @@ export function create_self_dual_implications(type: StructureType) {
169170
170171 const relevant_props = db
171172 . prepare < [ StructureType ] , { id : string ; dual : string } > (
172- `SELECT id, dual_property_id AS dual
173+ `SELECT
174+ id,
175+ dual_property_id AS dual
173176 FROM properties
174177 WHERE
175178 type = ?
@@ -180,17 +183,20 @@ export function create_self_dual_implications(type: StructureType) {
180183 . all ( type )
181184
182185 const implication_insert = db . prepare ( `
183- INSERT INTO implications (id, type, proof, is_deduced)
186+ INSERT INTO implications
187+ (id, type, proof, is_deduced)
184188 VALUES (?, ?, 'This holds by self-duality.', TRUE)
185189 ` )
186190
187191 const assumption_insert = db . prepare ( `
188- INSERT INTO assumptions (implication_id, property_id, type)
192+ INSERT INTO assumptions
193+ (implication_id, property_id, type)
189194 VALUES (?, ?, ?)
190195 ` )
191196
192197 const conclusion_insert = db . prepare ( `
193- INSERT INTO conclusions (implication_id, property_id, type)
198+ INSERT INTO conclusions
199+ (implication_id, property_id, type)
194200 VALUES (?, ?, ?)
195201 ` )
196202
0 commit comments