Skip to content

Commit 125b952

Browse files
authored
Merge pull request #58 from CICS-Oleg/main
Maker DAO examples stub added to deontic logic experiments
2 parents 0d687d1 + be0ca1f commit 125b952

31 files changed

+1255
-1
lines changed

deontic_logic/ct_dts.metta

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,24 @@
5757
(: and1 Eventuality)
5858
(: and2 Eventuality)
5959

60+
(= (NOT_EXIST_stb $x)
61+
(if (== $x (match &self $x $x)) True False)
62+
)
63+
64+
(= (FILTER_stb $p $set $x)
65+
(match &self
66+
(, ($p $set $x)
67+
($p aint-my-set $x))
68+
$x)
69+
)
70+
71+
(= (CONSTRUCT_stb $x $y)
72+
(add-atom &self (match &self $x $y))
73+
)
74+
75+
;Inference rules at the 1st level (the level of the eventualities)
76+
77+
;“not(en, e)” states that en and e are opposite eventualities; e.g., if e refers
78+
;to the fact that “John leaves”, en may refer to the fact that “John does not
79+
;leave”.
6080

61-
!(match )
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Overview
2+
3+
This folder contains some trivial examples on reasoning in deontic logic style with a simple functional implementation of inference.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
(:-- True True)
2+
3+
; a way to stop evaluation of what is wrapped in TV
4+
(: TV (-> Atom Atom))
5+
(= (infer-step (TV $x))
6+
(match &self (:-- $x $y) (TV $y)))
7+
; it could possibly be improved:
8+
; it's enough for one of operands to be False (while the second can be empty)
9+
(= (infer (AND $x $y))
10+
(and (infer $x)
11+
(infer $y))
12+
13+
(= (infer (OR $x $y))
14+
(or (infer $x)
15+
(infer $y))
16+
17+
)
18+
(= (infer (NOT-TRUE $x))
19+
; could it be done without case?
20+
(case (infer $x) ; a way to capture empty (unknown) results
21+
((True False)
22+
($_ True)))
23+
)
24+
25+
(= (infer $x)
26+
(case (infer-step (TV $x)) (
27+
((TV True) True)
28+
((TV False) False)
29+
((TV $y) (infer $y))
30+
)
31+
)
32+
)
33+
34+
(= (infer $x)
35+
(case (infer-step (TV $x)) (
36+
((TV True) True)
37+
((TV False) False)
38+
((TV $y) (infer $y))
39+
)
40+
)
41+
)
42+
43+
;a. PE(p)⊢ ¬OB(¬p), via Modus Ponens.
44+
;b. ¬OB(¬p)⊢ PE(p), via Modus Ponens.
45+
;c. OB(¬p)⊢ ¬PE(p), via Modus Tollens.
46+
;d. ¬PE(p)⊢ OB(¬p), via Modus Tollens.
47+
48+
(:-- (pe &p) (NOT-TRUE (ob (NOT-TRUE &p))))
49+
50+
;it is impermissible that (IM)
51+
52+
(:-- (im &p) (ob (NOT-TRUE &p)))
53+
54+
;it is omissible that (OM)
55+
56+
(:-- (om &p) (NOT-TRUE (ob &p)))
57+
58+
;it is optional that (OP)
59+
60+
:-- (op &p) (AND (om &p) (pe &p)))
61+
62+
;it is non-optional that (NO)
63+
64+
(:-- (no &p) (OR (ob &p) (im &p)))

deontic_logic/infer.metta

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
)
2727
)
2828

