Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tactics #19

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
bbf6abe
First tactics commit
konstantine4096 Sep 2, 2024
ee8261a
Progress on process
konstantine4096 Sep 3, 2024
ae2c75c
Subproof extraction working
konstantine4096 Sep 4, 2024
9f58d3a
Fid dictionaries instead of lists
konstantine4096 Sep 4, 2024
2b5f515
WIP
konstantine4096 Sep 4, 2024
faea1fc
WIP
konstantine4096 Sep 6, 2024
0f5e230
Merge branch 'master' of https://github.com/AthenaFoundation/athena i…
konstantine4096 Oct 13, 2024
a10130a
Refactoring tactics
konstantine4096 Oct 14, 2024
a97c699
Almost done with extraction tactics
konstantine4096 Oct 14, 2024
1c23f21
WIP
konstantine4096 Oct 14, 2024
8ce82cf
Tree-based representations of the search
konstantine4096 Oct 15, 2024
0ddd5a8
Marking leaves
konstantine4096 Oct 15, 2024
4aa4497
Implemented infer, contradiction, and from-complements tactics
konstantine4096 Oct 17, 2024
463cae6
WIP
konstantine4096 Oct 17, 2024
c7a7e1d
First draft of final proofs
konstantine4096 Oct 18, 2024
646fe06
Proofs produced for all tactics currently
konstantine4096 Oct 18, 2024
fb78a0e
Go-back tactic working
konstantine4096 Oct 20, 2024
1f59176
Adding polarities.ath
konstantine4096 Oct 20, 2024
7eb12da
WIP
konstantine4096 Oct 21, 2024
73e0b04
Extraction tactics working for quantified logic, also added ugen3
konstantine4096 Oct 21, 2024
253ab60
WIP
konstantine4096 Oct 21, 2024
9f17b89
Fix minor proof printing bug
konstantine4096 Oct 21, 2024
48395c6
Forward and-> and or-> now working with arbitrarily complicated conju…
konstantine4096 Oct 21, 2024
dc38ea3
Tightened backward tactics
konstantine4096 Oct 22, 2024
140b55d
Better formatting
konstantine4096 Oct 22, 2024
27cba38
More flexible backward tactics for disjunctions
konstantine4096 Oct 22, 2024
01960eb
Fixed reverting bug
konstantine4096 Oct 22, 2024
18953a5
Richer markers
konstantine4096 Oct 23, 2024
239f97a
Implemented replace-strings in util.ath using naive split patterns
konstantine4096 Oct 23, 2024
1f85921
WIP
konstantine4096 Oct 23, 2024
0fbb3ed
Restricted overly persmissive (forall (some-list vars) body) pattern …
konstantine4096 Oct 23, 2024
1eaf983
Implemented exists<-
konstantine4096 Oct 23, 2024
ac698d0
Ensuring that a goal's tactic info is not set prematurely.
konstantine4096 Oct 24, 2024
06dde66
Search-based version of exists<- working
konstantine4096 Oct 24, 2024
a48616e
Implemented separated-markers
konstantine4096 Oct 24, 2024
236fd59
New generalized case analysis, and argument-less extractions
konstantine4096 Oct 24, 2024
8929c85
Implemented 'exists->, the pick-witness tactic.
konstantine4096 Oct 25, 2024
6423376
WIP
konstantine4096 Oct 25, 2024
bf4fed5
Implemented exists->
konstantine4096 Oct 26, 2024
10e1c90
Allowing for negative extractions, where the parent flips the goal's …
konstantine4096 Oct 27, 2024
27a2b19
Implemented forall2 ->
konstantine4096 Oct 28, 2024
a05d161
Implemented replace<
konstantine4096 Oct 28, 2024
2e8f75d
Reimplementing simplification so that it works directly on Athena pro…
konstantine4096 Nov 4, 2024
633ea25
WIP
konstantine4096 Nov 6, 2024
f3385a4
WIP
konstantine4096 Nov 8, 2024
cf00648
WIP
konstantine4096 Nov 8, 2024
3b3d16f
Excluding deductive arguments from method-call FAs
konstantine4096 Nov 8, 2024
0fd4cbc
Added server.ath, reimplemented evaluate
konstantine4096 Nov 9, 2024
3a425dc
Adding client.py
konstantine4096 Nov 9, 2024
3325d60
Minor cleanup
konstantine4096 Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ab.sig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ sig

val insert: Prop.prop * assum_base -> assum_base

val insertAlongWithConjuncts: Prop.prop * assum_base -> assum_base

val remove: assum_base * Prop.prop -> assum_base

val augment: assum_base * Prop.prop list -> assum_base
Expand Down Expand Up @@ -48,6 +50,7 @@ sig

val getAssertions: assum_base -> Prop.prop list
val addAssertion: Prop.prop * assum_base -> assum_base
val addAssertionAlongWithConjuncts: Prop.prop * assum_base -> assum_base
val addAssertions: Prop.prop list * assum_base -> assum_base
val isAssertion: Prop.prop * assum_base -> bool

