benbrastmckie / ModelChecker

A hyperintensional theorem prover for counterfactual conditional, modal, constitutive explanatory, relevance, and extensional operators.
https://pypi.org/project/model-checker/
6 stars 0 forks source link

recursive interpretation #53

Closed benbrastmckie closed 3 weeks ago

benbrastmckie commented 3 weeks ago

The way it used to go was that in each sentence object, the immediate subsentences (called arguments) for that sentence would be stored as sentence objects. This created a class tree of sorts. It was really convenient, since it made it easy to look up the sentence objects for the arguments of any sentence. For instance, the all_sentences dictionary could very easily be built up by gathering all premises, conclusions, and recursively adding the arguments of each. Something similar would happen when it came time to instantiate() in ModelConstraints or to interpret() in ModelStructure.

I tried to do something similar in Syntax with initialize() which created prefix types for all sentences. My aim was to remove the dependency on operator_collection from Sentence, moving it to Syntax where it seemed to belong. I'm not totally sure why it was so hard, but moving things around seemed to break things. This makes me think that it was pretty fragile the way it was before, so not a bad thing to change it around. It seemed that prefix_sentence would end up getting overwritten before interpretation would happen, where this was something to do with how it would proceed recursively.

Now the dictionary of all sentence objects gets sorted by complexity and interpreted in that order. There is nevertheless something nice about the way sentences would get interpreted recursively by first interpreting their arguments since this doesn't rely on complexity or sorting the sentences before interpreting them. Interpreting recursively also nicely matches the way things go in semantics. At the very least, I'd like to know what was causing the problem with interpreting recursively.

I may keep messing around with this, but for now this reports on what I tried. It is working as is, and seems to be relatively readable even if it doesn't bring out as many parallels with semantics.

benbrastmckie commented 3 weeks ago

I got this working. Just needed to be a bit more systematic about my approach. As a result, complexity is no longer needed, but stored as an attribute anyhow.