model-checker 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- model_checker-0.7.2/LICENCE +19 -0
- model_checker-0.7.2/PKG-INFO +204 -0
- model_checker-0.7.2/README.md +188 -0
- model_checker-0.7.2/pyproject.toml +30 -0
- model_checker-0.7.2/setup.cfg +4 -0
- model_checker-0.7.2/src/__init__.py +0 -0
- model_checker-0.7.2/src/model_checker/__init__.py +78 -0
- model_checker-0.7.2/src/model_checker/__main__.py +547 -0
- model_checker-0.7.2/src/model_checker/builder.py +134 -0
- model_checker-0.7.2/src/model_checker/champollion.py +941 -0
- model_checker-0.7.2/src/model_checker/defined.py +296 -0
- model_checker-0.7.2/src/model_checker/examples.py +525 -0
- model_checker-0.7.2/src/model_checker/model.py +694 -0
- model_checker-0.7.2/src/model_checker/primitive.py +946 -0
- model_checker-0.7.2/src/model_checker/semantic.py +568 -0
- model_checker-0.7.2/src/model_checker/syntactic.py +497 -0
- model_checker-0.7.2/src/model_checker/template/__init__.py +0 -0
- model_checker-0.7.2/src/model_checker/template/examples.py +432 -0
- model_checker-0.7.2/src/model_checker/template/operators.py +960 -0
- model_checker-0.7.2/src/model_checker/template/semantic.py +561 -0
- model_checker-0.7.2/src/model_checker/utils.py +293 -0
- model_checker-0.7.2/src/model_checker.egg-info/PKG-INFO +204 -0
- model_checker-0.7.2/src/model_checker.egg-info/SOURCES.txt +32 -0
- model_checker-0.7.2/src/model_checker.egg-info/dependency_links.txt +1 -0
- model_checker-0.7.2/src/model_checker.egg-info/entry_points.txt +2 -0
- model_checker-0.7.2/src/model_checker.egg-info/requires.txt +1 -0
- model_checker-0.7.2/src/model_checker.egg-info/top_level.txt +2 -0
- model_checker-0.7.2/test/test_champollion.py +118 -0
- model_checker-0.7.2/test/test_constitutive.py +1257 -0
- model_checker-0.7.2/test/test_counterfactuals.py +829 -0
- model_checker-0.7.2/test/test_extensional.py +167 -0
- model_checker-0.7.2/test/test_imposition.py +830 -0
- model_checker-0.7.2/test/test_modals.py +447 -0
- model_checker-0.7.2/test/test_relevance.py +549 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2024 Benjamin Brast-McKie
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: model-checker
|
|
3
|
+
Version: 0.7.2
|
|
4
|
+
Summary: A hyperintensional theorem prover for modal, counterfactual conditional, constitutive explanatory, and extensional operators.
|
|
5
|
+
Author-email: Benjamin Brast-McKie <benbrastmckie@gmail.com>, Miguel Buitrago <mbuit82@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/benbrastmckie/ModelChecker
|
|
8
|
+
Project-URL: Issues, https://github.com/benbrastmckie/ModelChecker/issues
|
|
9
|
+
Keywords: semantics,Z3,logic,counterfactuals,modality,model checker,theorem prover,hyperintensionality
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENCE
|
|
15
|
+
Requires-Dist: z3-solver
|
|
16
|
+
|
|
17
|
+
This package draws on the SMT solver [Z3](https://github.com/Z3Prover/z3) to provide a [programmatic semantics]() for a number of hyperintensional operators along with a general purpose methodology for developing novel programmatic semantic theories and studying their resulting logics.
|
|
18
|
+
Rather than computing whether a given sentence is a logical consequence of some set of sentences by hand, these resources allow users to find countermodels or establish logical consequence up to a finite level complexity specified by the user.
|
|
19
|
+
Instead of only developing a model-theoretic version of a semantics and working out the consequence with pen and paper, this project provides tooling for finding hyperintensional countermodels and establish validity over models up to a user specified level of complexity in a propositional language with the following operators:
|
|
20
|
+
|
|
21
|
+
- `neg` for _negation_
|
|
22
|
+
- `wedge` for _conjunction_
|
|
23
|
+
- `vee` for _disjunction_
|
|
24
|
+
- `rightarrow` for the _material conditional_
|
|
25
|
+
- `leftrightarrow` for the _material biconditional_
|
|
26
|
+
- `boxright` for the _must counterfactual conditional_
|
|
27
|
+
- `circleright` for the _might counterfactual conditional_
|
|
28
|
+
- `Box` for _necessity_
|
|
29
|
+
- `Diamond` for _possibility_
|
|
30
|
+
- `leq` for _ground_ read 'sufficient for'
|
|
31
|
+
- `sqsubseteq` for _essence_ read 'necessary for'
|
|
32
|
+
- `equiv` for _propositional identity_ read 'just is for'
|
|
33
|
+
- `preceq` for _relevance_
|
|
34
|
+
|
|
35
|
+
### Screenshot
|
|
36
|
+
|
|
37
|
+
> NOTE: Additional images can be found [here](https://github.com/benbrastmckie/ModelChecker/blob/master/Images/screenshots.md).
|
|
38
|
+
|
|
39
|
+
## Programmatic Semantics
|
|
40
|
+
|
|
41
|
+
A programmatic methodology in semantics streamlines the otherwise computationally grueling process of developing and testing novel semantic theories and exploring their logics.
|
|
42
|
+
Although computational systems cannot search the space of all models (typically a proper class), the absence of bitvector countermodels up to a finite level of complexity provides evidence for logical consequence, where the strength of this evidence increases with the range of distinct models surveyed.
|
|
43
|
+
If finite countermodels exist, users will be able to generate and print those models rather than attempting to do so by hand.
|
|
44
|
+
|
|
45
|
+
The [hyperintensional semantics](#Hyperintensional-Semantics) for the operators indicated above is briefly discussed below.
|
|
46
|
+
In addition to including semantic clauses for the operators indicated above, this project provides templates and flexible tooling that can be adapted to accommodate new operators.
|
|
47
|
+
By easing the process of investigating increasingly complex semantic theories, this methodology aims to support the growth and maturity of semantics as a discipline.
|
|
48
|
+
|
|
49
|
+
Although computational resources are common place, the ability to make use of these resources to develop and explore the implications of novel semantic theories remains limited.
|
|
50
|
+
For instance, [Prover9 and Mace](https://www.cs.unm.edu/~mccune/prover9/) are restricted to first-order and equational statements.
|
|
51
|
+
However, for the purposes of semantics, it is desirable to: (1) introduce a range of primitive operators; (2) specify novel semantic clauses for those operators; (3) define frame constraints and a space of models for the resulting language; (4) test which sentences are a logical consequence of which; and (5) print readable countermodels if there are any.
|
|
52
|
+
Rather than displacing model theory and proof theory, developing and testing a programmatic semantics for a language aims to support the study of extensionally adequate logics before attempting to establish completeness.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
pip install model-checker
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The project has the `z3-solver` as a dependency and will be installed automatically.
|
|
61
|
+
More information can be found in the accessible installation [instructions](https://github.com/benbrastmckie/ModelChecker/blob/master/installation.md).
|
|
62
|
+
|
|
63
|
+
## Updating
|
|
64
|
+
|
|
65
|
+
Once installed, you can check the current version of the `model-checker` with:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
model-checker -v
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To update to the latest version, run:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
model-checker -u
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
Run `model-checker` in the terminal without arguments to create a new project with the following modules:
|
|
80
|
+
|
|
81
|
+
- `semantic.py` specifies the Z3 primitives, frame constraints, models, theory of logical consequence, defined semantic terms, theory of propositions, and instructions for displaying countermodels.
|
|
82
|
+
- `operators.py` specifies the semantic clauses for the primitive operators included in the default language along with a number of defined operators.
|
|
83
|
+
- `examples.py` specifies the settings, a number of examples, and the protocol for finding and printing countermodels if there are any.
|
|
84
|
+
|
|
85
|
+
After changing to the project directory that you created, run `model-checker project_examples.py` to find a countermodel if there is any.
|
|
86
|
+
The example settings specify the following inputs where the defaults are indicated below:
|
|
87
|
+
|
|
88
|
+
- The number of atomic states to include in each model: `N = 3`.
|
|
89
|
+
- An option to require all sentence letters to be contingent: `contingent = False`.
|
|
90
|
+
- An option to require all sentence letters to have at least one verifier and at least one falsifier: `non_empty = False`.
|
|
91
|
+
- An option to prevent sentence letters from having the null state as a verifier or a falsifier: `non_null = False`.
|
|
92
|
+
- An option to prevent sentence letters from having overlapping verifiers or falsifiers: `disjoint = False`.
|
|
93
|
+
- The maximum time in seconds to spend looking for a model: `max_time = 1`.
|
|
94
|
+
<!-- - Find a model with the smallest number of atomic elements: `optimize_bool = False`. -->
|
|
95
|
+
|
|
96
|
+
A number of general settings may also be specified with the following:
|
|
97
|
+
|
|
98
|
+
- An option to print impossible states: `print_impssible = False`.
|
|
99
|
+
- An option to print all Z3 constraints or unsatisfiable core constraints: `print_constraints = False`.
|
|
100
|
+
- An option to prompt the user to append the output to the current file or to create a new file: `save_output = False`.
|
|
101
|
+
|
|
102
|
+
Examples are specified by defining a list as follows:
|
|
103
|
+
```
|
|
104
|
+
# CF_CM_1: COUNTERFACTUAL ANTECEDENT STRENGTHENING
|
|
105
|
+
|
|
106
|
+
CF_CM_1_premises = ['(A \\boxright C)']
|
|
107
|
+
CF_CM_1_conclusions = ['((A \\wedge B) \\boxright C)']
|
|
108
|
+
CF_CM_1_settings = {
|
|
109
|
+
'N' : 3,
|
|
110
|
+
'contingent' : True,
|
|
111
|
+
'non_null' : True,
|
|
112
|
+
'non_empty' : True,
|
|
113
|
+
'disjoint' : False,
|
|
114
|
+
'max_time' : 1,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
CF_CM_1_example = [
|
|
118
|
+
CF_CM_1_premises,
|
|
119
|
+
CF_CM_1_conclusions,
|
|
120
|
+
CF_CM_1_settings,
|
|
121
|
+
]
|
|
122
|
+
```
|
|
123
|
+
The example `CF_CM_1_example` includes:
|
|
124
|
+
|
|
125
|
+
- A list of zero or more premises that are treated conjunctively: `premises = []`.
|
|
126
|
+
- A list of zero or more conclusions that are treated disjunctively: `conclusions = []`.
|
|
127
|
+
- A dictionary of settings where the defaults are indicated above.
|
|
128
|
+
|
|
129
|
+
Alternatively, users can define a general stock of `example_settings`, reusing these for an number of examples.
|
|
130
|
+
Users can override these settings from the command line by including the following flags:
|
|
131
|
+
|
|
132
|
+
- Include `-c` to set `contingent = True`.
|
|
133
|
+
- Include `-e` to set `non_empty = True`.
|
|
134
|
+
- Include `-n` to set `non_null = True`.
|
|
135
|
+
- Include `-d` to set `disjoint = True`.
|
|
136
|
+
- Include `-i` to set `print_impossibe = True`.
|
|
137
|
+
- Include `-p` to set `print_constraints = True`.
|
|
138
|
+
- Include `-s` to set `save_bool = True`.
|
|
139
|
+
|
|
140
|
+
Additional flags have been included in order to manage the package version:
|
|
141
|
+
|
|
142
|
+
- Include `-h` to print help information about the package and its usage.
|
|
143
|
+
- Include `-v` to print the installed version number.
|
|
144
|
+
- Include `-u` to upgrade to the latest version.
|
|
145
|
+
|
|
146
|
+
## Hyperintensional Semantics
|
|
147
|
+
|
|
148
|
+
This section sketches the underlying semantics.
|
|
149
|
+
More information can be found in the GitHub [repository](https://github.com/benbrastmckie/ModelChecker).
|
|
150
|
+
|
|
151
|
+
The semantics is hyperintensional insofar as sentences are evaluated at _states_ which may be partial rather than total as in intensional semantic theories.
|
|
152
|
+
States are modeled by bitvectors of a specified length (e.g., `#b00101` has length `5`), where _state fusion_ is modeled by the bitwise OR operator `|`.
|
|
153
|
+
For instance, `#b00101 | #b11001 = #b11101`.
|
|
154
|
+
The _atomic states_ have exactly one occurrence of `1` and the _null state_ has no occurrences of `1`.
|
|
155
|
+
The space of states is finite and closed under fusion.
|
|
156
|
+
|
|
157
|
+
States are named by lowercase letters in order to print readable countermodels.
|
|
158
|
+
Fusions are printed using `.` where `a.b` is the fusion of the states `a` and `b`.
|
|
159
|
+
A state `a` is _part_ of a state `b` just in case `a.b = b`.
|
|
160
|
+
States may be either _possible_ or _impossible_ where the null state is required to be possible and every part of a possible state is possible.
|
|
161
|
+
The states `a` and `b` are _compatible_ just in case `a.b` is possible.
|
|
162
|
+
A _world state_ is any state that is both possible and includes every compatible state as a part.
|
|
163
|
+
|
|
164
|
+
Sentences are assigned _verifier states_ and _falsifier states_ where both the verifiers and falsifiers are required to be closed under fusion.
|
|
165
|
+
A sentence is _true at_ a world state `w` just in case `w` includes a verifier for that sentence as a part and _false at_ `w` just in case `w` includes a falsifier for that sentence as a part.
|
|
166
|
+
In order to ensure that sentence letters have at most one truth-value at each world state, a fusion `a.b` is required to be impossible whenever `a` is verifier for a sentence letter `A` and `b` is a falsifier for `A`.
|
|
167
|
+
Additionally, sentence letters are guaranteed to have at least one truth-value at each world state by requiring every possible state to be compatible with either a verifier or falsifier for any sentence letter.
|
|
168
|
+
|
|
169
|
+
A _negated sentence_ is verified by the falsifiers for the sentence negated and falsified by the verifiers for the sentence negated.
|
|
170
|
+
A _conjunctive sentence_ is verified by the pairwise fusions of verifiers for the conjuncts and falsified by falsifiers for either of the conjuncts or fusions thereof.
|
|
171
|
+
A _disjunctive sentence_ is verified by the verifiers for either disjunct or fusions thereof and falsified by pairwise fusions of falsifiers for the disjuncts.
|
|
172
|
+
Conjunction and disjunction are dual operators obeying the standard idempotence and De Morgan laws.
|
|
173
|
+
The absorption laws do not hold, nor does conjunction distribute over disjunction, nor _vice versa_.
|
|
174
|
+
For a defense of the background theory of hyperintensional propositions, see this [paper](https://link.springer.com/article/10.1007/s10992-021-09612-w).
|
|
175
|
+
|
|
176
|
+
<!-- By contrast with the _bilateral_ extensional operators which treat both verifiers and falsifiers, the semantics for `not` is _unilateral_. -->
|
|
177
|
+
<!-- In particular `not A` is verified by a state `s` just in case every non-null part of `s` is incompatible with a verifier for `A` and every verifier for `A` is incompatible with some non-null part of `s`. -->
|
|
178
|
+
<!-- This semantics is further motivated and elaborated in [Bernard and Champollion](https://ling.auf.net/lingbuzz/007730/current.html) and included here for comparison. -->
|
|
179
|
+
|
|
180
|
+
A _necessity sentence_ `Box A` is true at a world just in case every world state includes a part that verifies `A` and a _possibility sentence_ `Diamond A` is true at a world just in case some world state includes a part that verifies `A`.
|
|
181
|
+
Given a world state `w` and state `s`, an `s`_-alternative_ to `w` is any world state to include as parts both `s` and a maximal part of `w` that is compatible with `s`.
|
|
182
|
+
A _must counterfactual conditional sentences_ `A boxright B` is true at a world state `w` just in case its consequent is true at any `s`-alternative to `w` for any verifier `s` for the antecedent of the counterfactual.
|
|
183
|
+
A _might counterfactual conditional sentences_ `A boxright B` is true at a world state `w` just in case its consequent is true at some `s`-alternative to `w` for some verifier `s` for the antecedent of the counterfactual.
|
|
184
|
+
The semantic theory for counterfactual conditionals is motivated and further elaborated in this accompanying [paper](https://github.com/benbrastmckie/ModelChecker/blob/master/Counterfactuals.pdf).
|
|
185
|
+
This account builds on [Fine 2012](https://www.pdcnet.org/jphil/content/jphil_2012_0109_0003_0221_0246) and [Fine2012a](https://link.springer.com/article/10.1007/s11229-012-0094-y?error=cookies_not_supported&code=5166a4da-1834-438c-9f93-75b61f58b6db).
|
|
186
|
+
|
|
187
|
+
A _grounding sentence_ `A leq B` may be read '`A` is _sufficient for_ `B`' and an _essence sentence_ `A sqsubseteq B` may be read '`A` is _necessary for_ `B`'.
|
|
188
|
+
A _propositional identity sentence_ `A equiv B` may be read '`A` _just is for_ `B`'.
|
|
189
|
+
A _relevance sentence_ `A preceq B` may be read '`A` _is wholly relevant to_ `B`'.
|
|
190
|
+
The semantics for ground requires every verifier for the antecedent to be a verifier for the consequent, any fusion of a falsifier for the antecedent and consequent to be a falsifier for the consequent, and any falsifier for the consequent to have a part that falsifies the antecedent.
|
|
191
|
+
The semantics for essence requires every fusion of a verifier for the antecedent and consequent to be a verifier for the consequent, any verifier for the consequent must have a part that verifies the antecedent, and every falsifier for the antecedent to be a falsifier for the consequent.
|
|
192
|
+
The semantics for propositional identity requires the two arguments to have the same verifiers and falsifiers.
|
|
193
|
+
The semantics for relevance requires any fusion of verifiers for the antecedent and consequent to be a verifier for the consequent and, similarly, any fusion of falsifiers for the antecedent and consequent to be a falsifier for the consequent.
|
|
194
|
+
Whereas the first three constitutive operators are interdefinable, relevance is definable in terms of the other constitutive operators but not _vice versa_:
|
|
195
|
+
|
|
196
|
+
- `A leq B := neg A sqsubseteq neg B := (A vee B) equiv B`.
|
|
197
|
+
- `A sqsubseteq B := neg A leq neg B := (A wedge B) equiv B`.
|
|
198
|
+
- `A equiv B := (A leq B) wedge (B leq A) := (A sqsubseteq B) wedge (B sqsubseteq A)`.
|
|
199
|
+
- `A preceq B := (A wedge B) leq B := (A vee B) sqsubseteq B`.
|
|
200
|
+
|
|
201
|
+
Instead of a Boolean lattice as in extensional and intensional semantics theories, the space of hyperintensional propositions forms a non-interlaced bilattice as described in this [paper](https://link.springer.com/article/10.1007/s10992-021-09612-w), building on [Fine 2017](https://link.springer.com/article/10.1007/s10992-016-9413-y).
|
|
202
|
+
|
|
203
|
+
More information can be found in the GitHub [repository](https://github.com/benbrastmckie/ModelChecker) as well as in this recent [manuscript](https://github.com/benbrastmckie/ModelChecker/blob/master/Counterfactuals.pdf).
|
|
204
|
+
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
This package draws on the SMT solver [Z3](https://github.com/Z3Prover/z3) to provide a [programmatic semantics]() for a number of hyperintensional operators along with a general purpose methodology for developing novel programmatic semantic theories and studying their resulting logics.
|
|
2
|
+
Rather than computing whether a given sentence is a logical consequence of some set of sentences by hand, these resources allow users to find countermodels or establish logical consequence up to a finite level complexity specified by the user.
|
|
3
|
+
Instead of only developing a model-theoretic version of a semantics and working out the consequence with pen and paper, this project provides tooling for finding hyperintensional countermodels and establish validity over models up to a user specified level of complexity in a propositional language with the following operators:
|
|
4
|
+
|
|
5
|
+
- `neg` for _negation_
|
|
6
|
+
- `wedge` for _conjunction_
|
|
7
|
+
- `vee` for _disjunction_
|
|
8
|
+
- `rightarrow` for the _material conditional_
|
|
9
|
+
- `leftrightarrow` for the _material biconditional_
|
|
10
|
+
- `boxright` for the _must counterfactual conditional_
|
|
11
|
+
- `circleright` for the _might counterfactual conditional_
|
|
12
|
+
- `Box` for _necessity_
|
|
13
|
+
- `Diamond` for _possibility_
|
|
14
|
+
- `leq` for _ground_ read 'sufficient for'
|
|
15
|
+
- `sqsubseteq` for _essence_ read 'necessary for'
|
|
16
|
+
- `equiv` for _propositional identity_ read 'just is for'
|
|
17
|
+
- `preceq` for _relevance_
|
|
18
|
+
|
|
19
|
+
### Screenshot
|
|
20
|
+
|
|
21
|
+
> NOTE: Additional images can be found [here](https://github.com/benbrastmckie/ModelChecker/blob/master/Images/screenshots.md).
|
|
22
|
+
|
|
23
|
+
## Programmatic Semantics
|
|
24
|
+
|
|
25
|
+
A programmatic methodology in semantics streamlines the otherwise computationally grueling process of developing and testing novel semantic theories and exploring their logics.
|
|
26
|
+
Although computational systems cannot search the space of all models (typically a proper class), the absence of bitvector countermodels up to a finite level of complexity provides evidence for logical consequence, where the strength of this evidence increases with the range of distinct models surveyed.
|
|
27
|
+
If finite countermodels exist, users will be able to generate and print those models rather than attempting to do so by hand.
|
|
28
|
+
|
|
29
|
+
The [hyperintensional semantics](#Hyperintensional-Semantics) for the operators indicated above is briefly discussed below.
|
|
30
|
+
In addition to including semantic clauses for the operators indicated above, this project provides templates and flexible tooling that can be adapted to accommodate new operators.
|
|
31
|
+
By easing the process of investigating increasingly complex semantic theories, this methodology aims to support the growth and maturity of semantics as a discipline.
|
|
32
|
+
|
|
33
|
+
Although computational resources are common place, the ability to make use of these resources to develop and explore the implications of novel semantic theories remains limited.
|
|
34
|
+
For instance, [Prover9 and Mace](https://www.cs.unm.edu/~mccune/prover9/) are restricted to first-order and equational statements.
|
|
35
|
+
However, for the purposes of semantics, it is desirable to: (1) introduce a range of primitive operators; (2) specify novel semantic clauses for those operators; (3) define frame constraints and a space of models for the resulting language; (4) test which sentences are a logical consequence of which; and (5) print readable countermodels if there are any.
|
|
36
|
+
Rather than displacing model theory and proof theory, developing and testing a programmatic semantics for a language aims to support the study of extensionally adequate logics before attempting to establish completeness.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
pip install model-checker
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The project has the `z3-solver` as a dependency and will be installed automatically.
|
|
45
|
+
More information can be found in the accessible installation [instructions](https://github.com/benbrastmckie/ModelChecker/blob/master/installation.md).
|
|
46
|
+
|
|
47
|
+
## Updating
|
|
48
|
+
|
|
49
|
+
Once installed, you can check the current version of the `model-checker` with:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
model-checker -v
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
To update to the latest version, run:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
model-checker -u
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
Run `model-checker` in the terminal without arguments to create a new project with the following modules:
|
|
64
|
+
|
|
65
|
+
- `semantic.py` specifies the Z3 primitives, frame constraints, models, theory of logical consequence, defined semantic terms, theory of propositions, and instructions for displaying countermodels.
|
|
66
|
+
- `operators.py` specifies the semantic clauses for the primitive operators included in the default language along with a number of defined operators.
|
|
67
|
+
- `examples.py` specifies the settings, a number of examples, and the protocol for finding and printing countermodels if there are any.
|
|
68
|
+
|
|
69
|
+
After changing to the project directory that you created, run `model-checker project_examples.py` to find a countermodel if there is any.
|
|
70
|
+
The example settings specify the following inputs where the defaults are indicated below:
|
|
71
|
+
|
|
72
|
+
- The number of atomic states to include in each model: `N = 3`.
|
|
73
|
+
- An option to require all sentence letters to be contingent: `contingent = False`.
|
|
74
|
+
- An option to require all sentence letters to have at least one verifier and at least one falsifier: `non_empty = False`.
|
|
75
|
+
- An option to prevent sentence letters from having the null state as a verifier or a falsifier: `non_null = False`.
|
|
76
|
+
- An option to prevent sentence letters from having overlapping verifiers or falsifiers: `disjoint = False`.
|
|
77
|
+
- The maximum time in seconds to spend looking for a model: `max_time = 1`.
|
|
78
|
+
<!-- - Find a model with the smallest number of atomic elements: `optimize_bool = False`. -->
|
|
79
|
+
|
|
80
|
+
A number of general settings may also be specified with the following:
|
|
81
|
+
|
|
82
|
+
- An option to print impossible states: `print_impssible = False`.
|
|
83
|
+
- An option to print all Z3 constraints or unsatisfiable core constraints: `print_constraints = False`.
|
|
84
|
+
- An option to prompt the user to append the output to the current file or to create a new file: `save_output = False`.
|
|
85
|
+
|
|
86
|
+
Examples are specified by defining a list as follows:
|
|
87
|
+
```
|
|
88
|
+
# CF_CM_1: COUNTERFACTUAL ANTECEDENT STRENGTHENING
|
|
89
|
+
|
|
90
|
+
CF_CM_1_premises = ['(A \\boxright C)']
|
|
91
|
+
CF_CM_1_conclusions = ['((A \\wedge B) \\boxright C)']
|
|
92
|
+
CF_CM_1_settings = {
|
|
93
|
+
'N' : 3,
|
|
94
|
+
'contingent' : True,
|
|
95
|
+
'non_null' : True,
|
|
96
|
+
'non_empty' : True,
|
|
97
|
+
'disjoint' : False,
|
|
98
|
+
'max_time' : 1,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
CF_CM_1_example = [
|
|
102
|
+
CF_CM_1_premises,
|
|
103
|
+
CF_CM_1_conclusions,
|
|
104
|
+
CF_CM_1_settings,
|
|
105
|
+
]
|
|
106
|
+
```
|
|
107
|
+
The example `CF_CM_1_example` includes:
|
|
108
|
+
|
|
109
|
+
- A list of zero or more premises that are treated conjunctively: `premises = []`.
|
|
110
|
+
- A list of zero or more conclusions that are treated disjunctively: `conclusions = []`.
|
|
111
|
+
- A dictionary of settings where the defaults are indicated above.
|
|
112
|
+
|
|
113
|
+
Alternatively, users can define a general stock of `example_settings`, reusing these for an number of examples.
|
|
114
|
+
Users can override these settings from the command line by including the following flags:
|
|
115
|
+
|
|
116
|
+
- Include `-c` to set `contingent = True`.
|
|
117
|
+
- Include `-e` to set `non_empty = True`.
|
|
118
|
+
- Include `-n` to set `non_null = True`.
|
|
119
|
+
- Include `-d` to set `disjoint = True`.
|
|
120
|
+
- Include `-i` to set `print_impossibe = True`.
|
|
121
|
+
- Include `-p` to set `print_constraints = True`.
|
|
122
|
+
- Include `-s` to set `save_bool = True`.
|
|
123
|
+
|
|
124
|
+
Additional flags have been included in order to manage the package version:
|
|
125
|
+
|
|
126
|
+
- Include `-h` to print help information about the package and its usage.
|
|
127
|
+
- Include `-v` to print the installed version number.
|
|
128
|
+
- Include `-u` to upgrade to the latest version.
|
|
129
|
+
|
|
130
|
+
## Hyperintensional Semantics
|
|
131
|
+
|
|
132
|
+
This section sketches the underlying semantics.
|
|
133
|
+
More information can be found in the GitHub [repository](https://github.com/benbrastmckie/ModelChecker).
|
|
134
|
+
|
|
135
|
+
The semantics is hyperintensional insofar as sentences are evaluated at _states_ which may be partial rather than total as in intensional semantic theories.
|
|
136
|
+
States are modeled by bitvectors of a specified length (e.g., `#b00101` has length `5`), where _state fusion_ is modeled by the bitwise OR operator `|`.
|
|
137
|
+
For instance, `#b00101 | #b11001 = #b11101`.
|
|
138
|
+
The _atomic states_ have exactly one occurrence of `1` and the _null state_ has no occurrences of `1`.
|
|
139
|
+
The space of states is finite and closed under fusion.
|
|
140
|
+
|
|
141
|
+
States are named by lowercase letters in order to print readable countermodels.
|
|
142
|
+
Fusions are printed using `.` where `a.b` is the fusion of the states `a` and `b`.
|
|
143
|
+
A state `a` is _part_ of a state `b` just in case `a.b = b`.
|
|
144
|
+
States may be either _possible_ or _impossible_ where the null state is required to be possible and every part of a possible state is possible.
|
|
145
|
+
The states `a` and `b` are _compatible_ just in case `a.b` is possible.
|
|
146
|
+
A _world state_ is any state that is both possible and includes every compatible state as a part.
|
|
147
|
+
|
|
148
|
+
Sentences are assigned _verifier states_ and _falsifier states_ where both the verifiers and falsifiers are required to be closed under fusion.
|
|
149
|
+
A sentence is _true at_ a world state `w` just in case `w` includes a verifier for that sentence as a part and _false at_ `w` just in case `w` includes a falsifier for that sentence as a part.
|
|
150
|
+
In order to ensure that sentence letters have at most one truth-value at each world state, a fusion `a.b` is required to be impossible whenever `a` is verifier for a sentence letter `A` and `b` is a falsifier for `A`.
|
|
151
|
+
Additionally, sentence letters are guaranteed to have at least one truth-value at each world state by requiring every possible state to be compatible with either a verifier or falsifier for any sentence letter.
|
|
152
|
+
|
|
153
|
+
A _negated sentence_ is verified by the falsifiers for the sentence negated and falsified by the verifiers for the sentence negated.
|
|
154
|
+
A _conjunctive sentence_ is verified by the pairwise fusions of verifiers for the conjuncts and falsified by falsifiers for either of the conjuncts or fusions thereof.
|
|
155
|
+
A _disjunctive sentence_ is verified by the verifiers for either disjunct or fusions thereof and falsified by pairwise fusions of falsifiers for the disjuncts.
|
|
156
|
+
Conjunction and disjunction are dual operators obeying the standard idempotence and De Morgan laws.
|
|
157
|
+
The absorption laws do not hold, nor does conjunction distribute over disjunction, nor _vice versa_.
|
|
158
|
+
For a defense of the background theory of hyperintensional propositions, see this [paper](https://link.springer.com/article/10.1007/s10992-021-09612-w).
|
|
159
|
+
|
|
160
|
+
<!-- By contrast with the _bilateral_ extensional operators which treat both verifiers and falsifiers, the semantics for `not` is _unilateral_. -->
|
|
161
|
+
<!-- In particular `not A` is verified by a state `s` just in case every non-null part of `s` is incompatible with a verifier for `A` and every verifier for `A` is incompatible with some non-null part of `s`. -->
|
|
162
|
+
<!-- This semantics is further motivated and elaborated in [Bernard and Champollion](https://ling.auf.net/lingbuzz/007730/current.html) and included here for comparison. -->
|
|
163
|
+
|
|
164
|
+
A _necessity sentence_ `Box A` is true at a world just in case every world state includes a part that verifies `A` and a _possibility sentence_ `Diamond A` is true at a world just in case some world state includes a part that verifies `A`.
|
|
165
|
+
Given a world state `w` and state `s`, an `s`_-alternative_ to `w` is any world state to include as parts both `s` and a maximal part of `w` that is compatible with `s`.
|
|
166
|
+
A _must counterfactual conditional sentences_ `A boxright B` is true at a world state `w` just in case its consequent is true at any `s`-alternative to `w` for any verifier `s` for the antecedent of the counterfactual.
|
|
167
|
+
A _might counterfactual conditional sentences_ `A boxright B` is true at a world state `w` just in case its consequent is true at some `s`-alternative to `w` for some verifier `s` for the antecedent of the counterfactual.
|
|
168
|
+
The semantic theory for counterfactual conditionals is motivated and further elaborated in this accompanying [paper](https://github.com/benbrastmckie/ModelChecker/blob/master/Counterfactuals.pdf).
|
|
169
|
+
This account builds on [Fine 2012](https://www.pdcnet.org/jphil/content/jphil_2012_0109_0003_0221_0246) and [Fine2012a](https://link.springer.com/article/10.1007/s11229-012-0094-y?error=cookies_not_supported&code=5166a4da-1834-438c-9f93-75b61f58b6db).
|
|
170
|
+
|
|
171
|
+
A _grounding sentence_ `A leq B` may be read '`A` is _sufficient for_ `B`' and an _essence sentence_ `A sqsubseteq B` may be read '`A` is _necessary for_ `B`'.
|
|
172
|
+
A _propositional identity sentence_ `A equiv B` may be read '`A` _just is for_ `B`'.
|
|
173
|
+
A _relevance sentence_ `A preceq B` may be read '`A` _is wholly relevant to_ `B`'.
|
|
174
|
+
The semantics for ground requires every verifier for the antecedent to be a verifier for the consequent, any fusion of a falsifier for the antecedent and consequent to be a falsifier for the consequent, and any falsifier for the consequent to have a part that falsifies the antecedent.
|
|
175
|
+
The semantics for essence requires every fusion of a verifier for the antecedent and consequent to be a verifier for the consequent, any verifier for the consequent must have a part that verifies the antecedent, and every falsifier for the antecedent to be a falsifier for the consequent.
|
|
176
|
+
The semantics for propositional identity requires the two arguments to have the same verifiers and falsifiers.
|
|
177
|
+
The semantics for relevance requires any fusion of verifiers for the antecedent and consequent to be a verifier for the consequent and, similarly, any fusion of falsifiers for the antecedent and consequent to be a falsifier for the consequent.
|
|
178
|
+
Whereas the first three constitutive operators are interdefinable, relevance is definable in terms of the other constitutive operators but not _vice versa_:
|
|
179
|
+
|
|
180
|
+
- `A leq B := neg A sqsubseteq neg B := (A vee B) equiv B`.
|
|
181
|
+
- `A sqsubseteq B := neg A leq neg B := (A wedge B) equiv B`.
|
|
182
|
+
- `A equiv B := (A leq B) wedge (B leq A) := (A sqsubseteq B) wedge (B sqsubseteq A)`.
|
|
183
|
+
- `A preceq B := (A wedge B) leq B := (A vee B) sqsubseteq B`.
|
|
184
|
+
|
|
185
|
+
Instead of a Boolean lattice as in extensional and intensional semantics theories, the space of hyperintensional propositions forms a non-interlaced bilattice as described in this [paper](https://link.springer.com/article/10.1007/s10992-021-09612-w), building on [Fine 2017](https://link.springer.com/article/10.1007/s10992-016-9413-y).
|
|
186
|
+
|
|
187
|
+
More information can be found in the GitHub [repository](https://github.com/benbrastmckie/ModelChecker) as well as in this recent [manuscript](https://github.com/benbrastmckie/ModelChecker/blob/master/Counterfactuals.pdf).
|
|
188
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "model-checker"
|
|
7
|
+
version = "0.7.2"
|
|
8
|
+
description = "A hyperintensional theorem prover for modal, counterfactual conditional, constitutive explanatory, and extensional operators."
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Benjamin Brast-McKie", email = "benbrastmckie@gmail.com" },
|
|
11
|
+
{ name = "Miguel Buitrago", email = "mbuit82@gmail.com" },
|
|
12
|
+
]
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3.8",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
]
|
|
20
|
+
keywords = ["semantics", "Z3", "logic", "counterfactuals", "modality", "model checker", "theorem prover", "hyperintensionality"]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"z3-solver",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/benbrastmckie/ModelChecker"
|
|
27
|
+
Issues = "https://github.com/benbrastmckie/ModelChecker/issues"
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
model-checker = "model_checker.__main__:main"
|
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# __init__.py
|
|
2
|
+
from importlib.metadata import version
|
|
3
|
+
try:
|
|
4
|
+
__version__ = version("model-checker")
|
|
5
|
+
except ImportError:
|
|
6
|
+
__version__ = "unknown"
|
|
7
|
+
|
|
8
|
+
# Import specific items from utils
|
|
9
|
+
from .utils import (
|
|
10
|
+
ForAll,
|
|
11
|
+
Exists,
|
|
12
|
+
bitvec_to_substates,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Import model as a whole
|
|
16
|
+
from . import model
|
|
17
|
+
|
|
18
|
+
# Import syntactic as a whole
|
|
19
|
+
from . import syntactic
|
|
20
|
+
|
|
21
|
+
# Import specific items from utils
|
|
22
|
+
from .builder import (
|
|
23
|
+
make_model_for,
|
|
24
|
+
find_max_N,
|
|
25
|
+
translate,
|
|
26
|
+
# run_comparison, # update
|
|
27
|
+
# save_comparisons, # update
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Import specific items from semantic
|
|
31
|
+
from .semantic import (
|
|
32
|
+
Semantics,
|
|
33
|
+
ImpositionSemantics,
|
|
34
|
+
Proposition,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Import specific items from primitive
|
|
38
|
+
from .primitive import (
|
|
39
|
+
AndOperator, NegationOperator, OrOperator, # extensional
|
|
40
|
+
TopOperator, BotOperator, # top and bottom
|
|
41
|
+
IdentityOperator, GroundOperator, EssenceOperator, # constitutive
|
|
42
|
+
RelevanceOperator, # relevance
|
|
43
|
+
NecessityOperator, PossibilityOperator, # modal
|
|
44
|
+
CounterfactualOperator, ImpositionOperator, # counterfactual
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
from .defined import (
|
|
48
|
+
ConditionalOperator, BiconditionalOperator, # extensional
|
|
49
|
+
DefEssenceOperator, DefGroundOperator, # constitutive
|
|
50
|
+
MightCounterfactualOperator, MightImpositionOperator, # counterfactual
|
|
51
|
+
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# Import specific items from __main__
|
|
56
|
+
from .__main__ import (
|
|
57
|
+
BuildModule,
|
|
58
|
+
BuildExample,
|
|
59
|
+
main,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Define the public API of the package
|
|
63
|
+
__all__ = [
|
|
64
|
+
"model", "syntactic",
|
|
65
|
+
"ForAll", "Exists", "bitvec_to_substates",
|
|
66
|
+
"make_model_for", "find_max_N", "translate", #"run_comparison", "save_comparisons",
|
|
67
|
+
"Semantics", "ImpositionSemantics", "Proposition",
|
|
68
|
+
"ConditionalOperator", "BiconditionalOperator",
|
|
69
|
+
"DefEssenceOperator", "DefGroundOperator",
|
|
70
|
+
"MightCounterfactualOperator", "MightImpositionOperator",
|
|
71
|
+
"AndOperator", "NegationOperator", "OrOperator",
|
|
72
|
+
"TopOperator", "BotOperator",
|
|
73
|
+
"IdentityOperator", "GroundOperator", "EssenceOperator",
|
|
74
|
+
"RelevanceOperator",
|
|
75
|
+
"NecessityOperator", "PossibilityOperator",
|
|
76
|
+
"CounterfactualOperator", "ImpositionOperator",
|
|
77
|
+
"BuildModule", "BuildExample", "main",
|
|
78
|
+
]
|