Expand Down
10 changes: 8 additions & 2 deletions ab.sml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ fun addAssertion(p,abase({prop_table,tag,...}):assum_base) =
fun addAssertions(props,beta:assum_base) =
let fun loop([],res) = res
| loop(a::more,res) = loop(more,addAssertion(a,res))
in loop(props,beta) end
in
loop(props,beta)
end

fun addAssertionAlongWithConjuncts(p,ab) = addAssertions(p::(Prop.getConjunctsOnly p),ab)

fun isAssertion(p,abase({prop_table,...}):assum_base) =
(case IntBinaryMap.find(prop_table,getPropCode(p)) of
Expand Down Expand Up @@ -212,10 +216,12 @@ fun insertAux(P,ab as abase({prop_table,tag,...}): assum_base) =
abase({prop_table=IntBinaryMap.insert(prop_table,code,P),tag=inc(next_ab_tag)})
end

fun insert(P,ab) = insertAux(P,ab)
fun insert(P,ab) = insertAux(P,ab)

fun augment(ab,props) = List.foldl insert ab props

fun insertAlongWithConjuncts(P,ab) = augment(ab,P::(Prop.getConjunctsOnly P))

fun getAll(ab as abase({prop_table,...}):assum_base) = IntBinaryMap.listItems(prop_table)

fun occursFree(v,ab) = List.exists (fn (P) => Prop.occursFree(v,P)) (getAll ab)
Expand Down
35 changes: 33 additions & 2 deletions abstract_syntax.sml
Original file line number Diff line number Diff line change
Expand Up @@ -1004,9 +1004,40 @@ and unparseCheckClause({test=boolCond(phr),result,...}:check_clause) = lparen^(u
| unparseCheckClause({test=elseCond,result,...}:check_clause) = lparen^(Names.else_name)^space^(unparseExp(result))^rparen
and unparseCheckClauses(clauses) = Basic.printSExpListStr(clauses,unparseCheckClause)
and unparseBinding({bpat,def,...}) = lparen^(printPat bpat)^space^(unparsePhrase def)^rparen
and unparseBindingInfix({bpat,def,...}) = (printPat bpat)^ " := " ^(unparsePhrase def)
and unparseBindings(bindings) = Basic.printSExpListStr(bindings,unparseBinding)
and unparseDed(methodAppDed({method,args,pos})) = "(!"^(unparseExp method)^space^(Basic.printSExpListStr(args,unparsePhrase))^")"
| unparseDed(_) = "(Don't know how to unparse this deduction yet.)"
and unparseBindingsInfix(bindings) = Basic.printListStr(bindings,unparseBindingInfix,"; ")
and unparseDed(methodAppDed({method,args,pos})) =
let
in
"(!"^(unparseExp method)^space^(Basic.printSExpListStr(args,unparsePhrase))^")"
end
| unparseDed(UMethAppDed({method, arg, pos})) =
let
in
"(!"^(unparseExp method)^space^(Basic.printSExpListStr([arg],unparsePhrase))^")"
end
| unparseDed(BMethAppDed({method, arg1, arg2, pos})) = "(!"^(unparseExp method)^space^(Basic.printSExpListStr([arg1,arg2],unparsePhrase))^")"
| unparseDed(letDed({bindings,body,pos,...})) = "let {"^(unparseBindingsInfix bindings)^"}"^space^(unparseDed body)
| unparseDed(beginDed({members,pos,...})) = "{"^(Basic.printListStr(members, unparseDed, ";\n"))^"}"
| unparseDed(matchDed(_)) = "Match ded!"
| unparseDed(letRecDed(_)) = "Letrec ded!"
| unparseDed(checkDed(_)) = "Check ded!"
| unparseDed(assumeDed(_)) = "Assume ded!"
| unparseDed(infixAssumeDed(_)) = "Infix Assume ded!"
| unparseDed(assumeLetDed(_)) = "Assume-Let ded!"
| unparseDed(absurdDed(_)) = "Absurd ded!"
| unparseDed(tryDed(_)) = "Try ded!"
| unparseDed(absurdLetDed(_)) = "Absurd-Let ded!"
| unparseDed(inductionDed(_)) = "Induction ded!"
| unparseDed(structureCasesDed(_)) = "Structure-Cases ded!"
| unparseDed(byDed(_)) = "By ded!"
| unparseDed(fromDed(_)) = "From ded!"
| unparseDed(genOverDed(_)) = "Gen-over ded!"
| unparseDed(pickAnyDed(_)) = "Pick-any ded!"
| unparseDed(withWitnessDed(_)) = "With-witness ded!"
| unparseDed(pickWitnessDed(_)) = "Pick-witness ded!"
| unparseDed(pickWitnessesDed(_)) = "Pick-witnesses ded!"
and unparsePhrase(exp(e)) = unparseExp(e)
| unparsePhrase(ded(d)) = unparseDed(d)
and
Expand Down
1 change: 0 additions & 1 deletion athena.grm
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ deduction: LPAREN expression BY deduction RPAREN (A.byDed({wanted_res=expressio
(A.byCasesDed({disj=phrase,from_exps=NONE,
arms=case_clauses,pos=getPos BY_CASESleft}))


| BY_CASES phrase FROM comma_separated_expression_list BEGIN case_clauses END
(A.byCasesDed({disj=phrase,from_exps=SOME(comma_separated_expression_list),
arms=case_clauses,pos=getPos BY_CASESleft}))
Expand Down
1 change: 1 addition & 0 deletions athena.mlb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ in
smt_output.sml
compiler.sml
server.sml
simp.sml
topenv_part1.sml
topenv_part2.sml
definition_processor.sml
Expand Down
4 changes: 4 additions & 0 deletions athena.sml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ fun run() = let val _ = Options.first_time := true
in runWithStarterFile(NONE) end

(**
fun run() = let val _ = Options.first_time := true
in ExpressServer.startServerOnPort(10000) end
**)
(**

-- XSB-specific code, commented out by default:

Expand Down
1 change: 1 addition & 0 deletions base.sig
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sig
val writeString: string * char Array.array * int -> int
val remove : ''a * ''a list -> ''a list
val removeAll : ''a list * ''a list -> ''a list
val removeAllEq : 'a list * 'a list * ('a * 'a -> bool) -> 'a list
val removeEq : 'a * 'a list * ('a * 'a ->bool) -> 'a list
val removeAndCheckMemEq : 'a * 'a list * ('a * 'a ->bool) -> ('a list * bool)
val zip : 'a list * 'b list -> ('a * 'b) list
Expand Down
8 changes: 8 additions & 0 deletions base.sml
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,21 @@ fun removeAll(L1,L2) =
loop(L1,L2)
end


fun removeEq(x,l,eq) =
let fun remove([],res) = res
| remove(y::ys,res) = if eq(x,y) then remove(ys,res) else remove(ys,y::res)
in
remove(l,[])
end

fun removeAllEq(L1,L2,f) =
let fun loop([],res) = res
| loop(x::more,res) = loop(more,removeEq(x,res,f))
in
loop(L1,L2)
end

(* removeAndCheckMemEq also does not preserve order: *)

fun removeAndCheckMemEq(x,l,eq) =
Expand Down
53 changes: 53 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import sys
sys.path.append('/mnt/c/code/python')
from utils1 import *
import socket

def send_request_to_server(request: str,port=10000) -> str:
# Define server address and port
server_address = 'localhost'
# Create a TCP/IP socket
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
# Connect to the server
sock.connect((server_address, port))
try:
# Send the request string encoded as bytes
sock.sendall(request.encode('utf-8'))
# Receive the response from the server
response = sock.recv(4096) # Buffer size is 4096 bytes
# Decode the response from bytes to a string
return response.decode('utf-8')
except Exception as e:
print(f"An error occurred: {e}")
return ""

# Usage example
# Usage example
#response = send_request_to_server("Hello, server!")


s = "(plus 1 2)"
request = s
b = s.encode('utf-8')
port = 10000
server_address = 'localhost'
#sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)


s = '''let {_ := (process-input-from-string "declare A, B, C, D, E, F, G, H: Boolean")}
assume h := (A & B) {
(!both (!right-and h) (!left-and h))
}
'''

#send_request_to_server('(process-input-from-string "(declare (A B C D E F G H) Boolean)")')

s = '''assume h := (A & B)
(!both (!right-and h) (!left-and h))
'''


s = '''assume h := (A & B)
(!both (!dn h) (!left-and h))
'''

9 changes: 6 additions & 3 deletions definition_processor.sml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ val pprint = TopEnv.pprint
val top_assum_base = ABase.top_assum_base

fun addPropToGlobalAb(p,mod_path,string_opt) =
(top_assum_base := ABase.insert(p,!top_assum_base);
let
in
(top_assum_base := ABase.insertAlongWithConjuncts(p,!top_assum_base);
P.addToModuleAb(mod_path,p,string_opt);
top_assum_base := ABase.addAssertion(p,!top_assum_base))
top_assum_base := ABase.addAssertionAlongWithConjuncts(p,!top_assum_base))
end

fun addPropsToGlobalAb(props,mod_path,string_opt) = List.app (fn p => addPropToGlobalAb(p,mod_path,string_opt)) props
val top_val_env = SV.top_val_env
Expand Down Expand Up @@ -1281,7 +1284,7 @@ fun printVal(Semantics.propVal(p),(true,_)) =

fun addProp(v as Semantics.propVal(p),env,eval_env,(is_ded,name_opt),mod_path,definition_sym_opt) =
if is_ded then
(top_assum_base := ABase.augment(!top_assum_base,[p]);
(top_assum_base := ABase.insertAlongWithConjuncts(p,!top_assum_base);
(case (name_opt,definition_sym_opt) of
(SOME(name),_) => (Semantics.updateTopValEnv(env,name,v,true);Semantics.updateTopValEnv(eval_env,name,v,true);P.addToModuleAb(mod_path,p,SOME(S.name(name))))
| (_,SOME(name)) => (Semantics.updateTopValEnv(env,name,v,true);Semantics.updateTopValEnv(eval_env,name,v,true);P.addToModuleAb(mod_path,p,SOME(S.name(name))))
Expand Down
Loading
Loading