Comments (2)
This is the code that's making it hang, by the way.
(include-book "data-structures/structures" :dir :system)
(defstructure bst left key right)
(defun key< (x y)
(< x y))
(in-theory (disable key<))
(defun key? (x)
(natp x))
(in-theory (disable key?))
(defthm key-<-or->
(implies (and (key? x)
(key? y)
(not (equal x y))
(not (key< x y)))
(key< y x))
:hints (("Goal" :in-theory (enable key? key<))))
(defun bst-keys-below (x tr)
(if (bst-p tr)
(and (key< (bst-key tr) x)
(bst-keys-below x (bst-left tr))
(bst-keys-below x (bst-right tr)))
t))
(defun bst-keys-above (x tr)
(if (bst-p tr)
(and (key< x (bst-key tr))
(bst-keys-above x (bst-left tr))
(bst-keys-above x (bst-right tr)))
t))
(defun bst? (tr)
(or (null tr)
(and (bst-p tr)
(key? (bst-key tr))
(bst-keys-below (bst-key tr) (bst-left tr))
(bst-keys-above (bst-key tr) (bst-right tr))
(bst? (bst-left tr))
(bst? (bst-right tr)))))
(defun bst-empty? (x)
(null x))
(defun empty-bst ()
nil)
(defthm left-<
(implies (bst-p tr)
(< (acl2-count (bst-left tr))
(acl2-count tr)))
:hints (("Goal" :in-theory (enable bst-left bst-p weak-bst-p))))
(defthm right-<
(implies (bst-p tr)
(< (acl2-count (bst-right tr))
(acl2-count tr)))
:hints (("Goal" :in-theory (enable bst-right bst-p weak-bst-p))))
(defun bst-insert (x tr)
(if (bst-p tr)
(cond ((key< x (bst-key tr))
(bst (bst-insert x (bst-left tr))
(bst-key tr)
(bst-right tr)))
((key< (bst-key tr) x)
(bst (bst-left tr)
(bst-key tr)
(bst-insert x (bst-right tr))))
(t tr))
(bst (empty-bst) x (empty-bst))))
(defthm left-<-root
(implies (bst-left tr)
(< (acl2-count (bst-left tr))
(acl2-count tr)))
:hints (("Goal"
:in-theory (enable bst-left))))
(defthm right-<-root
(implies (bst-right tr)
(< (acl2-count (bst-right tr))
(acl2-count tr)))
:hints (("Goal"
:in-theory (enable bst-right))))
(defun bst-first (tr)
(if (bst-empty? (bst-left tr))
(bst-key tr)
(bst-first (bst-left tr))))
(defun bst-remove-first (tr)
(if (bst-empty? (bst-left tr))
(bst-right tr)
(bst (bst-remove-first (bst-left tr))
(bst-key tr)
(bst-right tr))))
(defun bst-delete (x tr)
(if (bst-p tr)
(cond ((key< x (bst-key tr))
(bst (bst-delete x (bst-left tr))
(bst-key tr)
(bst-right tr)))
((key< (bst-key tr) x)
(bst (bst-left tr)
(bst-key tr)
(bst-delete x (bst-right tr))))
((equal (bst-key tr) x)
(if (bst-empty? (bst-right tr))
(bst-left tr)
(bst (bst-left tr)
(bst-first (bst-right tr))
(bst-remove-first (bst-right tr))))
))
(empty-bst)))
(defun bst-contains (x tr)
(and (bst-p tr)
(cond ((key< x (bst-key tr))
(bst-contains x (bst-left tr)))
((key< (bst-key tr) x)
(bst-contains x (bst-right tr)))
(t
(equal (bst-key tr) x)))))
(defthm not-x-key<-x
(implies (key? x)
(not (key< x x)))
:hints (("Goal" :in-theory (enable key? key<))))
(defthm contains-after-insert
(implies (and (bst? tr)
(key? x))
(bst-contains x (bst-insert x tr)))
:hints (("Goal"
:use (:instance key-<-or-> (x x) (y (bst-key tr))))))
(defthm bst-keys-below-after-insert
(implies (and (bst? tr)
(key? x)
(key? top)
(bst-keys-below top tr)
(key< x top))
(bst-keys-below top (bst-insert x tr))))
(defthm bst-keys-above-after-insert
(implies (and (bst? tr)
(key? x)
(key? bottom)
(bst-keys-above bottom tr)
(key< bottom x))
(bst-keys-above bottom (bst-insert x tr))))
(defthm bst-after-insert
(implies (and (bst? tr)
(key? x))
(bst? (bst-insert x tr))))
(defthm still-contains-after-insert
(implies (and (bst? tr)
(key? x)
(key? y)
(bst-contains y tr))
(bst-contains y (bst-insert x tr))))
(defthm not-contains-if-keys-above
(implies (and (bst? tr)
(key? x)
(bst-keys-below x tr))
(not (bst-contains x tr))))
(defthm not-contains-if-keys-below
(implies (and (bst? tr)
(key? x)
(bst-keys-above x tr))
(not (bst-contains x tr))))
(defthm not-<-and->
(implies (and (key? x)
(key? y)
(key< x y))
(not (key< y x)))
:hints (("Goal" :in-theory (enable key? key<))))
;(defthm bst-p-if-exists
; (implies (and (bst? tr)
; (bst-left (bst-left tr)))
; (bst-p (bst-left (bst-left tr)))))
(defthm key-<-transitive
(implies (and (key? x) (key? y) (key? z)
(key< x y) (key< y z))
(key< x z))
:hints (("Goal" :in-theory (enable key< key?))))
(defthm bst-first-is-key
(implies (and (bst? tr)
(bst-p tr))
(key? (bst-first tr))))
(defthm bst-first-<-root
(implies (and (bst? tr)
(bst-p (bst-left tr)))
(key< (bst-first tr)
(bst-key tr)))
:hints (("Subgoal *1/2"
:use (:instance key-<-transitive
(x (bst-first (bst-left tr)))
(y (bst-key (bst-left tr)))
(z (bst-key tr))))))
#|(defthm bst-root-not-<-bst-first
(implies (and (bst? tr)
(bst-p tr))
(not (key< (bst-key tr)
(bst-first tr))))
:hints (("Goal"
:in-theory (disable key-<-transitive)
:use (:instance key-<-transitive
(x (bst-first (bst-left tr)))
(y (bst-key (bst-left tr)))
(z (bst-key tr))))))
(defthm contains-first
(implies (and (bst-p tr)
(bst? tr))
(bst-contains (bst-first tr) tr))
:hints (("Subgoal *1/4"
:use ((:instance key-<-transitive
(x (bst-first (bst-left tr)))
(y (bst-key (bst-left tr)))
(z (bst-key tr)))
(:instance bst-first-is-key
(tr (bst-left tr))
)
(:instance bst-first-<-root
(tr (bst-left tr)))))
("Subgoal *1/6"
:use ((:instance key-<-transitive
(x (bst-first (bst-left tr)))
(y (bst-key (bst-left tr)))
(z (bst-key tr)))))))
|#
(defaxiom contains-first
(implies (and (bst-p tr)
(bst? tr))
(bst-contains (bst-first tr) tr)))#|ACL2s-ToDo-Line|#
(defthm still-not-contains-after-remove-first
(implies (and (bst? tr)
(key? x)
)
(equal (bst-contains x (bst-remove-first tr))
(and (not (equal x (bst-first tr)))
(bst-contains x tr)))))
(defthm gone-after-delete
(implies (and (bst? tr)
(key? x))
(not (bst-contains x (bst-delete x tr)))))
from proof-pad-classic.
I think this is fixed. flush()
is on a different thread, at any rate, so if that was indeed the problem then it's fixed.
from proof-pad-classic.
Related Issues (20)
- Special case error summaries for common functions?
- (if (cons ...) ...) warning
- Clean up error message for stack overflow
- Make error highlight more visible?
- Error doesn't show up when hovering below
- Back-references in the REPL
- Error-underline for theorem with same name as fn
- indentation anomaly HOT 1
- request: column number option and window size option
- odd behavior with multiline comment at beginning of file
- include-book, not compiled bug
- save-as infelicity: goes to My Documents
- Redundant "Replace existing file" dialogs HOT 3
- Website DNS lookup failure HOT 1
- No downloads HOT 1
- proof pad is damaged and cant be opened on my mac
- ProofPad is damaged for OSX? HOT 1
- Zoom out bug
- installation glitch (wx86cI64.exe open for write)
- Problem upon extraction of compressed file HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proof-pad-classic.