29+
;(Normally) there must be no fence
30+
;But if you do put a fence, it must be white
31+
;By the sea, you can put a fence
32+
;You decide to put a fence
33+
2934
(:-- (Fence fence-001) True)
3035
(:-- (Fence fence-002) True)
3136

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Overview
2+
3+
This folder contains attampts to map Maker Atlas regulatory documentation to a MeTTa atomspace knowledge base.
4+
5+
[not_exist.metta](not_exist.metta) is a stub script with direct mapping of [DeonticTraditionalScheme](https://github.com/liviorobaldo/conflict-tolerantDeonticTraditionalScheme)
6+
repo to the MeTTa language
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
;#------------------------------------------------------------------------------------------------------------------------------------------------
2+
;# Inference rules
3+
;#
4+
;# :InferenceRule is a special class that contains the SPARQL rules in the form CONSTRUCT-WHERE to execute. Each individual of this
5+
;# class is associated through the property has-sparql-code with a xsd:string that executes it. The automated reasoner first collects
6+
;# all individuals of the class :InferenceRule; then, it iteratively re-execute the SPARQL rules in the range of :has-sparql-code
7+
;# until no new individual is inferred.
8+
;#------------------------------------------------------------------------------------------------------------------------------------------------
9+
;
10+
;:InferenceRule rdf:type rdfs:Class.
11+
;:has-sparql-code rdf:type rdf:Property;
12+
; rdfs:domain :InferenceRule;
13+
; rdfs:range xsd:string.
14+
15+
;#------------------------------------------------------------------------------------------------------------------------------------------------
16+
;# 1st-level classes and properties (Hobbs's logic) - eventualities, modalities, and thematic roles
17+
18+
19+
;#Rexist modality:
20+
;:Rexist rdf:type rdfs:Class,:Modality.
21+
22+
(= (not_exist pattern)
23+
!(unify &self (pattern) T F))
24+
25+
(rexist class modality)
26+
27+
;#Top classes:
28+
;:Eventuality rdf:type rdfs:Class.
29+
;:Modality rdf:type rdfs:Class.
30+
;:ThematicRole rdf:type rdfs:Class.
31+
32+
(eventuality class type)
33+
(modality class type)
34+
(thematic_role class type)
35+
36+
;#negation, conjunction, and disjunction of eventualities:
37+
;:not rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality.
38+
;:and1 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality.
39+
;:and2 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality.
40+
;:or1 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality.
41+
;:or2 rdf:type rdf:Property; rdfs:domain :Eventuality; rdfs:range :Eventuality.
42+
43+
44+
(NOT property eventuality)
45+
(AND1 property eventuality)
46+
(AND2 property eventuality)
47+
(OR1 property eventuality)
48+
(OR2 property eventuality)
49+
50+
;#Deontic modalities:
51+
;:DeonticModality rdf:type rdfs:Class; rdfs:subClassOf :Modality.
52+
;:Obligatory rdf:type rdfs:Class,:DeonticModality.
53+
;:Permitted rdf:type rdfs:Class,:DeonticModality.
54+
;:Optional rdf:type rdfs:Class,:DeonticModality.
55+
56+
(deontic_modality class modality)
57+
(oligatory class deontic_modality)
58+
(permitted class deontic_modality)
59+
(optional class deontic_modality)
60+
61+
;#------------------------------------------------------------------------------------------------------------------------------------------------
62+
63+
;# 2nd-level classes and properties - classical logic operators applied to rdf:Statement(s), i.e., reifications of 1st-level assertions.
64+
;# These are needed because RDF vocabulary does not implement several operators from classical logic (negation, disjunction, etc.), nor
65+
;# the alethic modal logic operators of necessity (□) and possibility (◊)
66+
67+
68+
;:statement rdf:type rdfs:Class; rdfs:subClassOf rdf:Statement.
69+
;:true rdf:type rdfs:Class; rdfs:subClassOf :statement.
70+
;:false rdf:type rdfs:Class; rdfs:subClassOf :statement.
71+
;:hold rdf:type rdfs:Class; rdfs:subClassOf :statement.
72+
;:necessary a rdfs:Class; rdfs:subClassOf :statement.
73+
;:possible a rdfs:Class; rdfs:subClassOf :statement.
74+
;
75+
;:disjunction rdf:type rdf:Property;
76+
; rdfs:domain :statement;
77+
; rdfs:range :statement.
78+
79+
(true class statement)
80+
(false class statement)
81+
(hold class statement)
82+
(necessary class statement)
83+
(possible class statement)
84+
85+
(disjunction property (statement statement)) ;!!!!!!
86+
87+
;#------------------------------------------------------------------------------------------------------------------------------------------------
88+
89+
;3rd-level - explicit representation of contradictions, conflicts, violations, and other undesirable consequences (fallacies, mistakes, etc.)
90+
91+
;:is-in-contradiction-with rdf:type rdf:Property;
92+
; rdfs:domain :statement;
93+
; rdfs:range :statement.
94+
;:is-in-conflict-with rdf:type rdf:Property;
95+
; rdfs:domain :statement;
96+
; rdfs:range :statement.
97+
;:is-complied-with-by rdf:type rdf:Property;
98+
; rdfs:domain :statement;
99+
; rdfs:range :statement.
100+
;:is-violated-by rdf:type rdf:Property;
101+
; rdfs:domain :statement;
102+
; rdfs:range :statement.
103+
;:is-necessary-violated-by rdf:type rdf:Property;
104+
; rdfs:domain :statement;
105+
; rdfs:range :statement.
106+
107+
(is_in_contradiction_with property (statement statement))
108+
(is_in_conflict_with property (statement statement))
109+
(is_complied_with_by property (statement statement))
110+
(is_violated_by property (statement statement))
111+
(is_necessary_violated_by property (statement statement))
112+
113+
;#------------------------------------------------------------------------------------------------------------------------------------------------
114+
;# Inference rules at the 1st level (the level of the eventualities)
115+
116+
;#The following rule infers that if two eventualities are direct instantiations of the same abstract eventuality (i.e., they both describe the
117+
;#same action/state with the same thematic roles) but for at least one thematic role, for which it is asserted that one of the two eventualities
118+
;#has a certain value on that thematic role while the other one does not, then the two eventualities are connected by the ":not" property.
119+
120+
;[rdf:type :InferenceRule;
121+
; :has-sparql-code """CONSTRUCT{?e1 :not ?e2}
122+
; WHERE{?e1 rdf:type ?c. ?e2 rdf:type ?c. ?c rdf:type :Eventuality. FILTER(?e1!=?e2)
123+
; ?trn rdf:type :ThematicRole. ?e1 ?trn ?vn. ?r rdf:type :false,:hold; rdf:subject ?e2; rdf:predicate ?trn; rdf:object ?vn.
124+
; NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e1 ?tr ?tv1. NOT EXISTS{?e2 ?tr ?tv2}}
125+
; NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e2 ?tr ?tv2. NOT EXISTS{?e1 ?tr ?tv1}}
126+
; NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e1 ?tr ?tv1. ?e2 ?tr ?tv2. FILTER(?tv1!=?tv2)}}"""^^xsd:string].
127+
128+
!(match &self (, ($e1 rdf:type $c) ($e2 rdf:type $c) ($c property eventuality))
129+
(if (not (== $e1 $e2))
130+
131+
(match &self (, ($trn rdf:type :ThematicRole) ($e1 $trn $vn) (hold ($r rdf:type :false)) )
132+
(if (and (not_exist (, ($tr rdf:type :ThematicRole) ($e1 $tr $tv1) (not_exist ($e2 $tr $tv2))))
133+
(not_exist (, ($tr rdf:type :ThematicRole) ($e2 $tr $tv2) (not_exist ($e1 $tr $tv1))))
134+
(not_exist (, ($tr rdf:type :ThematicRole) ($e1 $tr $tv1) (($e2 $tr $tv2)))))
135+
136+
(add-atom &self (NOT $e1 $e2))))))
137+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
;https://mips.makerdao.com/mips/details/MIP102#MIP102c1
2+
;MIP102c1: Purpose Description
3+
;Amendments
4+
;MIP Amendments that preserve the MIP number can be performed
5+
;to modify any aspect of an existing MIP, including MIP0.
6+
;There are no restrictions on how an existing MIP can be amended.
7+
;
8+
;Multiple amendments to multiple MIPs are allowed to be submitted
9+
;as a single subproposal.
10+
;
11+
;Removals
12+
;MIP102 also enables the removal of one or multiple MIPs
13+
;that are inactive as a part of the Endgame transition.
14+
;
15+
;Multiple MIPs may be removed in a single MIP Removal subproposal.
16+
17+
(= (exist mip1) True)
18+
19+
(= (inactive mip1) True)
20+
21+
(= (preserve_mip_number amendment1 mip1) True)
22+
(= (preserve_mip_number amendment2 mip1) False)
23+
24+
(= (preserve_mip_number amendment3 mip2) True)
25+
(= (preserve_mip_number amendment4 mip2) False)
26+
27+
(= (permissible (modify $amendment $mip))
28+
(and (== (preserve_mip_number $amendment $mip) True) (== (exist $mip) True)))
29+
30+
(= (permissible (remove $mip))
31+
(== (inactive $mip) True))
32+
33+
!(permissible (modify amendment2 mip1))
34+
!(permissible (remove mip2))
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
;https://mips.makerdao.com/mips/details/MIP101#2-the-governance-scope-gov
2+
3+
;2.6.5.1.2
4+
;If FacilitatorDAOs fail to take action against misaligned AD,
5+
;they must be severely penalized.
6+
7+
;Aligned Delegate (AD)
8+
;Aligned Delegates are Anonymous Alignment Conservers that
9+
;use the Protocol Delegation System
10+
;to enable regular MKR holders to easily
11+
;and safely delegate their MKR voting power
12+
;towards implementing the Aligned Governance Strategy of an AVC,
13+
;while earning Governance Participation Rewards in the process.
14+
15+
;2.6.5.1
16+
;If a FacilitatorDAO finds that an AD has performed a misaligned act
17+
;or breached their requirements, they can derecognize the AD
18+
;and confiscate their AD Buffer.
19+
;The AD Buffer can be used as a whistleblower bounty in case
20+
;an ecosystem actor provided useful data, information or evidence
21+
;that led to the derecognition of the AD.
22+
;GOV6 must specify sufficient safety mechanisms around the payment of
23+
;the whistleblower bounty.
24+
25+
(= (Facilitator DAO) True)
26+
(= (misaligned AD1) False)
27+
(= (misaligned AD2) True)
28+
29+
(take-action DAO AD1)
30+
31+
(= (obliged (take-action $dao $ad))
32+
(and (== (Facilitator $dao) True) (== (misaligned $ad) True)))
33+
34+
(= (obliged (be-penalized $dao $ad))
35+
(and (and (== (Facilitator $dao) True) (== (misaligned $ad) True))
36+
(not (== (match &self (take-action $dao $ad) $ad) $ad))))
37+
38+
!(obliged (take-action DAO AD1))
39+
!(obliged (be-penalized DAO AD1))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
;https://mips.makerdao.com/mips/details/MIP101#2-3-scope-bounded-mutable-alignment-artifacts-gov3
2+
3+
4+
;Scope Artifacts are continuously updated.
5+
;Their updates must always be aligned with the specifications of the Atlas.
6+
7+
(= (update scope_artifacts) True)
8+
9+
(= (obliged (align_with_specs $artifacts))
10+
((== (update $artifacts) True) ))

0 commit comments

Comments
 (0)