-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new LTL representation is capable of representing Quantified LTL formulas, such as HyperLTL.
- Loading branch information
Showing
13 changed files
with
671 additions
and
414 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 was deleted.
Oops, something went wrong.
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,43 @@ | ||
|
||
extension LTL: CustomStringConvertible { | ||
|
||
public var description: String { | ||
switch self { | ||
case .atomicProposition(let ap): | ||
return ap.description | ||
case .pathProposition(let ap, let path): | ||
return "\(ap)[\(path)]" | ||
case .application(let function, parameters: let parameters): | ||
switch function.arity { | ||
case 0: | ||
return "\(function)" | ||
case 1: | ||
return "\(function) \(parameters[0])" | ||
case 2: | ||
return "\(parameters[0]) \(function) \(parameters[1])" | ||
default: | ||
fatalError() | ||
} | ||
case .pathQuantifier(let quant, parameters: let parameters, body: let body): | ||
return "\(quant) \(parameters.map(String.init(describing:)).joined(separator: " ")). \(body)" | ||
} | ||
} | ||
} | ||
|
||
extension LTLPathVariable: CustomStringConvertible { | ||
public var description: String { | ||
return name | ||
} | ||
} | ||
|
||
extension LTLAtomicProposition: CustomStringConvertible { | ||
public var description: String { | ||
return name | ||
} | ||
} | ||
|
||
extension LTLFunction: CustomStringConvertible { | ||
public var description: String { | ||
return symbol | ||
} | ||
} |
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,40 @@ | ||
|
||
extension LTLFunction: Hashable { | ||
public var hashValue: Int { | ||
return symbol.hashValue ^ arity.hashValue | ||
} | ||
|
||
public static func ==(lhs: LTLFunction, rhs: LTLFunction) -> Bool { | ||
return lhs.symbol == rhs.symbol && lhs.arity == rhs.arity | ||
} | ||
} | ||
|
||
extension LTLAtomicProposition: Equatable { | ||
public static func ==(lhs: LTLAtomicProposition, rhs: LTLAtomicProposition) -> Bool { | ||
return lhs.name == rhs.name | ||
} | ||
} | ||
|
||
extension LTLPathVariable: Equatable { | ||
public static func ==(lhs: LTLPathVariable, rhs: LTLPathVariable) -> Bool { | ||
return lhs.name == rhs.name | ||
} | ||
} | ||
|
||
extension LTL: Equatable { | ||
public static func == (lhs: LTL, rhs: LTL) -> Bool { | ||
switch (lhs, rhs) { | ||
case (.atomicProposition(let lhs), .atomicProposition(let rhs)): | ||
return lhs == rhs | ||
case (.pathProposition(let lhs, let lhsPath), .pathProposition(let rhs, let rhsPath)): | ||
return lhs == rhs && lhsPath == rhsPath | ||
case (.application(let lhsFun, let lhsParameters), .application(let rhsFun, parameters: let rhsParameters)): | ||
return lhsFun == rhsFun && lhsParameters == rhsParameters | ||
case (.pathQuantifier(let lhsQuant, let lhsParamaters, let lhsBody), .pathQuantifier(let rhsQuant, parameters: let rhsParameters, body: let rhsBody)): | ||
return lhsQuant == rhsQuant && lhsParamaters == rhsParameters && lhsBody == rhsBody | ||
default: | ||
return false | ||
} | ||
} | ||
} | ||
|
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,29 @@ | ||
|
||
// We define operators to make working with LTL easier | ||
|
||
// FIXME: check which precedence is correct | ||
infix operator => | ||
|
||
extension LTL { | ||
|
||
public static func && (lhs: LTL, rhs: LTL) -> LTL { | ||
return .application(.and, parameters: [lhs, rhs]) | ||
} | ||
|
||
public static func || (lhs: LTL, rhs: LTL) -> LTL { | ||
return .application(.or, parameters: [lhs, rhs]) | ||
} | ||
|
||
public static prefix func ! (ltl: LTL) -> LTL { | ||
return .application(.negation, parameters: [ltl]) | ||
} | ||
|
||
public static func => (lhs: LTL, rhs: LTL) -> LTL { | ||
return .application(.implies, parameters: [lhs, rhs]) | ||
} | ||
|
||
public static func until(_ lhs: LTL, _ rhs: LTL) -> LTL { | ||
return .application(.until, parameters: [lhs, rhs]) | ||
} | ||
|
||
} |
Oops, something went wrong.