mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
Improve derivation check algorithm
This commit is contained in:
parent
2fbbec0466
commit
16252b2145
|
@ -53,6 +53,9 @@ export function loadRSFormData(input: IRSFormData): IRSForm {
|
|||
// Calculate derivation of constituents based on formal definition analysis
|
||||
result.graph.topologicalOrder().forEach(id => {
|
||||
const cst = result.items.find(item => item.id === id)!;
|
||||
if (cst.cst_type === CstType.STRUCTURED) {
|
||||
return;
|
||||
}
|
||||
const resolvedInput: Set<ConstituentaID> = new Set();
|
||||
let definition = '';
|
||||
if (!isFunctional(cst.cst_type)) {
|
||||
|
@ -62,13 +65,34 @@ export function loadRSFormData(input: IRSFormData): IRSForm {
|
|||
} else {
|
||||
const expression = splitTemplateDefinition(cst.definition_formal);
|
||||
definition = expression.body;
|
||||
const dependencies = extractGlobals(definition);
|
||||
dependencies.forEach(alias => {
|
||||
const bodyDependencies = extractGlobals(definition);
|
||||
bodyDependencies.forEach(alias => {
|
||||
const targetCst = result.items.find(item => item.alias === alias);
|
||||
if (targetCst) {
|
||||
resolvedInput.add(derivationLookup.get(targetCst.id)!);
|
||||
}
|
||||
});
|
||||
const needCheckHead = () => {
|
||||
if (resolvedInput.size === 0) {
|
||||
return true;
|
||||
} else if (resolvedInput.size !== 1) {
|
||||
return false;
|
||||
} else {
|
||||
const base = result.items.find(item => item.id === resolvedInput.values().next().value)!;
|
||||
return (
|
||||
!isFunctional(base.cst_type) || splitTemplateDefinition(base.definition_formal).head !== expression.head
|
||||
);
|
||||
}
|
||||
};
|
||||
if (needCheckHead()) {
|
||||
const headDependencies = extractGlobals(expression.head);
|
||||
headDependencies.forEach(alias => {
|
||||
const targetCst = result.items.find(item => item.alias === alias);
|
||||
if (targetCst && !isBaseSet(targetCst.cst_type)) {
|
||||
resolvedInput.add(derivationLookup.get(targetCst.id)!);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (resolvedInput.size === 1 && isSimpleExpression(definition)) {
|
||||
const parent = result.items.find(item => item.id === resolvedInput.values().next().value)!;
|
||||
|
|
|
@ -22,6 +22,7 @@ const simpleExpressionData = [
|
|||
['ℬℬ(X1)', 'false'],
|
||||
['ℬ(X1)', 'false'],
|
||||
['D{(α,β)∈D6×D6 | α≠β & α∩β≠∅}', 'false'],
|
||||
['D{ξ ∈ X1 | (ξ,ξ)∈S1 }', 'false'],
|
||||
['I{(β,α) | α:∈D2; σ:=F5[α]; β:∈σ}', 'false'],
|
||||
['∀σ∈S1 (F1[σ]×F1[σ])∩D11=∅', 'false']
|
||||
];
|
||||
|
|
|
@ -29,7 +29,7 @@ function ConstituentaToolbar({
|
|||
onCreate
|
||||
}: ConstituentaToolbarProps) {
|
||||
return (
|
||||
<Overlay position='top-1 right-4 sm:right-1/2 sm:translate-x-1/2' className='cc-icons'>
|
||||
<Overlay position='top-1 right-4' className='cc-icons sm:right-1/2 sm:translate-x-1/2'>
|
||||
<MiniButton
|
||||
titleHtml={prepareTooltip('Сохранить изменения', 'Ctrl + S')}
|
||||
icon={<IconSave size='1.25rem' className='icon-primary' />}
|
||||
|
|
|
@ -97,7 +97,7 @@ function EditorConstituenta({ activeCst, isModified, setIsModified, onOpenEdit }
|
|||
className={clsx(
|
||||
'max-w-[95rem]', // prettier: split lines
|
||||
'flex',
|
||||
{ 'flex-col items-center': isNarrow }
|
||||
{ 'flex-col md:items-center': isNarrow }
|
||||
)}
|
||||
onKeyDown={handleInput}
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue
Block a user