-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Siddhartha Prasad
authored and
Siddhartha Prasad
committed
Feb 21, 2024
1 parent
b202cb0
commit b840df1
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#lang forge | ||
|
||
option run_sterling off | ||
option verbose 0 | ||
|
||
|
||
sig Node {edges: set Node} | ||
|
||
pred isDirectedTree { | ||
edges.~edges in iden -- Injective, each child has at most one parent | ||
lone edges.Node - Node.edges -- At most one element that does not have a parent | ||
no (^edges & iden) -- No loops | ||
lone Node or Node in edges.Node + Node.edges -- Either one node or every node has either a child or a parent. | ||
} | ||
|
||
pred isRoot[r : Node] { | ||
isDirectedTree | ||
one r | ||
(some edges) => (r in edges.Node - Node.edges) | ||
} | ||
|
||
pred isNotRoot[n : Node] { | ||
isDirectedTree | ||
some edges.n | ||
} | ||
|
||
|
||
assert all r1, r2 : Node | isRoot[r1] is necessary for isNotRoot[r2] | ||
|
||
example thisIsNotATree is {isDirectedTree} for { | ||
Node = `Node1 | ||
edges = `Node1->`Node1 | ||
} | ||
|
||
test expect { | ||
t1 : {some r1 : Node | isRoot[r1]} is theorem | ||
} |