-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: decidable quantifiers for
Vector
(#953)
- Loading branch information
Showing
3 changed files
with
84 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
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,25 @@ | ||
import Batteries.Data.Vector | ||
|
||
/-! ### Testing decidable quantifiers for `Vector`. -/ | ||
|
||
open Batteries | ||
|
||
example : ∃ v : Vector Bool 6, v.toList.count true = 3 := by decide | ||
|
||
inductive Gate : Nat → Type | ||
| const : Bool → Gate 0 | ||
| if : ∀ {n}, Gate n → Gate n → Gate (n + 1) | ||
|
||
namespace Gate | ||
|
||
def and : Gate 2 := .if (.if (.const true) (.const false)) (.if (.const false) (.const false)) | ||
|
||
def eval (g : Gate n) (v : Vector Bool n) : Bool := | ||
match g, v with | ||
| .const b, _ => b | ||
| .if g₁ g₂, v => if v.1.back then eval g₁ v.pop else eval g₂ v.pop | ||
|
||
example : ∀ v, and.eval v = (v[0] && v[1]) := by decide | ||
example : ∃ v, and.eval v = false := by decide | ||
|
||
end Gate |