Maketrue/makefalse behave unintuitively

Issue #718 resolved
fredericg created an issue

When a structure is passed from one procedure to another, and modified in the other, the original non changed interpreted symbols get lost, and so leads to an inconsistent structure.

Is there a way do this properly? (see attached example)

Comments (9)

  1. Bart Bogaerts

    Wat gaat er mis? En wat verwacht je?

    Als je de oorspronkelijke structuur wil bijhouden kan je hem clonen...

    strucclone= clone(struc)

  2. fredericg reporter
    vocabulary voc{
        type Klant
        type Bedrag isa int
        Aankoop(Klant, Bedrag)
        Tabel(Bedrag)
    }
    
    structure sample_struc:voc{
        Bedrag = {1..5}
        Tabel = {1;2;3;4;5}
    }
    
    theory theo:voc{}
    
    include <mx>
    procedure main(){
        local modifiedStruc = modifyStruc(sample_struc)
        print(modifiedStruc)
        printmodels(modelexpand(theo, modifiedStruc))
    }
    
    procedure modifyStruc(struc){
        struc[voc::Klant.type] = {"Jan"}
        print(struc)
        maketrue(struc[voc::Aankoop], {"Jan", 3})
        return struc
    }
    

    De lijn

    maketrue(struc[voc::Aankoop], {"Jan", 3})
    

    Maakt de structuur inconsistent, alleen heb ik geen idee waarom, Bedrag gaat van 1 tot 5 en in type Klant zit Jan..

  3. Broes De Cat

    Het probleem is als volgt: Als je een type overschrijft, zijn alle atomen van relaties over dat type default false (want ze lagen ervoor al buiten het domein en blijven false). Daarnaast maakt maketrue (momenteel) een structuur altijd meer precies. Dus als een atoom al false was, wordt het nu inconsistent (ipv de true die je verwacht, wordt aan gewerkt ;) ).

    Dus concreet: oplossing is eerst dat atoom unknown te maken en dan true. makeunknown(struc[voc::Aankoop], {"Jan", 3}) maketrue(struc[voc::Aankoop], {"Jan", 3})

  4. Log in to comment